vendor: 4,269 bytes, lines 1-2
1/*! For license information please see main.fae3918b.js.LICENSE.txt */ 2(()=>{"use strict";var e={4(e,t,n){var a=n(853),r=n(43),s=n(950);function i(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!==(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function c(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function d(e){if(31===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function u(e){if(l(e)!==e)throw Error(i(188))}function m(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=m(e)))return t;e=e.sibling}return null}var p=Object.assign,h=Symbol.for("react.element"),f=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),w=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),D=Symbol.for("react.lazy");Symbol.for("react.scope");var C=Symbol.for("react.activity");Symbol.for("react.legacy_hidden"),Symbol.for("react.tracing_marker");var A=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var S=Symbol.iterator;function E(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=S&&e[S]||e["@@iterator"])?e:null}var F=Symbol.for("react.client.reference");function R(e){if(null==e)return null;if("function"===typeof e)return e.$$typeof===F?null:e.displayName||e.name||null;if("string"===typeof e)return e;switch(e){case v:return"Fragment";case y:return"Profiler";case g:return"StrictMode";case k:return"Suspense";case N:return"SuspenseList";case C:return"Activity"}if("object"===typeof e)switch(e.$$typeof){case x:return"Portal";case w:return e.displayName||"Context";case b:return(e._context.displayName||"Context")+".Consumer";case j:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case _:return null!==(t=e.displayName||null)?t:R(e.type)||"Memo";case D:t=e._payload,e=e._init;try{return R(e(t))}catch(oK){}}return null}var I=Array.isArray,T=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O={pending:!1,data:null,method:null,action:null},B=[],L=-1;function M(e){return{current:e}}function z(e){0>L||(e.current=B[L],B[L]=null,L--)}function U(e,t){L++,B[L]=e.current,e.current=t}var V,q,W=M(null),H=M(null),G=M(null),K=M(null);function Y(e,t){switch(U(G,t),U(H,e),U(W,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?gu(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=yu(t=gu(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}z(W),U(W,e)}function J(){z(W),z(H),z(G)}function $(e){null!==e.memoizedState&&U(K,e);var t=W.current,n=yu(t,e.type);t!==n&&(U(H,e),U(W,n))}function X(e){H.current===e&&(z(W),z(H)),K.current===e&&(z(K),um._currentValue=O)}function Q(e){if(void 0===V)try{throw Error()}catch(oK){var t=oK.stack.trim().match(/\n( *(at )?)/);V=t&&t[1]||"",q=-1<oK.stack.indexOf("\n at")?" (<anonymous>)":-1<oK.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+V+e+q}var Z=!1;function ee(e,t){if(!e||Z)return"";Z=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"===typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(oK){var a=oK}Reflect.construct(e,[],n)}
vendor: 5,951 bytes, line 2
2else{try{n.call()}catch(r){a=r}e.call(n.prototype)}}else{try{throw Error()}catch(s){a=s}(n=e())&&"function"===typeof n.catch&&n.catch(function(){})}}catch(i){if(i&&a&&"string"===typeof i.stack)return[i.stack,a.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var s=a.DetermineComponentFrameRoot(),i=s[0],o=s[1];if(i&&o){var l=i.split("\n"),c=o.split("\n");for(r=a=0;a<l.length&&!l[a].includes("DetermineComponentFrameRoot");)a++;for(;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;if(a===l.length||r===c.length)for(a=l.length-1,r=c.length-1;1<=a&&0<=r&&l[a]!==c[r];)r--;for(;1<=a&&0<=r;a--,r--)if(l[a]!==c[r]){if(1!==a||1!==r)do{if(a--,0>--r||l[a]!==c[r]){var d="\n"+l[a].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),d}}while(1<=a&&0<=r);break}}}finally{Z=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?Q(n):""}function te(e,t){switch(e.tag){case 26:case 27:case 5:return Q(e.type);case 16:return Q("Lazy");case 13:return e.child!==t&&null!==t?Q("Suspense Fallback"):Q("Suspense");case 19:return Q("SuspenseList");case 0:case 15:return ee(e.type,!1);case 11:return ee(e.type.render,!1);case 1:return ee(e.type,!0);case 31:return Q("Activity");default:return""}}function ne(e){try{var t="",n=null;do{t+=te(e,n),n=e,e=e.return}while(e);return t}catch(oK){return"\nError generating stack: "+oK.message+"\n"+oK.stack}}var ae=Object.prototype.hasOwnProperty,re=a.unstable_scheduleCallback,se=a.unstable_cancelCallback,ie=a.unstable_shouldYield,oe=a.unstable_requestPaint,le=a.unstable_now,ce=a.unstable_getCurrentPriorityLevel,de=a.unstable_ImmediatePriority,ue=a.unstable_UserBlockingPriority,me=a.unstable_NormalPriority,pe=a.unstable_LowPriority,he=a.unstable_IdlePriority,fe=a.log,xe=a.unstable_setDisableYieldValue,ve=null,ge=null;function ye(e){if("function"===typeof fe&&xe(e),ge&&"function"===typeof ge.setStrictMode)try{ge.setStrictMode(ve,e)}catch(t){}}var be=Math.clz32?Math.clz32:function(e){return e>>>=0,0===e?32:31-(we(e)/je|0)|0},we=Math.log,je=Math.LN2;var ke=256,Ne=262144,_e=4194304;function De(e){var t=42&e;if(0!==t)return t;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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ce(e,t,n){var a=e.pendingLanes;if(0===a)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes;e=e.warmLanes;var o=134217727&a;return 0!==o?0!==(a=o&~s)?r=De(a):0!==(i&=o)?r=De(i):n||0!==(n=o&~e)&&(r=De(n)):0!==(o=a&~s)?r=De(o):0!==i?r=De(i):n||0!==(n=a&~e)&&(r=De(n)),0===r?0:0!==t&&t!==r&&0===(t&s)&&((s=r&-r)>=(n=t&-t)||32===s&&0!==(4194048&n))?t:r}function Ae(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Se(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function Ee(){var e=_e;return 0===(62914560&(_e<<=1))&&(_e=4194304),e}function Fe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Re(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ie(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-be(t);e.entangledLanes|=t,e.entanglements[a]=1073741824|e.entanglements[a]|261930&n}function Te(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var a=31-be(n),r=1<<a;r&t|e[a]&t&&(e[a]|=t),n&=~r}}function Pe(e,t){var n=t&-t;return 0!==((n=0!==(42&n)?1:Oe(n))&(e.suspendedLanes|t))?0:n}function Oe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Be(e){return 2<(e&=-e)?8<e?0!==(134217727&e)?32:268435456:8:2}function Le(){var e=P.p;return 0!==e?e:void 0===(e=window.event)?32:Cm(e.type)}function Me(e,t){var n=P.p;try{return P.p=e,t()}finally{P.p=n}}var ze=Math.random().toString(36).slice(2),Ue="__reactFiber$"+ze,Ve="__reactProps$"+ze,qe="__reactContainer$"+ze,We="__reactEvents$"+ze,He="__reactListeners$"+ze,Ge="__reactHandles$"+ze,Ke="__reactResources$"+ze,Ye="__reactMarker$"+ze;function Je(e){delete e[Ue],delete e[Ve],delete e[We],delete e[He],delete e[Ge]}function $e(e){var t=e[Ue];if(t)return t;for(var n=e.parentNode;n;){if(t=n[qe]||n[Ue]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Bu(e);null!==e;){if(n=e[Ue])return n;e=Bu(e)}return t}n=(e=n).parentNode}return null}function Xe(e){if(e=e[Ue]||e[qe]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function Qe(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(i(33))}function Ze(e){var t=e[Ke];return t||(t=e[Ke]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function et(e){e[Ye]=!0}var tt=new Set,nt={};function at(e,t){rt(e,t),rt(e+"Capture",t)}function rt(e,t){for(nt[e]=t,e=0;e<t.length;e++)tt.add(t[e])}var st=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u
2037D\\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]*$"),it={},ot={};function lt(e,t,n){if(r=t,ae.call(ot,r)||!ae.call(it,r)&&(st.test(r)?ot[r]=!0:(it[r]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var a=t.toLowerCase().slice(0,5);if("data-"!==a&&"aria-"!==a)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var r}function ct(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function dt(e,t,n,a){if(null===a)e.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+a)}}function ut(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function mt(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function pt(e){if(!e._valueTracker){var t=mt(e)?"checked":"value";e._valueTracker=function(e,t,n){var a=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&"undefined"!==typeof a&&"function"===typeof a.get&&"function"===typeof a.set){var r=a.get,s=a.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(e){n=""+e,s.call(this,e)}}),Object.defineProperty(e,t,{enumerable:a.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function ht(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),a="";return e&&(a=mt(e)?e.checked?"true":"false":e.value),(e=a)!==n&&(t.setValue(e),!0)}function ft(e){if("undefined"===typeof(e=e||("undefined"!==typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var xt=/[\n"\\]/g;function vt(e){return e.replace(xt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function gt(e,t,n,a,r,s,i,o){e.name="",null!=i&&"function"!==typeof i&&"symbol"!==typeof i&&"boolean"!==typeof i?e.type=i:e.removeAttribute("type"),null!=t?"number"===i?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ut(t)):e.value!==""+ut(t)&&(e.value=""+ut(t)):"submit"!==i&&"reset"!==i||e.removeAttribute("value"),null!=t?bt(e,i,ut(t)):null!=n?bt(e,i,ut(n)):null!=a&&e.removeAttribute("value"),null==r&&null!=s&&(e.defaultChecked=!!s),null!=r&&(e.checked=r&&"function"!==typeof r&&"symbol"!==typeof r),null!=o&&"function"!==typeof o&&"symbol"!==typeof o&&"boolean"!==typeof o?e.name=""+ut(o):e.removeAttribute("name")}function yt(e,t,n,a,r,s,i,o){if(null!=s&&"function"!==typeof s&&"symbol"!==typeof s&&"boolean"!==typeof s&&(e.type=s),null!=t||null!=n){if(!("submit"!==s&&"reset"!==s||void 0!==t&&null!==t))return void pt(e);n=null!=n?""+ut(n):"",t=null!=t?""+ut(t):n,o||t===e.value||(e.value=t),e.defaultValue=t}a="function"!==typeof(a=null!=a?a:r)&&"symbol"!==typeof a&&!!a,e.checked=o?e.checked:!!a,e.defaultChecked=!!a,null!=i&&"function"!==typeof i&&"symbol"!==typeof i&&"boolean"!==typeof i&&(e.name=i),pt(e)}function bt(e,t,n){"number"===t&&ft(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function wt(e,t,n,a){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&a&&(e[n].defaultSelected=!0)}else{for(n=""+ut(n),t=null,r=0;r<e.length;r++){if(e[r].value===n)return e[r].selected=!0,void(a&&(e[r].defaultSelected=!0));null!==t||e[r].disabled||(t=e[r])}null!==t&&(t.selected=!0)}}function jt(e,t,n){null==t||((t=""+ut(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ut(n):"":e.defaultValue!==t&&(e.defaultValue=t)}
vendor: 4,421 bytes, line 2
2function kt(e,t,n,a){if(null==t){if(null!=a){if(null!=n)throw Error(i(92));if(I(a)){if(1<a.length)throw Error(i(93));a=a[0]}n=a}null==n&&(n=""),t=n}n=ut(t),e.defaultValue=n,(a=e.textContent)===n&&""!==a&&null!==a&&(e.value=a),pt(e)}function Nt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var _t=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Dt(e,t,n){var a=0===t.indexOf("--");null==n||"boolean"===typeof n||""===n?a?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":a?e.setProperty(t,n):"number"!==typeof n||0===n||_t.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Ct(e,t,n){if(null!=t&&"object"!==typeof t)throw Error(i(62));if(e=e.style,null!=n){for(var a in n)!n.hasOwnProperty(a)||null!=t&&t.hasOwnProperty(a)||(0===a.indexOf("--")?e.setProperty(a,""):"float"===a?e.cssFloat="":e[a]="");for(var r in t)a=t[r],t.hasOwnProperty(r)&&n[r]!==a&&Dt(e,r,a)}else for(var s in t)t.hasOwnProperty(s)&&Dt(e,s,t[s])}function At(e){if(-1===e.indexOf("-"))return!1;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 St=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode
2-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Et=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Ft(e){return Et.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Rt(){}var It=null;function Tt(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Pt=null,Ot=null;function Bt(e){var t=Xe(e);if(t&&(e=t.stateNode)){var n=e[Ve]||null;e:switch(e=t.stateNode,t.type){case"input":if(gt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+vt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var r=a[Ve]||null;if(!r)throw Error(i(90));gt(a,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name)}}for(t=0;t<n.length;t++)(a=n[t]).form===e.form&&ht(a)}break e;case"textarea":jt(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&wt(e,!!n.multiple,t,!1)}}}var Lt=!1;function Mt(e,t,n){if(Lt)return e(t,n);Lt=!0;try{return e(t)}finally{if(Lt=!1,(null!==Pt||null!==Ot)&&(ed(),Pt&&(t=Pt,e=Ot,Ot=Pt=null,Bt(t),e)))for(t=0;t<e.length;t++)Bt(e[t])}}function zt(e,t){var n=e.stateNode;if(null===n)return null;var a=n[Ve]||null;if(null===a)return null;n=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(a=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!a;break e;default:e=!1}if(e)return null;if(n&&"function"!==typeof n)throw Error(i(231,t,typeof n));return n}var Ut=!("undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement),Vt=!1;if(Ut)try{var qt={};Object.defineProperty(qt,"passive",{get:function(){Vt=!0}}),window.addEventListener("test",qt,qt),window.removeEventListener("test",qt,qt)}catch(Qm){Vt=!1}var Wt=null,Ht=null,Gt=null;function Kt(){if(Gt)return Gt;var e,t,n=Ht,a=n.length,r="value"in Wt?Wt.value:Wt.textContent,s=r.length;for(e=0;e<a&&n[e]===r[e];e++);var i=a-e;for(t=1;t<=i&&n[a-t]===r[s-t];t++);return Gt=r.slice(e,1<t?1-t:void 0)}function Yt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function Jt(){return!0}function $t(){return!1}function Xt(e){function t(t,n,a,r,s){for(var i in this._reactName=t,this._targetInst=a,this.type=n,this.nativeEvent=r,this.target=s,this.currentTarget=null,e)e.hasOwnProperty(i)&&(t=e[i],this[i]=t?t(r):r[i]);return this.isDefaultPrevented=(null!=r.defaultPrevented?r.defaultPrevented:!1===r.returnValue)?Jt:$t,this.isPropagationStopped=$t,this}return p(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!==typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Jt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!==typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Jt)},persist:function(){},isPersistent:Jt}),t}var Qt,Zt,en,tn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},nn=Xt(tn),an=p({},tn,{view:0,detail:0}),rn=Xt(an),sn=p({},an,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.from
vendor: 4,410 bytes, line 2
2Element===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==en&&(en&&"mousemove"===e.type?(Qt=e.screenX-en.screenX,Zt=e.screenY-en.screenY):Zt=Qt=0,en=e),Qt)},movementY:function(e){return"movementY"in e?e.movementY:Zt}}),on=Xt(sn),ln=Xt(p({},sn,{dataTransfer:0})),cn=Xt(p({},an,{relatedTarget:0})),dn=Xt(p({},tn,{animationName:0,elapsedTime:0,pseudoElement:0})),un=Xt(p({},tn,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),mn=Xt(p({},tn,{data:0})),pn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},fn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=fn[e])&&!!t[e]}function vn(){return xn}var gn=p({},an,{key:function(e){if(e.key){var t=pn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Yt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?hn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vn,charCode:function(e){return"keypress"===e.type?Yt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Yt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),yn=Xt(gn),bn=Xt(p({},sn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),wn=Xt(p({},an,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vn})),jn=Xt(p({},tn,{propertyName:0,elapsedTime:0,pseudoElement:0})),kn=Xt(p({},sn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Nn=Xt(p({},tn,{newState:0,oldState:0})),_n=[9,13,27,32],Dn=Ut&&"CompositionEvent"in window,Cn=null;Ut&&"documentMode"in document&&(Cn=document.documentMode);var An=Ut&&"TextEvent"in window&&!Cn,Sn=Ut&&(!Dn||Cn&&8<Cn&&11>=Cn),En=String.fromCharCode(32),Fn=!1;function Rn(e,t){switch(e){case"keyup":return-1!==_n.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function In(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var Tn=!1;var Pn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function On(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Pn[e.type]:"textarea"===t}function Bn(e,t,n,a){Pt?Ot?Ot.push(a):Ot=[a]:Pt=a,0<(t=ru(t,"onChange")).length&&(n=new nn("onChange","change",null,n,a),e.push({event:n,listeners:t}))}var Ln=null,Mn=null;function zn(e){$d(e,0)}function Un(e){if(ht(Qe(e)))return e}function Vn(e,t){if("change"===e)return t}var qn=!1;if(Ut){var Wn;if(Ut){var Hn="oninput"in document;if(!Hn){var Gn=document.createElement("div");Gn.setAttribute("oninput","return;"),Hn="function"===typeof Gn.oninput}Wn=Hn}else Wn=!1;qn=Wn&&(!document.documentMode||9<document.documentMode)}function Kn(){Ln&&(Ln.detachEvent("onpropertychange",Yn),Mn=Ln=null)}function Yn(e){if("value"===e.propertyName&&Un(Mn)){var t=[];Bn(t,Mn,e,Tt(e)),Mt(zn,t)}}function Jn(e,t,n){"focusin"===e?(Kn(),Mn=n,(Ln=t).attachEvent("onpropertychange",Yn)):"focusout"===e&&Kn()}function $n(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Un(Mn)}function Xn(e,t){if("click"===e)return Un(t)}function Qn(e,t){if("input"===e||"change"===e)return Un(t)}var Zn="function"===typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e===1/t)||e!==e&&t!==t};function ea(e,t){if(Zn(e,t))return!0;
2if("object"!==typeof e||null===e||"object"!==typeof t||null===t)return!1;var n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(a=0;a<n.length;a++){var r=n[a];if(!ae.call(t,r)||!Zn(e[r],t[r]))return!1}return!0}function ta(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function na(e,t){var n,a=ta(e);for(e=0;a;){if(3===a.nodeType){if(n=e+a.textContent.length,e<=t&&n>=t)return{node:a,offset:t-e};e=n}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=ta(a)}}function aa(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?aa(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ra(e){for(var t=ft((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"===typeof t.contentWindow.location.href}catch(a){n=!1}if(!n)break;t=ft((e=t.contentWindow).document)}return t}function sa(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var ia=Ut&&"documentMode"in document&&11>=document.documentMode,oa=null,la=null,ca=null,da=!1;function ua(e,t,n){var a=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;da||null==oa||oa!==ft(a)||("selectionStart"in(a=oa)&&sa(a)?a={start:a.selectionStart,end:a.selectionEnd}:a={anchorNode:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset},ca&&ea(ca,a)||(ca=a,0<(a=ru(la,"onSelect")).length&&(t=new nn("onSelect","select",null,t,n),e.push({event:t,listeners:a}),t.target=oa)))}function ma(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var pa={animationend:ma("Animation","AnimationEnd"),animationiteration:ma("Animation","AnimationIteration"),animationstart:ma("Animation","AnimationStart"),transitionrun:ma("Transition","TransitionRun"),transitionstart:ma("Transition","TransitionStart"),transitioncancel:ma("Transition","TransitionCancel"),transitionend:ma("Transition","TransitionEnd")},ha={},fa={};function xa(e){if(ha[e])return ha[e];if(!pa[e])return e;var t,n=pa[e];for(t in n)if(n.hasOwnProperty(t)&&t in fa)return ha[e]=n[t];return e}Ut&&(fa=document.createElement("div").style,"AnimationEvent"in window||(delete pa.animationend.animation,delete pa.animationiteration.animation,delete pa.animationstart.animation),"TransitionEvent"in window||delete pa.transitionend.transition);var va=xa("animationend"),ga=xa("animationiteration"),ya=xa("animationstart"),ba=xa("transitionrun"),wa=xa("transitionstart"),ja=xa("transitioncancel"),ka=xa("transitionend"),Na=new Map,_a="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Da(e,t){Na.set(e,t),at(t,[e])}_a.push("scrollEnd");var Ca="function"===typeof reportError?reportError:function(e){if("object"===typeof window&&"function"===typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"===typeof e&&null!==e&&"string"===typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"===typeof process&&"function"===typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},Aa=[],Sa=0,Ea=0;function Fa(){for(var e=Sa,t=Ea=Sa=0;t<e;){var n=Aa[t];Aa[t++]=null;var a=Aa[t];Aa[t++]=null;var r=Aa[t];Aa[t++]=null;var s=Aa[t];if(Aa[t++]=null,null!==a&&null!==r){var i=a.pending;
vendor: 12,744 bytes, line 2
2null===i?r.next=r:(r.next=i.next,i.next=r),a.pending=r}0!==s&&Pa(n,r,s)}}function Ra(e,t,n,a){Aa[Sa++]=e,Aa[Sa++]=t,Aa[Sa++]=n,Aa[Sa++]=a,Ea|=a,e.lanes|=a,null!==(e=e.alternate)&&(e.lanes|=a)}function Ia(e,t,n,a){return Ra(e,t,n,a),Oa(e)}function Ta(e,t){return Ra(e,null,null,t),Oa(e)}function Pa(e,t,n){e.lanes|=n;var a=e.alternate;null!==a&&(a.lanes|=n);for(var r=!1,s=e.return;null!==s;)s.childLanes|=n,null!==(a=s.alternate)&&(a.childLanes|=n),22===s.tag&&(null===(e=s.stateNode)||1&e._visibility||(r=!0)),e=s,s=s.return;return 3===e.tag?(s=e.stateNode,r&&null!==t&&(r=31-be(n),null===(a=(e=s.hiddenUpdates)[r])?e[r]=[t]:a.push(t),t.lane=536870912|n),s):null}function Oa(e){if(50<Hc)throw Hc=0,Gc=null,Error(i(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Ba={};function La(e,t,n,a){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ma(e,t,n,a){return new La(e,t,n,a)}function za(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Ua(e,t){var n=e.alternate;return null===n?((n=Ma(e.tag,t,e.key,e.mode)).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=65011712&e.flags,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=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Va(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function qa(e,t,n,a,r,s){var o=0;if(a=e,"function"===typeof e)za(e)&&(o=1);else if("string"===typeof e)o=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!==typeof t.precedence||"string"!==typeof t.href||""===t.href)break;return!0;case"link":if("string"!==typeof t.rel||"string"!==typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"===typeof t.precedence&&null==e);case"script":if(t.async&&"function"!==typeof t.async&&"symbol"!==typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"===typeof t.src)return!0}return!1}(e,n,W.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case C:return(e=Ma(31,n,t,r)).elementType=C,e.lanes=s,e;case v:return Wa(n.children,r,s,t);case g:o=8,r|=24;break;case y:return(e=Ma(12,n,t,2|r)).elementType=y,e.lanes=s,e;case k:return(e=Ma(13,n,t,r)).elementType=k,e.lanes=s,e;case N:return(e=Ma(19,n,t,r)).elementType=N,e.lanes=s,e;default:if("object"===typeof e&&null!==e)switch(e.$$typeof){case w:o=10;break e;case b:o=9;break e;case j:o=11;break e;case _:o=14;break e;case D:o=16,a=null;break e}o=29,n=Error(i(130,null===e?"null":typeof e,"")),a=null}return(t=Ma(o,n,t,r)).elementType=e,t.type=a,t.lanes=s,t}function Wa(e,t,n,a){return(e=Ma(7,e,a,t)).lanes=n,e}function Ha(e,t,n){return(e=Ma(6,e,null,t)).lanes=n,e}function Ga(e){var t=Ma(18,null,null,0);return t.stateNode=e,t}function Ka(e,t,n){return(t=Ma(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Ya=new WeakMap;function Ja(e,t){if("object"===typeof e&&null!==e){var n=Ya.get(e);return void 0!==n?n:(t={value:e,source:t,stack:ne(t)},Ya.set(e,t),t)}return{value:e,source:t,stack:ne(t)}}var $a=[],Xa=0,Qa=null,Za=0,er=[],tr=0,nr=null,ar=1,rr="";function sr(e,t){$a[Xa++]=Za,$a[Xa++]=Qa,Qa=e,Za=t}function ir(e,t,n){er[tr++]=ar,er[tr++]=rr,er[tr++]=nr,nr=e;var a=ar;e=rr;var r=32-be(a)-1;a&=~(1<<r),n+=1;var s=32-be(t)+r;if(30<s){var i=r-r%5;s=(a&(1<<i)-1).toString(32),a>>=i,r-=i,ar=1<<32-be(t)+r|n<<r|a,rr=s+e}else ar=1<<s|n<<r|a,rr=e}function or(e){null!==e.return&&(sr(e,1),ir(e,1,0))}function lr(e){for(;e===Qa;)Qa=$a[--Xa],$a[Xa]=null,Za=$a[--Xa],$a[Xa]=null;for(;e===nr;)nr=er[--tr],er[tr]=null,rr=er[--tr],er[tr]=null,ar=er[--tr],er[tr]=null}function cr(e,t){er[tr++]=ar,er[tr++]=rr,er[tr++]=nr,ar=t.id,rr=t.overflow,nr=e}var dr=null,ur=null,mr=!1,pr=null,hr=!1,fr=Error(i(519));function xr(e){throw jr(Ja(Error(i(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),fr}function vr(e){var t=e.stateNode,n=e.type,a=e.memoizedProps;switch(t[Ue]=e,t[Ve]=a,n){case"dialog":Xd("cancel",t),Xd("close",t);break;case"iframe":case"object":case"embed":Xd("load",t);break;case"video":case"audio":for(n=0;n<Yd.length;n++)Xd(Yd[n],t);break;case"source":Xd("error",t);break;case"img":case"image":case"link":Xd("error",t),Xd("load",t);break;case"details":Xd("toggle",t);break;case"input":Xd("invalid",t),yt(t,a.value,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name,!0);break;case"select":Xd("invalid",t);break;case"textarea":Xd("invalid",t),kt(t,a.value,a.defaultValue,a.children)}"string"!==typeof(n=a.children)&&"number"!==typeof n&&"bigint"!==typeof n||t.textContent===""+n||!0===a.suppressHydrationWarning||du(t.textContent,n)?(null!=a.popover&&(Xd("beforetoggle",t),Xd("toggle",t)),null!=a.onScroll&&Xd("scroll",t),null!=a.onScrollEnd&&Xd("scrollend",t),null!=a.onClick&&(t.onclick=Rt),t=!0):t=!1,t||xr(e,!0)}function gr(e){for(dr=e.return;dr;)switch(dr.tag){case 5:case 31:case 13:return void(hr=!1);case 27:case 3:return void(hr=!0);default:dr=dr.return}}function yr(e){if(e!==dr)return!1;if(!mr)return gr(e),mr=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||bu(e.type,e.memoizedProps)),t=!t),t&&ur&&xr(e),gr(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));ur=Ou(e)}else if(31===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));ur=Ou(e)}else 27===n?(n=ur,Cu(e.type)?(e=Pu,Pu=null,ur=e):ur=n):ur=dr?Tu(e.stateNode.nextSibling):null;return!0}function br(){ur=dr=null,mr=!1}function wr(){var e=pr;return null!==e&&(null===Fc?Fc=e:Fc.push.apply(Fc,e),pr=null),e}function jr(e){null===pr?pr=[e]:pr.push(e)}var kr=M(null),Nr=null,_r=null;function Dr(e,t,n){U(kr,t._currentValue),t._currentValue=n}function Cr(e){e._currentValue=kr.current,z(kr)}function Ar(e,t,n){for(;null!==e;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==a&&(a.childLanes|=t)):null!==a&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===n)break;e=e.return}}function Sr(e,t,n,a){var r=e.child;for(null!==r&&(r.return=e);null!==r;){var s=r.dependencies;if(null!==s){var o=r.child;s=s.firstContext;e:for(;null!==s;){var l=s;s=r;for(var c=0;c<t.length;c++)if(l.context===t[c]){s.lanes|=n,null!==(l=s.alternate)&&(l.lanes|=n),Ar(s.return,n,e),a||(o=null);break e}s=l.next}}else if(18===r.tag){if(null===(o=r.return))throw Error(i(341));o.lanes|=n,null!==(s=o.alternate)&&(s.lanes|=n),Ar(o,n,e),o=null}else o=r.child;if(null!==o)o.return=r;else for(o=r;null!==o;){if(o===e){o=null;break}if(null!==(r=o.sibling)){r.return=o.return,o=r;break}o=o.return}r=o}}function Er(e,t,n,a){e=null;for(var r=t,s=!1;null!==r;){if(!s)if(0!==(524288&r.flags))s=!0;else if(0!==(262144&r.flags))break;if(10===r.tag){var o=r.alternate;if(null===o)throw Error(i(387));if(null!==(o=o.memoizedProps)){var l=r.type;Zn(r.pendingProps.value,o.value)||(null!==e?e.push(l):e=[l])}}else if(r===K.current){if(null===(o=r.alternate))throw Error(i(387));o.memoizedState.memoizedState!==r.memoizedState.memoizedState&&(null!==e?e.push(um):e=[um])}r=r.return}null!==e&&Sr(t,e,n,a),t.flags|=262144}function Fr(e){for(e=e.firstContext;null!==e;){if(!Zn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Rr(e){Nr=e,_r=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Ir(e){return Pr(Nr,e)}function Tr(e,t){return null===Nr&&Rr(e),Pr(e,t)}function Pr(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===_r){if(null===e)throw Error(i(308));_r=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else _r=_r.next=t;return n}var Or="undefined"!==typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Br=a.unstable_scheduleCallback,Lr=a.unstable_NormalPriority,Mr={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function zr(){return{controller:new Or,data:new Map,refCount:0}}function Ur(e){e.refCount--,0===e.refCount&&Br(Lr,function(){e.controller.abort()})}var Vr=null,qr=0,Wr=0,Hr=null;function Gr(){if(0===--qr&&null!==Vr){null!==Hr&&(Hr.status="fulfilled");var e=Vr;Vr=null,Wr=0,Hr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Kr=T.S;T.S=function(e,t){Tc=le(),"object"===typeof t&&null!==t&&"function"===typeof t.then&&function(e,t){if(null===Vr){var n=Vr=[];qr=0,Wr=qd(),Hr={status:"pending",value:void 0,then:function(e){n.push(e)}}}qr++,t.then(Gr,Gr)}(0,t),null!==Kr&&Kr(e,t)};var Yr=M(null);function Jr(){var e=Yr.current;return null!==e?e:fc.pooledCache}function $r(e,t){U(Yr,null===t?Yr.current:t.pool)}function Xr(){var e=Jr();return null===e?null:{parent:Mr._currentValue,pool:e}}var Qr=Error(i(460)),Zr=Error(i(474)),es=Error(i(542)),ts={then:function(){}};function ns(e){return"fulfilled"===(e=e.status)||"rejected"===e}function as(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(Rt,Rt),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw os(e=t.reason),e;default:if("string"===typeof t.status)t.then(Rt,Rt);else{if(null!==(e=fc)&&100<e.shellSuspendCounter)throw Error(i(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw os(e=t.reason),e}throw ss=t,Qr}}function rs(e){try{return(0,e._init)(e._payload)}catch(oK){if(null!==oK&&"object"===typeof oK&&"function"===typeof oK.then)throw ss=oK,Qr;throw oK}}var ss=null;function is(){if(null===ss)throw Error(i(459));var e=ss;return ss=null,e}function os(e){if(e===Qr||e===es)throw Error(i(483))}var ls=null,cs=0;function ds(e){var t=cs;return cs+=1,null===ls&&(ls=[]),as(ls,e,t)}function us(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function ms(e,t){if(t.$$typeof===h)throw Error(i(525));throw e=Object.prototype.toString.call(t),Error(i(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ps(e){function t(t,n){if(e){var a=t.deletions;null===a?(t.deletions=[n],t.flags|=16):a.push(n)}}function n(n,a){if(!e)return null;for(;null!==a;)t(n,a),a=a.sibling;return null}function a(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function r(e,t){return(e=Ua(e,t)).index=0,e.sibling=null,e}function s(t,n,a){return t.index=a,e?null!==(a=t.alternate)?(a=a.index)<n?(t.flags|=67108866,n):a:(t.flags|=67108866,n):(t.flags|=1048576,n)}function o(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function l(e,t,n,a){return null===t||6!==t.tag?((t=Ha(n,e.mode,a)).return=e,t):((t=r(t,n)).return=e,t)}function c(e,t,n,a){var s=n.type;return s===v?u(e,t,n.props.children,a,n.key):null!==t&&(t.elementType===s||"object"===typeof s&&null!==s&&s.$$typeof===D&&rs(s)===t.type)?(us(t=r(t,n.props),n),t.return=e,t):(us(t=qa(n.type,n.key,n.props,null,e.mode,a),n),t.return=e,t)}function d(e,t,n,a){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Ka(n,e.mode,a)).return=e,t):((t=r(t,n.children||[])).return=e,t)}function u(e,t,n,a,s){return null===t||7!==t.tag?((t=Wa(n,e.mode,a,s)).return=e,t):((t=r(t,n)).return=e,t)}function m(e,t,n){if("string"===typeof t&&""!==t||"number"===typeof t||"bigint"===typeof t)return(t=Ha(""+t,e.mode,n)).return=e,t;if("object"===typeof t&&null!==t){switch(t.$$typeof){case f:return us(n=qa(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case x:return(t=Ka(t,e.mode,n)).return=e,t;
2case D:return m(e,t=rs(t),n)}if(I(t)||E(t))return(t=Wa(t,e.mode,n,null)).return=e,t;if("function"===typeof t.then)return m(e,ds(t),n);if(t.$$typeof===w)return m(e,Tr(e,t),n);ms(e,t)}return null}function p(e,t,n,a){var r=null!==t?t.key:null;if("string"===typeof n&&""!==n||"number"===typeof n||"bigint"===typeof n)return null!==r?null:l(e,t,""+n,a);if("object"===typeof n&&null!==n){switch(n.$$typeof){case f:return n.key===r?c(e,t,n,a):null;case x:return n.key===r?d(e,t,n,a):null;case D:return p(e,t,n=rs(n),a)}if(I(n)||E(n))return null!==r?null:u(e,t,n,a,null);if("function"===typeof n.then)return p(e,t,ds(n),a);if(n.$$typeof===w)return p(e,t,Tr(e,n),a);ms(e,n)}return null}function h(e,t,n,a,r){if("string"===typeof a&&""!==a||"number"===typeof a||"bigint"===typeof a)return l(t,e=e.get(n)||null,""+a,r);if("object"===typeof a&&null!==a){switch(a.$$typeof){case f:return c(t,e=e.get(null===a.key?n:a.key)||null,a,r);case x:return d(t,e=e.get(null===a.key?n:a.key)||null,a,r);case D:return h(e,t,n,a=rs(a),r)}if(I(a)||E(a))return u(t,e=e.get(n)||null,a,r,null);if("function"===typeof a.then)return h(e,t,n,ds(a),r);if(a.$$typeof===w)return h(e,t,n,Tr(t,a),r);ms(t,a)}return null}function g(l,c,d,u){if("object"===typeof d&&null!==d&&d.type===v&&null===d.key&&(d=d.props.children),"object"===typeof d&&null!==d){switch(d.$$typeof){case f:e:{for(var y=d.key;null!==c;){if(c.key===y){if((y=d.type)===v){if(7===c.tag){n(l,c.sibling),(u=r(c,d.props.children)).return=l,l=u;break e}}else if(c.elementType===y||"object"===typeof y&&null!==y&&y.$$typeof===D&&rs(y)===c.type){n(l,c.sibling),us(u=r(c,d.props),d),u.return=l,l=u;break e}n(l,c);break}t(l,c),c=c.sibling}d.type===v?((u=Wa(d.props.children,l.mode,u,d.key)).return=l,l=u):(us(u=qa(d.type,d.key,d.props,null,l.mode,u),d),u.return=l,l=u)}return o(l);case x:e:{for(y=d.key;null!==c;){if(c.key===y){if(4===c.tag&&c.stateNode.containerInfo===d.containerInfo&&c.stateNode.implementation===d.implementation){n(l,c.sibling),(u=r(c,d.children||[])).return=l,l=u;break e}n(l,c);break}t(l,c),c=c.sibling}(u=Ka(d,l.mode,u)).return=l,l=u}return o(l);case D:return g(l,c,d=rs(d),u)}if(I(d))return function(r,i,o,l){for(var c=null,d=null,u=i,f=i=0,x=null;null!==u&&f<o.length;f++){u.index>f?(x=u,u=null):x=u.sibling;var v=p(r,u,o[f],l);if(null===v){null===u&&(u=x);break}e&&u&&null===v.alternate&&t(r,u),i=s(v,i,f),null===d?c=v:d.sibling=v,d=v,u=x}if(f===o.length)return n(r,u),mr&&sr(r,f),c;if(null===u){for(;f<o.length;f++)null!==(u=m(r,o[f],l))&&(i=s(u,i,f),null===d?c=u:d.sibling=u,d=u);return mr&&sr(r,f),c}for(u=a(u);f<o.length;f++)null!==(x=h(u,r,f,o[f],l))&&(e&&null!==x.alternate&&u.delete(null===x.key?f:x.key),i=s(x,i,f),null===d?c=x:d.sibling=x,d=x);return e&&u.forEach(function(e){return t(r,e)}),mr&&sr(r,f),c}(l,c,d,u);if(E(d)){if("function"!==typeof(y=E(d)))throw Error(i(150));return function(r,o,l,c){if(null==l)throw Error(i(151));for(var d=null,u=null,f=o,x=o=0,v=null,g=l.next();null!==f&&!g.done;x++,g=l.next()){f.index>x?(v=f,f=null):v=f.sibling;var y=p(r,f,g.value,c);if(null===y){null===f&&(f=v);break}e&&f&&null===y.alternate&&t(r,f),o=s(y,o,x),null===u?d=y:u.sibling=y,u=y,f=v}if(g.done)return n(r,f),mr&&sr(r,x),d;if(null===f){for(;!g.done;x++,g=l.next())null!==(g=m(r,g.value,c))&&(o=s(g,o,x),null===u?d=g:u.sibling=g,u=g);return mr&&sr(r,x),d}for(f=a(f);!g.done;x++,g=l.next())null!==(g=h(f,r,x,g.value,c))&&(e&&null!==g.alternate&&f.delete(null===g.key?x:g.key),o=s(g,o,x),null===u?d=g:u.sibling=g,u=g);return e&&f.forEach(function(e){return t(r,e)}),mr&&sr(r,x),d}(l,c,d=y.call(d),u)}if("function"===typeof d.then)return g(l,c,ds(d),u);if(d.$$typeof===w)return g(l,c,Tr(l,d),u);ms(l,d)}return"string"===typeof d&&""!==d||"number"===typeof d||"bigint"===typeof d?(d=""+d,null!==c&&6===c.tag?(n(l,c.sibling),(u=r(c,d)).return=l,l=u):(n(l,c),(u=Ha(d,l.mode,u)).return=l,l=u),o(l)):n(l,c)}return function(e,t,n,a){try{cs=0;var r=g(e,t,n,a);return ls=null,r}catch(oK){if(oK===Qr||oK===es)throw oK;var s=Ma(29,oK,null,e.mode);return s.lanes=a,s.return=e,s}}}var hs=ps(!0),fs=ps(!1),xs=!1;function vs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function gs(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ys(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function bs(e,t,n){var a=e.updateQueue;if(null===a)return null;if(a=a.shared,0!==(2&hc)){var r=a.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),a.pending=t,t=Oa(e),Pa(e,null,n),t}return Ra(e,a,t,n),Oa(e)}
vendor: 25,625 bytes, line 2
2function ws(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,0!==(4194048&n))){var a=t.lanes;n|=a&=e.pendingLanes,t.lanes=n,Te(e,n)}}function js(e,t){var n=e.updateQueue,a=e.alternate;if(null!==a&&n===(a=a.updateQueue)){var r=null,s=null;if(null!==(n=n.firstBaseUpdate)){do{var i={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===s?r=s=i:s=s.next=i,n=n.next}while(null!==n);null===s?r=s=t:s=s.next=t}else r=s=t;return n={baseState:a.baseState,firstBaseUpdate:r,lastBaseUpdate:s,shared:a.shared,callbacks:a.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var ks=!1;function Ns(){if(ks){if(null!==Hr)throw Hr}}function _s(e,t,n,a){ks=!1;var r=e.updateQueue;xs=!1;var s=r.firstBaseUpdate,i=r.lastBaseUpdate,o=r.shared.pending;if(null!==o){r.shared.pending=null;var l=o,c=l.next;l.next=null,null===i?s=c:i.next=c,i=l;var d=e.alternate;null!==d&&((o=(d=d.updateQueue).lastBaseUpdate)!==i&&(null===o?d.firstBaseUpdate=c:o.next=c,d.lastBaseUpdate=l))}if(null!==s){var u=r.baseState;for(i=0,d=c=l=null,o=s;;){var m=-536870913&o.lane,h=m!==o.lane;if(h?(vc&m)===m:(a&m)===m){0!==m&&m===Wr&&(ks=!0),null!==d&&(d=d.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var f=e,x=o;m=t;var v=n;switch(x.tag){case 1:if("function"===typeof(f=x.payload)){u=f.call(v,u,m);break e}u=f;break e;case 3:f.flags=-65537&f.flags|128;case 0:if(null===(m="function"===typeof(f=x.payload)?f.call(v,u,m):f)||void 0===m)break e;u=p({},u,m);break e;case 2:xs=!0}}null!==(m=o.callback)&&(e.flags|=64,h&&(e.flags|=8192),null===(h=r.callbacks)?r.callbacks=[m]:h.push(m))}else h={lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===d?(c=d=h,l=u):d=d.next=h,i|=m;if(null===(o=o.next)){if(null===(o=r.shared.pending))break;o=(h=o).next,h.next=null,r.lastBaseUpdate=h,r.shared.pending=null}}null===d&&(l=u),r.baseState=l,r.firstBaseUpdate=c,r.lastBaseUpdate=d,null===s&&(r.shared.lanes=0),_c|=i,e.lanes=i,e.memoizedState=u}}function Ds(e,t){if("function"!==typeof e)throw Error(i(191,e));e.call(t)}function Cs(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)Ds(n[e],t)}var As=M(null),Ss=M(0);function Es(e,t){U(Ss,e=kc),U(As,t),kc=e|t.baseLanes}function Fs(){U(Ss,kc),U(As,As.current)}function Rs(){kc=Ss.current,z(As),z(Ss)}var Is=M(null),Ts=null;function Ps(e){var t=e.alternate;U(zs,1&zs.current),U(Is,e),null===Ts&&(null===t||null!==As.current||null!==t.memoizedState)&&(Ts=e)}function Os(e){U(zs,zs.current),U(Is,e),null===Ts&&(Ts=e)}function Bs(e){22===e.tag?(U(zs,zs.current),U(Is,e),null===Ts&&(Ts=e)):Ls()}function Ls(){U(zs,zs.current),U(Is,Is.current)}function Ms(e){z(Is),Ts===e&&(Ts=null),z(zs)}var zs=M(0);function Us(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Ru(n)||Iu(n)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(0!==(128&t.flags))return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Vs=0,qs=null,Ws=null,Hs=null,Gs=!1,Ks=!1,Ys=!1,Js=0,$s=0,Xs=null,Qs=0;function Zs(){throw Error(i(321))}function ei(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Zn(e[n],t[n]))return!1;return!0}function ti(e,t,n,a,r,s){return Vs=s,qs=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,T.H=null===e||null===e.memoizedState?vo:go,Ys=!1,s=n(a,r),Ys=!1,Ks&&(s=ai(t,n,a,r)),ni(e),s}function ni(e){T.H=xo;var t=null!==Ws&&null!==Ws.next;if(Vs=0,Hs=Ws=qs=null,Gs=!1,$s=0,Xs=null,t)throw Error(i(300));null===e||To||null!==(e=e.dependencies)&&Fr(e)&&(To=!0)}function ai(e,t,n,a){qs=e;var r=0;do{if(Ks&&(Xs=null),$s=0,Ks=!1,25<=r)throw Error(i(301));if(r+=1,Hs=Ws=null,null!=e.updateQueue){var s=e.updateQueue;s.lastEffect=null,s.events=null,s.stores=null,null!=s.memoCache&&(s.memoCache.index=0)}T.H=yo,s=t(n,a)}while(Ks);return s}function ri(){var e=T.H,t=e.useState()[0];return t="function"===typeof t.then?di(t):t,e=e.useState()[0],(null!==Ws?Ws.memoizedState:null)!==e&&(qs.flags|=1024),t}function si(){var e=0!==Js;return Js=0,e}function ii(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function oi(e){if(Gs){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Gs=!1}Vs=0,Hs=Ws=qs=null,Ks=!1,$s=Js=0,Xs=null}function li(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Hs?qs.memoizedState=Hs=e:Hs=Hs.next=e,Hs}function ci(){if(null===Ws){var e=qs.alternate;e=null!==e?e.memoizedState:null}else e=Ws.next;var t=null===Hs?qs.memoizedState:Hs.next;if(null!==t)Hs=t,Ws=e;else{if(null===e){if(null===qs.alternate)throw Error(i(467));throw Error(i(310))}e={memoizedState:(Ws=e).memoizedState,baseState:Ws.baseState,baseQueue:Ws.baseQueue,queue:Ws.queue,next:null},null===Hs?qs.memoizedState=Hs=e:Hs=Hs.next=e}return Hs}function di(e){var t=$s;return $s+=1,null===Xs&&(Xs=[]),e=as(Xs,e,t),t=qs,null===(null===Hs?t.memoizedState:Hs.next)&&(t=t.alternate,T.H=null===t||null===t.memoizedState?vo:go),e}function ui(e){if(null!==e&&"object"===typeof e){if("function"===typeof e.then)return di(e);if(e.$$typeof===w)return Ir(e)}throw Error(i(438,String(e)))}function mi(e){var t=null,n=qs.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var a=qs.alternate;null!==a&&(null!==(a=a.updateQueue)&&(null!=(a=a.memoCache)&&(t={data:a.data.map(function(e){return e.slice()}),index:0})))}if(null==t&&(t={data:[],index:0}),null===n&&(n={lastEffect:null,events:null,stores:null,memoCache:null},qs.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),a=0;a<e;a++)n[a]=A;return t.index++,n}function pi(e,t){return"function"===typeof t?t(e):t}function hi(e){return fi(ci(),Ws,e)}function fi(e,t,n){var a=e.queue;if(null===a)throw Error(i(311));a.lastRenderedReducer=n;var r=e.baseQueue,s=a.pending;if(null!==s){if(null!==r){var o=r.next;r.next=s.next,s.next=o}t.baseQueue=r=s,a.pending=null}if(s=e.baseState,null===r)e.memoizedState=s;else{var l=o=null,c=null,d=t=r.next,u=!1;do{var m=-536870913&d.lane;if(m!==d.lane?(vc&m)===m:(Vs&m)===m){var p=d.revertLane;if(0===p)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),m===Wr&&(u=!0);else{if((Vs&p)===p){d=d.next,p===Wr&&(u=!0);continue}m={lane:0,revertLane:d.revertLane,gesture:null,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null},null===c?(l=c=m,o=s):c=c.next=m,qs.lanes|=p,_c|=p}m=d.action,Ys&&n(s,m),s=d.hasEagerState?d.eagerState:n(s,m)}else p={lane:m,revertLane:d.revertLane,gesture:d.gesture,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null},null===c?(l=c=p,o=s):c=c.next=p,qs.lanes|=m,_c|=m;d=d.next}while(null!==d&&d!==t);if(null===c?o=s:c.next=l,!Zn(s,e.memoizedState)&&(To=!0,u&&null!==(n=Hr)))throw n;e.memoizedState=s,e.baseState=o,e.baseQueue=c,a.lastRenderedState=s}return null===r&&(a.lanes=0),[e.memoizedState,a.dispatch]}function xi(e){var t=ci(),n=t.queue;if(null===n)throw Error(i(311));n.lastRenderedReducer=e;var a=n.dispatch,r=n.pending,s=t.memoizedState;if(null!==r){n.pending=null;var o=r=r.next;do{s=e(s,o.action),o=o.next}while(o!==r);Zn(s,t.memoizedState)||(To=!0),t.memoizedState=s,null===t.baseQueue&&(t.baseState=s),n.lastRenderedState=s}return[s,a]}function vi(e,t,n){var a=qs,r=ci(),s=mr;if(s){if(void 0===n)throw Error(i(407));n=n()}else n=t();var o=!Zn((Ws||r).memoizedState,n);if(o&&(r.memoizedState=n,To=!0),r=r.queue,Vi(bi.bind(null,a,r,e),[e]),r.getSnapshot!==t||o||null!==Hs&&1&Hs.memoizedState.tag){if(a.flags|=2048,Bi(9,{destroy:void 0},yi.bind(null,a,r,n,t),null),null===fc)throw Error(i(349));s||0!==(127&Vs)||gi(a,t,n)}return n}function gi(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=qs.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},qs.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function yi(e,t,n,a){t.value=n,t.getSnapshot=a,wi(t)&&ji(e)}function bi(e,t,n){return n(function(){wi(t)&&ji(e)})}function wi(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Zn(e,n)}catch(a){return!0}}function ji(e){var t=Ta(e,2);null!==t&&Jc(t,e,2)}function ki(e){var t=li();if("function"===typeof e){var n=e;if(e=n(),Ys){ye(!0);try{n()}finally{ye(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:pi,lastRenderedState:e},t}function Ni(e,t,n,a){return e.baseState=n,fi(e,Ws,"function"===typeof a?a:pi)}function _i(e,t,n,a,r){if(po(e))throw Error(i(485));if(null!==(e=t.action)){var s={payload:r,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){s.listeners.push(e)}};null!==T.T?n(!0):s.isTransition=!1,a(s),null===(n=t.pending)?(s.next=t.pending=s,Di(t,s)):(s.next=n.next,t.pending=n.next=s)}}function Di(e,t){var n=t.action,a=t.payload,r=e.state;if(t.isTransition){var s=T.T,i={};T.T=i;try{var o=n(r,a),l=T.S;null!==l&&l(i,o),Ci(e,t,o)}catch(c){Si(e,t,c)}finally{null!==s&&null!==i.types&&(s.types=i.types),T.T=s}}else try{Ci(e,t,s=n(r,a))}catch(d){Si(e,t,d)}}function Ci(e,t,n){null!==n&&"object"===typeof n&&"function"===typeof n.then?n.then(function(n){Ai(e,t,n)},function(n){return Si(e,t,n)}):Ai(e,t,n)}function Ai(e,t,n){t.status="fulfilled",t.value=n,Ei(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,Di(e,n)))}function Si(e,t,n){var a=e.pending;if(e.pending=null,null!==a){a=a.next;do{t.status="rejected",t.reason=n,Ei(t),t=t.next}while(t!==a)}e.action=null}function Ei(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Fi(e,t){return t}function Ri(e,t){if(mr){var n=fc.formState;if(null!==n){e:{var a=qs;if(mr){if(ur){t:{for(var r=ur,s=hr;8!==r.nodeType;){if(!s){r=null;break t}if(null===(r=Tu(r.nextSibling))){r=null;break t}}r="F!"===(s=r.data)||"F"===s?r:null}if(r){ur=Tu(r.nextSibling),a="F!"===r.data;break e}}xr(a)}a=!1}a&&(t=n[0])}}return(n=li()).memoizedState=n.baseState=t,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fi,lastRenderedState:t},n.queue=a,n=co.bind(null,qs,a),a.dispatch=n,a=ki(!1),s=mo.bind(null,qs,!1,a.queue),r={state:t,dispatch:null,action:e,pending:null},(a=li()).queue=r,n=_i.bind(null,qs,r,s,n),r.dispatch=n,a.memoizedState=e,[t,n,!1]}function Ii(e){return Ti(ci(),Ws,e)}function Ti(e,t,n){if(t=fi(e,t,Fi)[0],e=hi(pi)[0],"object"===typeof t&&null!==t&&"function"===typeof t.then)try{var a=di(t)}catch(oK){if(oK===Qr)throw es;throw oK}else a=t;var r=(t=ci()).queue,s=r.dispatch;return n!==t.memoizedState&&(qs.flags|=2048,Bi(9,{destroy:void 0},Pi.bind(null,r,n),null)),[a,s,e]}function Pi(e,t){e.action=t}function Oi(e){var t=ci(),n=Ws;if(null!==n)return Ti(t,n,e);ci(),t=t.memoizedState;var a=(n=ci()).queue.dispatch;return n.memoizedState=e,[t,a,!1]}function Bi(e,t,n,a){return e={tag:e,create:n,deps:a,inst:t,next:null},null===(t=qs.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},qs.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(a=n.next,n.next=e,e.next=a,t.lastEffect=e),e}function Li(){return ci().memoizedState}function Mi(e,t,n,a){var r=li();qs.flags|=e,r.memoizedState=Bi(1|t,{destroy:void 0},n,void 0===a?null:a)}function zi(e,t,n,a){var r=ci();a=void 0===a?null:a;var s=r.memoizedState.inst;null!==Ws&&null!==a&&ei(a,Ws.memoizedState.deps)?r.memoizedState=Bi(t,s,n,a):(qs.flags|=e,r.memoizedState=Bi(1|t,s,n,a))}function Ui(e,t){Mi(8390656,8,e,t)}function Vi(e,t){zi(2048,8,e,t)}function qi(e){var t=ci().memoizedState;return function(e){qs.flags|=4;var t=qs.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},qs.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if(0!==(2&hc))throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Wi(e,t){return zi(4,2,e,t)}function Hi(e,t){return zi(4,4,e,t)}function Gi(e,t){if("function"===typeof t){e=e();var n=t(e);return function(){"function"===typeof n?n():t(null)}}if(null!==t&&void 0!==t)return e=e(),t.current=e,function(){t.current=null}}function Ki(e,t,n){n=null!==n&&void 0!==n?n.concat([e]):null,zi(4,4,Gi.bind(null,t,e),n)}function Yi(){}function Ji(e,t){var n=ci();t=void 0===t?null:t;var a=n.memoizedState;return null!==t&&ei(t,a[1])?a[0]:(n.memoizedState=[e,t],e)}function $i(e,t){var n=ci();t=void 0===t?null:t;var a=n.memoizedState;if(null!==t&&ei(t,a[1]))return a[0];if(a=e(),Ys){ye(!0);try{e()}finally{ye(!1)}}return n.memoizedState=[a,t],a}function Xi(e,t,n){return void 0===n||0!==(1073741824&Vs)&&0===(261930&vc)?e.memoizedState=t:(e.memoizedState=n,e=Yc(),qs.lanes|=e,_c|=e,n)}function Qi(e,t,n,a){return Zn(n,t)?n:null!==As.current?(e=Xi(e,n,a),Zn(e,t)||(To=!0),e):0===(42&Vs)||0!==(1073741824&Vs)&&0===(261930&vc)?(To=!0,e.memoizedState=n):(e=Yc(),qs.lanes|=e,_c|=e,t)}function Zi(e,t,n,a,r){var s=P.p;P.p=0!==s&&8>s?s:8;var i=T.T,o={};T.T=o,mo(e,!1,t,n);try{var l=r(),c=T.S;if(null!==c&&c(o,l),null!==l&&"object"===typeof l&&"function"===typeof l.then)uo(e,t,function(e,t){var n=[],a={status:"pending",value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){a.status="fulfilled",a.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(a.status="rejected",a.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),a}(l,a),Kc());else uo(e,t,a,Kc())}catch(d){uo(e,t,{then:function(){},status:"rejected",reason:d},Kc())}finally{P.p=s,null!==i&&null!==o.types&&(i.types=o.types),T.T=i}}function eo(){}function to(e,t,n,a){if(5!==e.tag)throw Error(i(476));var r=no(e).queue;Zi(e,r,t,O,null===n?eo:function(){return ao(e),n(a)})}function no(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:O,baseState:O,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:pi,lastRenderedState:O},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:pi,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function ao(e){var t=no(e);null===t.next&&(t=e.alternate.memoizedState),uo(e,t.next.queue,{},Kc())}function ro(){return Ir(um)}function so(){return ci().memoizedState}function io(){return ci().memoizedState}function oo(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Kc(),a=bs(t,e=ys(n),n);return null!==a&&(Jc(a,t,n),ws(a,t,n)),t={cache:zr()},void(e.payload=t)}t=t.return}}function lo(e,t,n){var a=Kc();n={lane:a,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},po(e)?ho(t,n):null!==(n=Ia(e,t,n,a))&&(Jc(n,e,a),fo(n,t,a))}function co(e,t,n){uo(e,t,n,Kc())}function uo(e,t,n,a){var r={lane:a,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(po(e))ho(t,r);else{var s=e.alternate;if(0===e.lanes&&(null===s||0===s.lanes)&&null!==(s=t.lastRenderedReducer))try{var i=t.lastRenderedState,o=s(i,n);if(r.hasEagerState=!0,r.eagerState=o,Zn(o,i))return Ra(e,t,r,0),null===fc&&Fa(),!1}catch(l){}if(null!==(n=Ia(e,t,r,a)))return Jc(n,e,a),fo(n,t,a),!0}return!1}function mo(e,t,n,a){if(a={lane:2,revertLane:qd(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},po(e)){if(t)throw Error(i(479))}else null!==(t=Ia(e,n,a,2))&&Jc(t,e,2)}function po(e){var t=e.alternate;return e===qs||null!==t&&t===qs}function ho(e,t){Ks=Gs=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function fo(e,t,n){if(0!==(4194048&n)){var a=t.lanes;n|=a&=e.pendingLanes,t.lanes=n,Te(e,n)}}var xo={readContext:Ir,use:ui,useCallback:Zs,useContext:Zs,useEffect:Zs,useImperativeHandle:Zs,useLayoutEffect:Zs,useInsertionEffect:Zs,useMemo:Zs,useReducer:Zs,useRef:Zs,useState:Zs,useDebugValue:Zs,useDeferredValue:Zs,useTransition:Zs,useSyncExternalStore:Zs,useId:Zs,useHostTransitionStatus:Zs,useFormState:Zs,useActionState:Zs,useOptimistic:Zs,useMemoCache:Zs,useCacheRefresh:Zs};xo.useEffectEvent=Zs;var vo={readContext:Ir,use:ui,useCallback:function(e,t){return li().memoizedState=[e,void 0===t?null:t],e},useContext:Ir,useEffect:Ui,useImperativeHandle:function(e,t,n){n=null!==n&&void 0!==n?n.concat([e]):null,Mi(4194308,4,Gi.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Mi(4194308,4,e,t)},useInsertionEffect:function(e,t){Mi(4,2,e,t)},useMemo:function(e,t){var n=li();t=void 0===t?null:t;var a=e();if(Ys){ye(!0);try{e()}finally{ye(!1)}}return n.memoizedState=[a,t],a},useReducer:function(e,t,n){var a=li();if(void 0!==n){var r=n(t);if(Ys){ye(!0);try{n(t)}finally{ye(!1)}}}else r=t;return a.memoizedState=a.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},a.queue=e,e=e.dispatch=lo.bind(null,qs,e),[a.memoizedState,e]},useRef:function(e){return e={current:e},li().memoizedState=e},useState:function(e){var t=(e=ki(e)).queue,n=co.bind(null,qs,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Yi,useDeferredValue:function(e,t){return Xi(li(),e,t)},useTransition:function(){var e=ki(!1);return e=Zi.bind(null,qs,e.queue,!0,!1),li().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var a=qs,r=li();if(mr){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===fc)throw Error(i(349));0!==(127&vc)||gi(a,t,n)}r.memoizedState=n;var s={value:n,getSnapshot:t};return r.queue=s,Ui(bi.bind(null,a,s,e),[e]),a.flags|=2048,Bi(9,{destroy:void 0},yi.bind(null,a,s,n,t),null),n},useId:function(){var e=li(),t=fc.identifierPrefix;if(mr){var n=rr;t="_"+t+"R_"+(n=(ar&~(1<<32-be(ar)-1)).toString(32)+n),0<(n=Js++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=Qs++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:ro,useFormState:Ri,useActionState:Ri,useOptimistic:function(e){var t=li();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=mo.bind(null,qs,!0,n),n.dispatch=t,[e,t]},useMemoCache:mi,useCacheRefresh:function(){return li().memoizedState=oo.bind(null,qs)},useEffectEvent:function(e){var t=li(),n={impl:e};return t.memoizedState=n,function(){if(0!==(2&hc))throw Error(i(440));return n.impl.apply(void 0,arguments)}}},go={readContext:Ir,use:ui,useCallback:Ji,useContext:Ir,useEffect:Vi,useImperativeHandle:Ki,useInsertionEffect:Wi,useLayoutEffect:Hi,useMemo:$i,useReducer:hi,useRef:Li,useState:function(){return hi(pi)},useDebugValue:Yi,useDeferredValue:function(e,t){return Qi(ci(),Ws.memoizedState,e,t)},useTransition:function(){var e=hi(pi)[0],t=ci().memoizedState;return["boolean"===typeof e?e:di(e),t]},useSyncExternalStore:vi,useId:so,useHostTransitionStatus:ro,useFormState:Ii,useActionState:Ii,useOptimistic:function(e,t){return Ni(ci(),0,e,t)},useMemoCache:mi,useCacheRefresh:io};go.useEffectEvent=qi;var yo={readContext:Ir,use:ui,useCallback:Ji,useContext:Ir,useEffect:Vi,useImperativeHandle:Ki,useInsertionEffect:Wi,useLayoutEffect:Hi,useMemo:$i,useReducer:xi,useRef:Li,useState:function(){return xi(pi)},useDebugValue:Yi,useDeferredValue:function(e,t){var n=ci();return null===Ws?Xi(n,e,t):Qi(n,Ws.memoizedState,e,t)},useTransition:function(){var e=xi(pi)[0],t=ci().memoizedState;return["boolean"===typeof e?e:di(e),t]},useSyncExternalStore:vi,useId:so,useHostTransitionStatus:ro,useFormState:Oi,useActionState:Oi,useOptimistic:function(e,t){var n=ci();return null!==Ws?Ni(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:mi,useCacheRefresh:io};function bo(e,t,n,a){n=null===(n=n(a,t=e.memoizedState))||void 0===n?t:p({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}yo.useEffectEvent=qi;var wo={enqueueSetState:function(e,t,n){e=e._reactInternals;var a=Kc(),r=ys(a);r.payload=t,void 0!==n&&null!==n&&(r.callback=n),null!==(t=bs(e,r,a))&&(Jc(t,e,a),ws(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var a=Kc(),r=ys(a);r.tag=1,r.payload=t,void 0!==n&&null!==n&&(r.callback=n),null!==(t=bs(e,r,a))&&(Jc(t,e,a),ws(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Kc(),a=ys(n);a.tag=2,void 0!==t&&null!==t&&(a.callback=t),null!==(t=bs(e,a,n))&&(Jc(t,e,n),ws(t,e,n))}};function jo(e,t,n,a,r,s,i){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(a,s,i):!t.prototype||!t.prototype.isPureReactComponent||(!ea(n,a)||!ea(r,s))}function ko(e,t,n,a){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,a),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,a),t.state!==e&&wo.enqueueReplaceState(t,t.state,null)}function No(e,t){var n=t;if("ref"in t)for(var a in n={},t)"ref"!==a&&(n[a]=t[a]);if(e=e.defaultProps)for(var r in n===t&&(n=p({},n)),e)void 0===n[r]&&(n[r]=e[r]);return n}function _o(e){Ca(e)}function Do(e){console.error(e)}function Co(e){Ca(e)}function Ao(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(n){setTimeout(function(){throw n})}}function So(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(a){setTimeout(function(){throw a})}}function Eo(e,t,n){return(n=ys(n)).tag=3,n.payload={element:null},n.callback=function(){Ao(e,t)},n}function Fo(e){return(e=ys(e)).tag=3,e}function Ro(e,t,n,a){var r=n.type.getDerivedStateFromError;if("function"===typeof r){var s=a.value;e.payload=function(){return r(s)},e.callback=function(){So(t,n,a)}}var i=n.stateNode;null!==i&&"function"===typeof i.componentDidCatch&&(e.callback=function(){So(t,n,a),"function"!==typeof r&&(null===Bc?Bc=new Set([this]):Bc.add(this));var e=a.stack;this.componentDidCatch(a.value,{componentStack:null!==e?e:""})})}var Io=Error(i(461)),To=!1;function Po(e,t,n,a){t.child=null===e?fs(t,null,n,a):hs(t,e.child,n,a)}function Oo(e,t,n,a,r){n=n.render;var s=t.ref;if("ref"in a){var i={};for(var o in a)"ref"!==o&&(i[o]=a[o])}else i=a;return Rr(t),a=ti(e,t,n,i,s,r),o=si(),null===e||To?(mr&&o&&or(t),t.flags|=1,Po(e,t,a,r),t.child):(ii(e,t,r),sl(e,t,r))}function Bo(e,t,n,a,r){if(null===e){var s=n.type;return"function"!==typeof s||za(s)||void 0!==s.defaultProps||null!==n.compare?((e=qa(n.type,null,a,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=s,Lo(e,t,s,a,r))}if(s=e.child,!il(e,r)){var i=s.memoizedProps;if((n=null!==(n=n.compare)?n:ea)(i,a)&&e.ref===t.ref)return sl(e,t,r)}return t.flags|=1,(e=Ua(s,a)).ref=t.ref,e.return=t,t.child=e}function Lo(e,t,n,a,r){if(null!==e){var s=e.memoizedProps;if(ea(s,a)&&e.ref===t.ref){if(To=!1,t.pendingProps=a=s,!il(e,r))return t.lanes=e.lanes,sl(e,t,r);0!==(131072&e.flags)&&(To=!0)}}return Ho(e,t,n,a,r)}function Mo(e,t,n,a){var r=a.children,s=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===a.mode){if(0!==(128&t.flags)){if(s=null!==s?s.baseLanes|n:n,null!==e){for(a=t.child=e.child,r=0;null!==a;)r=r|a.lanes|a.childLanes,a=a.sibling;a=r&~s}else a=0,t.child=null;return Uo(e,t,s,n,a)}if(0===(536870912&n))return a=t.lanes=536870912,Uo(e,t,null!==s?s.baseLanes|n:n,n,a);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&$r(0,null!==s?s.cachePool:null),null!==s?Es(t,s):Fs(),Bs(t)}else null!==s?($r(0,s.cachePool),Es(t,s),Ls(),t.memoizedState=null):(null!==e&&$r(0,null),Fs(),Ls());return Po(e,t,r,n),t.child}function zo(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Uo(e,t,n,a,r){var s=Jr();return s=null===s?null:{parent:Mr._currentValue,pool:s},t.memoizedState={baseLanes:n,cachePool:s},null!==e&&$r(0,null),Fs(),Bs(t),null!==e&&Er(e,t,a,!0),t.childLanes=r,null}function Vo(e,t){return(t=el({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function qo(e,t,n){return hs(t,e.child,null,n),(e=Vo(t,t.pendingProps)).flags|=2,Ms(t),t.memoizedState=null,e}function Wo(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!==typeof n&&"object"!==typeof n)throw Error(i(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Ho(e,t,n,a,r){return Rr(t),n=ti(e,t,n,a,void 0,r),a=si(),null===e||To?(mr&&a&&or(t),t.flags|=1,Po(e,t,n,r),t.child):(ii(e,t,r),sl(e,t,r))}function Go(e,t,n,a,r,s){return Rr(t),t.updateQueue=null,n=ai(t,a,n,r),ni(e),a=si(),null===e||To?(mr&&a&&or(t),t.flags|=1,Po(e,t,n,s),t.child):(ii(e,t,s),sl(e,t,s))}function Ko(e,t,n,a,r){if(Rr(t),null===t.stateNode){var s=Ba,i=n.contextType;"object"===typeof i&&null!==i&&(s=Ir(i)),s=new n(a,s),t.memoizedState=null!==s.state&&void 0!==s.state?s.state:null,s.updater=wo,t.stateNode=s,s._reactInternals=t,(s=t.stateNode).props=a,s.state=t.memoizedState,s.refs={},vs(t),i=n.contextType,s.context="object"===typeof i&&null!==i?Ir(i):Ba,s.state=t.memoizedState,"function"===typeof(i=n.getDerivedStateFromProps)&&(bo(t,n,i,a),s.state=t.memoizedState),"function"===typeof n.getDerivedStateFromProps||"function"===typeof s.getSnapshotBeforeUpdate||"function"!==typeof s.UNSAFE_componentWillMount&&"function"!==typeof s.componentWillMount||(i=s.state,"function"===typeof s.componentWillMount&&s.componentWillMount(),"function"===typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount(),i!==s.state&&wo.enqueueReplaceState(s,s.state,null),_s(t,a,s,r),Ns(),s.state=t.memoizedState),"function"===typeof s.componentDidMount&&(t.flags|=4194308),a=!0}
2else if(null===e){s=t.stateNode;var o=t.memoizedProps,l=No(n,o);s.props=l;var c=s.context,d=n.contextType;i=Ba,"object"===typeof d&&null!==d&&(i=Ir(d));var u=n.getDerivedStateFromProps;d="function"===typeof u||"function"===typeof s.getSnapshotBeforeUpdate,o=t.pendingProps!==o,d||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(o||c!==i)&&ko(t,s,a,i),xs=!1;var m=t.memoizedState;s.state=m,_s(t,a,s,r),Ns(),c=t.memoizedState,o||m!==c||xs?("function"===typeof u&&(bo(t,n,u,a),c=t.memoizedState),(l=xs||jo(t,n,l,a,m,c,i))?(d||"function"!==typeof s.UNSAFE_componentWillMount&&"function"!==typeof s.componentWillMount||("function"===typeof s.componentWillMount&&s.componentWillMount(),"function"===typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount()),"function"===typeof s.componentDidMount&&(t.flags|=4194308)):("function"===typeof s.componentDidMount&&(t.flags|=4194308),t.memoizedProps=a,t.memoizedState=c),s.props=a,s.state=c,s.context=i,a=l):("function"===typeof s.componentDidMount&&(t.flags|=4194308),a=!1)}else{s=t.stateNode,gs(e,t),d=No(n,i=t.memoizedProps),s.props=d,u=t.pendingProps,m=s.context,c=n.contextType,l=Ba,"object"===typeof c&&null!==c&&(l=Ir(c)),(c="function"===typeof(o=n.getDerivedStateFromProps)||"function"===typeof s.getSnapshotBeforeUpdate)||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(i!==u||m!==l)&&ko(t,s,a,l),xs=!1,m=t.memoizedState,s.state=m,_s(t,a,s,r),Ns();var p=t.memoizedState;i!==u||m!==p||xs||null!==e&&null!==e.dependencies&&Fr(e.dependencies)?("function"===typeof o&&(bo(t,n,o,a),p=t.memoizedState),(d=xs||jo(t,n,d,a,m,p,l)||null!==e&&null!==e.dependencies&&Fr(e.dependencies))?(c||"function"!==typeof s.UNSAFE_componentWillUpdate&&"function"!==typeof s.componentWillUpdate||("function"===typeof s.componentWillUpdate&&s.componentWillUpdate(a,p,l),"function"===typeof s.UNSAFE_componentWillUpdate&&s.UNSAFE_componentWillUpdate(a,p,l)),"function"===typeof s.componentDidUpdate&&(t.flags|=4),"function"===typeof s.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!==typeof s.componentDidUpdate||i===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!==typeof s.getSnapshotBeforeUpdate||i===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=a,t.memoizedState=p),s.props=a,s.state=p,s.context=l,a=d):("function"!==typeof s.componentDidUpdate||i===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!==typeof s.getSnapshotBeforeUpdate||i===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),a=!1)}return s=a,Wo(e,t),a=0!==(128&t.flags),s||a?(s=t.stateNode,n=a&&"function"!==typeof n.getDerivedStateFromError?null:s.render(),t.flags|=1,null!==e&&a?(t.child=hs(t,e.child,null,r),t.child=hs(t,null,n,r)):Po(e,t,n,r),t.memoizedState=s.state,e=t.child):e=sl(e,t,r),e}function Yo(e,t,n,a){return br(),t.flags|=256,Po(e,t,n,a),t.child}var Jo={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function $o(e){return{baseLanes:e,cachePool:Xr()}}function Xo(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=Ac),e}function Qo(e,t,n){var a,r=t.pendingProps,s=!1,o=0!==(128&t.flags);if((a=o)||(a=(null===e||null!==e.memoizedState)&&0!==(2&zs.current)),a&&(s=!0,t.flags&=-129),a=0!==(32&t.flags),t.flags&=-33,null===e){if(mr){if(s?Ps(t):Ls(),(e=ur)?null!==(e=null!==(e=Fu(e,hr))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==nr?{id:ar,overflow:rr}:null,retryLane:536870912,hydrationErrors:null},(n=Ga(e)).return=t,t.child=n,dr=t,ur=null):e=null,null===e)throw xr(t);return Iu(e)?t.lanes=32:t.lanes=536870912,null}var l=r.children;return r=r.fallback,s?(Ls(),l=el({mode:"hidden",children:l},s=t.mode),r=Wa(r,s,n,null),l.return=t,r.return=t,l.sibling=r,t.child=l,(r=t.child).memoizedState=$o(n),r.childLanes=Xo(e,a,n),t.memoizedState=Jo,zo(null,r)):(Ps(t),Zo(t,l))}var c=e.memoizedState;if(null!==c&&null!==(l=c.dehydrated)){if(o)256&t.flags?(Ps(t),t.flags&=-257,t=tl(e,t,n)):null!==t.memoizedState?(Ls(),t.child=e.child,t.flags|=128,t=null):(Ls(),l=r.fallback,s=t.mode,r=el({mode:"visible",children:r.children},s),(l=Wa(l,s,n,null)).flags|=2,r.return=t,l.return=t,r.sibling=l,t.child=r,hs(t,e.child,null,n),(r=t.child).memoizedState=$o(n),r.childLanes=Xo(e,a,n),t.memoizedState=Jo,t=zo(null,r));else if(Ps(t),Iu(l)){if(a=l.nextSibling&&l.nextSibling.dataset)var d=a.dgst;a=d,(r=Error(i(419))).stack="",r.digest=a,jr({value:r,source:null,stack:null}),t=tl(e,t,n)}else if(To||Er(e,t,n,!1),a=0!==(n&e.childLanes),To||a){if(null!==(a=fc)&&(0!==(r=Pe(a,n))&&r!==c.retryLane))throw c.retryLane=r,Ta(e,r),Jc(a,e,r),Io;Ru(l)||od(),t=tl(e,t,n)}else Ru(l)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,ur=Tu(l.nextSibling),dr=t,mr=!0,pr=null,hr=!1,null!==e&&cr(t,e),(t=Zo(t,r.children)).flags|=4096);return t}return s?(Ls(),l=r.fallback,s=t.mode,d=(c=e.child).sibling,(r=Ua(c,{mode:"hidden",children:r.children})).subtreeFlags=65011712&c.subtreeFlags,null!==d?l=Ua(d,l):(l=Wa(l,s,n,null)).flags|=2,l.return=t,r.return=t,r.sibling=l,t.child=r,zo(null,r),r=t.child,null===(l=e.child.memoizedState)?l=$o(n):(null!==(s=l.cachePool)?(c=Mr._currentValue,s=s.parent!==c?{parent:c,pool:c}
vendor: 4,443 bytes, line 2
2:s):s=Xr(),l={baseLanes:l.baseLanes|n,cachePool:s}),r.memoizedState=l,r.childLanes=Xo(e,a,n),t.memoizedState=Jo,zo(e.child,r)):(Ps(t),e=(n=e.child).sibling,(n=Ua(n,{mode:"visible",children:r.children})).return=t,n.sibling=null,null!==e&&(null===(a=t.deletions)?(t.deletions=[e],t.flags|=16):a.push(e)),t.child=n,t.memoizedState=null,n)}function Zo(e,t){return(t=el({mode:"visible",children:t},e.mode)).return=e,e.child=t}function el(e,t){return(e=Ma(22,e,null,t)).lanes=0,e}function tl(e,t,n){return hs(t,e.child,null,n),(e=Zo(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function nl(e,t,n){e.lanes|=t;var a=e.alternate;null!==a&&(a.lanes|=t),Ar(e.return,t,n)}function al(e,t,n,a,r,s){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:a,tail:n,tailMode:r,treeForkCount:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=a,i.tail=n,i.tailMode=r,i.treeForkCount=s)}function rl(e,t,n){var a=t.pendingProps,r=a.revealOrder,s=a.tail;a=a.children;var i=zs.current,o=0!==(2&i);if(o?(i=1&i|2,t.flags|=128):i&=1,U(zs,i),Po(e,t,a,n),a=mr?Za:0,!o&&null!==e&&0!==(128&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&nl(e,n,t);else if(19===e.tag)nl(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===Us(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),al(t,!1,r,n,s,a);break;case"backwards":case"unstable_legacy-backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===Us(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}al(t,!0,n,null,s,a);break;case"together":al(t,!1,null,null,void 0,a);break;default:t.memoizedState=null}return t.child}function sl(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),_c|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Er(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(i(153));if(null!==t.child){for(n=Ua(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Ua(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function il(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Fr(e))}function ol(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)To=!0;else{if(!il(e,n)&&0===(128&t.flags))return To=!1,function(e,t,n){switch(t.tag){case 3:Y(t,t.stateNode.containerInfo),Dr(0,Mr,e.memoizedState.cache),br();break;case 27:case 5:$(t);break;case 4:Y(t,t.stateNode.containerInfo);break;case 10:Dr(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Os(t),null;break;case 13:var a=t.memoizedState;if(null!==a)return null!==a.dehydrated?(Ps(t),t.flags|=128,null):0!==(n&t.child.childLanes)?Qo(e,t,n):(Ps(t),null!==(e=sl(e,t,n))?e.sibling:null);Ps(t);break;case 19:var r=0!==(128&e.flags);if((a=0!==(n&t.childLanes))||(Er(e,t,n,!1),a=0!==(n&t.childLanes)),r){if(a)return rl(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),U(zs,zs.current),a)break;return null;case 22:return t.lanes=0,Mo(e,t,n,t.pendingProps);case 24:Dr(0,Mr,e.memoizedState.cache)}return sl(e,t,n)}(e,t,n);To=0!==(131072&e.flags)}else To=!1,mr&&0!==(1048576&t.flags)&&ir(t,Za,t.index);switch(t.lanes=0,t.tag){case 16:e:{var a=t.pendingProps;if(e=rs(t.elementType),t.type=e,"function"!==typeof e){if(void 0!==e&&null!==e){var r=e.$$typeof;if(r===j){t.tag=11,t=Oo(null,t,e,a,n);break e}if(r===_){t.tag=14,t=Bo(null,t,e,a,n);break e}}throw t=R(e)||e,Error(i(306,t,""))}za(e)?(a=No(e,a),t.tag=1,t=Ko(null,t,e,a,n)):(t.tag=0,t=Ho(null,t,e,a,n))}return t;case 0:return Ho(e,t,t.type,t.pendingProps,n);case 1:return Ko(e,t,a=t.type,r=No(a,t.pendingProps),n);case 3:e:{if(Y(t,t.stateNode.containerInfo),null===e)throw Error(i(387));a=t.pendingProps;var s=t.memoizedState;r=s.element,gs(e,t),_s(t,a,null,n);var o=t.memoizedState;if(a=o.cache,Dr(0,Mr,a),a!==s.cache&&Sr(t,[Mr],n,!0),Ns(),a=o.element,s.isDehydrated){if(s={element:a,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=s,t.memoizedState=s,256&t.flags){t=Yo(e,t,a,n);break e}if(a!==r){jr(r=Ja(Error(i(424)),t)),t=Yo(e,t,a,n);break e}if(9===(e=t.stateNode.containerInfo).nodeType)e=e.body;
vendor: 42,727 bytes, line 2
2else e="HTML"===e.nodeName?e.ownerDocument.body:e;for(ur=Tu(e.firstChild),dr=t,mr=!0,pr=null,hr=!0,n=fs(t,null,a,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(br(),a===r){t=sl(e,t,n);break e}Po(e,t,a,n)}t=t.child}return t;case 26:return Wo(e,t),null===e?(n=Gu(t.type,null,t.pendingProps,null))?t.memoizedState=n:mr||(n=t.type,e=t.pendingProps,(a=vu(G.current).createElement(n))[Ue]=t,a[Ve]=e,pu(a,n,e),et(a),t.stateNode=a):t.memoizedState=Gu(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return $(t),null===e&&mr&&(a=t.stateNode=Lu(t.type,t.pendingProps,G.current),dr=t,hr=!0,r=ur,Cu(t.type)?(Pu=r,ur=Tu(a.firstChild)):ur=r),Po(e,t,t.pendingProps.children,n),Wo(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&mr&&((r=a=ur)&&(null!==(a=function(e,t,n,a){for(;1===e.nodeType;){var r=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!a&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(a){if(!e[Ye])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(s=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(s!==r.rel||e.getAttribute("href")!==(null==r.href||""===r.href?null:r.href)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin)||e.getAttribute("title")!==(null==r.title?null:r.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((s=e.getAttribute("src"))!==(null==r.src?null:r.src)||e.getAttribute("type")!==(null==r.type?null:r.type)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin))&&s&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var s=null==r.name?null:""+r.name;if("hidden"===r.type&&e.getAttribute("name")===s)return e}if(null===(e=Tu(e.nextSibling)))break}return null}(a,t.type,t.pendingProps,hr))?(t.stateNode=a,dr=t,ur=Tu(a.firstChild),hr=!1,r=!0):r=!1),r||xr(t)),$(t),r=t.type,s=t.pendingProps,o=null!==e?e.memoizedProps:null,a=s.children,bu(r,s)?a=null:null!==o&&bu(r,o)&&(t.flags|=32),null!==t.memoizedState&&(r=ti(e,t,ri,null,null,n),um._currentValue=r),Wo(e,t),Po(e,t,a,n),t.child;case 6:return null===e&&mr&&((e=n=ur)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=Tu(e.nextSibling)))return null}return e}(n,t.pendingProps,hr))?(t.stateNode=n,dr=t,ur=null,e=!0):e=!1),e||xr(t)),null;case 13:return Qo(e,t,n);case 4:return Y(t,t.stateNode.containerInfo),a=t.pendingProps,null===e?t.child=hs(t,null,a,n):Po(e,t,a,n),t.child;case 11:return Oo(e,t,t.type,t.pendingProps,n);case 7:return Po(e,t,t.pendingProps,n),t.child;case 8:case 12:return Po(e,t,t.pendingProps.children,n),t.child;case 10:return a=t.pendingProps,Dr(0,t.type,a.value),Po(e,t,a.children,n),t.child;case 9:return r=t.type._context,a=t.pendingProps.children,Rr(t),a=a(r=Ir(r)),t.flags|=1,Po(e,t,a,n),t.child;case 14:return Bo(e,t,t.type,t.pendingProps,n);case 15:return Lo(e,t,t.type,t.pendingProps,n);case 19:return rl(e,t,n);case 31:return function(e,t,n){var a=t.pendingProps,r=0!==(128&t.flags);if(t.flags&=-129,null===e){if(mr){if("hidden"===a.mode)return e=Vo(t,a),t.lanes=536870912,zo(null,e);if(Os(t),(e=ur)?null!==(e=null!==(e=Fu(e,hr))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==nr?{id:ar,overflow:rr}:null,retryLane:536870912,hydrationErrors:null},(n=Ga(e)).return=t,t.child=n,dr=t,ur=null):e=null,null===e)throw xr(t);return t.lanes=536870912,null}return Vo(t,a)}var s=e.memoizedState;if(null!==s){var o=s.dehydrated;if(Os(t),r)if(256&t.flags)t.flags&=-257,t=qo(e,t,n);else{if(null===t.memoizedState)throw Error(i(558));t.child=e.child,t.flags|=128,t=null}else if(To||Er(e,t,n,!1),r=0!==(n&e.childLanes),To||r){if(null!==(a=fc)&&0!==(o=Pe(a,n))&&o!==s.retryLane)throw s.retryLane=o,Ta(e,o),Jc(a,e,o),Io;od(),t=qo(e,t,n)}else e=s.treeContext,ur=Tu(o.nextSibling),dr=t,mr=!0,pr=null,hr=!1,null!==e&&cr(t,e),(t=Vo(t,a)).flags|=4096;return t}return(e=Ua(e.child,{mode:a.mode,children:a.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,n);case 22:return Mo(e,t,n,t.pendingProps);case 24:return Rr(t),a=Ir(Mr),null===e?(null===(r=Jr())&&(r=fc,s=zr(),r.pooledCache=s,s.refCount++,null!==s&&(r.pooledCacheLanes|=n),r=s),t.memoizedState={parent:a,cache:r},vs(t),Dr(0,Mr,r)):(0!==(e.lanes&n)&&(gs(e,t),_s(t,null,null,n),Ns()),r=e.memoizedState,s=t.memoizedState,r.parent!==a?(r={parent:a,cache:a},t.memoizedState=r,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=r),Dr(0,Mr,a)):(a=s.cache,Dr(0,Mr,a),a!==r.cache&&Sr(t,[Mr],n,!0))),Po(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function ll(e){e.flags|=4}function cl(e,t,n,a,r){if((t=0!==(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&r)===r)if(e.stateNode.complete)e.flags|=8192;else{if(!rd())throw ss=ts,Zr;e.flags|=8192}}else e.flags&=-16777217}function dl(e,t){if("stylesheet"!==t.type||0!==(4&t.state.loading))e.flags&=-16777217;else if(e.flags|=16777216,!sm(t)){if(!rd())throw ss=ts,Zr;e.flags|=8192}}function ul(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Ee():536870912,e.lanes|=t,Sc|=t)}function ml(e,t){if(!mr)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var a=null;null!==n;)null!==n.alternate&&(a=n),n=n.sibling;null===a?t||null===e.tail?e.tail=null:e.tail.sibling=null:a.sibling=null}}function pl(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,a=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,a|=65011712&r.subtreeFlags,a|=65011712&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,a|=r.subtreeFlags,a|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=a,e.childLanes=n,t}function hl(e,t,n){var a=t.pendingProps;switch(lr(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return pl(t),null;case 3:return n=t.stateNode,a=null,null!==e&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Cr(Mr),J(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(yr(t)?ll(t):null===e||e.memoizedState.isDehydrated&&0===(256&t.flags)||(t.flags|=1024,wr())),pl(t),null;case 26:var r=t.type,s=t.memoizedState;return null===e?(ll(t),null!==s?(pl(t),dl(t,s)):(pl(t),cl(t,r,0,0,n))):s?s!==e.memoizedState?(ll(t),pl(t),dl(t,s)):(pl(t),t.flags&=-16777217):((e=e.memoizedProps)!==a&&ll(t),pl(t),cl(t,r,0,0,n)),null;case 27:if(X(t),n=G.current,r=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&ll(t);else{if(!a){if(null===t.stateNode)throw Error(i(166));return pl(t),null}e=W.current,yr(t)?vr(t):(e=Lu(r,a,n),t.stateNode=e,ll(t))}return pl(t),null;case 5:if(X(t),r=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&ll(t);else{if(!a){if(null===t.stateNode)throw Error(i(166));return pl(t),null}if(s=W.current,yr(t))vr(t);else{var o=vu(G.current);switch(s){case 1:s=o.createElementNS("http://www.w3.org/2000/svg",r);break;case 2:s=o.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;default:switch(r){case"svg":s=o.createElementNS("http://www.w3.org/2000/svg",r);break;case"math":s=o.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;case"script":(s=o.createElement("div")).innerHTML="<script><\/script>",s=s.removeChild(s.firstChild);break;case"select":s="string"===typeof a.is?o.createElement("select",{is:a.is}):o.createElement("select"),a.multiple?s.multiple=!0:a.size&&(s.size=a.size);break;default:s="string"===typeof a.is?o.createElement(r,{is:a.is}):o.createElement(r)}}s[Ue]=t,s[Ve]=a;e:for(o=t.child;null!==o;){if(5===o.tag||6===o.tag)s.appendChild(o.stateNode);else if(4!==o.tag&&27!==o.tag&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;null===o.sibling;){if(null===o.return||o.return===t)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=s;e:switch(pu(s,r,a),r){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&ll(t)}}return pl(t),cl(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==a&&ll(t);else{if("string"!==typeof a&&null===t.stateNode)throw Error(i(166));if(e=G.current,yr(t)){if(e=t.stateNode,n=t.memoizedProps,a=null,null!==(r=dr))switch(r.tag){case 27:case 5:a=r.memoizedProps}e[Ue]=t,(e=!!(e.nodeValue===n||null!==a&&!0===a.suppressHydrationWarning||du(e.nodeValue,n)))||xr(t,!0)}else(e=vu(e).createTextNode(a))[Ue]=t,t.stateNode=e}return pl(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(a=yr(t),null!==n){if(null===e){if(!a)throw Error(i(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(i(557));e[Ue]=t}else br(),0===(128&t.flags)&&(t.memoizedState=null),t.flags|=4;pl(t),e=!1}else n=wr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(Ms(t),t):(Ms(t),null);if(0!==(128&t.flags))throw Error(i(558))}return pl(t),null;case 13:if(a=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(r=yr(t),null!==a&&null!==a.dehydrated){if(null===e){if(!r)throw Error(i(318));if(!(r=null!==(r=t.memoizedState)?r.dehydrated:null))throw Error(i(317));r[Ue]=t}else br(),0===(128&t.flags)&&(t.memoizedState=null),t.flags|=4;pl(t),r=!1}else r=wr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=r),r=!0;if(!r)return 256&t.flags?(Ms(t),t):(Ms(t),null)}return Ms(t),0!==(128&t.flags)?(t.lanes=n,t):(n=null!==a,e=null!==e&&null!==e.memoizedState,n&&(r=null,null!==(a=t.child).alternate&&null!==a.alternate.memoizedState&&null!==a.alternate.memoizedState.cachePool&&(r=a.alternate.memoizedState.cachePool.pool),s=null,null!==a.memoizedState&&null!==a.memoizedState.cachePool&&(s=a.memoizedState.cachePool.pool),s!==r&&(a.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),ul(t,t.updateQueue),pl(t),null);case 4:return J(),null===e&&eu(t.stateNode.containerInfo),pl(t),null;case 10:return Cr(t.type),pl(t),null;case 19:if(z(zs),null===(a=t.memoizedState))return pl(t),null;if(r=0!==(128&t.flags),null===(s=a.rendering))if(r)ml(a,!1);else{if(0!==Nc||null!==e&&0!==(128&e.flags))for(e=t.child;null!==e;){if(null!==(s=Us(e))){for(t.flags|=128,ml(a,!1),e=s.updateQueue,t.updateQueue=e,ul(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)Va(n,e),n=n.sibling;return U(zs,1&zs.current|2),mr&&sr(t,a.treeForkCount),t.child}e=e.sibling}null!==a.tail&&le()>Pc&&(t.flags|=128,r=!0,ml(a,!1),t.lanes=4194304)}else{if(!r)if(null!==(e=Us(s))){if(t.flags|=128,r=!0,e=e.updateQueue,t.updateQueue=e,ul(t,e),ml(a,!0),null===a.tail&&"hidden"===a.tailMode&&!s.alternate&&!mr)return pl(t),null}else 2*le()-a.renderingStartTime>Pc&&536870912!==n&&(t.flags|=128,r=!0,ml(a,!1),t.lanes=4194304);a.isBackwards?(s.sibling=t.child,t.child=s):(null!==(e=a.last)?e.sibling=s:t.child=s,a.last=s)}return null!==a.tail?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=le(),e.sibling=null,n=zs.current,U(zs,r?1&n|2:1&n),mr&&sr(t,a.treeForkCount),e):(pl(t),null);case 22:case 23:return Ms(t),Rs(),a=null!==t.memoizedState,null!==e?null!==e.memoizedState!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?0!==(536870912&n)&&0===(128&t.flags)&&(pl(t),6&t.subtreeFlags&&(t.flags|=8192)):pl(t),null!==(n=t.updateQueue)&&ul(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),a=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(a=t.memoizedState.cachePool.pool),a!==n&&(t.flags|=2048),null!==e&&z(Yr),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Cr(Mr),pl(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}function fl(e,t){switch(lr(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Cr(Mr),J(),0!==(65536&(e=t.flags))&&0===(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return X(t),null;case 31:if(null!==t.memoizedState){if(Ms(t),null===t.alternate)throw Error(i(340));br()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(Ms(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));br()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return z(zs),null;case 4:return J(),null;case 10:return Cr(t.type),null;case 22:case 23:return Ms(t),Rs(),null!==e&&z(Yr),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Cr(Mr),null;default:return null}}function xl(e,t){switch(lr(t),t.tag){case 3:Cr(Mr),J();break;case 26:case 27:case 5:X(t);break;case 4:J();break;case 31:null!==t.memoizedState&&Ms(t);break;case 13:Ms(t);break;case 19:z(zs);break;case 10:Cr(t.type);break;case 22:case 23:Ms(t),Rs(),null!==e&&z(Yr);break;case 24:Cr(Mr)}}function vl(e,t){try{var n=t.updateQueue,a=null!==n?n.lastEffect:null;if(null!==a){var r=a.next;n=r;do{if((n.tag&e)===e){a=void 0;var s=n.create,i=n.inst;a=s(),i.destroy=a}n=n.next}while(n!==r)}}catch(o){Nd(t,t.return,o)}}function gl(e,t,n){try{var a=t.updateQueue,r=null!==a?a.lastEffect:null;if(null!==r){var s=r.next;a=s;do{if((a.tag&e)===e){var i=a.inst,o=i.destroy;if(void 0!==o){i.destroy=void 0,r=t;var l=n,c=o;try{c()}catch(d){Nd(r,l,d)}}}a=a.next}while(a!==s)}}catch(d){Nd(t,t.return,d)}}function yl(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{Cs(t,n)}catch(a){Nd(e,e.return,a)}}}function bl(e,t,n){n.props=No(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(a){Nd(e,t,a)}}function wl(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;default:a=e.stateNode}"function"===typeof n?e.refCleanup=n(a):n.current=a}}catch(r){Nd(e,t,r)}}function jl(e,t){var n=e.ref,a=e.refCleanup;if(null!==n)if("function"===typeof a)try{a()}catch(r){Nd(e,t,r)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"===typeof n)try{n(null)}catch(s){Nd(e,t,s)}else n.current=null}function kl(e){var t=e.type,n=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&a.focus();break e;case"img":n.src?a.src=n.src:n.srcSet&&(a.srcset=n.srcSet)}}catch(r){Nd(e,e.return,r)}}function Nl(e,t,n){try{var a=e.stateNode;!function(e,t,n,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var r=null,s=null,o=null,l=null,c=null,d=null,u=null;for(h in n){var m=n[h];if(n.hasOwnProperty(h)&&null!=m)switch(h){case"checked":case"value":break;case"defaultValue":c=m;default:a.hasOwnProperty(h)||uu(e,t,h,null,a,m)}}for(var p in a){var h=a[p];if(m=n[p],a.hasOwnProperty(p)&&(null!=h||null!=m))switch(p){case"type":s=h;break;case"name":r=h;break;case"checked":d=h;break;case"defaultChecked":u=h;break;case"value":o=h;break;case"defaultValue":l=h;break;case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(i(137,t));break;default:h!==m&&uu(e,t,p,h,a,m)}}return void gt(e,o,l,c,d,u,s,r);case"select":for(s in h=o=l=p=null,n)if(c=n[s],n.hasOwnProperty(s)&&null!=c)switch(s){case"value":break;case"multiple":h=c;default:a.hasOwnProperty(s)||uu(e,t,s,null,a,c)}for(r in a)if(s=a[r],c=n[r],a.hasOwnProperty(r)&&(null!=s||null!=c))switch(r){case"value":p=s;break;case"defaultValue":l=s;break;case"multiple":o=s;default:s!==c&&uu(e,t,r,s,a,c)}return t=l,n=o,a=h,void(null!=p?wt(e,!!n,p,!1):!!a!==!!n&&(null!=t?wt(e,!!n,t,!0):wt(e,!!n,n?[]:"",!1)));case"textarea":for(l in h=p=null,n)if(r=n[l],n.hasOwnProperty(l)&&null!=r&&!a.hasOwnProperty(l))switch(l){case"value":case"children":break;default:uu(e,t,l,null,a,r)}for(o in a)if(r=a[o],s=n[o],a.hasOwnProperty(o)&&(null!=r||null!=s))switch(o){case"value":p=r;break;case"defaultValue":h=r;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=r)throw Error(i(91));break;default:r!==s&&uu(e,t,o,r,a,s)}return void jt(e,p,h);case"option":for(var f in n)if(p=n[f],n.hasOwnProperty(f)&&null!=p&&!a.hasOwnProperty(f))if("selected"===f)e.selected=!1;else uu(e,t,f,null,a,p);for(c in a)if(p=a[c],h=n[c],a.hasOwnProperty(c)&&p!==h&&(null!=p||null!=h))if("selected"===c)e.selected=p&&"function"!==typeof p&&"symbol"!==typeof p;else uu(e,t,c,p,a,h);return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var x in n)p=n[x],n.hasOwnProperty(x)&&null!=p&&!a.hasOwnProperty(x)&&uu(e,t,x,null,a,p);for(d in a)if(p=a[d],h=n[d],a.hasOwnProperty(d)&&p!==h&&(null!=p||null!=h))switch(d){case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(i(137,t));break;default:uu(e,t,d,p,a,h)}return;default:if(At(t)){for(var v in n)p=n[v],n.hasOwnProperty(v)&&void 0!==p&&!a.hasOwnProperty(v)&&mu(e,t,v,void 0,a,p);for(u in a)p=a[u],h=n[u],!a.hasOwnProperty(u)||p===h||void 0===p&&void 0===h||mu(e,t,u,p,a,h);return}}for(var g in n)p=n[g],n.hasOwnProperty(g)&&null!=p&&!a.hasOwnProperty(g)&&uu(e,t,g,null,a,p);for(m in a)p=a[m],h=n[m],!a.hasOwnProperty(m)||p===h||null==p&&null==h||uu(e,t,m,p,a,h)}(a,e.type,n,t),a[Ve]=t}catch(r){Nd(e,e.return,r)}}function _l(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&Cu(e.type)||4===e.tag}function Dl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||_l(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&Cu(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function Cl(e,t,n){var a=e.tag;if(5===a||6===a)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!==(n=n._reactRootContainer)&&void 0!==n||null!==t.onclick||(t.onclick=Rt));else if(4!==a&&(27===a&&Cu(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(Cl(e,t,n),e=e.sibling;null!==e;)Cl(e,t,n),e=e.sibling}function Al(e,t,n){var a=e.tag;if(5===a||6===a)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==a&&(27===a&&Cu(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(Al(e,t,n),e=e.sibling;null!==e;)Al(e,t,n),e=e.sibling}function Sl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var a=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);pu(t,a,n),t[Ue]=e,t[Ve]=n}catch(s){Nd(e,e.return,s)}}var El=!1,Fl=!1,Rl=!1,Il="function"===typeof WeakSet?WeakSet:Set,Tl=null;function Pl(e,t,n){var a=n.flags;switch(n.tag){case 0:case 11:case 15:Jl(e,n),4&a&&vl(5,n);break;case 1:if(Jl(e,n),4&a)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(i){Nd(n,n.return,i)}else{var r=No(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(o){Nd(n,n.return,o)}}64&a&&yl(n),512&a&&wl(n,n.return);break;case 3:if(Jl(e,n),64&a&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{Cs(e,t)}catch(i){Nd(n,n.return,i)}}break;case 27:null===t&&4&a&&Sl(n);case 26:case 5:Jl(e,n),null===t&&4&a&&kl(n),512&a&&wl(n,n.return);break;case 12:Jl(e,n);break;case 31:Jl(e,n),4&a&&Ul(e,n);break;case 13:Jl(e,n),4&a&&Vl(e,n),64&a&&(null!==(e=n.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var a=function(){t(),n.removeEventListener("DOMContentLoaded",a)};n.addEventListener("DOMContentLoaded",a),e._reactRetry=a}}(e,n=Ad.bind(null,n))));break;case 22:if(!(a=null!==n.memoizedState||El)){t=null!==t&&null!==t.memoizedState||Fl,r=El;var s=Fl;El=a,(Fl=t)&&!s?Xl(e,n,0!==(8772&n.subtreeFlags)):Jl(e,n),El=r,Fl=s}break;case 30:break;default:Jl(e,n)}}function Ol(e){var t=e.alternate;null!==t&&(e.alternate=null,Ol(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Je(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Bl=null,Ll=!1;function Ml(e,t,n){for(n=n.child;null!==n;)zl(e,t,n),n=n.sibling}function zl(e,t,n){if(ge&&"function"===typeof ge.onCommitFiberUnmount)try{ge.onCommitFiberUnmount(ve,n)}catch(s){}switch(n.tag){case 26:Fl||jl(n,t),Ml(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Fl||jl(n,t);var a=Bl,r=Ll;Cu(n.type)&&(Bl=n.stateNode,Ll=!1),Ml(e,t,n),Mu(n.stateNode),Bl=a,Ll=r;break;case 5:Fl||jl(n,t);case 6:if(a=Bl,r=Ll,Bl=null,Ml(e,t,n),Ll=r,null!==(Bl=a))if(Ll)try{(9===Bl.nodeType?Bl.body:"HTML"===Bl.nodeName?Bl.ownerDocument.body:Bl).removeChild(n.stateNode)}catch(i){Nd(n,t,i)}else try{Bl.removeChild(n.stateNode)}catch(i){Nd(n,t,i)}break;case 18:null!==Bl&&(Ll?(Au(9===(e=Bl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Hm(e)):Au(Bl,n.stateNode));break;case 4:a=Bl,r=Ll,Bl=n.stateNode.containerInfo,Ll=!0,Ml(e,t,n),Bl=a,Ll=r;break;case 0:case 11:case 14:case 15:gl(2,n,t),Fl||gl(4,n,t),Ml(e,t,n);break;case 1:Fl||(jl(n,t),"function"===typeof(a=n.stateNode).componentWillUnmount&&bl(n,t,a)),Ml(e,t,n);break;case 21:Ml(e,t,n);break;case 22:Fl=(a=Fl)||null!==n.memoizedState,Ml(e,t,n),Fl=a;break;default:Ml(e,t,n)}}function Ul(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&null!==(e=e.memoizedState))){e=e.dehydrated;try{Hm(e)}catch(n){Nd(t,t.return,n)}}}function Vl(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Hm(e)}catch(n){Nd(t,t.return,n)}}function ql(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Il),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Il),t;default:throw Error(i(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var a=Sd.bind(null,e,t);t.then(a,a)}})}function Wl(e,t){var n=t.deletions;if(null!==n)for(var a=0;a<n.length;a++){var r=n[a],s=e,o=t,l=o;e:for(;null!==l;){switch(l.tag){case 27:if(Cu(l.type)){Bl=l.stateNode,Ll=!1;break e}break;case 5:Bl=l.stateNode,Ll=!1;break e;case 3:case 4:Bl=l.stateNode.containerInfo,Ll=!0;break e}l=l.return}if(null===Bl)throw Error(i(160));zl(s,o,r),Bl=null,Ll=!1,null!==(s=r.alternate)&&(s.return=null),r.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Gl(t,e),t=t.sibling}var Hl=null;function Gl(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Wl(t,e),Kl(e),4&a&&(gl(3,e,e.return),vl(3,e),gl(5,e,e.return));break;case 1:Wl(t,e),Kl(e),512&a&&(Fl||null===n||jl(n,n.return)),64&a&&El&&(null!==(e=e.updateQueue)&&(null!==(a=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?a:n.concat(a))));break;case 26:var r=Hl;if(Wl(t,e),Kl(e),512&a&&(Fl||null===n||jl(n,n.return)),4&a){var s=null!==n?n.memoizedState:null;if(a=e.memoizedState,null===n)if(null===a)if(null===e.stateNode){e:{a=e.type,n=e.memoizedProps,r=r.ownerDocument||r;t:switch(a){case"title":(!(s=r.getElementsByTagName("title")[0])||s[Ye]||s[Ue]||"http://www.w3.org/2000/svg"===s.namespaceURI||s.hasAttribute("itemprop"))&&(s=r.createElement(a),r.head.insertBefore(s,r.querySelector("head > title"))),pu(s,a,n),s[Ue]=e,et(s),a=s;break e;case"link":var o=am("link","href",r).get(a+(n.href||""));if(o)for(var l=0;l<o.length;l++)if((s=o[l]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&s.getAttribute("rel")===(null==n.rel?null:n.rel)&&s.getAttribute("title")===(null==n.title?null:n.title)&&s.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){o.splice(l,1);break t}pu(s=r.createElement(a),a,n),r.head.appendChild(s);break;case"meta":if(o=am("meta","content",r).get(a+(n.content||"")))for(l=0;l<o.length;l++)if((s=o[l]).getAttribute("content")===(null==n.content?null:""+n.content)&&s.getAttribute("name")===(null==n.name?null:n.name)&&s.getAttribute("property")===(null==n.property?null:n.property)&&s.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&s.getAttribute("charset")===(null==n.charSet?null:n.charSet)){o.splice(l,1);break t}pu(s=r.createElement(a),a,n),r.head.appendChild(s);break;default:throw Error(i(468,a))}s[Ue]=e,et(s),a=s}e.stateNode=a}else rm(r,e.type,e.stateNode);else e.stateNode=Qu(r,a,e.memoizedProps);else s!==a?(null===s?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):s.count--,null===a?rm(r,e.type,e.stateNode):Qu(r,a,e.memoizedProps)):null===a&&null!==e.stateNode&&Nl(e,e.memoizedProps,n.memoizedProps)}break;case 27:Wl(t,e),Kl(e),512&a&&(Fl||null===n||jl(n,n.return)),null!==n&&4&a&&Nl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Wl(t,e),Kl(e),512&a&&(Fl||null===n||jl(n,n.return)),32&e.flags){r=e.stateNode;try{Nt(r,"")}catch(f){Nd(e,e.return,f)}}4&a&&null!=e.stateNode&&Nl(e,r=e.memoizedProps,null!==n?n.memoizedProps:r),1024&a&&(Rl=!0);break;case 6:if(Wl(t,e),Kl(e),4&a){if(null===e.stateNode)throw Error(i(162));a=e.memoizedProps,n=e.stateNode;try{n.nodeValue=a}catch(f){Nd(e,e.return,f)}}break;case 3:if(nm=null,r=Hl,Hl=Vu(t.containerInfo),Wl(t,e),Hl=r,Kl(e),4&a&&null!==n&&n.memoizedState.isDehydrated)try{Hm(t.containerInfo)}catch(f){Nd(e,e.return,f)}Rl&&(Rl=!1,Yl(e));break;case 4:a=Hl,Hl=Vu(e.stateNode.containerInfo),Wl(t,e),Kl(e),Hl=a;break;case 12:default:Wl(t,e),Kl(e);break;case 31:case 19:Wl(t,e),Kl(e),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,ql(e,a)));break;case 13:Wl(t,e),Kl(e),8192&e.child.flags&&null!==e.memoizedState!==(null!==n&&null!==n.memoizedState)&&(Ic=le()),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,ql(e,a)));break;case 22:r=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,d=El,u=Fl;if(El=d||r,Fl=u||c,Wl(t,e),Fl=u,El=d,Kl(e),8192&a)e:for(t=e.stateNode,t._visibility=r?-2&t._visibility:1|t._visibility,r&&(null===n||c||El||Fl||$l(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(s=c.stateNode,r)"function"===typeof(o=s.style).setProperty?o.setProperty("display","none","important"):o.display="none";else{l=c.stateNode;var m=c.memoizedProps.style,p=void 0!==m&&null!==m&&m.hasOwnProperty("display")?m.display:null;l.style.display=null==p||"boolean"===typeof p?"":(""+p).trim()}}catch(f){Nd(c,c.return,f)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=r?"":c.memoizedProps}catch(f){Nd(c,c.return,f)}}}else if(18===t.tag){if(null===n){c=t;try{var h=c.stateNode;r?Su(h,!0):Su(c.stateNode,!1)}catch(f){Nd(c,c.return,f)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&a&&(null!==(a=e.updateQueue)&&(null!==(n=a.retryQueue)&&(a.retryQueue=null,ql(e,n))));case 30:case 21:}}function Kl(e){var t=e.flags;if(2&t){try{for(var n,a=e.return;null!==a;){if(_l(a)){n=a;break}a=a.return}if(null==n)throw Error(i(160));switch(n.tag){case 27:var r=n.stateNode;Al(e,Dl(e),r);break;case 5:var s=n.stateNode;32&n.flags&&(Nt(s,""),n.flags&=-33),Al(e,Dl(e),s);break;case 3:case 4:var o=n.stateNode.containerInfo;Cl(e,Dl(e),o);break;default:throw Error(i(161))}}catch(l){Nd(e,e.return,l)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Yl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Yl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Jl(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Pl(e,t.alternate,t),t=t.sibling}function $l(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:gl(4,t,t.return),$l(t);break;case 1:jl(t,t.return);var n=t.stateNode;"function"===typeof n.componentWillUnmount&&bl(t,t.return,n),$l(t);break;case 27:Mu(t.stateNode);case 26:case 5:jl(t,t.return),$l(t);break;case 22:null===t.memoizedState&&$l(t);break;default:$l(t)}e=e.sibling}}function Xl(e,t,n){for(n=n&&0!==(8772&t.subtreeFlags),t=t.child;null!==t;){var a=t.alternate,r=e,s=t,i=s.flags;switch(s.tag){case 0:case 11:case 15:Xl(r,s,n),vl(4,s);break;case 1:if(Xl(r,s,n),"function"===typeof(r=(a=s).stateNode).componentDidMount)try{r.componentDidMount()}catch(c){Nd(a,a.return,c)}if(null!==(r=(a=s).updateQueue)){var o=a.stateNode;try{var l=r.shared.hiddenCallbacks;if(null!==l)for(r.shared.hiddenCallbacks=null,r=0;r<l.length;r++)Ds(l[r],o)}catch(c){Nd(a,a.return,c)}}n&&64&i&&yl(s),wl(s,s.return);break;case 27:Sl(s);case 26:case 5:Xl(r,s,n),n&&null===a&&4&i&&kl(s),wl(s,s.return);break;case 12:Xl(r,s,n);break;case 31:Xl(r,s,n),n&&4&i&&Ul(r,s);break;case 13:Xl(r,s,n),n&&4&i&&Vl(r,s);break;case 22:null===s.memoizedState&&Xl(r,s,n),wl(s,s.return);break;case 30:break;default:Xl(r,s,n)}t=t.sibling}}function Ql(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&Ur(n))}function Zl(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ur(e))}function ec(e,t,n,a){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)tc(e,t,n,a),t=t.sibling}function tc(e,t,n,a){var r=t.flags;switch(t.tag){case 0:case 11:case 15:ec(e,t,n,a),2048&r&&vl(9,t);break;case 1:case 31:case 13:default:ec(e,t,n,a);break;case 3:ec(e,t,n,a),2048&r&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ur(e)));break;case 12:if(2048&r){ec(e,t,n,a),e=t.stateNode;try{var s=t.memoizedProps,i=s.id,o=s.onPostCommit;"function"===typeof o&&o(i,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(l){Nd(t,t.return,l)}}else ec(e,t,n,a);break;case 23:break;case 22:s=t.stateNode,i=t.alternate,null!==t.memoizedState?2&s._visibility?ec(e,t,n,a):ac(e,t):2&s._visibility?ec(e,t,n,a):(s._visibility|=2,nc(e,t,n,a,0!==(10256&t.subtreeFlags)||!1)),2048&r&&Ql(i,t);break;case 24:ec(e,t,n,a),2048&r&&Zl(t.alternate,t)}}function nc(e,t,n,a,r){for(r=r&&(0!==(10256&t.subtreeFlags)||!1),t=t.child;null!==t;){var s=e,i=t,o=n,l=a,c=i.flags;switch(i.tag){case 0:case 11:case 15:nc(s,i,o,l,r),vl(8,i);break;case 23:break;case 22:var d=i.stateNode;null!==i.memoizedState?2&d._visibility?nc(s,i,o,l,r):ac(s,i):(d._visibility|=2,nc(s,i,o,l,r)),r&&2048&c&&Ql(i.alternate,i);break;case 24:nc(s,i,o,l,r),r&&2048&c&&Zl(i.alternate,i);break;default:nc(s,i,o,l,r)}t=t.sibling}}function ac(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,a=t,r=a.flags;switch(a.tag){case 22:ac(n,a),2048&r&&Ql(a.alternate,a);break;case 24:ac(n,a),2048&r&&Zl(a.alternate,a);break;default:ac(n,a)}t=t.sibling}}var rc=8192;function sc(e,t,n){if(e.subtreeFlags&rc)for(e=e.child;null!==e;)ic(e,t,n),e=e.sibling}function ic(e,t,n){switch(e.tag){case 26:sc(e,t,n),e.flags&rc&&null!==e.memoizedState&&function(e,t,n,a){if("stylesheet"===n.type&&("string"!==typeof a.media||!1!==matchMedia(a.media).matches)&&0===(4&n.state.loading)){if(null===n.instance){var r=Ku(a.href),s=t.querySelector(Yu(r));if(s)return null!==(t=s._p)&&"object"===typeof t&&"function"===typeof t.then&&(e.count++,e=om.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=s,void et(s);s=t.ownerDocument||t,a=Ju(a),(r=zu.get(r))&&em(a,r),et(s=s.createElement("link"));var i=s;i._p=new Promise(function(e,t){i.onload=e,i.onerror=t}),pu(s,"link",a),n.instance=s}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&0===(3&n.state.loading)&&(e.count++,n=om.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}(n,Hl,e.memoizedState,e.memoizedProps);break;case 5:default:sc(e,t,n);break;case 3:case 4:var a=Hl;Hl=Vu(e.stateNode.containerInfo),sc(e,t,n),Hl=a;break;case 22:null===e.memoizedState&&(null!==(a=e.alternate)&&null!==a.memoizedState?(a=rc,rc=16777216,sc(e,t,n),rc=a):sc(e,t,n))}}function oc(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function lc(e){var t=e.deletions;if(0!==(16&e.flags)){if(null!==t)for(var n=0;n<t.length;n++){var a=t[n];Tl=a,uc(a,e)}oc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)cc(e),e=e.sibling}function cc(e){switch(e.tag){case 0:case 11:case 15:lc(e),2048&e.flags&&gl(9,e,e.return);break;case 3:case 12:default:lc(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,dc(e)):lc(e)}}function dc(e){var t=e.deletions;if(0!==(16&e.flags)){if(null!==t)for(var n=0;n<t.length;n++){var a=t[n];Tl=a,uc(a,e)}oc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:gl(8,t,t.return),dc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,dc(t));break;default:dc(t)}e=e.sibling}}function uc(e,t){for(;null!==Tl;){var n=Tl;switch(n.tag){case 0:case 11:case 15:gl(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var a=n.memoizedState.cachePool.pool;null!=a&&a.refCount++}break;case 24:Ur(n.memoizedState.cache)}if(null!==(a=n.child))a.return=n,Tl=a;else e:for(n=e;null!==Tl;){var r=(a=Tl).sibling,s=a.return;if(Ol(a),a===n){Tl=null;break e}if(null!==r){r.return=s,Tl=r;break e}Tl=s}}}var mc={getCacheForType:function(e){var t=Ir(Mr),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ir(Mr).controller.signal}},pc="function"===typeof WeakMap?WeakMap:Map,hc=0,fc=null,xc=null,vc=0,gc=0,yc=null,bc=!1,wc=!1,jc=!1,kc=0,Nc=0,_c=0,Dc=0,Cc=0,Ac=0,Sc=0,Ec=null,Fc=null,Rc=!1,Ic=0,Tc=0,Pc=1/0,Oc=null,Bc=null,Lc=0,Mc=null,zc=null,Uc=0,Vc=0,qc=null,Wc=null,Hc=0,Gc=null;function Kc(){return 0!==(2&hc)&&0!==vc?vc&-vc:null!==T.T?qd():Le()}function Yc(){if(0===Ac)if(0===(536870912&vc)||mr){var e=Ne;0===(3932160&(Ne<<=1))&&(Ne=262144),Ac=e}else Ac=536870912;return null!==(e=Is.current)&&(e.flags|=32),Ac}function Jc(e,t,n){(e!==fc||2!==gc&&9!==gc)&&null===e.cancelPendingCommit||(nd(e,0),Zc(e,vc,Ac,!1)),Re(e,n),0!==(2&hc)&&e===fc||(e===fc&&(0===(2&hc)&&(Dc|=n),4===Nc&&Zc(e,vc,Ac,!1)),Od(e))}function $c(e,t,n){if(0!==(6&hc))throw Error(i(327));for(var a=!n&&0===(127&t)&&0===(t&e.expiredLanes)||Ae(e,t),r=a?function(e,t){var n=hc;hc|=2;var a=sd(),r=id();fc!==e||vc!==t?(Oc=null,Pc=le()+500,nd(e,t)):wc=Ae(e,t);e:for(;;)try{if(0!==gc&&null!==xc){t=xc;var s=yc;t:switch(gc){case 1:gc=0,yc=null,pd(e,t,s,1);break;case 2:case 9:if(ns(s)){gc=0,yc=null,md(t);break}t=function(){2!==gc&&9!==gc||fc!==e||(gc=7),Od(e)},s.then(t,t);break e;case 3:gc=7;break e;case 4:gc=5;break e;case 7:ns(s)?(gc=0,yc=null,md(t)):(gc=0,yc=null,pd(e,t,s,7));break;case 5:var o=null;switch(xc.tag){case 26:o=xc.memoizedState;case 5:case 27:var l=xc;if(o?sm(o):l.stateNode.complete){gc=0,yc=null;var c=l.sibling;if(null!==c)xc=c;else{var d=l.return;null!==d?(xc=d,hd(d)):xc=null}break t}}gc=0,yc=null,pd(e,t,s,5);break;case 6:gc=0,yc=null,pd(e,t,s,6);break;case 8:td(),Nc=6;break e;default:throw Error(i(462))}}dd();break}catch(u){ad(e,u)}return _r=Nr=null,T.H=a,T.A=r,hc=n,null!==xc?0:(fc=null,vc=0,Fa(),Nc)}(e,t):ld(e,t,!0),s=a;;){if(0===r){wc&&!a&&Zc(e,t,0,!1);break}if(n=e.current.alternate,!s||Qc(n)){if(2===r){if(s=t,e.errorRecoveryDisabledLanes&s)var o=0;else o=0!==(o=-536870913&e.pendingLanes)?o:536870912&o?536870912:0;if(0!==o){t=o;e:{var l=e;r=Ec;var c=l.current.memoizedState.isDehydrated;if(c&&(nd(l,o).flags|=256),2!==(o=ld(l,o,!1))){if(jc&&!c){l.errorRecoveryDisabledLanes|=s,Dc|=s,r=4;break e}s=Fc,Fc=r,null!==s&&(null===Fc?Fc=s:Fc.push.apply(Fc,s))}r=o}if(s=!1,2!==r)continue}}if(1===r){nd(e,0),Zc(e,t,0,!0);break}e:{switch(a=e,s=r){case 0:case 1:throw Error(i(345));case 4:if((4194048&t)!==t)break;case 6:Zc(a,t,Ac,!bc);break e;case 2:Fc=null;break;case 3:case 5:break;default:throw Error(i(329))}if((62914560&t)===t&&10<(r=Ic+300-le())){if(Zc(a,t,Ac,!bc),0!==Ce(a,0,!0))break e;Uc=t,a.timeoutHandle=ju(Xc.bind(null,a,n,Fc,Oc,Rc,t,Ac,Dc,Sc,bc,s,"Throttled",-0,0),r)}else Xc(a,n,Fc,Oc,Rc,t,Ac,Dc,Sc,bc,s,null,-0,0)}break}r=ld(e,t,!1),s=!1}Od(e)}function Xc(e,t,n,a,r,s,i,o,l,c,d,u,m,p){if(e.timeoutHandle=-1,8192&(u=t.subtreeFlags)||16785408===(16785408&u)){ic(t,s,u={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Rt});var h=(62914560&s)===s?Ic-le():(4194048&s)===s?Tc-le():0;if(h=function(e,t){return e.stylesheets&&0===e.count&&cm(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var a=setTimeout(function(){if(e.stylesheets&&cm(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===im&&(im=62500*function(){if("function"===typeof performance.getEntriesByType){for(var e=0,t=0,n=performance.getEntriesByType("resource"),a=0;a<n.length;a++){var r=n[a],s=r.transferSize,i=r.initiatorType,o=r.duration;if(s&&o&&hu(i)){for(i=0,o=r.responseEnd,a+=1;a<n.length;a++){var l=n[a],c=l.startTime;if(c>o)break;var d=l.transferSize,u=l.initiatorType;d&&hu(u)&&(i+=d*((l=l.responseEnd)<o?1:(o-c)/(l-c)))}if(--a,t+=8*(s+i)/(r.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,"number"===typeof e)?e:5}());var r=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&cm(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>im?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(r)}}:null}(u,h),null!==h)return Uc=s,e.cancelPendingCommit=h(xd.bind(null,e,t,s,n,a,r,i,o,l,d,u,null,m,p)),void Zc(e,s,i,!c)}xd(e,t,s,n,a,r,i,o,l)}function Qc(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&(null!==(n=t.updateQueue)&&null!==(n=n.stores)))for(var a=0;a<n.length;a++){var r=n[a],s=r.getSnapshot;r=r.value;try{if(!Zn(s(),r))return!1}catch(i){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Zc(e,t,n,a){t&=~Cc,t&=~Dc,e.suspendedLanes|=t,e.pingedLanes&=~t,a&&(e.warmLanes|=t),a=e.expirationTimes;for(var r=t;0<r;){var s=31-be(r),i=1<<s;a[s]=-1,r&=~i}0!==n&&Ie(e,n,t)}function ed(){return 0!==(6&hc)||(Bd(0,!1),!1)}function td(){if(null!==xc){if(0===gc)var e=xc.return;else _r=Nr=null,oi(e=xc),ls=null,cs=0,e=xc;for(;null!==e;)xl(e.alternate,e),e=e.return;xc=null}}function nd(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,ku(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Uc=0,td(),fc=e,xc=n=Ua(e.current,null),vc=t,gc=0,yc=null,bc=!1,wc=Ae(e,t),jc=!1,Sc=Ac=Cc=Dc=_c=Nc=0,Fc=Ec=null,Rc=!1,0!==(8&t)&&(t|=32&t);var a=e.entangledLanes;if(0!==a)for(e=e.entanglements,a&=t;0<a;){var r=31-be(a),s=1<<r;t|=e[r],a&=~s}return kc=t,Fa(),n}function ad(e,t){qs=null,T.H=xo,t===Qr||t===es?(t=is(),gc=3):t===Zr?(t=is(),gc=4):gc=t===Io?8:null!==t&&"object"===typeof t&&"function"===typeof t.then?6:1,yc=t,null===xc&&(Nc=1,Ao(e,Ja(t,e.current)))}function rd(){var e=Is.current;return null===e||((4194048&vc)===vc?null===Ts:((62914560&vc)===vc||0!==(536870912&vc))&&e===Ts)}function sd(){var e=T.H;return T.H=xo,null===e?xo:e}function id(){var e=T.A;return T.A=mc,e}function od(){Nc=4,bc||(4194048&vc)!==vc&&null!==Is.current||(wc=!0),0===(134217727&_c)&&0===(134217727&Dc)||null===fc||Zc(fc,vc,Ac,!1)}function ld(e,t,n){var a=hc;hc|=2;var r=sd(),s=id();fc===e&&vc===t||(Oc=null,nd(e,t)),t=!1;var i=Nc;e:for(;;)try{if(0!==gc&&null!==xc){var o=xc,l=yc;switch(gc){case 8:td(),i=6;break e;case 3:case 2:case 9:case 6:null===Is.current&&(t=!0);var c=gc;if(gc=0,yc=null,pd(e,o,l,c),n&&wc){i=0;break e}break;default:c=gc,gc=0,yc=null,pd(e,o,l,c)}}cd(),i=Nc;break}catch(d){ad(e,d)}return t&&e.shellSuspendCounter++,_r=Nr=null,hc=a,T.H=r,T.A=s,null===xc&&(fc=null,vc=0,Fa()),i}function cd(){for(;null!==xc;)ud(xc)}function dd(){for(;null!==xc&&!ie();)ud(xc)}function ud(e){var t=ol(e.alternate,e,kc);e.memoizedProps=e.pendingProps,null===t?hd(e):xc=t}function md(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Go(n,t,t.pendingProps,t.type,void 0,vc);break;case 11:t=Go(n,t,t.pendingProps,t.type.render,t.ref,vc);break;case 5:oi(t);default:xl(n,t),t=ol(n,t=xc=Va(t,kc),kc)}e.memoizedProps=e.pendingProps,null===t?hd(e):xc=t}function pd(e,t,n,a){_r=Nr=null,oi(t),ls=null,cs=0;var r=t.return;try{if(function(e,t,n,a,r){if(n.flags|=32768,null!==a&&"object"===typeof a&&"function"===typeof a.then){if(null!==(t=n.alternate)&&Er(t,n,r,!0),null!==(n=Is.current)){switch(n.tag){case 31:case 13:return null===Ts?od():null===n.alternate&&0===Nc&&(Nc=3),n.flags&=-257,n.flags|=65536,n.lanes=r,a===ts?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([a]):t.add(a),_d(e,a,r)),!1;case 22:return n.flags|=65536,a===ts?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([a])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([a]):n.add(a),_d(e,a,r)),!1}throw Error(i(435,n.tag))}return _d(e,a,r),od(),!1}if(mr)return null!==(t=Is.current)?(0===(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=r,a!==fr&&jr(Ja(e=Error(i(422),{cause:a}),n))):(a!==fr&&jr(Ja(t=Error(i(423),{cause:a}),n)),(e=e.current.alternate).flags|=65536,r&=-r,e.lanes|=r,a=Ja(a,n),js(e,r=Eo(e.stateNode,a,r)),4!==Nc&&(Nc=2)),!1;var s=Error(i(520),{cause:a});if(s=Ja(s,n),null===Ec?Ec=[s]:Ec.push(s),4!==Nc&&(Nc=2),null===t)return!0;a=Ja(a,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=r&-r,n.lanes|=e,js(n,e=Eo(n.stateNode,a,e)),!1;case 1:if(t=n.type,s=n.stateNode,0===(128&n.flags)&&("function"===typeof t.getDerivedStateFromError||null!==s&&"function"===typeof s.componentDidCatch&&(null===Bc||!Bc.has(s))))return n.flags|=65536,r&=-r,n.lanes|=r,Ro(r=Fo(r),e,n,a),js(n,r),!1}n=n.return}while(null!==n);return!1}(e,r,t,n,vc))return Nc=1,Ao(e,Ja(n,e.current)),void(xc=null)}catch(s){if(null!==r)throw xc=r,s;return Nc=1,Ao(e,Ja(n,e.current)),void(xc=null)}32768&t.flags?(mr||1===a?e=!0:wc||0!==(536870912&vc)?e=!1:(bc=e=!0,(2===a||9===a||3===a||6===a)&&(null!==(a=Is.current)&&13===a.tag&&(a.flags|=16384))),fd(t,e)):hd(t)}function hd(e){var t=e;do{if(0!==(32768&t.flags))return void fd(t,bc);e=t.return;var n=hl(t.alternate,t,kc);if(null!==n)return void(xc=n);if(null!==(t=t.sibling))return void(xc=t);xc=t=e}while(null!==t);0===Nc&&(Nc=5)}function fd(e,t){do{var n=fl(e.alternate,e);if(null!==n)return n.flags&=32767,void(xc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deleti
2ons=null),!t&&null!==(e=e.sibling))return void(xc=e);xc=e=n}while(null!==e);Nc=6,xc=null}function xd(e,t,n,a,r,s,o,l,c){e.cancelPendingCommit=null;do{wd()}while(0!==Lc);if(0!==(6&hc))throw Error(i(327));if(null!==t){if(t===e.current)throw Error(i(177));if(s=t.lanes|t.childLanes,function(e,t,n,a,r,s){var i=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=i&~n;0<n;){var d=31-be(n),u=1<<d;o[d]=0,l[d]=-1;var m=c[d];if(null!==m)for(c[d]=null,d=0;d<m.length;d++){var p=m[d];null!==p&&(p.lane&=-536870913)}n&=~u}0!==a&&Ie(e,a,0),0!==s&&0===r&&0!==e.tag&&(e.suspendedLanes|=s&~(i&~t))}(e,n,s|=Ea,o,l,c),e===fc&&(xc=fc=null,vc=0),zc=t,Mc=e,Uc=n,Vc=s,qc=r,Wc=a,0!==(10256&t.subtreeFlags)||0!==(10256&t.flags)?(e.callbackNode=null,e.callbackPriority=0,re(me,function(){return jd(),null})):(e.callbackNode=null,e.callbackPriority=0),a=0!==(13878&t.flags),0!==(13878&t.subtreeFlags)||a){a=T.T,T.T=null,r=P.p,P.p=2,o=hc,hc|=4;try{!function(e,t){if(e=e.containerInfo,fu=bm,sa(e=ra(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var a=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(a&&0!==a.rangeCount){n=a.anchorNode;var r=a.anchorOffset,s=a.focusNode;a=a.focusOffset;try{n.nodeType,s.nodeType}catch(x){n=null;break e}var o=0,l=-1,c=-1,d=0,u=0,m=e,p=null;t:for(;;){for(var h;m!==n||0!==r&&3!==m.nodeType||(l=o+r),m!==s||0!==a&&3!==m.nodeType||(c=o+a),3===m.nodeType&&(o+=m.nodeValue.length),null!==(h=m.firstChild);)p=m,m=h;for(;;){if(m===e)break t;if(p===n&&++d===r&&(l=o),p===s&&++u===a&&(c=o),null!==(h=m.nextSibling))break;p=(m=p).parentNode}m=h}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(xu={focusedElem:e,selectionRange:n},bm=!1,Tl=t;null!==Tl;)if(e=(t=Tl).child,0!==(1028&t.subtreeFlags)&&null!==e)e.return=t,Tl=e;else for(;null!==Tl;){switch(s=(t=Tl).alternate,e=t.flags,t.tag){case 0:if(0!==(4&e)&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(n=0;n<e.length;n++)(r=e[n]).ref.impl=r.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(0!==(1024&e)&&null!==s){e=void 0,n=t,r=s.memoizedProps,s=s.memoizedState,a=n.stateNode;try{var f=No(n.type,r);e=a.getSnapshotBeforeUpdate(f,s),a.__reactInternalSnapshotBeforeUpdate=e}
2catch(v){Nd(n,n.return,v)}}break;case 3:if(0!==(1024&e))if(9===(n=(e=t.stateNode.containerInfo).nodeType))Eu(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Eu(e);break;default:e.textContent=""}break;default:if(0!==(1024&e))throw Error(i(163))}if(null!==(e=t.sibling)){e.return=t.return,Tl=e;break}Tl=t.return}}(e,t)}finally{hc=o,P.p=r,T.T=a}}Lc=1,vd(),gd(),yd()}}function vd(){if(1===Lc){Lc=0;var e=Mc,t=zc,n=0!==(13878&t.flags);if(0!==(13878&t.subtreeFlags)||n){n=T.T,T.T=null;var a=P.p;P.p=2;var r=hc;hc|=4;try{Gl(t,e);var s=xu,i=ra(e.containerInfo),o=s.focusedElem,l=s.selectionRange;if(i!==o&&o&&o.ownerDocument&&aa(o.ownerDocument.documentElement,o)){if(null!==l&&sa(o)){var c=l.start,d=l.end;if(void 0===d&&(d=c),"selectionStart"in o)o.selectionStart=c,o.selectionEnd=Math.min(d,o.value.length);else{var u=o.ownerDocument||document,m=u&&u.defaultView||window;if(m.getSelection){var p=m.getSelection(),h=o.textContent.length,f=Math.min(l.start,h),x=void 0===l.end?f:Math.min(l.end,h);!p.extend&&f>x&&(i=x,x=f,f=i);var v=na(o,f),g=na(o,x);if(v&&g&&(1!==p.rangeCount||p.anchorNode!==v.node||p.anchorOffset!==v.offset||p.focusNode!==g.node||p.focusOffset!==g.offset)){var y=u.createRange();y.setStart(v.node,v.offset),p.removeAllRanges(),f>x?(p.addRange(y),p.extend(g.node,g.offset)):(y.setEnd(g.node,g.offset),p.addRange(y))}}}}for(u=[],p=o;p=p.parentNode;)1===p.nodeType&&u.push({element:p,left:p.scrollLeft,top:p.scrollTop});for("function"===typeof o.focus&&o.focus(),o=0;o<u.length;o++){var b=u[o];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}bm=!!fu,xu=fu=null}finally{hc=r,P.p=a,T.T=n}}e.current=t,Lc=2}}function gd(){if(2===Lc){Lc=0;var e=Mc,t=zc,n=0!==(8772&t.flags);if(0!==(8772&t.subtreeFlags)||n){n=T.T,T.T=null;var a=P.p;P.p=2;var r=hc;hc|=4;try{Pl(e,t.alternate,t)}finally{hc=r,P.p=a,T.T=n}}Lc=3}}function yd(){if(4===Lc||3===Lc){Lc=0,oe();var e=Mc,t=zc,n=Uc,a=Wc;0!==(10256&t.subtreeFlags)||0!==(10256&t.flags)?Lc=5:(Lc=0,zc=Mc=null,bd(e,e.pendingLanes));var r=e.pendingLanes;if(0===r&&(Bc=null),Be(n),t=t.stateNode,ge&&"function"===typeof ge.onCommitFiberRoot)try{ge.onCommitFiberRoot(ve,t,void 0,128===(128&t.current.flags))}catch(l){}if(null!==a){t=T.T,r=P.p,P.p=2,T.T=null;try{for(var s=e.onRecoverableError,i=0;i<a.length;i++){var o=a[i];s(o.value,{componentStack:o.stack})}}finally{T.T=t,P.p=r}}0!==(3&Uc)&&wd(),Od(e),r=e.pendingLanes,0!==(261930&n)&&0!==(42&r)?e===Gc?Hc++:(Hc=0,Gc=e):Hc=0,Bd(0,!1)}}function bd(e,t){0===(e.pooledCacheLanes&=t)&&(null!=(t=e.pooledCache)&&(e.pooledCache=null,Ur(t)))}function wd(){return vd(),gd(),yd(),jd()}function jd(){if(5!==Lc)return!1;var e=Mc,t=Vc;Vc=0;var n=Be(Uc),a=T.T,r=P.p;try{P.p=32>n?32:n,T.T=null,n=qc,qc=null;var s=Mc,o=Uc;if(Lc=0,zc=Mc=null,Uc=0,0!==(6&hc))throw Error(i(331));var l=hc;if(hc|=4,cc(s.current),tc(s,s.current,o,n),hc=l,Bd(0,!1),ge&&"function"===typeof ge.onPostCommitFiberRoot)try{ge.onPostCommitFiberRoot(ve,s)}catch(c){}return!0}finally{P.p=r,T.T=a,bd(e,t)}}function kd(e,t,n){t=Ja(n,t),null!==(e=bs(e,t=Eo(e.stateNode,t,2),2))&&(Re(e,2),Od(e))}function Nd(e,t,n){if(3===e.tag)kd(e,e,n);else for(;null!==t;){if(3===t.tag){kd(t,e,n);break}if(1===t.tag){var a=t.stateNode;if("function"===typeof t.type.getDerivedStateFromError||"function"===typeof a.componentDidCatch&&(null===Bc||!Bc.has(a))){e=Ja(n,e),null!==(a=bs(t,n=Fo(2),2))&&(Ro(n,a,t,e),Re(a,2),Od(a));break}}t=t.return}}function _d(e,t,n){var a=e.pingCache;if(null===a){a=e.pingCache=new pc;var r=new Set;a.set(t,r)}else void 0===(r=a.get(t))&&(r=new Set,a.set(t,r));r.has(n)||(jc=!0,r.add(n),e=Dd.bind(null,e,t,n),t.then(e,e))}function Dd(e,t,n){var a=e.pingCache;null!==a&&a.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,fc===e&&(vc&n)===n&&(4===Nc||3===Nc&&(62914560&vc)===vc&&300>le()-Ic?0===(2&hc)&&nd(e,0):Cc|=n,Sc===vc&&(Sc=0)),Od(e)}function Cd(e,t){0===t&&(t=Ee()),null!==(e=Ta(e,t))&&(Re(e,t),Od(e))}function Ad(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Cd(e,n)}function Sd(e,t){var n=0;switch(e.tag){case 31:case 13:var a=e.stateNode,r=e.memoizedState;null!==r&&(n=r.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==a&&a.delete(t),Cd(e,n)}var Ed=null,Fd=null,Rd=!1,Id=!1,Td=!1,Pd=0;
vendor: 4,549 bytes, line 2
2function Od(e){e!==Fd&&null===e.next&&(null===Fd?Ed=Fd=e:Fd=Fd.next=e),Id=!0,Rd||(Rd=!0,_u(function(){0!==(6&hc)?re(de,Ld):Md()}))}function Bd(e,t){if(!Td&&Id){Td=!0;do{for(var n=!1,a=Ed;null!==a;){if(!t)if(0!==e){var r=a.pendingLanes;if(0===r)var s=0;else{var i=a.suspendedLanes,o=a.pingedLanes;s=(1<<31-be(42|e)+1)-1,s=201326741&(s&=r&~(i&~o))?201326741&s|1:s?2|s:0}0!==s&&(n=!0,Vd(a,s))}else s=vc,0===(3&(s=Ce(a,a===fc?s:0,null!==a.cancelPendingCommit||-1!==a.timeoutHandle)))||Ae(a,s)||(n=!0,Vd(a,s));a=a.next}}while(n);Td=!1}}function Ld(){Md()}function Md(){Id=Rd=!1;var e=0;0!==Pd&&function(){var e=window.event;if(e&&"popstate"===e.type)return e!==wu&&(wu=e,!0);return wu=null,!1}()&&(e=Pd);for(var t=le(),n=null,a=Ed;null!==a;){var r=a.next,s=zd(a,t);0===s?(a.next=null,null===n?Ed=r:n.next=r,null===r&&(Fd=n)):(n=a,(0!==e||0!==(3&s))&&(Id=!0)),a=r}0!==Lc&&5!==Lc||Bd(e,!1),0!==Pd&&(Pd=0)}function zd(e,t){for(var n=e.suspendedLanes,a=e.pingedLanes,r=e.expirationTimes,s=-62914561&e.pendingLanes;0<s;){var i=31-be(s),o=1<<i,l=r[i];-1===l?0!==(o&n)&&0===(o&a)||(r[i]=Se(o,t)):l<=t&&(e.expiredLanes|=o),s&=~o}if(n=vc,n=Ce(e,e===(t=fc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),a=e.callbackNode,0===n||e===t&&(2===gc||9===gc)||null!==e.cancelPendingCommit)return null!==a&&null!==a&&se(a),e.callbackNode=null,e.callbackPriority=0;if(0===(3&n)||Ae(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==a&&se(a),Be(n)){case 2:case 8:n=ue;break;case 32:default:n=me;break;case 268435456:n=he}return a=Ud.bind(null,e),n=re(n,a),e.callbackPriority=t,e.callbackNode=n,t}return null!==a&&null!==a&&se(a),e.callbackPriority=2,e.callbackNode=null,2}function Ud(e,t){if(0!==Lc&&5!==Lc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(wd()&&e.callbackNode!==n)return null;var a=vc;return 0===(a=Ce(e,e===fc?a:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:($c(e,a,t),zd(e,le()),null!=e.callbackNode&&e.callbackNode===n?Ud.bind(null,e):null)}function Vd(e,t){if(wd())return null;$c(e,t,!0)}function qd(){if(0===Pd){var e=Wr;0===e&&(e=ke,0===(261888&(ke<<=1))&&(ke=256)),Pd=e}return Pd}function Wd(e){return null==e||"symbol"===typeof e||"boolean"===typeof e?null:"function"===typeof e?e:Ft(""+e)}function Hd(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Gd=0;Gd<_a.length;Gd++){var Kd=_a[Gd];Da(Kd.toLowerCase(),"on"+(Kd[0].toUpperCase()+Kd.slice(1)))}Da(va,"onAnimationEnd"),Da(ga,"onAnimationIteration"),Da(ya,"onAnimationStart"),Da("dblclick","onDoubleClick"),Da("focusin","onFocus"),Da("focusout","onBlur"),Da(ba,"onTransitionRun"),Da(wa,"onTransitionStart"),Da(ja,"onTransitionCancel"),Da(ka,"onTransitionEnd"),rt("onMouseEnter",["mouseout","mouseover"]),rt("onMouseLeave",["mouseout","mouseover"]),rt("onPointerEnter",["pointerout","pointerover"]),rt("onPointerLeave",["pointerout","pointerover"]),at("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),at("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),at("onBeforeInput",["compositionend","keypress","textInput","paste"]),at("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),at("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),at("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Yd="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Jd=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Yd));function $d(e,t){t=0!==(4&t);for(var n=0;n<e.length;n++){var a=e[n],r=a.event;a=a.listeners;e:{var s=void 0;if(t)for(var i=a.length-1;0<=i;i--){var o=a[i],l=o.instance,c=o.currentTarget;if(o=o.listener,l!==s&&r.isPropagationStopped())break e;s=o,r.currentTarget=c;try{s(r)}catch(d){Ca(d)}r.currentTarget=null,s=l}else for(i=0;i<a.length;i++){if(l=(o=a[i]).instance,c=o.currentTarget,o=o.listener,l!==s&&r.isPropagationStopped())break e;s=o,r.currentTarget=c;try{s(r)}catch(d){Ca(d)}r.currentTarget=null,s=l}}}}function Xd(e,t){var n=t[We];void 0===n&&(n=t[We]=new Set);var a=e+"__bubble";n.has(a)||(tu(t,e,2,!1),n.add(a))}
vendor: 4,385 bytes, line 2
2function Qd(e,t,n){var a=0;t&&(a|=4),tu(n,e,a,t)}var Zd="_reactListening"+Math.random().toString(36).slice(2);function eu(e){if(!e[Zd]){e[Zd]=!0,tt.forEach(function(t){"selectionchange"!==t&&(Jd.has(t)||Qd(t,!1,e),Qd(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Zd]||(t[Zd]=!0,Qd("selectionchange",!1,t))}}function tu(e,t,n,a){switch(Cm(t)){case 2:var r=wm;break;case 8:r=jm;break;default:r=km}n=r.bind(null,t,n,e),r=void 0,!Vt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(r=!0),a?void 0!==r?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):void 0!==r?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function nu(e,t,n,a,r){var s=a;if(0===(1&t)&&0===(2&t)&&null!==a)e:for(;;){if(null===a)return;var i=a.tag;if(3===i||4===i){var o=a.stateNode.containerInfo;if(o===r)break;if(4===i)for(i=a.return;null!==i;){var c=i.tag;if((3===c||4===c)&&i.stateNode.containerInfo===r)return;i=i.return}for(;null!==o;){if(null===(i=$e(o)))return;if(5===(c=i.tag)||6===c||26===c||27===c){a=s=i;continue e}o=o.parentNode}}a=a.return}Mt(function(){var a=s,r=Tt(n),i=[];e:{var o=Na.get(e);if(void 0!==o){var c=nn,d=e;switch(e){case"keypress":if(0===Yt(n))break e;case"keydown":case"keyup":c=yn;break;case"focusin":d="focus",c=cn;break;case"focusout":d="blur",c=cn;break;case"beforeblur":case"afterblur":c=cn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=on;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=ln;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=wn;break;case va:case ga:case ya:c=dn;break;case ka:c=jn;break;case"scroll":case"scrollend":c=rn;break;case"wheel":c=kn;break;case"copy":case"cut":case"paste":c=un;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=bn;break;case"toggle":case"beforetoggle":c=Nn}var u=0!==(4&t),m=!u&&("scroll"===e||"scrollend"===e),p=u?null!==o?o+"Capture":null:o;u=[];for(var h,f=a;null!==f;){var x=f;if(h=x.stateNode,5!==(x=x.tag)&&26!==x&&27!==x||null===h||null===p||null!=(x=zt(f,p))&&u.push(au(f,x,h)),m)break;f=f.return}0<u.length&&(o=new c(o,d,null,n,r),i.push({event:o,listeners:u}))}}if(0===(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(o="mouseover"===e||"pointerover"===e)||n===It||!(d=n.relatedTarget||n.fromElement)||!$e(d)&&!d[qe])&&(c||o)&&(o=r.window===r?r:(o=r.ownerDocument)?o.defaultView||o.parentWindow:window,c?(c=a,null!==(d=(d=n.relatedTarget||n.toElement)?$e(d):null)&&(m=l(d),u=d.tag,d!==m||5!==u&&27!==u&&6!==u)&&(d=null)):(c=null,d=a),c!==d)){if(u=on,x="onMouseLeave",p="onMouseEnter",f="mouse","pointerout"!==e&&"pointerover"!==e||(u=bn,x="onPointerLeave",p="onPointerEnter",f="pointer"),m=null==c?o:Qe(c),h=null==d?o:Qe(d),(o=new u(x,f+"leave",c,n,r)).target=m,o.relatedTarget=h,x=null,$e(r)===a&&((u=new u(p,f+"enter",d,n,r)).target=h,u.relatedTarget=m,x=u),m=x,c&&d)e:{for(u=su,f=d,h=0,x=p=c;x;x=u(x))h++;x=0;for(var v=f;v;v=u(v))x++;for(;0<h-x;)p=u(p),h--;for(;0<x-h;)f=u(f),x--;for(;h--;){if(p===f||null!==f&&p===f.alternate){u=p;break e}p=u(p),f=u(f)}u=null}else u=null;null!==c&&iu(i,o,c,u,!1),null!==d&&null!==m&&iu(i,m,d,u,!0)}if("select"===(c=(o=a?Qe(a):window).nodeName&&o.nodeName.toLowerCase())||"input"===c&&"file"===o.type)var g=Vn;else if(On(o))if(qn)g=Qn;else{g=$n;var y=Jn}else!(c=o.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==o.type&&"radio"!==o.type?a&&At(a.elementType)&&(g=Vn):g=Xn;switch(g&&(g=g(e,a))?Bn(i,g,n,r):(y&&y(e,o,a),"focusout"===e&&a&&"number"===o.type&&null!=a.memoizedProps.value&&bt(o,"number",o.value)),y=a?Qe(a):window,e){case"focusin":(On(y)||"true"===y.contentEditable)&&(oa=y,la=a,ca=null);break;case"focusout":ca=la=oa=null;break;case"mousedown":da=!0;break;case"contextmenu":case"mouseup":case"dragend":da=!1,ua(i,n,r);break;case"selectionchange":if(ia)break;case"keydown":case"keyup":ua(i,n,r)}var b;if(Dn)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else Tn?Rn(e,n)&&(w="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(w="onCompositionStart");
2w&&(Sn&&"ko"!==n.locale&&(Tn||"onCompositionStart"!==w?"onCompositionEnd"===w&&Tn&&(b=Kt()):(Ht="value"in(Wt=r)?Wt.value:Wt.textContent,Tn=!0)),0<(y=ru(a,w)).length&&(w=new mn(w,e,null,n,r),i.push({event:w,listeners:y}),b?w.data=b:null!==(b=In(n))&&(w.data=b))),(b=An?function(e,t){switch(e){case"compositionend":return In(t);case"keypress":return 32!==t.which?null:(Fn=!0,En);case"textInput":return(e=t.data)===En&&Fn?null:e;default:return null}}(e,n):function(e,t){if(Tn)return"compositionend"===e||!Dn&&Rn(e,t)?(e=Kt(),Gt=Ht=Wt=null,Tn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Sn&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(w=ru(a,"onBeforeInput")).length&&(y=new mn("onBeforeInput","beforeinput",null,n,r),i.push({event:y,listeners:w}),y.data=b)),function(e,t,n,a,r){if("submit"===t&&n&&n.stateNode===r){var s=Wd((r[Ve]||null).action),i=a.submitter;i&&null!==(t=(t=i[Ve]||null)?Wd(t.formAction):i.getAttribute("formAction"))&&(s=t,i=null);var o=new nn("action","action",null,a,r);e.push({event:o,listeners:[{instance:null,listener:function(){if(a.defaultPrevented){if(0!==Pd){var e=i?Hd(r,i):new FormData(r);to(n,{pending:!0,data:e,method:r.method,action:s},null,e)}}else"function"===typeof s&&(o.preventDefault(),e=i?Hd(r,i):new FormData(r),to(n,{pending:!0,data:e,method:r.method,action:s},s,e))},currentTarget:r}]})}}(i,e,a,n,r)}$d(i,t)})}function au(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ru(e,t){for(var n=t+"Capture",a=[];null!==e;){var r=e,s=r.stateNode;if(5!==(r=r.tag)&&26!==r&&27!==r||null===s||(null!=(r=zt(e,n))&&a.unshift(au(e,r,s)),null!=(r=zt(e,t))&&a.push(au(e,r,s))),3===e.tag)return a;e=e.return}return[]}function su(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function iu(e,t,n,a,r){for(var s=t._reactName,i=[];null!==n&&n!==a;){var o=n,l=o.alternate,c=o.stateNode;if(o=o.tag,null!==l&&l===a)break;5!==o&&26!==o&&27!==o||null===c||(l=c,r?null!=(c=zt(n,s))&&i.unshift(au(n,c,l)):r||null!=(c=zt(n,s))&&i.push(au(n,c,l))),n=n.return}0!==i.length&&e.push({event:t,listeners:i})}var ou=/\r\n?/g,lu=/\u0000|\uFFFD/g;function cu(e){return("string"===typeof e?e:""+e).replace(ou,"\n").replace(lu,"")}function du(e,t){return t=cu(t),cu(e)===t}function uu(e,t,n,a,r,s){switch(n){case"children":"string"===typeof a?"body"===t||"textarea"===t&&""===a||Nt(e,a):("number"===typeof a||"bigint"===typeof a)&&"body"!==t&&Nt(e,""+a);break;case"className":ct(e,"class",a);break;case"tabIndex":ct(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":ct(e,n,a);break;case"style":Ct(e,a,s);break;case"data":if("object"!==t){ct(e,"data",a);break}case"src":case"href":if(""===a&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==a||"function"===typeof a||"symbol"===typeof a||"boolean"===typeof a){e.removeAttribute(n);break}a=Ft(""+a),e.setAttribute(n,a);break;case"action":case"formAction":if("function"===typeof a){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"===typeof s&&("formAction"===n?("input"!==t&&uu(e,t,"name",r.name,r,null),uu(e,t,"formEncType",r.formEncType,r,null),uu(e,t,"formMethod",r.formMethod,r,null),uu(e,t,"formTarget",r.formTarget,r,null)):(uu(e,t,"encType",r.encType,r,null),uu(e,t,"method",r.method,r,null),uu(e,t,"target",r.target,r,null))),null==a||"symbol"===typeof a||"boolean"===typeof a){e.removeAttribute(n);break}a=Ft(""+a),e.setAttribute(n,a);break;case"onClick":null!=a&&(e.onclick=Rt);break;case"onScroll":null!=a&&Xd("scroll",e);break;case"onScrollEnd":null!=a&&Xd("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=a){if("object"!==typeof a||!("__html"in a))throw Error(i(61));if(null!=(n=a.__html)){if(null!=r.children)throw Error(i(60));e.innerHTML=n}}break;case"multiple":e.multiple=a&&"function"!==typeof a&&"symbol"!==typeof a;break;case"muted":e.muted=a&&"function"!==typeof a&&"symbol"!==typeof a;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==a||"function"===typeof a||"boolean"===typeof a||"symbol"===typeof a){e.removeAttribute("xlink:href");break}n=Ft(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=a&&"function"!==typeof a&&"symbol"!==typeof a?e.setAttribute(n,""+a):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInl
2ine":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&"function"!==typeof a&&"symbol"!==typeof a?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===a?e.setAttribute(n,""):!1!==a&&null!=a&&"function"!==typeof a&&"symbol"!==typeof a?e.setAttribute(n,a):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=a&&"function"!==typeof a&&"symbol"!==typeof a&&!isNaN(a)&&1<=a?e.setAttribute(n,a):e.removeAttribute(n);break;case"rowSpan":case"start":null==a||"function"===typeof a||"symbol"===typeof a||isNaN(a)?e.removeAttribute(n):e.setAttribute(n,a);break;case"popover":Xd("beforetoggle",e),Xd("toggle",e),lt(e,"popover",a);break;case"xlinkActuate":dt(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":dt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":dt(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":dt(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":dt(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":dt(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":dt(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":dt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":dt(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":lt(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&<(e,n=St.get(n)||n,a)}}function mu(e,t,n,a,r,s){switch(n){case"style":Ct(e,a,s);break;case"dangerouslySetInnerHTML":if(null!=a){if("object"!==typeof a||!("__html"in a))throw Error(i(61));if(null!=(n=a.__html)){if(null!=r.children)throw Error(i(60));e.innerHTML=n}}break;case"children":"string"===typeof a?Nt(e,a):("number"===typeof a||"bigint"===typeof a)&&Nt(e,""+a);break;case"onScroll":null!=a&&Xd("scroll",e);break;case"onScrollEnd":null!=a&&Xd("scrollend",e);break;case"onClick":null!=a&&(e.onclick=Rt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:nt.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(r=n.endsWith("Capture"),t=n.slice(2,r?n.length-7:void 0),"function"===typeof(s=null!=(s=e[Ve]||null)?s[n]:null)&&e.removeEventListener(t,s,r),"function"!==typeof a)?n in e?e[n]=a:!0===a?e.setAttribute(n,""):lt(e,n,a):("function"!==typeof s&&null!==s&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,a,r)))}}function pu(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Xd("error",e),Xd("load",e);var a,r=!1,s=!1;for(a in n)if(n.hasOwnProperty(a)){var o=n[a];if(null!=o)switch(a){case"src":r=!0;break;case"srcSet":s=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:uu(e,t,a,o,n,null)}}return s&&uu(e,t,"srcSet",n.srcSet,n,null),void(r&&uu(e,t,"src",n.src,n,null));case"input":Xd("invalid",e);var l=a=o=s=null,c=null,d=null;for(r in n)if(n.hasOwnProperty(r)){var u=n[r];if(null!=u)switch(r){case"name":s=u;break;case"type":o=u;break;case"checked":c=u;break;case"defaultChecked":d=u;break;case"value":a=u;break;case"defaultValue":l=u;break;case"children":case"dangerouslySetInnerHTML":if(null!=u)throw Error(i(137,t));break;default:uu(e,t,r,u,n,null)}}return void yt(e,a,l,c,d,o,s,!1);case"select":for(s in Xd("invalid",e),r=o=a=null,n)if(n.hasOwnProperty(s)&&null!=(l=n[s]))switch(s){case"value":a=l;break;case"defaultValue":o=l;break;case"multiple":r=l;default:uu(e,t,s,l,n,null)}return t=a,n=o,e.multiple=!!r,void(null!=t?wt(e,!!r,t,!1):null!=n&&wt(e,!!r,n,!0));case"textarea":for(o in Xd("invalid",e),a=s=r=null,n)if(n.hasOwnProperty(o)&&null!=(l=n[o]))switch(o){case"value":r=l;break;case"defaultValue":s=l;break;case"children":a=l;break;case"dangerouslySetInnerHTML":if(null!=l)throw Error(i(91));break;default:uu(e,t,o,l,n,null)}return void kt(e,r,s,a);case"option":for(c in n)if(n.hasOwnProperty(c)&&null!=(r=n[c]))if("selected"===c)e.selected=r&&"function"!==typeof r&&"symbol"!==typeof r;else uu(e,t,c,r,n,null);return;case"dialog":Xd("beforetoggle",e),Xd("toggle",e),Xd("cancel",e),Xd("close",e);break;case"iframe":case"object":Xd("load",e);break;case"video":case"audio":for(r=0;r<Yd.length;r++)Xd(Yd[r],e);break;case"image":Xd("error",e),Xd("load",e);break;case"details":Xd("toggle",e);break;case"embed":case"source":case"link":Xd("error",e),Xd("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(d in n)if(n.hasOwnProperty(d)&&null!=(r=n[d]))switch(d){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:uu(e,t,d,r,n,null)}return;default:if(At(t)){for(u in n)n.hasOwnProperty(u)&&(void 0!==(r=n[u])&&mu(e,t,u,r,n,void 0));return}}for(l in n)n.hasOwnProperty(l)&&(null!=(r=n[l])&&uu(e,t,l,r,n,null))}function hu(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var fu=null,xu=null;
vendor: 11,754 bytes, line 2
2function vu(e){return 9===e.nodeType?e:e.ownerDocument}function gu(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function yu(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function bu(e,t){return"textarea"===e||"noscript"===e||"string"===typeof t.children||"number"===typeof t.children||"bigint"===typeof t.children||"object"===typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var wu=null;var ju="function"===typeof setTimeout?setTimeout:void 0,ku="function"===typeof clearTimeout?clearTimeout:void 0,Nu="function"===typeof Promise?Promise:void 0,_u="function"===typeof queueMicrotask?queueMicrotask:"undefined"!==typeof Nu?function(e){return Nu.resolve(null).then(e).catch(Du)}:ju;function Du(e){setTimeout(function(){throw e})}function Cu(e){return"head"===e}function Au(e,t){var n=t,a=0;do{var r=n.nextSibling;if(e.removeChild(n),r&&8===r.nodeType)if("/$"===(n=r.data)||"/&"===n){if(0===a)return e.removeChild(r),void Hm(t);a--}else if("$"===n||"$?"===n||"$~"===n||"$!"===n||"&"===n)a++;else if("html"===n)Mu(e.ownerDocument.documentElement);else if("head"===n){Mu(n=e.ownerDocument.head);for(var s=n.firstChild;s;){var i=s.nextSibling,o=s.nodeName;s[Ye]||"SCRIPT"===o||"STYLE"===o||"LINK"===o&&"stylesheet"===s.rel.toLowerCase()||n.removeChild(s),s=i}}else"body"===n&&Mu(e.ownerDocument.body);n=r}while(n);Hm(t)}function Su(e,t){var n=e;e=0;do{var a=n.nextSibling;if(1===n.nodeType?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",""===n.getAttribute("style")&&n.removeAttribute("style")):3===n.nodeType&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),a&&8===a.nodeType)if("/$"===(n=a.data)){if(0===e)break;e--}else"$"!==n&&"$?"!==n&&"$~"!==n&&"$!"!==n||e++;n=a}while(n)}function Eu(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Eu(n),Je(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function Fu(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Tu(e.nextSibling)))return null}return e}function Ru(e){return"$?"===e.data||"$~"===e.data}function Iu(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Tu(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Pu=null;function Ou(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n||"/&"===n){if(0===t)return Tu(e.nextSibling);t--}else"$"!==n&&"$!"!==n&&"$?"!==n&&"$~"!==n&&"&"!==n||t++}e=e.nextSibling}return null}function Bu(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n||"$~"===n||"&"===n){if(0===t)return e;t--}else"/$"!==n&&"/&"!==n||t++}e=e.previousSibling}return null}function Lu(e,t,n){switch(t=vu(n),e){case"html":if(!(e=t.documentElement))throw Error(i(452));return e;case"head":if(!(e=t.head))throw Error(i(453));return e;case"body":if(!(e=t.body))throw Error(i(454));return e;default:throw Error(i(451))}}function Mu(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Je(e)}var zu=new Map,Uu=new Set;function Vu(e){return"function"===typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var qu=P.d;P.d={f:function(){var e=qu.f(),t=ed();return e||t},r:function(e){var t=Xe(e);null!==t&&5===t.tag&&"form"===t.type?ao(t):qu.r(e)},D:function(e){qu.D(e),Hu("dns-prefetch",e,null)},C:function(e,t){qu.C(e,t),Hu("preconnect",e,t)},L:function(e,t,n){qu.L(e,t,n);var a=Wu;if(a&&e&&t){var r='link[rel="preload"][as="'+vt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(r+='[imagesrcset="'+vt(n.imageSrcSet)+'"]',"string"===typeof n.imageSizes&&(r+='[imagesizes="'+vt(n.imageSizes)+'"]')):r+='[href="'+vt(e)+'"]';var s=r;switch(t){case"style":s=Ku(e);break;case"script":s=$u(e)}zu.has(s)||(e=p({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),zu.set(s,e),null!==a.querySelector(r)||"style"===t&&a.querySelector(Yu(s))||"script"===t&&a.querySelector(Xu(s))||(pu(t=a.createElement("link"),"link",e),et(t),a.head.appendChild(t)))}},m:function(e,t){qu.m(e,t);var n=Wu;if(n&&e){var a=t&&"string"===typeof t.as?t.as:"script",r='link[rel="modulepreload"][as="'+vt(a)+'"][href="'+vt(e)+'"]',s=r;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":s=$u(e)}if(!zu.has(s)&&(e=p({rel:"modulepreload",href:e},t),zu.set(s,e),null===n.querySelector(r))){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Xu(s)))return}pu(a=n.createElement("link"),"link",e),et(a),n.head.appendChild(a)}}},X:function(e,t){qu.X(e,t);var n=Wu;if(n&&e){var a=Ze(n).hoistableScripts,r=$u(e),s=a.get(r);s||((s=n.querySelector(Xu(r)))||(e=p({src:e,async:!0},t),(t=zu.get(r))&&tm(e,t),et(s=n.createElement("script")),pu(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},a.set(r,s))}},S:function(e,t,n){qu.S(e,t,n);var a=Wu;if(a&&e){var r=Ze(a).hoistableStyles,s=Ku(e);t=t||"default";var i=r.get(s);if(!i){var o={loading:0,preload:null};if(i=a.querySelector(Yu(s)))o.loading=5;else{e=p({rel:"stylesheet",href:e,"data-precedence":t},n),(n=zu.get(s))&&em(e,n);var l=i=a.createElement("link");et(l),pu(l,"link",e),l._p=new Promise(function(e,t){l.onload=e,l.onerror=t}),l.addEventListener("load",function(){o.loading|=1}),l.addEventListener("error",function(){o.loading|=2}),o.loading|=4,Zu(i,t,a)}i={type:"stylesheet",instance:i,count:1,state:o},r.set(s,i)}}},M:function(e,t){qu.M(e,t);var n=Wu;if(n&&e){var a=Ze(n).hoistableScripts,r=$u(e),s=a.get(r);s||((s=n.querySelector(Xu(r)))||(e=p({src:e,async:!0,type:"module"},t),(t=zu.get(r))&&tm(e,t),et(s=n.createElement("script")),pu(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},a.set(r,s))}}};var Wu="undefined"===typeof document?null:document;function Hu(e,t,n){var a=Wu;if(a&&"string"===typeof t&&t){var r=vt(t);r='link[rel="'+e+'"][href="'+r+'"]',"string"===typeof n&&(r+='[crossorigin="'+n+'"]'),Uu.has(r)||(Uu.add(r),e={rel:e,crossOrigin:n,href:t},null===a.querySelector(r)&&(pu(t=a.createElement("link"),"link",e),et(t),a.head.appendChild(t)))}}function Gu(e,t,n,a){var r=(r=G.current)?Vu(r):null;if(!r)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return"string"===typeof n.precedence&&"string"===typeof n.href?(t=Ku(n.href),(a=(n=Ze(r).hoistableStyles).get(t))||(a={type:"style",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"===typeof n.href&&"string"===typeof n.precedence){e=Ku(n.href);var s=Ze(r).hoistableStyles,o=s.get(e);if(o||(r=r.ownerDocument||r,o={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},s.set(e,o),(s=r.querySelector(Yu(e)))&&!s._p&&(o.instance=s,o.state.loading=5),zu.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},zu.set(e,n),s||function(e,t,n,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),pu(t,"link",n),et(t),e.head.appendChild(t))}(r,e,n,o.state))),t&&null===a)throw Error(i(528,""));return o}if(t&&null!==a)throw Error(i(529,""));return null;case"script":return t=n.async,"string"===typeof(n=n.src)&&t&&"function"!==typeof t&&"symbol"!==typeof t?(t=$u(n),(a=(n=Ze(r).hoistableScripts).get(t))||(a={type:"script",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Ku(e){return'href="'+vt(e)+'"'}function Yu(e){return'link[rel="stylesheet"]['+e+"]"}function Ju(e){return p({},e,{"data-precedence":e.precedence,precedence:null})}function $u(e){return'[src="'+vt(e)+'"]'}function Xu(e){return"script[async]"+e}function Qu(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+vt(n.href)+'"]');if(a)return t.instance=a,et(a),a;var r=p({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return et(a=(e.ownerDocument||e).createElement("style")),pu(a,"style",r),Zu(a,n.precedence,e),t.instance=a;case"stylesheet":r=Ku(n.href);var s=e.querySelector(Yu(r));if(s)return t.state.loading|=4,t.instance=s,et(s),s;a=Ju(n),(r=zu.get(r))&&em(a,r),et(s=(e.ownerDocument||e).createElement("link"));var o=s;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),pu(s,"link",a),t.state.loading|=4,Zu(s,n.precedence,e),t.instance=s;case"script":return s=$u(n.src),(r=e.querySelector(Xu(s)))?(t.instance=r,et(r),r):(a=n,(r=zu.get(s))&&tm(a=p({},n),r),et(r=(e=e.ownerDocument||e).createElement("script")),pu(r,"link",a),e.head.appendChild(r),t.instance=r);case"void":return null;default:throw Error(i(443,t.type))}else"stylesheet"===t.type&&0===(4&t.state.loading)&&(a=t.instance,t.state.loading|=4,Zu(a,n.precedence,e));return t.instance}function Zu(e,t,n){for(var a=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=a.length?a[a.length-1]:null,s=r,i=0;i<a.length;i++){var o=a[i];if(o.dataset.precedence===t)s=o;else if(s!==r)break}s?s.parentNode.insertBefore(e,s.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function em(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function tm(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var nm=null;function am(e,t,n){if(null===nm){var a=new Map,r=nm=new Map;r.set(n,a)}else(a=(r=nm).get(n))||(a=new Map,r.set(n,a));if(a.has(e))return a;for(a.set(e,null),n=n.getElementsByTagName(e),r=0;r<n.length;r++){var s=n[r];if(!(s[Ye]||s[Ue]||"link"===e&&"stylesheet"===s.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==s.namespaceURI){var i=s.getAttribute(t)||"";i=e+i;var o=a.get(i);o?o.push(s):a.set(i,[s])}}return a}function rm(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function sm(e){return"stylesheet"!==e.type||0!==(3&e.state.loading)}var im=0;function om(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)cm(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var lm=null;function cm(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,lm=new Map,t.forEach(dm,e),lm=null,om.call(e))}function dm(e,t){if(!(4&t.state.loading)){var n=lm.get(e);if(n)var a=n.get(null);else{n=new Map,lm.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),s=0;s<r.length;s++){var i=r[s];"LINK"!==i.nodeName&&"not all"===i.getAttribute("media")||(n.set(i.dataset.precedence,i),a=i)}a&&n.set(null,a)}i=(r=t.instance).getAttribute("data-precedence"),(s=n.get(i)||a)===a&&n.set(null,r),n.set(i,r),this.count++,a=om.bind(this),r.addEventListener("load",a),r.addEventListener("error",a),s?s.parentNode.insertBefore(r,
vendor: 4,641 bytes, line 2
2s.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(r,e.firstChild),t.state.loading|=4}}var um={$$typeof:w,Provider:null,Consumer:null,_currentValue:O,_currentValue2:O,_threadCount:0};function mm(e,t,n,a,r,s,i,o,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Fe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Fe(0),this.hiddenUpdates=Fe(null),this.identifierPrefix=a,this.onUncaughtError=r,this.onCaughtError=s,this.onRecoverableError=i,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function pm(e,t,n,a,r,s,i,o,l,c,d,u){return e=new mm(e,t,n,i,l,c,d,u,o),t=1,!0===s&&(t|=24),s=Ma(3,null,null,t),e.current=s,s.stateNode=e,(t=zr()).refCount++,e.pooledCache=t,t.refCount++,s.memoizedState={element:a,isDehydrated:n,cache:t},vs(s),e}function hm(e){return e?e=Ba:Ba}function fm(e,t,n,a,r,s){r=hm(r),null===a.context?a.context=r:a.pendingContext=r,(a=ys(t)).payload={element:n},null!==(s=void 0===s?null:s)&&(a.callback=s),null!==(n=bs(e,a,t))&&(Jc(n,0,t),ws(n,e,t))}function xm(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function vm(e,t){xm(e,t),(e=e.alternate)&&xm(e,t)}function gm(e){if(13===e.tag||31===e.tag){var t=Ta(e,67108864);null!==t&&Jc(t,0,67108864),vm(e,67108864)}}function ym(e){if(13===e.tag||31===e.tag){var t=Kc(),n=Ta(e,t=Oe(t));null!==n&&Jc(n,0,t),vm(e,t)}}var bm=!0;function wm(e,t,n,a){var r=T.T;T.T=null;var s=P.p;try{P.p=2,km(e,t,n,a)}finally{P.p=s,T.T=r}}function jm(e,t,n,a){var r=T.T;T.T=null;var s=P.p;try{P.p=8,km(e,t,n,a)}finally{P.p=s,T.T=r}}function km(e,t,n,a){if(bm){var r=Nm(a);if(null===r)nu(e,t,a,_m,n),Om(e,a);else if(function(e,t,n,a,r){switch(t){case"focusin":return Sm=Bm(Sm,e,t,n,a,r),!0;case"dragenter":return Em=Bm(Em,e,t,n,a,r),!0;case"mouseover":return Fm=Bm(Fm,e,t,n,a,r),!0;case"pointerover":var s=r.pointerId;return Rm.set(s,Bm(Rm.get(s)||null,e,t,n,a,r)),!0;case"gotpointercapture":return s=r.pointerId,Im.set(s,Bm(Im.get(s)||null,e,t,n,a,r)),!0}return!1}(r,e,t,n,a))a.stopPropagation();else if(Om(e,a),4&t&&-1<Pm.indexOf(e)){for(;null!==r;){var s=Xe(r);if(null!==s)switch(s.tag){case 3:if((s=s.stateNode).current.memoizedState.isDehydrated){var i=De(s.pendingLanes);if(0!==i){var o=s;for(o.pendingLanes|=2,o.entangledLanes|=2;i;){var l=1<<31-be(i);o.entanglements[1]|=l,i&=~l}Od(s),0===(6&hc)&&(Pc=le()+500,Bd(0,!1))}}break;case 31:case 13:null!==(o=Ta(s,2))&&Jc(o,0,2),ed(),vm(s,2)}if(null===(s=Nm(a))&&nu(e,t,a,_m,n),s===r)break;r=s}null!==r&&a.stopPropagation()}else nu(e,t,a,null,n)}}function Nm(e){return Dm(e=Tt(e))}var _m=null;function Dm(e){if(_m=null,null!==(e=$e(e))){var t=l(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=c(t)))return e;e=null}else if(31===n){if(null!==(e=d(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return _m=e,null}function Cm(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ce()){case de:return 2;case ue:return 8;case me:case pe:return 32;case he:return 268435456;default:return 32}default:return 32}}var Am=!1,Sm=null,Em=null,Fm=null,Rm=new Map,Im=new Map,Tm=[],Pm="mou
2sedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Om(e,t){switch(e){case"focusin":case"focusout":Sm=null;break;case"dragenter":case"dragleave":Em=null;break;case"mouseover":case"mouseout":Fm=null;break;case"pointerover":case"pointerout":Rm.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Im.delete(t.pointerId)}}function Bm(e,t,n,a,r,s){return null===e||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:a,nativeEvent:s,targetContainers:[r]},null!==t&&(null!==(t=Xe(t))&&gm(t)),e):(e.eventSystemFlags|=a,t=e.targetContainers,null!==r&&-1===t.indexOf(r)&&t.push(r),e)}function Lm(e){var t=$e(e.target);if(null!==t){var n=l(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=c(n)))return e.blockedOn=t,void Me(e.priority,function(){ym(n)})}else if(31===t){if(null!==(t=d(n)))return e.blockedOn=t,void Me(e.priority,function(){ym(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Mm(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Nm(e.nativeEvent);if(null!==n)return null!==(t=Xe(n))&&gm(t),e.blockedOn=n,!1;var a=new(n=e.nativeEvent).constructor(n.type,n);It=a,n.target.dispatchEvent(a),It=null,t.shift()}return!0}function zm(e,t,n){Mm(e)&&n.delete(t)}function Um(){Am=!1,null!==Sm&&Mm(Sm)&&(Sm=null),null!==Em&&Mm(Em)&&(Em=null),null!==Fm&&Mm(Fm)&&(Fm=null),Rm.forEach(zm),Im.forEach(zm)}function Vm(e,t){e.blockedOn===t&&(e.blockedOn=null,Am||(Am=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,Um)))}var qm=null;function Wm(e){qm!==e&&(qm=e,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){qm===e&&(qm=null);for(var t=0;t<e.length;t+=3){var n=e[t],a=e[t+1],r=e[t+2];if("function"!==typeof a){if(null===Dm(a||n))continue;break}var s=Xe(n);null!==s&&(e.splice(t,3),t-=3,to(s,{pending:!0,data:r,method:n.method,action:a},a,r))}}))}function Hm(e){function t(t){return Vm(t,e)}null!==Sm&&Vm(Sm,e),null!==Em&&Vm(Em,e),null!==Fm&&Vm(Fm,e),Rm.forEach(t),Im.forEach(t);for(var n=0;n<Tm.length;n++){var a=Tm[n];a.blockedOn===e&&(a.blockedOn=null)}for(;0<Tm.length&&null===(n=Tm[0]).blockedOn;)Lm(n),null===n.blockedOn&&Tm.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(a=0;a<n.length;a+=3){var r=n[a],s=n[a+1],i=r[Ve]||null;if("function"===typeof s)i||Wm(n);else if(i){var o=null;if(s&&s.hasAttribute("formAction")){if(r=s,i=s[Ve]||null)o=i.formAction;else if(null!==Dm(r))continue}else o=i.action;"function"===typeof o?n[a+1]=o:(n.splice(a,3),a-=3),Wm(n)}}}function Gm(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return r=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==r&&(r(),r=null),a||setTimeout(n,20)}function n(){if(!a&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"===typeof navigation){var a=!1,r=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){a=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==r&&(r(),r=null)}}}function Km(e){this._internalRoot=e}function Ym(e){this._internalRoot=e}Ym.prototype.render=Km.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(i(409));fm(t.current,Kc(),e,t,null,null)},Ym.prototype.unmount=Km.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;fm(e.current,2,null,e,null,null),ed(),t[qe]=null}},Ym.prototype.unstable_scheduleHydration=function(e){if(e){var t=Le();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Tm.length&&0!==t&&t<Tm[n].priority;n++);Tm.splice(n,0,e),0===n&&Lm(e)}};var Jm=r.version;if("19.2.3"!==Jm)throw Error(i(527,Jm,"19.2.3"));P.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"===typeof e.render)throw Error(i(188));throw e=Object.keys(e).join(","),Error(i(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=l(e)))throw Error(i(188));return t!==e?null:e}for(var n=e,a=t;;){var r=n.return;if(null===r)break;var s=r.alternate;if(null===s){if(null!==(a=r.return)){n=a;continue}break}if(r.child===s.child){for(s=r.child;s;){if(s===n)return u(r),e;if(s===a)return u(r),t;s=s.sibling}throw Error(i(188))}if(n.return!==a.return)n=r,a=s;else{for(var o=!1,c=r.child;c;){if(c===n){o=!0,n=r,a=s;break}if(c===a){o=!0,a=r,n=s;break}c=c.sibling}if(!o){for(c=s.child;c;){if(c===n){o=!0,n=s,a=r;break}if(c===a){o=!0,a=s,n=r;break}c=c.sibling}if(!o)throw Error(i(189))}}if(n.alternate!==a)throw Error(i(190))}if(3!==n.tag)throw Error(i(188));return n.stateNode.current===n?e:t}(t),e=null===(e=null!==e?m(e):null)?null:e.stateNode};var $m={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:T,reconcilerVersion:"19.2.3"};if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Xm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xm.isDisabled&&Xm.supportsFiber)try{ve=Xm.inject($m),ge=Xm}catch(Zm){}}t.createRoot=function(e,t){if(!o(e))throw Error(i(299));var n=!1,a="",r=_o,s=Do,l=Co;return null!==t&&void 0!==t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(a=t.identifierPrefix),void 0!==t.onUncaughtError&&(r=t.onUncaughtError),void 0!==t.onCaughtError&&(s=t.onCaughtError),void 0!==t.onRecoverableError&&(l=t.onRecoverableError)),t=pm(e,1,!1,null,0,n,a,null,r,s,l,Gm),e[qe]=t.current,eu(e),new Km(t)},t.hydrateRoot=function(e,t,n){if(!o(e))throw Error(i(299));var a=!1,r="",s=_o,l=Do,c=Co,d=null;return null!==n&&void 0!==n&&(!0===n.unstable_strictMode&&(a=!0),void 0!==n.identifierPrefix&&(r=n.identifierPrefix),void 0!==n.onUncaughtError&&(s=n.onUncaughtError),void 0!==n.onCaughtError&&(l=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.formState&&(d=n.formState)),(t=pm(e,1,!0,t,0,a,r,d,s,l,c,Gm)).context=hm(null),n=t.current,(r=ys(a=Oe(a=Kc()))).callback=null,bs(n,r,a),n=a,t.current.lanes=n,Re(t,n),Od(t),e[qe]=t.current,eu(e),new Ym(t)},t.version="19.2.3"},43(e,t,n){e.exports=n(288)},106(e){var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;
2\s]*/,l=/^\s+|\s+$/g,c="";function d(e){return e?e.replace(l,c):c}e.exports=function(e,l){if("string"!==typeof e)throw new TypeError("First argument must be a string");if(!e)return[];l=l||{};var u=1,m=1;function p(e){var t=e.match(n);t&&(u+=t.length);var a=e.lastIndexOf("\n");m=~a?e.length-a:m+e.length}function h(){var e={line:u,column:m};return function(t){return t.position=new f(e),g(),t}}function f(e){this.start=e,this.end={line:u,column:m},this.source=l.source}function x(t){var n=new Error(l.source+":"+u+":"+m+": "+t);if(n.reason=t,n.filename=l.source,n.line=u,n.column=m,n.source=e,!l.silent)throw n}function v(t){var n=t.exec(e);if(n){var a=n[0];return p(a),e=e.slice(a.length),n}}function g(){v(a)}function y(e){var t;for(e=e||[];t=b();)!1!==t&&e.push(t);return e}function b(){var t=h();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;c!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,c===e.charAt(n-1))return x("End of comment missing");var a=e.slice(2,n-2);return m+=2,p(a),e=e.slice(n),m+=2,t({type:"comment",comment:a})}}function w(){var e=h(),n=v(r);if(n){if(b(),!v(s))return x("property missing ':'");var a=v(i),l=e({type:"declaration",property:d(n[0].replace(t,c)),value:a?d(a[0].replace(t,c)):c});return v(o),l}}return f.prototype.content=e,g(),function(){var e,t=[];for(y(t);e=w();)!1!==e&&(t.push(e),y(t));return t}()}},146(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.camelCase=void 0;var n=/^--[a-zA-Z0-9_-]+$/,a=/-([a-z])/g,r=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(e,t){return t.toUpperCase()},l=function(e,t){return"".concat(t,"-")};t.camelCase=function(e,t){return void 0===t&&(t={}),function(e){return!e||r.test(e)||n.test(e)}(e)?e:(e=e.toLowerCase(),(e=t.reactCompat?e.replace(i,l):e.replace(s,l)).replace(a,o))}},222(e,t,n){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){let n=null;if(!e||"string"!==typeof e)return n;const a=(0,r.default)(e),s="function"===typeof t;return a.forEach(e=>{if("declaration"!==e.type)return;const{property:a,value:r}=e;s?t(a,r,e):r&&(n=n||{},n[a]=r)}),n};const r=a(n(106))},240(e){var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,a=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=function(e){return"function"===typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},i=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var a,r=t.call(e,"constructor"),s=e.constructor&&e.constructor.prototype&&t.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!s)return!1;for(a in e);return"undefined"===typeof a||t.call(e,a)},o=function(e,t){a&&"__proto__"===t.name?a(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,n){if("__proto__"===n){if(!t.call(e,n))return;if(r)return r(e,n).value}return e[n]};e.exports=function e(){var t,n,a,r,c,d,u=arguments[0],m=1,p=arguments.length,h=!1;for("boolean"===typeof u&&(h=u,u=arguments[1]||{},m=2),(null==u||"object"!==typeof u&&"function"!==typeof u)&&(u={});m<p;++m)if(null!=(t=arguments[m]))for(n in t)a=l(u,n),u!==(r=l(t,n))&&(h&&r&&(i(r)||(c=s(r)))?(c?(c=!1,d=a&&s(a)?a:[]):d=a&&i(a)?a:{},o(u,{name:n,newValue:e(h,d,r)})):"undefined"!==typeof r&&o(u,{name:n,newValue:r}));return u}},266(e,t,n){n.d(t,{Di:()=>i});const a="ndorflow.chimeMuted";let r=0;function s(){try{return!("undefined"===typeof window||!window.localStorage)&&"true"===window.localStorage.getItem(a)}catch(e){return!1}}function i(){try{if("undefined"===typeof window)return;if(s())return;const e=Date.now();if(e-r<2e3)return;r=e;const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const n=new t,a=n.currentTime,i=[{freq:880,start:0,dur:.16},{freq:1318.51,start:.13,dur:.18}],o=n.createGain();o.gain.value=.07,o.connect(n.destination),i.forEach(e=>{let{freq:t,start:r,dur:s}=e;const i=n.createOscillator(),l=n.createGain();i.type="sine",i.frequency.value=t,l.gain.value=0,l.gain.setValueAtTime(0,a+r),l.gain.linearRampToValueAtTime(1,a+r+.02),l.gain.linearRampToValueAtTime(0,a+r+s),i.connect(l),l.connect(o),i.start(a+r),i.stop(a+r+s+.01)}),setTimeout(()=>{try{n.close()}catch(e){}},500)}catch(e){}}},288(e,t){var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),h=Symbol.iterator;var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,v={};function g(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||f}function y(){}function b(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||f}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("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")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},y.prototype=g.prototype;var w=b.prototype=new y;w.constructor=b,x(w,g.prototype),w.isPureReactComponent=!0;var j=Array.isArray;function k(){}var N={H:null,A:null,T:null,S:null},_=Object.prototype.hasOwnProperty;function D(e,t,a){var r=a.ref;return{$$typeof:n,type:e,key:t,ref:void 0!==r?r:null,props:a}}function C(e){return"object"===typeof e&&null!==e&&e.$$typeof===n}var A=/\/+/g;function S(e,t){return"object"===typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function E(e,t,r,s,i){var o=typeof e;"undefined"!==o&&"boolean"!==o||(e=null);var l,c,d=!1;if(null===e)d=!0;else switch(o){case"bigint":case"string":case"number":d=!0;break;case"object":switch(e.$$typeof){case n:case a:d=!0;break;case m:return E((d=e._init)(e._payload),t,r,s,i)}}if(d)return i=i(e),d=""===s?"."+S(e,0):s,j(i)?(r="",null!=d&&(r=d.replace(A,"$&/")+"/"),E(i,t,r,"",function(e){return e})):null!=i&&(C(i)&&(l=i,c=r+(null==i.key||e&&e.key===i.key?"":(""+i.key).replace(A,"$&/")+"/")+d,i=D(l.type,c,l.props)),t.push(i)),1;d=0;var u,p=""===s?".":s+":";if(j(e))for(var f=0;f<e.length;f++)d+=E(s=e[f],t,r,o=p+S(s,f),i);else if("function"===typeof(f=null===(u=e)||"object"!==typeof u?null:"function"===typeof(u=h&&u[h]||u["@@iterator"])?u:null))for(e=f.call(e),f=0;!(s=e.next()).done;)d+=E(s=s.value,t,r,o=p+S(s,f++),i);else if("object"===o){if("function"===typeof e.then)return E(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"===typeof e.status?e.then(k,k):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(e),t,r,s,i);throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return d}function F(e,t,n){if(null==e)return e;var a=[],r=0;return E(e,a,"","",function(e){return t.call(n,e,r++)}),a}function R(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var I="function"===typeof reportError?reportError:function(e){if("object"===typeof window&&"function"===typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"===typeof e&&null!==e&&"string"===typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"===typeof process&&"function"===typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)}
2,T={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};t.Activity=p,t.Children=T,t.Component=g,t.Fragment=r,t.Profiler=i,t.PureComponent=b,t.StrictMode=s,t.Suspense=d,t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,t.__COMPILER_RUNTIME={__proto__:null,c:function(e){return N.H.useMemoCache(e)}},t.cache=function(e){return function(){return e.apply(null,arguments)}},t.cacheSignal=function(){return null},t.cloneElement=function(e,t,n){if(null===e||void 0===e)throw Error("The argument must be a React element, but you passed "+e+".");var a=x({},e.props),r=e.key;if(null!=t)for(s in void 0!==t.key&&(r=""+t.key),t)!_.call(t,s)||"key"===s||"__self"===s||"__source"===s||"ref"===s&&void 0===t.ref||(a[s]=t[s]);var s=arguments.length-2;if(1===s)a.children=n;else if(1<s){for(var i=Array(s),o=0;o<s;o++)i[o]=arguments[o+2];a.children=i}return D(e.type,r,a)},t.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:o,_context:e},e},t.createElement=function(e,t,n){var a,r={},s=null;if(null!=t)for(a in void 0!==t.key&&(s=""+t.key),t)_.call(t,a)&&"key"!==a&&"__self"!==a&&"__source"!==a&&(r[a]=t[a]);var i=arguments.length-2;if(1===i)r.children=n;else if(1<i){for(var o=Array(i),l=0;l<i;l++)o[l]=arguments[l+2];r.children=o}if(e&&e.defaultProps)for(a in i=e.defaultProps)void 0===r[a]&&(r[a]=i[a]);return D(e,s,r)},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:c,render:e}},t.isValidElement=C,t.lazy=function(e){return{$$typeof:m,_payload:{_status:-1,_result:e},_init:R}},t.memo=function(e,t){return{$$typeof:u,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=N.T,n={};N.T=n;try{var a=e(),r=N.S;null!==r&&r(n,a),"object"===typeof a&&null!==a&&"function"===typeof a.then&&a.then(k,I)}catch(s){I(s)}finally{null!==t&&null!==n.types&&(t.types=n.types),N.T=t}},t.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},t.use=function(e){return N.H.use(e)},t.useActionState=function(e,t,n){return N.H.useActionState(e,t,n)},t.useCallback=function(e,t){return N.H.useCallback(e,t)},t.useContext=function(e){return N.H.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e,t){return N.H.useDeferredValue(e,t)},t.useEffect=function(e,t){return N.H.useEffect(e,t)},t.useEffectEvent=function(e){return N.H.useEffectEvent(e)},t.useId=function(){return N.H.useId()},t.useImperativeHandle=function(e,t,n){return N.H.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return N.H.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return N.H.useLayoutEffect(e,t)},t.useMemo=function(e,t){return N.H.useMemo(e,t)},t.useOptimistic=function(e,t){return N.H.useOptimistic(e,t)},t.useReducer=function(e,t,n){return N.H.useReducer(e,t,n)},t.useRef=function(e){return N.H.useRef(e)},t.useState=function(e){return N.H.useState(e)},t.useSyncExternalStore=function(e,t,n){return N.H.useSyncExternalStore(e,t,n)},t.useTransition=function(){return N.H.useTransition()},t.version="19.2.3"},294(e,t,n){var a=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(n(222)),r=n(146);function s(e,t){var n={};return e&&"string"===typeof e?((0,a.default)(e,function(e,a){e&&a&&(n[(0,r.camelCase)(e,t)]=a)}),n):n}s.default=s,e.exports=s},326(e,t,n){n.d(t,{Cl:()=>a,Tt:()=>r,fX:()=>i,sH:()=>s});var a=function(){return a=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},a.apply(this,arguments)};function r(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n}
2function s(e,t,n,a){return new(n||(n=Promise))(function(r,s){function i(e){try{l(a.next(e))}catch(t){s(t)}}function o(e){try{l(a.throw(e))}catch(t){s(t)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,o)}l((a=a.apply(e,t||[])).next())})}Object.create;function i(e,t,n){if(n||2===arguments.length)for(var a,r=0,s=t.length;r<s;r++)!a&&r in t||(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}Object.create;"function"===typeof SuppressedError&&SuppressedError},330(e,t,n){var a=n(43);var r="function"===typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e===1/t)||e!==e&&t!==t},s=a.useState,i=a.useEffect,o=a.useLayoutEffect,l=a.useDebugValue;function c(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(a){return!0}}var d="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),a=s({inst:{value:n,getSnapshot:t}}),r=a[0].inst,d=a[1];return o(function(){r.value=n,r.getSnapshot=t,c(r)&&d({inst:r})},[e,n,t]),i(function(){return c(r)&&d({inst:r}),e(function(){c(r)&&d({inst:r})})},[e]),l(n),n};t.useSyncExternalStore=void 0!==a.useSyncExternalStore?a.useSyncExternalStore:d},391(e,t,n){!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=n(4)},461(e,t,n){e.exports=n(330)},555(e,t,n){function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function r(e){var t=function(e,t){if("object"!=a(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==a(t)?t:t+""}function s(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}n.d(t,{A:()=>o})},579(e,t,n){e.exports=n(799)},657(e,t,n){n.d(t,{A:()=>a});const a="rc-1-55-z4-2026-05-13"},672(e,t,n){var a=n(43);function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var i={d:{f:s,r:function(){throw Error(r(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},o=Symbol.for("react.portal");var l=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){return"font"===e?"":"string"===typeof t?"use-credentials"===t?t:"":void 0}t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,t.createPortal=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!t||1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType)throw Error(r(299));return function(e,t,n){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:o,key:null==a?null:""+a,children:e,containerInfo:t,implementation:n}}(e,t,null,n)},t.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},t.preconnect=function(e,t){"string"===typeof e&&(t?t="string"===typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,i.d.C(e,t))},t.prefetchDNS=function(e){"string"===typeof e&&i.d.D(e)},t.preinit=function(e,t){if("string"===typeof e&&t&&"string"===typeof t.as){var n=t.as,a=c(n,t.crossOrigin),r="string"===typeof t.integrity?t.integrity:void 0,s="string"===typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?i.d.S(e,"string"===typeof t.precedence?t.precedence:void 0,{crossOrigin:a,integrity:r,fetchPriority:s}):"script"===n&&i.d.X(e,{crossOrigin:a,integrity:r,fetchPriority:s,nonce:"string"===typeof t.nonce?t.nonce:void 0})}},t.preinitModule=function(e,t){if("string"===typeof e)if("object"===typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:"string"===typeof t.integrity?t.integrity:void 0,nonce:"string"===typeof t.nonce?t.nonce:void 0})}}else null==t&&i.d.M(e)},t.preload=function(e,t){if("string"===typeof e&&"object"===typeof t&&null!==t&&"string"===typeof t.as){var n=t.as,a=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:a,integrity:"string"===typeof t.integrity?t.integrity:void 0,nonce:"string"===typeof t.nonce?t.nonce:void 0,type:"string"===typeof t.type?t.type:void 0,fetchPriority:"string"===typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"str
2ing"===typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"===typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"===typeof t.imageSizes?t.imageSizes:void 0,media:"string"===typeof t.media?t.media:void 0})}},t.preloadModule=function(e,t){if("string"===typeof e)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:"string"===typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"===typeof t.integrity?t.integrity:void 0})}else i.d.m(e)},t.requestFormReset=function(e){i.d.r(e)},t.unstable_batchedUpdates=function(e,t){return e(t)},t.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},t.useFormStatus=function(){return l.H.useHostTransitionStatus()},t.version="19.2.3"},695(e,t,n){n.d(t,{generateCvVariantWithPolling:()=>i});var a=n(555),r=n(657),s=n(266);async function i(e){const{requestBody:t,apiPost:n,apiGet:i,signal:c,onRunStatus:d,telemetryHeaders:u,onRunIdReady:m}=e;if(!n||!i)throw new Error("generateCvVariantWithPolling: apiPost + apiGet required");const p=(0,a.A)({"X-Ndor-Dispatch-Surface":"workspace_cv_section_v1","X-Ndor-Bundle-Version":r.A},u||{}),h=await n("/api/runs",{method:"POST",headers:p,body:{action_code:"cv_variant",payload:t}});if(!h||"object"!==typeof h)throw new Error("cv-variant run dispatch returned non-object");const f=h.served_via||"sync_200";if("sync_200"===f||"replay_200"===f)return h.result&&"object"===typeof h.result?h.result:h;if("async_202"===f){const e=h.run_id;if(!e)throw new Error("cv-variant async_202 envelope missing run_id");if("function"===typeof m)try{m(e)}catch(x){}if("function"===typeof d)try{d("running")}catch(v){}return async function(e,t){const{apiGet:n,signal:r,onRunStatus:i}=t;if(!e)throw new Error("pollCvVariantRun: runId is required");const c=Date.now()+12e4;let d=3e3;const u=()=>{"undefined"!==typeof document&&"visible"===document.visibilityState&&(d=500)};"undefined"!==typeof document&&document.addEventListener&&document.addEventListener("visibilitychange",u);try{for(;Date.now()<c;){if(r&&r.aborted)throw new Error("Polling aborted");let t=null;try{t=await n("/api/cv-variants/".concat(e),{headers:{"X-RC-1-52-Poll":"1"}})}catch(x){console.warn("[RC 1.52 cvVariantPolling] transient read error",x),t=null}if(t){const n=(t.status||t.run_status||"complete").toLowerCase();if("function"===typeof i)try{i(n)}catch(v){}if("complete"===n){try{(0,s.Di)()}catch(g){}var m,p,h,f;return t.result&&"object"===typeof t.result?(0,a.A)((0,a.A)({},t.result),{},{billing:null!==(m=t.billing)&&void 0!==m?m:null,served_via:null!==(p=t.served_via)&&void 0!==p?p:"poll_200",run_id:null!==(h=t.run_id)&&void 0!==h?h:t.result.variant_id,status:"complete",idempotent_replay:null!==(f=t.idempotent_replay)&&void 0!==f&&f}):l(t)}if("failed"===n){const n=new Error(t.error_detail||t.run_error_detail||"CV variant generation failed.");throw n.code=t.error_code||t.run_error_code||"cv_variant_failed",n.runStatus="failed",n.runId=e,n}"number"===typeof t.retry_after_ms&&t.retry_after_ms>=1500&&(d=t.retry_after_ms)}await o(d,r)}const t=new Error("CV variant still generating in the background.");throw t.code="cv_variant_still_running",t.runId=e,t.recoverable=!0,t}finally{"undefined"!==typeof document&&document.removeEventListener&&document.removeEventListener("visibilitychange",u)}}(e,{apiGet:i,signal:c,onRunStatus:d})}return h.result||h}function o(e,t){return new Promise((n,a)=>{const r=setTimeout(n,e);t&&t.addEventListener&&t.addEventListener("abort",()=>{clearTimeout(r),a(new Error("Polling aborted"))})})}function l(e){const t=e.content_json||{};return{variant_id:e.id,variant_name:e.variant_name,role_family:e.role_family,fit_summary:t,generated_text:e.content_markdown||"",created_at:e.created_at,run_status:"complete"}}},799(e,t){var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function r(e,t,a){var r=null;if(void 0!==a&&(r=""+a),void 0!==t.key&&(r=""+t.key),"key"in t)for(var s in a={},t)"key"!==s&&(a[s]=t[s]);else a=t;return t=a.ref,{$$typeof:n,type:e,key:r,ref:void 0!==t?t:null,props:a}}t.Fragment=a,t.jsx=r,t.jsxs=r},820(e,t,n){n.d(t,{supabase:()=>Ea});var a=n(326);
2class r extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"FunctionsError",n=arguments.length>2?arguments[2]:void 0;super(e),this.name=t,this.context=n}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class s extends r{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class i extends r{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class o extends r{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var l;!function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"}(l||(l={}));class c{constructor(e){let{headers:t={},customFetch:n,region:a=l.Any}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.url=e,this.headers=t,this.region=a,this.fetch=(e=>e?function(){return e(...arguments)}:function(){return fetch(...arguments)})(n)}setAuth(e){this.headers.Authorization="Bearer ".concat(e)}invoke(e){return(0,a.sH)(this,arguments,void 0,function(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){var a;let r,l;try{const{headers:c,method:d,body:u,signal:m,timeout:p}=n;let h={},{region:f}=n;f||(f=t.region);const x=new URL("".concat(t.url,"/").concat(e));let v;f&&"any"!==f&&(h["x-region"]=f,x.searchParams.set("forceFunctionRegion",f)),u&&(c&&!Object.prototype.hasOwnProperty.call(c,"Content-Type")||!c)?"undefined"!==typeof Blob&&u instanceof Blob||u instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",v=u):"string"===typeof u?(h["Content-Type"]="text/plain",v=u):"undefined"!==typeof FormData&&u instanceof FormData?v=u:(h["Content-Type"]="application/json",v=JSON.stringify(u)):v=!u||"string"===typeof u||"undefined"!==typeof Blob&&u instanceof Blob||u instanceof ArrayBuffer||"undefined"!==typeof FormData&&u instanceof FormData?u:JSON.stringify(u);let g=m;p&&(l=new AbortController,r=setTimeout(()=>l.abort(),p),m?(g=l.signal,m.addEventListener("abort",()=>l.abort())):g=l.signal);const y=yield t.fetch(x.toString(),{method:d||"POST",headers:Object.assign(Object.assign(Object.assign({},h),t.headers),c),body:v,signal:g}).catch(e=>{throw new s(e)}),b=y.headers.get("x-relay-error");if(b&&"true"===b)throw new i(y);if(!y.ok)throw new o(y);let w,j=(null!==(a=y.headers.get("Content-Type"))&&void 0!==a?a:"text/plain").split(";")[0].trim();return w="application/json"===j?yield y.json():"application/octet-stream"===j||"application/pdf"===j?yield y.blob():"text/event-stream"===j?y:"multipart/form-data"===j?yield y.formData():yield y.text(),{data:w,error:null,response:y}}catch(c){return{data:null,error:c,response:c instanceof o||c instanceof i?c.context:void 0}}finally{r&&clearTimeout(r)}}()})}}const d=e=>Math.min(1e3*2**e,3e4),u=[520,503],m=["GET","HEAD","OPTIONS"];var p=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.co
2de=e.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function h(e,t){return new Promise(n=>{if(null===t||void 0===t?void 0:t.aborted)return void n();const a=setTimeout(()=>{null===t||void 0===t||t.removeEventListener("abort",r),n()},e);function r(){clearTimeout(a),n()}null===t||void 0===t||t.addEventListener("abort",r)})}function f(e,t,n,a){return!(!a||n>=3)&&(!!m.includes(e)&&!!u.includes(t))}var x=class{constructor(e){var t,n,a,r,s;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!==(t=e.shouldThrowOnError)&&void 0!==t&&t,this.signal=e.signal,this.isMaybeSingle=null!==(n=e.isMaybeSingle)&&void 0!==n&&n,this.shouldStripNulls=null!==(a=e.shouldStripNulls)&&void 0!==a&&a,this.urlLengthLimit=null!==(r=e.urlLengthLimit)&&void 0!==r?r:8e3,this.retryEnabled=null===(s=e.retry)||void 0===s||s,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if("text/csv"===this.headers.get("Accept"))throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}retry(e){return this.retryEnabled=e,this}then(e,t){var n=this;if(void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){const e=this.headers.get("Accept");"application/vnd.pgrst.object+json"===e?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):e&&"application/json"!==e||this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const a=this.fetch;let r=(async()=>{let e=0;for(;;){const i=new Headers(n.headers);let o;e>0&&i.set("X-Retry-Count",String(e));try{o=await a(n.url.toString(),{method:n.method,headers:i,body:JSON.stringify(n.body),signal:n.signal})}catch(s){if("AbortError"===(null===s||void 0===s?void 0:s.name)||"ABORT_ERR"===(null===s||void 0===s?void 0:s.code))throw s;if(!m.includes(n.method))throw s;if(n.retryEnabled&&e<3){const t=d(e);e++,await h(t,n.signal);continue}throw s}if(f(n.method,o.status,e,n.retryEnabled)){var t,r;const a=null!==(t=null===(r=o.headers)||void 0===r?void 0:r.get("Retry-After"))&&void 0!==t?t:null,s=null!==a?1e3*Math.max(0,parseInt(a,10)||0):d(e);await o.text(),e++,await h(s,n.signal);continue}return await n.processResponse(o)}})();return this.shouldThrowOnError||(r=r.catch(e=>{var t;let n="",a="",r="";const s=null===e||void 0===e?void 0:e.cause;if(s){var i,o,l,c;const t=null!==(i=null===s||void 0===s?void 0:s.message)&&void 0!==i?i:"",a=null!==(o=null===s||void 0===s?void 0:s.code)&&void 0!==o?o:"";n="".concat(null!==(l=null===e||void 0===e?void 0:e.name)&&void 0!==l?l:"FetchError",": ").concat(null===e||void 0===e?void 0:e.message),n+="\n\nCaused by: ".concat(null!==(c=null===s||void 0===s?void 0:s.name)&&void 0!==c?c:"Error",": ").concat(t),a&&(n+=" (".concat(a,")")),(null===s||void 0===s?void 0:s.stack)&&(n+="\n".concat(s.stack))}else{var d;n=null!==(d=null===e||void 0===e?void 0:e.stack)&&void 0!==d?d:""}const u=this.url.toString().length;return"AbortError"===(null===e||void 0===e?void 0:e.name)||"ABORT_ERR"===(null===e||void 0===e?void 0:e.code)?(r="",a="Request was aborted (timeout or manual cancellation)",u>this.urlLengthLimit&&(a+=". Note: Your request URL is ".concat(u," characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side."))):"HeadersOverflowError"!==(null===s||void 0===s?void 0:s.name)&&"UND_ERR_HEADERS_OVERFLOW"!==(null===s||void 0===s?void 0:s.code)||(r="",a="HTTP headers exceeded server limits (typically 16KB)",u>this.urlLengthLimit&&(a+=". Your request URL is ".concat(u," characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead."))),{success:!1,error:{message:"".concat(null!==(t=null===e||void 0===e?void 0:e.name)&&void 0!==t?t:"FetchError",": ").concat(null===e||void 0===e?void 0:e.message),details:n,hint:a,code:r},data:null,count:null,status:0,statusText:""}}
2)),r.then(e,t)}async processResponse(e){var t=this;let n=null,a=null,r=null,s=e.status,i=e.statusText;if(e.ok){var o,l;if("HEAD"!==t.method){var c;const n=await e.text();""===n||(a="text/csv"===t.headers.get("Accept")||t.headers.get("Accept")&&(null===(c=t.headers.get("Accept"))||void 0===c?void 0:c.includes("application/vnd.pgrst.plan+text"))?n:JSON.parse(n))}const d=null===(o=t.headers.get("Prefer"))||void 0===o?void 0:o.match(/count=(exact|planned|estimated)/),u=null===(l=e.headers.get("content-range"))||void 0===l?void 0:l.split("/");d&&u&&u.length>1&&(r=parseInt(u[1])),t.isMaybeSingle&&Array.isArray(a)&&(a.length>1?(n={code:"PGRST116",details:"Results contain ".concat(a.length," rows, application/vnd.pgrst.object+json requires 1 row"),hint:null,message:"JSON object requested, multiple (or no) rows returned"},a=null,r=null,s=406,i="Not Acceptable"):a=1===a.length?a[0]:null)}else{const r=await e.text();try{n=JSON.parse(r),Array.isArray(n)&&404===e.status&&(a=[],n=null,s=200,i="OK")}catch(d){404===e.status&&""===r?(s=204,i="No Content"):n={message:r}}if(n&&t.shouldThrowOnError)throw new p(n)}return{success:null===n,error:n,data:a,count:r,status:s,statusText:i}}returns(){return this}overrideTypes(){return this}},v=class extends x{select(e){let t=!1;const n=(null!==e&&void 0!==e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e){let{ascending:t=!0,nullsFirst:n,foreignTable:a,referencedTable:r=a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=r?"".concat(r,".order"):"order",i=this.url.searchParams.get(s);return this.url.searchParams.set(s,"".concat(i?"".concat(i,","):"").concat(e,".").concat(t?"asc":"desc").concat(void 0===n?"":n?".nullsfirst":".nullslast")),this}limit(e){let{foreignTable:t,referencedTable:n=t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a="undefined"===typeof n?"limit":"".concat(n,".limit");return this.url.searchParams.set(a,"".concat(e)),this}range(e,t){let{foreignTable:n,referencedTable:a=n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r="undefined"===typeof a?"offset":"".concat(a,".offset"),s="undefined"===typeof a?"limit":"".concat(a,".limit");return this.url.searchParams.set(r,"".concat(e)),this.url.searchParams.set(s,"".concat(t-e+1)),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain(){let{analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:a=!1,wal:r=!1,format:s="text"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var i;const o=[e?"analyze":null,t?"verbose":null,n?"settings":null,a?"buffers":null,r?"wal":null].filter(Boolean).join("|"),l=null!==(i=this.headers.get("Accept"))&&void 0!==i?i:"application/json";return this.headers.set("Accept","application/vnd.pgrst.plan+".concat(s,'; for="').concat(l,'"; options=').concat(o,";")),this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer","max-affected=".concat(e)),this}};const g=new RegExp("[,()]");var y=class extends v{eq(e,t){return this.url.searchParams.append(e,"eq.".concat(t)),this}neq(e,t){return this.url.searchParams.append(e,"neq.".concat(t)),this}gt(e,t){return this.url.searchParams.append(e,"gt.".concat(t)),this}gte(e,t){return this.url.searchParams.append(e,"gte.".concat(t)),this}lt(e,t){return this.url.searchParams.append(e,"lt.".concat(t)),this}lte(e,t){return this.url.searchParams.append(e,"lte.".concat(t)),this}like(e,t){return this.url.searchParams.append(e,"like.".concat(t)),this}likeAllOf(e,t){return this.url.searchParams.append(e,"like(all).{".concat(t.join(","),"}")),this}likeAnyOf(e,t){return this.url.searchParams.append(e,"like(any).{".concat(t.join(","),"}")),this}ilike(e,t){return this.url.searchParams.append(e,"ilike.".concat(t)),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,"ilike(all).{".concat(t.join(","),"}")),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,"ilike(any).{".concat(t.join(","),"}")),this}regexMatch(e,t){return this.url.searchParams.append(e,"match.".concat(t)),this}regexIMatch(e,t){return this.url.searchParams.append(e,"imatch.".concat(t)),this}is(e,t){return this.url.searchParams.append(e,"is.".concat(t)),this}isDistinct(e,t){return this.url.searchParams.append(e,"isdistinct.".concat(t)),this}in(e,t){const n=Array.from(new Set(t)).map(e=>"string"===typeof e&&g.test(e)?'"'.concat(e,'"'):"".concat(e)).join(",");return this.url.searchParams.append(e,"in.(".concat(n,")")),this}notIn(e,t){const n=Array.from(new Set(t)).map(e=>"string"===typeof e&&g.test(e)?'"'.concat(e,'"'):"".concat(e)).join(",");return this.url.searchParams.append(e,"not.in.(".concat(n,")")),this}contains(e,t){return"string"===typeof t?this.url.searchParams.append(e,"cs.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cs.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cs.".concat(JSON.stringify(t))),this}containedBy(e,t){return"string"===typeof t?this.url.searchParams.append(e,"cd.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cd.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cd.".concat(JSON.stringify(t))),this}rangeGt(e,t){return this.url.searchParams.append(e,"sr.".concat(t)),this}rangeGte(e,t){return this.url.searchParams.append(e,"nxl.".concat(t)),this}rangeLt(e,t){return this.url.searchParams.append(e,"sl.".concat(t)),this}rangeLte(e,t){return this.url.searchParams.append(e,"nxr.".concat(t)),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,"adj.".concat(t)),this}overlaps(e,t){return"string"===typeof t?this.url.searchParams.append(e,"ov.".concat(t)):this.url.searchParams.append(e,"ov.{".concat(t.join(","),"}")),this}
2textSearch(e,t){let{config:n,type:a}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r="";"plain"===a?r="pl":"phrase"===a?r="ph":"websearch"===a&&(r="w");const s=void 0===n?"":"(".concat(n,")");return this.url.searchParams.append(e,"".concat(r,"fts").concat(s,".").concat(t)),this}match(e){return Object.entries(e).filter(e=>{let[t,n]=e;return void 0!==n}).forEach(e=>{let[t,n]=e;this.url.searchParams.append(t,"eq.".concat(n))}),this}not(e,t,n){return this.url.searchParams.append(e,"not.".concat(t,".").concat(n)),this}or(e){let{foreignTable:t,referencedTable:n=t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=n?"".concat(n,".or"):"or";return this.url.searchParams.append(a,"(".concat(e,")")),this}filter(e,t,n){return this.url.searchParams.append(e,"".concat(t,".").concat(n)),this}},b=class{constructor(e,t){let{headers:n={},schema:a,fetch:r,urlLengthLimit:s=8e3,retry:i}=t;this.url=e,this.headers=new Headers(n),this.schema=a,this.fetch=r,this.urlLengthLimit=s,this.retry=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(e,t){const{head:n=!1,count:a}=null!==t&&void 0!==t?t:{},r=n?"HEAD":"GET";let s=!1;const i=(null!==e&&void 0!==e?e:"*").split("").map(e=>/\s/.test(e)&&!s?"":('"'===e&&(s=!s),e)).join(""),{url:o,headers:l}=this.cloneRequestState();return o.searchParams.set("select",i),a&&l.append("Prefer","count=".concat(a)),new y({method:r,url:o,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(e){let{count:t,defaultToNull:n=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var a;const{url:r,headers:s}=this.cloneRequestState();if(t&&s.append("Prefer","count=".concat(t)),n||s.append("Prefer","missing=default"),Array.isArray(e)){const t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){const e=[...new Set(t)].map(e=>'"'.concat(e,'"'));r.searchParams.set("columns",e.join(","))}}return new y({method:"POST",url:r,headers:s,schema:this.schema,body:e,fetch:null!==(a=this.fetch)&&void 0!==a?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(e){let{onConflict:t,ignoreDuplicates:n=!1,count:a,defaultToNull:r=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var s;const{url:i,headers:o}=this.cloneRequestState();if(o.append("Prefer","resolution=".concat(n?"ignore":"merge","-duplicates")),void 0!==t&&i.searchParams.set("on_conflict",t),a&&o.append("Prefer","count=".concat(a)),r||o.append("Prefer","missing=default"),Array.isArray(e)){const t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){const e=[...new Set(t)].map(e=>'"'.concat(e,'"'));i.searchParams.set("columns",e.join(","))}}return new y({method:"POST",url:i,headers:o,schema:this.schema,body:e,fetch:null!==(s=this.fetch)&&void 0!==s?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(e){let{count:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;const{url:a,headers:r}=this.cloneRequestState();return t&&r.append("Prefer","count=".concat(t)),new y({method:"PATCH",url:a,headers:r,schema:this.schema,body:e,fetch:null!==(n=this.fetch)&&void 0!==n?n:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete(){let{count:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t;const{url:n,headers:a}=this.cloneRequestState();return e&&a.append("Prefer","count=".concat(e)),new y({method:"DELETE",url:n,headers:a,schema:this.schema,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function j(e){var t=function(e,t){if("object"!=w(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=w(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==w(t)?t:t+""}
2function k(e,t,n){return(t=j(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function N(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?N(Object(n),!0).forEach(function(t){k(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var D=class e{constructor(e){let{headers:t={},schema:n,fetch:a,timeout:r,urlLengthLimit:s=8e3,retry:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.url=e,this.headers=new Headers(t),this.schemaName=n,this.urlLengthLimit=s;const o=null!==a&&void 0!==a?a:globalThis.fetch;this.fetch=void 0!==r&&r>0?(e,t)=>{const n=new AbortController,a=setTimeout(()=>n.abort(),r),s=null===t||void 0===t?void 0:t.signal;if(s){if(s.aborted)return clearTimeout(a),o(e,t);const r=()=>{clearTimeout(a),n.abort()};return s.addEventListener("abort",r,{once:!0}),o(e,_(_({},t),{},{signal:n.signal})).finally(()=>{clearTimeout(a),s.removeEventListener("abort",r)})}return o(e,_(_({},t),{},{signal:n.signal})).finally(()=>clearTimeout(a))}:o,this.retry=i}from(e){if(!e||"string"!==typeof e||""===e.trim())throw new Error("Invalid relation name: relation must be a non-empty string.");return new b(new URL("".concat(this.url,"/").concat(e)),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(t){return new e(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{head:n=!1,get:a=!1,count:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var s;let i;const o=new URL("".concat(this.url,"/rpc/").concat(e));let l;const c=e=>null!==e&&"object"===typeof e&&(!Array.isArray(e)||e.some(c)),d=n&&Object.values(t).some(c);d?(i="POST",l=t):n||a?(i=n?"HEAD":"GET",Object.entries(t).filter(e=>{let[t,n]=e;return void 0!==n}).map(e=>{let[t,n]=e;return[t,Array.isArray(n)?"{".concat(n.join(","),"}"):"".concat(n)]}).forEach(e=>{let[t,n]=e;o.searchParams.append(t,n)})):(i="POST",l=t);const u=new Headers(this.headers);return d?u.set("Prefer",r?"count=".concat(r,",return=minimal"):"return=minimal"):r&&u.set("Prefer","count=".concat(r)),new y({method:i,url:o,headers:u,schema:this.schemaName,body:l,fetch:null!==(s=this.fetch)&&void 0!==s?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};const C=class{constructor(){}static detectEnvironment(){var e;if("undefined"!==typeof WebSocket)return{type:"native",constructor:WebSocket};if("undefined"!==typeof globalThis&&"undefined"!==typeof globalThis.WebSocket)return{type:"native",constructor:globalThis.WebSocket};if("undefined"!==typeof n.g&&"undefined"!==typeof n.g.WebSocket)return{type:"native",constructor:n.g.WebSocket};if("undefined"!==typeof globalThis&&"undefined"!==typeof globalThis.WebSocketPair&&"undefined"===typeof globalThis.WebSocket)return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if("undefined"!==typeof globalThis&&globalThis.EdgeRuntime||"undefined"!==typeof navigator&&(null===(e=navigator.userAgent)||void 0===e?void 0:e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const t=globalThis.process;if(t){const e=t.versions;if(e&&e.node){const t=e.node,n=parseInt(t.replace(/^v/,"").split(".")[0]);return n>=22?"undefined"!==typeof globalThis.WebSocket?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:"Node.js ".concat(n," detected but native WebSocket not found."),workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:"Node.js ".concat(n," detected without native WebSocket support."),workaround:'For Node.js < 22, install "ws" package and provide it via the transport option:\nimport ws from "ws"\nnew RealtimeClient(url, { transport: ws })'}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+="\n\nSuggested solution: ".concat(e.workaround)),new Error(t)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return"native"===e.type||"ws"===e.type}catch(e){return!1}}},A="realtime-js/".concat("2.103.0"),S="2.0.0",E=S,F="closed",R="errored",I="joined",T="joining",P="leaving",O={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"},B="connecting",L="closing",M="closed";class z{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=null!==e&&void 0!==e?e:[]}encode(e,t){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&"string"===typeof e.payload.event)return t(this._binaryEncodeUserBroadcastPush(e));let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))}_binaryEncodeUserBroadcastPush(e){var t;return this._isArrayBuffer(null===(t=e.payload)||void 0===t?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var t,n;const a=null!==(n=null===(t=e.payload)||void 0===t?void 0:t.payload)&&void 0!==n?n:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,a)}_encodeJsonUserBroadcastPush(e){var t,n;const a=null!==(n=null===(t=e.payload)||void 0===t?void 0:t.payload)&&void 0!==n?n:{},r=(new TextEncoder).encode(JSON.stringify(a)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,r)}
2_encodeUserBroadcastPush(e,t,n){var a,r;const s=e.topic,i=null!==(a=e.ref)&&void 0!==a?a:"",o=null!==(r=e.join_ref)&&void 0!==r?r:"",l=e.payload.event,c=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},d=0===Object.keys(c).length?"":JSON.stringify(c);if(o.length>255)throw new Error("joinRef length ".concat(o.length," exceeds maximum of 255"));if(i.length>255)throw new Error("ref length ".concat(i.length," exceeds maximum of 255"));if(s.length>255)throw new Error("topic length ".concat(s.length," exceeds maximum of 255"));if(l.length>255)throw new Error("userEvent length ".concat(l.length," exceeds maximum of 255"));if(d.length>255)throw new Error("metadata length ".concat(d.length," exceeds maximum of 255"));const u=this.USER_BROADCAST_PUSH_META_LENGTH+o.length+i.length+s.length+l.length+d.length,m=new ArrayBuffer(this.HEADER_LENGTH+u);let p=new DataView(m),h=0;p.setUint8(h++,this.KINDS.userBroadcastPush),p.setUint8(h++,o.length),p.setUint8(h++,i.length),p.setUint8(h++,s.length),p.setUint8(h++,l.length),p.setUint8(h++,d.length),p.setUint8(h++,t),Array.from(o,e=>p.setUint8(h++,e.charCodeAt(0))),Array.from(i,e=>p.setUint8(h++,e.charCodeAt(0))),Array.from(s,e=>p.setUint8(h++,e.charCodeAt(0))),Array.from(l,e=>p.setUint8(h++,e.charCodeAt(0))),Array.from(d,e=>p.setUint8(h++,e.charCodeAt(0)));var f=new Uint8Array(m.byteLength+n.byteLength);return f.set(new Uint8Array(m),0),f.set(new Uint8Array(n),m.byteLength),f.buffer}decode(e,t){if(this._isArrayBuffer(e)){return t(this._binaryDecode(e))}if("string"===typeof e){const n=JSON.parse(e),[a,r,s,i,o]=n;return t({join_ref:a,ref:r,topic:s,event:i,payload:o})}return t({})}_binaryDecode(e){const t=new DataView(e),n=t.getUint8(0),a=new TextDecoder;if(n===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,t,a)}_decodeUserBroadcast(e,t,n){const a=t.getUint8(1),r=t.getUint8(2),s=t.getUint8(3),i=t.getUint8(4);let o=this.HEADER_LENGTH+4;const l=n.decode(e.slice(o,o+a));o+=a;const c=n.decode(e.slice(o,o+r));o+=r;const d=n.decode(e.slice(o,o+s));o+=s;const u=e.slice(o,e.byteLength),m=i===this.JSON_ENCODING?JSON.parse(n.decode(u)):u,p={type:this.BROADCAST_EVENT,event:c,payload:m};return s>0&&(p.meta=JSON.parse(d)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST_EVENT,payload:p}}_isArrayBuffer(e){var t;return e instanceof ArrayBuffer||"ArrayBuffer"===(null===(t=null===e||void 0===e?void 0:e.constructor)||void 0===t?void 0:t.name)}_pick(e,t){return e&&"object"===typeof e?Object.fromEntries(Object.entries(e).filter(e=>{let[n]=e;return t.includes(n)})):{}}}var U;!function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(U||(U={}));const V=function(e,t){var n;const a=null!==(n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).skipTypes)&&void 0!==n?n:[];return t?Object.keys(t).reduce((n,r)=>(n[r]=q(r,e,t,a),n),{}):{}},q=(e,t,n,a)=>{const r=t.find(t=>t.name===e),s=null===r||void 0===r?void 0:r.type,i=n[e];return s&&!a.includes(s)?W(s,i):H(i)},W=(e,t)=>{if("_"===e.charAt(0)){const n=e.slice(1,e.length);return J(t,n)}switch(e){case U.bool:return G(t);case U.float4:case U.float8:case U.int2:case U.int4:case U.int8:case U.numeric:case U.oid:return K(t);case U.json:case U.jsonb:return Y(t);case U.timestamp:return $(t);case U.abstime:case U.date:case U.daterange:case U.int4range:case U.int8range:case U.money:case U.reltime:case U.text:case U.time:case U.timestamptz:case U.timetz:case U.tsrange:case U.tstzrange:default:return H(t)}},H=e=>e,G=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},K=e=>{if("string"===typeof e){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},Y=e=>{if("string"===typeof e)try{return JSON.parse(e)}catch(t){return e}return e},J=(e,t)=>
2{if("string"!==typeof e)return e;const n=e.length-1,a=e[n];if("{"===e[0]&&"}"===a){let a;const s=e.slice(1,n);try{a=JSON.parse("["+s+"]")}catch(r){a=s?s.split(","):[]}return a.map(e=>W(t,e))}return e},$=e=>"string"===typeof e?e.replace(" ","T"):e,X=e=>{const t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),""===t.pathname||"/"===t.pathname?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};var Q,Z,ee,te,ne=e=>{if("function"===typeof e)return e;return function(){return e}},ae="undefined"!==typeof self?self:null,re="undefined"!==typeof window?window:null,se=ae||re||globalThis,ie=0,oe=1,le=2,ce=3,de="closed",ue="errored",me="joined",pe="joining",he="leaving",fe="phx_close",xe="phx_error",ve="phx_join",ge="phx_reply",ye="phx_leave",be="longpoll",we="websocket",je=4,ke="base64url.bearer.phx.",Ne=class{constructor(e,t,n,a){this.channel=e,this.event=t,this.payload=n||function(){return{}},this.receivedResp=null,this.timeout=a,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive(e){let{status:t,response:n,_ref:a}=e;this.recHooks.filter(e=>e.status===t).forEach(e=>e.callback(n))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},_e=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},De=class{constructor(e,t,n){this.state=de,this.topic=e,this.params=ne(t||{}),this.socket=n,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Ne(this,ve,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new _e(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=me,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=ue,this.socket.hasLogger()&&this.socket.log("channel","error ".concat(this.topic),e),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel","close ".concat(this.topic)),this.state=de,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel","error ".concat(this.topic),e),this.isJoining()&&this.joinPush.reset(),this.state=ue,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel","timeout ".concat(this.topic),this.joinPush.timeout),new Ne(this,ye,ne({}),this.timeout).send(),this.state=ue,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(ge,(e,t)=>{this.trigger(this.replyEventName(t),e)})}join(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}
2teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=de,this.bindings=[]}onClose(e){this.on(fe,e)}onError(e){return this.on(xe,t=>e(t))}on(e,t){let n=this.bindingRef++;return this.bindings.push({event:e,ref:n,callback:t}),n}off(e,t){this.bindings=this.bindings.filter(n=>!(n.event===e&&("undefined"===typeof t||t===n.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.timeout;if(t=t||{},!this.joinedOnce)throw new Error("tried to push '".concat(e,"' to '").concat(this.topic,"' before joining. Use channel.join() before pushing events"));let a=new Ne(this,e,function(){return t},n);return this.canPush()?a.send():(a.startTimeout(),this.pushBuffer.push(a)),a}leave(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=he;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel","leave ".concat(this.topic)),this.trigger(fe,"leave")},n=new Ne(this,ye,ne({}),e);return n.receive("ok",()=>t()).receive("timeout",()=>t()),n.send(),this.canPush()||n.trigger("ok",{}),n}onMessage(e,t,n){return t}filterBindings(e,t,n){return!0}isMember(e,t,n,a){return this.topic===e&&(!a||a===this.joinRef()||(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:n,joinRef:a}),!1))}joinRef(){return this.joinPush.ref}rejoin(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=pe,this.joinPush.resend(e))}trigger(e,t,n,a){let r=this.onMessage(e,t,n,a);if(t&&!r)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let s=this.bindings.filter(a=>a.event===e&&this.filterBindings(a,t,n));for(let i=0;i<s.length;i++){s[i].callback(r,n,a||this.joinRef())}}replyEventName(e){return"chan_reply_".concat(e)}isClosed(){return this.state===de}isErrored(){return this.state===ue}isJoined(){return this.state===me}isJoining(){return this.state===pe}isLeaving(){return this.state===he}},Ce=class{static request(e,t,n,a,r,s,i){if(se.XDomainRequest){let n=new se.XDomainRequest;return this.xdomainRequest(n,e,t,a,r,s,i)}if(se.XMLHttpRequest){let o=new se.XMLHttpRequest;return this.xhrRequest(o,e,t,n,a,r,s,i)}if(se.fetch&&se.AbortController)return this.fetchRequest(e,t,n,a,r,s,i);throw new Error("No suitable XMLHttpRequest implementation found")}static fetchRequest(e,t,n,a,r,s,i){let o={method:e,headers:n,body:a},l=null;if(r){l=new AbortController;setTimeout(()=>l.abort(),r);o.signal=l.signal}return se.fetch(t,o).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>i&&i(e)).catch(e=>{"AbortError"===e.name&&s?s():i&&i(null)}),l}static xdomainRequest(e,t,n,a,r,s,i){return e.timeout=r,e.open(t,n),e.onload=()=>{let t=this.parseJSON(e.responseText);i&&i(t)},s&&(e.ontimeout=s),e.onprogress=()=>{},e.send(a),e}static xhrRequest(e,t,n,a,r,s,i,o){e.open(t,n,!0),e.timeout=s;for(let[l,c]of Object.entries(a))e.setRequestHeader(l,c);return e.onerror=()=>o&&o(null),e.onreadystatechange=()=>{if(e.readyState===je&&o){let t=this.parseJSON(e.responseText);o(t)}},i&&(e.ontimeout=i),e.send(r),e}static parseJSON(e){if(!e||""===e)return null;try{return JSON.parse(e)}catch(t){return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let n=[];for(var a in e){if(!Object.prototype.hasOwnProperty.call(e,a))continue;let r=t?"".concat(t,"[").concat(a,"]"):a,s=e[a];"object"===typeof s?n.push(this.serialize(s,r)):n.push(encodeURIComponent(r)+"="+encodeURIComponent(s))}return n.join("&")}static appendParams(e,t){if(0===Object.keys(t).length)return e;let n=e.match(/\?/)?"&":"?";return"".concat(e).concat(n).concat(this.serialize(t))}},Ae=class{constructor(e,t){t&&2===t.length&&t[1].startsWith(ke)&&(this.authToken=atob(t[1].slice(21))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){}
2,this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=ie,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+we),"$1/"+be)}endpointURL(){return Ce.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,n){this.close(e,t,n),this.readyState=ie}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===oe||this.readyState===ie}poll(){const e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:n,messages:a}=e;if(410===t&&null!==this.token)return this.onerror(410),void this.closeAndRetry(3410,"session_gone",!1);this.token=n}else t=0;switch(t){case 200:a.forEach(e=>{setTimeout(()=>this.onmessage({data:e}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=oe,this.onopen({}),this.poll();break;case 403:this.onerror
2(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error("unhandled poll status ".concat(t))}})}send(e){"string"!==typeof e&&(e=(e=>{let t="",n=new Uint8Array(e),a=n.byteLength;for(let r=0;r<a;r++)t+=String.fromCharCode(n[r]);return btoa(t)})(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},e.join("\n"),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,e&&200===e.status?this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[]):(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1))})}close(e,t,n){for(let r of this.reqs)r.abort();this.readyState=ce;let a=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:n});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,"undefined"!==typeof CloseEvent?this.onclose(new CloseEvent("close",a)):this.onclose(a)}ajax(e,t,n,a,r){let s;s=Ce.request(e,this.endpointURL(),t,n,this.timeout,()=>{this.reqs.delete(s),a()},e=>{this.reqs.delete(s),this.isActive()&&r(e)}),this.reqs.add(s)}},Se=class e{constructor(t){let n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(n.state,t=>{let{onJoin:n,onLeave:a,onSync:r}=this.caller;this.joinRef=this.channel.joinRef(),this.state=e.syncState(this.state,t,n,a),this.pendingDiffs.forEach(t=>{this.state=e.syncDiff(this.state,t,n,a)}),this.pendingDiffs=[],r()}),this.channel.on(n.diff,t=>{let{onJoin:n,onLeave:a,onSync:r}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(t):(this.state=e.syncDiff(this.state,t,n,a),r())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(t){return e.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,t,n,a){let r=this.clone(e),s={},i={};return this.map(r,(e,n)=>{t[e]||(i[e]=n)}),this.map(t,(e,t)=>{let n=r[e];if(n){let a=t.metas.map(e=>e.phx_ref),r=n.metas.map(e=>e.phx_ref),o=t.metas.filter(e=>r.indexOf(e.phx_ref)<0),l=n.metas.filter(e=>a.indexOf(e.phx_ref)<0);o.length>0&&(s[e]=t,s[e].metas=o),l.length>0&&(i[e]=this.clone(n),i[e].metas=l)}else s[e]=t}),this.syncDiff(r,{joins:s,leaves:i},n,a)}static syncDiff(e,t,n,a){let{joins:r,leaves:s}=this.clone(t);return n||(n=function(){}),a||(a=function(){}),this.map(r,(t,a)=>{let r=e[t];if(e[t]=this.clone(a),r){let n=e[t].metas.map(e=>e.phx_ref),a=r.metas.filter(e=>n.indexOf(e.phx_ref)<0);e[t].metas.unshift(...a)}n(t,r,a)}),this.map(s,(t,n)=>{let r=e[t];if(!r)return;let s=n.metas.map(e=>e.phx_ref);r.metas=r.metas.filter(e=>s.indexOf(e.phx_ref)<0),a(t,r,n),0===r.metas.length&&delete e[t]}),e}static list(e,t){return t||(t=function(e,t){return t}),this.map(e,(e,n)=>t(e,n))}static map(e,t){return Object.getOwnPropertyNames(e).map(n=>t(n,e[n]))}static clone(e){return JSON.parse(JSON.stringify(e))}},Ee={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(n))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[n,a,r,s,i]=JSON.parse(e);return t({join_ref:n,ref:a,topic:r,event:s,payload:i})}},binaryEncode(e){let{join_ref:t,ref:n,event:a,topic:r,payload:s}=e,i=this.META_LENGTH+t.length+n.length+r.length+a.length,o=new ArrayBuffer(this.HEADER_LENGTH+i),l=new DataView(o),c=0;l.setUint8(c++,this.KINDS.push),l.setUint8(c++,t.length),l.setUint8(c++,n.length),l.setUint8(c++,r.length),l.setUint8(c++,a.length),Array.from(t,e=>l.setUint8(c++,e.charCodeAt(0))),Array.from(n,e=>l.setUint8(c++,e.charCodeAt(0))),Array.from(r,e=>l.setUint8(c++,e.charCodeAt(0))),Array.from(a,e=>l.setUint8(c++,e.charCodeAt(0)));var d=new Uint8Array(o.byteLength+s.byteLength);return d.set(new Uint8Array(o),0),d.set(new Uint8Array(s),o.byteLength),d.buffer},binaryDecode(e){let t=new DataView(e),n=t.getUint8(0),a=new TextDecoder;switch(n){case this.KINDS.push:return this.decodePush(e,t,a);case this.KINDS.reply:return this.decodeReply(e,t,a);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,a)}}
2,decodePush(e,t,n){let a=t.getUint8(1),r=t.getUint8(2),s=t.getUint8(3),i=this.HEADER_LENGTH+this.META_LENGTH-1,o=n.decode(e.slice(i,i+a));i+=a;let l=n.decode(e.slice(i,i+r));i+=r;let c=n.decode(e.slice(i,i+s));return i+=s,{join_ref:o,ref:null,topic:l,event:c,payload:e.slice(i,e.byteLength)}},decodeReply(e,t,n){let a=t.getUint8(1),r=t.getUint8(2),s=t.getUint8(3),i=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,l=n.decode(e.slice(o,o+a));o+=a;let c=n.decode(e.slice(o,o+r));o+=r;let d=n.decode(e.slice(o,o+s));o+=s;let u=n.decode(e.slice(o,o+i));o+=i;let m=e.slice(o,e.byteLength);return{join_ref:l,ref:c,topic:d,event:ge,payload:{status:u,response:m}}},decodeBroadcast(e,t,n){let a=t.getUint8(1),r=t.getUint8(2),s=this.HEADER_LENGTH+2,i=n.decode(e.slice(s,s+a));s+=a;let o=n.decode(e.slice(s,s+r));return s+=r,{join_ref:null,ref:null,topic:i,event:o,payload:e.slice(s,e.byteLength)}}},Fe=class{constructor(e){var t,n;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.stateChangeCallbacks={open:[],close
2:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=a.timeout||1e4,this.transport=a.transport||se.WebSocket||Ae,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=a.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=a.sessionStorage||se&&se.sessionStorage,this.establishedConnections=0,this.defaultEncoder=Ee.encode.bind(Ee),this.defaultDecoder=Ee.decode.bind(Ee),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=a.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==Ae?(this.encode=a.encode||this.defaultEncoder,this.decode=a.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let r=null;re&&re.addEventListener&&(re.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),r=this.connectClock)}),re.addEventListener("pageshow",e=>{r===this.connectClock&&(r=null,this.connect())}),re.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?this.pageHidden=!0:(this.pageHidden=!1,this.isConnected()||this.closeWasClean||this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=a.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=null===(t=a.autoSendHeartbeat)||void 0===t||t,this.heartbeatCallback=null!==(n=a.heartbeatCallback)&&void 0!==n?n:()=>{},this.rejoinAfterMs=e=>a.rejoinAfterMs?a.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>a.reconnectAfterMs?a.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=a.logger||null,!this.logger&&a.debug&&(this.logger=(e,t,n)=>{console.log("".concat(e,": ").concat(t),n)}),this.longpollerTimeout=a.longpollerTimeout||2e4,this.params=ne(a.params||{}),this.endPoint="".concat(e,"/").concat(we),this.vsn=a.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new _e(()=>{if(this.pageHidden)return this.log("Not reconnecting as page is hidden!"),void this.teardown();this.teardown(async()=>{a.beforeReconnect&&await a.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=a.authToken}getLongPollTransport(){return Ae}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=Ce.appendParams(Ce.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return"/"!==e.charAt(0)?e:"/"===e.charAt(1)?"".concat(this.protocol(),":").concat(e):"".concat(this.protocol(),"://").concat(location.host).concat(e)}disconnect(e,t,n){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,n)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=ne(e)),this.conn&&!this.disconnecting||(this.longPollFallbackMs&&this.transport!==Ae?this.connectWithF
2allback(Ae,this.longPollFallbackMs):this.transportConnect())}log(e,t,n){this.logger&&this.logger(e,t,n)}hasLogger(){return null!==this.logger}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),n=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let a=this.onMessage(r=>{r.ref===t&&(this.off([a]),e(Date.now()-n))});return!0}transportName(e){return e===Ae?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix","".concat(ke).concat(btoa(this.authToken).replace(/=/g,""))]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2500;clearTimeout(this.fallbackTimer);let n,a=!1,r=!0,s=this.transportName(e),i=t=>{this.log("transport","falling back to ".concat(s,"..."),t),this.off([undefined,n]),r=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession("phx:fallback:".concat(s)))return i("memorized");this.fallbackTimer=setTimeout(i,t),n=this.onError(e=>{this.log("transport","error",e),r&&!a&&(clearTimeout(this.fallbackTimer),i(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(a=!0,!r){let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession("phx:fallback:".concat(t),"true"),this.log("transport","established ".concat(t," fallback"))}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(i,t),this.ping(e=>{this.log("transport","connected to primary after",e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport","connected to ".concat(this.endPointURL())),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),1e3,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,n){if(!this.conn)return e&&e();const a=this.conn;this.waitForBufferDone(a,()=>{t?a.close(t,n||""):a.close(),this.waitForSocketClosed(a,()=>{this.conn===a&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;5!==n&&e.bufferedAmount?setTimeout(()=>{this.waitForBufferDone(e,t,n+1)},150*n):t()}waitForSocketClosed(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;5!==n&&e.readyState!==ce?setTimeout(()=>{this.waitForSocketClosed(e,t,n+1)},150*n):t()}
2onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport",e);let t=this.transport,n=this.establishedConnections;this.triggerStateCallbacks("error",e,t,n),(t===this.transport||n>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(xe)})}connectionState(){switch(this.conn&&this.conn.readyState){case ie:return"connecting";case oe:return"open";case le:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(t=>{let[n]=t;return-1===e.indexOf(n)})}channel(e){let t=new De(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},this);return this.channels.push(t),t}push(e){if(this.hasLogger()){let{topic:t,event:n,payload:a,ref:r,join_ref:s}=e;this.log("push","".concat(t," ").concat(n," (").concat(s,", ").concat(r,")"),a)}this.isConnected()?this.encode(e,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(e,e=>this.conn.send(e)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(this.isConnected())if(this.pendingHeartbeatRef)this.heartbeatTimeout();else{this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}else try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:n,payload:a,ref:r,join_ref:s}=e;if(r&&r===this.pendingHeartbeatRef){const e=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback("ok"===a.status?"ok":"error",e)}catch(i){this.log("error","error in heartbeat callback",i)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive","".concat(a.status||""," ").concat(t," ").concat(n," ").concat(r&&"("+r+")"||"").trim(),a);for(let o=0;o<this.channels.length;o++){const e=this.channels[o];e.isMember(t,n,a,s)&&e.trigger(n,a,r,s)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];try{this.stateChangeCallbacks[e].forEach(t=>{let[a,r]=t;try{r(...n)}catch(s){this.log("error","error in ".concat(e," callback"),s)}})}catch(r){this.log("error","error triggering ".concat(e," callbacks"),r)}}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log("transport",'leaving duplicate topic "'.concat(e,'"')),t.leave())}};class Re{constructor(e,t){const n=function(e){return(null===e||void 0===e?void 0:e.events)&&{events:e.events}}(t);this.presence=new Se(e.getChannel(),n),this.presence.onJoin((t,n,a)=>{const r=Re.onJoinPayload(t,n,a);e.getChannel().trigger("presence",r)}),this.presence.onLeave((t,n,a)=>{const r=Re.onLeavePayload(t,n,a);e.getChannel().trigger("presence",r)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return Re.transformState(this.presence.state)}static transformState(e){return e=function(e){return JSON.parse(JSON.stringify(e))}(e),Object.getOwnPropertyNames(e).reduce((t,n)=>{const a=e[n];return t[n]=Ie(a),t},{})}static onJoinPayload(e,t,n){return{event:"join",key:e,currentPresences:Te(t),newPresences:Ie(n)}}static onLeavePayload(e,t,n){return{event:"leave",key:e,currentPresences:Te(t),leftPresences:Ie(n)}}}function Ie(e){return e.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function Te(e){return(null===e||void 0===e?void 0:e.metas)?Ie(e):[]}!function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"}(Q||(Q={}));class Pe{get state(){return this.presenceAdapter.state}constructor(e,t){this.channel=e,this.presenceAdapter=new Re(this.channel.channelAdapter,t)}}class Oe{constructor(e,t,n){const a=function(e){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},e.config)}}(n);this.channel=e.getSocket().channel(t,a),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,t){return this.channel.on(e,t)}off(e,t){this.channel.off(e,t)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}
2push(e,t,n){let a;try{a=this.channel.push(e,t,n)}catch(r){throw"tried to push '".concat(e,"' to '").concat(this.channel.topic,"' before joining. Use channel.subscribe() before pushing events")}if(this.channel.pushBuffer.length>100){const e=this.channel.pushBuffer.shift();e.cancelTimeout(),this.socket.log("channel","discarded push due to buffer overflow: ".concat(e.event),e.payload())}return a}updateJoinPayload(e){const t=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},t),e)}canPush(){return this.socket.isConnected()&&this.state===I}isJoined(){return this.state===I}isJoining(){return this.state===T}isClosed(){return this.state===F}isLeaving(){return this.state===P}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}!function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"}(Z||(Z={})),function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"}(ee||(ee={})),function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"}(te||(te={}));class Be{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}},n=arguments.length>2?arguments[2]:void 0;var a,r;if(this.topic=e,this.params=t,this.socket=n,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config),this.channelAdapter=new Oe(this.socket.socketAdapter,e,this.params),this.presence=new Pe(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=X(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(null===(r=null===(a=this.params.config)||void 0===a?void 0:a.broadcast)||void 0===r?void 0:r.replay))throw"tried to use replay on public channel '".concat(this.topic,"'. It must be a private channel.")}subscribe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.timeout;var n,a,r;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:s,presence:i,private:o}}=this.params,l=null!==(a=null===(n=this.bindings.postgres_changes)||void 0===n?void 0:n.map(e=>e.filter))&&void 0!==a?a:[],c=!!this.bindings[ee.PRESENCE]&&this.bindings[ee.PRESENCE].length>0||!0===(null===(r=this.params.config.presence)||void 0===r?void 0:r.enabled),d={},u={broadcast:s,presence:Object.assign(Object.assign({},i),{enabled:c}),postgres_changes:l,private:o};this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this._onError(t=>{null===e||void 0===e||e(te.CHANNEL_ERROR,t)}),this._onClose(()=>null===e||void 0===e?void 0:e(te.CLOSED)),this.updateJoinPayload(Object.assign({config:u},d)),this._updateFilterMessage(),this.channelAdapter.subscribe(t).receive("ok",async t=>{let{postgres_changes:n}=t;this.socket._isManualToken()||this.socket.setAuth(),void 0!==n?this._updatePostgresBindings(n,e):null===e||void 0===e||e(te.SUBSCRIBED)}).receive("error",t=>{this.state=R,null===e||void 0===e||e(te.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(t).join(", ")||"error")))}).receive("timeout",()=>{null===e||void 0===e||e(te.TIMED_OUT)})}return this}_updatePostgresBindings(e,t){var n;const a=this.bindings.postgres_changes,r=null!==(n=null===a||void 0===a?void 0:a.length)&&void 0!==n?n:0,s=[];for(let i=0;i<r;i++){const n=a[i],{filter:{event:r,schema:o,table:l,filter:c}}=n,d=e&&e[i];if(!(d&&d.event===r&&Be.isFilterValueEqual(d.schema,o)&&Be.isFilterValueEqual(d.table,l)&&Be.isFilterValueEqual(d.filter,c)))return this.unsubscribe(),this.state=R,void(null===t||void 0===t||t(te.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes")));s.push(Object.assign(Object.assign({},n),{id:d.id}))}this.bindings.postgres_changes=s,this.state!=R&&t&&t(te.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return await this.send({type:"presence",event:"untrack"},e)}on(e,t,n){const a=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),r=e===ee.PRESENCE||e===ee.POSTGRES_CHANGES;if(a&&r)throw this.socket.log("channel","cannot add `".concat(e,"` callbacks for ").concat(this.topic," after `subscribe()`.")),new Error("cannot add `".concat(e,"` callbacks for ").concat(this.topic," after `subscribe()`."));return this._on(e,t,n)}async httpSend(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var a;if(void 0===t||null===t)return Promise.reject("Payload is required for httpSend()");const r={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(r.Authorization="Bearer ".concat(this.socket.accessTokenValue));const s={method:"POST",headers:r,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:t,private:this.private}]})},i=await this._fetchWithTimeout(this.broadcastEndpointURL,s,null!==(a=n.timeout)&&void 0!==a?a:this.timeout);if(202===i.status)return{success:!0};let o=i.statusText;
2try{const e=await i.json();o=e.error||e.message||o}catch(l){}return Promise.reject(new Error(o))}async send(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,a;if(this.channelAdapter.canPush()||"broadcast"!==e.type)return new Promise(n=>{var a,r,s;const i=this.channelAdapter.push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null===(s=null===(r=null===(a=this.params)||void 0===a?void 0:a.config)||void 0===r?void 0:r.broadcast)||void 0===s?void 0:s.ack)||n("ok"),i.receive("ok",()=>n("ok")),i.receive("error",()=>n("error")),i.receive("timeout",()=>n("timed out"))});{console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:s,payload:i}=e,o={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(o.Authorization="Bearer ".concat(this.socket.accessTokenValue));const l={method:"POST",headers:o,body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:i,private:this.private}]})};try{const e=await this._fetchWithTimeout(this.broadcastEndpointURL,l,null!==(n=t.timeout)&&void 0!==n?n:this.timeout);return await(null===(a=e.body)||void 0===a?void 0:a.cancel()),e.ok?"ok":"error"}catch(r){return"AbortError"===r.name?"timed out":"error"}}}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;return new Promise(t=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>t("ok")).receive("timeout",()=>t("timed out")).receive("error",()=>t("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,t,n){const a=new AbortController,r=setTimeout(()=>a.abort(),n),s=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:a.signal}));return clearTimeout(r),s}_on(e,t,n){const a=e.toLocaleLowerCase(),r={type:a,filter:t,callback:n,ref:this.channelAdapter.on(e,n)};return this.bindings[a]?this.bindings[a].push(r):this.bindings[a]=[r],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,t,n)=>{var a,r,s,i,o,l,c;const d=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(d,n))return!1;const u=null===(a=this.bindings[d])||void 0===a?void 0:a.find(t=>t.ref===e.ref);if(!u)return!0;if(["broadcast","presence","postgres_changes"].includes(d)){if("id"in u){const e=u.id,n=null===(r=u.filter)||void 0===r?void 0:r.event;return e&&(null===(s=t.ids)||void 0===s?void 0:s.includes(e))&&("*"===n||(null===n||void 0===n?void 0:n.toLocaleLowerCase())===(null===(i=t.data)||void 0===i?void 0:i.type.toLocaleLowerCase()))}{const e=null===(l=null===(o=null===u||void 0===u?void 0:u.filter)||void 0===o?void 0:o.event)||void 0===l?void 0:l.toLocaleLowerCase();return"*"===e||e===(null===(c=null===t||void 0===t?void 0:t.event)||void 0===c?void 0:c.toLocaleLowerCase())}}return u.type.toLocaleLowerCase()===d})}_notThisChannelEvent(e,t){const{close:n,error:a,leave:r,join:s}=O;return t&&[n,a,r,s].includes(e)&&t!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,t,n)=>{if("object"===typeof t&&"ids"in t){const e=t.data,{schema:n,table:a,commit_timestamp:r,type:s,errors:i}=e,o={schema:n,table:a,commit_timestamp:r,eventType:s,new:{},old:{},errors:i};return Object.assign(Object.assign({},o),this._getPayloadRecords(e))}return t})}copyBindings(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const t in e.bindings)for(const n of e.bindings[t])this._on(n.type,n.filter,n.callback)}static isFilterValueEqual(e,t){return(null!==e&&void 0!==e?e:void 0)===(null!==t&&void 0!==t?t:void 0)}_getPayloadRecords(e){const t={new:{},old:{}};return"INSERT"!==e.type&&"UPDATE"!==e.type||(t.new=V(e.columns,e.record)),"UPDATE"!==e.type&&"DELETE"!==e.type||(t.old=V(e.columns,e.old_record)),t}}class Le{constructor(e,t){this.socket=new Fe(e,t)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e4;return new Promise(r=>{setTimeout(()=>r("timeout"),a),this.socket.disconnect(()=>{e(),r("ok")},t,n)})}push(e){this.socket.push(e)}log(e,t,n){this.socket.log(e,t,n)}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==B}isDisconnecting(){return this.socket.connectionState()==L}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const Me=25e3,ze=[1e3,2e3,5e3,1e4];class Ue{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,t){var n;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={}
2,this.ref=0,this.serializer=new z,this._manuallySetToken=!1,this._authPromise=null,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._resolveFetch=e=>e?function(){return e(...arguments)}:function(){return fetch(...arguments)},!(null===(n=null===t||void 0===t?void 0:t.params)||void 0===n?void 0:n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey;const a=this._initializeOptions(t);this.socketAdapter=new Le(e,a),this.httpEndpoint=X(e),this.fetch=this._resolveFetch(null===t||void 0===t?void 0:t.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(e){const t=e.message;if(t.includes("Node.js"))throw new Error("".concat(t,"\n\n")+'To use Realtime in Node.js, you need to provide a WebSocket implementation:\n\nOption 1: Use Node.js 22+ which has native WebSocket support\nOption 2: Install and provide the "ws" package:\n\n npm install ws\n\n import ws from "ws"\n const client = new RealtimeClient(url, {\n ...options,\n transport: ws\n })');throw new Error("WebSocket not available: ".concat(t))}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,t){return this.isDisconnecting()?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,t)}getChannels(){return this.channels}async removeChannel(e){const t=await e.unsubscribe();return"ok"===t&&e.teardown(),0===this.channels.length&&this.disconnect(),t}async removeAllChannels(){const e=this.channels.map(async e=>{const t=await e.unsubscribe();return e.teardown(),t}),t=await Promise.all(e);return this.disconnect(),t}log(e,t,n){this.socketAdapter.log(e,t,n)}connectionState(){return this.socketAdapter.connectionState()||M}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}};const n="realtime:".concat(e),a=this.getChannels().find(e=>e.topic===n);if(a)return a;{const n=new Be("realtime:".concat(e),t,this);return this.channels.push(n),n}}push(e){this.socketAdapter.push(e)}async setAuth(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(t=>t.topic!==e.topic)}async _performAuth(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=!1;if(t)e=t,n=!0;else if(this.accessToken)try{e=await this.accessToken()}catch(a){this.log("error","Error fetching access token from callback",a),e=this.accessTokenValue}else e=this.accessTokenValue;n?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=e&&(this.accessTokenValue=e,this.channels.forEach(t=>{const n={access_token:e,version:A};e&&t.updateJoinPayload(n),t.joinedOnce&&t.channelAdapter.isJoined()&&t.channelAdapter.push(O.access_token,{access_token:e})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"general";this._isManualToken()||this.setAuth().catch(t=>{this.log("error","Error setting auth in ".concat(e),t)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(e=>{this.log("error","error waiting for auth on connect",e)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>
2{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(t,n)=>{"sent"==t&&this._setAuthSafely(),e&&e(t,n)}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker","starting worker for from ".concat(this.workerUrl)):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log("worker","worker error",e.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=e=>{"keepAlive"===e.data.event&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let t;if(e)t=e;else{const e=new Blob(['\n addEventListener("message", (e) => {\n if (e.data.event === "start") {\n setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);\n }\n });'],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}_initializeOptions(e){var t,n,a,r,s,i,o,l,c;this.worker=null!==(t=null===e||void 0===e?void 0:e.worker)&&void 0!==t&&t,this.accessToken=null!==(n=null===e||void 0===e?void 0:e.accessToken)&&void 0!==n?n:null;const d={};let u,m;d.timeout=null!==(a=null===e||void 0===e?void 0:e.timeout)&&void 0!==a?a:1e4,d.heartbeatIntervalMs=null!==(r=null===e||void 0===e?void 0:e.heartbeatIntervalMs)&&void 0!==r?r:Me,d.transport=null!==(s=null===e||void 0===e?void 0:e.transport)&&void 0!==s?s:C.getWebSocketConstructor(),d.params=null===e||void 0===e?void 0:e.params,d.logger=null===e||void 0===e?void 0:e.logger,d.heartbeatCallback=this._wrapHeartbeatCallback(null===e||void 0===e?void 0:e.heartbeatCallback),d.reconnectAfterMs=null!==(i=null===e||void 0===e?void 0:e.reconnectAfterMs)&&void 0!==i?i:e=>ze[e-1]||1e4;const p=null!==(o=null===e||void 0===e?void 0:e.vsn)&&void 0!==o?o:E;switch(p){case"1.0.0":u=(e,t)=>t(JSON.stringify(e)),m=(e,t)=>t(JSON.parse(e));break;case S:u=this.serializer.encode.bind(this.serializer),m=this.serializer.decode.bind(this.serializer);break;default:throw new Error("Unsupported serializer version: ".concat(d.vsn))}if(d.vsn=p,d.encode=null!==(l=null===e||void 0===e?void 0:e.encode)&&void 0!==l?l:u,d.decode=null!==(c=null===e||void 0===e?void 0:e.decode)&&void 0!==c?c:m,d.beforeReconnect=this._reconnectAuth.bind(this),((null===e||void 0===e?void 0:e.logLevel)||(null===e||void 0===e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,d.params=Object.assign(Object.assign({},d.params),{log_level:this.logLevel})),this.worker){if("undefined"!==typeof window&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=null===e||void 0===e?void 0:e.workerUrl,d.autoSendHeartbeat=!this.worker}return d}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var Ve=n(555),qe=class extends Error{constructor(e,t){var n;super(e),this.name="IcebergError",this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown="CommitStateUnknownException"===t.icebergType||[500,502,504].includes(t.status)&&!0===(null===(n=t.icebergType)||void 0===n?void 0:n.includes("CommitState"))}isNotFound(){return 404===this.status}isConflict(){return 409===this.status}isAuthenticationTimeout(){return 419===this.status}};function We(e){var t;const n=null!==(t=e.fetchImpl)&&void 0!==t?t:globalThis.fetch;return{async request(t){let{method:a,path:r,query:s,body:i,headers:o}=t;const l=function(e,t,n){const a=new URL(t,e);if(n)for(const[r,s]of Object.entries(n))void 0!==s&&a.searchParams.set(r,s);return a.toString()}(e.baseUrl,r,s),c=await async function(e){return e&&"none"!==e.type?"bearer"===e.type?{Authorization:"Bearer ".concat(e.token)}:"header"===e.type?{[e.name]:e.value}:"custom"===e.type?await e.getHeaders():{}:{}}(e.auth),d=await n(l,{method:a,headers:(0,Ve.A)((0,Ve.A)((0,Ve.A)({},i?{"Content-Type":"application/json"}:{}
2),c),o),body:i?JSON.stringify(i):void 0}),u=await d.text(),m=(d.headers.get("content-type")||"").includes("application/json"),p=m&&u?JSON.parse(u):u;if(!d.ok){var h;const e=m?p:void 0,t=null===e||void 0===e?void 0:e.error;throw new qe(null!==(h=null===t||void 0===t?void 0:t.message)&&void 0!==h?h:"Request failed with status ".concat(d.status),{status:d.status,icebergType:null===t||void 0===t?void 0:t.type,icebergCode:null===t||void 0===t?void 0:t.code,details:e})}return{status:d.status,headers:d.headers,data:p}}}}function He(e){return e.join("\x1f")}var Ge=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";this.client=e,this.prefix=t}async listNamespaces(e){const t=e?{parent:He(e.namespace)}:void 0;return(await this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces"),query:t})).data.namespaces.map(e=>({namespace:e}))}async createNamespace(e,t){const n={namespace:e.namespace,properties:null===t||void 0===t?void 0:t.properties};return(await this.client.request({method:"POST",path:"".concat(this.prefix,"/namespaces"),body:n})).data}async dropNamespace(e){await this.client.request({method:"DELETE",path:"".concat(this.prefix,"/namespaces/").concat(He(e.namespace))})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces/").concat(He(e.namespace))})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:"".concat(this.prefix,"/namespaces/").concat(He(e.namespace))}),!0}catch(t){if(t instanceof qe&&404===t.status)return!1;throw t}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(n){if(n instanceof qe&&409===n.status)return;throw n}}};function Ke(e){return e.join("\x1f")}var Ye=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0;this.client=e,this.prefix=t,this.accessDelegation=n}async listTables(e){return(await this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces/").concat(Ke(e.namespace),"/tables")})).data.identifiers}async createTable(e,t){const n={};this.accessDelegation&&(n["X-Iceberg-Access-Delegation"]=this.accessDelegation);return(await this.client.request({method:"POST",path:"".concat(this.prefix,"/namespaces/").concat(Ke(e.namespace),"/tables"),body:t,headers:n})).data.metadata}async updateTable(e,t){const n=await this.client.request({method:"POST",path:"".concat(this.prefix,"/namespaces/").concat(Ke(e.namespace),"/tables/").concat(e.name),body:t});return{"metadata-location":n.data["metadata-location"],metadata:n.data.metadata}}async dropTable(e,t){var n;await this.client.request({method:"DELETE",path:"".concat(this.prefix,"/namespaces/").concat(Ke(e.namespace),"/tables/").concat(e.name),query:{purgeRequested:String(null!==(n=null===t||void 0===t?void 0:t.purge)&&void 0!==n&&n)}})}async loadTable(e){const t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);return(await this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces/").concat(Ke(e.namespace),"/tables/").concat(e.name),headers:t})).data.metadata}async tableExists(e){const t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:"".concat(this.prefix,"/namespaces/").concat(Ke(e.namespace),"/tables/").concat(e.name),headers:t}),!0}catch(n){if(n instanceof qe&&404===n.status)return!1;throw n}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(n){if(n instanceof qe&&409===n.status)return await this.loadTable({namespace:e.namespace,name:t.name});throw n}}},Je=class{constructor(e){var t;let n="v1";e.catalogName&&(n+="/".concat(e.catalogName));const a=e.baseUrl.endsWith("/")?e.baseUrl:"".concat(e.baseUrl,"/");this.client=We({baseUrl:a,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=null===(t=e.accessDelegation)||void 0===t?void 0:t.join(","),this.namespaceOps=new Ge(this.client,n),this.tableOps=new Ye(this.client,n,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}
2async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}};var $e=class extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"storage",n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0;super(e),this.__isStorageError=!0,this.namespace=t,this.name="vectors"===t?"StorageVectorsError":"StorageError",this.status=n,this.statusCode=a}};function Xe(e){return"object"===typeof e&&null!==e&&"__isStorageError"in e}var Qe=class extends $e{constructor(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"storage";super(e,a,t,n),this.name="vectors"===a?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},Ze=class extends $e{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"storage";super(e,n),this.name="vectors"===n?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};const et=e=>{if(Array.isArray(e))return e.map(e=>et(e));if("function"===typeof e||e!==Object(e))return e;const t={};return Object.entries(e).forEach(e=>{let[n,a]=e;const r=n.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""));t[r]=et(a)}),t};function tt(e){return(tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function nt(e){var t=function(e,t){if("object"!=tt(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=tt(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==tt(t)?t:t+""}function at(e,t,n){return(t=nt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rt(Object(n),!0).forEach(function(t){at(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const it=e=>{var t;return e.msg||e.message||e.error_description||("string"===typeof e.error?e.error:null===(t=e.error)||void 0===t?void 0:t.message)||JSON.stringify(e)},ot=(e,t,n,a)=>{const r={method:e,headers:(null===t||void 0===t?void 0:t.headers)||{}};if("GET"===e||"HEAD"===e||!a)return st(st({},r),n);if((e=>{if("object"!==typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)})(a)){var s;const e=(null===t||void 0===t?void 0:t.headers)||{};let n;for(const[t,a]of Object.entries(e))"content-type"===t.toLowerCase()&&(n=a);r.headers=function(e,t,n){const a=st({},e);for(const r of Object.keys(a))r.toLowerCase()===t.toLowerCase()&&delete a[r];return a[t]=n,a}(e,"Content-Type",null!==(s=n)&&void 0!==s?s:"application/json"),r.body=JSON.stringify(a)}else r.body=a;return(null===t||void 0===t?void 0:t.duplex)&&(r.duplex=t.duplex),st(st({},r),n)};async function lt(e,t,n,a,r,s,i){return new Promise((o,l)=>{e(n,ot(t,a,r,s)).then(e=>{if(!e.ok)throw e;if(null===a||void 0===a?void 0:a.noResolveJson)return e;if("vectors"===i){const t=e.headers.get("content-type");if("0"===e.headers.get("content-length")||204===e.status)return{};if(!t||!t.includes("application/json"))return{}}return e.json()}).then(e=>o(e)).catch(e=>(async(e,t,n,a)=>
2{if(null!==e&&"object"===typeof e&&"function"===typeof e.json){const n=e;let r=parseInt(n.status,10);Number.isFinite(r)||(r=500),n.json().then(e=>{const n=(null===e||void 0===e?void 0:e.statusCode)||(null===e||void 0===e?void 0:e.code)||r+"";t(new Qe(it(e),r,n,a))}).catch(()=>{const e=r+"";t(new Qe(n.statusText||"HTTP ".concat(r," error"),r,e,a))})}else t(new Ze(it(e),e,a))})(e,l,0,i))})}function ct(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"storage";return{get:async(t,n,a,r)=>lt(t,"GET",n,a,r,void 0,e),post:async(t,n,a,r,s)=>lt(t,"POST",n,r,s,a,e),put:async(t,n,a,r,s)=>lt(t,"PUT",n,r,s,a,e),head:async(t,n,a,r)=>lt(t,"HEAD",n,st(st({},a),{},{noResolveJson:!0}),r,void 0,e),remove:async(t,n,a,r,s)=>lt(t,"DELETE",n,r,s,a,e)}}const dt=ct("storage"),{get:ut,post:mt,put:pt,head:ht,remove:ft}=dt,xt=ct("vectors");var vt=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"storage";var r;this.shouldThrowOnError=!1,this.url=e,this.headers=Object.fromEntries(Object.entries(t).map(e=>{let[t,n]=e;return[t.toLowerCase(),n]})),this.fetch=(r=n)?function(){return r(...arguments)}:function(){return fetch(...arguments)},this.namespace=a}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=st(st({},this.headers),{},{[e.toLowerCase()]:t}),this}async handleOperation(e){try{return{data:await e(),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(Xe(t))return{data:null,error:t};throw t}}},gt=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t}then(e,t){return this.execute().then(e,t)}async execute(){try{return{data:(await this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(Xe(e))return{data:null,error:e};throw e}}};let yt;yt=Symbol.toStringTag;var bt=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[yt]="BlobDownloadBuilder",this.promise=null}asStream(){return new gt(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:await(await this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(Xe(e))return{data:null,error:e};throw e}}};const wt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},jt={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var kt=class extends vt{constructor(e){let t=arguments.length>2?arguments[2]:void 0;super(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>3?arguments[3]:void 0,"storage"),this.bucketId=t}async uploadOrUpdate(e,t,n,a){var r=this;return r.handleOperation(async()=>{let s;const i=st(st({},jt),a);let o=st(st({},r.headers),"POST"===e&&{"x-upsert":String(i.upsert)});const l=i.metadata;"undefined"!==typeof Blob&&n instanceof Blob?(s=new FormData,s.append("cacheControl",i.cacheControl),l&&s.append("metadata",r.encodeMetadata(l)),s.append("",n)):"undefined"!==typeof FormData&&n instanceof FormData?(s=n,s.has("cacheControl")||s.append("cacheControl",i.cacheControl),l&&!s.has("metadata")&&s.append("metadata",r.encodeMetadata(l))):(s=n,o["cache-control"]="max-age=".concat(i.cacheControl),o["content-type"]=i.contentType,l&&(o["x-metadata"]=r.toBase64(r.encodeMetadata(l))),("undefined"!==typeof ReadableStream&&s instanceof ReadableStream||s&&"object"===typeof s&&"pipe"in s&&"function"===typeof s.pipe)&&!i.duplex&&(i.duplex="half")),(null===a||void 0===a?void 0:a.headers)&&(o=st(st({},o),a.headers));const c=r._removeEmptyFolders(t),d=r._getFinalPath(c),u=await("PUT"==e?pt:mt)(r.fetch,"".concat(r.url,"/object/").concat(d),s,st({headers:o},(null===i||void 0===i?void 0:i.duplex)?{duplex:i.duplex}:{}));return{path:c,id:u.Id,fullPath:u.Key}})}async upload(e,t,n){return this.uploadOrUpdate("POST",e,t,n)}async uploadToSignedUrl(e,t,n,a){var r=this;const s=r._removeEmptyFolders(e),i=r._getFinalPath(s),o=new URL(r.url+"/object/upload/sign/".concat(i));return o.searchParams.set("token",t),r.handleOperation(async()=>{let e;const t=st(st({},jt),a),i=st(st({},r.headers),{"x-upsert":String(t.upsert)});return"undefined"!==typeof Blob&&n instanceof Blob?(e=new FormData,e.append("cacheControl",t.cacheControl),e.append("",n)):"undefined"!==typeof FormData&&n instanceof FormData?(e=n,e.append("cacheControl",t.cacheControl)):(e=n,i["cache-control"]="max-age=".concat(t.cacheControl),i["content-type"]=t.contentType),{path:s,fullPath:(await pt(r.fetch,o.toString(),e,{headers:i})).Key}})}async createSignedUploadUrl(e,t){var n=this;return n.handleOperation(async()=>{let a=n._getFinalPath(e);const r=st({},n.headers);(null===t||void 0===t?void 0:t.upsert)&&(r["x-upsert"]="true");const s=await mt(n.fetch,"".concat(n.url,"/object/upload/sign/").concat(a),{},{headers:r}),i=new URL(n.url+s.url),o=i.searchParams.get("token");if(!o)throw new $e("No token returned by API");return{signedUrl:i.toString(),path:e,token:o}})}async update(e,t,n){return this.uploadOrUpdate("PUT",e,t,n)}async move(e,t,n){var a=this;return a.handleOperation(async()=>await mt(a.fetch,"".concat(a.url,"/object/move"),{bucketId:a.bucketId,sourceKey:e,destinationKey:t,de
2stinationBucket:null===n||void 0===n?void 0:n.destinationBucket},{headers:a.headers}))}async copy(e,t,n){var a=this;return a.handleOperation(async()=>({path:(await mt(a.fetch,"".concat(a.url,"/object/copy"),{bucketId:a.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null===n||void 0===n?void 0:n.destinationBucket},{headers:a.headers})).Key}))}async createSignedUrl(e,t,n){var a=this;return a.handleOperation(async()=>{let r=a._getFinalPath(e);const s="object"===typeof(null===n||void 0===n?void 0:n.transform)&&null!==n.transform&&Object.keys(n.transform).length>0;let i=await mt(a.fetch,"".concat(a.url,"/object/sign/").concat(r),st({expiresIn:t},s?{transform:n.transform}:{}),{headers:a.headers});const o=new URLSearchParams;(null===n||void 0===n?void 0:n.download)&&o.set("download",!0===n.download?"":n.download),null!=(null===n||void 0===n?void 0:n.cacheNonce)&&o.set("cacheNonce",String(n.cacheNonce));const l=o.toString(),c=s&&i.signedURL.includes("/object/sign/")?i.signedURL.replace("/object/sign/","/render/image/sign/"):i.signedURL;return{signedUrl:encodeURI("".concat(a.url).concat(c).concat(l?"&".concat(l):""))}})}async createSignedUrls(e,t,n){var a=this;return a.handleOperation(async()=>{const r=await mt(a.fetch,"".concat(a.url,"/object/sign/").concat(a.bucketId),{expiresIn:t,paths:e},{headers:a.headers}),s=new URLSearchParams;(null===n||void 0===n?void 0:n.download)&&s.set("download",!0===n.download?"":n.download),null!=(null===n||void 0===n?void 0:n.cacheNonce)&&s.set("cacheNonce",String(n.cacheNonce));const i=s.toString();return r.map(e=>st(st({},e),{},{signedUrl:e.signedURL?encodeURI("".concat(a.url).concat(e.signedURL).concat(i?"&".concat(i):"")):null}))})}download(e,t,n){const a="undefined"!==typeof(null===t||void 0===t?void 0:t.transform)?"render/image/authenticated":"object",r=new URLSearchParams;(null===t||void 0===t?void 0:t.transform)&&this.applyTransformOptsToQuery(r,t.transform),null!=(null===t||void 0===t?void 0:t.cacheNonce)&&r.set("cacheNonce",String(t.cacheNonce));const s=r.toString(),i=this._getFinalPath(e);return new bt(()=>ut(this.fetch,"".concat(this.url,"/").concat(a,"/").concat(i).concat(s?"?".concat(s):""),{headers:this.headers,noResolveJson:!0},n),this.shouldThrowOnError)}async info(e){var t=this;const n=t._getFinalPath(e);return t.handleOperation(async()=>et(await ut(t.fetch,"".concat(t.url,"/object/info/").concat(n),{headers:t.headers})))}async exists(e){var t=this;const n=t._getFinalPath(e);try{return await ht(t.fetch,"".concat(t.url,"/object/").concat(n),{headers:t.headers}),{data:!0,error:null}}catch(r){if(t.shouldThrowOnError)throw r;if(Xe(r)){var a;const e=r instanceof Qe?r.status:r instanceof Ze?null===(a=r.originalError)||void 0===a?void 0:a.status:void 0;if(void 0!==e&&[400,404].includes(e))return{data:!1,error:r}}throw r}}getPublicUrl(e,t){const n=this._getFinalPath(e),a=new URLSearchParams;(null===t||void 0===t?void 0:t.download)&&a.set("download",!0===t.download?"":t.download),(null===t||void 0===t?void 0:t.transform)&&this.applyTransformOptsToQuery(a,t.transform),null!=(null===t||void 0===t?void 0:t.cacheNonce)&&a.set("cacheNonce",String(t.cacheNonce));const r=a.toString(),s="undefined"!==typeof(null===t||void 0===t?void 0:t.transform)?"render/image":"object";return{data:{publicUrl:encodeURI("".concat(this.url,"/").concat(s,"/public/").concat(n))+(r?"?".concat(r):"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await ft(t.fetch,"".concat(t.url,"/object/").concat(t.bucketId),{prefixes:e},{headers:t.headers}))}async list(e,t,n){var a=this;return a.handleOperation(async()=>{const r=st(st(st({},wt),t),{},{prefix:e||""});return await mt(a.fetch,"".concat(a.url,"/object/list/").concat(a.bucketId),r,{headers:a.headers},n)})}async listV2(e,t){var n=this;return n.handleOperation(async()=>{const a=st({},e);return await mt(n.fetch,"".concat(n.url,"/object/list-v2/").concat(n.bucketId),a,{headers:n.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return"undefined"!==typeof Buffer?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return"".concat(this.bucketId,"/").concat(e.replace(/^\/+/,""))}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(e,t){return t.width&&e.set("width",t.width.toString()),t.height&&e.set("height",t.height.toString()),t.resize&&e.set("resize",t.resize),t.format&&e.set("format",t.format),t.quality&&e.set("qual
2ity",t.quality.toString()),e}};const Nt={"X-Client-Info":"storage-js/".concat("2.103.0")};var _t=class extends vt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0;const r=new URL(e);(null===a||void 0===a?void 0:a.useNewHostname)&&/supabase\.(co|in|red)$/.test(r.hostname)&&!r.hostname.includes("storage.supabase.")&&(r.hostname=r.hostname.replace("supabase.","storage.supabase."));super(r.href.replace(/\/$/,""),st(st({},Nt),t),n,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const n=t.listBucketOptionsToQueryString(e);return await ut(t.fetch,"".concat(t.url,"/bucket").concat(n),{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await ut(t.fetch,"".concat(t.url,"/bucket/").concat(e),{headers:t.headers}))}async createBucket(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{public:!1};var n=this;return n.handleOperation(async()=>await mt(n.fetch,"".concat(n.url,"/bucket"),{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:n.headers}))}async updateBucket(e,t){var n=this;return n.handleOperation(async()=>await pt(n.fetch,"".concat(n.url,"/bucket/").concat(e),{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:n.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await mt(t.fetch,"".concat(t.url,"/bucket/").concat(e,"/empty"),{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await ft(t.fetch,"".concat(t.url,"/bucket/").concat(e),{},{headers:t.headers}))}listBucketOptionsToQueryString(e){const t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}},Dt=class extends vt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;super(e.replace(/\/$/,""),st(st({},Nt),t),n,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await mt(t.fetch,"".concat(t.url,"/bucket"),{name:e},{headers:t.headers}))}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const n=new URLSearchParams;void 0!==(null===e||void 0===e?void 0:e.limit)&&n.set("limit",e.limit.toString()),void 0!==(null===e||void 0===e?void 0:e.offset)&&n.set("offset",e.offset.toString()),(null===e||void 0===e?void 0:e.sortColumn)&&n.set("sortColumn",e.sortColumn),(null===e||void 0===e?void 0:e.sortOrder)&&n.set("sortOrder",e.sortOrder),(null===e||void 0===e?void 0:e.search)&&n.set("search",e.search);const a=n.toString(),r=a?"".concat(t.url,"/bucket?").concat(a):"".concat(t.url,"/bucket");return await ut(t.fetch,r,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await ft(t.fetch,"".concat(t.url,"/bucket/").concat(e),{},{headers:t.headers}))}from(e){var t=this;if(!(e=>!(!e||"string"!==typeof e)&&!(0===e.length||e.length>100)&&e.trim()===e&&!e.includes("/")&&!e.includes("\\")&&/^[\w!.\*'() &$@=;:+,?-]+$/.test(e))(e))throw new $e("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const n=new Je({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:async()=>t.headers},fetch:this.fetch}),a=this.shouldThrowOnError;return new Proxy(n,{get(e,t){const n=e[t];return"function"!==typeof n?n:async function(){try{for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return{data:await n.apply(e,r),error:null}}catch(i){if(a)throw i;return{data:null,error:i}}}}})}},Ct=class extends vt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;super(e.replace(/\/$/,""),st(st({},Nt),{},{"Content-Type":"application/json"},t),n,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/CreateIndex"),e,{headers:t.headers})||{})}async getIndex(e,t){var n=this;return n.handleOperation(async()=>await xt.post(n.fetch,"".concat(n.url,"/GetIndex"),{vectorBucketName:e,indexName:t},{headers:n.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/ListIndexes"),e,{headers:t.headers}))}async deleteIndex(e,t){var n=this;return n.handleOperation(async()=>await xt.post(n.fetch,"".concat(n.url,"/DeleteIndex"),{vectorBucketName:e,indexName:t},{headers:n.headers})||{})}},At=class extends vt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;super(e.replace(/\/$/,""),st(st({},Nt),{},{"Content-Type":"application/json"},t),n,"vectors")}async putVectors(e){var t=this;if(e.vectors.length<1||e.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/PutVectors"),e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/GetVectors"),e,{headers:t.headers}))}async listVectors(e){var t=this;if(void 0!==e.segmentCount){if(e.segmentCount<1||e.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");
2if(void 0!==e.segmentIndex&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw new Error("segmentIndex must be between 0 and ".concat(e.segmentCount-1))}return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/ListVectors"),e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/QueryVectors"),e,{headers:t.headers}))}async deleteVectors(e){var t=this;if(e.keys.length<1||e.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/DeleteVectors"),e,{headers:t.headers})||{})}},St=class extends vt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;super(e.replace(/\/$/,""),st(st({},Nt),{},{"Content-Type":"application/json"},t),n,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/CreateVectorBucket"),{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/GetVectorBucket"),{vectorBucketName:e},{headers:t.headers}))}async listBuckets(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t=this;return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/ListVectorBuckets"),e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await xt.post(t.fetch,"".concat(t.url,"/DeleteVectorBucket"),{vectorBucketName:e},{headers:t.headers})||{})}},Et=class extends St{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,t.headers||{},t.fetch)}from(e){return new Ft(this.url,this.headers,e,this.fetch)}async createBucket(e){return(()=>super.createBucket)().call(this,e)}async getBucket(e){return(()=>super.getBucket)().call(this,e)}async listBuckets(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(()=>super.listBuckets)().call(this,e)}async deleteBucket(e){return(()=>super.deleteBucket)().call(this,e)}},Ft=class extends Ct{constructor(e,t,n,a){super(e,t,a),this.vectorBucketName=n}async createIndex(e){return(()=>super.createIndex)().call(this,st(st({},e),{},{vectorBucketName:this.vectorBucketName}))}async listIndexes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(()=>super.listIndexes)().call(this,st(st({},e),{},{vectorBucketName:this.vectorBucketName}))}async getIndex(e){return(()=>super.getIndex)().call(this,this.vectorBucketName,e)}async deleteIndex(e){return(()=>super.deleteIndex)().call(this,this.vectorBucketName,e)}index(e){return new Rt(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},Rt=class extends At{constructor(e,t,n,a,r){super(e,t,r),this.vectorBucketName=n,this.indexName=a}async putVectors(e){var t=this;return(()=>super.putVectors)().call(t,st(st({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}async getVectors(e){var t=this;return(()=>super.getVectors)().call(t,st(st({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}async listVectors(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t=this;return(()=>super.listVectors)().call(t,st(st({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}async queryVectors(e){var t=this;return(()=>super.queryVectors)().call(t,st(st({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}async deleteVectors(e){var t=this;return(()=>super.deleteVectors)().call(t,st(st({},e),{},{vectorBucketName:t.vectorBucketName,indexName:t.indexName}))}},It=class extends _t{constructor(e){super(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2?arguments[2]:void 0,arguments.length>3?arguments[3]:void 0)}from(e){return new kt(this.url,this.headers,e,this.fetch)}get vectors(){return new Et(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Dt(this.url+"/iceberg",this.headers,this.fetch)}};const Tt="2.103.0",Pt=3e4,Ot=9e4,Bt={"X-Client-Info":"gotrue-js/".concat(Tt)},Lt="X-Supabase-Api-Version",Mt={timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"},zt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i;
2class Ut extends Error{constructor(e,t,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=n}}function Vt(e){return"object"===typeof e&&null!==e&&"__isAuthError"in e}class qt extends Ut{constructor(e,t,n){super(e,t,n),this.name="AuthApiError",this.status=t,this.code=n}}class Wt extends Ut{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class Ht extends Ut{constructor(e,t,n,a){super(e,n,a),this.name=t,this.status=n}}class Gt extends Ht{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Kt(e){return Vt(e)&&"AuthSessionMissingError"===e.name}class Yt extends Ht{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Jt extends Ht{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class $t extends Ht{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Xt extends Ht{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Qt extends Ht{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class Zt extends Ht{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function en(e){return Vt(e)&&"AuthRetryableFetchError"===e.name}class tn extends Ht{constructor(e,t,n){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=n}}class nn extends Ht{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const an="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),rn=" \t\n\r=".split(""),sn=(()=>{const e=new Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<rn.length;t+=1)e[rn[t].charCodeAt(0)]=-2;for(let t=0;t<an.length;t+=1)e[an[t].charCodeAt(0)]=t;return e})();function on(e,t,n){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;){const e=t.queue>>t.queuedBits-6&63;n(an[e]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){const e=t.queue>>t.queuedBits-6&63;n(an[e]),t.queuedBits-=6}}
2function ln(e,t,n){const a=sn[e];if(!(a>-1)){if(-2===a)return;throw new Error('Invalid Base64-URL character "'.concat(String.fromCharCode(e),'"'))}for(t.queue=t.queue<<6|a,t.queuedBits+=6;t.queuedBits>=8;)n(t.queue>>t.queuedBits-8&255),t.queuedBits-=8}function cn(e){const t=[],n=e=>{t.push(String.fromCodePoint(e))},a={utf8seq:0,codepoint:0},r={queue:0,queuedBits:0},s=e=>{!function(e,t,n){if(0===t.utf8seq){if(e<=127)return void n(e);for(let n=1;n<6;n+=1)if(0===(e>>7-n&1)){t.utf8seq=n;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else{if(4!==t.utf8seq)throw new Error("Invalid UTF-8 sequence");t.codepoint=7&e}t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&n(t.codepoint)}}(e,a,n)};for(let i=0;i<e.length;i+=1)ln(e.charCodeAt(i),r,s);return t.join("")}function dn(e,t){if(!(e<=127)){if(e<=2047)return t(192|e>>6),void t(128|63&e);if(e<=65535)return t(224|e>>12),t(128|e>>6&63),void t(128|63&e);if(e<=1114111)return t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),void t(128|63&e);throw new Error("Unrecognized Unicode codepoint: ".concat(e.toString(16)))}t(e)}function un(e,t){for(let n=0;n<e.length;n+=1){let a=e.charCodeAt(n);if(a>55295&&a<=56319){const t=1024*(a-55296)&65535;a=65536+(e.charCodeAt(n+1)-56320&65535|t),n+=1}dn(a,t)}}function mn(e){const t=[],n={queue:0,queuedBits:0},a=e=>{t.push(e)};for(let r=0;r<e.length;r+=1)ln(e.charCodeAt(r),n,a);return new Uint8Array(t)}function pn(e){const t=[],n={queue:0,queuedBits:0},a=e=>{t.push(e)};return e.forEach(e=>on(e,n,a)),on(null,n,a),t.join("")}const hn=()=>"undefined"!==typeof window&&"undefined"!==typeof document,fn={tested:!1,writable:!1},xn=()=>{if(!hn())return!1;try{if("object"!==typeof globalThis.localStorage)return!1}catch(t){return!1}if(fn.tested)return fn.writable;const e="lswt-".concat(Math.random()).concat(Math.random());try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),fn.tested=!0,fn.writable=!0}catch(t){fn.tested=!0,fn.writable=!1}return fn.writable};const vn=e=>e?function(){return e(...arguments)}:function(){return fetch(...arguments)},gn=async(e,t,n)=>{await e.setItem(t,JSON.stringify(n))},yn=async(e,t)=>{const n=await e.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch(a){return n}},bn=async(e,t)=>{await e.removeItem(t)};class wn{constructor(){this.promise=new wn.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function jn(e){const t=e.split(".");if(3!==t.length)throw new nn("Invalid JWT structure");for(let n=0;n<t.length;n++)if(!zt.test(t[n]))throw new nn("JWT not in base64url format");return{header:JSON.parse(cn(t[0])),payload:JSON.parse(cn(t[1])),signature:mn(t[2]),raw:{header:t[0],payload:t[1]}}}function kn(e){return("0"+e.toString(16)).substr(-2)}async function Nn(e){if(!("undefined"!==typeof crypto&&"undefined"!==typeof crypto.subtle&&"undefined"!==typeof TextEncoder))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e;const t=await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t),a=new Uint8Array(n);return Array.from(a).map(e=>String.fromCharCode(e)).join("")}(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function _n(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const a=function(){const e=new Uint32Array(56);if("undefined"===typeof crypto){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length;let n="";for(let a=0;a<56;a++)n+=e.charAt(Math.floor(Math.random()*t));return n}return crypto.getRandomValues(e),Array.from(e,kn).join("")}();let r=a;n&&(r+="/PASSWORD_RECOVERY"),await gn(e,"".concat(t,"-code-verifier"),r);const s=await Nn(a);return[s,a===s?"plain":"s256"]}wn.promiseConstructor=Promise;const Dn=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;const Cn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function An(e){if(!Cn.test(e))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Sn(){return new Proxy({},{get:(e,t)=>{if("__isUserNotAvailableProxy"===t)return!0;
2if("symbol"===typeof t){const e=t.toString();if("Symbol(Symbol.toPrimitive)"===e||"Symbol(Symbol.toStringTag)"===e||"Symbol(util.inspect.custom)"===e)return}throw new Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "'.concat(t,'" property of the session object is not supported. Please use getUser() instead.'))},set:(e,t)=>{throw new Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "'.concat(t,'" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.'))},deleteProperty:(e,t)=>{throw new Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "'.concat(t,'" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.'))}})}function En(e){return JSON.parse(JSON.stringify(e))}const Fn=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),Rn=[502,503,504];async function In(e){var t,n;if(!("object"===typeof(n=e)&&null!==n&&"status"in n&&"ok"in n&&"json"in n&&"function"===typeof n.json))throw new Zt(Fn(e),0);if(Rn.includes(e.status))throw new Zt(Fn(e),e.status);let a,r;try{a=await e.json()}catch(i){throw new Wt(Fn(i),i)}const s=function(e){const t=e.headers.get(Lt);if(!t)return null;if(!t.match(Dn))return null;try{return new Date("".concat(t,"T00:00:00.0Z"))}catch(i){return null}}(e);if(s&&s.getTime()>=Mt.timestamp&&"object"===typeof a&&a&&"string"===typeof a.code?r=a.code:"object"===typeof a&&a&&"string"===typeof a.error_code&&(r=a.error_code),r){if("weak_password"===r)throw new tn(Fn(a),e.status,(null===(t=a.weak_password)||void 0===t?void 0:t.reasons)||[]);if("session_not_found"===r)throw new Gt}else if("object"===typeof a&&a&&"object"===typeof a.weak_password&&a.weak_password&&Array.isArray(a.weak_password.reasons)&&a.weak_password.reasons.length&&a.weak_password.reasons.reduce((e,t)=>e&&"string"===typeof t,!0))throw new tn(Fn(a),e.status,a.weak_password.reasons);throw new qt(Fn(a),e.status||500,r)}async function Tn(e,t,n,a){var r;const s=Object.assign({},null===a||void 0===a?void 0:a.headers);s[Lt]||(s[Lt]=Mt.name),(null===a||void 0===a?void 0:a.jwt)&&(s.Authorization="Bearer ".concat(a.jwt));const i=null!==(r=null===a||void 0===a?void 0:a.query)&&void 0!==r?r:{};(null===a||void 0===a?void 0:a.redirectTo)&&(i.redirect_to=a.redirectTo);const o=Object.keys(i).length?"?"+new URLSearchParams(i).toString():"",l=await async function(e,t,n,a,r,s){const i=((e,t,n,a)=>{const r={method:e,headers:(null===t||void 0===t?void 0:t.headers)||{}};return"GET"===e?r:(r.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null===t||void 0===t?void 0:t.headers),r.body=JSON.stringify(a),Object.assign(Object.assign({},r),n))})(t,a,r,s);let o;try{o=await e(n,Object.assign({},i))}catch(l){throw console.error(l),new Zt(Fn(l),0)}o.ok||await In(o);if(null===a||void 0===a?void 0:a.noResolveJson)return o;try{return await o.json()}catch(l){await In(l)}}(e,t,n+o,{headers:s,noResolveJson:null===a||void 0===a?void 0:a.noResolveJson},{},null===a||void 0===a?void 0:a.body);return(null===a||void 0===a?void 0:a.xform)?null===a||void 0===a?void 0:a.xform(l):{data:Object.assign({},l),error:null}}function Pn(e){var t;let n=null;var a;(function(e){return e.access_token&&e.refresh_token&&e.expires_in})(e)&&(n=Object.assign({},e),e.expires_at||(n.expires_at=(a=e.expires_in,Math.round(Date.now()/1e3)+a)));return{data:{session:n,user:null!==(t=e.user)&&void 0!==t?t:e},error:null}}function On(e){const t=Pn(e);return!t.error&&e.weak_password&&"object"===typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&"string"===typeof e.weak_password.message&&e.weak_password.reasons.reduce((e,t)=>e&&"string"===typeof t,!0)&&(t.data.weak_password=e.weak_password),t}function Bn(e){var t;return{data:{user:null!==(t=e.user)&&void 0!==t?t:e},error:null}}function Ln(e){return{data:e,error:null}}function Mn(e){const{action_link:t,email_otp:n,hashed_token:r,redirect_to:s,verification_type:i}=e,o=(0,a.Tt)(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]);return{data:{properties:{action_link:t,email_otp:n,hashed_token:r,redirect_to:s,verification_type:i},user:Object.assign({},o)},error:null}}function zn(e){return e}const Un=["global","local","others"];class Vn{constructor(e){let{url:t="",headers:n={},fetch:a}=e;this.url=t,this.headers=n,this.fetch=vn(a),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)}}async signOut(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Un[0];if(Un.indexOf(t)<0)throw new Error("@supabase/auth-js: Parameter scope must be one of ".concat(Un.join(", ")));try{return await Tn(this.fetch,"POST","".concat(this.url,"/logout?scope=").concat(t),{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Vt(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return await Tn(this.fetch,"POST","".concat(this.url,"/invite"),{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:Bn})}catch(n){if(Vt(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{const{options:t}=e,n=(0,a.Tt)(e,["options"]),r=Object.assign(Object.assign({},n),t);return"newEmail"in n&&(r.new_email=null===n||void 0===n?void 0:n.newEmail,delete r.newEmail),await Tn(this.fetch,"POST","".concat(this.url,"/admin/generate_link"),{body:r,headers:this.headers,xform:Mn,redirectTo:null===t||void 0===t?void 0:t.redirectTo})}catch(t){if(Vt(t))return{data:{properties:null,user:null},error:t};throw t}}async createUser(e){try{return await Tn(this.fetch,"POST","".concat(this.url,"/admin/users"),{body:e,headers:this.headers,xform:Bn})}catch(t){if(Vt(t))return{data:{user:null},error:t};throw t}}async listUsers(e){var t,n,a,r,s,i,o;try{const l={nextPage:null,lastPage:0,total:0},c=await Tn(this.fetch,"GET","".concat(this.url,"/admin/users"),{headers:this.headers,noResolveJson:!0,query:{page:null!==(n=null===(t=null===e||void 0===e?void 0:e.page)||void 0===t?void 0:t.toString())&&void 0!==n?n:"",per_page:null!==(r=null===(a=null===e||void 0===e?void 0:e.perPage)||void 0===a?void 0:a.toString())&&void 0!==r?r:""},xform:zn});if(c.error)throw c.error;const d=await c.json(),u=null!==(s=c.headers.get("x-total-count"))&&void 0!==s?s:0,m=null!==(o=null===(i=c.headers.get("link"))||void 0===i?void 0:i.split(","))&&void 0!==o?o:[];return m.length>
20&&(m.forEach(e=>{const t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),n=JSON.parse(e.split(";")[1].split("=")[1]);l["".concat(n,"Page")]=t}),l.total=parseInt(u)),{data:Object.assign(Object.assign({},d),l),error:null}}catch(l){if(Vt(l))return{data:{users:[]},error:l};throw l}}async getUserById(e){An(e);try{return await Tn(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,xform:Bn})}catch(t){if(Vt(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){An(e);try{return await Tn(this.fetch,"PUT","".concat(this.url,"/admin/users/").concat(e),{body:t,headers:this.headers,xform:Bn})}catch(n){if(Vt(n))return{data:{user:null},error:n};throw n}}async deleteUser(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];An(e);try{return await Tn(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,body:{should_soft_delete:t},xform:Bn})}catch(n){if(Vt(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){An(e.userId);try{const{data:t,error:n}=await Tn(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e.userId,"/factors"),{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:n}}catch(t){if(Vt(t))return{data:null,error:t};throw t}}async _deleteFactor(e){An(e.userId),An(e.id);try{return{data:await Tn(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e.userId,"/factors/").concat(e.id),{headers:this.headers}),error:null}}catch(t){if(Vt(t))return{data:null,error:t};throw t}}async _listOAuthClients(e){var t,n,a,r,s,i,o;try{const l={nextPage:null,lastPage:0,total:0},c=await Tn(this.fetch,"GET","".concat(this.url,"/admin/oauth/clients"),{headers:this.headers,noResolveJson:!0,query:{page:null!==(n=null===(t=null===e||void 0===e?void 0:e.page)||void 0===t?void 0:t.toString())&&void 0!==n?n:"",per_page:null!==(r=null===(a=null===e||void 0===e?void 0:e.perPage)||void 0===a?void 0:a.toString())&&void 0!==r?r:""},xform:zn});if(c.error)throw c.error;const d=await c.json(),u=null!==(s=c.headers.get("x-total-count"))&&void 0!==s?s:0,m=null!==(o=null===(i=c.headers.get("link"))||void 0===i?void 0:i.split(","))&&void 0!==o?o:[];return m.length>0&&(m.forEach(e=>{const t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),n=JSON.parse(e.split(";")[1].split("=")[1]);l["".concat(n,"Page")]=t}),l.total=parseInt(u)),{data:Object.assign(Object.assign({},d),l),error:null}}catch(l){if(Vt(l))return{data:{clients:[]},error:l};throw l}}async _createOAuthClient(e){try{return await Tn(this.fetch,"POST","".concat(this.url,"/admin/oauth/clients"),{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(t){if(Vt(t))return{data:null,error:t};throw t}}async _getOAuthClient(e){try{return await Tn(this.fetch,"GET","".concat(this.url,"/admin/oauth/clients/").concat(e),{headers:this.headers,xform:e=>({data:e,error:null})})}catch(t){if(Vt(t))return{data:null,error:t};throw t}}async _updateOAuthClient(e,t){try{return await Tn(this.fetch,"PUT","".concat(this.url,"/admin/oauth/clients/").concat(e),{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(n){if(Vt(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(e){try{return await Tn(this.fetch,"DELETE","".concat(this.url,"/admin/oauth/clients/").concat(e),{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(t){if(Vt(t))return{data:null,error:t};throw t}}async _regenerateOAuthClientSecret(e){try{return await Tn(this.fetch,"POST","".concat(this.url,"/admin/oauth/clients/").concat(e,"/regenerate_secret"),{headers:this.headers,xform:e=>({data:e,error:null})})}catch(t){if(Vt(t))return{data:null,error:t};throw t}}async _listCustomProviders(e){try{const t={};return(null===e||void 0===e?void 0:e.type)&&(t.type=e.type),await Tn(this.fetch,"GET","".concat(this.url,"/admin/custom-providers"),{headers:this.headers,query:t,xform:e=>{var t;return{data:{providers:null!==(t=null===e||void 0===e?void 0:e.providers)&&void 0!==t?t:[]},error:null}}})}catch(t){if(Vt(t))return{data:{providers:[]},error:t};throw t}}async _createCustomProvider(e){try{return await Tn(this.fetch,"POST","".concat(this.url,"/admin/custom-providers"),{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(t){if(Vt(t))return{data:null,error:t};throw t}}async _getCustomProvider(e){try{return await Tn(this.fetch,"GET","".concat(this.url,"/admin/custom-providers/").concat(e),{headers:this.headers,xform:e=>({data:e,error:null})})}catch(t){if(Vt(t))return{data:null,error:t};throw t}}async _updateCustomProvider(e,t){try{return await Tn(this.fetch,"PUT","".concat(this.url,"/admin/custom-providers/").concat(e),{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(n){if(Vt(n))return{data:null,error:n};throw n}}async _deleteCustomProvider(e){try{return await Tn(this.fetch,"DELET
2E","".concat(this.url,"/admin/custom-providers/").concat(e),{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(t){if(Vt(t))return{data:null,error:t};throw t}}}function qn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{getItem:t=>e[t]||null,setItem:(t,n)=>{e[t]=n},removeItem:t=>{delete e[t]}}}const Wn=!!(globalThis&&xn()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"));class Hn extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class Gn extends Hn{}async function Kn(e,t,n){Wn&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);const a=new globalThis.AbortController;let r;t>0&&(r=setTimeout(()=>{a.abort(),Wn&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t)),await Promise.resolve();try{return await globalThis.navigator.locks.request(e,0===t?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:a.signal},async a=>{if(!a){if(0===t)throw Wn&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new Gn('Acquiring an exclusive Navigator LockManager lock "'.concat(e,'" immediately failed'));if(Wn)try{const e=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(e,null," "))}catch(s){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",s)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),clearTimeout(r),await n()}clearTimeout(r),Wn&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,a.name);try{return await n()}finally{Wn&&console.log("@supabase/gotrue-js: navigatorLock: released",e,a.name)}})}catch(s){if(t>0&&clearTimeout(r),"AbortError"===(null===s||void 0===s?void 0:s.name)&&t>0){if(a.signal.aborted)return Wn&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",e),console.warn('@supabase/gotrue-js: Lock "'.concat(e,'" was not released within ').concat(t,"ms. ")+"This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover."),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,{mode:"exclusive",steal:!0},async t=>{if(!t)return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await n();Wn&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",e,t.name);try{return await n()}finally{Wn&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",e,t.name)}}));throw Wn&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",e),new Gn('Lock "'.concat(e,'" was released because another request stole it'))}throw s}}function Yn(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw new Error('@supabase/auth-js: Address "'.concat(e,'" is invalid.'));return e.toLowerCase()}function Jn(e){const t=(new TextEncoder).encode(e);return"0x"+Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}class $n extends Error{constructor(e){let{message:t,code:n,cause:a,name:r}=e;var s;super(t,{cause:a}),this.__isWebAuthnError=!0,this.name=null!==(s=null!==r&&void 0!==r?r:a instanceof Error?a.name:void 0)&&void 0!==s?s:"Unknown Error",this.code=n}}class Xn extends $n{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}
2function Qn(e){let{error:t,options:n}=e;var a,r,s;const{publicKey:i}=n;if(!i)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if(n.signal instanceof AbortSignal)return new $n({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if("ConstraintError"===t.name){if(!0===(null===(a=i.authenticatorSelection)||void 0===a?void 0:a.requireResidentKey))return new $n({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if("conditional"===n.mediation&&"required"===(null===(r=i.authenticatorSelection)||void 0===r?void 0:r.userVerification))return new $n({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if("required"===(null===(s=i.authenticatorSelection)||void 0===s?void 0:s.userVerification))return new $n({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if("InvalidStateError"===t.name)return new $n({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if("NotAllowedError"===t.name)return new $n({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if("NotSupportedError"===t.name){return 0===i.pubKeyCredParams.filter(e=>"public-key"===e.type).length?new $n({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new $n({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t})}if("SecurityError"===t.name){const e=window.location.hostname;if(!sa(e))return new $n({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(i.rp.id!==e)return new $n({message:'The RP ID "'.concat(i.rp.id,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("TypeError"===t.name){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new $n({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if("UnknownError"===t.name)return new $n({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new $n({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}
2function Zn(e){let{error:t,options:n}=e;const{publicKey:a}=n;if(!a)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if(n.signal instanceof AbortSignal)return new $n({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if("NotAllowedError"===t.name)return new $n({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if("SecurityError"===t.name){const e=window.location.hostname;if(!sa(e))return new $n({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(a.rpId!==e)return new $n({message:'The RP ID "'.concat(a.rpId,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("UnknownError"===t.name)return new $n({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new $n({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}const ea=new class{createNewAbortSignal(){if(this.controller){const e=new Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}};function ta(e){if(!e)throw new Error("Credential creation options are required");if("undefined"!==typeof PublicKeyCredential&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&"function"===typeof PublicKeyCredential.parseCreationOptionsFromJSON)return PublicKeyCredential.parseCreationOptionsFromJSON(e);const{challenge:t,user:n,excludeCredentials:r}=e,s=(0,a.Tt)(e,["challenge","user","excludeCredentials"]),i=mn(t).buffer,o=Object.assign(Object.assign({},n),{id:mn(n.id).buffer}),l=Object.assign(Object.assign({},s),{challenge:i,user:o});if(r&&r.length>0){l.excludeCredentials=new Array(r.length);for(let e=0;e<r.length;e++){const t=r[e];l.excludeCredentials[e]=Object.assign(Object.assign({},t),{id:mn(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return l}function na(e){if(!e)throw new Error("Credential request options are required");if("undefined"!==typeof PublicKeyCredential&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&"function"===typeof PublicKeyCredential.parseRequestOptionsFromJSON)return PublicKeyCredential.parseRequestOptionsFromJSON(e);const{challenge:t,allowCredentials:n}=e,r=(0,a.Tt)(e,["challenge","allowCredentials"]),s=mn(t).buffer,i=Object.assign(Object.assign({},r),{challenge:s});if(n&&n.length>0){i.allowCredentials=new Array(n.length);for(let e=0;e<n.length;e++){const t=n[e];i.allowCredentials[e]=Object.assign(Object.assign({},t),{id:mn(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return i}function aa(e){var t;if("toJSON"in e&&"function"===typeof e.toJSON)return e.toJSON();const n=e;return{id:e.id,rawId:e.id,response:{attestationObject:pn(new Uint8Array(e.response.attestationObject)),clientDataJSON:pn(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:null!==(t=n.authenticatorAttachment)&&void 0!==t?t:void 0}}function ra(e){var t;if("toJSON"in e&&"function"===typeof e.toJSON)return e.toJSON();const n=e,a=e.getClientExtensionResults(),r=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:pn(new Uint8Array(r.authenticatorData)),clientDataJSON:pn(new Uint8Array(r.clientDataJSON)),signature:pn(new Uint8Array(r.signature)),userHandle:r.userHandle?pn(new Uint8Array(r.userHandle)):void 0},type:"public-key",clientExtensionResults:a,authenticatorAttachment:null!==(t=n.authenticatorAttachment)&&void 0!==t?t:void 0}}function sa(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function ia(){var e,t;return!!(hn()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&"function"===typeof(null===(e=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===e?void 0:e.create)&&"function"===typeof(null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.get))}const oa={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},la={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function ca(){const e=e=>null!==e&&"object"===typeof e&&!Array.isArray(e),t=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),n={};for(var a=arguments.length,r=new Array(a),s=0;s<a;s++)r[s]=arguments[s];for(const i of r)if(i)for(const a in i){const r=i[a];if(void 0!==r)if(Array.isArray(r))n[a]=r;else if(t(r))n[a]=r;else if(e(r)){const t=n[a];e(t)?n[a]=ca(t,r):n[a]=ca(r)}else n[a]=r}return n}class da{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge(e,t){let{factorId:n,webauthn:a,friendlyName:r,signal:s}=e;var i;try{const{data:e,error:o}=await this.client.mfa.challenge({factorId:n,webauthn:a});if(!e)return{data:null,error:o};const l=null!==s&&void 0!==s?s:ea.createNewAbortSignal();if("create"===e.webauthn.type){const{user:t}=e.webauthn.credential_options.publicKey;if(!t.name){const e=r;if(e)t.name="".concat(t.id,":").concat(e);else{const e=(await this.client.getUser()).data.user,n=(null===(i=null===e||void 0===e?void 0:e.user_metadata)||void 0===i?void 0:i.name)||(null===e||void 0===e?void 0:e.email)||(null===e||void 0===e?void 0:e.id)||"User";t.name="".concat(t.id,":").concat(n)}}t.displayName||(t.displayName=t.name)}switch(e.webauthn.type){case"create":{const a=function(e,t){return ca(oa,e,t||{})}(e.webauthn.credential_options.publicKey,null===t||void 0===t?void 0:t.create),{data:r,error:s}=await async function(e){try{const t=await navigator.credentials.create(e);return t?t instanceof PublicKeyCredential?{data:t,error:null}:{data:null,error:new Xn("Browser returned unexpected credential type",t)}:{data:null,error:new Xn("Empty credential response",t)}}
2catch(t){return{data:null,error:Qn({error:t,options:e})}}}({publicKey:a,signal:l});return r?{data:{factorId:n,challengeId:e.id,webauthn:{type:e.webauthn.type,credential_response:r}},error:null}:{data:null,error:s}}case"request":{const a=function(e,t){return ca(la,e,t||{})}(e.webauthn.credential_options.publicKey,null===t||void 0===t?void 0:t.request),{data:r,error:s}=await async function(e){try{const t=await navigator.credentials.get(e);return t?t instanceof PublicKeyCredential?{data:t,error:null}:{data:null,error:new Xn("Browser returned unexpected credential type",t)}:{data:null,error:new Xn("Empty credential response",t)}}catch(t){return{data:null,error:Zn({error:t,options:e})}}}(Object.assign(Object.assign({},e.webauthn.credential_options),{publicKey:a,signal:l}));return r?{data:{factorId:n,challengeId:e.id,webauthn:{type:e.webauthn.type,credential_response:r}},error:null}:{data:null,error:s}}}}catch(o){return Vt(o)?{data:null,error:o}:{data:null,error:new Wt("Unexpected error in challenge",o)}}}async _verify(e){let{challengeId:t,factorId:n,webauthn:a}=e;return this.client.mfa.verify({factorId:n,challengeId:t,webauthn:a})}async _authenticate(e,t){let{factorId:n,webauthn:{rpId:a=("undefined"!==typeof window?window.location.hostname:void 0),rpOrigins:r=("undefined"!==typeof window?[window.location.origin]:void 0),signal:s}={}}=e;if(!a)return{data:null,error:new Ut("rpId is required for WebAuthn authentication")};try{if(!ia())return{data:null,error:new Wt("Browser does not support WebAuthn",null)};const{data:e,error:i}=await this.challenge({factorId:n,webauthn:{rpId:a,rpOrigins:r},signal:s},{request:t});if(!e)return{data:null,error:i};const{webauthn:o}=e;return this._verify({factorId:n,challengeId:e.challengeId,webauthn:{type:o.type,rpId:a,rpOrigins:r,credential_response:o.credential_response}})}catch(i){return Vt(i)?{data:null,error:i}:{data:null,error:new Wt("Unexpected error in authenticate",i)}}}async _register(e,t){let{friendlyName:n,webauthn:{rpId:a=("undefined"!==typeof window?window.location.hostname:void 0),rpOrigins:r=("undefined"!==typeof window?[window.location.origin]:void 0),signal:s}={}}=e;if(!a)return{data:null,error:new Ut("rpId is required for WebAuthn registration")};try{if(!ia())return{data:null,error:new Wt("Browser does not support WebAuthn",null)};const{data:e,error:i}=await this._enroll({friendlyName:n});if(!e)return await this.client.mfa.listFactors().then(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.all.find(e=>"webauthn"===e.factor_type&&e.friendly_name===n&&"unverified"!==e.status)}).then(e=>e?this.client.mfa.unenroll({factorId:null===e||void 0===e?void 0:e.id}):void 0),{data:null,error:i};const{data:o,error:l}=await this._challenge({factorId:e.id,friendlyName:e.friendly_name,webauthn:{rpId:a,rpOrigins:r},signal:s},{create:t});return o?this._verify({factorId:e.id,challengeId:o.challengeId,webauthn:{rpId:a,rpOrigins:r,type:o.webauthn.type,credential_response:o.webauthn.credential_response}}):{data:null,error:l}}catch(i){return Vt(i)?{data:null,error:i}:{data:null,error:new Wt("Unexpected error in register",i)}}}}!function(){if("object"!==typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"undefined"!==typeof self&&(self.globalThis=self)}}();const ua={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Bt,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1};async function ma(e,t,n){return await n()}const pa={};class ha{get jwks(){var e,t;return null!==(t=null===(e=pa[this.storageKey])||void 0===e?void 0:e.jwks)&&void 0!==t?t:{keys:[]}}set jwks(e){pa[this.storageKey]=Object.assign(Object.assign({},pa[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!==(t=null===(e=pa[this.storageKey])||void 0===e?void 0:e.cachedAt)&&void 0!==t?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){pa[this.storageKey]=Object.assign(Object.assign({},pa[this.storageKey]),{cachedAt:e})}constructor(e){var t,n,a;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const r=Object.assign(Object.assign({},ua),e);if(this.storageKey=r.storageKey,this.instanceID=null!==(t=ha.nextInstanceID[this.storageKey])&&void 0!==t?t:0,ha.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!r.debug,"function"===typeof r.debug&&(this.logger=r.debug),this.instanceID>0&&hn()){const e="".concat(this._logPrefix()," Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");console.warn(e),this.logDebugMessages&&console.trace(e)}if(this.persistSession=r.persistSession,this.autoRefreshToken=r.autoRefreshToken,this.admin=new Vn({url:r.url,headers:r.headers,fetch:r.fetch}),this.url=r.url,this.headers=r.headers,this.fetch=vn(r.fetch),this.lock=r.lock||ma,this.detectSessionInUrl=r.detectSessionInUrl,this.flowType=r.flowType,this.hasCustomAuthorizationHeader=r.hasCustomAuthorizationHeader,this.throwOnError=r.throwOnError,this.lockAcquireTimeout=r.lockAcquireTimeout,r.lock?this.lock=r.lock:this.persistSession&&hn()&&(null===(n=null===globalThis||void 0===globalThis?void 0:globalThis.navigator)||void 0===n?void 0:n.locks)?this.lock=Kn:this.lock=ma,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new da(this)}
2,this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(r.storage?this.storage=r.storage:xn()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=qn(this.memoryStorage)),r.userStorage&&(this.userStorage=r.userStorage)):(this.memoryStorage={},this.storage=qn(this.memoryStorage)),hn()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(s){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",s)}null===(a=this.broadcastChannel)||void 0===a||a.addEventListener("message",async e=>{this._debug("received broadcast notification from other tab or client",e);try{await this._notifyAllSubscribers(e.data.event,e.data.session,!1)}catch(t){this._debug("#broadcastChannel","error",t)}})}r.skipAutoInitialize||this.initialize().catch(e=>{this._debug("#initialize()","error",e)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return"GoTrueClient@"+"".concat(this.storageKey,":").concat(this.instanceID," (").concat(Tt,") ").concat((new Date).toISOString())}_debug(){if(this.logDebugMessages){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.logger(this._logPrefix(),...t)}return this}async initialize(){return this.initializePromise||(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))()),await this.initializePromise}async _initialize(){var e;try{let t={},n="none";if(hn()&&(t=function(e){const t={},n=new URL(e);if(n.hash&&"#"===n.hash[0])try{new URLSearchParams(n.hash.substring(1)).forEach((e,n)=>{t[n]=e})}catch(a){}return n.searchParams.forEach((e,n)=>{t[n]=e}),t}(window.location.href),this._isImplicitGrantCallback(t)?n="implicit":await this._isPKCECallback(t)&&(n="pkce")),hn()&&this.detectSessionInUrl&&"none"!==n){const{data:a,error:r}=await this._getSessionFromURL(t,n);if(r){if(this._debug("#_initialize()","error detecting session from URL",r),function(e){return Vt(e)&&"AuthImplicitGrantRedirectError"===e.name}(r)){const t=null===(e=r.details)||void 0===e?void 0:e.code;if("identity_already_exists"===t||"identity_not_found"===t||"single_identity_not_deletable"===t)return{error:r}}return{error:r}}const{session:s,redirectType:i}=a;return this._debug("#_initialize()","detected session in URL",s,"redirect type",i),await this._saveSession(s),setTimeout(async()=>{"recovery"===i?await this._notifyAllSubscribers("PASSWORD_RECOVERY",s):await this._notifyAllSubscribers("SIGNED_IN",s)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(t){return Vt(t)?this._returnResult({error:t}):this._returnResult({error:new Wt("Unexpected error during initialization",t)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,n,a;try{const r=await Tn(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,body:{data:null!==(n=null===(t=null===e||void 0===e?void 0:e.options)||void 0===t?void 0:t.data)&&void 0!==n?n:{},gotrue_meta_security:{captcha_token:null===(a=null===e||void 0===e?void 0:e.options)||void 0===a?void 0:a.captchaToken}},xform:Pn}),{data:s,error:i}=r;if(i||!s)return this._returnResult({data:{user:null,session:null},error:i});const o=s.session,l=s.user;return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",o)),this._returnResult({data:{user:l,session:o},error:null})}catch(r){if(Vt(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signUp(e){var t,n,a;try{let r;if("email"in e){const{email:n,password:a,options:s}=e;let i=null,o=null;"pkce"===this.flowType&&([i,o]=await _n(this.storage,this.storageKey)),r=await Tn(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,redirectTo:null===s||void 0===s?void 0:s.emailRedirectTo,body:{email:n,password:a,data:null!==(t=null===s||void 0===s?void 0:s.data)&&void 0!==t?t:{},gotrue_meta_security:{captcha_token:null===s||void 0===s?void 0:s.captchaToken},code_challenge:i,code_challenge_method:o},xform:Pn})}else{if(!("phone"in e))throw new Jt("You must provide either an email or phone number and a password");{const{phone:t,password:s,options:i}=e;r=await Tn(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,body:{phone:t,password:s,data:null!==(n=null===i||void 0===i?void 0:i.data)&&void 0!==n?n:{},channel:null!==(a=null===i||void 0===i?void 0:i.channel)&&void 0!==a?a:"sms",gotrue_meta_security:{captcha_token:null===i||void 0===i?void 0:i.captchaToken}},xform:Pn})}}const{data:s,error:i}=r;if(i||!s)return await bn(this.storage,"".concat(this.storageKey,"-code-verifier")),this._returnResult({data:{user:null,session:null},error:i});const o=s.session,l=s.user;return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",o)),this._returnResult({data:{user:l,session:o},error:null})}catch(r){if(await bn(this.storage,"".concat(this.storageKey,"-code-verifier")),Vt(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithPassword(e){try{let t;if("email"in e){const{email:n,password:a,options:r}=e;t=await Tn(this.fetch,"POST","".concat(this.url,"/token?grant_type=password"),{headers:this.headers,body:{email:n,password:a,gotrue_meta_security:{captcha_token:null===r||void 0===r?void 0:r.captchaToken}},xform:On})}else{if(!("phone"in e))throw new Jt("You must provide either an email or phone number and a password");{const{phone:n,password:a,options:r}=e;t=await Tn(this.fetch,"POST","".concat(this.url,"/token?grant_type=password"),{headers:this.headers,body:{phone:n,password:a,gotrue_meta_security:{captcha_token:null===r||void 0===r?void 0:r.captchaToken}},xform:On})}}const{data:n,error:a}=t;if(a)return this._returnResult({data:{user:null,session:null},error:a});if(!n||!n.session||!n.user){const e=new Yt;return this._returnResult({data:{user:null,session:null},error:e})}return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),this._returnResult({data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:a})}catch(t){if(Vt(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async signInWithOAuth(e){var t,n,a,r;return await this._handleProviderSignIn(e.provider,{redirectTo:null===(t=e.options)||void 0===t?void 0:t.redirectTo,scopes:null===(n=e.options)||void 0===n?void 0:n.scopes,queryParams:null===(a=e.options)||void 0===a?void 0:a.queryParams,skipBrowserRedirect:null===(r=e.options)||void 0===r?void 0:r.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:t}=e;switch(t){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error('@supabase/auth-js: Unsupported chain "'.concat(t,'"'))}}async signInWithEthereum(e){var t,n,a,r,s,i,o,l,c,d,u;let m,p;if("message"in e)m=e.message,p=e.signature;else{const{chain:d,wallet:u,statement:h,options:f}=e;let x;if(hn())if("object"===typeof u)x=u;else{const e=window;if(!("ethereum"in e)||"object"!==typeof e.ethereum||!("request"in e.ethereum)||"function"!==typeof e.ethereum.request)throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.");x=e.ethereum}else{if("object"!==typeof u||!(null===f||void 0===f?void 0:f.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");x=u}const v=new URL(null!==(t=null===f||void 0===f?void 0:f.url)&&void 0!==t?t:window.location.href),g=await x.request({method:"eth_requestAccounts"}).then(e=>e).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!g||0===g.length)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const y=Yn(g[0]);let b=null===(n=null===f||void 0===f?void 0:f.signInWithEthereum)||void 0===n?void 0:n.chainId;if(!b){const e=await x.request({method:"eth_chainId"});b=parseInt(e,16)}m=function(e){var t;const{chainId:n,domain:a,expirationTime:r,issuedAt:s=new Date,nonce:i,notBefore:o,requestId:l,resources:c,scheme:d,uri:u,version:m}=e;if(!Number.isInteger(n))throw new Error('@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: '.concat(n));if(!a)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(i&&i.length<8)throw new Error('@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: '.concat(i));if(!u)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if("1"!==m)throw new Error("@supabase/auth-js: Invalid SIWE message field \"version\". Version must be '1'. Provided value: ".concat(m));if(null===(t=e.statement)||void 0===t?void 0:t.includes("\n"))throw new Error("@supabase/auth-js: Invalid SIWE message field \"statement\". Statement must not include '\\n'. Provided value: ".concat(e.statement));const p=Yn(e.address),h=d?"".concat(d,"://").concat(a):a,f=e.statement?"".concat(e.statement,"\n"):"",x="".concat(h," wants you to sign in with your Ethereum account:\n").concat(p,"\n\n").concat(f);let v="URI: ".concat(u,"\nVersion: ").concat(m,"\nChain ID: ").concat(n).concat(i?"\nNonce: ".concat(i):"","\nIssued At: ").concat(s.toISOString());if(r&&(v+="\nExpiration Time: ".concat(r.toISOString())),o&&(v+="\nNot Before: ".concat(o.toISOString())),l&&(v+="\nRequest ID: ".concat(l)),c){let e="\nResources:";for(const t of c){if(!t||"string"!==typeof t)throw new Error('@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: '.concat(t));e+="\n- ".concat(t)}v+=e}return"".concat(x,"\n").concat(v)}({domain:v.host,address:y,statement:h,uri:v.href,version:"1",chainId:b,nonce:null===(a=null===f||void 0===f?void 0:f.signInWithEthereum)||void 0===a?void 0:a.nonce,issuedAt:null!==(s=null===(r=null===f||void 0===f?void 0:f.signInWithEthereum)||void 0===r?void 0:r.issuedAt)&&void 0!==s?s:new Date,expirationTime:null===(i=null===f||void 0===f?void 0:f.signInWithEthereum)||void 0===i?void 0:i.expirationTime,notBefore:null===(o=null===f||void 0===f?void 0:f.signInWithEthereum)||void 0===o?void 0:o.notBefore,requestId:null===(l=null===f||void 0===f?void 0:f.signInWithEthereum)||void 0===l?void 0:l.requestId,resources:null===(c=null===f||void 0===f?void 0:f.signInWithEthereum)||void 0===c?void 0:c.resources}),p=await x.request({method:"personal_sign",params:[Jn(m),y]})}try{const{data:t,error:n}=await Tn(this.fetch,"POST","".concat(this.url,"/token?grant_type=web3"),{headers:this.headers,body:Object.assign({chain:"ethereum",message:m,signature:p},(null===(d=e.options)||void 0===d?void 0:d.captchaToken)?{gotrue_meta_security:{captcha_token:null===(u=e.options)||void 0===u?void 0:u.captchaToken}}:null),xform:Pn});if(n)throw n;if(!t||!t.session||!t.user){const e=new Yt;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:n})}catch(h){if(Vt(h))return this._returnResult({data:{user:null,session:null},error:h});throw h}}async signInWithSolana(e){var t,n,a,r,s,i,o,l,c,d,u,m;let p,h;if("message"in e)p=e.message,h=e.signature;else{const{chain:u,wallet:m,statement:f,options:x}=e;let v;if(hn())if("object"===typeof m)v=m;else{const e=window;if(!("solana"in e)||"object"!==typeof e.solana||!("signIn"in e.solana&&"function"===typeof e.solana.signIn||"sign
2Message"in e.solana&&"function"===typeof e.solana.signMessage))throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.");v=e.solana}else{if("object"!==typeof m||!(null===x||void 0===x?void 0:x.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");v=m}const g=new URL(null!==(t=null===x||void 0===x?void 0:x.url)&&void 0!==t?t:window.location.href);if("signIn"in v&&v.signIn){const e=await v.signIn(Object.assign(Object.assign(Object.assign({issuedAt:(new Date).toISOString()},null===x||void 0===x?void 0:x.signInWithSolana),{version:"1",domain:g.host,uri:g.href}),f?{statement:f}:null));let t;if(Array.isArray(e)&&e[0]&&"object"===typeof e[0])t=e[0];else{if(!(e&&"object"===typeof e&&"signedMessage"in e&&"signature"in e))throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");t=e}if(!("signedMessage"in t&&"signature"in t&&("string"===typeof t.signedMessage||t.signedMessage instanceof Uint8Array)&&t.signature instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields");p="string"===typeof t.signedMessage?t.signedMessage:(new TextDecoder).decode(t.signedMessage),h=t.signature}else{if(!("signMessage"in v)||"function"!==typeof v.signMessage||!("publicKey"in v)||"object"!==typeof v||!v.publicKey||!("toBase58"in v.publicKey)||"function"!==typeof v.publicKey.toBase58)throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");p=["".concat(g.host," wants you to sign in with your Solana account:"),v.publicKey.toBase58(),...f?["",f,""]:[""],"Version: 1","URI: ".concat(g.href),"Issued At: ".concat(null!==(a=null===(n=null===x||void 0===x?void 0:x.signInWithSolana)||void 0===n?void 0:n.issuedAt)&&void 0!==a?a:(new Date).toISOString()),...(null===(r=null===x||void 0===x?void 0:x.signInWithSolana)||void 0===r?void 0:r.notBefore)?["Not Before: ".concat(x.signInWithSolana.notBefore)]:[],...(null===(s=null===x||void 0===x?void 0:x.signInWithSolana)||void 0===s?void 0:s.expirationTime)?["Expiration Time: ".concat(x.signInWithSolana.expirationTime)]:[],...(null===(i=null===x||void 0===x?void 0:x.signInWithSolana)||void 0===i?void 0:i.chainId)?["Chain ID: ".concat(x.signInWithSolana.chainId)]:[],...(null===(o=null===x||void 0===x?void 0:x.signInWithSolana)||void 0===o?void 0:o.nonce)?["Nonce: ".concat(x.signInWithSolana.nonce)]:[],...(null===(l=null===x||void 0===x?void 0:x.signInWithSolana)||void 0===l?void 0:l.requestId)?["Request ID: ".concat(x.signInWithSolana.requestId)]:[],...(null===(d=null===(c=null===x||void 0===x?void 0:x.signInWithSolana)||void 0===c?void 0:c.resources)||void 0===d?void 0:d.length)?["Resources",...x.signInWithSolana.resources.map(e=>"- ".concat(e))]:[]].join("\n");const e=await v.signMessage((new TextEncoder).encode(p),"utf8");if(!e||!(e instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");h=e}}try{const{data:t,error:n}=await Tn(this.fetch,"POST","".concat(this.url,"/token?grant_type=web3"),{headers:this.headers,body:Object.assign({chain:"solana",message:p,signature:pn(h)},(null===(u=e.options)||void 0===u?void 0:u.captchaToken)?{gotrue_meta_security:{captcha_token:null===(m=e.options)||void 0===m?void 0:m.captchaToken}}:null),xform:Pn});if(n)throw n;if(!t||!t.session||!t.user){const e=new Yt;return this._returnResult({data:{user:null,session:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign({},t),error:n})}catch(f){if(Vt(f))return this._returnResult({data:{user:null,session:null},error:f});throw f}}async _exchangeCodeForSession(e){const t=await yn(this.storage,"".concat(this.storageKey,"-code-verifier")),[n,a]=(null!==t&&void 0!==t?t:"").split("/");try{if(!n&&"pkce"===this.flowType)throw new Qt;const{data:t,error:r}=await Tn(this.fetch,"POST","".concat(this.url,"/token?grant_type=pkce"),{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Pn});if(await bn(this.storage,"".concat(this.storageKey,"-code-verifier")),r)throw r;if(!t||!t.session||!t.user){const e=new Yt;return this._returnResult({data:{user:null,session:null,redirectType:null},error:e})}return t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),this._returnResult({data:Object.assign(Object.assign({},t),{redirectType:null!==a&&void 0!==a?a:null}),error:r})}catch(r){if(await bn(this.storage,"".concat(this.storageKey,"-code-verifier")),Vt(r))return this._returnResult({data:{user:null,session:null,redirectType:null},error:r});throw r}}async signInWithIdToken(e){try{const{options:t,provider:n,token:a,access_token:r,nonce:s}
2=e,i=await Tn(this.fetch,"POST","".concat(this.url,"/token?grant_type=id_token"),{headers:this.headers,body:{provider:n,id_token:a,access_token:r,nonce:s,gotrue_meta_security:{captcha_token:null===t||void 0===t?void 0:t.captchaToken}},xform:Pn}),{data:o,error:l}=i;if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!o||!o.session||!o.user){const e=new Yt;return this._returnResult({data:{user:null,session:null},error:e})}return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",o.session)),this._returnResult({data:o,error:l})}catch(t){if(Vt(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async signInWithOtp(e){var t,n,a,r,s;try{if("email"in e){const{email:a,options:r}=e;let s=null,i=null;"pkce"===this.flowType&&([s,i]=await _n(this.storage,this.storageKey));const{error:o}=await Tn(this.fetch,"POST","".concat(this.url,"/otp"),{headers:this.headers,body:{email:a,data:null!==(t=null===r||void 0===r?void 0:r.data)&&void 0!==t?t:{},create_user:null===(n=null===r||void 0===r?void 0:r.shouldCreateUser)||void 0===n||n,gotrue_meta_security:{captcha_token:null===r||void 0===r?void 0:r.captchaToken},code_challenge:s,code_challenge_method:i},redirectTo:null===r||void 0===r?void 0:r.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}if("phone"in e){const{phone:t,options:n}=e,{data:i,error:o}=await Tn(this.fetch,"POST","".concat(this.url,"/otp"),{headers:this.headers,body:{phone:t,data:null!==(a=null===n||void 0===n?void 0:n.data)&&void 0!==a?a:{},create_user:null===(r=null===n||void 0===n?void 0:n.shouldCreateUser)||void 0===r||r,gotrue_meta_security:{captcha_token:null===n||void 0===n?void 0:n.captchaToken},channel:null!==(s=null===n||void 0===n?void 0:n.channel)&&void 0!==s?s:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:null===i||void 0===i?void 0:i.message_id},error:o})}throw new Jt("You must provide either an email or phone number.")}catch(i){if(await bn(this.storage,"".concat(this.storageKey,"-code-verifier")),Vt(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async verifyOtp(e){var t,n;try{let a,r;"options"in e&&(a=null===(t=e.options)||void 0===t?void 0:t.redirectTo,r=null===(n=e.options)||void 0===n?void 0:n.captchaToken);const{data:s,error:i}=await Tn(this.fetch,"POST","".concat(this.url,"/verify"),{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:r}}),redirectTo:a,xform:Pn});if(i)throw i;if(!s){throw new Error("An error occurred on token verification.")}const o=s.session,l=s.user;return(null===o||void 0===o?void 0:o.access_token)&&(await this._saveSession(o),await this._notifyAllSubscribers("recovery"==e.type?"PASSWORD_RECOVERY":"SIGNED_IN",o)),this._returnResult({data:{user:l,session:o},error:null})}catch(a){if(Vt(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async signInWithSSO(e){var t,n,a,r,s;try{let i=null,o=null;"pkce"===this.flowType&&([i,o]=await _n(this.storage,this.storageKey));const l=await Tn(this.fetch,"POST","".concat(this.url,"/sso"),{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:null!==(n=null===(t=e.options)||void 0===t?void 0:t.redirectTo)&&void 0!==n?n:void 0}),(null===(a=null===e||void 0===e?void 0:e.options)||void 0===a?void 0:a.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:o}),headers:this.headers,xform:Ln});return(null===(r=l.data)||void 0===r?void 0:r.url)&&hn()&&!(null===(s=e.options)||void 0===s?void 0:s.skipBrowserRedirect)&&window.location.assign(l.data.url),this._returnResult(l)}catch(i){if(await bn(this.storage,"".concat(this.storageKey,"-code-verifier")),Vt(i))return this._returnResult({data:null,error:i});throw i}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:t},error:n}=e;if(n)throw n;if(!t)throw new Gt;const{error:a}=await Tn(this.fetch,"GET","".concat(this.url,"/reauthenticate"),{headers:this.headers,jwt:t.access_token});return this._returnResult({data:{user:null,session:null},error:a})})}catch(e){if(Vt(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const t="".concat(this.url,"/resend");if("email"in e){const{email:n,type:a,options:r}=e,{error:s}=await Tn(this.fetch,"POST",t,{headers:this.headers,body:{email:n,type:a,gotrue_meta_security:{captcha_token:null===r||void 0===r?void 0:r.captchaToken}},redirectTo:null===r||void 0===r?void 0:r.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:s})}if("phone"in e){const{phone:n,type:a,options:r}=e,{data:s,error:i}=await Tn(this.fetch,"POST",t,{headers:this.headers,body:{phone:n,type:a,gotrue_meta_security:{captcha_token:null===r||void 0===r?void 0:r.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:null===s||void 0===s?void 0:s.message_id},error:i})}throw new Jt("You must provide either an email or phone number and a type")}catch(t){if(Vt(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async getSession(){await this.initializePromise;return await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async e=>e))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const e=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await n}catch(e){}})()),n}return await this.lock("lock:".concat(this.storageKey),e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const e=t();for(this.pendingInLock.push((async()=>{try{await e}catch(t){}})()),await e;this.pendingInLock.length;){const e=[...this.pendingInLock];await Promise.all(e),this.pendingInLock.splice(0,e.length)}return await e}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",(new Error).stack);try{let e=null;const t=await yn(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),null!==t&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not val
2id"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=!!e.expires_at&&1e3*e.expires_at-Date.now()<Ot;if(this._debug("#__loadSession()","session has".concat(n?"":" not"," expired"),"expires_at",e.expires_at),!n){if(this.userStorage){const t=await yn(this.userStorage,this.storageKey+"-user");(null===t||void 0===t?void 0:t.user)?e.user=t.user:e.user=Sn()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const t={value:this.suppressGetSessionWarning};e.user=function(e,t){return new Proxy(e,{get:(e,n,a)=>{if("__isInsecureUserWarningProxy"===n)return!0;if("symbol"===typeof n){const t=n.toString();if("Symbol(Symbol.toPrimitive)"===t||"Symbol(Symbol.toStringTag)"===t||"Symbol(util.inspect.custom)"===t||"Symbol(nodejs.util.inspect.custom)"===t)return Reflect.get(e,n,a)}return t.value||"string"!==typeof n||(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t.value=!0),Reflect.get(e,n,a)}})}(e.user,t),t.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:a,error:r}=await this._callRefreshToken(e.refresh_token);return r?this._returnResult({data:{session:null},error:r}):this._returnResult({data:{session:a},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const t=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return t.data.user&&(this.suppressGetSessionWarning=!0),t}async _getUser(e){try{return e?await Tn(this.fetch,"GET","".concat(this.url,"/user"),{headers:this.headers,jwt:e,xform:Bn}):await this._useSession(async e=>{var t,n,a;const{data:r,error:s}=e;if(s)throw s;return(null===(t=r.session)||void 0===t?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await Tn(this.fetch,"GET","".concat(this.url,"/user"),{headers:this.headers,jwt:null!==(a=null===(n=r.session)||void 0===n?void 0:n.access_token)&&void 0!==a?a:void 0,xform:Bn}):{data:{user:null},error:new Gt}})}catch(t){if(Vt(t))return Kt(t)&&(await this._removeSession(),await bn(this.storage,"".concat(this.storageKey,"-code-verifier"))),this._returnResult({data:{user:null},error:t});throw t}}async updateUser(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,t))}async _updateUser(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return await this._useSession(async n=>{const{data:a,error:r}=n;if(r)throw r;if(!a.session)throw new Gt;const s=a.session;let i=null,o=null;"pkce"===this.flowType&&null!=e.email&&([i,o]=await _n(this.storage,this.storageKey));const{data:l,error:c}=await Tn(this.fetch,"PUT","".concat(this.url,"/user"),{headers:this.headers,redirectTo:null===t||void 0===t?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:i,code_challenge_method:o}),jwt:s.access_token,xform:Bn});if(c)throw c;return s.user=l.user,await this._saveSession(s),await this._notifyAllSubscribers("USER_UPDATED",s),this._returnResult({data:{user:s.user},error:null})})}catch(n){if(await bn(this.storage,"".concat(this.storageKey,"-code-verifier")),Vt(n))return this._returnResult({data:{user:null},error:n});throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Gt;const t=Date.now()/1e3;let n=t,a=!0,r=null;const{payload:s}=jn(e.access_token);if(s.exp&&(n=s.exp,a=n<=t),a){const{data:t,error:n}=await this._callRefreshToken(e.refresh_token);if(n)return this._returnResult({data:{user:null,session:null},error:n});if(!t)return{data:{user:null,session:null},error:null};r=t}else{const{data:a,error:s}=await this._getUser(e.access_token);if(s)return this._returnResult({data:{user:null,session:null},error:s});r={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:n-t,expires_at:n},await this._saveSession(r),await this._notifyAllSubscribers("SIGNED_IN",r)}return this._returnResult({data:{user:r.user,session:r},error:null})}catch(t){if(Vt(t))return this._returnResult({data:{session:null,user:null},error:t});throw t}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async t=>{var n;if(!e){const{data:a,error:r}=t;if(r)throw r;e=null!==(n=a.session)&&void 0!==n?n:void 0}if(!(null===e||void 0===e?void 0:e.refresh_token))throw new Gt;const{data:a,error:r}=await this._callRefreshToken(e.refresh_token);return r?this._returnResult({data:{user:null,session:null},error:r}):a?this._returnResult({data:{user:a.user,session:a},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(t){if(Vt(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async _getSessionFromURL(e,t){try{if(!hn())throw new $t("No browser detected.");
2if(e.error||e.error_description||e.error_code)throw new $t(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if("pkce"===this.flowType)throw new Xt("Not a valid PKCE flow url.");break;case"pkce":if("implicit"===this.flowType)throw new $t("Not a valid implicit grant flow url.")}if("pkce"===t){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Xt("No code detected.");const{data:t,error:n}=await this._exchangeCodeForSession(e.code);if(n)throw n;const a=new URL(window.location.href);return a.searchParams.delete("code"),window.history.replaceState(window.history.state,"",a.toString()),{data:{session:t.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:r,refresh_token:s,expires_in:i,expires_at:o,token_type:l}=e;if(!r||!i||!s||!l)throw new $t("No session defined in URL");const c=Math.round(Date.now()/1e3),d=parseInt(i);let u=c+d;o&&(u=parseInt(o));const m=u-c;1e3*m<=Pt&&console.warn("@supabase/gotrue-js: Session as retrieved from URL expires in ".concat(m,"s, should have been closer to ").concat(d,"s"));const p=u-d;c-p>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",p,u,c):c-p<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",p,u,c);const{data:h,error:f}=await this._getUser(r);if(f)throw f;const x={provider_token:n,provider_refresh_token:a,access_token:r,expires_in:d,expires_at:u,refresh_token:s,token_type:l,user:h.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:x,redirectType:e.type},error:null})}catch(n){if(Vt(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return"function"===typeof this.detectSessionInUrl?this.detectSessionInUrl(new URL(window.location.href),e):Boolean(e.access_token||e.error_description)}async _isPKCECallback(e){const t=await yn(this.storage,"".concat(this.storageKey,"-code-verifier"));return!(!e.code||!t)}async signOut(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{scope:"global"};return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut(){let{scope:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{scope:"global"};return await this._useSession(async t=>{var n;const{data:a,error:r}=t;if(r&&!Kt(r))return this._returnResult({error:r});const s=null===(n=a.session)||void 0===n?void 0:n.access_token;if(s){const{error:t}=await this.admin.signOut(s,e);if(t&&(!function(e){return Vt(e)&&"AuthApiError"===e.name}(t)||404!==t.status&&401!==t.status&&403!==t.status)&&!Kt(t))return this._returnResult({error:t})}return"others"!==e&&(await this._removeSession(),await bn(this.storage,"".concat(this.storageKey,"-code-verifier"))),this._returnResult({error:null})})}onAuthStateChange(e){const t=Symbol("auth-callback"),n={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,n),(async()=>{await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(t)})})(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async t=>{var n,a;try{const{data:{session:a},error:r}=t;if(r)throw r;await(null===(n=this.stateChangeEmitters.get(e))||void 0===n?void 0:n.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(r){await(null===(a=this.stateChangeEmitters.get(e))||void 0===a?void 0:a.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",r),Kt(r)?console.warn(r):console.error(r)}})}async resetPasswordForEmail(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,a=null;"pkce"===this.flowType&&([n,a]=await _n(this.storage,this.storageKey,!0));try{return await Tn(this.fetch,"POST","".concat(this.url,"/recover"),{body:{email:e,code_challenge:n,code_challenge_method:a,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(r){if(await bn(this.storage,"".concat(this.storageKey,"-code-verifier")),Vt(r))return this._returnResult({data:null,error:r});throw r}}async getUserIdentities(){var e;try{const{data:t,error:n}=await this.getUser();if(n)throw n;return this._returnResult({data:{identities:null!==(e=t.user.identities)&&void 0!==e?e:[]},error:null})}catch(t){if(Vt(t))return this._returnResult({data:null,error:t});throw t}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var t;try{const{data:n,error:a}=await this._useSession(async t=>{var n,a,r,s,i;const{data:o,error:l}=t;if(l)throw l;const c=await this._getUrlForProvider("".concat(this.url,"/user/identities/authorize"),e.provider,{redirectTo:null===(n=e.options)||void 0===n?void 0:n.redirectTo,scopes:null===(a=e.options)||void 0===a?void 0:a.scopes,queryParams:null===(r=e.options)||void 0===r?void 0:r.queryParams,skipBrowserRedirect:!0});return await Tn(this.fetch,"GET",c,{headers:this.headers,jwt:null!==(i=null===(s=o.session)||void 0===s?void 0:s.access_token)&&void 0!==i?i:void 0})});if(a)throw a;return hn()&&!(null===(t=e.options)||void 0===t?void 0:t.skipBrowserRedirect)&&window.location.assign(null===n||void 0===n?void 0:n.url),this._returnResult({data:{provider:e.provider,url:null===n||void 0===n?void 0:n.url},error:null})}catch(n){if(Vt(n))return this._returnResult({data:{provider:e.provider,url:null},error:n});throw n}}async linkIdentityIdToken(e){return await this._useSession(async t=>{var n;try{const{error:a,data:{session:r}}=t;if(a)throw a;const{options:s,provider:i,token:o,access_token:l,nonce:c}=e,d=await Tn(this.fetch,"POST","".concat(this.url,"/token?grant_type=id_token"),{headers:this.headers,jwt:null!==(n=null===r||void 0===r?void 0:r.access_token)&&void 0!==n?n:void 0,body:{provider:i,id_token:o,access_token:l,nonce:c,link_identity:!0,gotrue_meta_security:{captcha_token:null===s||void 0===s?void 0:s.captchaToken}},xform:Pn}),{data:u,error:m}=d;return m?this._returnResult({data:{user:null,session:null},error:m}):u&&u.session&&u.user?(u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("USER_UPDATED",u.session)),this._returnResult({data:u,error:m})):this._returnResult({data:{user:null,session:null},error:new Yt})}catch(a){if(await bn(this.storage,"".concat(this.storageKey,"-code-verifier")),Vt(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}})}async unlinkIdentity(e){try{return await this._useSession(async t=>{var n,a;const{data:r,error:s}=t;if(s)throw s;
2return await Tn(this.fetch,"DELETE","".concat(this.url,"/user/identities/").concat(e.identity_id),{headers:this.headers,jwt:null!==(a=null===(n=r.session)||void 0===n?void 0:n.access_token)&&void 0!==a?a:void 0})})}catch(t){if(Vt(t))return this._returnResult({data:null,error:t});throw t}}async _refreshAccessToken(e){const t="#_refreshAccessToken(".concat(e.substring(0,5),"...)");this._debug(t,"begin");try{const r=Date.now();return await(n=async n=>(n>0&&await async function(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}(200*Math.pow(2,n-1)),this._debug(t,"refreshing attempt",n),await Tn(this.fetch,"POST","".concat(this.url,"/token?grant_type=refresh_token"),{body:{refresh_token:e},headers:this.headers,xform:Pn})),a=(e,t)=>{const n=200*Math.pow(2,e);return t&&en(t)&&Date.now()+n-r<Pt},new Promise((e,t)=>{(async()=>{for(let s=0;s<1/0;s++)try{const t=await n(s);if(!a(s,null,t))return void e(t)}catch(r){if(!a(s,r))return void t(r)}})()}))}catch(r){if(this._debug(t,"error",r),Vt(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}finally{this._debug(t,"end")}var n,a}_isValidSession(e){return"object"===typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){const n=await this._getUrlForProvider("".concat(this.url,"/authorize"),e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",n),hn()&&!t.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e,t;const n="#_recoverAndRefresh()";this._debug(n,"begin");try{const r=await yn(this.storage,this.storageKey);if(r&&this.userStorage){let t=await yn(this.userStorage,this.storageKey+"-user");this.storage.isServer||!Object.is(this.storage,this.userStorage)||t||(t={user:r.user},await gn(this.userStorage,this.storageKey+"-user",t)),r.user=null!==(e=null===t||void 0===t?void 0:t.user)&&void 0!==e?e:Sn()}else if(r&&!r.user&&!r.user){const e=await yn(this.storage,this.storageKey+"-user");e&&(null===e||void 0===e?void 0:e.user)?(r.user=e.user,await bn(this.storage,this.storageKey+"-user"),await gn(this.storage,this.storageKey,r)):r.user=Sn()}if(this._debug(n,"session from storage",r),!this._isValidSession(r))return this._debug(n,"session is not valid"),void(null!==r&&await this._removeSession());const s=1e3*(null!==(t=r.expires_at)&&void 0!==t?t:1/0)-Date.now()<Ot;if(this._debug(n,"session has".concat(s?"":" not"," expired with margin of ").concat(Ot,"s")),s){if(this.autoRefreshToken&&r.refresh_token){const{error:e}=await this._callRefreshToken(r.refresh_token);e&&(console.error(e),en(e)||(this._debug(n,"refresh failed with a non-retryable error, removing the session",e),await this._removeSession()))}}else if(r.user&&!0===r.user.__isUserNotAvailableProxy)try{const{data:e,error:t}=await this._getUser(r.access_token);!t&&(null===e||void 0===e?void 0:e.user)?(r.user=e.user,await this._saveSession(r),await this._notifyAllSubscribers("SIGNED_IN",r)):this._debug(n,"could not get user data, skipping SIGNED_IN notification")}catch(a){console.error("Error getting user data:",a),this._debug(n,"error getting user data, skipping SIGNED_IN notification",a)}else await this._notifyAllSubscribers("SIGNED_IN",r)}catch(r){return this._debug(n,"error",r),void console.error(r)}finally{this._debug(n,"end")}}async _callRefreshToken(e){var t,n;if(!e)throw new Gt;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const a="#_callRefreshToken(".concat(e.substring(0,5),"...)");this._debug(a,"begin");try{this.refreshingDeferred=new wn;const{data:t,error:n}=await this._refreshAccessToken(e);if(n)throw n;if(!t.session)throw new Gt;await this._saveSession(t.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",t.session);const a={data:t.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(r){if(this._debug(a,"error",r),Vt(r)){const e={data:null,error:r};return en(r)||await this._removeSession(),null===(t=this.refreshingDeferred)||void 0===t||t.resolve(e),e}throw null===(n=this.refreshingDeferred)||void 0===n||n.reject(r),r}finally{this.refreshingDeferred=null,this._debug(a,"end")}}async _notifyAllSubscribers(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const a="#_notifyAllSubscribers(".concat(e,")");this._debug(a,"begin",t,"broadcast = ".concat(n));try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:t});const a=[],r=Array.from(this.stateChangeEmitters.values()).map(async n=>{try{await n.callback(e,t)}catch(r){a.push(r)}});if(await Promise.all(r),a.length>0){for(let e=0;e<a.length;e+=1)console.error(a[e]);throw a[0]}}finally{this._debug(a,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await bn(this.storage,"".concat(this.storageKey,"-code-verifier"));const t=Object.assign({},e),n=t.user&&!0===t.user.__isUserNotAvailableProxy;if(this.userStorage){!n&&t.user&&await gn(this.userStorage,this.storageKey+"-user",{user:t.user});const e=Object.assign({},t);delete e.user;const a=En(e);await gn(this.storage,this.storageKey,a)}else{const e=En(t);await gn(this.storage,this.storageKey,e)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await bn(this.storage,this.storageKey),await bn(this.storage,this.storageKey+"-code-verifier"),await bn(this.storage,this.storageKey+"-user"),this.userStorage&&await bn(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&hn()&&(null===window||void 0===window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}
2catch(t){console.error("removing visibilitychange callback failed",t)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Pt);this.autoRefreshTicker=e,e&&"object"===typeof e&&"function"===typeof e.unref?e.unref():"undefined"!==typeof Deno&&"function"===typeof Deno.unrefTimer&&Deno.unrefTimer(e);const t=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=t,t&&"object"===typeof t&&"function"===typeof t.unref?t.unref():"undefined"!==typeof Deno&&"function"===typeof Deno.unrefTimer&&Deno.unrefTimer(t)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const t=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,t&&clearTimeout(t)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const t=Date.now();try{return await this._useSession(async e=>{const{data:{session:n}}=e;if(!n||!n.refresh_token||!n.expires_at)return void this._debug("#_autoRefreshTokenTick()","no session");const a=Math.floor((1e3*n.expires_at-t)/Pt);this._debug("#_autoRefreshTokenTick()","access token expires in ".concat(a," ticks, a tick lasts ").concat(Pt,"ms, refresh threshold is ").concat(3," ticks")),a<=3&&await this._callRefreshToken(n.refresh_token)})}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(!(e.isAcquireTimeout||e instanceof Hn))throw e;this._debug("auto refresh token tick lock not available")}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!hn()||!(null===window||void 0===window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},null===window||void 0===window||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const t="#_onVisibilityChanged(".concat(e,")");this._debug(t,"visibilityState",document.visibilityState),"visible"===document.visibilityState?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{"visible"===document.visibilityState?await this._recoverAndRefresh():this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting")}))):"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,n){const a=["provider=".concat(encodeURIComponent(t))];if((null===n||void 0===n?void 0:n.redirectTo)&&a.push("redirect_to=".concat(encodeURIComponent(n.redirectTo))),(null===n||void 0===n?void 0:n.scopes)&&a.push("scopes=".concat(encodeURIComponent(n.scopes))),"pkce"===this.flowType){const[e,t]=await _n(this.storage,this.storageKey),n=new URLSearchParams({code_challenge:"".concat(encodeURIComponent(e)),code_challenge_method:"".concat(encodeURIComponent(t))});a.push(n.toString())}if(null===n||void 0===n?void 0:n.queryParams){const e=new URLSearchParams(n.queryParams);a.push(e.toString())}return(null===n||void 0===n?void 0:n.skipBrowserRedirect)&&a.push("skip_http_redirect=".concat(n.skipBrowserRedirect)),"".concat(e,"?").concat(a.join("&"))}async _unenroll(e){try{return await this._useSession(async t=>{var n;const{data:a,error:r}=t;return r?this._returnResult({data:null,error:r}):await Tn(this.fetch,"DELETE","".concat(this.url,"/factors/").concat(e.factorId),{headers:this.headers,jwt:null===(n=null===a||void 0===a?void 0:a.session)||void 0===n?void 0:n.access_token})})}catch(t){if(Vt(t))return this._returnResult({data:null,error:t});throw t}}async _enroll(e){try{return await this._useSession(async t=>{var n,a;const{data:r,error:s}=t;if(s)return this._returnResult({data:null,error:s});const i=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},"phone"===e.factorType?{phone:e.phone}:"totp"===e.factorType?{issuer:e.issuer}:{}),{data:o,error:l}=await Tn(this.fetch,"POST","".concat(this.url,"/factors"),{body:i,headers:this.headers,jwt:null===(n=null===r||void 0===r?void 0:r.session)||void 0===n?void 0:n.access_token});return l?this._returnResult({data:null,error:l}):("totp"===e.factorType&&"totp"===o.type&&(null===(a=null===o||void 0===o?void 0:o.totp)||void 0===a?void 0:a.qr_code)&&(o.totp.qr_code="data:image/svg+xml;utf-8,".concat(o.totp.qr_code)),this._returnResult({data:o,error:null}))})}catch(t){if(Vt(t))return this._returnResult({data:null,error:t});throw t}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async t=>{var n;const{data:a,error:r}=t;if(r)return this._returnResult({data:null,error:r});const s=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:"create"===e.webauthn.type?aa(e.webauthn.credential_response):ra(e.webauthn.credential_response)})}:{code:e.code}),{data:i,error:o}=await Tn(this.fetch,"POST","".concat(this.url,"/factors/").concat(e.factorId,"/verify"),{body:s,headers:this.headers,jwt:null===(n=null===a||void 0===a?void 0:a.session)||void 0===n?void 0:n.access_token});return o?this._returnResult({data:null,error:o}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+i.expires_in},i)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",i),this._returnResult({data:i,error:o}))})}catch(t){if(Vt(t))return this._returnResult({data:null,error:t});throw t}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async t=>{var n;const{data:a,error:r}=t;if(r)return this._returnResult({data:null,error:r});const s=await Tn(this.fetch,"POST","".concat(this.url,"/factors/").concat(e.factorId,"/challenge"),{body:e,headers:this.headers,jwt:null===(n=null===a||void 0===a?void 0:a.session)||void 0===n?void 0:n.access_token});if(s.error)return s;const{data:i}=s;if("webauthn"!==i.type)return{data:i,error:null};switch(i.webauthn.type){case"create":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:ta(i.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},i),{webauthn:Object.assign(Object.assign({},i.webauthn),{credential_options:Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:na(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(t){if(Vt(t))return this._returnResult({data:null,error:t});throw t}})}async _challengeAndVerify(e){const{data:t,error:n}=await this._challenge({factorId:e.factorId});return n?this._returnResult({data:null,error:n}):await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){var e;const{data:{user:t},error:n}=await this.getUser();if(n)return{data:null,error:n};const a={all:[],phone:[],totp:[],webauthn:[]};for(const r of null!==(e=null===t||void 0===t?void 0:t.factors)&&void 0!==e?e:[])a.all.push(r),"verified"===r.status&&a[r.factor_type].push(r);return{data:a,error:null}}async _getAuthenticatorAssuranceLevel(e){var t,n,a,r;if(e)try{const{payload:a}=jn(e);let r=null;a.aal&&(r=a.aal);let s=r;const{data:{user:i},error:o}=await this.getUser(e);if(o)return this._returnResult({data:null,error:o});(null!==(n=null===(t=null===i||void 0===i?void 0:i.factors)||void 0===t?void 0:t.filter(e=>"verified"===e.status))&&void 0!==n?n:[]).length>0&&(s="aal2");return{data:{currentLevel:r,nextLevel:s,currentAuthenticationMethods:a.amr||[]},error:null}}catch(d){if(Vt(d))return this._returnResult({data:null,error:d});throw d}const{data:{session:s},error:i}
2=await this.getSession();if(i)return this._returnResult({data:null,error:i});if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=jn(s.access_token);let l=null;o.aal&&(l=o.aal);let c=l;(null!==(r=null===(a=s.user.factors)||void 0===a?void 0:a.filter(e=>"verified"===e.status))&&void 0!==r?r:[]).length>0&&(c="aal2");return{data:{currentLevel:l,nextLevel:c,currentAuthenticationMethods:o.amr||[]},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async t=>{const{data:{session:n},error:a}=t;return a?this._returnResult({data:null,error:a}):n?await Tn(this.fetch,"GET","".concat(this.url,"/oauth/authorizations/").concat(e),{headers:this.headers,jwt:n.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new Gt})})}catch(t){if(Vt(t))return this._returnResult({data:null,error:t});throw t}}async _approveAuthorization(e,t){try{return await this._useSession(async n=>{const{data:{session:a},error:r}=n;if(r)return this._returnResult({data:null,error:r});if(!a)return this._returnResult({data:null,error:new Gt});const s=await Tn(this.fetch,"POST","".concat(this.url,"/oauth/authorizations/").concat(e,"/consent"),{headers:this.headers,jwt:a.access_token,body:{action:"approve"},xform:e=>({data:e,error:null})});return s.data&&s.data.redirect_url&&hn()&&!(null===t||void 0===t?void 0:t.skipBrowserRedirect)&&window.location.assign(s.data.redirect_url),s})}catch(n){if(Vt(n))return this._returnResult({data:null,error:n});throw n}}async _denyAuthorization(e,t){try{return await this._useSession(async n=>{const{data:{session:a},error:r}=n;if(r)return this._returnResult({data:null,error:r});if(!a)return this._returnResult({data:null,error:new Gt});const s=await Tn(this.fetch,"POST","".concat(this.url,"/oauth/authorizations/").concat(e,"/consent"),{headers:this.headers,jwt:a.access_token,body:{action:"deny"},xform:e=>({data:e,error:null})});return s.data&&s.data.redirect_url&&hn()&&!(null===t||void 0===t?void 0:t.skipBrowserRedirect)&&window.location.assign(s.data.redirect_url),s})}catch(n){if(Vt(n))return this._returnResult({data:null,error:n});throw n}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:t},error:n}=e;return n?this._returnResult({data:null,error:n}):t?await Tn(this.fetch,"GET","".concat(this.url,"/user/oauth/grants"),{headers:this.headers,jwt:t.access_token,xform:e=>({data:e,error:null})}):this._returnResult({data:null,error:new Gt})})}catch(e){if(Vt(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async t=>{const{data:{session:n},error:a}=t;return a?this._returnResult({data:null,error:a}):n?(await Tn(this.fetch,"DELETE","".concat(this.url,"/user/oauth/grants"),{headers:this.headers,jwt:n.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new Gt})})}catch(t){if(Vt(t))return this._returnResult({data:null,error:t});throw t}}async fetchJwk(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{keys:[]}).keys.find(t=>t.kid===e);if(t)return t;const n=Date.now();if(t=this.jwks.keys.find(t=>t.kid===e),t&&this.jwks_cached_at+6e5>n)return t;const{data:a,error:r}=await Tn(this.fetch,"GET","".concat(this.url,"/.well-known/jwks.json"),{headers:this.headers});if(r)throw r;return a.keys&&0!==a.keys.length?(this.jwks=a,this.jwks_cached_at=n,t=a.keys.find(t=>t.kid===e),t||null):null}async getClaims(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{let n=e;if(!n){const{data:e,error:t}
2=await this.getSession();if(t||!e.session)return this._returnResult({data:null,error:t});n=e.session.access_token}const{header:a,payload:r,signature:s,raw:{header:i,payload:o}}=jn(n);(null===t||void 0===t?void 0:t.allowExpired)||function(e){if(!e)throw new Error("Missing exp claim");if(e<=Math.floor(Date.now()/1e3))throw new Error("JWT has expired")}(r.exp);const l=a.alg&&!a.alg.startsWith("HS")&&a.kid&&"crypto"in globalThis&&"subtle"in globalThis.crypto?await this.fetchJwk(a.kid,(null===t||void 0===t?void 0:t.keys)?{keys:t.keys}:null===t||void 0===t?void 0:t.jwks):null;if(!l){const{error:e}=await this.getUser(n);if(e)throw e;return{data:{claims:r,header:a,signature:s},error:null}}const c=function(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}(a.alg),d=await crypto.subtle.importKey("jwk",l,c,!0,["verify"]);if(!await crypto.subtle.verify(c,d,s,function(e){const t=[];return un(e,e=>t.push(e)),new Uint8Array(t)}("".concat(i,".").concat(o))))throw new nn("Invalid JWT signature");return{data:{claims:r,header:a,signature:s},error:null}}catch(n){if(Vt(n))return this._returnResult({data:null,error:n});throw n}}}ha.nextInstanceID={};const fa=ha;let xa="";xa="undefined"!==typeof Deno?"deno":"undefined"!==typeof document?"web":"undefined"!==typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";const va={headers:{"X-Client-Info":"supabase-js-".concat(xa,"/").concat("2.103.0")}},ga={schema:"public"},ya={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},ba={};function wa(e){return(wa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ja(e){var t=function(e,t){if("object"!=wa(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=wa(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==wa(t)?t:t+""}function ka(e,t,n){return(t=ja(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Na(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function _a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Na(Object(n),!0).forEach(function(t){ka(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Na(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Da=(e,t,n)=>{const a=(e=>e?function(){return e(...arguments)}:function(){return fetch(...arguments)})(n),r=Headers;return async(n,s)=>{var i;const o=null!==(i=await t())&&void 0!==i?i:e;let l=new r(null===s||void 0===s?void 0:s.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization","Bearer ".concat(o)),a(n,_a(_a({},s),{},{headers:l}))}};var Ca=class extends fa{constructor(e){super(e)}},Aa=class{constructor(e,t,n){var a,r;this.supabaseUrl=e,this.supabaseKey=t;const s=function(e){const t=null===e||void 0===e?void 0:e.trim();if(!t)throw new Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL((n=t).endsWith("/")?n:n+"/")}catch(a){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}var n}(e);if(!t)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",s),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",s),this.storageUrl=new URL("storage/v1",s),this.functionsUrl=new URL("functions/v1",s);const i="sb-".concat(s.hostname.split(".")[0],"-auth-token"),o=function(e,t){var n,a;const{db:r,auth:s,realtime:i,global:o}=e,{db:l,auth:c,realtime:d,global:u}=t,m={db:_a(_a({},l),r),auth:_a(_a({},c),s),realtime:_a(_a({},d),i),storage:{},global:_a(_a(_a({},u),o),{},{headers:_a(_a({},null!==(n=null===u||void 0===u?void 0:u.headers)&&void 0!==n?n:{}),null!==(a=null===o||void 0===o?void 0:o.headers)&&void 0!==a?a:{})}),accessToken:async()=>""};return e.accessToken?m.accessToken=e.accessToken:delete m.accessToken,m}(null!==n&&void 0!==n?n:{},{db:ga,realtime:ba,auth:_a(_a({},ya),{},{storageKey:i}),global:va});var l;(this.storageKey=null!==(a=o.auth.storageKey)&&void 0!==a?a:"",this.headers=null!==(r=o.global.headers)&&void 0!==r?r:{},o.accessToken)?(this.accessToken=o.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw new Error("@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.".concat(String(t)," is not possible"))}})):this.auth=this._initSupabaseAuthClient(null!==(l=o.auth)&&void 0!==l?l:{},this.headers,o.global.fetch);this.fetch=Da(t,this._getAccessToken.bind(this),o.global.fetch),this.realtime=this._initRealtimeClient(_a({headers:this.headers,accessToken:this._getAccessToken.bind(this)},o.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(e=>this.realtime.setAuth(e)).catch(e=>console.warn("Failed to set initial Realtime auth token:",e)),this.rest=new D(new URL("rest/v1",s).href,{headers:this.headers,schema:o.db.schema,fetch:this.fetch,timeout:o.db.timeout,urlLengthLimit:o.db.urlLengthLimit}),this.storage=new It(this.storageUrl.href,this.headers,this.fetch,null===n||void 0===n?void 0:n.storage),o.accessToken||this._listenForAuthEvents()}get functions(){return new c(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{head:!1,get:!1,count:void 0};return this.rest.rpc(e,t,n)}channel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}};return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var e,t,n=this;if(n.accessToken)return await n.accessToken();const{data:a}=await n.auth.getSession();return null!==(e=null===(t=a.session)||void 0===t?void 0:t.access_token)&&void 0!==e?e:n.supabaseKey}_initSupabaseAuthClient(e,t,n){let{autoRefreshToken:a,persistSession:r,detectSessionInUrl:s,storage:i,userStorage:o,storageKey:l,flowType:c,lock:d,debug:u,throwOnError:m}=e;const p={Authorization:"Bearer ".concat(this.supabaseKey),apikey:"".concat(this.supabaseKey)};return new Ca({url:this.authUrl.href,headers:_a(_a({},p),t),storageKey:l,autoRefreshToken:a,persistSession:r,detectSessionInUrl:s,storage:i,userStorage:o,flowType:c,lock:d,debug:u,throwOnError:m,fetch:n,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new Ue(this.realtimeUrl.href,_a(_a({},e),{},{params:_a(_a({},{apikey:this.supabaseKey}),null===e||void 0===e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",null===t||void 0===t?void 0:t.access_token)})}_handleTokenChanged(e,t,n){"TOKEN_REFRESHED"!==e&&"SIGNED_IN"!==e||this.changedAccessToken===n?"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0):(this.changedAccessToken=n,this.realtime.setAuth(n))}};(function(){if("undefined"!==typeof window)return!1;const e=globalThis.process;if(!e)return!1;const t=e.version;if(void 0===t||null===t)return!1;const n=t.match(/^v(\d+)\./);return!!n&&parseInt(n[1],10)<=18})()&&console.warn("\u26a0\ufe0f Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to N
2ode.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const Sa=new Set([204,205,304]),Ea=((e,t,n)=>new Aa(e,t,n))("https://gxrskeymwyxkeadshzla.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imd4cnNrZXltd3l4a2VhZHNoemxhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzU5OTEwMzIsImV4cCI6MjA5MTU2NzAzMn0.OUOJuRn9KdjSh2B3zls3Hn6cQm-zUq2fcUQZf4GRiKM",{global:{fetch:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((n,a)=>{const r=new XMLHttpRequest;r.open(t.method||"GET",e);const s=t.headers instanceof Headers?Object.fromEntries(t.headers.entries()):t.headers||{};Object.entries(s).forEach(e=>{let[t,n]=e;return r.setRequestHeader(t,n)}),r.onload=()=>{const e=new Headers;r.getAllResponseHeaders().trim().split("\r\n").forEach(t=>{const n=t.indexOf(": ");n>0&&e.append(t.slice(0,n),t.slice(n+2))});const t=Sa.has(r.status)?null:r.responseText;n(new Response(t,{status:r.status,statusText:r.statusText,headers:e}))},r.onerror=()=>a(new TypeError("Network request failed")),r.send(t.body||null)})}}})},853(e,t,n){e.exports=n(896)},896(e,t){function n(e,t){var n=e.length;e.push(t);e:for(;0<n;){var a=n-1>>>1,r=e[a];if(!(0<s(r,t)))break e;e[a]=t,e[n]=r,n=a}}function a(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var a=0,r=e.length,i=r>>>1;a<i;){var o=2*(a+1)-1,l=e[o],c=o+1,d=e[c];if(0>s(l,n))c<r&&0>s(d,l)?(e[a]=d,e[c]=n,a=c):(e[a]=l,e[o]=n,a=o);else{if(!(c<r&&0>s(d,n)))break e;e[a]=d,e[c]=n,a=c}}}return t}function s(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(t.unstable_now=void 0,"object"===typeof performance&&"function"===typeof performance.now){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],d=[],u=1,m=null,p=3,h=!1,f=!1,x=!1,v=!1,g="function"===typeof setTimeout?setTimeout:null,y="function"===typeof clearTimeout?clearTimeout:null,b="undefined"!==typeof setImmediate?setImmediate:null;function w(e){for(var t=a(d);null!==t;){if(null===t.callback)r(d);else{if(!(t.startTime<=e))break;r(d),t.sortIndex=t.expirationTime,n(c,t)}t=a(d)}}function j(e){if(x=!1,w(e),!f)if(null!==a(c))f=!0,N||(N=!0,k());else{var t=a(d);null!==t&&R(j,t.startTime-e)}}var k,N=!1,_=-1,D=5,C=-1;function A(){return!!v||!(t.unstable_now()-C<D)}function S(){if(v=!1,N){var e=t.unstable_now();C=e;var n=!0;try{e:{f=!1,x&&(x=!1,y(_),_=-1),h=!0;var s=p;try{t:{for(w(e),m=a(c);null!==m&&!(m.expirationTime>e&&A());){var i=m.callback;if("function"===typeof i){m.callback=null,p=m.priorityLevel;var o=i(m.expirationTime<=e);if(e=t.unstable_now(),"function"===typeof o){m.callback=o,w(e),n=!0;break t}m===a(c)&&r(c),w(e)}else r(c);m=a(c)}if(null!==m)n=!0;else{var l=a(d);null!==l&&R(j,l.startTime-e),n=!1}}break e}finally{m=null,p=s,h=!1}n=void 0}}finally{n?k():N=!1}}}if("function"===typeof b)k=function(){b(S)};else if("undefined"!==typeof MessageChannel){var E=new MessageChannel,F=E.port2;E.port1.onmessage=S,k=function(){F.postMessage(null)}}else k=function(){g(S,0)};function R(e,n){_=g(function(){e(t.unstable_now())},n)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<e?Math.floor(1e3/e):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_next=function(e){switch(p){case 1:case 2:case 3:var t=3;break;default:t=p}var n=p;p=t;try{return e()}finally{p=n}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=p;p=e;try{return t()}finally{p=n}},t.unstable_scheduleCallback=function(e,r,s){var i=t.unstable_now();switch("object"===typeof s&&null!==s?s="number"===typeof(s=s.delay)&&0<s?i+s:i:s=i,e){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return e={id:u++,callback:r,priorityLevel:e,startTime:s,expirationTime:o=s+o,sortIndex:-1},s>i?(e.sortIndex=s,n(d,e),null===a(c)&&e===a(d)&&(x?(y(_),_=-1):x=!0,R(j,s-i))
2):(e.sortIndex=o,n(c,e),f||h||(f=!0,N||(N=!0,k()))),e},t.unstable_shouldYield=A,t.unstable_wrapCallback=function(e){var t=p;return function(){var n=p;p=t;try{return e.apply(this,arguments)}finally{p=n}}}},950(e,t,n){!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=n(672)},960(e,t,n){n.d(t,{generateCoverLetterWithPolling:()=>o,q:()=>i});var a=n(555),r=n(657),s=n(266);async function i(e,t){const{apiGet:n,signal:r,onRunStatus:i}=t;if(!e)throw new Error("pollCoverLetterRun: runId is required");const o=Date.now()+12e4;let d=3e3;const u=()=>{"undefined"!==typeof document&&"visible"===document.visibilityState&&(d=500)};"undefined"!==typeof document&&document.addEventListener&&document.addEventListener("visibilitychange",u);try{for(;Date.now()<o;){if(r&&r.aborted)throw new Error("Polling aborted");let t=null;try{t=await n("/api/cover-letters/".concat(e),{headers:{"X-RC-1-52-Poll":"1"}})}catch(v){console.warn("[RC 1.52 coverLetterPolling] transient read error",v),t=null}if(t){const n=(t.status||t.run_status||"complete").toLowerCase();if("function"===typeof i)try{i(n)}catch(g){}if("complete"===n){try{(0,s.Di)()}catch(y){}var m,p,h,f,x;return t.result&&"object"===typeof t.result?(0,a.A)((0,a.A)({},t.result),{},{billing:null!==(m=t.billing)&&void 0!==m?m:null,charge_reason:null!==(p=t.charge_reason)&&void 0!==p?p:null,served_via:null!==(h=t.served_via)&&void 0!==h?h:"poll_200",run_id:null!==(f=t.run_id)&&void 0!==f?f:t.result.cover_letter_id,status:"complete",idempotent_replay:null!==(x=t.idempotent_replay)&&void 0!==x&&x}):c(t)}if("failed"===n){const n=new Error(t.error_detail||t.run_error_detail||"Cover letter generation failed.");throw n.code=t.error_code||t.run_error_code||"cover_letter_failed",n.runStatus="failed",n.runId=e,n}"number"===typeof t.retry_after_ms&&t.retry_after_ms>=1500&&(d=t.retry_after_ms)}await l(d,r)}const t=new Error("Cover letter still generating in the background.");throw t.code="cover_letter_still_running",t.runId=e,t.recoverable=!0,t}finally{"undefined"!==typeof document&&document.removeEventListener&&document.removeEventListener("visibilitychange",u)}}async function o(e){const{requestBody:t,apiPost:n,apiGet:s,signal:o,onRunStatus:l,telemetryHeaders:c,onRunIdReady:d}=e;if(!n||!s)throw new Error("generateCoverLetterWithPolling: apiPost + apiGet required");const u=(0,a.A)({"X-Ndor-Dispatch-Surface":"workspace_cover_letter_section_v1","X-Ndor-Bundle-Version":r.A},c||{}),m=await n("/api/runs",{method:"POST",headers:u,body:{action_code:"cover_letter",payload:t}});if(!m||"object"!==typeof m)throw new Error("cover-letter run dispatch returned non-object");const p=m.served_via||"sync_200";if("sync_200"===p||"replay_200"===p)return m.result&&"object"===typeof m.result?m.result:m;if("async_202"===p){const e=m.run_id;if(!e)throw new Error("cover-letter async_202 envelope missing run_id");if("function"===typeof d)try{d(e)}catch(h){}if("function"===typeof l)try{l("running")}catch(f){}return i(e,{apiGet:s,signal:o,onRunStatus:l})}return m.result||m}function l(e,t){return new Promise((n,a)=>{const r=setTimeout(n,e);t&&t.addEventListener&&t.addEventListener("abort",()=>{clearTimeout(r),a(new Error("Polling aborted"))})})}function c(e){const t=e.content_json||{};return{cover_letter_id:e.id,title:e.title,tone_type:e.tone_type,fit_score:t.fit_score,generated_text:e.content_markdown||"",linked_cv_variant_id:e.cv_variant_id,fabrication_check:t.fabrication_check||{ok:!0},created_at:e.created_at}}},980(e,t,n){n.d(t,{n:()=>d});var a=n(555),r=n(820);const s="https://app.ndorflow.app";function i(e,t){let{method:n,headers:a,body:r}=t;return new Promise((t,s)=>{const i=new XMLHttpRequest;i.open(n||"GET",e),Object.entries(a||{}).forEach(e=>{let[t,n]=e;return i.setRequestHeader(t,n)}),i.onload=()=>{t({status:i.status,ok:i.status>=200&&i.status<300,text:i.responseText})},i.onerror=()=>s(new TypeError("Network request failed")),i.send(r||null)})}let o=!1;function l(){if(!o){o=!0;try{window.dispatchEvent(new Event("ndorflow:session-expired"))}catch(e){}setTimeout(()=>{o=!1},3e4)}}let c=null;async function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{data:{session:n}}=await r.supabase.auth.getSession();if(null===n||void 0===n||!n.access_token){l();const e=new Error("Not authenticated. Please sign in.");throw e.status=401,e.code="SESSION_EXPIRED",e}const o="undefined"!==typeof FormData&&t.body instanceof FormData;let d=null;void 0!==t.body&&null!==t.body&&(d=o||"string"===typeof t.body?t.body:JSON.stringify(t.body));const u=e=>{const n=(0,a.A)((0,a.A)({},t.headers||{}),{},{Authorization:"Bearer ".concat(e)});return o||n["Content-Type"]||n["content-type"]||(n["Content-Type"]="application/json"),n};let m=await i("".concat(s).concat(e),{method:t.method||"GET",headers:u(n.access_token),body:d});if(401===m.status&&!t._skipRefresh){const n=await async function(){return c||(c=(async()=>{try{var e;const{data:t,error:n}=await r.supabase.auth.refreshSession();return n||null===t||void 0===t||null===(e=t.session)||void 0===e||!e.access_token?null:t.session.access_token}catch(t){return null}finally{setTimeout(()=>{c=null},500)}})()),c}();n?m=await i("".concat(s).concat(e),{method:t.method||"GET",headers:u(n),body:d}):l()}let p=null;if(m.text)try{p=JSON.parse(m.text)}catch(f){p=null}if(!m.ok){var h;const e=null===(h=p)||void 0===h?void 0:h.detail;let t,n=null;e&&"object"===typeof e?(n=e.code||null,t=e.reason||e.code||"HTTP ".concat(m.status),"SESSION_EXPIRED"===n&&(l(),t="Your session has expired. Please sign in again.")):t="string"===typeof e&&e||m.text||"HTTP ".concat(m.status);const a=new Error("string"===typeof t?t:JSON.stringify(t));throw a.status=m.status,a.code=n,p&&"object"===typeof p&&(a.data=p),a}return p}},997(e,t,n){n.d(t,{K:()=>c,generateInterviewPrepWithPolling:()=>d});var a=n(555),r=n(980);const s={"X-Envelope":"rc_1_52_canonical"};
2class i extends Error{constructor(e){let{recoverable:t=!1,code:n,detail:a,status:r,runId:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),this.recoverable=t,this.code=n,this.detail=a,this.status=r,this.runId=s}}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new i(e,(0,a.A)({recoverable:!0},t))}async function l(e){let{signal:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((n,a)=>{if(null!==t&&void 0!==t&&t.aborted)return a(o("Interview Prep generation is still running in the background.",{code:"interview_prep_aborted_recoverable"}));const r=setTimeout(n,e);null===t||void 0===t||t.addEventListener("abort",()=>{clearTimeout(r),a(o("Interview Prep generation is still running in the background.",{code:"interview_prep_aborted_recoverable"}))},{once:!0})})}async function c(e){let{signal:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)throw new Error("pollInterviewPrepUntilTerminal: runId required");const n=Date.now();for(;;){var c,d;if(null!==t&&void 0!==t&&t.aborted)throw o("Interview Prep generation is still running in the background.",{code:"interview_prep_aborted_recoverable",runId:e});if(Date.now()-n>12e4)throw o("Interview Prep is taking longer than usual. We will surface it shortly.",{code:"interview_prep_still_running",runId:e});let x;try{x=await(0,r.n)("/api/interview-prep/".concat(e),{method:"GET",headers:s,signal:t})}catch(f){if("AbortError"===(null===f||void 0===f?void 0:f.name))throw o("Interview Prep generation is still running in the background.",{code:"interview_prep_aborted_recoverable",runId:e});await l(1500,{signal:t});continue}const v=((null===(c=x)||void 0===c?void 0:c.status)||"").toLowerCase();if("complete"===v){const t=x.result||{};return(0,a.A)((0,a.A)({},t),{},{run_id:x.run_id||e,interview_prep_id:t.interview_prep_id||x.run_id||e,status:"complete",served_via:"poll_200",billing:x.billing||t.billing||null,idempotent_replay:!1})}var u,m,p,h;if("failed"===v)throw new i((null===(u=x)||void 0===u?void 0:u.error_detail)||"Interview Prep generation failed. Please try again.",{recoverable:!(null===(m=x)||void 0===m||!m.retryable),code:null===(p=x)||void 0===p?void 0:p.error_code,detail:null===(h=x)||void 0===h?void 0:h.error_detail,runId:e});await l((null===(d=x)||void 0===d?void 0:d.retry_after_ms)||1500,{signal:t})}}async function d(){var e,t,n;let{jobId:i,jobText:l,sourceType:d,sourceId:u,cvVariantId:m,baseCvId:p,title:h,idempotencyKey:f,forceRegenerate:x=!1,onRunIdReady:v,signal:g}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!l)throw new Error("jobText is required.");const y={job_id:i,job_text:l,source_type:d,source_id:u,cv_variant_id:m,base_cv_id:p,title:h||"",idempotency_key:x?null:f||null,force_regenerate:!!x};let b;try{b=await(0,r.n)("/api/interview-prep/generate",{method:"POST",body:JSON.stringify(y),headers:(0,a.A)({"Content-Type":"application/json"},s),signal:g})}catch(k){if("AbortError"===(null===k||void 0===k?void 0:k.name))throw o("Interview Prep dispatch was interrupted \u2014 it may still be running.",{code:"interview_prep_aborted_recoverable"});throw k}const w=((null===(e=b)||void 0===e?void 0:e.served_via)||"").toLowerCase();if("sync_200"===w||"replay_200"===w)return b;const j=(null===(t=b)||void 0===t?void 0:t.interview_prep_id)||(null===(n=b)||void 0===n?void 0:n.run_id);if(!j)throw new Error("Interview Prep dispatch returned no run id.");if("function"===typeof v)try{v(j)}catch(N){}return c(j,{signal:g})}}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var s=t[a]={exports:{}};return e[a].call(s.exports,s,s.exports,n),s.exports}(()=>{var e,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;n.t=function(a,r){if(1&r&&(a=this(a)),8&r)return a;
2if("object"===typeof a&&a){if(4&r&&a.__esModule)return a;if(16&r&&"function"===typeof a.then)return a}var s=Object.create(null);n.r(s);var i={};e=e||[null,t({}),t([]),t(t)];for(var o=2&r&&a;("object"==typeof o||"function"==typeof o)&&!~e.indexOf(o);o=t(o))Object.getOwnPropertyNames(o).forEach(e=>i[e]=()=>a[e]);return i.default=()=>a,n.d(s,i),s}})(),n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0;var a={};n.r(a),n.d(a,{boolean:()=>Oz,booleanish:()=>Bz,commaOrSpaceSeparated:()=>Vz,commaSeparated:()=>Uz,number:()=>Mz,overloadedBoolean:()=>Lz,spaceSeparated:()=>zz});var r={};n.r(r),n.d(r,{attentionMarkers:()=>gq,contentInitial:()=>mq,disable:()=>yq,document:()=>uq,flow:()=>hq,flowInitial:()=>pq,insideSpan:()=>vq,string:()=>fq,text:()=>xq});var s=n(43),i=n.t(s,2),o=n(391);function l(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(-1!==t.indexOf(a))continue;n[a]=e[a]}return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)n=s[a],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var c=n(555);const d=["sri"],u=["page"],m=["page","matches"],p=["onClick","discover","prefetch","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition","unstable_defaultShouldRevalidate"],h=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],f=["discover","fetcherKey","navigate","reloadDocument","replace","state","method","action","onSubmit","relative","preventScrollReset","viewTransition","unstable_defaultShouldRevalidate"];var x="popstate";function v(){return N(function(e,t){let{pathname:n,search:a,hash:r}=e.location;return w("",{pathname:n,search:a,hash:r},t.state&&t.state.usr||null,t.state&&t.state.key||"default")},function(e,t){return"string"===typeof t?t:j(t)},null,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}function g(e,t){if(!1===e||null===e||"undefined"===typeof e)throw new Error(t)}function y(e,t){if(!e){"undefined"!==typeof console&&console.warn(t);try{throw new Error(t)}catch(n){}}}function b(e,t){return{usr:e.state,key:e.key,idx:t}}function w(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3?arguments[3]:void 0;return(0,c.A)((0,c.A)({pathname:"string"===typeof e?e:e.pathname,search:"",hash:""},"string"===typeof t?k(t):t),{},{state:n,key:t&&t.key||a||Math.random().toString(36).substring(2,10)})}function j(e){let{pathname:t="/",search:n="",hash:a=""}=e;return n&&"?"!==n&&(t+="?"===n.charAt(0)?n:"?"+n),a&&"#"!==a&&(t+="#"===a.charAt(0)?a:"#"+a),t}function k(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function N(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},{window:r=document.defaultView,v5Compat:s=!1}=a,i=r.history,o="POP",l=null,d=u();function u(){return(i.state||{idx:null}).idx}function m(){o="POP";let e=u(),t=null==e?null:e-d;d=e,l&&l({action:o,location:h.location,delta:t})}function p(e){return _(e)}null==d&&(d=0,i.replaceState((0,c.A)((0,c.A)({},i.state),{},{idx:d}),""));let h={get action(){return o},get location(){return e(r,i)},listen(e){if(l)throw new Error("A history only accepts one active listener");return r.addEventListener(x,m),l=e,()=>{r.removeEventListener(x,m),l=null}},createHref:e=>t(r,e),createURL:p,encodeLocation(e){let t=p(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){o="PUSH";let a=w(h.location,e,t);n&&n(a,e),d=u()+1;let c=b(a,d),m=h.createHref(a);try{i.pushState(c,"",m)}catch(p){if(p instanceof DOMException&&"DataCloneError"===p.name)throw p;r.location.assign(m)}s&&l&&l({action:o,location:h.location,delta:1})},replace:function(e,t){o="REPLACE";let a=w(h.location,e,t);n&&n(a,e),d=u();
2let r=b(a,d),c=h.createHref(a);i.replaceState(r,"",c),s&&l&&l({action:o,location:h.location,delta:0})},go:e=>i.go(e)};return h}function _(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="http://localhost";"undefined"!==typeof window&&(n="null"!==window.location.origin?window.location.origin:window.location.href),g(n,"No window.location.(origin|href) available to create URL");let a="string"===typeof e?e:j(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=n+a),new URL(a,n)}new WeakMap;function D(e,t){return C(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:"/",!1)}function C(e,t,n,a){let r=V(("string"===typeof t?k(t):t).pathname||"/",n);if(null==r)return null;let s=A(e);!function(e){e.sort((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let n=e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n]);return n?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)))}(s);let i=null;for(let o=0;null==i&&o<s.length;++o){let e=U(r);i=L(s[o],e,a)}return i}function A(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=function(e,s){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,o=arguments.length>3?arguments[3]:void 0,l={relativePath:void 0===o?e.path||"":o,caseSensitive:!0===e.caseSensitive,childrenIndex:s,route:e};if(l.relativePath.startsWith("/")){if(!l.relativePath.startsWith(a)&&i)return;g(l.relativePath.startsWith(a),'Absolute route path "'.concat(l.relativePath,'" nested under path "').concat(a,'" is not valid. An absolute child route path must start with the combined path of all its parent routes.')),l.relativePath=l.relativePath.slice(a.length)}let c=$([a,l.relativePath]),d=n.concat(l);e.children&&e.children.length>0&&(g(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'.concat(c,'".')),A(e.children,t,d,c,i)),(null!=e.path||e.index)&&t.push({path:c,score:B(c,e.index),routesMeta:d})};return e.forEach((e,t)=>{var n;if(""!==e.path&&null!==(n=e.path)&&void 0!==n&&n.includes("?"))for(let a of S(e.path))s(e,t,!0,a);else s(e,t)}),t}function S(e){let t=e.split("/");if(0===t.length)return[];let[n,...a]=t,r=n.endsWith("?"),s=n.replace(/\?$/,"");if(0===a.length)return r?[s,""]:[s];let i=S(a.join("/")),o=[];return o.push(...i.map(e=>""===e?s:[s,e].join("/"))),r&&o.push(...i),o.map(t=>e.startsWith("/")&&""===t?"/":t)}var E=/^:[\w-]+$/,F=3,R=2,I=1,T=10,P=-2,O=e=>"*"===e;function B(e,t){let n=e.split("/"),a=n.length;return n.some(O)&&(a+=P),t&&(a+=R),n.filter(e=>!O(e)).reduce((e,t)=>e+(E.test(t)?F:""===t?I:T),a)}function L(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],{routesMeta:a}=e,r={},s="/",i=[];for(let o=0;o<a.length;++o){let e=a[o],l=o===a.length-1,c="/"===s?t:t.slice(s.length)||"/",d=M({path:e.relativePath,caseSensitive:e.caseSensitive,end:l},c),u=e.route;if(!d&&l&&n&&!a[a.length-1].route.index&&(d=M({path:e.relativePath,caseSensitive:e.caseSensitive,end:!1},c)),!d)return null;
2Object.assign(r,d.params),i.push({params:r,pathname:$([s,d.pathname]),pathnameBase:X($([s,d.pathnameBase])),route:u}),"/"!==d.pathnameBase&&(s=$([s,d.pathnameBase]))}return i}function M(e,t){"string"===typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=z(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let s=r[0],i=s.replace(/(.)\/+$/,"$1"),o=r.slice(1),l=a.reduce((e,t,n)=>{let{paramName:a,isOptional:r}=t;if("*"===a){let e=o[n]||"";i=s.slice(0,s.length-e.length).replace(/(.)\/+$/,"$1")}const l=o[n];return e[a]=r&&!l?void 0:(l||"").replace(/%2F/g,"/"),e},{});return{params:l,pathname:s,pathnameBase:i,pattern:e}}function z(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];y("*"===e||!e.endsWith("*")||e.endsWith("/*"),'Route path "'.concat(e,'" will be treated as if it were "').concat(e.replace(/\*$/,"/*"),'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "').concat(e.replace(/\*$/,"/*"),'".'));let a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(a.push({paramName:t,isOptional:null!=n}),n?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),r+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":""!==e&&"/"!==e&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),a]}function U(e){try{return e.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(t){return y(!1,'The URL path "'.concat(e,'" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (').concat(t,").")),e}}function V(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,a=e.charAt(n);return a&&"/"!==a?null:e.slice(n)||"/"}var q=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,W=e=>q.test(e);function H(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)}),n.length>1?n.join("/"):"/"}function G(e,t,n,a){return"Cannot include a '".concat(e,"' character in a manually specified `to.").concat(t,"` field [").concat(JSON.stringify(a),"]. Please separate it out to the `to.").concat(n,'` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.')}function K(e){return e.filter((e,t)=>0===t||e.route.path&&e.route.path.length>0)}function Y(e){let t=K(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function J(e,t,n){let a,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];"string"===typeof e?a=k(e):(a=(0,c.A)({},e),g(!a.pathname||!a.pathname.includes("?"),G("?","pathname","search",a)),g(!a.pathname||!a.pathname.includes("#"),G("#","pathname","hash",a)),g(!a.search||!a.search.includes("#"),G("#","search","hash",a)));let s,i=""===e||""===a.pathname,o=i?"/":a.pathname;if(null==o)s=n;else{let e=t.length-1;if(!r&&o.startsWith("..")){let t=o.split("/");for(;".."===t[0];)t.shift(),e-=1;a.pathname=t.join("/")}s=e>=0?t[e]:"/"}let l=function(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",{pathname:a,search:r="",hash:s=""}="string"===typeof e?k(e):e;if(a)if(W(a))t=a;else{if(a.includes("//")){let e=a;a=a.replace(/\/\/+/g,"/"),y(!1,"Pathnames cannot have embedded double slashes - normalizing ".concat(e," -> ").concat(a))}t=a.startsWith("/")?H(a.substring(1),"/"):H(a,n)}else t=n;return{pathname:t,search:Q(r),hash:Z(s)}}(a,s),d=o&&"/"!==o&&o.endsWith("/"),u=(i||"."===o)&&n.endsWith("/");return l.pathname.endsWith("/")||!d&&!u||(l.pathname+="/"),l}var $=e=>e.join("/").replace(/\/\/+/g,"/"),X=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Q=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",Z=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";var ee=class{constructor(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.status=e,this.statusText=t||"",this.internal=a,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function te(e){return null!=e&&"number"===typeof e.status&&"string"===typeof e.statusText&&"boolean"===typeof e.internal&&"data"in e}function ne(e){return e.map(e=>
2e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var ae="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;function re(e,t){let n=e;if("string"!==typeof n||!q.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let a=n,r=!1;if(ae)try{let e=new URL(window.location.href),a=n.startsWith("//")?new URL(e.protocol+n):new URL(n),s=V(a.pathname,t);a.origin===e.origin&&null!=s?n=s+a.search+a.hash:r=!0}catch(s){y(!1,'<Link to="'.concat(n,'"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.'))}return{absoluteURL:a,isExternal:r,to:n}}Symbol("Uninstrumented");Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var se=["POST","PUT","PATCH","DELETE"],ie=(new Set(se),["GET",...se]);new Set(ie),Symbol("ResetLoaderData");var oe=s.createContext(null);oe.displayName="DataRouter";var le=s.createContext(null);le.displayName="DataRouterState";var ce=s.createContext(!1);function de(){return s.useContext(ce)}var ue=s.createContext({isTransitioning:!1});ue.displayName="ViewTransition";var me=s.createContext(new Map);me.displayName="Fetchers";var pe=s.createContext(null);pe.displayName="Await";var he=s.createContext(null);he.displayName="Navigation";var fe=s.createContext(null);fe.displayName="Location";var xe=s.createContext({outlet:null,matches:[],isDataRoute:!1});xe.displayName="Route";var ve=s.createContext(null);ve.displayName="RouteError";var ge="REACT_ROUTER_ERROR";function ye(){return null!=s.useContext(fe)}function be(){return g(ye(),"useLocation() may be used only in the context of a <Router> component."),s.useContext(fe).location}var we="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function je(e){s.useContext(he).static||s.useLayoutEffect(e)}function ke(){let{isDataRoute:e}=s.useContext(xe);return e?function(){let{router:e}=Oe("useNavigate"),t=Le("useNavigate"),n=s.useRef(!1);je(()=>{n.current=!0});let a=s.useCallback(async function(a){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};y(n.current,we),n.current&&("number"===typeof a?await e.navigate(a):await e.navigate(a,(0,c.A)({fromRouteId:t},r)))},[e,t]);return a}():function(){g(ye(),"useNavigate() may be used only in the context of a <Router> component.");let e=s.useContext(oe),{basename:t,navigator:n}=s.useContext(he),{matches:a}=s.useContext(xe),{pathname:r}=be(),i=JSON.stringify(Y(a)),o=s.useRef(!1);je(()=>{o.current=!0});let l=s.useCallback(function(a){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(y(o.current,we),!o.current)return;if("number"===typeof a)return void n.go(a);let l=J(a,JSON.parse(i),r,"path"===s.relative);null==e&&"/"!==t&&(l.pathname="/"===l.pathname?t:$([t,l.pathname])),(s.replace?n.replace:n.push)(l,s.state,s)},[t,n,i,r,e]);return l}()}var Ne=s.createContext(null);function _e(){let{matches:e}=s.useContext(xe),t=e[e.length-1];return t?t.params:{}}function De(e){let{relative:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{matches:n}=s.useContext(xe),{pathname:a}=be(),r=JSON.stringify(Y(n));return s.useMemo(()=>J(e,JSON.parse(r),a,"path"===t),[e,r,a,t])}function Ce(e,t,n,a,r){g(ye(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=s.useContext(he),{matches:o}=s.useContext(xe),l=o[o.length-1],d=l?l.params:{},u=l?l.pathname:"/",m=l?l.pathnameBase:"/",p=l&&l.route;{let e=p&&p.path||"";Ue(u,!p||e.endsWith("*")||e.endsWith("*?"),'You rendered descendant <Routes> (or called `useRoutes()`) at "'.concat(u,'" (under <Route path="').concat(e,'">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won\'t match anymore and therefore the child routes will never render.\n\nPlease change the parent <Route path="').concat(e,'"> to <Route path="').concat("/"===e?"*":"".concat(e,"/*"),'">.'))}let h,f=be();if(t){var x;let e="string"===typeof t?k(t):t;g("/"===m||(null===(x=e.pathname)||void 0===x?void 0:x.startsWith(m)),'When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "'.concat(m,'" but pathname "').concat(e.pathname,'" was given in the `location` prop.')),h=e}else h=f;let v=h.pathname||"/",b=v;if("/"!==m){let e=m.replace(/^\//,"").split("/");b="/"+v.replace(/^\//,"").split("/").slice(e.length).join("/")}let w=D(e,{pathname:b});y(p||null!=w,'No routes matched location "'.concat(h.pathname).concat(h.search).concat(h.hash,'" ')),y(null==w||void 0!==w[w.length-1].route.element||void 0!==w[w.length-1].route.Component||void 0!==w[w.length-1].route.lazy,'Matched leaf route at location "'.concat(h.pathname).concat(h.search).concat(h.hash,'" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.'));let j=Te(w&&w.map(e=>Object.assign({},e,{params:Object.assign({},d,e.params),pathname:$([m,i.encodeLocation?i.encodeLocation(e.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?m:$([m,i.encodeLocation?i.encodeLocation(e.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathnameBase])})),o,n,a,r);return t&&j?s.createElement(fe.Provider,{value:{location:(0,c.A)({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:"POP"}},j):j}function Ae(){let e=Me(),t=te(e)?"".concat(e.status," ").concat(e.statusText):e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:a},i={padding:"2px 4px",backgroundColor:a},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=s.createElement(s.Fragment,null,s.createElement("p",null,"\ud83d\udcbf Hey developer \ud83d\udc4b"),s.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",s.createElement("code",{style:i},"ErrorBoundary")," or"," ",s.createElement("code",{style:i},"errorElement")," prop on your route.")),s.createElement(s.Fragment,null,s.createElement("h2",null,"Unexpected Application
2Error!"),s.createElement("h3",{style:{fontStyle:"italic"}},t),n?s.createElement("pre",{style:r},n):null,o)}var Se=s.createElement(Ae,null),Ee=class extends s.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&"object"===typeof e&&e&&"digest"in e&&"string"===typeof e.digest){const t=function(e){if(e.startsWith("".concat(ge,":").concat("ROUTE_ERROR_RESPONSE",":{")))try{let t=JSON.parse(e.slice(40));if("object"===typeof t&&t&&"number"===typeof t.status&&"string"===typeof t.statusText)return new ee(t.status,t.statusText,t.data)}catch(t){}}(e.digest);t&&(e=t)}let t=void 0!==e?s.createElement(xe.Provider,{value:this.props.routeContext},s.createElement(ve.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?s.createElement(Re,{error:e},t):t}};Ee.contextType=ce;var Fe=new WeakMap;function Re(e){let{children:t,error:n}=e,{basename:a}=s.useContext(he);if("object"===typeof n&&n&&"digest"in n&&"string"===typeof n.digest){let e=function(e){if(e.startsWith("".concat(ge,":").concat("REDIRECT",":{")))try{let t=JSON.parse(e.slice(28));if("object"===typeof t&&t&&"number"===typeof t.status&&"string"===typeof t.statusText&&"string"===typeof t.location&&"boolean"===typeof t.reloadDocument&&"boolean"===typeof t.replace)return t}catch(t){}}(n.digest);if(e){let t=Fe.get(n);if(t)throw t;let r=re(e.location,a);if(ae&&!Fe.get(n)){if(!r.isExternal&&!e.reloadDocument){const t=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(r.to,{replace:e.replace}));throw Fe.set(n,t),t}window.location.href=r.absoluteURL||r.to}return s.createElement("meta",{httpEquiv:"refresh",content:"0;url=".concat(r.absoluteURL||r.to)})}}return t}function Ie(e){let{routeContext:t,match:n,children:a}=e,r=s.useContext(oe);return r&&r.static&&r.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=n.route.id),s.createElement(xe.Provider,{value:t},a)}function Te(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(null==e){if(!n)return null;if(n.errors)e=n.matches;else{if(0!==t.length||n.initialized||!(n.matches.length>0))return null;e=n.matches}}let r=e,i=null===n||void 0===n?void 0:n.errors;if(null!=i){let e=r.findIndex(e=>e.route.id&&void 0!==(null===i||void 0===i?void 0:i[e.route.id]));g(e>=0,"Could not find a matching route for errors on route IDs: ".concat(Object.keys(i).join(","))),r=r.slice(0,Math.min(r.length,e+1))}let o=!1,l=-1;if(n)for(let s=0;s<r.length;s++){let e=r[s];if((e.route.HydrateFallback||e.route.hydrateFallbackElement)&&(l=s),e.route.id){let{loaderData:t,errors:a}=n,s=e.route.loader&&!t.hasOwnProperty(e.route.id)&&(!a||void 0===a[e.route.id]);if(e.route.lazy||s){o=!0,r=l>=0?r.slice(0,l+1):[r[0]];break}}}let c=n&&a?(e,t)=>{var r,s;a(e,{location:n.location,params:null!==(r=null===(s=n.matches)||void 0===s||null===(s=s[0])||void 0===s?void 0:s.params)&&void 0!==r?r:{},unstable_pattern:ne(n.matches),errorInfo:t})}:void 0;return r.reduceRight((e,a,d)=>{let u,m=!1,p=null,h=null;n&&(u=i&&a.route.id?i[a.route.id]:void 0,p=a.route.errorElement||Se,o&&(l<0&&0===d?(Ue("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),m=!0,h=null):l===d&&(m=!0,h=a.route.hydrateFallbackElement||null)));let f=t.concat(r.slice(0,d+1)),x=()=>{let t;return t=u?p:m?h:a.route.Component?s.createElement(a.route.Component,null):a.route.element?a.route.element:e,s.createElement(Ie,{match:a,routeC
2ontext:{outlet:e,matches:f,isDataRoute:null!=n},children:t})};return n&&(a.route.ErrorBoundary||a.route.errorElement||0===d)?s.createElement(Ee,{location:n.location,revalidation:n.revalidation,component:p,error:u,children:x(),routeContext:{outlet:null,matches:f,isDataRoute:!0},onError:c}):x()},null)}function Pe(e){return"".concat(e," must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.")}function Oe(e){let t=s.useContext(oe);return g(t,Pe(e)),t}function Be(e){let t=s.useContext(le);return g(t,Pe(e)),t}function Le(e){let t=function(e){let t=s.useContext(xe);return g(t,Pe(e)),t}(e),n=t.matches[t.matches.length-1];return g(n.route.id,"".concat(e,' can only be used on routes that contain a unique "id"')),n.route.id}function Me(){var e;let t=s.useContext(ve),n=Be("useRouteError"),a=Le("useRouteError");return void 0!==t?t:null===(e=n.errors)||void 0===e?void 0:e[a]}var ze={};function Ue(e,t,n){t||ze[e]||(ze[e]=!0,y(!1,n))}var Ve={};function qe(e,t){e||Ve[t]||(Ve[t]=!0,console.warn(t))}i.useOptimistic;s.memo(function(e){let{routes:t,future:n,state:a,onError:r}=e;return Ce(t,void 0,a,r,n)});function We(e){let{to:t,replace:n,state:a,relative:r}=e;g(ye(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=s.useContext(he);y(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:o}=s.useContext(xe),{pathname:l}=be(),c=ke(),d=J(t,Y(o),l,"path"===r),u=JSON.stringify(d);return s.useEffect(()=>{c(JSON.parse(u),{replace:n,state:a,relative:r})},[c,u,r,n,a]),null}function He(e){return function(e){let t=s.useContext(xe).outlet;return s.useMemo(()=>t&&s.createElement(Ne.Provider,{value:e},t),[t,e])}(e.context)}function Ge(e){g(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ke(e){let{basename:t="/",children:n=null,location:a,navigationType:r="POP",navigator:i,static:o=!1,unstable_useTransitions:l}=e;g(!ye(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=t.replace(/^\/*/,"/"),d=s.useMemo(()=>({basename:c,navigator:i,static:o,unstable_useTransitions:l,future:{}}),[c,i,o,l]);"string"===typeof a&&(a=k(a));let{pathname:u="/",search:m="",hash:p="",state:h=null,key:f="default"}=a,x=s.useMemo(()=>{let e=V(u,c);return null==e?null:{location:{pathname:e,search:m,hash:p,state:h,key:f},navigationType:r}},[c,u,m,p,h,f,r]);return y(null!=x,'<Router basename="'.concat(c,'"> is not able to match the URL "').concat(u).concat(m).concat(p,"\" because it does not start with the basename, so the <Router> won't render anything.")),null==x?null:s.createElement(he.Provider,{value:d},s.createElement(fe.Provider,{children:n,value:x}))}function Ye(e){let{children:t,location:n}=e;return Ce(Je(t),n)}s.Component;function Je(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[];return s.Children.forEach(e,(e,a)=>{if(!s.isValidElement(e))return;let r=[...t,a];if(e.type===s.Fragment)return void n.push.apply(n,Je(e.props.children,r));g(e.type===Ge,"[".concat("string"===typeof e.type?e.type:e.type.name,"] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>")),g(!e.props.index||!e.props.children,"An index route cannot have child routes.");let i={id:e.props.id||r.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:!0===e.props.hasErrorBoundary||null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(i.children=Je(e.props.children,r)),n.push(i)}),n}var $e="get",Xe="application/x-www-form-urlencoded";function Qe(e){return"undefined"!==typeof HTMLElement&&e instanceof HTMLElement}function Ze(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return new URLSearchParams("string"===typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let a=e[n];return t.concat(Array.isArray(a)?a.map(e=>[n,e]):[[n,a]])},[]))}var et=null;var tt=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function nt(e){return null==e||tt.has(e)?e:(y(!1,'"'.concat(e,'" is not a valid `encType` for `<Form>`/`<fetcher.Form>` and will default to "').concat(Xe,'"')),null)}function at(e,t){let n,a,r,s,i;if(Qe(o=e)&&"form"===o.tagName.toLowerCase()){let i=e.getAttribute("action");a=i?V(i,t):null,n=e.getAttribute("method")||$e,r=nt(e.getAttribute("enctype"))||Xe,s=new FormData(e)}else if(function(e){return Qe(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return Qe(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let o=e.getAttribute("formaction")||i.getAttribute("action");if(a=o?V(o,t):null,n=e.getAttribute("formmethod")||i.getAttribute("method")||$e,r=nt(e.getAttribute("formenctype"))||nt(i.getAttribute("enctype"))||Xe,s=new FormData(i,e),!function(){if(null===et)try{new FormData(document.createElement("form"),0),et=!1}catch(e){et=!0}return et}()){let{name:t,type:n,value:a}=e;if("image"===n){let e=t?"".concat(t,"."):"";s.append("".concat(e,"x"),"0"),s.append("".concat(e,"y"),"0")}else t&&s.append(t,a)}}else{if(Qe(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=$e,a=null,r=Xe,i=e}var o;return s&&"text/plain"===r&&(i=s,s=void 0),{action:a,method:n.toLowerCase(),encType:r,formData:s,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");"undefined"!==typeof window?window:"undefined"!==typeof globalThis&&globalThis;function rt(e,t){if(!1===e||null===e||"undefined"===typeof e)throw new Error(t)}Symbol("SingleFetchRedirect");function st(e,t,n){let a="string"===typeof e?new URL(e,"undefined"===typeof window?"server://singlefetch/":window.location.origin):e;return"/"===a.pathname?a.pathname="_root.".concat(n):t&&"/"===V(a.pathname,t)?a.pathname="".concat(t.replace(/\/$/,""),"/_root.").concat(n):a.pathname="".concat(a.pathname.replace(/\/$/,""),".").concat(n),a}async function it(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error("Error loading route module `".concat(e.module,"`, reloading page...")),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.
2isSpaMode,window.location.reload(),new Promise(()=>{})}}function ot(e){return null!=e&&"string"===typeof e.page}function lt(e){return null!=e&&(null==e.href?"preload"===e.rel&&"string"===typeof e.imageSrcSet&&"string"===typeof e.imageSizes:"string"===typeof e.rel&&"string"===typeof e.href)}function ct(e,t,n,a,r,s){let i=(e,t)=>!n[t]||e.route.id!==n[t].route.id,o=(e,t)=>{var a;return n[t].pathname!==e.pathname||(null===(a=n[t].route.path)||void 0===a?void 0:a.endsWith("*"))&&n[t].params["*"]!==e.params["*"]};return"assets"===s?t.filter((e,t)=>i(e,t)||o(e,t)):"data"===s?t.filter((t,s)=>{let l=a.routes[t.route.id];if(!l||!l.hasLoader)return!1;if(i(t,s)||o(t,s))return!0;if(t.route.shouldRevalidate){var c;let a=t.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:(null===(c=n[0])||void 0===c?void 0:c.params)||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if("boolean"===typeof a)return a}return!0}):[]}function dt(e,t){let{includeHydrateFallback:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a=e.map(e=>{let a=t.routes[e.route.id];if(!a)return[];let r=[a.module];return a.clientActionModule&&(r=r.concat(a.clientActionModule)),a.clientLoaderModule&&(r=r.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(r=r.concat(a.hydrateFallbackModule)),a.imports&&(r=r.concat(a.imports)),r}
2).flat(1),[...new Set(a)];var a}function ut(e,t){let n=new Set,a=new Set(t);return e.reduce((e,r)=>{if(t&&!ot(r)&&"script"===r.as&&r.href&&a.has(r.href))return e;let s=JSON.stringify(function(e){let t={},n=Object.keys(e).sort();for(let a of n)t[a]=e[a];return t}(r));return n.has(s)||(n.add(s),e.push({key:s,link:r})),e},[])}function mt(e,t){return"lazy"===e.mode&&!0===t}function pt(){let e=s.useContext(oe);return rt(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function ht(){let e=s.useContext(le);return rt(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ft=s.createContext(void 0);function xt(){let e=s.useContext(ft);return rt(e,"You must render this element inside a <HydratedRouter> element"),e}function vt(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function gt(e,t,n){if(n&&!jt)return[e[0]];if(t){let n=e.findIndex(e=>void 0!==t[e.route.id]);return e.slice(0,n+1)}return e}ft.displayName="FrameworkContext";function yt(e){let{page:t}=e,n=l(e,u),{router:a}=pt(),r=s.useMemo(()=>D(a.routes,t,a.basename),[a.routes,t,a.basename]);return r?s.createElement(wt,(0,c.A)({page:t,matches:r},n)):null}function bt(e){let{manifest:t,routeModules:n}=xt(),[a,r]=s.useState([]);return s.useEffect(()=>{let a=!1;return async function(e,t,n){return ut((await Promise.all(e.map(async e=>{let a=t.routes[e.route.id];if(a){let e=await it(a,n);return e.links?e.links():[]}return[]}))).flat(1).filter(lt).filter(e=>"stylesheet"===e.rel||"preload"===e.rel).map(e=>"stylesheet"===e.rel?(0,c.A)((0,c.A)({},e),{},{rel:"prefetch",as:"style"}):(0,c.A)((0,c.A)({},e),{},{rel:"prefetch"})))}(e,t,n).then(e=>{a||r(e)}),()=>{a=!0}},[e,t,n]),a}function wt(e){let{page:t,matches:n}=e,a=l(e,m),r=be(),{manifest:i,routeModules:o}=xt(),{basename:d}=pt(),{loaderData:u,matches:p}=ht(),h=s.useMemo(()=>ct(t,n,p,i,r,"data"),[t,n,p,i,r]),f=s.useMemo(()=>ct(t,n,p,i,r,"assets"),[t,n,p,i,r]),x=s.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let e=new Set,a=!1;if(n.forEach(t=>{var n;let r=i.routes[t.route.id];r&&r.hasLoader&&(!h.some(e=>e.route.id===t.route.id)&&t.route.id in u&&null!==(n=o[t.route.id])&&void 0!==n&&n.shouldRevalidate||r.hasClientLoader?a=!0:e.add(t.route.id))}),0===e.size)return[];let s=st(t,d,"data");return a&&e.size>0&&s.searchParams.set("_routes",n.filter(t=>e.has(t.route.id)).map(e=>e.route.id).join(",")),[s.pathname+s.search]},[d,u,r,i,h,n,t,o]),v=s.useMemo(()=>dt(f,i),[f,i]),g=bt(f);return s.createElement(s.Fragment,null,x.map(e=>s.createElement("link",(0,c.A)({key:e,rel:"prefetch",as:"fetch",href:e},a))),v.map(e=>s.createElement("link",(0,c.A)({key:e,rel:"modulepreload",href:e},a))),g.map(e=>{let{key:t,link:n}=e;return s.createElement("link",(0,c.A)({key:t,nonce:a.nonce},n))}))}var jt=!1;function kt(e){let{manifest:t,serverHandoffString:n,isSpaMode:a,renderMeta:r,routeDiscovery:i,ssr:o}=xt(),{router:u,static:m,staticContext:p}=pt(),{matches:h}=ht(),f=de(),x=mt(i,o);r&&(r.didRenderScripts=!0);let v=gt(h,null,a);s.useEffect(()=>{jt=!0},[]);let g=s.useMemo(()=>{var a;if(f)return null;let r=p?"window.__reactRouterContext = ".concat(n,";").concat("window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());"):" ",i=m?"".concat(null!==(a=t.hmr)&&void 0!==a&&a.runtime?"import ".concat(JSON.stringify(t.hmr.runtime),";"):"").concat(x?"":"import ".concat(JSON.stringify(t.url)),";\n").concat(v.map((e,n)=>{let a="route".concat(n),r=t.routes[e.route.id];rt(r,"Route ".concat(e.route.id," not found in manifest"));let{clientActionModule:s,clientLoaderModule:i,clientMiddlewareModule:o,hydrateFallbackModule:l,module:c}=r,d=[...s?[{module:s,varName:"".concat(a,"_clientAction")}]:[],...i?[{module:i,varName:"".concat(a,"_clientLoader")}]:[],...o?[{module:o,varName:"".concat(a,"_clientMiddleware")}]:[],...l?[{module:l,varName:"".concat(a,"_HydrateFallback")}]:[],{module:c,varName:"".concat(a,"_main")}];return 1===d.length?"import * as ".concat(a," from ").concat(JSON.stringify(c),";"):[d.map(e=>"import * as ".concat(e.varName,' from "').concat(e.module,'";
2')).join("\n"),"const ".concat(a," = {").concat(d.map(e=>"...".concat(e.varName)).join(","),"};")].join("\n")}).join("\n"),"\n ").concat(x?"window.__reactRouterManifest = ".concat(JSON.stringify(function(e,t){let{sri:n}=e,a=l(e,d),r=new Set(t.state.matches.map(e=>e.route.id)),s=t.state.location.pathname.split("/").filter(Boolean),i=["/"];for(s.pop();s.length>0;)i.push("/".concat(s.join("/"))),s.pop();i.forEach(e=>{let n=D(t.routes,e,t.basename);n&&n.forEach(e=>r.add(e.route.id))});let o=[...r].reduce((e,t)=>Object.assign(e,{[t]:a.routes[t]}),{});return(0,c.A)((0,c.A)({},a),{},{routes:o,sri:!!n||void 0})}(t,u),null,2),";"):"","\n window.__reactRouterRouteModules = {").concat(v.map((e,t)=>"".concat(JSON.stringify(e.route.id),":route").concat(t)).join(","),"};\n\nimport(").concat(JSON.stringify(t.entry.module),");"):" ";return s.createElement(s.Fragment,null,s.createElement("script",(0,c.A)((0,c.A)({},e),{},{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:r},type:void 0})),s.createElement("script",(0,c.A)((0,c.A)({},e),{},{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:i},type:"module",async:!0})))},[]),y=jt||f?[]:(b=t.entry.imports.concat(dt(v,t,{includeHydrateFallback:!0})),[...new Set(b)]);var b;let w="object"===typeof t.sri?t.sri:{};return qe(!f,"The <Scripts /> element is a no-op when using RSC and can be safely removed."),jt||f?null:s.createElement(s.Fragment,null,"object"===typeof t.sri?s.createElement("script",{"rr-importmap":"",type:"importmap",suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:JSON.stringify({integrity:w})}}):null,x?null:s.createElement("link",{rel:"modulepreload",href:t.url,crossOrigin:e.crossOrigin,integrity:w[t.url],suppressHydrationWarning:!0}),s.createElement("link",{rel:"modulepreload",href:t.entry.module,crossOrigin:e.crossOrigin,integrity:w[t.entry.module],suppressHydrationWarning:!0}),y.map(t=>s.createElement("link",{key:t,rel:"modulepreload",href:t,crossOrigin:e.crossOrigin,integrity:w[t],suppressHydrationWarning:!0})),g)}function Nt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return e=>{t.forEach(t=>{"function"===typeof t?t(e):null!=t&&(t.current=e)})}}s.Component;function _t(e){let{error:t,isOutsideRemixApp:n}=e;console.error(t);let a,r=s.createElement("script",{dangerouslySetInnerHTML:{__html:'\n console.log(\n "\ud83d\udcbf Hey developer \ud83d\udc4b. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."\n );\n '}});if(te(t))return s.createElement(Dt,{title:"Unhandled Thrown Response!"},s.createElement("h1",{style:{fontSize:"24px"}},t.status," ",t.statusText),r);if(t instanceof Error)a=t;else{let e=null==t?"Unknown Error":"object"===typeof t&&"toString"in t?t.toString():JSON.stringify(t);a=new Error(e)}return s.createElement(Dt,{title:"Application Error!",isOutsideRemixApp:n},s.createElement("h1",{style:{fontSize:"24px"}},"Application Error"),s.createElement("pre",{style:{padding:"2rem",background:"hsla(10, 50%, 50%, 0.1)",color:"red",overflow:"auto"}},a.stack),r)}function Dt(e){var t;let{title:n,renderScripts:a,isOutsideRemixApp:r,children:i}=e,{routeModules:o}=xt();return null!==(t=o.root)&&void 0!==t&&t.Layout&&!r?i:s.createElement("html",{lang:"en"},s.createElement("head",null,s.createElement("meta",{charSet:"utf-8"}),s.createElement("meta",{name:"viewport",content:"width=device-width,initial-scale=1,viewport-fit=cover"}),s.createElement("title",null,n)),s.createElement("body",null,s.createElement("main",{style:{fontFamily:"system-ui, sans-serif",padding:"2rem"}},i,a?s.createElement(kt,null):null)))}var Ct="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;try{Ct&&(window.__reactRouterVersion="7.11.0")}catch(mK){}function At(e){let{basename:t,children:n,unstable_useTransitions:a,window:r}=e,i=s.useRef();null==i.current&&(i.current=v({window:r,v5Compat:!0}));let o=i.current,[l,c]=s.useState({action:o.action,location:o.location}),d=s.useCallback(e=>{!1===a?c(e):s.startTransition(()=>c(e))},[a]);return s.useLayoutEffect(()=>o.listen(d),[o,d]),s.createElement(Ke,{basename:t,children:n,location:l.location,navigationType:l.action,navigator:o,unstable_useTransitions:a})}var St=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Et=s.forwardRef(function(e,t){let{onClick:n,discover:a="render",prefetch:r="none",relative:i,reloadDocument:o,replace:d,state:u,target:m,to:h,preventScrollReset:f,viewTransition:x,unstable_defaultShouldRevalidate:v}=e,y=l(e,p),{basename:b,unstable_useTransitions:w}=s.useContext(he),k="string"===typeof h&&St.test(h),N=re(h,b);h=N.to;let _=function(e){let{relative:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};g(ye(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:a}=s.useContext(he),{hash:r,pathname:i,search:o}=De(e,{relative:t}),l=i;return"/"!==n&&(l="/"===i?n:$([n,i])),a.createHref({pathname:l,search:o,hash:r})}(h,{relative:i}),[D,C,A]=function(e,t){let n=s.useContext(ft),[a,r]=s.useState(!1),[i,o]=s.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:u,onTouchStart:m}=t,p=s.useRef(null);s.useEffect(()=>{if("render"===e&&o(!0),"viewport"===e){let e=new IntersectionObserver(e=>
2{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),s.useEffect(()=>{if(a){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[a]);let h=()=>{r(!0)},f=()=>{r(!1),o(!1)};return n?"intent"!==e?[i,p,{}]:[i,p,{onFocus:vt(l,h),onBlur:vt(c,f),onMouseEnter:vt(d,h),onMouseLeave:vt(u,f),onTouchStart:vt(m,h)}]:[!1,p,{}]}(r,y),S=function(e){let{target:t,replace:n,state:a,preventScrollReset:r,relative:i,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},d=ke(),u=be(),m=De(e,{relative:i});return s.useCallback(p=>{if(function(e,t){return 0===e.button&&(!t||"_self"===t)&&!function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)}(p,t)){p.preventDefault();let t=void 0!==n?n:j(u)===j(m),h=()=>d(e,{replace:t,state:a,preventScrollReset:r,relative:i,viewTransition:o,unstable_defaultShouldRevalidate:l});c?s.startTransition(()=>h()):h()}},[u,d,m,n,a,t,e,r,i,o,l,c])}(h,{replace:d,state:u,target:m,preventScrollReset:f,relative:i,viewTransition:x,unstable_defaultShouldRevalidate:v,unstable_useTransitions:w});let E=s.createElement("a",(0,c.A)((0,c.A)((0,c.A)({},y),A),{},{href:N.absoluteURL||_,onClick:N.isExternal||o?n:function(e){n&&n(e),e.defaultPrevented||S(e)},ref:Nt(t,C),target:m,"data-discover":k||"render"!==a?void 0:"true"}));return D&&!k?s.createElement(s.Fragment,null,E,s.createElement(yt,{page:_})):E});Et.displayName="Link";var Ft=s.forwardRef(function(e,t){let{"aria-current":n="page",caseSensitive:a=!1,className:r="",end:i=!1,style:o,to:d,viewTransition:u,children:m}=e,p=l(e,h),f=De(d,{relative:p.relative}),x=be(),v=s.useContext(le),{navigator:y,basename:b}=s.useContext(he),w=null!=v&&function(e){let{relative:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=s.useContext(ue);g(null!=n,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=Tt("useViewTransitionState"),r=De(e,{relative:t});if(!n.isTransitioning)return!1;let i=V(n.currentLocation.pathname,a)||n.currentLocation.pathname,o=V(n.nextLocation.pathname,a)||n.nextLocation.pathname;return null!=M(r.pathname,o)||null!=M(r.pathname,i)}(f)&&!0===u,j=y.encodeLocation?y.encodeLocation(f).pathname:f.pathname,k=x.pathname,N=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;a||(k=k.toLowerCase(),N=N?N.toLowerCase():null,j=j.toLowerCase()),N&&b&&(N=V(N,b)||N);const _="/"!==j&&j.endsWith("/")?j.length-1:j.length;let D,C=k===j||!i&&k.startsWith(j)&&"/"===k.charAt(_),A=null!=N&&(N===j||!i&&N.startsWith(j)&&"/"===N.charAt(j.length)),S={isActive:C,isPending:A,isTransitioning:w},E=C?n:void 0;D="function"===typeof r?r(S):[r,C?"active":null,A?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let F="function"===typeof o?o(S):o;return s.createElement(Et,(0,c.A)((0,c.A)({},p),{},{"aria-current":E,className:D,ref:t,style:F,to:d,viewTransition:u}),"function"===typeof m?m(S):m)});Ft.displayName="NavLink";var Rt=s.forwardRef((e,t)=>{let{discover:n="render",fetcherKey:a,navigate:r,reloadDocument:i,replace:o,state:d,method:u=$e,action:m,onSubmit:p,relative:h,preventScrollReset:x,viewTransition:v,unstable_defaultShouldRevalidate:y}=e,b=l(e,f),{unstable_useTransitions:w}=s.useContext(he),k=Lt(),N=function(e){let{relative:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{basename:n}=s.useContext(he),a=s.useContext(xe);g(a,"useFormAction must be used inside a RouteContext");let[r]=a.matches.slice(-1),i=(0,c.A)({},De(e||".",{relative:t})),o=be();if(null==e){i.search=o.search;let e=new URLSearchParams(i.search),t=e.getAll("index");if(t.some(e=>""===e)){e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let n=e.toString();i.search=n?"?".concat(n):""}}e&&"."!==e||!r.route.index||(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index");"/"!==n&&(i.pathname="/"===i.pathname?n:$([n,i.pathname]));return j(i)}(m,{relative:h}),_="get"===u.toLowerCase()?"get":"post",D="string"===typeof m&&St.test(m);return s.createElement("form",(0,c.A)((0,c.A)({ref:t,method:_,action:N,onSubmit:i?p:e=>{if(p&&p(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,n=(null===t||void 0===t?void 0:t.getAttribute("formmethod"))||u,i=()=>k(t||e.currentTarget,{fetcherKey:a,method:n,navigate:r,replace:o,state:d,relative:h,preventScrollReset:x,viewTransition:v,unstable_defaultShouldRevalidate:y});w&&!1!==r?s.startTransition(()=>i()):i()}},b),{},{"data-discover":D||"render"!==n?void 0:"true"}))});function It(e){return"".concat(e," must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.")}function Tt(e){let t=s.useContext(oe);return g(t,It(e)),t}function Pt(e){y("undefined"!==typeof URLSearchParams,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=s.useRef(Ze(e)),n=s.useRef(!1),a=be(),r=s.useMemo(()=>function(e,t){let n=Ze(e);return t&&t.forEach((e,a)=>
2{n.has(a)||t.getAll(a).forEach(e=>{n.append(a,e)})}),n}(a.search,n.current?null:t.current),[a.search]),i=ke(),o=s.useCallback((e,t)=>{const a=Ze("function"===typeof e?e(new URLSearchParams(r)):e);n.current=!0,i("?"+a,t)},[i,r]);return[r,o]}Rt.displayName="Form";var Ot=0,Bt=()=>"__".concat(String(++Ot),"__");function Lt(){let{router:e}=Tt("useSubmit"),{basename:t}=s.useContext(he),n=Le("useRouteId"),a=e.fetch,r=e.navigate;return s.useCallback(async function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{action:i,method:o,encType:l,formData:c,body:d}=at(e,t);if(!1===s.navigate){let e=s.fetcherKey||Bt();await a(e,n,s.action||i,{unstable_defaultShouldRevalidate:s.unstable_defaultShouldRevalidate,preventScrollReset:s.preventScrollReset,formData:c,body:d,formMethod:s.method||o,formEncType:s.encType||l,flushSync:s.flushSync})}else await r(s.action||i,{unstable_defaultShouldRevalidate:s.unstable_defaultShouldRevalidate,preventScrollReset:s.preventScrollReset,formData:c,body:d,formMethod:s.method||o,formEncType:s.encType||l,replace:s.replace,state:s.state,fromRouteId:n,flushSync:s.flushSync,viewTransition:s.viewTransition})},[a,r,t,n])}var Mt=n(820),zt=n(980);const Ut=new Set(["email","user_email","name","full_name","first_name","last_name","password","cv_text","jd_text","job_description","resume_text"]);function Vt(){return"undefined"!==typeof window&&!0===window.__ndorAnalyticsConsent}function qt(){return"undefined"!==typeof window&&window.posthog&&"function"===typeof window.posthog.capture}function Wt(e){if(!e||"object"!==typeof e)return e;const t={};for(const n of Object.keys(e))Ut.has(n)||(t[n]=e[n]);return t}function Ht(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;try{if(!e||"string"!==typeof e)return;if(!Vt())return;if(!qt())return;const n=Wt(t);window.posthog.capture(e,n)}catch(n){}}function Gt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;try{if(!e)return;if(!Vt())return;if(!qt())return;const n=Wt(t);window.posthog.identify(String(e),n)}catch(n){}}function Kt(){try{if(!qt())return;window.posthog.reset()}catch(e){}}const Yt="emp_invite_bypass_v1";function Jt(){try{return"undefined"!==typeof window?window.sessionStorage:null}catch(e){return null}}function $t(e){if(!e)return!1;const t=Jt();return!!t&&t.getItem(Yt)===String(e)}var Xt=n(579);const Qt=(0,s.createContext)(null);function Zt(e){const t=(e||"").toLowerCase(),n=t.includes("email not confirmed")||t.includes("email_not_confirmed");let a;return a=n?"Please verify your email address before signing in. Check your inbox for a confirmation link.":t.includes("invalid login credentials")||t.includes("invalid_credentials")?"The email or password you entered is incorrect.":t.includes("user already registered")||t.includes("already been registered")?"An account with this email already exists. Try signing in instead.":t.includes("email rate limit")||t.includes("over_email_send_rate_limit")?"Too many attempts. Please wait a few minutes before trying again.":t.includes("password")&&t.includes("at least")?e:t.includes("body stream")?"Unable to complete the request. Please try again.":e||"Something went wrong. Please try again.",{friendly:a,isEmailUnverified:n}}function en(e){var t;let{children:n}=e;const[a,r]=(0,s.useState)(null),[i,o]=(0,s.useState)(!1),[l,d]=(0,s.use
2State)(!1),[u,m]=(0,s.useState)(!0),p=(0,s.useRef)(!1),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{const{data:{subscription:e}}=Mt.supabase.auth.onAuthStateChange(async(e,t)=>{if(null!==t&&void 0!==t&&t.user){r(e=>e&&e.id===t.user.id&&e.email===t.user.email?e:t.user),Gt(t.user.id),"INITIAL_SESSION"===e&&await new Promise(e=>setTimeout(e,500));const n=new Set(["SIGNED_IN","INITIAL_SESSION"]),a=h.current===t.user.id,s=n.has(e)&&!a;await x(t.user.id,t.access_token,{gate:s}),h.current=t.user.id}else{r(null),o(!1),Kt();try{sessionStorage.removeItem("ndor_onboarding_completed_fired"),sessionStorage.removeItem("ndor_plan_activated_fired"),sessionStorage.removeItem("ndor_dashboard_first_action_fired")}catch(n){}h.current=null,d(!0);try{for(const e of Object.keys(sessionStorage))e.startsWith("ndor-onboarding-")&&sessionStorage.removeItem(e)}catch(a){}}p.current||(p.current=!0,m(!1))}),t=setTimeout(()=>{p.current||(p.current=!0,m(!1))},5e3);return()=>{e.unsubscribe(),clearTimeout(t)}},[]);const f=(0,s.useRef)(new Set);async function x(e,t){let{gate:n=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};console.log("[AuthContext] checkOnboardingComplete called for:",e,"hasToken:",!!t,"gate:",n),n&&d(!1);try{var a,r;let n=t;if(!n){const{data:{session:e}}=await Mt.supabase.auth.getSession();n=null===e||void 0===e?void 0:e.access_token}if(!n)return void console.warn("[AuthContext] No access token available \u2014 preserving prior hasProfile");const s="https://gxrskeymwyxkeadshzla.supabase.co",i="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imd4cnNrZXltd3l4a2VhZHNoemxhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzU5OTEwMzIsImV4cCI6MjA5MTU2NzAzMn0.OUOJuRn9KdjSh2B3zls3Hn6cQm-zUq2fcUQZf4GRiKM",l=e=>new Promise(t=>{const a=new XMLHttpRequest;a.open("GET",e),a.setRequestHeader("apikey",i),a.setRequestHeader("Authorization","Bearer ".concat(n)),a.timeout=6e3,a.onload=()=>{if(a.status>=200&&a.status<300)try{t(JSON.parse(a.responseText))}catch(e){t(null)}else t(null)},a.onerror=()=>t(null),a.ontimeout=()=>t(null),a.send()}),[c,d]=await Promise.all([l("".concat(s,"/rest/v1/profiles?id=eq.").concat(e,"&select=id,employer_access,candidate_access&limit=1")),l("".concat(s,"/rest/v1/consents?user_id=eq.").concat(e,"&select=id&limit=1"))]);if(null===c||null===d)return void console.warn("[AuthContext] checkOnboardingComplete: transport error \u2014 preserving prior hasProfile");const u=Array.isArray(c)&&c.length>0,m=Array.isArray(d)&&d.length>0,p=u&&Array.isArray(c)&&c.length>0&&!0===(null===(a=c[0])||void 0===a?void 0:a.employer_access)&&
2!0!==(null===(r=c[0])||void 0===r?void 0:r.candidate_access),h=p?u:u&&m;console.log("[AuthContext] hasProfile result:",h,"| profile:",u,"| consent:",m,"| employerOnly:",p),o(e=>{if(h&&!1===e)try{const e="ndor_onboarding_completed_fired";"1"!==sessionStorage.getItem(e)&&(Ht("onboarding_completed"),sessionStorage.setItem(e,"1"))}catch(t){}return h})}catch(s){console.warn("[AuthContext] checkOnboardingComplete failed \u2014 preserving prior hasProfile:",s.message)}finally{d(!0)}}(0,s.useEffect)(()=>{var e;if(null===a||void 0===a||!a.id)return;const t=null===a||void 0===a||null===(e=a.user_metadata)||void 0===e?void 0:e.role;if("candidate"!==t&&"employer"!==t)return;const n="".concat(a.id,"::").concat(t);if(f.current.has(n))return;f.current.add(n);let r=!0;return(0,zt.n)("/api/auth/me/self-access",{method:"POST",body:{role:t}}).catch(e=>{r&&409!==(null===e||void 0===e?void 0:e.status)&&console.warn("[AuthContext] self-access apply failed:",null===e||void 0===e?void 0:e.message)}),()=>{r=!1}},[null===a||void 0===a?void 0:a.id,null===a||void 0===a||null===(t=a.user_metadata)||void 0===t?void 0:t.role]);const v=(0,s.useCallback)(async function(e,t){var n,a,r;let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{first_name:i,last_name:o,nickname:l,role:d}=s,u=await Mt.supabase.auth.signUp({email:e,password:t,options:{data:{first_name:i||null,last_name:o||null,nickname:l||null,role:d||null}}});if(u.error){const{friendly:e}=Zt(u.error.message);return u.error=(0,c.A)((0,c.A)({},u.error),{},{message:e}),u}const m=null===(n=u.data)||void 0===n||null===(a=n.user)||void 0===a?void 0:a.id,p=null===(r=u.data)||void 0===r?void 0:r.session;if(m&&null!==p&&void 0!==p&&p.access_token){try{const e=(i||"").trim(),t=(o||"").trim(),n=[e,t].filter(Boolean).join(" ")||null;await Mt.supabase.from("profiles").upsert({id:m,first_name:e||null,last_name:t||null,nickname:(l||"").trim()||null,full_name:n},{onConflict:"id"})}catch(h){console.warn("[AuthContext] profile upsert after signup failed:",(null===h||void 0===h?void 0:h.message)||h)}if("candidate"===d||"employer"===d)try{await(0,zt.n)("/api/auth/me/self-access",{method:"POST",body:{role:d}})}catch(h){console.warn("[AuthContext] self-access apply failed:",(null===h||void 0===h?void 0:h.message)||h)}}return u},[]),g=(0,s.useCallback)(async(e,t)=>{const n=await Mt.supabase.auth.signInWithPassword({email:e,password:t});if(n.error){const{friendly:e,isEmailUnverified:t}=Zt(n.error.message);n.error=(0,c.A)((0,c.A)({},n.error),{},{message:e,_isEmailUnverified:t})}return n},[]),y=(0,s.useCallback)(async()=>{const{error:e}=await Mt.supabase.auth.signOut();return e||(!function(){const e=Jt();e&&e.removeItem(Yt)}(),r(null),o(!1)),{error:e}},[]),b=(0,s.useCallback)(async e=>{const{error:t}=await Mt.supabase.auth.resend({type:"signup",email:e});if(t){const{friendly:e}=Zt(t.message);return{error:{message:e}}}return{error:null}},[]),w=(0,s.useCallback)(async()=>{if(!a)return;const{data:{session:e}}=await Mt.supabase.auth.getSession();await x(a.id,null===e||void 0===e?void 0:e.access_token)},[a]),j=(0,s.useMemo)(()=>({user:a,hasProfile:i,profileChecked:l,loading:u,signUp:v,signIn:g,signOut:y,resendConfirmation:b,refreshProfile:w}),[a,i,l,u,v,g,y,b,w]);return(0,Xt.jsx)(Qt.Provider,{value:j,children:n})}function tn(){const e=(0,s.useContext)(Qt);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const nn={admin:{landing:"/admin/jobs",prefixes:["/admin"]},employer:{landing:"/employer",prefixes:["/employer"]},candidate:{landing:"/dashboard",prefixes:["/dashboard","/jobs","/documents","/applications","/account","/automation"]}};function an(e){var t;return(null===(t=nn[e])||void 0===t?void 0:t.landing)||"/dashboard"}const rn=(0,s.createContext)(null);function sn(e){let{children:t}=e;const{user:n,hasProfile:a}=tn(),r=be(),i=ke(),[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(null),p=(0,s.useRef)(null),h=(0,s.useCallback)(async()=>{if(n){if(!a&&$t(n.id))return l({allowed_workspaces:["employer"],effective_default:"employer",candidate_access:!1,employer_access:!0,is_admin:!1,synthetic:"emp_invite_bypass"}),void d(!1);if(a){d(!0),m(null);try{const e=await(0,zt.n)("/api/auth/me/access");l(e||null)}catch(e){m((null===e||void 0===e?void 0:e.message)||"Failed to load w
2orkspace access."),l(null)}finally{d(!1)}}else l(null)}else l(null)},[n,a]);(0,s.useEffect)(()=>{h()},[h]);const f=(0,s.useRef)(0);(0,s.useEffect)(()=>{if(!n||!a)return;const e=()=>{if("visible"!==document.visibilityState)return;const e=Date.now();e-f.current<3e4||(f.current=e,h())};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[n,a,h]);const x=(0,s.useMemo)(()=>(null===o||void 0===o?void 0:o.allowed_workspaces)||[],[o]),v=(null===o||void 0===o?void 0:o.effective_default)||null,g=(0,s.useMemo)(()=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if("string"!==typeof e)return t;for(const n of["admin","employer","candidate"])for(const t of nn[n].prefixes)if(e===t||e.startsWith("".concat(t,"/")))return n;return t}(r.pathname,v),[r.pathname,v]),y=(0,s.useCallback)(async e=>{if(e&&x.includes(e)&&(i(an(e)),o&&o.default_workspace!==e&&p.current!==e)){p.current=e;try{const t=await(0,zt.n)("/api/auth/me/default-workspace",{method:"POST",body:{default_workspace:e}});l(t||null)}catch(t){console.warn("[WorkspaceContext] default_workspace persist failed:",(null===t||void 0===t?void 0:t.message)||t)}}},[o,x,i]),b=(0,s.useMemo)(()=>({access:o,loading:c,error:u,allowedWorkspaces:x,effectiveDefault:v,currentWorkspace:g,reload:h,switchWorkspace:y}),[o,c,u,x,v,g,h,y]);return(0,Xt.jsx)(rn.Provider,{value:b,children:t})}function on(){const e=(0,s.useContext)(rn);if(!e)throw new Error("useWorkspace must be used within WorkspaceProvider");return e}function ln(e){let{children:t,requireProfile:n=!0,redirectIfProfile:a=!1}=e;const{user:r,hasProfile:s,profileChecked:i,loading:o}=tn(),l=be();if(o)return null;if(r&&!i)return null;if(!r)return(0,Xt.jsx)(We,{to:"/login",replace:!0});if(n&&!s){const e="/employer"===l.pathname||l.pathname.startsWith("/employer/"),t=$t(r.id);if(!e||!t)return(0,Xt.jsx)(We,{to:"/onboarding",replace:!0})}return a&&s?(0,Xt.jsx)(We,{to:"/post-login",replace:!0}):t}function cn(e){let{children:t}=e;const{user:n,hasProfile:a,profileChecked:r,loading:s}=tn(),[i]=Pt();if(s)return null;if(n&&!r)return null;if(n){const e=function(e){if(!e)return null;try{const t=decodeURIComponent(e);if(t.startsWith("/")&&!t.startsWith("//"))return t}catch(t){}return null}(i.get("returnTo"));return e?(0,Xt.jsx)(We,{to:e,replace:!0}):(0,Xt.jsx)(We,{to:a?"/post-login":"/onboarding",replace:!0})}return t}function dn(){const{access:e,loading:t,allowedWorkspaces:n,effectiveDefault:a}=on();return!e&&t?null:e?n.length?1===n.length?(0,Xt.jsx)(We,{to:an(n[0]),replace:!0}):a?(0,Xt.jsx)(We,{to:an(a),replace:!0}):(0,Xt.jsx)(We,{to:"/choose-workspace",replace:!0}):(0,Xt.jsx)(We,{to:"/no-access",replace:!0}):null}function un(e){let{workspace:t,children:n}=e;const{access:a,loading:r,allowedWorkspaces:s,effectiveDefault:i}=on(),o=be();return!a&&r?null:a?s.length?t&&!s.includes(t)?(0,Xt.jsx)(We,{to:an(i),replace:!0}):n:"/no-access"===o.pathname?n:(0,Xt.jsx)(We,{to:"/no-access",replace:!0}):null}const mn=Object.freeze({isOperator:!1,loading:!0,resolved:!1});function pn(){const[e,t]=(0,s.useState)(mn),n=(0,s.useCallback)(async()=>{try{const e=await(0,zt.n)("/api/auth/me/access");t({isOperator:Boolean(null===e||void 0===e?void 0:e.is_operator),loading:!1,resolved:!0})}catch(e){t({isOperator:!1,loading:!1,resolved:!0})}},[]);return(0,s.useEffect)(()=>{n()},[n]),(0,c.A)((0,c.A)({},e),{},{refresh:n})}const hn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),fn=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},xn=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim()};var vn={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const gn=["color","size","strokeWidth","absoluteStrokeWidth","className","children","iconNode"],yn=(0,s.forwardRef)((e,t)=>{let{color:n="currentColor",size:a=24,strokeWidth:r=2,absoluteStrokeWidth:i,className:o="",children:d,iconNode:u}=e,m=l(e,gn);return(0,s.createElement)("svg",(0,c.A)((0,c.A)((0,c.A)({ref:t},vn),{},{width:a,height:a,stroke:n,strokeWidth:i?24*Number(r)/Number(a):r,className:xn("lucide",o)},!d&&!(e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0})(m)&&{"aria-hidden":"true"}),m),[...u.map(e=>{let[t,n]=e;return(0,s.createElement)(t,n)}),...Array.isArray(d)?d:[d]])}),bn=["className"],wn=(e,t)=>{const n=(0,s.forwardRef)((n,a)=>{let{className:r}=n,i=l(n,bn);return(0,s.createElement)(yn,(0,c.A)({ref:a,iconNode:t,className:xn("lucide-".concat(hn(fn(e))),"lucide-".concat(e),r)},i))});return n.displayName=fn(e),n}
2,jn=wn("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]),kn=wn("briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]),Nn=wn("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),_n=wn("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),Dn=wn("inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]),Cn=wn("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),An=wn("circle-help",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),Sn=wn("coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]),En=wn("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),Fn=wn("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),Rn=wn("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),In=wn("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),Tn=wn("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),Pn=wn("building-2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]),On=wn("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]),Bn=wn("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
2y:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Ln=wn("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),Mn=wn("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),zn=wn("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),Un=wn("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]),Vn=wn("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),qn=wn("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Wn=wn("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),Hn=wn("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]),Gn=wn("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),Kn=wn("sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),Yn=wn("log-out",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);function Jn(e,t){if("function"===typeof e)return e(t);null!==e&&void 0!==e&&(e.current=t)}function $n(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return e=>{let n=!1;const a=t.map(t=>{const a=Jn(t,e);return n||"function"!=typeof a||(n=!0),a});if(n)return()=>{for(let e=0;e<a.length;e++){const n=a[e];"function"==typeof n?n():Jn(t[e],null)}}}}function Xn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return s.useCallback($n(...t),t)}const Qn=["children"],Zn=["children"];var ea=Symbol.for("react.lazy"),ta=i[" use ".trim().toString()];function na(e){return null!=e&&"object"===typeof e&&"$$typeof"in e&&e.$$typeof===ea&&"_payload"in e&&("object"===typeof(t=e._payload)&&null!==t&&"then"in t);var t}function aa(e){const t=sa(e),n=s.forwardRef((e,n)=>{let{children:a}=e,r=l(e,Qn);na(a)&&"function"===typeof ta&&(a=ta(a._payload));const i=s.Children.toArray(a),o=i.find(oa);if(o){const e=o.props.children,a=i.map(t=>t===o?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,a):null}))}return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:a}))});return n.displayName="".concat(e,".Slot"),n}var ra=aa("Slot");function sa(e){const t=s.forwardRef((e,t)=>{let{children:n}=e,a=l(e,Zn);if(na(n)&&"function"===typeof ta&&(n=ta(n._payload)),s.isValidElement(n)){const e=function(e){var t,n;let a=null===(t=Object.getOwnPropertyDescriptor(e.props,"ref"))||void 0===t?void 0:t.get,r=a&&"isReactWarning"in a&&a.isReactWarning;if(r)return e.ref;if(a=null===(n=Object.getOwnPropertyDescriptor(e,"ref"))||void 0===n?void 0:n.get,r=a&&"isReactWarning"in a&&a.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,t){const n=(0,c.A)({},t);for(const a in t){const r=e[a],s=t[a];/^on[A-Z]/.test(a)?r&&s?n[a]=function(){const e=s(...arguments);return r(...arguments),e}:r&&(n[a]=r):"style"===a?n[a]=(0,c.A)((0,c.A)({},r),s):"className"===a&&(n[a]=[r,s].filter(Boolean).join(" "))}return(0,c.A)((0,c.A)({},e),n)}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?$n(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName="".concat(e,".SlotClone"),t}var ia=Symbol("radix.slottable");function oa(e){return s.isValidElement(e)&&"function"===typeof e.type&&"__radixId"in e.type&&e.type.__radixId===ia}function la(e){var t,n,a="";if("string"==typeof e||"number"==typeof e)a+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(t=0;t<r;
2t++)e[t]&&(n=la(e[t]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function ca(){for(var e,t,n=0,a="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=la(e))&&(a&&(a+=" "),a+=t);return a}const da=["class","className"],ua=e=>"boolean"===typeof e?"".concat(e):0===e?"0":e,ma=ca,pa=(e,t)=>n=>{var a;if(null==(null===t||void 0===t?void 0:t.variants))return ma(e,null===n||void 0===n?void 0:n.class,null===n||void 0===n?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(e=>{const t=null===n||void 0===n?void 0:n[e],a=null===s||void 0===s?void 0:s[e];if(null===t)return null;const i=ua(t)||ua(a);return r[e][i]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,a]=t;return void 0===a||(e[n]=a),e},{}),d=null===t||void 0===t||null===(a=t.compoundVariants)||void 0===a?void 0:a.reduce((e,t)=>{let{class:n,className:a}=t,r=l(t,da);return Object.entries(r).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes((0,c.A)((0,c.A)({},s),o)[t]):(0,c.A)((0,c.A)({},s),o)[t]===n})?[...e,n,a]:e},[]);return ma(e,i,d,null===n||void 0===n?void 0:n.class,null===n||void 0===n?void 0:n.className)},ha=function(){return{nextPart:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Map,validators:arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,classGroupId:arguments.length>2?arguments[2]:void 0}},fa="-",xa=[],va=e=>{const t=ba(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return ya(e);const n=e.split(fa),a=""===n[0]&&n.length>1?1:0;return ga(n,a,t)},getConflictingClassGroupIds:(e,t)=>{if(t){const t=a[e],r=n[e];return t?r?((e,t)=>{const n=new Array(e.length+t.length);for(let a=0;a<e.length;a++)n[a]=e[a];for(let a=0;a<t.length;a++)n[e.length+a]=t[a];return n})(r,t):t:r||xa}return n[e]||xa}}},ga=(e,t,n)=>{if(0===e.length-t)return n.classGroupId;const a=e[t],r=n.nextPart.get(a);if(r){const n=ga(e,t+1,r);if(n)return n}const s=n.validators;if(null===s)return;const i=0===t?e.join(fa):e.slice(t).join(fa),o=s.length;for(let l=0;l<o;l++){const e=s[l];if(e.validator(i))return e.classGroupId}},ya=e=>-1===e.slice(1,-1).indexOf(":")?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),a=t.slice(0,n);return a?"arbitrary.."+a:void 0})(),ba=e=>{const{theme:t,classGroups:n}=e;return wa(n,t)},wa=(e,t)=>{const n=ha();for(const a in e){const r=e[a];ja(r,n,a,t)}return n},ja=(e,t,n,a)=>{const r=e.length;for(let s=0;s<r;s++){const r=e[s];ka(r,t,n,a)}},ka=(e,t,n,a)=>{"string"!==typeof e?"function"!==typeof e?Da(e,t,n,a):_a(e,t,n,a):Na(e,t,n)},Na=(e,t,n)=>{(""===e?t:Ca(t,e)).classGroupId=n},_a=(e,t,n,a)=>{Aa(e)?ja(e(a),t,n,a):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(n,e)))},Da=(e,t,n,a)=>{const r=Object.entries(e),s=r.length;for(let i=0;i<s;i++){const[e,s]=r[i];ja(s,Ca(t,e),n,a)}},Ca=(e,t)=>{let n=e;const a=t.split(fa),r=a.length;for(let s=0;s<r;s++){const e=a[s];let t=n.nextPart.get(e);t||(t=ha(),n.nextPart.set(e,t)),n=t}return n},Aa=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,Sa=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),a=Object.create(null);const r=(r,s)=>{n[r]=s,t++,t>e&&(t=0,a=n,n=Object.create(null))};return{get(e){let t=n[e];return void 0!==t?t:void 0!==(t=a[e])?(r(e,t),t):void 0},set(e,t){e in n?n[e]=t:r(e,t)}}},Ea=[],Fa=(e,t,n,a,r)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:a,isExternal:r}),Ra=e=>{const{prefix:t,experimentalParseClassName:n}=e;let a=e=>{const t=[];let n,a=0,r=0,s=0;const i=e.length;for(let d=0;d<i;d++){const i=e[d];if(0===a&&0===r){if(":"===i){t.push(e.slice(s,d)),s=d+1;continue}if("/"===i){n=d;continue}}"["===i?a++:"]"===i?a--:"("===i?r++:")"===i&&r--}const o=0===t.length?e:e.slice(s);let l=o,c=!1;o.endsWith("!")?(l=o.slice(0,-1),c=!0):o.startsWith("!")&&(l=o.slice(1),c=!0);return Fa(t,c,l,n&&n>s?n-s:void 0)};if(t){const e=t+":",n=a;a=t=>t.startsWith(e)?n(t.slice(e.length)):Fa(Ea,!1,t,void 0,!0)}if(n){const e=a;a=t=>n({className:t,parseClassName:e})}return a},Ia=e=>{const t=new Map;
vendor: 4,936 bytes, line 2
2return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{const n=[];let a=[];for(let r=0;r<e.length;r++){const s=e[r],i="["===s[0],o=t.has(s);i||o?(a.length>0&&(a.sort(),n.push(...a),a=[]),n.push(s)):a.push(s)}return a.length>0&&(a.sort(),n.push(...a)),n}},Ta=/\s+/,Pa=e=>{if("string"===typeof e)return e;let t,n="";for(let a=0;a<e.length;a++)e[a]&&(t=Pa(e[a]))&&(n&&(n+=" "),n+=t);return n},Oa=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];let r,s,i,o;const l=e=>{const t=s(e);if(t)return t;const n=((e,t)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:r,sortModifiers:s}=t,i=[],o=e.trim().split(Ta);let l="";for(let c=o.length-1;c>=0;c-=1){const e=o[c],{isExternal:t,modifiers:d,hasImportantModifier:u,baseClassName:m,maybePostfixModifierPosition:p}=n(e);if(t){l=e+(l.length>0?" "+l:l);continue}let h=!!p,f=a(h?m.substring(0,p):m);if(!f){if(!h){l=e+(l.length>0?" "+l:l);continue}if(f=a(m),!f){l=e+(l.length>0?" "+l:l);continue}h=!1}const x=0===d.length?"":1===d.length?d[0]:s(d).join(":"),v=u?x+"!":x,g=v+f;if(i.indexOf(g)>-1)continue;i.push(g);const y=r(f,h);for(let n=0;n<y.length;++n){const e=y[n];i.push(v+e)}l=e+(l.length>0?" "+l:l)}return l})(e,r);return i(e,n),n};return o=t=>{const a=n.reduce((e,t)=>t(e),e());return r=(e=>(0,c.A)({cache:Sa(e.cacheSize),parseClassName:Ra(e),sortModifiers:Ia(e)},va(e)))(a),s=r.cache.get,i=r.cache.set,o=l,l(t)},function(){return o(function(){let e,t,n=0,a="";for(;n<arguments.length;){var r;(e=(r=n++)<0||arguments.length<=r?void 0:arguments[r])&&(t=Pa(e))&&(a&&(a+=" "),a+=t)}return a}(...arguments))}},Ba=[],La=e=>{const t=t=>t[e]||Ba;return t.isThemeGetter=!0,t},Ma=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,za=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ua=/^\d+\/\d+$/,Va=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qa=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Wa=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ha=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ga=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ka=e=>Ua.test(e),Ya=e=>!!e&&!Number.isNaN(Number(e)),Ja=e=>!!e&&Number.isInteger(Number(e)),$a=e=>e.endsWith("%")&&Ya(e.slice(0,-1)),Xa=e=>Va.test(e),Qa=()=>!0,Za=e=>qa.test(e)&&!Wa.test(e),er=()=>!1,tr=e=>Ha.test(e),nr=e=>Ga.test(e),ar=e=>!sr(e)&&!ur(e),rr=e=>gr(e,jr,er),sr=e=>Ma.test(e),ir=e=>gr(e,kr,Za),or=e=>gr(e,Nr,Ya),lr=e=>gr(e,br,er),cr=e=>gr(e,wr,nr),dr=e=>gr(e,Dr,tr),ur=e=>za.test(e),mr=e=>yr(e,kr),pr=e=>yr(e,_r),hr=e=>yr(e,br),fr=e=>yr(e,jr),xr=e=>yr(e,wr),vr=e=>yr(e,Dr,!0),gr=(e,t,n)=>{const a=Ma.exec(e);return!!a&&(a[1]?t(a[1]):n(a[2]))},yr=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const a=za.exec(e);return!!a&&(a[1]?t(a[1]):n)},br=e=>"position"===e||"percentage"===e,wr=e=>"image"===e||"url"===e,jr=e=>"length"===e||"size"===e||"bg-size"===e,kr=e=>"length"===e,Nr=e=>"number"===e,_r=e=>"family-name"===e,Dr=e=>"shadow"===e,Cr=(Symbol.toStringTag,()=>{const e=La("color"),t=La("font"),n=La("text"),a=La("font-weight"),r=La("tracking"),s=La("leading"),i=La("breakpoint"),o=La("container"),l=La("spacing"),c=La("radius"),d=La("shadow"),u=La("inset-shadow"),m=La("text-shadow"),p=La("drop-shadow"),h=La("blur"),f=La("perspective"),x=La("aspect"),v=La("ease"),g=La("animate"),y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",ur,sr],b=()=>[ur,sr,l],w=()=>[Ka,"full","auto",...b()],j=()=>[Ja,"none","subgrid",ur,sr],k=()=>["auto",{span:["full",Ja,ur,sr]},Ja,ur,sr],N=()=>[Ja,"auto",ur,sr],_=()=>["auto","min","max","fr",ur,sr],D=()=>["auto",...b()],C=()=>[Ka,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...b()],A=()=>[e,ur,sr],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",hr,lr,{position:[ur,sr]}],E=()=>["auto","cover","contain",fr,rr,{size:[ur,sr]}],F=()=>[$a,mr,ir],R=()=>["","none","full",c,ur,sr],I=()=>["",Ya,mr,ir],T=()=>[Ya,$a,hr,lr],P=()=>["","none",h,ur,sr],O=()=>["none",Ya,ur,sr],B=()=>["none",Ya,ur,sr],L=()=>[Ya,ur,sr],M=()=>[Ka,"full",...b()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Xa],breakpoint:[Xa],color:[Qa],container:[Xa],"drop-shadow":[Xa],ease:["in","out","in-out"],font:[ar],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Xa],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Xa],shadow:[Xa],spacing:["px",Ya],text:[Xa],"text-shadow":[Xa],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ka,sr,ur,x]}
vendor: 5,347 bytes, line 2
2],container:["container"],columns:[{columns:[Ya,sr,ur,o]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:y()}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:w()}],"inset-x":[{"inset-x":w()}],"inset-y":[{"inset-y":w()}],start:[{start:w()}],end:[{end:w()}],top:[{top:w()}],right:[{right:w()}],bottom:[{bottom:w()}],left:[{left:w()}],visibility:["visible","invisible","collapse"],z:[{z:[Ja,"auto",ur,sr]}],basis:[{basis:[Ka,"full","auto",o,...b()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ya,Ka,"auto","initial","none",sr]}],grow:[{grow:["",Ya,ur,sr]}],shrink:[{shrink:["",Ya,ur,sr]}],order:[{order:[Ja,"first","last","none",ur,sr]}],"grid-cols":[{"grid-cols":j()}],"col-start-end":[{col:k()}],"col-start":[{"col-start":N()}],"col-end":[{"col-end":N()}],"grid-rows":[{"grid-rows":j()}],"row-start-end":[{row:k()}],"row-start":[{"row-start":N()}],"row-end":[{"row-end":N()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":_()}],"auto-rows":[{"auto-rows":_()}],gap:[{gap:b()}],"gap-x":[{"gap-x":b()}],"gap-y":[{"gap-y":b()}],"justify-content":[{justify:["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe","normal"]}],"justify-items":[{"justify-items":["start","end","center","stretch","center-safe","end-safe","normal"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"align-items":[{items:["start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"align-self":[{self:["auto","start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"place-items":[{"place-items":["start","end","center","stretch","center-safe","end-safe","baseline"]}],"place-self":[{"place-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],p:[{p:b()}],px:[{px:b()}],py:[{py:b()}],ps:[{ps:b()}],pe:[{pe:b()}],pt:[{pt:b()}],pr:[{pr:b()}],pb:[{pb:b()}],pl:[{pl:b()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":b()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":b()}],"space-y-reverse":["space-y-reverse"],size:[{size:C()}],w:[{w:[o,"screen",...C()]}],"min-w":[{"min-w":[o,"screen","none",...C()]}],"max-w":[{"max-w":[o,"screen","none","prose",{screen:[i]},...C()]}],h:[{h:["screen","lh",...C()]}],"min-h":[{"min-h":["screen","lh","none",...C()]}],"max-h":[{"max-h":["screen","lh",...C()]}],"font-size":[{text:["base",n,mr,ir]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,ur,or]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",$a,sr]}],"font-family":[{font:[pr,sr,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,ur,sr]}],"line-clamp":[{"line-clamp":[Ya,"none",ur,or]}],leading:[{leading:[s,...b()]}],"list-image":[{"list-image":["none",ur,sr]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ur,sr]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","
2wavy"]}],"text-decoration-thickness":[{decoration:[Ya,"from-font","auto",ur,ir]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[Ya,"auto",ur,sr]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:b()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ur,sr]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ur,sr]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:S()}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","space","round"]}]}],"bg-size":[{bg:E()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ja,ur,sr],radial:["",ur,sr],conic:[Ja,ur,sr]},xr,cr]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:F()}],"gradient-via-pos":[{via:F()}],"gradient-to-pos":[{to:F()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:R()}],"rounded-s":[{"rounded-s":R()}],"rounded-e":[{"rounded-e":R()}],"rounded-t":[{"rounded-t":R()}],"rounded-r":[{"rounded-r":R()}],"rounded-b":[{"rounded-b":R()}],"rounded-l":[{"rounded-l":R()}],"rounded-ss":[{"rounded-ss":R()}],"rounded-se":[{"rounded-se":R()}],"rounded-ee":[{"rounded-ee":R()}],"rounded-es":[{"rounded-es":R()}],"rounded-tl":[{"rounded-tl":R()}],"rounded-tr":[{"rounded-tr":R()}],"rounded-br":[{"rounded-br":R()}],"rounded-bl":[{"rounded-bl":R()}],"border-w":[{border:I()}],"border-w-x":[{"border-x":I()}],"border-w-y":[{"border-y":I()}],"border-w-s":[{"border-s":I()}],"border-w-e":[{"border-e":I()}],"border-w-t":[{"border-t":I()}],"border-w-r":[{"border-r":I()}],"border-w-b":[{"border-b":I()}],"border-w-l":[{"border-l":I()}
vendor: 6,691 bytes, line 2
2],"divide-x":[{"divide-x":I()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":I()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:["solid","dashed","dotted","double","hidden","none"]}],"divide-style":[{divide:["solid","dashed","dotted","double","hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[Ya,ur,sr]}],"outline-w":[{outline:["",Ya,mr,ir]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",d,vr,dr]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",u,vr,dr]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[Ya,ir]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":I()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",m,vr,dr]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[Ya,ur,sr]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ya]}],"mask-image-linear-from-pos":[{"mask-linear-from":T()}],"mask-image-linear-to-pos":[{"mask-linear-to":T()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":T()}],"mask-image-t-to-pos":[{"mask-t-to":T()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":T()}],"mask-image-r-to-pos":[{"mask-r-to":T()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":T()}],"mask-image-b-to-pos":[{"mask-b-to":T()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":T()}],"mask-image-l-to-pos":[{"mask-l-to":T()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":T()}],"mask-image-x-to-pos":[{"mask-x-to":T()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":T()}],"mask-image-y-to-pos":[{"mask-y-to":T()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[ur,sr]}],"mask-image-radial-from-pos":[{"mask-radial-from":T()}],"mask-image-radial-to-pos":[{"mask-radial-to":T()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"]}],"mask-image-conic-pos":[{"mask-conic":[Ya]}],"mask-image-conic-from-pos":[{"mask-conic-from":T()}],"mask-image-conic-to-pos":[{"mask-conic-to":T()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:S()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:E()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ur,sr]}],filter:[{filter:["","none",ur,sr]}],blur:[{blur:P()}],brightness:[{brightness:[Ya,ur,sr]}],contrast:[{contrast:[Ya,ur,sr]}],"drop-shadow":[{"drop-shadow":["","none",p,vr,dr]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",Ya,ur,sr]}],"hue-rotate":[{"hue-rotate":[Ya,ur,sr]}],invert:[{invert:["",Ya,ur,sr]}],saturate:[{saturate:[Ya,ur,sr]}],sepia:[{sepia:["",Ya,ur,sr]}],"backdrop-filter":[{"backdrop-filter":["","none",ur,sr]}],"backdrop-blur":[{"backdrop-blur":P()}],"backdrop-brightness":[{"backdrop-brightness":[Ya,ur,sr]}],"backdrop-contrast":[{"backdrop-contrast":[Ya,ur,sr]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ya,ur,sr]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ya,ur,sr]}],"backdrop-invert":[{"backdrop-invert":["",Ya,ur,sr]}],"backdrop-opacity":[{"backdrop-opacity":[Ya,ur,sr]}],"backdrop-saturate":[{"backdrop-saturate":[Ya,ur,sr]}],"backdrop-sepia":[{"backdrop-sepia":["",Ya,ur,sr]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":b()}],"border-spacing-x":[{"border-spacing-x":b()}],"border-spacing-y":[{"border-spacing-y":b()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ur,sr]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ya,"initial",ur,sr]}],ease:[{ease:["linear","initial",v,ur,sr]}],delay:[{delay:[Ya,ur,sr]}],animate:[{animate:["none",g,ur,sr]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[f,ur,sr]}],"perspective-origin":[{"perspective-origin":y()}],rotate:[{rotate:O()}],"rotate-x":[{"rotate-x":O()}],"rotate-y":[{"rotate-y":O()}],"rotate-z":[{"rotate-z":O()}],scale:[{scale:B()}],"scale-x":[{"scale-x":B()}],"scale-y":[{"scale-y":B()}],"scale-z":[{"scale-z":B()}],"scale-3d":["scale-3d"],skew:[{skew:L()}],"skew-x":[{"skew-x":L()}],"skew-y":[{"skew-y":L()}],transform:[{transform:[ur,sr,"","none","gpu","cpu"]}],"transform-origin":[{origin:y()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:M()}],"translate-x":[{"translate-x":M()}
vendor: 5,733 bytes, line 2
2],"translate-y":[{"translate-y":M()}],"translate-z":[{"translate-z":M()}],"translate-none":["translate-none"],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ur,sr]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":b()}],"scroll-mx":[{"scroll-mx":b()}],"scroll-my":[{"scroll-my":b()}],"scroll-ms":[{"scroll-ms":b()}],"scroll-me":[{"scroll-me":b()}],"scroll-mt":[{"scroll-mt":b()}],"scroll-mr":[{"scroll-mr":b()}],"scroll-mb":[{"scroll-mb":b()}],"scroll-ml":[{"scroll-ml":b()}],"scroll-p":[{"scroll-p":b()}],"scroll-px":[{"scroll-px":b()}],"scroll-py":[{"scroll-py":b()}],"scroll-ps":[{"scroll-ps":b()}],"scroll-pe":[{"scroll-pe":b()}],"scroll-pt":[{"scroll-pt":b()}],"scroll-pr":[{"scroll-pr":b()}],"scroll-pb":[{"scroll-pb":b()}],"scroll-pl":[{"scroll-pl":b()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ur,sr]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[Ya,mr,ir,or]}],stroke:[{stroke:["none",...A()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}}),Ar=Oa(Cr);function Sr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ar(ca(t))}const Er=["className","variant","size","asChild"],Fr=pa("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Rr=s.forwardRef((e,t)=>
2{let{className:n,variant:a,size:r,asChild:s=!1}=e,i=l(e,Er);const o=s?ra:"button";return(0,Xt.jsx)(o,(0,c.A)({className:Sr(Fr({variant:a,size:r,className:n})),ref:t},i))});Rr.displayName="Button";const Ir=["scope","children"];function Tr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const a=t[0];if(1===t.length)return a;const r=()=>{const e=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const n=e.reduce((e,n)=>{let{useScope:a,scopeName:r}=n;const s=a(t)["__scope".concat(r)];return(0,c.A)((0,c.A)({},e),s)},{});return s.useMemo(()=>({["__scope".concat(a.scopeName)]:n}),[n])}};return r.scopeName=a.scopeName,r}function Pr(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>function(){for(var e,n=arguments.length,a=new Array(n),r=0;r<n;r++)a[r]=arguments[r];return null===(e=t.current)||void 0===e?void 0:e.call(t,...a)},[])}var Or=null!==globalThis&&void 0!==globalThis&&globalThis.document?s.useLayoutEffect:()=>{},Br=n(950);const Lr=["asChild"];var Mr=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=aa("Primitive.".concat(t)),a=s.forwardRef((e,a)=>{const{asChild:r}=e,s=l(e,Lr),i=r?n:t;return"undefined"!==typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,Xt.jsx)(i,(0,c.A)((0,c.A)({},s),{},{ref:a}))});return a.displayName="Primitive.".concat(t),(0,c.A)((0,c.A)({},e),{},{[t]:a})},{});var zr=n(461);function Ur(){return()=>{}}const Vr=["__scopeAvatar"],qr=["__scopeAvatar","src","onLoadingStatusChange"],Wr=["__scopeAvatar","delayMs"];var Hr="Avatar",[Gr,Kr]=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[];const a=()=>{const t=n.map(e=>s.createContext(e));return function(n){const a=(null===n||void 0===n?void 0:n[e])||t;return s.useMemo(()=>({["__scope".concat(e)]:(0,c.A)((0,c.A)({},n),{},{[e]:a})}),[n,a])}};return a.scopeName=e,[function(t,a){const r=s.createContext(a);r.displayName=t+"Context";const i=n.length;n=[...n,a];const o=t=>{var n;const{scope:a,children:o}=t,c=l(t,Ir),d=(null===a||void 0===a||null===(n=a[e])||void 0===n?void 0:n[i])||r,u=s.useMemo(()=>c,Object.values(c));return(0,Xt.jsx)(d.Provider,{value:u,children:o})};return o.displayName=t+"Provider",[o,function(n,o){var l;const c=(null===o||void 0===o||null===(l=o[e])||void 0===l?void 0:l[i])||r,d=s.useContext(c);if(d)return d;if(void 0!==a)return a;throw new Error("`".concat(n,"` must be used within `").concat(t,"`"))}]},Tr(a,...t)]}(Hr),[Yr,Jr]=Gr(Hr),$r=s.forwardRef((e,t)=>{const{__scopeAvatar:n}=e,a=l(e,Vr),[r,i]=s.useState("idle");return(0,Xt.jsx)(Yr,{scope:n,imageLoadingStatus:r,onImageLoadingStatusChange:i,children:(0,Xt.jsx)(Mr.span,(0,c.A)((0,c.A)({},a),{},{ref:t}))})});$r.displayName=Hr;var Xr="AvatarImage",Qr=s.forwardRef((e,t)=>{const{__scopeAvatar:n,src:a,onLoadingStatusChange:r=()=>{}}=e,i=l(e,qr),o=Jr(Xr,n),d=function(e,t){let{referrerPolicy:n,crossOrigin:a}=t;const r=(0,zr.useSyncExternalStore)(Ur,()=>!0,()=>!1),i=s.useRef(null),o=r?(i.current||(i.current=new window.Image),i.current):null,[l,c]=s.useState(()=>ts(o,e));return Or(()=>{c(ts(o,e))},[o,e]),Or(()=>{const e=e=>()=>{c(e)};if(!o)return;const t=e("loaded"),r=e("error");return o.addEventListener("load",t),o.addEventListener("error",r),n&&(o.referrerPolicy=n),"string"===typeof a&&(o.crossOrigin=a),()=>{o.removeEventListener("load",t),o.removeEventListener("error",r)}},[o,a,n]),l}(a,i),u=Pr(e=>{r(e),o.onImageLoadingStatusChange(e)});return Or(()=>{"idle"!==d&&u(d)},[d,u]),"loaded"===d?(0,Xt.jsx)(Mr.img,(0,c.A)((0,c.A)({},i),{},{ref:t,src:a})):null});Qr.displayName=Xr;var Zr="AvatarFallback",es=s.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:a}=e,r=l(e,Wr),i=Jr(Zr,n),[o,d]=s.useState(void 0===a);return s.useEffect(()=>{if(void 0!==a){const e=window.setTimeout(()=>d(!0),a);return()=>window.clearTimeout(e)}},[a]),o&&"loaded"!==i.imageLoadingStatus?(0,Xt.jsx)(Mr.span,(0,c.A)((0,c.A)({},r),{},{ref:t})):null});function ts(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}es.displayName=Zr;var ns=$r,as=Qr,rs=es;const ss=["className"],is=["className"],os=["className"],ls=s.forwardRef((e,t)=>
2{let{className:n}=e,a=l(e,ss);return(0,Xt.jsx)(ns,(0,c.A)({ref:t,className:Sr("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",n)},a))});ls.displayName=ns.displayName;s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,is);return(0,Xt.jsx)(as,(0,c.A)({ref:t,className:Sr("aspect-square h-full w-full",n)},a))}).displayName=as.displayName;const cs=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,os);return(0,Xt.jsx)(rs,(0,c.A)({ref:t,className:Sr("flex h-full w-full items-center justify-center rounded-full bg-muted",n)},a))});cs.displayName=rs.displayName;const ds=["asChild"];var us=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=aa("Primitive.".concat(t)),a=s.forwardRef((e,a)=>{const{asChild:r}=e,s=l(e,ds),i=r?n:t;return"undefined"!==typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,Xt.jsx)(i,(0,c.A)((0,c.A)({},s),{},{ref:a}))});return a.displayName="Primitive.".concat(t),(0,c.A)((0,c.A)({},e),{},{[t]:a})},{});const ms=["decorative","orientation"];var ps="horizontal",hs=["horizontal","vertical"],fs=s.forwardRef((e,t)=>{const{decorative:n,orientation:a=ps}=e,r=l(e,ms),s=function(e){return hs.includes(e)}(a)?a:ps,i=n?{role:"none"}:{"aria-orientation":"vertical"===s?s:void 0,role:"separator"};return(0,Xt.jsx)(us.div,(0,c.A)((0,c.A)((0,c.A)({"data-orientation":s},i),r),{},{ref:t}))});fs.displayName="Separator";var xs=fs;const vs=["className","orientation","decorative"],gs=s.forwardRef((e,t)=>{let{className:n,orientation:a="horizontal",decorative:r=!0}=e,s=l(e,vs);return(0,Xt.jsx)(xs,(0,c.A)({ref:t,decorative:r,orientation:a,className:Sr("shrink-0 bg-border","horizontal"===a?"h-[1px] w-full":"h-full w-[1px]",n)},s))});gs.displayName=xs.displayName;"undefined"===typeof window||!window.document||window.document.createElement;function ys(e,t){let{checkForDefaultPrevented:n=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(a){if(null===e||void 0===e||e(a),!1===n||!a.defaultPrevented)return null===t||void 0===t?void 0:t(a)}}const bs=["children"],ws=["scope","children"];function js(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[];const a=()=>{const t=n.map(e=>s.createContext(e));return function(n){const a=(null===n||void 0===n?void 0:n[e])||t;return s.useMemo(()=>({["__scope".concat(e)]:(0,c.A)((0,c.A)({},n),{},{[e]:a})}),[n,a])}};return a.scopeName=e,[function(t,a){const r=s.createContext(a),i=n.length;n=[...n,a];const o=t=>{var n;const{scope:a,children:o}=t,c=l(t,ws),d=(null===a||void 0===a||null===(n=a[e])||void 0===n?void 0:n[i])||r,u=s.useMemo(()=>c,Object.values(c));return(0,Xt.jsx)(d.Provider,{value:u,children:o})};return o.displayName=t+"Provider",[o,function(n,o){var l;const c=(null===o||void 0===o||null===(l=o[e])||void 0===l?void 0:l[i])||r,d=s.useContext(c);if(d)return d;if(void 0!==a)return a;throw new Error("`".concat(n,"` must be used within `").concat(t,"`"))}]},ks(a,...t)]}function ks(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const a=t[0];if(1===t.length)return a;const r=()=>{const e=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const n=e.reduce((e,n)=>{let{useScope:a,scopeName:r}=n;const s=a(t)["__scope".concat(r)];return(0,c.A)((0,c.A)({},e),s)},{});return s.useMemo(()=>({["__scope".concat(a.scopeName)]:n}),[n])}};return r.scopeName=a.scopeName,r}var Ns=i[" useInsertionEffect ".trim().toString()]||Or;function _s(e){let{prop:t,defaultProp:n,onChange:a=()=>{},caller:r}=e;const[i,o,l]=function(e){let{defaultProp:t,onChange:n}=e;const[a,r]=s.useState(t),i=s.useRef(a),o=s.useRef(n);return Ns(()=>{o.current=n},[n]),s.useEffect(()=>{var e;i.current!==a&&(null===(e=o.current)||void 0===e||e.call(o,a),i.current=a)},[a,i]),[a,r,o]}({defaultProp:n,onChange:a}),c=void 0!==t,d=c?t:i;{const e=s.useRef(void 0!==t);s.useEffect(()=>{const t=e.current;if(t!==c){const e=t?"controlled":"uncontrolled",n=c?"controlled":"uncontrolled";console.warn("".concat(r," is changing from ").concat(e," to ").concat(n,". Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component."))}e.current=c},[c,r])}const u=s.useCallback(e=>{if(c){const a=function(e){return"function"===typeof e}(e)?e(t):e;var n;if(a!==t)null===(n=l.current)||void 0===n||n.call(l,a)}else o(e)},[c,t,o,l]);return[d,u]}Symbol("RADIX:SYNC_STATE");const Ds=["children"],Cs=["children"];
2function As(e){const t=Ss(e),n=s.forwardRef((e,n)=>{const{children:a}=e,r=l(e,Ds),i=s.Children.toArray(a),o=i.find(Fs);if(o){const e=o.props.children,a=i.map(t=>t===o?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,a):null}))}return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:a}))});return n.displayName="".concat(e,".Slot"),n}function Ss(e){const t=s.forwardRef((e,t)=>{const{children:n}=e,a=l(e,Cs);if(s.isValidElement(n)){const e=function(e){var t,n;let a=null===(t=Object.getOwnPropertyDescriptor(e.props,"ref"))||void 0===t?void 0:t.get,r=a&&"isReactWarning"in a&&a.isReactWarning;if(r)return e.ref;if(a=null===(n=Object.getOwnPropertyDescriptor(e,"ref"))||void 0===n?void 0:n.get,r=a&&"isReactWarning"in a&&a.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,t){const n=(0,c.A)({},t);for(const a in t){const r=e[a],s=t[a];/^on[A-Z]/.test(a)?r&&s?n[a]=function(){const e=s(...arguments);return r(...arguments),e}:r&&(n[a]=r):"style"===a?n[a]=(0,c.A)((0,c.A)({},r),s):"className"===a&&(n[a]=[r,s].filter(Boolean).join(" "))}return(0,c.A)((0,c.A)({},e),n)}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?$n(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName="".concat(e,".SlotClone"),t}var Es=Symbol("radix.slottable");function Fs(e){return s.isValidElement(e)&&"function"===typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Es}const Rs=["asChild"];var Is=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=As("Primitive.".concat(t)),a=s.forwardRef((e,a)=>{const{asChild:r}=e,s=l(e,Rs),i=r?n:t;return"undefined"!==typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,Xt.jsx)(i,(0,c.A)((0,c.A)({},s),{},{ref:a}))});return a.displayName="Primitive.".concat(t),(0,c.A)((0,c.A)({},e),{},{[t]:a})},{});function Ts(e,t){e&&Br.flushSync(()=>e.dispatchEvent(t))}function Ps(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function Os(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function Bs(e,t){return e.get(Os(e,t))}function Ls(e,t,n){return e.set(Os(e,t),n),n}const Ms=["children"],zs=["children"];function Us(e){const t=Vs(e),n=s.forwardRef((e,n)=>{const{children:a}=e,r=l(e,Ms),i=s.Children.toArray(a),o=i.find(Hs);if(o){const e=o.props.children,a=i.map(t=>t===o?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,a):null}))}return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:a}))});return n.displayName="".concat(e,".Slot"),n}function Vs(e){const t=s.forwardRef((e,t)=>{const{children:n}=e,a=l(e,zs);if(s.isValidElement(n)){const e=function(e){var t,n;let a=null===(t=Object.getOwnPropertyDescriptor(e.props,"ref"))||void 0===t?void 0:t.get,r=a&&"isReactWarning"in a&&a.isReactWarning;if(r)return e.ref;if(a=null===(n=Object.getOwnPropertyDescriptor(e,"ref"))||void 0===n?void 0:n.get,r=a&&"isReactWarning"in a&&a.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,t){const n=(0,c.A)({},t);for(const a in t){const r=e[a],s=t[a];/^on[A-Z]/.test(a)?r&&s?n[a]=function(){const e=s(...arguments);return r(...arguments),e}:r&&(n[a]=r):"style"===a?n[a]=(0,c.A)((0,c.A)({},r),s):"className"===a&&(n[a]=[r,s].filter(Boolean).join(" "))}return(0,c.A)((0,c.A)({},e),n)}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?$n(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName="".concat(e,".SlotClone"),t}var qs=Symbol("radix.slottable");var Ws;function Hs(e){return s.isValidElement(e)&&"function"===typeof e.type&&"__radixId"in e.type&&e.type.__radixId===qs}const Gs=["scope","children"];function Ks(e){const t=e+"CollectionProvider",[n,a]=js(t),[r,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{const{scope:t,children:n}=e,a=s.useRef(null),i=s.useRef(new Map).current;return(0,Xt.jsx)(r,{scope:t,itemMap:i,collectionRef:a,children:n})};o.displayName=t;const d=e+"CollectionSlot",u=Us(d),m=s.forwardRef((e,t)=>
2{const{scope:n,children:a}=e,r=Xn(t,i(d,n).collectionRef);return(0,Xt.jsx)(u,{ref:r,children:a})});m.displayName=d;const p=e+"CollectionItemSlot",h="data-radix-collection-item",f=Us(p),x=s.forwardRef((e,t)=>{const{scope:n,children:a}=e,r=l(e,Gs),o=s.useRef(null),d=Xn(t,o),u=i(p,n);return s.useEffect(()=>(u.itemMap.set(o,(0,c.A)({ref:o},r)),()=>{u.itemMap.delete(o)})),(0,Xt.jsx)(f,(0,c.A)((0,c.A)({},{[h]:""}),{},{ref:d,children:a}))});return x.displayName=p,[{Provider:o,Slot:m,ItemSlot:x},function(t){const n=i(e+"CollectionConsumer",t),a=s.useCallback(()=>{const e=n.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll("[".concat(h,"]"))),a=Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current));return a},[n.collectionRef,n.itemMap]);return a},a]}var Ys=new WeakMap;Ws=new WeakMap,Map;function Js(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=function(e,t){const n=e.length,a=$s(t),r=a>=0?a:n+a;return r<0||r>=n?-1:r}(e,t);return-1===n?void 0:e[n]}function $s(e){return e!==e||0===e?0:Math.trunc(e)}var Xs=s.createContext(void 0);function Qs(e){const t=s.useContext(Xs);return e||t||"ltr"}const Zs=["disableOutsidePointerEvents","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss"];var ei,ti="dismissableLayer.update",ni="dismissableLayer.pointerDownOutside",ai="dismissableLayer.focusOutside",ri=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),si=s.forwardRef((e,t)=>{var n;const{disableOutsidePointerEvents:a=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:d,onDismiss:u}=e,m=l(e,Zs),p=s.useContext(ri),[h,f]=s.useState(null),x=null!==(n=null===h||void 0===h?void 0:h.ownerDocument)&&void 0!==n?n:null===globalThis||void 0===globalThis?void 0:globalThis.document,[,v]=s.useState({}),g=Xn(t,e=>f(e)),y=Array.from(p.layers),[b]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),w=y.indexOf(b),j=h?y.indexOf(h):-1,k=p.layersWithOutsidePointerEventsDisabled.size>0,N=j>=w,_=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null===globalThis||void 0===globalThis?void 0:globalThis.document;const n=Pr(e),a=s.useRef(!1),r=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!a.current){let a=function(){li(ni,n,s,{discrete:!0})};const s={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",r.current),r.current=a,t.addEventListener("click",r.current,{once:!0})):a()}else t.removeEventListener("click",r.current);a.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",e),t.removeEventListener("click",r.current)}},[t,n]),{onPointerDownCapture:()=>a.current=!0}}(e=>{const t=e.target,n=[...p.branches].some(e=>e.contains(t));N&&!n&&(null===i||void 0===i||i(e),null===d||void 0===d||d(e),e.defaultPrevented||null===u||void 0===u||u())},x),D=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null===globalThis||void 0===globalThis?void 0:globalThis.document;const n=Pr(e),a=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!a.current){li(ai,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>a.current=!0,onBlurCapture:()=>a.current=!1}}(e=>{const t=e.target;[...p.branches].some(e=>e.contains(t))||(null===o||void 0===o||o(e),null===d||void 0===d||d(e),e.defaultPrevented||null===u||void 0===u||u())},x);return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null===globalThis||void 0===globalThis?void 0:globalThis.document;const n=Pr(e);s.useEffect(()=>{const e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}(e=>{j===p.layers.size-1&&(null===r||void 0===r||r(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))},x),s.useEffect(()=>{if(h)return a&&(0===p.layersWithOutsidePointerEventsDisabled.size&&(ei=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(h)),p.layers.add(h),oi(),()=>{a&&1===p.layersWithOutsidePointerEventsDisabled.size&&(x.body.style.pointerEvents=ei)}},[h,x,a,p]),s.useEffect(()=>()=>{h&&(p.layers.delete(h),p.layersWithOutsidePointerEventsDisabled.delete(h),oi())},[h,p]),s.useEffect(()=>{const e=()=>v({});return document.addEventListener(ti,e),()=>document.removeEventListener(ti,e)},[]),(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({},m),{},{ref:g,style:(0,c.A)({pointerEvents:k?N?"auto":"none":void 0},e.style),onFocusCapture:ys(e.onFocusCapture,D.onFocusCapture),onBlurCapture:ys(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:ys(e.onPointerDownCapture,_.onPointerDownCapture)}))});si.displayName="DismissableLayer";var ii=s.forwardRef((e,t)=>
2{const n=s.useContext(ri),a=s.useRef(null),r=Xn(t,a);return s.useEffect(()=>{const e=a.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({},e),{},{ref:r}))});function oi(){const e=new CustomEvent(ti);document.dispatchEvent(e)}function li(e,t,n,a){let{discrete:r}=a;const s=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?Ts(s,i):s.dispatchEvent(i)}ii.displayName="DismissableLayerBranch";var ci=0;function di(){s.useEffect(()=>{var e,t;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",null!==(e=n[0])&&void 0!==e?e:ui()),document.body.insertAdjacentElement("beforeend",null!==(t=n[1])&&void 0!==t?t:ui()),ci++,()=>{1===ci&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),ci--}},[])}function ui(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}const mi=["loop","trapped","onMountAutoFocus","onUnmountAutoFocus"];var pi="focusScope.autoFocusOnMount",hi="focusScope.autoFocusOnUnmount",fi={bubbles:!1,cancelable:!0},xi=s.forwardRef((e,t)=>{const{loop:n=!1,trapped:a=!1,onMountAutoFocus:r,onUnmountAutoFocus:i}=e,o=l(e,mi),[d,u]=s.useState(null),m=Pr(r),p=Pr(i),h=s.useRef(null),f=Xn(t,e=>u(e)),x=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(a){let e=function(e){if(x.paused||!d)return;const t=e.target;d.contains(t)?h.current=t:bi(h.current,{select:!0})},t=function(e){if(x.paused||!d)return;const t=e.relatedTarget;null!==t&&(d.contains(t)||bi(h.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&bi(d)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const a=new MutationObserver(n);return d&&a.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),a.disconnect()}}},[a,d,x.paused]),s.useEffect(()=>{if(d){wi.add(x);const t=document.activeElement;if(!d.contains(t)){const n=new CustomEvent(pi,fi);d.addEventListener(pi,m),d.dispatchEvent(n),n.defaultPrevented||(!function(e){let{select:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=document.activeElement;for(const a of e)if(bi(a,{select:t}),document.activeElement!==n)return}((e=vi(d),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&bi(d))}return()=>{d.removeEventListener(pi,m),setTimeout(()=>{const e=new CustomEvent(hi,fi);d.addEventListener(hi,p),d.dispatchEvent(e),e.defaultPrevented||bi(null!==t&&void 0!==t?t:document.body,{select:!0}),d.removeEventListener(hi,p),wi.remove(x)},0)}}var e},[d,m,p,x]);const v=s.useCallback(e=>{if(!n&&!a)return;if(x.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){const t=e.currentTarget,[a,s]=function(e){const t=vi(e),n=gi(t,e),a=gi(t.reverse(),e);return[n,a]}(t);a&&s?e.shiftKey||r!==s?e.shiftKey&&r===a&&(e.preventDefault(),n&&bi(s,{select:!0})):(e.preventDefault(),n&&bi(a,{select:!0})):r===t&&e.preventDefault()}},[n,a,x.paused]);return(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({tabIndex:-1},o),{},{ref:f,onKeyDown:v}))});function vi(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function gi(e,t){for(const n of e)if(!yi(n,{upTo:t}))return n}function yi(e,t){let{upTo:n}=t;if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==n&&e===n)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function bi(e){let{select:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}xi.displayName="FocusScope";var wi=function(){let e=[];return{add(t){const n=e[0];t!==n&&(null===n||void 0===n||n.pause()),e=ji(e,t),e.unshift(t)},remove(t){var n;e=ji(e,t),null===(n=e[0])||void 0===n||n.resume()}}}();function ji(e,t){const n=[...e],a=n.indexOf(t);return-1!==a&&n.splice(a,1),n}var ki=i[" useId ".trim().toString()]||(()=>{}),Ni=0;function _i(e){const[t,n]=s.useState(ki());return Or(()=>{e||n(e=>null!==e&&void 0!==e?e:String(Ni++))},[e]),e||(t?"radix-".concat(t):"")}const Di=["top","right","bottom","left"],Ci=Math.min,Ai=Math.max,Si=Math.round,Ei=Math.floor,Fi=e=>({x:e,y:e}
2),Ri={left:"right",right:"left",bottom:"top",top:"bottom"},Ii={start:"end",end:"start"};function Ti(e,t,n){return Ai(e,Ci(t,n))}function Pi(e,t){return"function"===typeof e?e(t):e}function Oi(e){return e.split("-")[0]}function Bi(e){return e.split("-")[1]}function Li(e){return"x"===e?"y":"x"}function Mi(e){return"y"===e?"height":"width"}const zi=new Set(["top","bottom"]);function Ui(e){return zi.has(Oi(e))?"y":"x"}function Vi(e){return Li(Ui(e))}function qi(e){return e.replace(/start|end/g,e=>Ii[e])}const Wi=["left","right"],Hi=["right","left"],Gi=["top","bottom"],Ki=["bottom","top"];function Yi(e,t,n,a){const r=Bi(e);let s=function(e,t,n){switch(e){case"top":case"bottom":return n?t?Hi:Wi:t?Wi:Hi;case"left":case"right":return t?Gi:Ki;default:return[]}}(Oi(e),"start"===n,a);return r&&(s=s.map(e=>e+"-"+r),t&&(s=s.concat(s.map(qi)))),s}function Ji(e){return e.replace(/left|right|bottom|top/g,e=>Ri[e])}function $i(e){return"number"!==typeof e?function(e){return(0,c.A)({top:0,right:0,bottom:0,left:0},e)}(e):{top:e,right:e,bottom:e,left:e}}function Xi(e){const{x:t,y:n,width:a,height:r}=e;return{width:a,height:r,top:n,left:t,right:t+a,bottom:n+r,x:t,y:n}}const Qi=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],Zi=["strategy"],eo=["mainAxis","crossAxis","limiter"],to=["apply"];function no(e,t,n){let{reference:a,floating:r}=e;const s=Ui(t),i=Vi(t),o=Mi(i),l=Oi(t),c="y"===s,d=a.x+a.width/2-r.width/2,u=a.y+a.height/2-r.height/2,m=a[o]/2-r[o]/2;let p;switch(l){case"top":p={x:d,y:a.y-r.height};break;case"bottom":p={x:d,y:a.y+a.height};break;case"right":p={x:a.x+a.width,y:u};break;case"left":p={x:a.x-r.width,y:u};break;default:p={x:a.x,y:a.y}}switch(Bi(t)){case"start":p[i]-=m*(n&&c?-1:1);break;case"end":p[i]+=m*(n&&c?-1:1)}return p}async function ao(e,t){var n;void 0===t&&(t={});const{x:a,y:r,platform:s,rects:i,elements:o,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:m=!1,padding:p=0}=Pi(t,e),h=$i(p),f=o[m?"floating"===u?"reference":"floating":u],x=Xi(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(f)))||n?f:f.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(o.floating)),boundary:c,rootBoundary:d,strategy:l})),v="floating"===u?{x:a,y:r,width:i.floating.width,height:i.floating.height}:i.reference,g=await(null==s.getOffsetParent?void 0:s.getOffsetParent(o.floating)),y=await(null==s.isElement?void 0:s.isElement(g))&&await(null==s.getScale?void 0:s.getScale(g))||{x:1,y:1},b=Xi(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:v,offsetParent:g,strategy:l}):v);return{top:(x.top-b.top+h.top)/y.y,bottom:(b.bottom-x.bottom+h.bottom)/y.y,left:(x.left-b.left+h.left)/y.x,right:(b.right-x.right+h.right)/y.x}}function ro(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function so(e){return Di.some(t=>e[t]>=0)}const io=new Set(["left","top"]);function oo(){return"undefined"!==typeof window}function lo(e){return mo(e)?(e.nodeName||"").toLowerCase():"#document"}function co(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function uo(e){var t;return null==(t=(mo(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function mo(e){return!!oo()&&(e instanceof Node||e instanceof co(e).Node)}function po(e){return!!oo()&&(e instanceof Element||e instanceof co(e).Element)}function ho(e){return!!oo()&&(e instanceof HTMLElement||e instanceof co(e).HTMLElement)}function fo(e){return!(!oo()||"undefined"===typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof co(e).ShadowRoot)}const xo=new Set(["inline","contents"]);function vo(e){const{overflow:t,overflowX:n,overflowY:a,display:r}=So(e);return/auto|scroll|overlay|hidden|clip/.test(t+a+n)&&!xo.has(r)}const go=new Set(["table","td","th"]);function yo(e){return go.has(lo(e))}const bo=[":popover-open",":modal"];function wo(e){return bo.some(t=>{try{return e.matches(t)}catch(n){return!1}})}const jo=["transform","translate","scale","rotate","perspective"],k
vendor: 7,145 bytes, line 2
2o=["transform","translate","scale","rotate","perspective","filter"],No=["paint","layout","strict","content"];function _o(e){const t=Do(),n=po(e)?So(e):e;return jo.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||ko.some(e=>(n.willChange||"").includes(e))||No.some(e=>(n.contain||"").includes(e))}function Do(){return!("undefined"===typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Co=new Set(["html","body","#document"]);function Ao(e){return Co.has(lo(e))}function So(e){return co(e).getComputedStyle(e)}function Eo(e){return po(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fo(e){if("html"===lo(e))return e;const t=e.assignedSlot||e.parentNode||fo(e)&&e.host||uo(e);return fo(t)?t.host:t}function Ro(e){const t=Fo(e);return Ao(t)?e.ownerDocument?e.ownerDocument.body:e.body:ho(t)&&vo(t)?t:Ro(t)}function Io(e,t,n){var a;void 0===t&&(t=[]),void 0===n&&(n=!0);const r=Ro(e),s=r===(null==(a=e.ownerDocument)?void 0:a.body),i=co(r);if(s){const e=To(i);return t.concat(i,i.visualViewport||[],vo(r)?r:[],e&&n?Io(e):[])}return t.concat(r,Io(r,[],n))}function To(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Po(e){const t=So(e);let n=parseFloat(t.width)||0,a=parseFloat(t.height)||0;const r=ho(e),s=r?e.offsetWidth:n,i=r?e.offsetHeight:a,o=Si(n)!==s||Si(a)!==i;return o&&(n=s,a=i),{width:n,height:a,$:o}}function Oo(e){return po(e)?e:e.contextElement}function Bo(e){const t=Oo(e);if(!ho(t))return Fi(1);const n=t.getBoundingClientRect(),{width:a,height:r,$:s}=Po(t);let i=(s?Si(n.width):n.width)/a,o=(s?Si(n.height):n.height)/r;return i&&Number.isFinite(i)||(i=1),o&&Number.isFinite(o)||(o=1),{x:i,y:o}}const Lo=Fi(0);function Mo(e){const t=co(e);return Do()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Lo}function zo(e,t,n,a){void 0===t&&(t=!1),void 0===n&&(n=!1);const r=e.getBoundingClientRect(),s=Oo(e);let i=Fi(1);t&&(a?po(a)&&(i=Bo(a)):i=Bo(e));const o=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==co(e))&&t}(s,n,a)?Mo(s):Fi(0);let l=(r.left+o.x)/i.x,c=(r.top+o.y)/i.y,d=r.width/i.x,u=r.height/i.y;if(s){const e=co(s),t=a&&po(a)?co(a):a;let n=e,r=To(n);for(;r&&a&&t!==n;){const e=Bo(r),t=r.getBoundingClientRect(),a=So(r),s=t.left+(r.clientLeft+parseFloat(a.paddingLeft))*e.x,i=t.top+(r.clientTop+parseFloat(a.paddingTop))*e.y;l*=e.x,c*=e.y,d*=e.x,u*=e.y,l+=s,c+=i,n=co(r),r=To(n)}}return Xi({width:d,height:u,x:l,y:c})}function Uo(e,t){const n=Eo(e).scrollLeft;return t?t.left+n:zo(uo(e)).left+n}function Vo(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Uo(e,n),y:n.top+t.scrollTop}}const qo=new Set(["absolute","fixed"]);function Wo(e,t,n){let a;if("viewport"===t)a=function(e,t){const n=co(e),a=uo(e),r=n.visualViewport;let s=a.clientWidth,i=a.clientHeight,o=0,l=0;if(r){s=r.width,i=r.height;const e=Do();(!e||e&&"fixed"===t)&&(o=r.offsetLeft,l=r.offsetTop)}const c=Uo(a);if(c<=0){const e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r);i<=25&&(s-=i)}else c<=25&&(s+=c);return{width:s,height:i,x:o,y:l}}(e,n);else if("document"===t)a=function(e){const t=uo(e),n=Eo(e),a=e.ownerDocument.body,r=Ai(t.scrollWidth,t.clientWidth,a.scrollWidth,a.clientWidth),s=Ai(t.scrollHeight,t.clientHeight,a.scrollHeight,a.clientHeight);let i=-n.scrollLeft+Uo(e);const o=-n.scrollTop;return"rtl"===So(a).direction&&(i+=Ai(t.clientWidth,a.clientWidth)-r),{width:r,height:s,x:i,y:o}}(uo(e));else if(po(t))a=function(e,t){const n=zo(e,!0,"fixed"===t),a=n.top+e.clientTop,r=n.left+e.clientLeft,s=ho(e)?Bo(e):Fi(1);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:r*s.x,y:a*s.y}}(t,n);else{const n=Mo(e);a={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Xi(a)}function Ho(e,t){const n=Fo(e);return!(n===t||!po(n)||Ao(n))&&("fixed"===So(n).position||Ho(n,t))}function Go(e,t,n){const a=ho(t),r=uo(t),s="fixed"===n,i=zo(e,!0,s,t);let o={scrollLeft:0,scrollTop:0};const l=Fi(0);function c(){l.x=Uo(r)}if(a||!a&&!s)if(("body"!==lo(t)||vo(r))&&(o=Eo(t)),a){const e=zo(t,!0,s,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else r&&c();s&&!a&&r&&c();const d=!r||a||s?Fi(0):Vo(r,o);return{x:i.left+o.scrollLeft-l.x-d.x,y:i.top+o.scrollTop-l.y-d.y,width:i.width,height:i.height}}function Ko(e){return"static"===So(e).position}function Yo(e,t){if(!ho(e)||"fixed"===So(e).position)return null;if(t)return t(e);let n=e.offsetParent;return uo(e)===n&&(n=n.ownerDocument.body),n}function Jo(e,t){const n=co(e);if(wo(e))return n;if(!ho(e)){let t=Fo(e);for(;t&&!Ao(t);){if(po(t)&&!Ko(t))return t;t=Fo(t)}return n}let a=Yo(e,t);for(;a&&yo(a)&&Ko(a);)a=Yo(a,t);return a&&Ao(a)&&Ko(a)&&!_o(a)?n:a||function(e){let t=Fo(e);for(;ho(t)&&!Ao(t);){if(_o(t))return t;if(wo(t))return null;t=Fo(t)}return null}(e)||n}const $o={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:a,strategy:r}=e;const s="fixed"===r,i=uo(a),o=!!t&&wo(t.floating);if(a===i||o&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Fi(1);const d=Fi(0),u=ho(a);if((u||!u&&!s)&&(("body"!==lo(a)||vo(i))&&(l=Eo(a)),ho(a))){const e=zo(a);c=Bo(a),d.x=e.x+a.clientLeft,d.y=e.y+a.clientTop}const m=!i||u||s?Fi(0):Vo(i,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}},getDocumentElement:uo,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:a,strategy:r}=e;const s=[..."clippingAncestors"===n?wo(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let a=Io(e,[],!1).filter(e=>po(e)&&"body"!==lo(e)),r=null;const s="fixed"===So(e).position;let i=s?Fo(e):e;for(;po(i)&&!Ao(i);){const t=So(i),n=_o(i);n||"fixed"!==t.position||(r=null),(s?!n&&!r:!n&&"static"===t.position&&r&&qo.has(r.position)||vo(i)&&!n&&Ho(e,i))?a=a.filter(e=>e!==i):r=t,i=Fo(i)}return t.set(e,a),a}(t,this._c):[].concat(n),a],i=s[0],o=s.reduce((e,n)=>{const a=Wo(t,n,r);return e.top=Ai(a.top,e.top),e.right=Ci(a.right,e.right),e.bottom=Ci(a.bottom,e.bottom),e.left=Ai(a.left,e.left),e},Wo(t,i,r));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:Jo,getElementRects:async function(e){const t=this.getOffsetParent||Jo,n=this.getDimensions,a=await n(e.floating);return{reference:Go(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Po(e);return{width:t,height:n}},getScale:Bo,isElement:po,isRTL:function(e){return"rtl"===So(e).direction}};function Xo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Qo(e,t,n,a){void 0===a&&(a={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:i="function"===typeof ResizeObserver,layoutShift:o="function"===typeof IntersectionObserver,animationFrame:l=!1}=a,d=Oo(e),u=r||s?[...d?Io(d):[],...Io(t)]:[];
2u.forEach(e=>{r&&e.addEventListener("scroll",n,{passive:!0}),s&&e.addEventListener("resize",n)});const m=d&&o?function(e,t){let n,a=null;const r=uo(e);function s(){var e;clearTimeout(n),null==(e=a)||e.disconnect(),a=null}return function i(o,l){void 0===o&&(o=!1),void 0===l&&(l=1),s();const d=e.getBoundingClientRect(),{left:u,top:m,width:p,height:h}=d;if(o||t(),!p||!h)return;const f={rootMargin:-Ei(m)+"px "+-Ei(r.clientWidth-(u+p))+"px "+-Ei(r.clientHeight-(m+h))+"px "+-Ei(u)+"px",threshold:Ai(0,Ci(1,l))||1};let x=!0;function v(t){const a=t[0].intersectionRatio;if(a!==l){if(!x)return i();a?i(!1,a):n=setTimeout(()=>{i(!1,1e-7)},1e3)}1!==a||Xo(d,e.getBoundingClientRect())||i(),x=!1}try{a=new IntersectionObserver(v,(0,c.A)((0,c.A)({},f),{},{root:r.ownerDocument}))}catch(g){a=new IntersectionObserver(v,f)}a.observe(e)}(!0),s}(d,n):null;let p,h=-1,f=null;i&&(f=new ResizeObserver(e=>{let[a]=e;a&&a.target===d&&f&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var e;null==(e=f)||e.observe(t)})),n()}),d&&!l&&f.observe(d),f.observe(t));let x=l?zo(e):null;return l&&function t(){const a=zo(e);x&&!Xo(x,a)&&n();x=a,p=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach(e=>{r&&e.removeEventListener("scroll",n),s&&e.removeEventListener("resize",n)}),null==m||m(),null==(e=f)||e.disconnect(),f=null,l&&cancelAnimationFrame(p)}}const Zo=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,a;const{x:r,y:s,placement:i,middlewareData:o}=t,l=await async function(e,t){const{placement:n,platform:a,elements:r}=e,s=await(null==a.isRTL?void 0:a.isRTL(r.floating)),i=Oi(n),o=Bi(n),l="y"===Ui(n),c=io.has(i)?-1:1,d=s&&l?-1:1,u=Pi(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:h}="number"===typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return o&&"number"===typeof h&&(p="end"===o?-1*h:h),l?{x:p*d,y:m*c}:{x:m*c,y:p*d}}(t,e);return i===(null==(n=o.offset)?void 0:n.placement)&&null!=(a=o.arrow)&&a.alignmentOffset?{}:{x:r+l.x,y:s+l.y,data:(0,c.A)((0,c.A)({},l),{},{placement:i})}}}},el=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:a,placement:r}=t,s=Pi(e,t),{mainAxis:i=!0,crossAxis:o=!1,limiter:d={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}}}=s,u=l(s,eo),m={x:n,y:a},p=await ao(t,u),h=Ui(Oi(r)),f=Li(h);let x=m[f],v=m[h];if(i){const e="y"===f?"bottom":"right";x=Ti(x+p["y"===f?"top":"left"],x,x-p[e])}if(o){const e="y"===h?"bottom":"right";v=Ti(v+p["y"===h?"top":"left"],v,v-p[e])}const g=d.fn((0,c.A)((0,c.A)({},t),{},{[f]:x,[h]:v}));return(0,c.A)((0,c.A)({},g),{},{data:{x:g.x-n,y:g.y-a,enabled:{[f]:i,[h]:o}}})}}},tl=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,a;const{placement:r,middlewareData:s,rects:i,initialPlacement:o,platform:c,elements:d}=t,u=Pi(e,t),{mainAxis:m=!0,crossAxis:p=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0}=u,g=l(u,Qi);if(null!=(n=s.arrow)&&n.alignmentOffset)return{};const y=Oi(r),b=Ui(o),w=Oi(o)===o,j=await(null==c.isRTL?void 0:c.isRTL(d.floating)),k=h||(w||!v?[Ji(o)]:function(e){const t=Ji(e);return[qi(e),t,qi(t)]}(o)),N="none"!==x;!h&&N&&k.push(...Yi(o,v,x,j));const _=[o,...k],D=await ao(t,g),C=[];let A=(null==(a=s.flip)?void 0:a.overflows)||[];if(m&&C.push(D[y]),p){const e=function(e,t,n){void 0===n&&(n=!1);const a=Bi(e),r=Vi(e),s=Mi(r);let i="x"===r?a===(n?"end":"start")?"right":"left":"start"===a?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ji(i)),[i,Ji(i)]}(r,i,j);C.push(D[e[0]],D[e[1]])}if(A=[...A,{placement:r,overflows:C}],!C.every(e=>e<=0)){var S,E;const e=((null==(S=s.flip)?void 0:S.index)||0)+1,t=_[e];if(t){if(!("alignment"===p&&b!==Ui(t))||A.every(e=>Ui(e.placement)!==b||e.overflows[0]>0))return{data:{index:e,overflows:A},reset:{placement:t}}}let n=null==(E=A.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:E.placement;if(!n)switch(f){case"bestFit":{var F;const e=null==(F=A.filter(e=>{if(N){const t=Ui(e.placement);return t===b||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>
2e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:F[0];e&&(n=e);break}case"initialPlacement":n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},nl=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,a;const{placement:r,rects:s,platform:i,elements:o}=t,d=Pi(e,t),{apply:u=()=>{}}=d,m=l(d,to),p=await ao(t,m),h=Oi(r),f=Bi(r),x="y"===Ui(r),{width:v,height:g}=s.floating;let y,b;"top"===h||"bottom"===h?(y=h,b=f===(await(null==i.isRTL?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(b=h,y="end"===f?"top":"bottom");const w=g-p.top-p.bottom,j=v-p.left-p.right,k=Ci(g-p[y],w),N=Ci(v-p[b],j),_=!t.middlewareData.shift;let D=k,C=N;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(C=j),null!=(a=t.middlewareData.shift)&&a.enabled.y&&(D=w),_&&!f){const e=Ai(p.left,0),t=Ai(p.right,0),n=Ai(p.top,0),a=Ai(p.bottom,0);x?C=v-2*(0!==e||0!==t?e+t:Ai(p.left,p.right)):D=g-2*(0!==n||0!==a?n+a:Ai(p.top,p.bottom))}await u((0,c.A)((0,c.A)({},t),{},{availableWidth:C,availableHeight:D}));const A=await i.getDimensions(o.floating);return v!==A.width||g!==A.height?{reset:{rects:!0}}:{}}}},al=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,a=Pi(e,t),{strategy:r="referenceHidden"}=a,s=l(a,Zi);switch(r){case"referenceHidden":{const e=ro(await ao(t,(0,c.A)((0,c.A)({},s),{},{elementContext:"reference"})),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:so(e)}}}case"escaped":{const e=ro(await ao(t,(0,c.A)((0,c.A)({},s),{},{altBoundary:!0})),n.floating);return{data:{escapedOffsets:e,escaped:so(e)}}}default:return{}}}}},rl=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:a,placement:r,rects:s,platform:i,elements:o,middlewareData:l}=t,{element:d,padding:u=0}=Pi(e,t)||{};if(null==d)return{};const m=$i(u),p={x:n,y:a},h=Vi(r),f=Mi(h),x=await i.getDimensions(d),v="y"===h,g=v?"top":"left",y=v?"bottom":"right",b=v?"clientHeight":"clientWidth",w=s.reference[f]+s.reference[h]-p[h]-s.floating[f],j=p[h]-s.reference[h],k=await(null==i.getOffsetParent?void 0:i.getOffsetParent(d));let N=k?k[b]:0;N&&await(null==i.isElement?void 0:i.isElement(k))||(N=o.floating[b]||s.floating[f]);const _=w/2-j/2,D=N/2-x[f]/2-1,C=Ci(m[g],D),A=Ci(m[y],D),S=C,E=N-x[f]-A,F=N/2-x[f]/2+_,R=Ti(S,F,E),I=!l.arrow&&null!=Bi(r)&&F!==R&&s.reference[f]/2-(F<S?C:A)-x[f]/2<0,T=I?F<S?F-S:F-E:0;return{[h]:p[h]+T,data:(0,c.A)({[h]:R,centerOffset:F-R-T},I&&{alignmentOffset:T}),reset:I}}}),sl=function(e){return void 0===e&&(e={}),{options:e,fn(t){const{x:n,y:a,placement:r,rects:s,middlewareData:i}=t,{offset:o=0,mainAxis:l=!0,crossAxis:d=!0}=Pi(e,t),u={x:n,y:a},m=Ui(r),p=Li(m);let h=u[p],f=u[m];const x=Pi(o,t),v="number"===typeof x?{mainAxis:x,crossAxis:0}:(0,c.A)({mainAxis:0,crossAxis:0},x);if(l){const e="y"===p?"height":"width",t=s.reference[p]-s.floating[e]+v.mainAxis,n=s.reference[p]+s.reference[e]-v.mainAxis;h<t?h=t:h>n&&(h=n)}if(d){var g,y;const e="y"===p?"width":"height",t=io.has(Oi(r)),n=s.reference[m]-s.floating[e]+(t&&(null==(g=i.offset)?void 0:g[m])||0)+(t?0:v.crossAxis),a=s.reference[m]+s.reference[e]+(t?0:(null==(y=i.offset)?void 0:y[m])||0)-(t?v.crossAxis:0);f<n?f=n:f>a&&(f=a)}return{[p]:h,[m]:f}}}},il=(e,t,n)=>{const a=new Map,r=(0,c.A)({platform:$o},n),s=(0,c.A)((0,c.A)({},r.platform),{},{_c:a});return(async(e,t,n)=>{const{placement:a="bottom",strategy:r="absolute",middleware:s=[],platform:i}=n,o=s.filter(Boolean),l=await(null==i.isRTL?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:u,y:m}=no(d,a,l),p=a,h={},f=0;for(let x=0;x<o.length;x++){const{name:n,fn:s}=o[x],{x:v,y:g,data:y,reset:b}=await s({x:u,y:m,initialPlacement:a,placement:p,strategy:r,middlewareData:h,rects:d,platform:i,elements:{reference:e,floating:t}});u=null!=v?v:u,m=null!=g?g:m,h=(0,c.A)((0,c.A)({},h),{},{[n]:(0,c.A)((0,c.A)({},h[n]),y)}),b&&f<=50&&(f++,"object"===typeof b&&(b.placement&&(p=b.placement),b.rects&&(d=!0===b.rects?await i.getElementRects({reference:e,floating:t,strategy:r}):b.rects),({x:u,y:m}=no(d,p,l))),x=-1)}return{x:u,y:m,placement:p,strategy:r,middlewareData:h}})(e,t,(0,c.A)((0,c.A)({},r),{},{platform:s}))};var ol="undefined"!==typeof document?s.useLayoutEffect:function(){};function ll(e,t){if(e===t)return!0;
2if(typeof e!==typeof t)return!1;if("function"===typeof e&&e.toString()===t.toString())return!0;let n,a,r;if(e&&t&&"object"===typeof e){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(a=n;0!==a--;)if(!ll(e[a],t[a]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(a=n;0!==a--;)if(!{}.hasOwnProperty.call(t,r[a]))return!1;for(a=n;0!==a--;){const n=r[a];if(("_owner"!==n||!e.$$typeof)&&!ll(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function cl(e){if("undefined"===typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function dl(e,t){const n=cl(e);return Math.round(t*n)/n}function ul(e){const t=s.useRef(e);return ol(()=>{t.current=e}),t}const ml=(e,t)=>(0,c.A)((0,c.A)({},Zo(e)),{},{options:[e,t]}),pl=(e,t)=>(0,c.A)((0,c.A)({},el(e)),{},{options:[e,t]}),hl=(e,t)=>(0,c.A)((0,c.A)({},sl(e)),{},{options:[e,t]}),fl=(e,t)=>(0,c.A)((0,c.A)({},tl(e)),{},{options:[e,t]}),xl=(e,t)=>(0,c.A)((0,c.A)({},nl(e)),{},{options:[e,t]}),vl=(e,t)=>(0,c.A)((0,c.A)({},al(e)),{},{options:[e,t]}),gl=(e,t)=>(0,c.A)((0,c.A)({},(e=>({name:"arrow",options:e,fn(t){const{element:n,padding:a}="function"===typeof e?e(t):e;return n&&(r=n,{}.hasOwnProperty.call(r,"current"))?null!=n.current?rl({element:n.current,padding:a}).fn(t):{}:n?rl({element:n,padding:a}).fn(t):{};var r}}))(e)),{},{options:[e,t]}),yl=["children","width","height"];var bl=s.forwardRef((e,t)=>{const{children:n,width:a=10,height:r=5}=e,s=l(e,yl);return(0,Xt.jsx)(Is.svg,(0,c.A)((0,c.A)({},s),{},{ref:t,width:a,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:(0,Xt.jsx)("polygon",{points:"0,0 30,0 15,10"})}))});bl.displayName="Arrow";var wl=bl;function jl(e){const[t,n]=s.useState(void 0);return Or(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const a=t[0];let r,s;if("borderBoxSize"in a){const e=a.borderBoxSize,t=Array.isArray(e)?e[0]:e;r=t.inlineSize,s=t.blockSize}else r=e.offsetWidth,s=e.offsetHeight;n({width:r,height:s})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}n(void 0)},[e]),t}const kl=["__scopePopper","virtualRef"],Nl=["__scopePopper","side","sideOffset","align","alignOffset","arrowPadding","avoidCollisions","collisionBoundary","collisionPadding","sticky","hideWhenDetached","updatePositionStrategy","onPlaced"],_l=["__scopePopper"];var Dl="Popper",[Cl,Al]=js(Dl),[Sl,El]=Cl(Dl),Fl=e=>{const{__scopePopper:t,children:n}=e,[a,r]=s.useState(null);return(0,Xt.jsx)(Sl,{scope:t,anchor:a,onAnchorChange:r,children:n})};Fl.displayName=Dl;var Rl="PopperAnchor",Il=s.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:a}=e,r=l(e,kl),i=El(Rl,n),o=s.useRef(null),d=Xn(t,o),u=s.useRef(null);return s.useEffect(()=>{const e=u.current;u.current=(null===a||void 0===a?void 0:a.current)||o.current,e!==u.current&&i.onAnchorChange(u.current)}),a?null:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({},r),{},{ref:d}))});Il.displayName=Rl;var Tl="PopperContent",[Pl,Ol]=Cl(Tl),Bl=s.forwardRef((e,t)=>{var n,a,r,i,o,d,u,m;const{__scopePopper:p,side:h="bottom",sideOffset:f=0,align:x="center",alignOffset:v=0,arrowPadding:g=0,avoidCollisions:y=!0,collisionBoundary:b=[],collisionPadding:w=0,sticky:j="partial",hideWhenDetached:k=!1,updatePositionStrategy:N="optimized",onPlaced:_}=e,D=l(e,Nl),C=El(Tl,p),[A,S]=s.useState(null),E=Xn(t,e=>S(e)),[F,R]=s.useState(null),I=jl(F),T=null!==(n=null===I||void 0===I?void 0:I.width)&&void 0!==n?n:0,P=null!==(a=null===I||void 0===I?void 0:I.height)&&void 0!==a?a:0,O=h+("center"!==x?"-"+x:""),B="number"===typeof w?w:(0,c.A)({top:0,right:0,bottom:0,left:0},w),L=Array.isArray(b)?b:[b],M=L.length>0,z={padding:B,boundary:L.filter(Ul),altBoundary:M},{refs:U,floatingStyles:V,placement:q,isPositioned:W,middlewareData:H}=function(e){void 0===e&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:a=[],platform:r,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:d,open:u}=e,[m,p]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,f]=s.useState(a);ll(h,a)||f(a);const[x,v]=s.useState(null),[g,y]=s.useState(null),b=s.useCallback(e=>
2{e!==N.current&&(N.current=e,v(e))},[]),w=s.useCallback(e=>{e!==_.current&&(_.current=e,y(e))},[]),j=i||x,k=o||g,N=s.useRef(null),_=s.useRef(null),D=s.useRef(m),C=null!=d,A=ul(d),S=ul(r),E=ul(u),F=s.useCallback(()=>{if(!N.current||!_.current)return;const e={placement:t,strategy:n,middleware:h};S.current&&(e.platform=S.current),il(N.current,_.current,e).then(e=>{const t=(0,c.A)((0,c.A)({},e),{},{isPositioned:!1!==E.current});R.current&&!ll(D.current,t)&&(D.current=t,Br.flushSync(()=>{p(t)}))})},[h,t,n,S,E]);ol(()=>{!1===u&&D.current.isPositioned&&(D.current.isPositioned=!1,p(e=>(0,c.A)((0,c.A)({},e),{},{isPositioned:!1})))},[u]);const R=s.useRef(!1);ol(()=>(R.current=!0,()=>{R.current=!1}),[]),ol(()=>{if(j&&(N.current=j),k&&(_.current=k),j&&k){if(A.current)return A.current(j,k,F);F()}},[j,k,F,A,C]);const I=s.useMemo(()=>({reference:N,floating:_,setReference:b,setFloating:w}),[b,w]),T=s.useMemo(()=>({reference:j,floating:k}),[j,k]),P=s.useMemo(()=>{const e={position:n,left:0,top:0};if(!T.floating)return e;const t=dl(T.floating,m.x),a=dl(T.floating,m.y);return l?(0,c.A)((0,c.A)({},e),{},{transform:"translate("+t+"px, "+a+"px)"},cl(T.floating)>=1.5&&{willChange:"transform"}):{position:n,left:t,top:a}},[n,l,T.floating,m.x,m.y]);return s.useMemo(()=>(0,c.A)((0,c.A)({},m),{},{update:F,refs:I,elements:T,floatingStyles:P}),[m,F,I,T,P])}({strategy:"fixed",placement:O,whileElementsMounted:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Qo(...t,{animationFrame:"always"===N})},elements:{reference:C.anchor},middleware:[ml({mainAxis:f+P,alignmentAxis:v}),y&&pl((0,c.A)({mainAxis:!0,crossAxis:!1,limiter:"partial"===j?hl():void 0},z)),y&&fl((0,c.A)({},z)),xl((0,c.A)((0,c.A)({},z),{},{apply:e=>{let{elements:t,rects:n,availableWidth:a,availableHeight:r}=e;const{width:s,height:i}=n.reference,o=t.floating.style;o.setProperty("--radix-popper-available-width","".concat(a,"px")),o.setProperty("--radix-popper-available-height","".concat(r,"px")),o.setProperty("--radix-popper-anchor-width","".concat(s,"px")),o.setProperty("--radix-popper-anchor-height","".concat(i,"px"))}})),F&&gl({element:F,padding:g}),Vl({arrowWidth:T,arrowHeight:P}),k&&vl((0,c.A)({strategy:"referenceHidden"},z))]}),[G,K]=ql(q),Y=Pr(_);Or(()=>{W&&(null===Y||void 0===Y||Y())},[W,Y]);const J=null===(r=H.arrow)||void 0===r?void 0:r.x,$=null===(i=H.arrow)||void 0===i?void 0:i.y,X=0!==(null===(o=H.arrow)||void 0===o?void 0:o.centerOffset),[Q,Z]=s.useState();return Or(()=>{A&&Z(window.getComputedStyle(A).zIndex)},[A]),(0,Xt.jsx)("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:(0,c.A)((0,c.A)({},V),{},{transform:W?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[null===(d=H.transformOrigin)||void 0===d?void 0:d.x,null===(u=H.transformOrigin)||void 0===u?void 0:u.y].join(" ")},(null===(m=H.hide)||void 0===m?void 0:m.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}),dir:e.dir,children:(0,Xt.jsx)(Pl,{scope:p,placedSide:G,onArrowChange:R,arrowX:J,arrowY:$,shouldHideArrow:X,children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({"data-side":G,"data-align":K},D),{},{ref:E,style:(0,c.A)((0,c.A)({},D.style),{},{animation:W?void 0:"none"})}))})})});Bl.displayName=Tl;var Ll="PopperArrow",Ml={top:"bottom",right:"left",bottom:"top",left:"right"},zl=s.forwardRef(function(e,t){const{__scopePopper:n}=e,a=l(e,_l),r=Ol(Ll,n),s=Ml[r.placedSide];return(0,Xt.jsx)("span",{ref:r.onArrowChange,style:{position:"absolute",left:r.arrowX,top:r.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[r.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[r.placedSide],visibility:r.shouldHideArrow?"hidden":void 0},children:(0,Xt.jsx)(wl,(0,c.A)((0,c.A)({},a),{},{ref:t,style:(0,c.A)((0,c.A)({},a.style),{},{display:"block"})}))})});function Ul(e){return null!==e}zl.displayName=Ll;var Vl=e=>({name:"transformOrigin",options:e,fn(t){var n,a,r,s,i;const{placement:o,rects:l,middlewareData:c}=t,d=0!==(null===(n=c.arrow)||void 0===n?void 0:n.centerOffset),u=d?0:e.arrowWidth,m=d?0:e.arrowHeight,[p,h]=ql(o),f={start:"0%",center:"50%",end:"100%"}[h],x=(null!==(a=null===(r=c.arrow)||void 0===r?void 0:r.x)&&void 0!==a?a:0)+u/2,v=(null!==(s=null===(i=c.arrow)||void 0===i?void 0:i.y)&&void 0!==s?s:0)+m/2;let g="",y="";return"bottom"===p?(g=d?f:"".concat(x,"px"),y="".concat(-m,"px")):"top"===p?(g=d?f:"".concat(x,"px"),y="".concat(l.floating.height+m,"px")):"right"===p?(g="".concat(-m,"px"),y=d?f:"".concat(v,"px")):"left"===p&&(g="".concat(l.floating.width+m,"px"),y=d?f:"".concat(v,"px")),{data:{x:g,y:y}}}});function ql(e){const[t,n="center"]=e.split("-");return[t,n]}var Wl=Fl,Hl=Il,Gl=Bl,Kl=zl;const Yl=["container"];var Jl=s.forwardRef((e,t)=>
2{var n;const{container:a}=e,r=l(e,Yl),[i,o]=s.useState(!1);Or(()=>o(!0),[]);const d=a||i&&(null===globalThis||void 0===globalThis||null===(n=globalThis.document)||void 0===n?void 0:n.body);return d?Br.createPortal((0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({},r),{},{ref:t})),d):null});Jl.displayName="Portal";var $l=e=>{const{present:t,children:n}=e,a=function(e){const[t,n]=s.useState(),a=s.useRef(null),r=s.useRef(e),i=s.useRef("none"),o=e?"mounted":"unmounted",[l,c]=function(e,t){return s.useReducer((e,n)=>{const a=t[e][n];return null!==a&&void 0!==a?a:e},e)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const e=Xl(a.current);i.current="mounted"===l?e:"none"},[l]),Or(()=>{const t=a.current,n=r.current;if(n!==e){const a=i.current,s=Xl(t);if(e)c("MOUNT");else if("none"===s||"none"===(null===t||void 0===t?void 0:t.display))c("UNMOUNT");else{c(n&&a!==s?"ANIMATION_OUT":"UNMOUNT")}r.current=e}},[e,c]),Or(()=>{if(t){var e;let n;const s=null!==(e=t.ownerDocument.defaultView)&&void 0!==e?e:window,o=e=>{const i=Xl(a.current).includes(CSS.escape(e.animationName));if(e.target===t&&i&&(c("ANIMATION_END"),!r.current)){const e=t.style.animationFillMode;t.style.animationFillMode="forwards",n=s.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=e)})}},l=e=>{e.target===t&&(i.current=Xl(a.current))};return t.addEventListener("animationstart",l),t.addEventListener("animationcancel",o),t.addEventListener("animationend",o),()=>{s.clearTimeout(n),t.removeEventListener("animationstart",l),t.removeEventListener("animationcancel",o),t.removeEventListener("animationend",o)}}c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:s.useCallback(e=>{a.current=e?getComputedStyle(e):null,n(e)},[])}}(t),r="function"===typeof n?n({present:a.isPresent}):s.Children.only(n),i=Xn(a.ref,function(e){var t,n;let a=null===(t=Object.getOwnPropertyDescriptor(e.props,"ref"))||void 0===t?void 0:t.get,r=a&&"isReactWarning"in a&&a.isReactWarning;if(r)return e.ref;if(a=null===(n=Object.getOwnPropertyDescriptor(e,"ref"))||void 0===n?void 0:n.get,r=a&&"isReactWarning"in a&&a.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(r));return"function"===typeof n||a.isPresent?s.cloneElement(r,{ref:i}):null};function Xl(e){return(null===e||void 0===e?void 0:e.animationName)||"none"}$l.displayName="Presence";const Ql=["__scopeRovingFocusGroup","orientation","loop","dir","currentTabStopId","defaultCurrentTabStopId","onCurrentTabStopIdChange","onEntryFocus","preventScrollOnEntryFocus"],Zl=["__scopeRovingFocusGroup","focusable","active","tabStopId","children"];var ec="rovingFocusGroup.onEntryFocus",tc={bubbles:!1,cancelable:!0},nc="RovingFocusGroup",[ac,rc,sc]=Ks(nc),[ic,oc]=js(nc,[sc]),[lc,cc]=ic(nc),dc=s.forwardRef((e,t)=>(0,Xt.jsx)(ac.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,Xt.jsx)(ac.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,Xt.jsx)(uc,(0,c.A)((0,c.A)({},e),{},{ref:t}))})}));dc.displayName=nc;var uc=s.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:a,loop:r=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:u,onEntryFocus:m,preventScrollOnEntryFocus:p=!1}=e,h=l(e,Ql),f=s.useRef(null),x=Xn(t,f),v=Qs(i),[g,y]=_s({prop:o,defaultProp:null!==d&&void 0!==d?d:null,onChange:u,caller:nc}),[b,w]=s.useState(!1),j=Pr(m),k=rc(n),N=s.useRef(!1),[_,D]=s.useState(0);return s.useEffect(()=>{const e=f.current;if(e)return e.addEventListener(ec,j),()=>e.removeEventListener(ec,j)},[j]),(0,Xt.jsx)(lc,{scope:n,orientation:a,dir:v,loop:r,currentTabStopId:g,onItemFocus:s.useCallback(e=>y(e),[y]),onItemShiftTab:s.useCallback(()=>w(!0),[]),onFocusableItemAdd:s.useCallback(()=>D(e=>e+1),[]),onFocusableItemRemove:s.useCallback(()=>D(e=>e-1),[]),children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({tabIndex:b||0===_?-1:0,"data-orientation":a},h),{},{ref:x,style:(0,c.A)({outline:"none"},e.style),onMouseDown:ys(e.onMouseDown,()=>{N.current=!0}),onFocus:ys(e.onFocus,e=>{const t=!N.current;if(e.target===e.currentTarget&&t&&!b){const t=new CustomEvent(ec,tc);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){const e=k().filter(e=>
2e.focusable);fc([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),p)}}N.current=!1}),onBlur:ys(e.onBlur,()=>w(!1))}))})}),mc="RovingFocusGroupItem",pc=s.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:a=!0,active:r=!1,tabStopId:i,children:o}=e,d=l(e,Zl),u=_i(),m=i||u,p=cc(mc,n),h=p.currentTabStopId===m,f=rc(n),{onFocusableItemAdd:x,onFocusableItemRemove:v,currentTabStopId:g}=p;return s.useEffect(()=>{if(a)return x(),()=>v()},[a,x,v]),(0,Xt.jsx)(ac.ItemSlot,{scope:n,id:m,focusable:a,active:r,children:(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({tabIndex:h?0:-1,"data-orientation":p.orientation},d),{},{ref:t,onMouseDown:ys(e.onMouseDown,e=>{a?p.onItemFocus(m):e.preventDefault()}),onFocus:ys(e.onFocus,()=>p.onItemFocus(m)),onKeyDown:ys(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void p.onItemShiftTab();if(e.target!==e.currentTarget)return;const t=function(e,t,n){const a=function(e,t){return"rtl"!==t?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,n);return"vertical"===t&&["ArrowLeft","ArrowRight"].includes(a)||"horizontal"===t&&["ArrowUp","ArrowDown"].includes(a)?void 0:hc[a]}(e,p.orientation,p.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let r=f().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)r.reverse();else if("prev"===t||"next"===t){"prev"===t&&r.reverse();const s=r.indexOf(e.currentTarget);r=p.loop?(a=s+1,(n=r).map((e,t)=>n[(a+t)%n.length])):r.slice(s+1)}setTimeout(()=>fc(r))}var n,a}),children:"function"===typeof o?o({isCurrentTabStop:h,hasTabStop:null!=g}):o}))})});pc.displayName=mc;var hc={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function fc(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=document.activeElement;for(const a of e){if(a===n)return;if(a.focus({preventScroll:t}),document.activeElement!==n)return}}var xc=dc,vc=pc;const gc=["children"],yc=["children"];function bc(e){const t=wc(e),n=s.forwardRef((e,n)=>{const{children:a}=e,r=l(e,gc),i=s.Children.toArray(a),o=i.find(kc);if(o){const e=o.props.children,a=i.map(t=>t===o?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,a):null}))}return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:a}))});return n.displayName="".concat(e,".Slot"),n}function wc(e){const t=s.forwardRef((e,t)=>{const{children:n}=e,a=l(e,yc);if(s.isValidElement(n)){const e=function(e){var t,n;let a=null===(t=Object.getOwnPropertyDescriptor(e.props,"ref"))||void 0===t?void 0:t.get,r=a&&"isReactWarning"in a&&a.isReactWarning;if(r)return e.ref;if(a=null===(n=Object.getOwnPropertyDescriptor(e,"ref"))||void 0===n?void 0:n.get,r=a&&"isReactWarning"in a&&a.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,t){const n=(0,c.A)({},t);for(const a in t){const r=e[a],s=t[a];/^on[A-Z]/.test(a)?r&&s?n[a]=function(){const e=s(...arguments);return r(...arguments),e}:r&&(n[a]=r):"style"===a?n[a]=(0,c.A)((0,c.A)({},r),s):"className"===a&&(n[a]=[r,s].filter(Boolean).join(" "))}return(0,c.A)((0,c.A)({},e),n)}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?$n(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName="".concat(e,".SlotClone"),t}var jc=Symbol("radix.slottable");function kc(e){return s.isValidElement(e)&&"function"===typeof e.type&&"__radixId"in e.type&&e.type.__radixId===jc}var Nc=function(e){return"undefined"===typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},_c=new WeakMap,Dc=new WeakMap,Cc={},Ac=0,Sc=function(e){return e&&(e.host||Sc(e.parentNode))},Ec=function(e,t,n,a){var r=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Sc(t);return n&&e.contains(n)?n:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);Cc[n]||(Cc[n]=new WeakMap);var s=Cc[n],i=[],o=new Set,l=new Set(r),c=function(e){e&&!o.has(e)&&(o.add(e),c(e.parentNode))};r.forEach(c);var d=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(o.has(e))d(e);else try{var t=e.getAttribute(a),r=null!==t&&"false"!==t,l=(_c.get(e)||0)+1,c=(s.get(e)||0)+1;_c.set(e,l),s.set(e,c),i.push(e),1===l&&r&&Dc.set(e,!0),1===c&&e.setAttribute(n,"true"),r||e.setAttribute(a,"true")}catch(mK){console.error("aria-hidden: cannot operate on ",e,mK)}})};
2return d(t),o.clear(),Ac++,function(){i.forEach(function(e){var t=_c.get(e)-1,r=s.get(e)-1;_c.set(e,t),s.set(e,r),t||(Dc.has(e)||e.removeAttribute(a),Dc.delete(e)),r||e.removeAttribute(n)}),--Ac||(_c=new WeakMap,_c=new WeakMap,Dc=new WeakMap,Cc={})}},Fc=function(e,t,n){void 0===n&&(n="data-aria-hidden");var a=Array.from(Array.isArray(e)?e:[e]),r=t||Nc(e);return r?(a.push.apply(a,Array.from(r.querySelectorAll("[aria-live], script"))),Ec(a,r,n,"aria-hidden")):function(){return null}},Rc=n(326),Ic="right-scroll-bar-position",Tc="width-before-scroll-bar";function Pc(e,t){return"function"===typeof e?e(t):e&&(e.current=t),e}var Oc="undefined"!==typeof window?s.useLayoutEffect:s.useEffect,Bc=new WeakMap;function Lc(e,t){var n=function(e,t){var n=(0,s.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}(t||null,function(t){return e.forEach(function(e){return Pc(e,t)})});return Oc(function(){var t=Bc.get(n);if(t){var a=new Set(t),r=new Set(e),s=n.current;a.forEach(function(e){r.has(e)||Pc(e,null)}),r.forEach(function(e){a.has(e)||Pc(e,s)})}Bc.set(n,e)},[e]),n}function Mc(e){return e}function zc(e,t){void 0===t&&(t=Mc);var n=[],a=!1,r={read:function(){if(a)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var r=t(e,a);return n.push(r),function(){n=n.filter(function(e){return e!==r})}},assignSyncMedium:function(e){for(a=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){a=!0;var t=[];if(n.length){var r=n;n=[],r.forEach(e),t=n}var s=function(){var n=t;t=[],n.forEach(e)},i=function(){return Promise.resolve().then(s)};i(),n={push:function(e){t.push(e),i()},filter:function(e){return t=t.filter(e),n}}}};return r}var Uc=function(e){void 0===e&&(e={});var t=zc(null);return t.options=(0,Rc.Cl)({async:!0,ssr:!1},e),t}(),Vc=function(){},qc=s.forwardRef(function(e,t){var n=s.useRef(null),a=s.useState({onScrollCapture:Vc,onWheelCapture:Vc,onTouchMoveCapture:Vc}),r=a[0],i=a[1],o=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,u=e.enabled,m=e.shards,p=e.sideCar,h=e.noRelative,f=e.noIsolation,x=e.inert,v=e.allowPinchZoom,g=e.as,y=void 0===g?"div":g,b=e.gapMode,w=(0,Rc.Tt)(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=p,k=Lc([n,t]),N=(0,Rc.Cl)((0,Rc.Cl)({},w),r);return s.createElement(s.Fragment,null,u&&s.createElement(j,{sideCar:Uc,removeScrollBar:d,shards:m,noRelative:h,noIsolation:f,inert:x,setCallbacks:i,allowPinchZoom:!!v,lockRef:n,gapMode:b}),o?s.cloneElement(s.Children.only(l),(0,Rc.Cl)((0,Rc.Cl)({},N),{ref:k})):s.createElement(y,(0,Rc.Cl)({},N,{className:c,ref:k}),l))});qc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},qc.classNames={fullWidth:Tc,zeroRight:Ic};var Wc,Hc=function(e){var t=e.sideCar,n=(0,Rc.Tt)(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var a=t.read();if(!a)throw new Error("Sidecar medium not found");return s.createElement(a,(0,Rc.Cl)({},n))};Hc.isSideCarExport=!0;function Gc(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Wc||n.nc;return t&&e.setAttribute("nonce",t),e}var Kc=function(){var e=0,t=null;return{add:function(n){var a,r;0==e&&(t=Gc())&&(r=n,(a=t).styleSheet?a.styleSheet.cssText=r:a.appendChild(document.createTextNode(r)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Yc=function(){var e=function(){var e=Kc();return function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}}();return function(t){var n=t.styles,a=t.dynamic;return e(n,a),null}},Jc={left:0,top:0,right:0,gap:0},$c=function(e){return parseInt(e||"",10)||0},Xc=function(e){if(void 0===e&&(e="margin"),"undefined"===typeof window)return Jc;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],a=t["padding"===e?"paddingTop":"marginTop"],r=t["padding"===e?"paddingRight":"marginRight"];return[$c(n),$c(a),$c(r)]}(e),n=document.documentElement.clientWidth,a=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,a-n+t[2]-t[0])}},Qc=Yc(),Zc="data-scroll-locked",ed=function(e,t,n,a){var r=e.left,s=e.top,i=e.right,o=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(a,";\n padding-right: ").concat(o,"px ").concat(a,";\n }\n body[").concat(Zc,"] {\n overflow: hidden ").concat(a,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(a,";"),"margin"===n&&"\n padding-left: ".concat(r,"px;\n padding-top: ").concat(s,"px;\n padding-right: ").concat(i,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(o,"px ").concat(a,";\n "),"padding"===n&&"padding-right: ".concat(o,"px ").concat(a,";
2")].filter(Boolean).join(""),"\n }\n \n .").concat(Ic," {\n right: ").concat(o,"px ").concat(a,";\n }\n \n .").concat(Tc," {\n margin-right: ").concat(o,"px ").concat(a,";\n }\n \n .").concat(Ic," .").concat(Ic," {\n right: 0 ").concat(a,";\n }\n \n .").concat(Tc," .").concat(Tc," {\n margin-right: 0 ").concat(a,";\n }\n \n body[").concat(Zc,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},td=function(){var e=parseInt(document.body.getAttribute(Zc)||"0",10);return isFinite(e)?e:0},nd=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,r=void 0===a?"margin":a;s.useEffect(function(){return document.body.setAttribute(Zc,(td()+1).toString()),function(){var e=td()-1;e<=0?document.body.removeAttribute(Zc):document.body.setAttribute(Zc,e.toString())}},[]);var i=s.useMemo(function(){return Xc(r)},[r]);return s.createElement(Qc,{styles:ed(i,!t,r,n?"":"!important")})},ad=!1;if("undefined"!==typeof window)try{var rd=Object.defineProperty({},"passive",{get:function(){return ad=!0,!0}});window.addEventListener("test",rd,rd),window.removeEventListener("test",rd,rd)}catch(pK){ad=!1}var sd=!!ad&&{passive:!1},id=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},od=function(e,t){var n=t.ownerDocument,a=t;do{if("undefined"!==typeof ShadowRoot&&a instanceof ShadowRoot&&(a=a.host),ld(e,a)){var r=cd(e,a);if(r[1]>r[2])return!0}a=a.parentNode}while(a&&a!==n.body);return!1},ld=function(e,t){return"v"===e?function(e){return id(e,"overflowY")}(t):function(e){return id(e,"overflowX")}(t)},cd=function(e,t){return"v"===e?[(n=t).scrollTop,n.scrollHeight,n.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var n},dd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ud=function(e){return[e.deltaX,e.deltaY]},md=function(e){return e&&"current"in e?e.current:e},pd=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},hd=0,fd=[];function xd(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const vd=(gd=function(e){var t=s.useRef([]),n=s.useRef([0,0]),a=s.useRef(),r=s.useState(hd++)[0],i=s.useState(Yc)[0],o=s.useRef(e);s.useEffect(function(){o.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var t=(0,Rc.fX)([e.lockRef.current],(e.shards||[]).map(md),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var l=s.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var r,s=dd(e),i=n.current,l="deltaX"in e?e.deltaX:i[0]-s[0],c="deltaY"in e?e.deltaY:i[1]-s[1],d=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===d.type)return!1;var m=window.getSelection(),p=m&&m.anchorNode;if(p&&(p===d||p.contains(d)))return!1;var h=od(u,d);if(!h)return!0;if(h?r=u:(r="v"===u?"h":"v",h=od(u,d)),!h)return!1;if(!a.current&&"changedTouches"in e&&(l||c)&&(a.current=r),!r)return!0;var f=a.current||r;return function(e,t,n,a,r){var s=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),i=s*a,o=n.target,l=t.contains(o),c=!1,d=i>0,u=0,m=0;do{if(!o)break;var p=cd(e,o),h=p[0],f=p[1]-p[2]-s*h;(h||f)&&ld(e,o)&&(u+=f,m+=h);var x=o.parentNode;o=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!l&&o!==document.body||l&&(t.contains(o)||t===o));return(d&&(r&&Math.abs(u)<1||!r&&i>u)||!d&&(r&&Math.abs(m)<1||!r&&-i>m))&&(c=!0),c}(f,t,e,"h"===f?l:c,!0)},[]),c=s.useCallback(function(e){var n=e;if(fd.length&&fd[fd.length-1]===i){var a="deltaY"in n?ud(n):dd(n),r=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&function(e,t){return e[0]===t[0]&&e[1]===t[1]}(e.delta,a)})[0];if(r&&r.should)n.cancelable&&n.preventDefault();
2else if(!r){var s=(o.current.shards||[]).map(md).filter(Boolean).filter(function(e){return e.contains(n.target)});(s.length>0?l(n,s[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),d=s.useCallback(function(e,n,a,r){var s={name:e,delta:n,target:a,should:r,shadowParent:xd(a)};t.current.push(s),setTimeout(function(){t.current=t.current.filter(function(e){return e!==s})},1)},[]),u=s.useCallback(function(e){n.current=dd(e),a.current=void 0},[]),m=s.useCallback(function(t){d(t.type,ud(t),t.target,l(t,e.lockRef.current))},[]),p=s.useCallback(function(t){d(t.type,dd(t),t.target,l(t,e.lockRef.current))},[]);s.useEffect(function(){return fd.push(i),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:p}),document.addEventListener("wheel",c,sd),document.addEventListener("touchmove",c,sd),document.addEventListener("touchstart",u,sd),function(){fd=fd.filter(function(e){return e!==i}),document.removeEventListener("wheel",c,sd),document.removeEventListener("touchmove",c,sd),document.removeEventListener("touchstart",u,sd)}},[]);var h=e.removeScrollBar,f=e.inert;return s.createElement(s.Fragment,null,f?s.createElement(i,{styles:pd(r)}):null,h?s.createElement(nd,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},Uc.useMedium(gd),Hc);var gd,yd=s.forwardRef(function(e,t){return s.createElement(qc,(0,Rc.Cl)({},e,{ref:t,sideCar:vd}))});yd.classNames=qc.classNames;const bd=yd,wd=["__scopeMenu"],jd=["forceMount"],kd=["__scopeMenu","loop","trapFocus","onOpenAutoFocus","onCloseAutoFocus","disableOutsidePointerEvents","onEntryFocus","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","onDismiss","disableOutsideScroll"],Nd=["__scopeMenu"],_d=["__scopeMenu"],Dd=["disabled","onSelect"],Cd=["__scopeMenu","disabled","textValue"],Ad=["checked","onCheckedChange"],Sd=["value","onValueChange"],Ed=["value"],Fd=["__scopeMenu","forceMount"],Rd=["__scopeMenu"],Id=["__scopeMenu"],Td=["forceMount"];var Pd=["Enter"," "],Od=["ArrowUp","PageDown","End"],Bd=["ArrowDown","PageUp","Home",...Od],Ld={ltr:[...Pd,"ArrowRight"],rtl:[...Pd,"ArrowLeft"]},Md={ltr:["ArrowLeft"],rtl:["ArrowRight"]},zd="Menu",[Ud,Vd,qd]=Ks(zd),[Wd,Hd]=js(zd,[qd,Al,oc]),Gd=Al(),Kd=oc(),[Yd,Jd]=Wd(zd),[$d,Xd]=Wd(zd),Qd=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:o=!0}=e,l=Gd(t),[d,u]=s.useState(null),m=s.useRef(!1),p=Pr(i),h=Qs(r);return s.useEffect(()=>{const e=()=>{m.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>m.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),(0,Xt.jsx)(Wl,(0,c.A)((0,c.A)({},l),{},{children:(0,Xt.jsx)(Yd,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:u,children:(0,Xt.jsx)($d,{scope:t,onClose:s.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:h,modal:o,children:a})})}))};Qd.displayName=zd;var Zd=s.forwardRef((e,t)=>{const{__scopeMenu:n}=e,a=l(e,wd),r=Gd(n);return(0,Xt.jsx)(Hl,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Zd.displayName="MenuAnchor";var eu="MenuPortal",[tu,nu]=Wd(eu,{forceMount:void 0}),au=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,s=Jd(eu,t);return(0,Xt.jsx)(tu,{scope:t,forceMount:n,children:(0,Xt.jsx)($l,{present:n||s.open,children:(0,Xt.jsx)(Jl,{asChild:!0,container:r,children:a})})})};au.displayName=eu;var ru="MenuContent",[su,iu]=Wd(ru),ou=s.forwardRef((e,t)=>{const n=nu(ru,e.__scopeMenu),{forceMount:a=n.forceMount}=e,r=l(e,jd),s=Jd(ru,e.__scopeMenu),i=Xd(ru,e.__scopeMenu);return(0,Xt.jsx)(Ud.Provider,{scope:e.__scopeMenu,children:(0,Xt.jsx)($l,{present:a||s.open,children:(0,Xt.jsx)(Ud.Slot,{scope:e.__scopeMenu,children:i.modal?(0,Xt.jsx)(lu,(0,c.A)((0,c.A)({},r),{},{ref:t})):(0,Xt.jsx)(cu,(0,c.A)((0,c.A)({},r),{},{ref:t}))})})})}),lu=s.forwardRef((e,t)=>{const n=Jd(ru,e.__scopeMenu),a=s.useRef(null),r=Xn(t,a);return s.useEffect(()=>{const e=a.current;if(e)return Fc(e)},[]),(0,Xt.jsx)(uu,(0,c.A)((0,c.A)({},e),{},{ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ys(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))}),cu=s.forwardRef((e,t)=>
2{const n=Jd(ru,e.__scopeMenu);return(0,Xt.jsx)(uu,(0,c.A)((0,c.A)({},e),{},{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))}),du=bc("MenuContent.ScrollLock"),uu=s.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:d,onEntryFocus:u,onEscapeKeyDown:m,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:f,onDismiss:x,disableOutsideScroll:v}=e,g=l(e,kd),y=Jd(ru,n),b=Xd(ru,n),w=Gd(n),j=Kd(n),k=Vd(n),[N,_]=s.useState(null),D=s.useRef(null),C=Xn(t,D,y.onContentChange),A=s.useRef(0),S=s.useRef(""),E=s.useRef(0),F=s.useRef(null),R=s.useRef("right"),I=s.useRef(0),T=v?bd:s.Fragment,P=v?{as:du,allowPinchZoom:!0}:void 0,O=e=>{var t,n;const a=S.current+e,r=k().filter(e=>!e.disabled),s=document.activeElement,i=null===(t=r.find(e=>e.ref.current===s))||void 0===t?void 0:t.textValue,o=function(e,t,n){const a=t.length>1&&Array.from(t).every(e=>e===t[0]),r=a?t[0]:t,s=n?e.indexOf(n):-1;let i=(o=e,l=Math.max(s,0),o.map((e,t)=>o[(l+t)%o.length]));var o,l;1===r.length&&(i=i.filter(e=>e!==n));const c=i.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return c!==n?c:void 0}(r.map(e=>e.textValue),a,i),l=null===(n=r.find(e=>e.textValue===o))||void 0===n?void 0:n.ref.current;!function e(t){S.current=t,window.clearTimeout(A.current),""!==t&&(A.current=window.setTimeout(()=>e(""),1e3))}(a),l&&setTimeout(()=>l.focus())};s.useEffect(()=>()=>window.clearTimeout(A.current),[]),di();const B=s.useCallback(e=>{var t,n;return R.current===(null===(t=F.current)||void 0===t?void 0:t.side)&&function(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return function(e,t){const{x:n,y:a}=e;let r=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const e=t[s],o=t[i],l=e.x,c=e.y,d=o.x,u=o.y;c>a!==u>a&&n<(d-l)*(a-c)/(u-c)+l&&(r=!r)}return r}(n,t)}(e,null===(n=F.current)||void 0===n?void 0:n.area)},[]);return(0,Xt.jsx)(su,{scope:n,searchRef:S,onItemEnter:s.useCallback(e=>{B(e)&&e.preventDefault()},[B]),onItemLeave:s.useCallback(e=>{var t;B(e)||(null===(t=D.current)||void 0===t||t.focus(),_(null))},[B]),onTriggerLeave:s.useCallback(e=>{B(e)&&e.preventDefault()},[B]),pointerGraceTimerRef:E,onPointerGraceIntentChange:s.useCallback(e=>{F.current=e},[]),children:(0,Xt.jsx)(T,(0,c.A)((0,c.A)({},P),{},{children:(0,Xt.jsx)(xi,{asChild:!0,trapped:r,onMountAutoFocus:ys(i,e=>{var t;e.preventDefault(),null===(t=D.current)||void 0===t||t.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,Xt.jsx)(si,{asChild:!0,disableOutsidePointerEvents:d,onEscapeKeyDown:m,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:f,onDismiss:x,children:(0,Xt.jsx)(xc,(0,c.A)((0,c.A)({asChild:!0},j),{},{dir:b.dir,orientation:"vertical",loop:a,currentTabStopId:N,onCurrentTabStopIdChange:_,onEntryFocus:ys(u,e=>{b.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,Xt.jsx)(Gl,(0,c.A)((0,c.A)((0,c.A)({role:"menu","aria-orientation":"vertical","data-state":Mu(y.open),"data-radix-menu-content":"",dir:b.dir},w),g),{},{ref:C,style:(0,c.A)({outline:"none"},g.style),onKeyDown:ys(g.onKeyDown,e=>{const t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,a=1===e.key.length;t&&("Tab"===e.key&&e.preventDefault(),!n&&a&&O(e.key));const r=D.current;if(e.target!==r)return;if(!Bd.includes(e.key))return;e.preventDefault();const s=k().filter(e=>!e.disabled).map(e=>e.ref.current);Od.includes(e.key)&&s.reverse(),function(e){const t=document.activeElement;for(const n of e){if(n===t)return;if(n.focus(),document.activeElement!==t)return}}(s)}),onBlur:ys(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(A.current),S.current="")}),onPointerMove:ys(e.onPointerMove,Vu(e=>{const t=e.target,n=I.current!==e.clientX;if(e.currentTarget.contains(t)&&n){const t=e.clientX>I.current?"right":"left";R.current=t,I.current=e.clientX}}))}))}))})})}))})});ou.displayName=ru;var mu=s.forwardRef((e,t)=>{const{__scopeMenu:n}=e,a=l(e,Nd);return(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({role:"group"},a),{},{ref:t}))});mu.displayName="MenuGroup";var pu=s.forwardRef((e,t)=>
2{const{__scopeMenu:n}=e,a=l(e,_d);return(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({},a),{},{ref:t}))});pu.displayName="MenuLabel";var hu="MenuItem",fu="menu.itemSelect",xu=s.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a}=e,r=l(e,Dd),i=s.useRef(null),o=Xd(hu,e.__scopeMenu),d=iu(hu,e.__scopeMenu),u=Xn(t,i),m=s.useRef(!1);return(0,Xt.jsx)(vu,(0,c.A)((0,c.A)({},r),{},{ref:u,disabled:n,onClick:ys(e.onClick,()=>{const e=i.current;if(!n&&e){const t=new CustomEvent(fu,{bubbles:!0,cancelable:!0});e.addEventListener(fu,e=>null===a||void 0===a?void 0:a(e),{once:!0}),Ts(e,t),t.defaultPrevented?m.current=!1:o.onClose()}}),onPointerDown:t=>{var n;null===(n=e.onPointerDown)||void 0===n||n.call(e,t),m.current=!0},onPointerUp:ys(e.onPointerUp,e=>{var t;m.current||null===(t=e.currentTarget)||void 0===t||t.click()}),onKeyDown:ys(e.onKeyDown,e=>{const t=""!==d.searchRef.current;n||t&&" "===e.key||Pd.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})}))});xu.displayName=hu;var vu=s.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r}=e,i=l(e,Cd),o=iu(hu,n),d=Kd(n),u=s.useRef(null),m=Xn(t,u),[p,h]=s.useState(!1),[f,x]=s.useState("");return s.useEffect(()=>{const e=u.current;var t;e&&x((null!==(t=e.textContent)&&void 0!==t?t:"").trim())},[i.children]),(0,Xt.jsx)(Ud.ItemSlot,{scope:n,disabled:a,textValue:null!==r&&void 0!==r?r:f,children:(0,Xt.jsx)(vc,(0,c.A)((0,c.A)({asChild:!0},d),{},{focusable:!a,children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0},i),{},{ref:m,onPointerMove:ys(e.onPointerMove,Vu(e=>{if(a)o.onItemLeave(e);else if(o.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:ys(e.onPointerLeave,Vu(e=>o.onItemLeave(e))),onFocus:ys(e.onFocus,()=>h(!0)),onBlur:ys(e.onBlur,()=>h(!1))}))}))})}),gu=s.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a}=e,r=l(e,Ad);return(0,Xt.jsx)(Du,{scope:e.__scopeMenu,checked:n,children:(0,Xt.jsx)(xu,(0,c.A)((0,c.A)({role:"menuitemcheckbox","aria-checked":zu(n)?"mixed":n},r),{},{ref:t,"data-state":Uu(n),onSelect:ys(r.onSelect,()=>null===a||void 0===a?void 0:a(!!zu(n)||!n),{checkForDefaultPrevented:!1})}))})});gu.displayName="MenuCheckboxItem";var yu="MenuRadioGroup",[bu,wu]=Wd(yu,{value:void 0,onValueChange:()=>{}}),ju=s.forwardRef((e,t)=>{const{value:n,onValueChange:a}=e,r=l(e,Sd),s=Pr(a);return(0,Xt.jsx)(bu,{scope:e.__scopeMenu,value:n,onValueChange:s,children:(0,Xt.jsx)(mu,(0,c.A)((0,c.A)({},r),{},{ref:t}))})});ju.displayName=yu;var ku="MenuRadioItem",Nu=s.forwardRef((e,t)=>{const{value:n}=e,a=l(e,Ed),r=wu(ku,e.__scopeMenu),s=n===r.value;return(0,Xt.jsx)(Du,{scope:e.__scopeMenu,checked:s,children:(0,Xt.jsx)(xu,(0,c.A)((0,c.A)({role:"menuitemradio","aria-checked":s},a),{},{ref:t,"data-state":Uu(s),onSelect:ys(a.onSelect,()=>{var e;return null===(e=r.onValueChange)||void 0===e?void 0:e.call(r,n)},{checkForDefaultPrevented:!1})}))})});Nu.displayName=ku;var _u="MenuItemIndicator",[Du,Cu]=Wd(_u,{checked:!1}),Au=s.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a}=e,r=l(e,Fd),s=Cu(_u,n);return(0,Xt.jsx)($l,{present:a||zu(s.checked)||!0===s.checked,children:(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({},r),{},{ref:t,"data-state":Uu(s.checked)}))})});Au.displayName=_u;var Su=s.forwardRef((e,t)=>{const{__scopeMenu:n}=e,a=l(e,Rd);return(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({role:"separator","aria-orientation":"horizontal"},a),{},{ref:t}))});Su.displayName="MenuSeparator";var Eu=s.forwardRef((e,t)=>{const{__scopeMenu:n}=e,a=l(e,Id),r=Gd(n);return(0,Xt.jsx)(Kl,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Eu.displayName="MenuArrow";var Fu="MenuSub",[Ru,Iu]=Wd(Fu),Tu=e=>{const{__scopeMenu:t,children:n,open:a=!1,onOpenChange:r}=e,i=Jd(Fu,t),o=Gd(t),[l,d]=s.useState(null),[u,m]=s.useState(null),p=Pr(r);return s.useEffect(()=>(!1===i.open&&p(!1),()=>p(!1)),[i.open,p]),(0,Xt.jsx)(Wl,(0,c.A)((0,c.A)({},o),{},{children:(0,Xt.jsx)(Yd,{scope:t,open:a,onOpenChange:p,content:u,onContentChange:m,children:(0,Xt.jsx)(Ru,{scope:t,contentId:_i(),triggerId:_i(),trigger:l,onTriggerChange:d,children:n})})}))};Tu.displayName=Fu;var Pu="MenuSubTrigger",Ou=s.forwardRef((e,t)=>
2{const n=Jd(Pu,e.__scopeMenu),a=Xd(Pu,e.__scopeMenu),r=Iu(Pu,e.__scopeMenu),i=iu(Pu,e.__scopeMenu),o=s.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:d}=i,u={__scopeMenu:e.__scopeMenu},m=s.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return s.useEffect(()=>m,[m]),s.useEffect(()=>{const e=l.current;return()=>{window.clearTimeout(e),d(null)}},[l,d]),(0,Xt.jsx)(Zd,(0,c.A)((0,c.A)({asChild:!0},u),{},{children:(0,Xt.jsx)(vu,(0,c.A)((0,c.A)({id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":Mu(n.open)},e),{},{ref:$n(t,r.onTriggerChange),onClick:t=>{var a;null===(a=e.onClick)||void 0===a||a.call(e,t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ys(e.onPointerMove,Vu(t=>{i.onItemEnter(t),t.defaultPrevented||e.disabled||n.open||o.current||(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:ys(e.onPointerLeave,Vu(e=>{var t;m();const a=null===(t=n.content)||void 0===t?void 0:t.getBoundingClientRect();if(a){var r;const t=null===(r=n.content)||void 0===r?void 0:r.dataset.side,s="right"===t,o=s?-5:5,c=a[s?"left":"right"],d=a[s?"right":"left"];i.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:a.top},{x:d,y:a.top},{x:d,y:a.bottom},{x:c,y:a.bottom}],side:t}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(e),e.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:ys(e.onKeyDown,t=>{const r=""!==i.searchRef.current;var s;e.disabled||r&&" "===t.key||Ld[a.dir].includes(t.key)&&(n.onOpenChange(!0),null===(s=n.content)||void 0===s||s.focus(),t.preventDefault())})}))}))});Ou.displayName=Pu;var Bu="MenuSubContent",Lu=s.forwardRef((e,t)=>{const n=nu(ru,e.__scopeMenu),{forceMount:a=n.forceMount}=e,r=l(e,Td),i=Jd(ru,e.__scopeMenu),o=Xd(ru,e.__scopeMenu),d=Iu(Bu,e.__scopeMenu),u=s.useRef(null),m=Xn(t,u);return(0,Xt.jsx)(Ud.Provider,{scope:e.__scopeMenu,children:(0,Xt.jsx)($l,{present:a||i.open,children:(0,Xt.jsx)(Ud.Slot,{scope:e.__scopeMenu,children:(0,Xt.jsx)(uu,(0,c.A)((0,c.A)({id:d.contentId,"aria-labelledby":d.triggerId},r),{},{ref:m,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{var t;o.isUsingKeyboardRef.current&&(null===(t=u.current)||void 0===t||t.focus()),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:ys(e.onFocusOutside,e=>{e.target!==d.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:ys(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:ys(e.onKeyDown,e=>{const t=e.currentTarget.contains(e.target),n=Md[o.dir].includes(e.key);var a;t&&n&&(i.onOpenChange(!1),null===(a=d.trigger)||void 0===a||a.focus(),e.preventDefault())})}))})})})});function Mu(e){return e?"open":"closed"}function zu(e){return"indeterminate"===e}function Uu(e){return zu(e)?"indeterminate":e?"checked":"unchecked"}function Vu(e){return t=>"mouse"===t.pointerType?e(t):void 0}Lu.displayName=Bu;var qu=Qd,Wu=Zd,Hu=au,Gu=ou,Ku=mu,Yu=pu,Ju=xu,$u=gu,Xu=ju,Qu=Nu,Zu=Au,em=Su,tm=Eu,nm=Ou,am=Lu;const rm=["__scopeDropdownMenu","disabled"],sm=["__scopeDropdownMenu"],im=["__scopeDropdownMenu"],om=["__scopeDropdownMenu"],lm=["__scopeDropdownMenu"],cm=["__scopeDropdownMenu"],dm=["__scopeDropdownMenu"],um=["__scopeDropdownMenu"],mm=["__scopeDropdownMenu"],pm=["__scopeDropdownMenu"],hm=["__scopeDropdownMenu"],fm=["__scopeDropdownMenu"],xm=["__scopeDropdownMenu"],vm=["__scopeDropdownMenu"];var gm="DropdownMenu",[ym,bm]=js(gm,[Hd]),wm=Hd(),[jm,km]=ym(gm),Nm=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,d=wm(t),u=s.useRef(null),[m,p]=_s({prop:r,defaultProp:null!==i&&void 0!==i&&i,onChange:o,caller:gm});return(0,Xt.jsx)(jm,{scope:t,triggerId:_i(),triggerRef:u,contentId:_i(),open:m,onOpenChange:p,onOpenToggle:s.useCallback(()=>p(e=>!e),[p]),modal:l,children:(0,Xt.jsx)(qu,(0,c.A)((0,c.A)({},d),{},{open:m,onOpenChange:p,dir:a,modal:l,children:n}))})};Nm.displayName=gm;var _m="DropdownMenuTrigger",Dm=s.forwardRef((e,t)=>
2{const{__scopeDropdownMenu:n,disabled:a=!1}=e,r=l(e,rm),s=km(_m,n),i=wm(n);return(0,Xt.jsx)(Wu,(0,c.A)((0,c.A)({asChild:!0},i),{},{children:(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":a?"":void 0,disabled:a},r),{},{ref:$n(t,s.triggerRef),onPointerDown:ys(e.onPointerDown,e=>{a||0!==e.button||!1!==e.ctrlKey||(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:ys(e.onKeyDown,e=>{a||(["Enter"," "].includes(e.key)&&s.onOpenToggle(),"ArrowDown"===e.key&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})}))}))});Dm.displayName=_m;var Cm=e=>{const{__scopeDropdownMenu:t}=e,n=l(e,sm),a=wm(t);return(0,Xt.jsx)(Hu,(0,c.A)((0,c.A)({},a),n))};Cm.displayName="DropdownMenuPortal";var Am="DropdownMenuContent",Sm=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,im),r=km(Am,n),i=wm(n),o=s.useRef(!1);return(0,Xt.jsx)(Gu,(0,c.A)((0,c.A)((0,c.A)({id:r.contentId,"aria-labelledby":r.triggerId},i),a),{},{ref:t,onCloseAutoFocus:ys(e.onCloseAutoFocus,e=>{var t;o.current||null===(t=r.triggerRef.current)||void 0===t||t.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:ys(e.onInteractOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,a=2===t.button||n;r.modal&&!a||(o.current=!0)}),style:(0,c.A)((0,c.A)({},e.style),{"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"})}))});Sm.displayName=Am;var Em=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,om),r=wm(n);return(0,Xt.jsx)(Ku,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Em.displayName="DropdownMenuGroup";var Fm=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,lm),r=wm(n);return(0,Xt.jsx)(Yu,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Fm.displayName="DropdownMenuLabel";var Rm=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,cm),r=wm(n);return(0,Xt.jsx)(Ju,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Rm.displayName="DropdownMenuItem";var Im=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,dm),r=wm(n);return(0,Xt.jsx)($u,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Im.displayName="DropdownMenuCheckboxItem";var Tm=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,um),r=wm(n);return(0,Xt.jsx)(Xu,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Tm.displayName="DropdownMenuRadioGroup";var Pm=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,mm),r=wm(n);return(0,Xt.jsx)(Qu,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Pm.displayName="DropdownMenuRadioItem";var Om=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,pm),r=wm(n);return(0,Xt.jsx)(Zu,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Om.displayName="DropdownMenuItemIndicator";var Bm=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,hm),r=wm(n);return(0,Xt.jsx)(em,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Bm.displayName="DropdownMenuSeparator";var Lm=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,fm),r=wm(n);return(0,Xt.jsx)(tm,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Lm.displayName="DropdownMenuArrow";var Mm=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,xm),r=wm(n);return(0,Xt.jsx)(nm,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});Mm.displayName="DropdownMenuSubTrigger";var zm=s.forwardRef((e,t)=>{const{__scopeDropdownMenu:n}=e,a=l(e,vm),r=wm(n);return(0,Xt.jsx)(am,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t,style:(0,c.A)((0,c.A)({},e.style),{"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"})}))});zm.displayName="DropdownMenuSubContent";var Um=Nm,Vm=Dm,qm=Cm,Wm=Sm,Hm=Fm,Gm=Rm,Km=Im,Ym=Pm,Jm=Om,$m=Bm,Xm=Mm,Qm=zm;const Zm=wn("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),ep=wn("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),tp=["className","inset","children"],np=["className"],ap=["className","sideOffset"],rp=["className","inset"],sp=["className","children","checked"],ip=["className","children"],op=["className","inset"],lp=["className"],cp=Um,dp=Vm;s.forwardRef((e,t)=>
2{let{className:n,inset:a,children:r}=e,s=l(e,tp);return(0,Xt.jsxs)(Xm,(0,c.A)((0,c.A)({ref:t,className:Sr("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a&&"pl-8",n)},s),{},{children:[r,(0,Xt.jsx)(qn,{className:"ml-auto"})]}))}).displayName=Xm.displayName;s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,np);return(0,Xt.jsx)(Qm,(0,c.A)({ref:t,className:Sr("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",n)},a))}).displayName=Qm.displayName;const up=s.forwardRef((e,t)=>{let{className:n,sideOffset:a=4}=e,r=l(e,ap);return(0,Xt.jsx)(qm,{children:(0,Xt.jsx)(Wm,(0,c.A)({ref:t,sideOffset:a,className:Sr("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",n)},r))})});up.displayName=Wm.displayName;const mp=s.forwardRef((e,t)=>{let{className:n,inset:a}=e,r=l(e,rp);return(0,Xt.jsx)(Gm,(0,c.A)({ref:t,className:Sr("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",a&&"pl-8",n)},r))});mp.displayName=Gm.displayName;s.forwardRef((e,t)=>{let{className:n,children:a,checked:r}=e,s=l(e,sp);return(0,Xt.jsxs)(Km,(0,c.A)((0,c.A)({ref:t,className:Sr("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),checked:r},s),{},{children:[(0,Xt.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,Xt.jsx)(Jm,{children:(0,Xt.jsx)(Zm,{className:"h-4 w-4"})})}),a]}))}).displayName=Km.displayName;s.forwardRef((e,t)=>{let{className:n,children:a}=e,r=l(e,ip);return(0,Xt.jsxs)(Ym,(0,c.A)((0,c.A)({ref:t,className:Sr("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n)},r),{},{children:[(0,Xt.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,Xt.jsx)(Jm,{children:(0,Xt.jsx)(ep,{className:"h-2 w-2 fill-current"})})}),a]}))}).displayName=Ym.displayName;const pp=s.forwardRef((e,t)=>{let{className:n,inset:a}=e,r=l(e,op);return(0,Xt.jsx)(Hm,(0,c.A)({ref:t,className:Sr("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",n)},r))});pp.displayName=Hm.displayName;const hp=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,lp);return(0,Xt.jsx)($m,(0,c.A)({ref:t,className:Sr("-mx-1 my-1 h-px bg-muted",n)},a))});hp.displayName=$m.displayName;const fp=["children"],xp=["children"];function vp(e){const t=gp(e),n=s.forwardRef((e,n)=>{const{children:a}=e,r=l(e,fp),i=s.Children.toArray(a),o=i.find(bp);if(o){const e=o.props.children,a=i.map(t=>t===o?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,a):null}))}return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:a}))});return n.displayName="".concat(e,".Slot"),n}function gp(e){const t=s.forwardRef((e,t)=>
2{const{children:n}=e,a=l(e,xp);if(s.isValidElement(n)){const e=function(e){var t,n;let a=null===(t=Object.getOwnPropertyDescriptor(e.props,"ref"))||void 0===t?void 0:t.get,r=a&&"isReactWarning"in a&&a.isReactWarning;if(r)return e.ref;if(a=null===(n=Object.getOwnPropertyDescriptor(e,"ref"))||void 0===n?void 0:n.get,r=a&&"isReactWarning"in a&&a.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,t){const n=(0,c.A)({},t);for(const a in t){const r=e[a],s=t[a];/^on[A-Z]/.test(a)?r&&s?n[a]=function(){const e=s(...arguments);return r(...arguments),e}:r&&(n[a]=r):"style"===a?n[a]=(0,c.A)((0,c.A)({},r),s):"className"===a&&(n[a]=[r,s].filter(Boolean).join(" "))}return(0,c.A)((0,c.A)({},e),n)}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?$n(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName="".concat(e,".SlotClone"),t}var yp=Symbol("radix.slottable");function bp(e){return s.isValidElement(e)&&"function"===typeof e.type&&"__radixId"in e.type&&e.type.__radixId===yp}const wp=["__scopeDialog"],jp=["forceMount"],kp=["__scopeDialog"],Np=["forceMount"],_p=["__scopeDialog","trapFocus","onOpenAutoFocus","onCloseAutoFocus"],Dp=["__scopeDialog"],Cp=["__scopeDialog"],Ap=["__scopeDialog"];var Sp="Dialog",[Ep,Fp]=js(Sp),[Rp,Ip]=Ep(Sp),Tp=e=>{const{__scopeDialog:t,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:o=!0}=e,l=s.useRef(null),c=s.useRef(null),[d,u]=_s({prop:a,defaultProp:null!==r&&void 0!==r&&r,onChange:i,caller:Sp});return(0,Xt.jsx)(Rp,{scope:t,triggerRef:l,contentRef:c,contentId:_i(),titleId:_i(),descriptionId:_i(),open:d,onOpenChange:u,onOpenToggle:s.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};Tp.displayName=Sp;var Pp="DialogTrigger",Op=s.forwardRef((e,t)=>{const{__scopeDialog:n}=e,a=l(e,wp),r=Ip(Pp,n),s=Xn(t,r.triggerRef);return(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":nh(r.open)},a),{},{ref:s,onClick:ys(e.onClick,r.onOpenToggle)}))});Op.displayName=Pp;var Bp="DialogPortal",[Lp,Mp]=Ep(Bp,{forceMount:void 0}),zp=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Ip(Bp,t);return(0,Xt.jsx)(Lp,{scope:t,forceMount:n,children:s.Children.map(a,e=>(0,Xt.jsx)($l,{present:n||i.open,children:(0,Xt.jsx)(Jl,{asChild:!0,container:r,children:e})}))})};zp.displayName=Bp;var Up="DialogOverlay",Vp=s.forwardRef((e,t)=>{const n=Mp(Up,e.__scopeDialog),{forceMount:a=n.forceMount}=e,r=l(e,jp),s=Ip(Up,e.__scopeDialog);return s.modal?(0,Xt.jsx)($l,{present:a||s.open,children:(0,Xt.jsx)(Wp,(0,c.A)((0,c.A)({},r),{},{ref:t}))}):null});Vp.displayName=Up;var qp=vp("DialogOverlay.RemoveScroll"),Wp=s.forwardRef((e,t)=>{const{__scopeDialog:n}=e,a=l(e,kp),r=Ip(Up,n);return(0,Xt.jsx)(bd,{as:qp,allowPinchZoom:!0,shards:[r.contentRef],children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({"data-state":nh(r.open)},a),{},{ref:t,style:(0,c.A)({pointerEvents:"auto"},a.style)}))})}),Hp="DialogContent",Gp=s.forwardRef((e,t)=>{const n=Mp(Hp,e.__scopeDialog),{forceMount:a=n.forceMount}=e,r=l(e,Np),s=Ip(Hp,e.__scopeDialog);return(0,Xt.jsx)($l,{present:a||s.open,children:s.modal?(0,Xt.jsx)(Kp,(0,c.A)((0,c.A)({},r),{},{ref:t})):(0,Xt.jsx)(Yp,(0,c.A)((0,c.A)({},r),{},{ref:t}))})});Gp.displayName=Hp;var Kp=s.forwardRef((e,t)=>{const n=Ip(Hp,e.__scopeDialog),a=s.useRef(null),r=Xn(t,n.contentRef,a);return s.useEffect(()=>{const e=a.current;if(e)return Fc(e)},[]),(0,Xt.jsx)(Jp,(0,c.A)((0,c.A)({},e),{},{ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ys(e.onCloseAutoFocus,e=>{var t;e.preventDefault(),null===(t=n.triggerRef.current)||void 0===t||t.focus()}),onPointerDownOutside:ys(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:ys(e.onFocusOutside,e=>e.preventDefault())}))}),Yp=s.forwardRef((e,t)=>{const n=Ip(Hp,e.__scopeDialog),a=s.useRef(!1),r=s.useRef(!1);return(0,Xt.jsx)(Jp,(0,c.A)((0,c.A)({},e),{},{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var s,i;(null===(s=e.onCloseAutoFocus)||void 0===s||s.call(e,t),t.defaultPrevented)||(a.current||null===(i=n.triggerRef.current)||void 0===i||i.focus(),t.preventDefault());a.current=!1,r.current=!1},onInteractOutside:t=>{var s,i;null===(s=e.onInteractOutside)||void 0===s||s.call(e,t),t.defaultPrevented||(a.current=!0,"pointerdown"===t.detail.originalEvent.type&&(r.current=!0));const o=t.target;(null===(i=n.triggerRef.current)||void 0===i?void 0:i.contains(o))&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&r.current&&t.preventDefault()}}))}),Jp=s.forwardRef((e,t)=>
2{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i}=e,o=l(e,_p),d=Ip(Hp,n),u=s.useRef(null),m=Xn(t,u);return di(),(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(xi,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:(0,Xt.jsx)(si,(0,c.A)((0,c.A)({role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":nh(d.open)},o),{},{ref:m,onDismiss:()=>d.onOpenChange(!1)}))}),(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(ih,{titleId:d.titleId}),(0,Xt.jsx)(oh,{contentRef:u,descriptionId:d.descriptionId})]})]})}),$p="DialogTitle",Xp=s.forwardRef((e,t)=>{const{__scopeDialog:n}=e,a=l(e,Dp),r=Ip($p,n);return(0,Xt.jsx)(Is.h2,(0,c.A)((0,c.A)({id:r.titleId},a),{},{ref:t}))});Xp.displayName=$p;var Qp="DialogDescription",Zp=s.forwardRef((e,t)=>{const{__scopeDialog:n}=e,a=l(e,Cp),r=Ip(Qp,n);return(0,Xt.jsx)(Is.p,(0,c.A)((0,c.A)({id:r.descriptionId},a),{},{ref:t}))});Zp.displayName=Qp;var eh="DialogClose",th=s.forwardRef((e,t)=>{const{__scopeDialog:n}=e,a=l(e,Ap),r=Ip(eh,n);return(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button"},a),{},{ref:t,onClick:ys(e.onClick,()=>r.onOpenChange(!1))}))});function nh(e){return e?"open":"closed"}th.displayName=eh;var ah="DialogTitleWarning",[rh,sh]=function(e,t){const n=s.createContext(t),a=e=>{const{children:t}=e,a=l(e,bs),r=s.useMemo(()=>a,Object.values(a));return(0,Xt.jsx)(n.Provider,{value:r,children:t})};return a.displayName=e+"Provider",[a,function(a){const r=s.useContext(n);if(r)return r;if(void 0!==t)return t;throw new Error("`".concat(a,"` must be used within `").concat(e,"`"))}]}(ah,{contentName:Hp,titleName:$p,docsSlug:"dialog"}),ih=e=>{let{titleId:t}=e;const n=sh(ah),a="`".concat(n.contentName,"` requires a `").concat(n.titleName,"` for the component to be accessible for screen reader users.\n\nIf you want to hide the `").concat(n.titleName,"`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/").concat(n.docsSlug);return s.useEffect(()=>{if(t){document.getElementById(t)||console.error(a)}},[a,t]),null},oh=e=>{let{contentRef:t,descriptionId:n}=e;const a=sh("DialogDescriptionWarning"),r="Warning: Missing `Description` or `aria-describedby={undefined}` for {".concat(a.contentName,"}.");return s.useEffect(()=>{var e;const a=null===(e=t.current)||void 0===e?void 0:e.getAttribute("aria-describedby");if(n&&a){document.getElementById(n)||console.warn(r)}},[r,t,n]),null},lh=Tp,ch=Op,dh=zp,uh=Vp,mh=Gp,ph=Xp,hh=Zp,fh=th;const xh=wn("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),vh=["className"],gh=["side","className","children"],yh=["className"],bh=["className"],wh=["className"],jh=["className"],kh=lh,Nh=ch,_h=dh,Dh=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,vh);return(0,Xt.jsx)(uh,(0,c.A)((0,c.A)({className:Sr("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n)},a),{},{ref:t}))});Dh.displayName=uh.displayName;const Ch=pa("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Ah=s.forwardRef((e,t)=>{let{side:n="right",className:a,children:r}=e,s=l(e,gh);return(0,Xt.jsxs)(_h,{children:[(0,Xt.jsx)(Dh,{}),(0,Xt.jsxs)(mh,(0,c.A)((0,c.A)({ref:t,className:Sr(Ch({side:n}),a)},s),{},{children:[(0,Xt.jsxs)(fh,{className:"absolute right-4 top-4 roun
2ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,Xt.jsx)(xh,{className:"h-4 w-4"}),(0,Xt.jsx)("span",{className:"sr-only",children:"Close"})]}),r]}))]})});Ah.displayName=mh.displayName;const Sh=e=>{let{className:t}=e,n=l(e,yh);return(0,Xt.jsx)("div",(0,c.A)({className:Sr("flex flex-col space-y-2 text-center sm:text-left",t)},n))};Sh.displayName="SheetHeader";const Eh=e=>{let{className:t}=e,n=l(e,bh);return(0,Xt.jsx)("div",(0,c.A)({className:Sr("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t)},n))};Eh.displayName="SheetFooter";const Fh=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,wh);return(0,Xt.jsx)(ph,(0,c.A)({ref:t,className:Sr("text-lg font-semibold text-foreground",n)},a))});Fh.displayName=ph.displayName;const Rh=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,jh);return(0,Xt.jsx)(hh,(0,c.A)({ref:t,className:Sr("text-sm text-muted-foreground",n)},a))});Rh.displayName=hh.displayName;var Ih=Symbol("radix.slottable");function Th(e){const t=e=>{let{children:t}=e;return(0,Xt.jsx)(Xt.Fragment,{children:t})};return t.displayName="".concat(e,".Slottable"),t.__radixId=Ih,t}var Ph=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Oh=s.forwardRef((e,t)=>(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({},e),{},{ref:t,style:(0,c.A)((0,c.A)({},Ph),e.style)})));Oh.displayName="VisuallyHidden";var Bh=Oh;const Lh=["__scopeTooltip"],Mh=["forceMount","side"],zh=["__scopeTooltip","children","aria-label","onEscapeKeyDown","onPointerDownOutside"],Uh=["__scopeTooltip"];var[Vh,qh]=js("Tooltip",[Al]),Wh=Al(),Hh="TooltipProvider",Gh=700,Kh="tooltip.open",[Yh,Jh]=Vh(Hh),$h=e=>{const{__scopeTooltip:t,delayDuration:n=Gh,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=e,o=s.useRef(!0),l=s.useRef(!1),c=s.useRef(0);return s.useEffect(()=>{const e=c.current;return()=>window.clearTimeout(e)},[]),(0,Xt.jsx)(Yh,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:s.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:s.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,a)},[a]),isPointerInTransitRef:l,onPointerInTransitChange:s.useCallback(e=>{l.current=e},[]),disableHoverableContent:r,children:i})};$h.displayName=Hh;var Xh="Tooltip",[Qh,Zh]=Vh(Xh),ef=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:o,delayDuration:l}=e,d=Jh(Xh,e.__scopeTooltip),u=Wh(t),[m,p]=s.useState(null),h=_i(),f=s.useRef(0),x=null!==o&&void 0!==o?o:d.disableHoverableContent,v=null!==l&&void 0!==l?l:d.delayDuration,g=s.useRef(!1),[y,b]=_s({prop:a,defaultProp:null!==r&&void 0!==r&&r,onChange:e=>{e?(d.onOpen(),document.dispatchEvent(new CustomEvent(Kh))):d.onClose(),null===i||void 0===i||i(e)},caller:Xh}),w=s.useMemo(()=>y?g.current?"delayed-open":"instant-open":"closed",[y]),j=s.useCallback(()=>{window.clearTimeout(f.current),f.current=0,g.current=!1,b(!0)},[b]),k=s.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),N=s.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{g.current=!0,b(!0),f.current=0},v)},[v,b]);return s.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),(0,Xt.jsx)(Wl,(0,c.A)((0,c.A)({},u),{},{children:(0,Xt.jsx)(Qh,{scope:t,contentId:h,open:y,stateAttribute:w,trigger:m,onTriggerChange:p,onTriggerEnter:s.useCallback(()=>{d.isOpenDelayedRef.current?N():j()},[d.isOpenDelayedRef,N,j]),onTriggerLeave:s.useCallback(()=>{x?k():(window.clearTimeout(f.current),f.current=0)},[k,x]),onOpen:j,onClose:k,disableHoverableContent:x,children:n})}))};ef.displayName=Xh;var tf="TooltipTrigger",nf=s.forwardRef((e,t)=>{const{__scopeTooltip:n}=e,a=l(e,Lh),r=Zh(tf,n),i=Jh(tf,n),o=Wh(n),d=Xn(t,s.useRef(null),r.onTriggerChange),u=s.useRef(!1),m=s.useRef(!1),p=s.useCallback(()=>u.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),(0,Xt.jsx)(Hl,(0,c.A)((0,c.A)({asChild:!0},o),{},{children:(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute},a),{},{ref:d,onPointerMove:ys(e.onPointerMove,e=>{"touch"!==e.pointerType&&(m.current||i.isPointerInTransitRef.current||(r.onTriggerEnter(),m.current=!0))}),onPointerLeave:ys(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:ys(e.onPointerDown,()=>{r.open&&r.onClose(),u.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ys(e.onFocus,()=>{u.current||r.onOpen()}),onBlur:ys(e.onBlur,r.onClose),onClick:ys(e.onClick,r.onClose)}))}))});nf.displayName=tf;var af="TooltipPortal",[rf,sf]=Vh(af,{forceMount:void 0}),of=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,s=Zh(af,t);return(0,Xt.jsx)(rf,{scope:t,forceMount:n,children:(0,Xt.jsx)($l,{present:n||s.open,children:(0,Xt.jsx)(Jl,{asChild:!0,container:r,children:a})})})};of.displayName=af;var lf="TooltipContent",cf=s.forwardRef((e,t)=>
2{const n=sf(lf,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top"}=e,s=l(e,Mh),i=Zh(lf,e.__scopeTooltip);return(0,Xt.jsx)($l,{present:a||i.open,children:i.disableHoverableContent?(0,Xt.jsx)(hf,(0,c.A)((0,c.A)({side:r},s),{},{ref:t})):(0,Xt.jsx)(df,(0,c.A)((0,c.A)({side:r},s),{},{ref:t}))})}),df=s.forwardRef((e,t)=>{const n=Zh(lf,e.__scopeTooltip),a=Jh(lf,e.__scopeTooltip),r=s.useRef(null),i=Xn(t,r),[o,l]=s.useState(null),{trigger:d,onClose:u}=n,m=r.current,{onPointerInTransitChange:p}=a,h=s.useCallback(()=>{l(null),p(!1)},[p]),f=s.useCallback((e,t)=>{const n=e.currentTarget,a={x:e.clientX,y:e.clientY},r=function(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,a,r,s)){case s:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}(a,n.getBoundingClientRect()),s=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return a}(a,r),i=function(e){const t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),function(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const n=e[a];for(;t.length>=2;){const e=t[t.length-1],a=t[t.length-2];if(!((e.x-a.x)*(n.y-a.y)>=(e.y-a.y)*(n.x-a.x)))break;t.pop()}t.push(n)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const t=e[a];for(;n.length>=2;){const e=n[n.length-1],a=n[n.length-2];if(!((e.x-a.x)*(t.y-a.y)>=(e.y-a.y)*(t.x-a.x)))break;n.pop()}n.push(t)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...s,...function(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}(t.getBoundingClientRect())]);l(i),p(!0)},[p]);return s.useEffect(()=>()=>h(),[h]),s.useEffect(()=>{if(d&&m){const e=e=>f(e,m),t=e=>f(e,d);return d.addEventListener("pointerleave",e),m.addEventListener("pointerleave",t),()=>{d.removeEventListener("pointerleave",e),m.removeEventListener("pointerleave",t)}}},[d,m,f,h]),s.useEffect(()=>{if(o){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},a=(null===d||void 0===d?void 0:d.contains(t))||(null===m||void 0===m?void 0:m.contains(t)),r=!function(e,t){const{x:n,y:a}=e;let r=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const e=t[s],o=t[i],l=e.x,c=e.y,d=o.x,u=o.y;c>a!==u>a&&n<(d-l)*(a-c)/(u-c)+l&&(r=!r)}return r}(n,o);a?h():r&&(h(),u())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[d,m,o,u,h]),(0,Xt.jsx)(hf,(0,c.A)((0,c.A)({},e),{},{ref:i}))}),[uf,mf]=Vh(Xh,{isInside:!1}),pf=Th("TooltipContent"),hf=s.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:o}=e,d=l(e,zh),u=Zh(lf,n),m=Wh(n),{onClose:p}=u;return s.useEffect(()=>(document.addEventListener(Kh,p),()=>document.removeEventListener(Kh,p)),[p]),s.useEffect(()=>{if(u.trigger){const e=e=>{const t=e.target;null!==t&&void 0!==t&&t.contains(u.trigger)&&p()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[u.trigger,p]),(0,Xt.jsx)(si,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:p,children:(0,Xt.jsxs)(Gl,(0,c.A)((0,c.A)((0,c.A)({"data-state":u.stateAttribute},m),d),{},{ref:t,style:(0,c.A)((0,c.A)({},d.style),{"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"}),children:[(0,Xt.jsx)(pf,{children:a}),(0,Xt.jsx)(uf,{scope:n,isInside:!0,children:(0,Xt.jsx)(Bh,{id:u.contentId,role:"tooltip",children:r||a})})]}))})});cf.displayName=lf;var ff="TooltipArrow",xf=s.forwardRef((e,t)=>
2{const{__scopeTooltip:n}=e,a=l(e,Uh),r=Wh(n);return mf(ff,n).isInside?null:(0,Xt.jsx)(Kl,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});xf.displayName=ff;var vf=of,gf=cf;const yf=["className","sideOffset"],bf=$h,wf=ef,jf=nf,kf=s.forwardRef((e,t)=>{let{className:n,sideOffset:a=4}=e,r=l(e,yf);return(0,Xt.jsx)(vf,{children:(0,Xt.jsx)(gf,(0,c.A)({ref:t,sideOffset:a,className:Sr("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",n)},r))})});function Nf(e,t){if(!e||"object"!==typeof e)return null;const n=e[t];return"number"===typeof n&&Number.isFinite(n)&&n>=0?n:null}function _f(e){let{includedUsageRemaining:t,extraUsageRemaining:n}=e;return"number"!==typeof t&&"number"!==typeof n?null:(Number(t)||0)+(Number(n)||0)}function Df(e){return"focus"===e||"flow"===e}function Cf(e){let{planCode:t,includedUsageRemaining:n,extraUsageRemaining:a,cost:r}=e;if(!Df(t))return!1;if("number"!==typeof r||r<=0)return!1;const s=_f({includedUsageRemaining:n,extraUsageRemaining:a});return"number"===typeof s&&s<r}function Af(e){return"number"===typeof e&&Number.isFinite(e)?e.toLocaleString("en-US"):"\u2014"}function Sf(e){const t=Nf(e,"analyze_fit"),n=Nf(e,"cv_improve"),a=Nf(e,"cover_letter");if(null===t||null===n||null===a)return null;const r=t+n+a;return r>0?r:null}kf.displayName=gf.displayName;const Ef={planCode:null,status:null,hasEntitlement:!1,includedUsageRemaining:null,extraUsageRemaining:null,usageCosts:null,freeFit:null,loading:!1,refresh:()=>{}},Ff=(0,s.createContext)(Ef);function Rf(e){let{children:t}=e;const[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(!1),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(null),[p,h]=(0,s.use
2State)(null),[f,x]=(0,s.useState)(null),[v,g]=(0,s.useState)(!1),y=be(),b=(0,s.useRef)(0),w=(0,s.useCallback)(async()=>{g(!0);try{const[e,t]=await Promise.allSettled([(0,zt.n)("/api/account/plan"),(0,zt.n)("/api/jobs/analyze-fit/usage")]);if("fulfilled"===e.status){const t=e.value||{};a(t.plan_code||null),i(t.status||null),l(!!t.has_entitlement),d("number"===typeof t.included_usage_remaining?t.included_usage_remaining:null),m("number"===typeof t.extra_usage_remaining?t.extra_usage_remaining:null);const n=t.usage_costs;if(n&&"object"===typeof n){const e={};for(const[t,a]of Object.entries(n))"number"===typeof a&&Number.isFinite(a)&&a>=0&&(e[t]=a);h(Object.keys(e).length?e:null)}}if("fulfilled"===t.status){const e=t.value||{},n=Number(e.limit),a=Number(e.used),r=Number(e.remaining);[n,a,r].every(Number.isFinite)&&x({limit:n,used:a,remaining:r,reset_at_utc:e.reset_at_utc||null,plan:e.plan||null})}b.current=Date.now()}catch(e){}finally{g(!1)}},[]),j=(0,s.useCallback)(async()=>{b.current=0,await w()},[w]);(0,s.useEffect)(()=>{Date.now()-b.current>=6e4&&w()},[w,y.pathname]);const k=(0,s.useMemo)(()=>({planCode:n,status:r,hasEntitlement:o,includedUsageRemaining:c,extraUsageRemaining:u,usageCosts:p,freeFit:f,loading:v,refresh:j}),[n,r,o,c,u,p,f,v,j]);return(0,Xt.jsx)(Ff.Provider,{value:k,children:t})}function If(){return(0,s.useContext)(Ff)}function Tf(){const{planCode:e,includedUsageRemaining:t,extraUsageRemaining:n,freeFit:a,loading:r}=If();if(null==e)return(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-md border border-ndor-edge bg-ndor-surface-alt/40 text-[11px] whitespace-nowrap","data-testid":"credits-balance-pill","data-state":r?"loading":"empty","aria-label":"Plan and usage ledger (loading)",children:[(0,Xt.jsx)(Un,{className:"h-3.5 w-3.5 text-ndor-ink-muted shrink-0","aria-hidden":!0}),(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-ink-muted","data-testid":"credits-pill-skeleton",children:"\u2026"})]});const s=Df(e),i=function(e){return e&&"string"===typeof e?e.charAt(0).toUpperCase()+e.slice(1):null}(e),o=Af(t),l=Af(n),c=Af(("number"===typeof t?t:0)+("number"===typeof n?n:0)),d="number"===typeof(null===a||void 0===a?void 0:a.remaining)?a.remaining:null,u="number"===typeof(null===a||void 0===a?void 0:a.limit)?a.limit:null,m=!s&&null!=d&&null!=u,p=(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium mb-1",children:"Account ledger"}),(0,Xt.jsxs)("p",{className:"text-ndor-ink-secondary leading-relaxed",children:[i&&(0,Xt.jsxs)(Xt.Fragment,{children:["Plan: ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:i}),(0,Xt.jsx)("br",{})]}),s?(0,Xt.jsxs)(Xt.Fragment,{children:["Total Credits: ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:c}),(0,Xt.jsx)("br",{}),(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted text-[11px]",children:["(",o," plan + ",l," top-up)"]})]}):(0,Xt.jsxs)(Xt.Fragment,{children:["Free Analyse Fits today:"," ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:null!=d?"".concat(d,"/").concat(u):"\u2014"}),(0,Xt.jsx)("br",{}),"Top-up Credits: ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:l})]})]}),(0,Xt.jsx)("p",{className:"text-ndor-ink-muted mt-1.5 text-[10px]",children:"Click to manage your plan and top up."})]});return(0,Xt.jsxs)(wf,{children:[(0,Xt.jsx)(jf,{asChild:!0,children:(0,Xt.jsxs)(Et,{to:"/account?tab=plan",className:"inline-flex items-center gap-1.5 sm:gap-2 px-2 sm:px-2.5 py-1 rounded-md border border-ndor-edge bg-ndor-surface-alt/60 hover:bg-ndor-surface-alt hover:border-ndor-gold/40 transition-colors text-[11px] whitespace-nowrap max-w-full","data-testid":"credits-balance-pill","data-plan-code":e||"","data-included-remaining":"number"===typeof t?String(t):"","data-extra-remaining":"number"===typeof n?String(n):"","aria-label":"Plan and usage ledger",children:[(0,Xt.jsx)(Un,{className:"h-3.5 w-3.5 text-ndor-gold shrink-0","aria-hidden":!0}),i&&(0,Xt.jsxs)("span",{className:"hidden sm:inline-flex items-baseline gap-1",children:[(0,Xt.jsx)("span",{className:"font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted text-[10px]",children:"Plan"}),(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium","data-testid":"credits-pill-plan",children:i}),(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"\xb7"})]}),s?(0,Xt.jsxs)("span",{className:"inline-flex items-baseline gap-1",children:[(0,Xt.jsx)("span",{className:"font-mono-ui uppercase tracking-[0.14em] sm:tracking-[0.16em] text-ndor-ink-muted text-[10px]",children:"Credits"}),(0,Xt.jsx)("span",{className:"text-ndor-ink font-mono-ui font-semibold","data-testid":"credits-pill-total",children:c})]}):(0,Xt.jsxs)(Xt.Fragment,{children:[m&&(0,Xt.jsxs)("span",{className:"inline-flex items-baseline gap-1",children:[(0,Xt.jsxs)("span",{className:"font-mono-ui uppercase tracking-[0.14em] sm:tracking-[0.16em] text-ndor-ink-muted text-[10px]",children:[(0,Xt.jsx)("span",{className:"hidden sm:inline",children:"Free fits today"}),(0,Xt.jsx)("span",{className:"sm:hidden",children:"Free"})]}),(0,Xt.jsxs)("span",{className:d>0?"text-ndor-success font-mono-ui font-semibold":"text-ndor-ink-muted font-mono-ui","data-testid":"credits-pill-free-remaining",children:[d,"/",u]})]}),(0,Xt.jsxs)("span",{className:"hidden md:inline-flex items-baseline gap-1 pl-2 ml-1 border-l border-ndor-edge",children:[(0,Xt.jsx)("span",{className:"font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted text-[10px]",children:"Credits left"}),(0,Xt.jsx)("span",{className:"text-ndor-ink font-mono-ui font-semibold","data-testid":"credits-pill-extra",children:l})]})]})]})}),(0,Xt.jsx)(kf,{side:"bottom",className:"bg-ndor-surface border border-ndor-edge text-xs max-w-[280px]",children:p})]})}const Pf={starter:"Starter",professional:"Professional",business:"Business",enterprise:"Enterprise"},Of={starter:"Free baseline \xb7 evaluation layer",professional:"Active recruiting teams",business:"Scale-stage hiring teams",enterprise:"Admin-provisioned \xb7 institutional deployment"};function Bf(e){return e?Pf[e]||e:"Starter"}function Lf(e){return e?Of[e]||"":"Free baseline \xb7 evaluation layer"}function Mf(){var e,t,n;
2const[a,r]=(0,s.useState)(null),[i,o]=(0,s.useState)(!0),[l,c]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{const t=await(0,zt.n)("/api/employer/v1/plan");e||(r(t||null),c(!1))}catch(mK){e||(r(null),c(404===(null===mK||void 0===mK?void 0:mK.status)))}finally{e||o(!1)}})(),()=>{e=!0}},[]);const d=(null===a||void 0===a?void 0:a.entitlement)||null,u=(null===a||void 0===a?void 0:a.active_plan)||null,m=(null===d||void 0===d?void 0:d.plan_tier)||(null===u||void 0===u?void 0:u.plan_tier)||null,p=Bf(m),h=Lf(m),f=null!==(e=null!==(t=null===d||void 0===d?void 0:d.active_roles_cap)&&void 0!==t?t:null===u||void 0===u?void 0:u.active_roles_cap)&&void 0!==e?e:null,x=null!==(n=null===d||void 0===d?void 0:d.active_roles_current)&&void 0!==n?n:null;let v;if(d)if(null===f)v="Unlimited active roles";else{const e=null===x||void 0===x?0:Number(x),t=Math.max(0,Number(f)-e),n=1===t?"role":"roles";v="".concat(t," active ").concat(n," available")}else v="Usage inactive";if(i)return(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-md border border-ndor-edge bg-ndor-surface-alt/40 text-[11px] whitespace-nowrap","data-testid":"employer-plan-pill","data-state":"loading","aria-label":"Employer plan and usage (loading)",children:[(0,Xt.jsx)(Pn,{className:"h-3.5 w-3.5 text-ndor-ink-muted shrink-0","aria-hidden":!0}),(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-ink-muted",children:"\u2026"})]});if(l||!a)return null;const g=(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium mb-1",children:"Account & usage"}),(0,Xt.jsxs)("p",{className:"text-ndor-ink-secondary leading-relaxed",children:["Plan: ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:p}),h&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("br",{}),(0,Xt.jsx)("span",{className:"text-ndor-ink-muted text-[11px]",children:h})]}),(0,Xt.jsx)("br",{}),"Roles left:"," ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:v})]})]});return(0,Xt.jsxs)(wf,{children:[(0,Xt.jsx)(jf,{asChild:!0,children:(0,Xt.jsxs)(Et,{to:"/employer/account",className:"inline-flex items-center gap-1.5 sm:gap-2 px-2 sm:px-2.5 py-1 rounded-md border border-ndor-edge bg-ndor-surface-alt/60 hover:bg-ndor-surface-alt hover:border-ndor-gold/40 transition-colors text-[11px] whitespace-nowrap max-w-full","data-testid":"employer-plan-pill","data-plan-tier":m||"","aria-label":"Employer plan and usage",children:[(0,Xt.jsx)(Pn,{className:"h-3.5 w-3.5 text-ndor-gold shrink-0","aria-hidden":!0}),(0,Xt.jsxs)("span",{className:"inline-flex items-baseline gap-1",children:[(0,Xt.jsx)("span",{className:"hidden sm:inline font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted text-[10px]",children:"Plan"}),(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium","data-testid":"employer-plan-pill-tier",children:p})]})]})}),(0,Xt.jsx)(kf,{side:"bottom",className:"bg-ndor-surface border border-ndor-edge text-xs max-w-[280px]",children:g})]})}const zf=wn("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),Uf="rc_1_47_5_ui";function Vf(){if("false"==={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:"443",FAST_REFRESH:!0,REACT_APP_BACKEND_URL:"https://app.ndorflow.app",REACT_APP_SUPABASE_URL:"https://gxrskeymwyxkeadshzla.supabase.co",REACT_APP_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imd4cnNrZXltd3l4a2VhZHNoemxhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzU5OTEwMzIsImV4cCI6MjA5MTU2NzAzMn0.OUOJuRn9KdjSh2B3zls3Hn6cQm-zUq2fcUQZf4GRiKM",REACT_APP_STRIPE_TEST_MODE:"false",REACT_APP_WORKSPACE_MODE_ENABLED:"true",REACT_APP_EMPLOYER_SIGNUPS_ENABLED:"true"}.REACT_APP_RC_1_47_5_CANONICAL_FIT_UI)return!1;const e=function(){if("undefined"===typeof window)return null;try{const e=new URLSearchParams(window.location.search).get("rc_1_47_5");if("off"===e||"on"===e)return e}catch(e){}return null}();if(null!==e)return function(e){if("undefined"!==typeof window)try{window.localStorage.setItem(Uf,JSON.stringify({value:e,set_at:Date.now()}))}catch(t){}}(e),"on"===e;const t=function(){if("undefined"===typeof window)return null;try{const e=window.localStorage.getItem(Uf);if(!e)return null;const t=JSON.parse(e);return t&&"object"===typeof t?Date.now()-(t.set_at||0)>864e5?null:"off"===t.value?"off":"on":null}catch(e){return null}}();return null===t||"on"===t}function qf(){return Vf()?(0,Xt.jsxs)(kh,{children:[(0,Xt.jsx)(Nh,{asChild:!0,children:(0,Xt.jsxs)(Rr,{variant:"ghost",size:"sm","aria-label":"What is \\u00b15?","data-testid":"score-variance-help-trigger",className:" inline-flex items-center gap-1.5 px-2 py-1 text-xs text-ndor-ink-secondary hover:text-ndor-ink hover:bg-ndor-surface-alt rounded-md ",children:[(0,Xt.jsx)(zf,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,Xt.jsx)("span",{className:"hidden md:inline",children:"What is \xb15?"}),(0,Xt.jsx)("span",{className:"md:hidden font-mono-ui",children:"\xb15"})]})}),(0,Xt.jsxs)(Ah,{side:"right",className:"w-full sm:max-w-md overflow-y-auto","data-testid":"score-variance-help-drawer",children:[(0,Xt.jsx)(Sh,{className:"text-left",children:(0,Xt.jsx)(Fh,{className:"text-lg font-medium",children:"What does \u201c\xb15\u201d mean on NDORFlow scores?"})}),(0,Xt.jsxs)("div",{className:"mt-6 space-y-5 text-sm leading-relaxed text-ndor-ink",children:[(0,Xt.jsx)("section",{className:"rounded-md border border-ndor-edge bg-muted/30 p-4",children:(0,Xt.jsx)("p",{className:"text-ndor-ink",children:"NDOR scores are directional assessments. Small movements within \xb15 points are typically not materially significant and may reflect normal scoring variance rather than meaningful candidate deterioration."})}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)("h3",{className:"text-xs uppercase tracking-wide text-ndor-ink-secondary",children:"Directional, not arithmetic"}),(0,Xt.jsxs)("p",{className:"text-ndor-ink-muted",children:["Every NDOR score \u2014 Overall Fit, NDOR CV verdict, sub-scores \u2014 is a",(0,Xt.jsx)("em",{children:" directional assessment"})," produced by independent grader passes against a fixed rubric. It is not a measurement on a calibrated instrument. The same candidate, CV and job description can score 76 on one run and 78 on another without anything materially changing about the candidate's fit."]})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)("h3",{className:"text-xs uppercase tracking-wide text-ndor-ink-secondary",children:"Why \xb15?"}),(0,Xt.jsx)("p",{className:"text-ndor-ink-muted",children:"From observed run-to-run dispersion across thousands of grading passes, NDOR scores typically fluctuate within a five-point band even when the underlying evidence is unchanged. A drift of 1\u20135 points in either direction is normal noise, not a signal."})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)("h3",{className:"text-xs uppercase tracking-wide text-ndor-ink-secondary",children:"How to read score changes"}),(0,Xt.jsxs)("ul",{className:"space-y-1.5 text-ndor-ink-muted",children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"|\u0394|\xa0\u2264\xa05"}),"\xa0\u2014 treat as steady-state. The candidate's position has not materially changed."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"|\u0394|\xa06\u20139"}),"\xa0\u2014 meaningful directional movement. Worth investigating but not dramatic."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"|\u0394|\xa0\u2265\xa010"}),"\xa0\u2014 strong signal. Examine the strongest evidence shifts in the reasoning panel."]})]})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)("h3",{className:"text-xs uppercase tracking-wide text-ndor-ink-secondary",children:"How NDORFlow uses this internally"}),(0,Xt.jsxs)("p",{className:"text-ndor-ink-muted",children:["The platform's tolerance governance treats the same band as material: when a Tailored Variant's NDOR CV verdict moves within \xb15 of its Source baseline, the post-generation charge is automatically waived as",(0,Xt.jsx)("em",{children:" \u201cwithin NDOR confidence band\u201d"}),". Material improvement is recognised only when the verdict moves at least six points above the baseline. Refunds, free-rebuild rules and pack canonical fit all use the same band s
2o user-visible numbers and operator-side governance stay aligned."]})]}),(0,Xt.jsx)("section",{className:"rounded-md border border-ndor-edge bg-muted/20 p-4",children:(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"NDORFlow surfaces the \xb15 band on every fit number and verdict so you never have to guess whether a small movement is meaningful. The score itself remains canonical and unchanged \u2014 the band is interpretive framing, not a recalculation."})})]})]})]}):null}function Wf(e){let{variant:t="full",size:n,className:a="",testId:r}=e;if("symbol"===t){const e=n||32;return(0,Xt.jsx)("img",{src:"/ndorflow-symbol-512.png",alt:"NDORFlow",width:e,height:e,style:{width:e,height:e,objectFit:"contain"},className:a,"data-testid":r||"brand-symbol",draggable:!1})}const s=n||52;return(0,Xt.jsx)("img",{src:"/ndorflow-full.png",alt:"NDORFlow \u2014 Decision Intelligence",style:{height:s,width:"auto",objectFit:"contain"},className:a,"data-testid":r||"brand-full",draggable:!1})}function Hf(e,t){let[n,a]=t;return Math.min(a,Math.max(n,e))}const Gf=["children"],Kf=["children"];function Yf(e){const t=Jf(e),n=s.forwardRef((e,n)=>{const{children:a}=e,r=l(e,Gf),i=s.Children.toArray(a),o=i.find(Xf);if(o){const e=o.props.children,a=i.map(t=>t===o?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,a):null}))}return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:a}))});return n.displayName="".concat(e,".Slot"),n}function Jf(e){const t=s.forwardRef((e,t)=>{const{children:n}=e,a=l(e,Kf);if(s.isValidElement(n)){const e=function(e){var t,n;let a=null===(t=Object.getOwnPropertyDescriptor(e.props,"ref"))||void 0===t?void 0:t.get,r=a&&"isReactWarning"in a&&a.isReactWarning;if(r)return e.ref;if(a=null===(n=Object.getOwnPropertyDescriptor(e,"ref"))||void 0===n?void 0:n.get,r=a&&"isReactWarning"in a&&a.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,t){const n=(0,c.A)({},t);for(const a in t){const r=e[a],s=t[a];/^on[A-Z]/.test(a)?r&&s?n[a]=function(){const e=s(...arguments);return r(...arguments),e}:r&&(n[a]=r):"style"===a?n[a]=(0,c.A)((0,c.A)({},r),s):"className"===a&&(n[a]=[r,s].filter(Boolean).join(" "))}return(0,c.A)((0,c.A)({},e),n)}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?$n(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName="".concat(e,".SlotClone"),t}var $f=Symbol("radix.slottable");function Xf(e){return s.isValidElement(e)&&"function"===typeof e.type&&"__radixId"in e.type&&e.type.__radixId===$f}function Qf(e){const t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}const Zf=["__scopeSelect","disabled"],ex=["__scopeSelect","className","style","children","placeholder"],tx=["__scopeSelect","children"],nx=["__scopeSelect","position","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","side","sideOffset","align","alignOffset","arrowPadding","collisionBoundary","collisionPadding","sticky","hideWhenDetached","avoidCollisions"],ax=["__scopeSelect","onPlaced"],rx=["__scopeSelect","align","collisionPadding"],sx=["__scopeSelect","nonce"],ix=["__scopeSelect"],ox=["__scopeSelect"],lx=["__scopeSelect","value","disabled","textValue"],cx=["__scopeSelect","className","style"],dx=["__scopeSelect"],ux=["__scopeSelect","onAutoScroll"],mx=["__scopeSelect"],px=["__scopeSelect"],hx=["__scopeSelect","value"];var fx=[" ","Enter","ArrowUp","ArrowDown"],xx=[" ","Enter"],vx="Select",[gx,yx,bx]=Ks(vx),[wx,jx]=js(vx,[bx,Al]),kx=Al(),[Nx,_x]=wx(vx),[Dx,Cx]=wx(vx),Ax=e=>{const{__scopeSelect:t,children:n,open:a,defaultOpen:r,onOpenChange:i,value:o,defaultValue:l,onValueChange:d,dir:u,name:m,autoComplete:p,disabled:h,required:f,form:x}=e,v=kx(t),[g,y]=s.useState(null),[b,w]=s.useState(null),[j,k]=s.useState(!1),N=Qs(u),[_,D]=_s({prop:a,defaultProp:null!==r&&void 0!==r&&r,onChange:i,caller:vx}),[C,A]=_s({prop:o,defaultProp:l,onChange:d,caller:vx}),S=s.useRef(null),E=!g||(x||!!g.closest("form")),[F,R]=s.useState(new Set),I=Array.from(F).map(e=>e.props.value).join(";");return(0,Xt.jsx)(Wl,(0,c.A)((0,c.A)({},v),{},{children:(0,Xt.jsxs)(Nx,{required:f,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:w,valueNodeHasChildren:j,onValueNodeHasChildrenChange:k,contentId:_i(),value:C,onValueChange:A,open:_,onOpenChange:D,dir:N,triggerPointerDownPosRef:S,disabled:h,children:[(0,Xt.jsx)(gx.Provider,{scope:t,children:(0,Xt.jsx)(Dx,{scope:e.__scopeSelect,onNativeOptionAdd:s.useCallback(e=>{R(t=>new Set(t).add(e))},[]),onNativeOptionRemove:s.useCallback(e=>{R(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:n})}),E?(0,Xt.jsxs)(xv,{"aria-hidden":!0,required:f,tabIndex:-1,name:m,autoComplete:p,value:C,onChange:e=>A(e.target.value),disabled:h,form:x,children:[void 0===C?(0,Xt.jsx)("option",{value:""}):null,Array.from(F)]},I):null]})}))};Ax.displayName=vx;var Sx="SelectTrigger",Ex=s.forwardRef((e,t)=>
2{const{__scopeSelect:n,disabled:a=!1}=e,r=l(e,Zf),i=kx(n),o=_x(Sx,n),d=o.disabled||a,u=Xn(t,o.onTriggerChange),m=yx(n),p=s.useRef("touch"),[h,f,x]=gv(e=>{const t=m().filter(e=>!e.disabled),n=t.find(e=>e.value===o.value),a=yv(t,e,n);void 0!==a&&o.onValueChange(a.value)}),v=e=>{d||(o.onOpenChange(!0),x()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,Xt.jsx)(Hl,(0,c.A)((0,c.A)({asChild:!0},i),{},{children:(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":vv(o.value)?"":void 0},r),{},{ref:u,onClick:ys(r.onClick,e=>{e.currentTarget.focus(),"mouse"!==p.current&&v(e)}),onPointerDown:ys(r.onPointerDown,e=>{p.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(v(e),e.preventDefault())}),onKeyDown:ys(r.onKeyDown,e=>{const t=""!==h.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||f(e.key),t&&" "===e.key||fx.includes(e.key)&&(v(),e.preventDefault())})}))}))});Ex.displayName=Sx;var Fx="SelectValue",Rx=s.forwardRef((e,t)=>{const{__scopeSelect:n,className:a,style:r,children:s,placeholder:i=""}=e,o=l(e,ex),d=_x(Fx,n),{onValueNodeHasChildrenChange:u}=d,m=void 0!==s,p=Xn(t,d.onValueNodeChange);return Or(()=>{u(m)},[u,m]),(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({},o),{},{ref:p,style:{pointerEvents:"none"},children:vv(d.value)?(0,Xt.jsx)(Xt.Fragment,{children:i}):s}))});Rx.displayName=Fx;var Ix=s.forwardRef((e,t)=>{const{__scopeSelect:n,children:a}=e,r=l(e,tx);return(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({"aria-hidden":!0},r),{},{ref:t,children:a||"\u25bc"}))});Ix.displayName="SelectIcon";var Tx=e=>(0,Xt.jsx)(Jl,(0,c.A)({asChild:!0},e));Tx.displayName="SelectPortal";var Px="SelectContent",Ox=s.forwardRef((e,t)=>{const n=_x(Px,e.__scopeSelect),[a,r]=s.useState();if(Or(()=>{r(new DocumentFragment)},[]),!n.open){const t=a;return t?Br.createPortal((0,Xt.jsx)(Lx,{scope:e.__scopeSelect,children:(0,Xt.jsx)(gx.Slot,{scope:e.__scopeSelect,children:(0,Xt.jsx)("div",{children:e.children})})}),t):null}return(0,Xt.jsx)(Ux,(0,c.A)((0,c.A)({},e),{},{ref:t}))});Ox.displayName=Px;var Bx=10,[Lx,Mx]=wx(Px),zx=Yf("SelectContent.RemoveScroll"),Ux=s.forwardRef((e,t)=>{const{__scopeSelect:n,position:a="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:i,onPointerDownOutside:o,side:d,sideOffset:u,align:m,alignOffset:p,arrowPadding:h,collisionBoundary:f,collisionPadding:x,sticky:v,hideWhenDetached:g,avoidCollisions:y}=e,b=l(e,nx),w=_x(Px,n),[j,k]=s.useState(null),[N,_]=s.useState(null),D=Xn(t,e=>k(e)),[C,A]=s.useState(null),[S,E]=s.useState(null),F=yx(n),[R,I]=s.useState(!1),T=s.useRef(!1);s.useEffect(()=>{if(j)return Fc(j)},[j]),di();const P=s.useCallback(e=>{const[t,...n]=F().map(e=>e.ref.current),[a]=n.slice(-1),r=document.activeElement;for(const s of e){if(s===r)return;if(null===s||void 0===s||s.scrollIntoView({block:"nearest"}),s===t&&N&&(N.scrollTop=0),s===a&&N&&(N.scrollTop=N.scrollHeight),null===s||void 0===s||s.focus(),document.activeElement!==r)return}},[F,N]),O=s.useCallback(()=>P([C,j]),[P,C,j]);s.useEffect(()=>{R&&O()},[R,O]);const{onOpenChange:B,triggerPointerDownPosRef:L}=w;s.useEffect(()=>{if(j){let e={x:0,y:0};const t=t=>{var n,a,r,s;e={x:Math.abs(Math.round(t.pageX)-(null!==(n=null===(a=L.current)||void 0===a?void 0:a.x)&&void 0!==n?n:0)),y:Math.abs(Math.round(t.pageY)-(null!==(r=null===(s=L.current)||void 0===s?void 0:s.y)&&void 0!==r?r:0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():j.contains(n.target)||B(!1),document.removeEventListener("pointermove",t),L.current=null};return null!==L.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[j,B,L]),s.useEffect(()=>{const e=()=>B(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[B]);const[M,z]=gv(e=>{const t=F().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),a=yv(t,e,n);a&&setTimeout(()=>a.ref.current.focus())}),U=s.useCallback((e,t,n)=>{const a=!T.current&&!n;(void 0!==w.value&&w.value===t||a)&&(A(e),a&&(T.current=!0))},[w.value]),V=s.useCallback(()=>null===j||void 0===j?void 0:j.focus(),[j]),q=s.useCallback((e,t,n)=>{const a=!T.current&&!n;(void 0!==w.value&&w.value===t||a)&&E(e)},[w.value]),W="popper"===a?qx:Vx,H=W===qx?{side:d,sideOffset:u,align:m,alignOffset:p,arrowPadding:h,collisionBoundary:f,collisionPadding:x,sticky:v,hideWhenDetached:g,avoidCollisions:y}:{};return(0,Xt.jsx)(Lx,{scope:n,content:j,viewport:N,onViewportChange:_,itemRefCallback:U,selectedItem:C,onItemLeave:V,itemTextRefCallback:q,focusSelectedItem:O,selectedItemText:S,position:a,isPositioned:R,searchRef:M,children:(0,Xt.jsx)(bd,{as:zx,allowPinchZoom:!0,children:(0,Xt.jsx)(xi,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:ys(r,e=>{var t;null===(t=w.trigger)||void 0===t||t.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Xt.jsx)(si,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:(0,Xt.jsx)(W,(0,c.A)((0,c.A)((0,c.A)({role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:e=>e.preventDefault()},b),H),{},{onPlaced:()=>
2I(!0),ref:D,style:(0,c.A)({display:"flex",flexDirection:"column",outline:"none"},b.style),onKeyDown:ys(b.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||z(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=F().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,a=t.indexOf(n);t=t.slice(a+1)}setTimeout(()=>P(t)),e.preventDefault()}})}))})})})})});Ux.displayName="SelectContentImpl";var Vx=s.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:a}=e,r=l(e,ax),i=_x(Px,n),o=Mx(Px,n),[d,u]=s.useState(null),[m,p]=s.useState(null),h=Xn(t,e=>p(e)),f=yx(n),x=s.useRef(!1),v=s.useRef(!0),{viewport:g,selectedItem:y,selectedItemText:b,focusSelectedItem:w}=o,j=s.useCallback(()=>{if(i.trigger&&i.valueNode&&d&&m&&g&&y&&b){const e=i.trigger.getBoundingClientRect(),t=m.getBoundingClientRect(),n=i.valueNode.getBoundingClientRect(),r=b.getBoundingClientRect();if("rtl"!==i.dir){const a=r.left-t.left,s=n.left-a,i=e.left-s,o=e.width+i,l=Math.max(o,t.width),c=window.innerWidth-Bx,u=Hf(s,[Bx,Math.max(Bx,c-l)]);d.style.minWidth=o+"px",d.style.left=u+"px"}else{const a=t.right-r.right,s=window.innerWidth-n.right-a,i=window.innerWidth-e.right-s,o=e.width+i,l=Math.max(o,t.width),c=window.innerWidth-Bx,u=Hf(s,[Bx,Math.max(Bx,c-l)]);d.style.minWidth=o+"px",d.style.right=u+"px"}const s=f(),o=window.innerHeight-2*Bx,l=g.scrollHeight,c=window.getComputedStyle(m),u=parseInt(c.borderTopWidth,10),p=parseInt(c.paddingTop,10),h=parseInt(c.borderBottomWidth,10),v=u+p+l+parseInt(c.paddingBottom,10)+h,w=Math.min(5*y.offsetHeight,v),j=window.getComputedStyle(g),k=parseInt(j.paddingTop,10),N=parseInt(j.paddingBottom,10),_=e.top+e.height/2-Bx,D=o-_,C=y.offsetHeight/2,A=u+p+(y.offsetTop+C),S=v-A;if(A<=_){const e=s.length>0&&y===s[s.length-1].ref.current;d.style.bottom="0px";const t=m.clientHeight-g.offsetTop-g.offsetHeight,n=A+Math.max(D,C+(e?N:0)+t+h);d.style.height=n+"px"}else{const e=s.length>0&&y===s[0].ref.current;d.style.top="0px";const t=Math.max(_,u+g.offsetTop+(e?k:0)+C)+S;d.style.height=t+"px",g.scrollTop=A-_+g.offsetTop}d.style.margin="".concat(Bx,"px 0"),d.style.minHeight=w+"px",d.style.maxHeight=o+"px",null===a||void 0===a||a(),requestAnimationFrame(()=>x.current=!0)}},[f,i.trigger,i.valueNode,d,m,g,y,b,i.dir,a]);Or(()=>j(),[j]);const[k,N]=s.useState();Or(()=>{m&&N(window.getComputedStyle(m).zIndex)},[m]);const _=s.useCallback(e=>{e&&!0===v.current&&(j(),null===w||void 0===w||w(),v.current=!1)},[j,w]);return(0,Xt.jsx)(Wx,{scope:n,contentWrapper:d,shouldExpandOnScrollRef:x,onScrollButtonChange:_,children:(0,Xt.jsx)("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({},r),{},{ref:h,style:(0,c.A)({boxSizing:"border-box",maxHeight:"100%"},r.style)}))})})});Vx.displayName="SelectItemAlignedPosition";var qx=s.forwardRef((e,t)=>{const{__scopeSelect:n,align:a="start",collisionPadding:r=Bx}=e,s=l(e,rx),i=kx(n);return(0,Xt.jsx)(Gl,(0,c.A)((0,c.A)((0,c.A)({},i),s),{},{ref:t,align:a,collisionPadding:r,style:(0,c.A)((0,c.A)({boxSizing:"border-box"},s.style),{"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"})}))});qx.displayName="SelectPopperPosition";var[Wx,Hx]=wx(Px,{}),Gx="SelectViewport",Kx=s.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:a}=e,r=l(e,sx),i=Mx(Gx,n),o=Hx(Gx,n),d=Xn(t,i.onViewportChange),u=s.useRef(0);return(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),(0,Xt.jsx)(gx.Slot,{scope:n,children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({"data-radix-select-viewport":"",role:"presentation"},r),{},{ref:d,style:(0,c.A)({position:"relative",flex:1,overflow:"hidden auto"},r.style),onScroll:ys(r.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:a}=o;if(null!==a&&void 0!==a&&a.current&&n){const e=Math.abs(u.current-t.scrollTop);if(e>0){const a=window.innerHeight-2*Bx,r=parseFloat(n.style.minHeight),s=parseFloat(n.style.height),i=Math.max(r,s);if(i<a){const r=i+e,s=Math.min(a,r),o=r-s;n.style.height=s+"px","0px"===n.style.bottom&&(t.scrollTop=o>0?o:0,n.style.justifyContent="flex-end")}}}u.current=t.scrollTop})}))})]})});Kx.displayName=Gx;var Yx="SelectGroup",[Jx,$x]=wx(Yx),Xx=s.forwardRef((e,t)=>
2{const{__scopeSelect:n}=e,a=l(e,ix),r=_i();return(0,Xt.jsx)(Jx,{scope:n,id:r,children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({role:"group","aria-labelledby":r},a),{},{ref:t}))})});Xx.displayName=Yx;var Qx="SelectLabel",Zx=s.forwardRef((e,t)=>{const{__scopeSelect:n}=e,a=l(e,ox),r=$x(Qx,n);return(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({id:r.id},a),{},{ref:t}))});Zx.displayName=Qx;var ev="SelectItem",[tv,nv]=wx(ev),av=s.forwardRef((e,t)=>{const{__scopeSelect:n,value:a,disabled:r=!1,textValue:i}=e,o=l(e,lx),d=_x(ev,n),u=Mx(ev,n),m=d.value===a,[p,h]=s.useState(null!==i&&void 0!==i?i:""),[f,x]=s.useState(!1),v=Xn(t,e=>{var t;return null===(t=u.itemRefCallback)||void 0===t?void 0:t.call(u,e,a,r)}),g=_i(),y=s.useRef("touch"),b=()=>{r||(d.onValueChange(a),d.onOpenChange(!1))};if(""===a)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,Xt.jsx)(tv,{scope:n,value:a,disabled:r,textId:g,isSelected:m,onItemTextChange:s.useCallback(e=>{h(t=>{var n;return t||(null!==(n=null===e||void 0===e?void 0:e.textContent)&&void 0!==n?n:"").trim()})},[]),children:(0,Xt.jsx)(gx.ItemSlot,{scope:n,value:a,disabled:r,textValue:p,children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":m&&f,"data-state":m?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1},o),{},{ref:v,onFocus:ys(o.onFocus,()=>x(!0)),onBlur:ys(o.onBlur,()=>x(!1)),onClick:ys(o.onClick,()=>{"mouse"!==y.current&&b()}),onPointerUp:ys(o.onPointerUp,()=>{"mouse"===y.current&&b()}),onPointerDown:ys(o.onPointerDown,e=>{y.current=e.pointerType}),onPointerMove:ys(o.onPointerMove,e=>{var t;(y.current=e.pointerType,r)?null===(t=u.onItemLeave)||void 0===t||t.call(u):"mouse"===y.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ys(o.onPointerLeave,e=>{var t;e.currentTarget===document.activeElement&&(null===(t=u.onItemLeave)||void 0===t||t.call(u))}),onKeyDown:ys(o.onKeyDown,e=>{var t;""!==(null===(t=u.searchRef)||void 0===t?void 0:t.current)&&" "===e.key||(xx.includes(e.key)&&b()," "===e.key&&e.preventDefault())})}))})})});av.displayName=ev;var rv="SelectItemText",sv=s.forwardRef((e,t)=>{const{__scopeSelect:n,className:a,style:r}=e,i=l(e,cx),o=_x(rv,n),d=Mx(rv,n),u=nv(rv,n),m=Cx(rv,n),[p,h]=s.useState(null),f=Xn(t,e=>h(e),u.onItemTextChange,e=>{var t;return null===(t=d.itemTextRefCallback)||void 0===t?void 0:t.call(d,e,u.value,u.disabled)}),x=null===p||void 0===p?void 0:p.textContent,v=s.useMemo(()=>(0,Xt.jsx)("option",{value:u.value,disabled:u.disabled,children:x},u.value),[u.disabled,u.value,x]),{onNativeOptionAdd:g,onNativeOptionRemove:y}=m;return Or(()=>(g(v),()=>y(v)),[g,y,v]),(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({id:u.textId},i),{},{ref:f})),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Br.createPortal(i.children,o.valueNode):null]})});sv.displayName=rv;var iv="SelectItemIndicator",ov=s.forwardRef((e,t)=>{const{__scopeSelect:n}=e,a=l(e,dx);return nv(iv,n).isSelected?(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({"aria-hidden":!0},a),{},{ref:t})):null});ov.displayName=iv;var lv="SelectScrollUpButton",cv=s.forwardRef((e,t)=>{const n=Mx(lv,e.__scopeSelect),a=Hx(lv,e.__scopeSelect),[r,i]=s.useState(!1),o=Xn(t,a.onScrollButtonChange);return Or(()=>{if(n.viewport&&n.isPositioned){let e=function(){const e=t.scrollTop>0;i(e)};const t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),r?(0,Xt.jsx)(mv,(0,c.A)((0,c.A)({},e),{},{ref:o,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}})):null});cv.displayName=lv;var dv="SelectScrollDownButton",uv=s.forwardRef((e,t)=>{const n=Mx(dv,e.__scopeSelect),a=Hx(dv,e.__scopeSelect),[r,i]=s.useState(!1),o=Xn(t,a.onScrollButtonChange);return Or(()=>{if(n.viewport&&n.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;i(n)};const t=n.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[n.viewport,n.isPositioned]),r?(0,Xt.jsx)(mv,(0,c.A)((0,c.A)({},e),{},{ref:o,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}})):null});uv.displayName=dv;var mv=s.forwardRef((e,t)=>
2{const{__scopeSelect:n,onAutoScroll:a}=e,r=l(e,ux),i=Mx("SelectScrollButton",n),o=s.useRef(null),d=yx(n),u=s.useCallback(()=>{null!==o.current&&(window.clearInterval(o.current),o.current=null)},[]);return s.useEffect(()=>()=>u(),[u]),Or(()=>{var e;const t=d().find(e=>e.ref.current===document.activeElement);null===t||void 0===t||null===(e=t.ref.current)||void 0===e||e.scrollIntoView({block:"nearest"})},[d]),(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({"aria-hidden":!0},r),{},{ref:t,style:(0,c.A)({flexShrink:0},r.style),onPointerDown:ys(r.onPointerDown,()=>{null===o.current&&(o.current=window.setInterval(a,50))}),onPointerMove:ys(r.onPointerMove,()=>{var e;null===(e=i.onItemLeave)||void 0===e||e.call(i),null===o.current&&(o.current=window.setInterval(a,50))}),onPointerLeave:ys(r.onPointerLeave,()=>{u()})}))}),pv=s.forwardRef((e,t)=>{const{__scopeSelect:n}=e,a=l(e,mx);return(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({"aria-hidden":!0},a),{},{ref:t}))});pv.displayName="SelectSeparator";var hv="SelectArrow",fv=s.forwardRef((e,t)=>{const{__scopeSelect:n}=e,a=l(e,px),r=kx(n),s=_x(hv,n),i=Mx(hv,n);return s.open&&"popper"===i.position?(0,Xt.jsx)(Kl,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t})):null});fv.displayName=hv;var xv=s.forwardRef((e,t)=>{let{__scopeSelect:n,value:a}=e,r=l(e,hx);const i=s.useRef(null),o=Xn(t,i),d=Qf(a);return s.useEffect(()=>{const e=i.current;if(!e)return;const t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,"value").set;if(d!==a&&n){const t=new Event("change",{bubbles:!0});n.call(e,a),e.dispatchEvent(t)}},[d,a]),(0,Xt.jsx)(Is.select,(0,c.A)((0,c.A)({},r),{},{style:(0,c.A)((0,c.A)({},Ph),r.style),ref:o,defaultValue:a}))});function vv(e){return""===e||void 0===e}function gv(e){const t=Pr(e),n=s.useRef(""),a=s.useRef(0),r=s.useCallback(e=>{const r=n.current+e;t(r),function e(t){n.current=t,window.clearTimeout(a.current),""!==t&&(a.current=window.setTimeout(()=>e(""),1e3))}(r)},[t]),i=s.useCallback(()=>{n.current="",window.clearTimeout(a.current)},[]);return s.useEffect(()=>()=>window.clearTimeout(a.current),[]),[n,r,i]}function yv(e,t,n){const a=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,r=n?e.indexOf(n):-1;let s=(i=e,o=Math.max(r,0),i.map((e,t)=>i[(o+t)%i.length]));var i,o;1===a.length&&(s=s.filter(e=>e!==n));const l=s.find(e=>e.textValue.toLowerCase().startsWith(a.toLowerCase()));return l!==n?l:void 0}xv.displayName="SelectBubbleInput";var bv=Ax,wv=Ex,jv=Rx,kv=Ix,Nv=Tx,_v=Ox,Dv=Kx,Cv=Zx,Av=av,Sv=sv,Ev=ov,Fv=cv,Rv=uv,Iv=pv;const Tv=wn("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),Pv=["className","children"],Ov=["className"],Bv=["className"],Lv=["className","children","position"],Mv=["className"],zv=["className","children"],Uv=["className"],Vv=bv,qv=jv,Wv=s.forwardRef((e,t)=>{let{className:n,children:a}=e,r=l(e,Pv);return(0,Xt.jsxs)(wv,(0,c.A)((0,c.A)({ref:t,className:Sr("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",n)},r),{},{children:[a,(0,Xt.jsx)(kv,{asChild:!0,children:(0,Xt.jsx)(Gn,{className:"h-4 w-4 opacity-50"})})]}))});Wv.displayName=wv.displayName;const Hv=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Ov);return(0,Xt.jsx)(Fv,(0,c.A)((0,c.A)({ref:t,className:Sr("flex cursor-default items-center justify-center py-1",n)},a),{},{children:(0,Xt.jsx)(Tv,{className:"h-4 w-4"})}))});Hv.displayName=Fv.displayName;const Gv=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Bv);return(0,Xt.jsx)(Rv,(0,c.A)((0,c.A)({ref:t,className:Sr("flex cursor-default items-center justify-center py-1",n)},a),{},{children:(0,Xt.jsx)(Gn,{className:"h-4 w-4"})}))});
2Gv.displayName=Rv.displayName;const Kv=s.forwardRef((e,t)=>{let{className:n,children:a,position:r="popper"}=e,s=l(e,Lv);return(0,Xt.jsx)(Nv,{children:(0,Xt.jsxs)(_v,(0,c.A)((0,c.A)({ref:t,className:Sr("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===r&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:r},s),{},{children:[(0,Xt.jsx)(Hv,{}),(0,Xt.jsx)(Dv,{className:Sr("p-1","popper"===r&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),(0,Xt.jsx)(Gv,{})]}))})});Kv.displayName=_v.displayName;s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Mv);return(0,Xt.jsx)(Cv,(0,c.A)({ref:t,className:Sr("px-2 py-1.5 text-sm font-semibold",n)},a))}).displayName=Cv.displayName;const Yv=s.forwardRef((e,t)=>{let{className:n,children:a}=e,r=l(e,zv);return(0,Xt.jsxs)(Av,(0,c.A)((0,c.A)({ref:t,className:Sr("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n)},r),{},{children:[(0,Xt.jsx)("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,Xt.jsx)(Ev,{children:(0,Xt.jsx)(Zm,{className:"h-4 w-4"})})}),(0,Xt.jsx)(Sv,{children:a})]}))});Yv.displayName=Av.displayName;s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Uv);return(0,Xt.jsx)(Iv,(0,c.A)({ref:t,className:Sr("-mx-1 my-1 h-px bg-muted",n)},a))}).displayName=Iv.displayName;const Jv={candidate:{label:"Candidate",Icon:kn},employer:{label:"Employer",Icon:Pn},admin:{label:"Admin",Icon:Ln}};function $v(e){let{collapsed:t=!1}=e;const{allowedWorkspaces:n,currentWorkspace:a,switchWorkspace:r}=on();if(!n||n.length<2)return null;const s=a||n[0],i=(Jv[s]||Jv.candidate).Icon;if(t){var o;const e=n[(n.indexOf(s)+1)%n.length];return(0,Xt.jsx)("button",{type:"button",onClick:()=>r(e),className:"mx-auto mb-3 flex h-9 w-9 items-center justify-center rounded-md border border-ndor-edge bg-ndor-surface-alt hover:bg-ndor-surface text-ndor-ink","data-testid":"workspace-switcher-collapsed",title:"Switch to ".concat((null===(o=Jv[e])||void 0===o?void 0:o.label)||e),children:(0,Xt.jsx)(i,{className:"h-4 w-4"})})}return(0,Xt.jsxs)("div",{className:"px-3 mb-3","data-testid":"workspace-switcher",children:[(0,Xt.jsx)("p",{className:"text-[9px] uppercase tracking-[0.22em] text-ndor-ink-muted font-mono-ui mb-1.5",children:"Workspace"}),(0,Xt.jsxs)(Vv,{value:s,onValueChange:e=>r(e),children:[(0,Xt.jsx)(Wv,{className:"h-9 text-sm bg-ndor-surface-alt border-ndor-edge","data-testid":"workspace-switcher-trigger",children:(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(i,{className:"h-4 w-4 text-ndor-ink-muted"}),(0,Xt.jsx)(qv,{})]})}),(0,Xt.jsx)(Kv,{children:n.map(e=>{const t=Jv[e];if(!t)return null;const{Icon:n}=t;return(0,Xt.jsx)(Yv,{value:e,"data-testid":"workspace-switcher-option-".concat(e),children:(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(n,{className:"h-4 w-4 text-ndor-ink-muted"}),(0,Xt.jsx)("span",{children:t.label})]})},e)})})]})]})}function Xv(e){let{variant:t="app"}=e;const n=(new Date).getFullYear();return(0,Xt.jsxs)("footer",{className:"auth"===t?"border-t border-ndor-edge bg-ndor-canvas px-4 sm:px-6 py-5":"border-t border-ndor-edge bg-ndor-surface px-4 sm:px-6 lg:px-8 py-5 mt-auto","data-testid":"legal-footer",children:[(0,Xt.jsxs)("div",{className:"max-w-5xl mx-auto flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[(0,Xt.jsxs)("nav",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-ndor-ink-muted",children:[(0,Xt.jsx)(Et,{to:"/terms","data-testid":"legal-footer-terms",className:"hover:text-ndor-ink hover:underline",children:"Terms"}
2),(0,Xt.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,Xt.jsx)(Et,{to:"/privacy","data-testid":"legal-footer-privacy",className:"hover:text-ndor-ink hover:underline",children:"Privacy"}),(0,Xt.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,Xt.jsx)(Et,{to:"/refund","data-testid":"legal-footer-refund",className:"hover:text-ndor-ink hover:underline",children:"Refund Policy"}),(0,Xt.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,Xt.jsx)("a",{href:"mailto:[email protected]?subject=NDORFlow%20-%20Support%20request","data-testid":"legal-footer-support",className:"hover:text-ndor-ink hover:underline",children:"Support"}),(0,Xt.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,Xt.jsx)("a",{href:"mailto:[email protected]?subject=NDORFlow%20-%20Billing","data-testid":"legal-footer-billing",className:"hover:text-ndor-ink hover:underline",children:"Billing"})]}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"legal-footer-copyright",children:["\xa9 ",n," NDOR Labs Limited. All rights reserved."]})]}),(0,Xt.jsx)("p",{className:"mt-3 max-w-5xl mx-auto text-[11px] text-ndor-ink-muted leading-relaxed","data-testid":"legal-footer-company-line",children:'The NDORFlow software platform is owned, developed and licensed by NDOR Labs Limited. IAA Energy Resources Limited (Company No. 11583381) is the Authorised Commercial Operator for NDORFlow and is responsible for marketing, sales, subscriptions, billing, payment collection, commercial onboarding and customer support. Registered office: 71-75 Shelton Street, Covent Garden, London, England, WC2H 9JQ. Invoices and payment statements will show "IAA Energy Resources Limited".'})]})}const Qv=["className"],Zv=["className","children"],eg=["className"],tg=["className"],ng=["className"],ag=["className"],rg=lh,sg=ch,ig=dh,og=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Qv);return(0,Xt.jsx)(uh,(0,c.A)({ref:t,className:Sr("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n)},a))});og.displayName=uh.displayName;const lg=s.forwardRef((e,t)=>{let{className:n,children:a}=e,r=l(e,Zv);return(0,Xt.jsxs)(ig,{children:[(0,Xt.jsx)(og,{}),(0,Xt.jsxs)(mh,(0,c.A)((0,c.A)({ref:t,className:Sr("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n)},r),{},{children:[a,(0,Xt.jsxs)(fh,{className:"absolute right-4 top-4 roun
2ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,Xt.jsx)(xh,{className:"h-4 w-4"}),(0,Xt.jsx)("span",{className:"sr-only",children:"Close"})]})]}))]})});lg.displayName=mh.displayName;const cg=e=>{let{className:t}=e,n=l(e,eg);return(0,Xt.jsx)("div",(0,c.A)({className:Sr("flex flex-col space-y-1.5 text-center sm:text-left",t)},n))};cg.displayName="DialogHeader";const dg=e=>{let{className:t}=e,n=l(e,tg);return(0,Xt.jsx)("div",(0,c.A)({className:Sr("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t)},n))};dg.displayName="DialogFooter";const ug=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,ng);return(0,Xt.jsx)(ph,(0,c.A)({ref:t,className:Sr("text-lg font-semibold leading-none tracking-tight",n)},a))});ug.displayName=ph.displayName;const mg=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,ag);return(0,Xt.jsx)(hh,(0,c.A)({ref:t,className:Sr("text-sm text-muted-foreground",n)},a))});mg.displayName=hh.displayName;const pg=wn("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);function hg(){const[e,t]=(0,s.useState)(!1),n=ke();(0,s.useEffect)(()=>{const e=()=>t(!0);return window.addEventListener("ndorflow:session-expired",e),()=>window.removeEventListener("ndorflow:session-expired",e)},[]);const a=(0,s.useCallback)(async()=>{try{await Mt.supabase.auth.signOut()}catch(e){}t(!1),n("/login",{replace:!0})},[n]);return(0,Xt.jsx)(rg,{open:e,onOpenChange:e=>{e?t(e):a()},children:(0,Xt.jsxs)(lg,{"data-testid":"session-expired-modal",className:"sm:max-w-md",children:[(0,Xt.jsx)(cg,{children:(0,Xt.jsxs)("div",{className:"flex items-start gap-3",children:[(0,Xt.jsx)("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full bg-amber-500/10 text-amber-600",children:(0,Xt.jsx)(pg,{className:"h-5 w-5","aria-hidden":"true"})}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(ug,{children:"Your session has expired"}),(0,Xt.jsx)(mg,{className:"mt-1",children:"For your security, NDORFlow sessions time out after a period of inactivity. Please sign in again to continue. Your work is saved \u2014 nothing has been lost."})]})]})}),(0,Xt.jsx)(dg,{children:(0,Xt.jsx)(Rr,{onClick:a,"data-testid":"session-expired-sign-in-btn",className:"w-full sm:w-auto",children:"Sign in again"})})]})})}function fg(e){if(!e)return null;const t=(e.nickname||"").trim();if(t)return t;const n=(e.first_name||"").trim();if(n)return n;const a=(e.full_name||"").trim();return a?a.split(/\s+/)[0]:null}function xg(){const{user:e}=tn(),[t,n]=(0,s.useState)(null),[a,r]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(null===e||void 0===e||!e.id)return void n(null);let t=!0;return r(!0),(async()=>{try{const{data:a,error:r}=await Mt.supabase.from("profiles").select("id, full_name, first_name, last_name, nickname, is_admin").eq("id",e.id).maybeSingle();if(!t)return;r?(console.warn("[useProfile]",r.message),n(null)):n(a||null)}finally{t&&r(!1)}})(),()=>{t=!1}},[null===e||void 0===e?void 0:e.id]),{profile:t,loading:a,greetingName:fg(t)}}const vg=[{label:"Dashboard",path:"/dashboard",icon:jn},{label:"Jobs",path:"/jobs",icon:kn},{label:"Documents",path:"/documents",icon:Nn},{label:"Applications",path:"/applications",icon:_n},{label:"Signals",path:"/candidate/signals",icon:Dn}],gg=[{label:"Workflow",path:"/automation",icon:Cn,requiresPlan:["focus","flow"]},{label:"How it works",path:"/how-it-works",icon:An,testId:"nav-how-it-works-link"}],yg=[{label:"Credits",path:"/credits",icon:Sn,testId:"nav-credits-link"},{label:"Account",path:"/account",icon:En},{label:"Candidate User Guide",path:"/help/candidate",icon:Fn,testId:"nav-help-candidate-link"}],bg=[{label:"Signals",path:"/employer/signals",icon:Dn,testId:"sidebar-employer-signals-link"},{label:"Account",path:"/employer/account",icon:Rn,testId:"sidebar-employer-settings-link"},{label:"How it works",path:"/employer/help/workflow",icon:Fn,testId:"sidebar-employer-workflow-link"},{label:"Help",path:"/employer/help/permissions",icon:An,testId:"sidebar-employer-permissions-link"},{label:"Employer User Guide",path:"/help/employer",icon:Fn,testId:"sidebar-employer-user-guide-link",requiresMemberRole:["owner","admin"]},{label:"Reviewer User Guide",path:"/help/reviewer",icon:Fn,testId:"sidebar-reviewer-user-guide-link",requiresMemberRole:["owner","admin","recruiter","reviewer"]}],wg=[],jg=[{label:"Dashboard",path:"/employer",icon:jn,testId:"sidebar-employer-dashboard-link"},{label:"Roles",path:"/employer/roles",icon:kn,requiresMemberRole:["owner","admin","recruiter"]},{label:"Reviews",path:"/employer/reviews",icon:In,testId:"sidebar-reviews-link",requiresMemberRole:["reviewer"]},{label:"Members",path:"/employer/members",icon:Tn,testId:"sidebar-employer-members-link",requiresMemberRole:["owner","admin","recruiter"]},{label:"Organisation",path:"/employer/organisation",icon:Pn,testId:"sidebar-employer-organisation-link",requiresMemberRole:["owner","admin"]}],kg=[{label:"Analytics",path:"/admin/analytics",icon:On},{label:"Scoring",path:"/admin/scoring",icon:Bn},{label:"Jobs Inventory",path:"/admin/jobs",icon:Ln},{label:"Duplicates",path:"/admin/duplicates",icon:Mn},{label:"Sources",path:"/admin/sources",icon:zn},{label:"Catalogue",path:"/admin/catalogue",icon:Pn},{label:"Users",path:"/admin/users",icon:Tn},{label:"Employers",path:"/admin/employers",icon:Pn,testId:"sidebar-employers-link"},{label:"Billing",path:"/admin/billing",icon:Un},{label:"Retention",path:"/admin/retention",icon:Vn},{label:"Settings",path:"/admin/settings",icon:Rn}];function Ng(e){let{item:t,collapsed:n,onClick:a,badge:r}=e;const s=(0,Xt.jsx)(Ft,{to:t.path,onClick:a,"data-testid":t.testId||"sidebar-".concat(t.label.toLowerCase().replace(/\s+/g,"-"),"-link"),children:e=>{let{isActive:a}=e;return(0,Xt.jsxs)("span",{className:"group relative flex items-center gap-x-3 rounded-md px-3 py-2.5 text-sm transition-colors\n ".concat(a?"bg-ndor-surface-alt text-ndor-ink font-semibold":"text-ndor-ink-secondary hover:bg-ndor-surface-alt/60 hover:text-ndor-ink","\n ").concat(n?"justify-center px-2":""),children:[a&&(0,Xt.jsx)("span",{"aria-hidden":!0,
2className:"absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-ndor-gold"}),(0,Xt.jsx)(t.icon,{className:"h-[18px] w-[18px] shrink-0 ".concat(a?"text-ndor-gold":"text-ndor-ink-muted group-hover:text-ndor-ink-secondary"),strokeWidth:1.6}),!n&&(0,Xt.jsx)("span",{className:"tracking-tight",children:t.label}),r>0&&(0,Xt.jsx)("span",{className:n?"absolute top-1 right-1 state-pill state-pill--pending !px-1 !py-0 !text-[9px] !font-semibold":"ml-auto state-pill state-pill--pending !py-0 !text-[10px] !font-semibold","data-testid":"sidebar-".concat(t.label.toLowerCase(),"-badge"),children:r>9?"9+":r})]})}});return n?(0,Xt.jsxs)(wf,{delayDuration:150,children:[(0,Xt.jsx)(jf,{asChild:!0,children:s}),(0,Xt.jsxs)(kf,{side:"right",className:"bg-ndor-surface-alt text-ndor-ink border-ndor-edge",children:[t.label,r>0?" \u2014 ".concat(r>9?"9+":r," pending"):""]})]}):s}function _g(e){let{collapsed:t,onNavClick:n,currentWorkspace:a,signalsPending:r,reviewerPending:s,isOperator:i,employerMemberRole:o}=e;const{planCode:l}=If();let c=[],d=[],u=[],m="Workspace";return"candidate"===a?(c=vg.filter(e=>"/candidate/signals"!==e.path||i),d=gg.filter(e=>!e.requiresPlan||e.requiresPlan.includes(l||"base")),u=yg,m="Workspace"):"employer"===a?(c=jg.filter(e=>!e.requiresMemberRole||o&&e.requiresMemberRole.includes(o)),u=bg.filter(e=>!e.requiresMemberRole||o&&e.requiresMemberRole.includes(o)),m="Employer"):"admin"===a&&(c=kg,u=wg,m="Admin"),(0,Xt.jsxs)("div",{className:"flex flex-col h-full",children:[(0,Xt.jsxs)("div",{className:"flex items-center ".concat(t?"justify-center px-2":"gap-3 px-5"," pt-2 pb-8"),children:[(0,Xt.jsx)(Wf,{variant:"symbol",size:t?40:44}),!t&&(0,Xt.jsxs)("div",{className:"flex flex-col leading-none",children:[(0,Xt.jsxs)("span",{className:"text-[22px] font-serif-display font-semibold tracking-tight text-ndor-ink",children:["NDOR",(0,Xt.jsx)("span",{className:"text-gold-accent",children:"Flow"})]}),(0,Xt.jsx)("span",{className:"text-[9px] uppercase tracking-[0.22em] text-ndor-ink-secondary font-mono-ui mt-1.5",children:"Decision Intelligence"})]})]}),(0,Xt.jsx)($v,{collapsed:t}),(0,Xt.jsxs)("nav",{className:"flex-1 ".concat(t?"px-2":"px-3"," space-y-1"),"data-testid":"primary-nav","data-workspace":a||"unknown",children:[!t&&(0,Xt.jsx)("p",{className:"px-3 mb-2 text-[10px] font-semibold tracking-[0.22em] uppercase text-ndor-ink-muted font-mono-ui",children:m}),c.map(e=>(0,Xt.jsx)(Ng,{item:e,collapsed:t,onClick:n,badge:"/candidate/signals"===e.path?r:"/employer/reviews"===e.path?s:0},e.path)),d.length>0&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(gs,{className:"my-4 bg-ndor-edge"}),!t&&(0,Xt.jsx)("p",{className:"px-3 mb-2 text-[10px] font-semibold tracking-[0.22em] uppercase text-ndor-ink-muted font-mono-ui",children:"Tools"}),d.map(e=>(0,Xt.jsx)(Ng,{item:e,collapsed:t,onClick:n},e.path))]}),u.length>0&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(gs,{className:"my-4 bg-ndor-edge"}),u.map(e=>(0,Xt.jsx)(Ng,{item:e,collapsed:t,onClick:n},e.path))]})]}),(0,Xt.jsx)("div",{className:"".concat(t?"px-2":"px-3"," pb-4 pt-2"),children:!t&&(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt/60 p-3",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-secondary font-mono-ui",children:"Decision Intelligence"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary mt-1 leading-relaxed",children:"Every action is logged to your ledger."})]})})]})}function Dg(){var e,t;const{user:n,signOut:a}=tn(),{profile:r,greetingName:i}=xg(),{currentWorkspace:o}=on(),l=be(),c=ke(),[d,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)(()=>{try{return"1"===localStorage.getItem("ndor.sidebar.collapsed")}catch(e){return!1}});(0,s.useEffect)(()=>{try{localStorage.setItem("ndor.sidebar.collapsed",m?"1":"0")}catch(e){}},[m]);l.pathname;const h=((null===i||void 0===i?void 0:i[0])||(null===r||void 0===r||null===(e=r.first_name)||void 0===e?void 0:e[0])||(null===n||void 0===n||null===(t=n.email)||void 0===t?void 0:t[0])||"U").toUpperCase(),f=i||(null===r||void 0===r?void 0:r.first_name)||"Account",{isOperator:x}=pn(),v=function(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];
2const[a,r]=(0,s.useState)(0);return(0,s.useEffect)(()=>{if(!n)return void r(0);if("candidate"!==e)return void r(0);let t=!1;return(async()=>{try{const n=await(0,zt.n)("/api/candidate/signals");var e;t||r(0|(null===n||void 0===n||null===(e=n.counts)||void 0===e?void 0:e.pending)||0)}catch(n){t||r(0)}})(),()=>{t=!0}},[e,t,n]),a}(o,l.pathname,x),g=function(e){const[t,n]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if("employer"!==e)return void n(null);let t=!1;return(async()=>{try{var e;const a=await(0,zt.n)("/api/employer/v1/me");t||n((null===a||void 0===a||null===(e=a.member)||void 0===e?void 0:e.role)||null)}catch(a){t||n(null)}})(),()=>{t=!0}},[e]),t}(o),y=function(e,t,n){const[a,r]=(0,s.useState)(0);return(0,s.useEffect)(()=>{if("employer"!==e)return void r(0);if("reviewer"!==n)return void r(0);let t=!1;return(async()=>{try{const e=await(0,zt.n)("/api/employer/v1/reviewer/queue?limit=200");if(t)return;const n=Array.isArray(null===e||void 0===e?void 0:e.reviews)?e.reviews:[];r(n.filter(e=>"pending"===(null===e||void 0===e?void 0:e.status)).length)}catch(e){t||r(0)}})(),()=>{t=!0}},[e,t,n]),a}(o,l.pathname,g),b=m?"lg:w-[76px]":"lg:w-[260px]",w=m?"lg:pl-[76px]":"lg:pl-[260px]";return(0,Xt.jsx)(Rf,{children:(0,Xt.jsx)(bf,{delayDuration:300,children:(0,Xt.jsxs)("div",{className:"min-h-screen bg-ndor-canvas",children:[(0,Xt.jsxs)("aside",{className:"fixed inset-y-0 left-0 z-50 hidden lg:flex flex-col ".concat(b," border-r border-ndor-edge bg-ndor-surface pt-6 pb-4 transition-[width] duration-200 ease-out"),"data-testid":"desktop-sidebar","data-collapsed":m?"true":"false",children:[(0,Xt.jsx)(_g,{collapsed:m,currentWorkspace:o,signalsPending:v,reviewerPending:y,isOperator:x,employerMemberRole:g}),(0,Xt.jsx)("button",{type:"button",onClick:()=>p(e=>!e),className:"absolute -right-3 top-20 h-6 w-6 rounded-full bg-ndor-surface-alt border border-ndor-edge text-ndor-ink-muted hover:text-ndor-ink flex items-center justify-center shadow-md","data-testid":"sidebar-collapse-toggle","aria-label":m?"Expand sidebar":"Collapse sidebar",children:m?(0,Xt.jsx)(qn,{className:"h-3 w-3"}):(0,Xt.jsx)(Wn,{className:"h-3 w-3"})})]}),(0,Xt.jsxs)("div",{className:"".concat(w," flex flex-col min-h-screen"),children:[(0,Xt.jsxs)("header",{className:"sticky top-0 z-40 flex h-16 shrink-0 items-center gap-x-2 sm:gap-x-3 lg:gap-x-4 border-b border-ndor-edge bg-ndor-surface/80 backdrop-blur-xl px-3 sm:px-6 lg:px-8 min-w-0","data-testid":"topbar",children:[(0,Xt.jsxs)("div",{className:"lg:hidden flex items-center gap-2 shrink-0","data-testid":"mobile-brand",children:[(0,Xt.jsxs)(kh,{open:d,onOpenChange:u,children:[(0,Xt.jsx)(Nh,{asChild:!0,children:(0,Xt.jsx)(Rr,{variant:"ghost",size:"icon",className:"text-ndor-ink-secondary","data-testid":"mobile-menu-button",children:(0,Xt.jsx)(Hn,{className:"h-5 w-5"})})}),(0,Xt.jsx)(Ah,{side:"left",className:"w-64 p-0 pt-6 bg-ndor-surface border-ndor-edge",children:(0,Xt.jsx)(_g,{collapsed:!1,currentWorkspace:o,signalsPending:v,reviewerPending:y,isOperator:x,employerMemberRole:g,onNavClick:()=>u(!1)})})]}),(0,Xt.jsx)(Wf,{variant:"symbol",size:28})]}),(0,Xt.jsx)("div",{className:"flex-1 min-w-0","data-testid":"page-title-spacer"}),(0,Xt.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-x-2 sm:gap-x-3",children:[(0,Xt.jsx)(qf,{}),"candidate"===o&&(0,Xt.jsx)(Tf,{}),"employer"===o&&(0,Xt.jsx)(Mf,{}),(0,Xt.jsxs)(cp,{children:[(0,Xt.jsx)(dp,{asChild:!0,children:(0,Xt.jsxs)(Rr,{variant:"ghost",className:"flex items-center gap-2 px-2 hover:bg-ndor-surface-alt","data-testid":"user-menu-trigger",children:[(0,Xt.jsx)(ls,{className:"h-8 w-8",children:(0,Xt.jsx)(cs,{className:"bg-ndor-surface-alt text-ndor-ink-secondary text-sm font-medium border border-ndor-edge",children:h})}),(0,Xt.jsx)("span",{className:"hidden md:block text-sm text-ndor-ink-secondary max-w-[140px] truncate","data-testid":"topbar-user-label",children:f}),(0,Xt.jsx)(Gn,{className:"h-4 w-4 text-ndor-ink-muted"})]})}),(0,Xt.jsxs)(up,{align:"end",className:"w-56 bg-ndor-surface border-ndor-edge",children:[(0,Xt.jsxs)(pp,{className:"font-normal",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink","data-testid":"usermenu-name",children:i||(null===r||void 0===r?void 0:r.first_name)||"Account"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary truncate",children:null===n||void 0===n?void 0:n.email})]}),(0,Xt.jsx)(hp,{className:"bg-ndor-edge"}),"candidate"===o&&(0,Xt.jsxs)(mp,{onClick:()=>c("/how-it-works"),"data-testid":"usermenu-how-it-works",className:"cursor-pointer",children:[(0,Xt.jsx)(An,{className:"mr-2 h-4 w-4"}),"How it works"]}),"candidate"===o&&(0,Xt.jsxs)(mp,{onClick:()=>{c("/dashboard"),setTimeout(()=>{window.dispatchEvent(new Event("ndor:first-run-open"))},0)},"data-testid":"usermenu-show-first-run",className:"cursor-pointer",children:[(0,Xt.jsx)(Kn,{className:"mr-2 h-4 w-4"}),"Show first-run guide"]}),"employer"===o&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)(mp,{onClick:()=>c("/employer/help/permissions"),"data-testid":"usermenu-employer-permissions",className:"cursor-pointer",children:[(0,Xt.jsx)(Bn,{className:"mr-2 h-4 w-4"}),"Roles & permissions"]}),(0,Xt.jsxs)(mp,{onClick:()=>c("/employer/account"),"data-testid":"usermenu-employer-account",className:"cursor-pointer",children:[(0,Xt.jsx)(Pn,{className:"mr-2 h-4 w-4"}),"Account & Usage"]})]}),(0,Xt.jsxs)(mp,{onClick:async()=>{await a()},"data-testid":"logout-button",className:"text-ndor-error focus:text-ndor-error cursor-pointer",children:[(0,Xt.jsx)(Yn,{className:"mr-2 h-4 w-4"}),"Log out"]})]})]})]})]}),(0,Xt.jsx)("main",{className:"flex-1 px-3 py-4 sm:p-6 lg:p-8 pb-[calc(env(safe-area-inset-bottom)+1rem)]","data-testid":"main-content",children:(0,Xt.jsx)("div",{className:"mx-auto w-full max-w-5xl","data-testid":"main-content-container",children:(0,Xt.jsx)(He,{})})}),(0,Xt.jsx)(Xv,{}),(0,Xt.jsx)(hg,{})]})]})})})}const Cg=["className","type"],Ag=s.forwardRef((e,t)=>
2{let{className:n,type:a}=e,r=l(e,Cg);return(0,Xt.jsx)("input",(0,c.A)({type:a,className:Sr("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:t},r))});Ag.displayName="Input";const Sg=["asChild"];var Eg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=aa("Primitive.".concat(t)),a=s.forwardRef((e,a)=>{const{asChild:r}=e,s=l(e,Sg),i=r?n:t;return"undefined"!==typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,Xt.jsx)(i,(0,c.A)((0,c.A)({},s),{},{ref:a}))});return a.displayName="Primitive.".concat(t),(0,c.A)((0,c.A)({},e),{},{[t]:a})},{});var Fg=s.forwardRef((e,t)=>(0,Xt.jsx)(Eg.label,(0,c.A)((0,c.A)({},e),{},{ref:t,onMouseDown:t=>{var n;t.target.closest("button, input, select, textarea")||(null===(n=e.onMouseDown)||void 0===n||n.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})));Fg.displayName="Label";var Rg=Fg;const Ig=["className"],Tg=pa("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Pg=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Ig);return(0,Xt.jsx)(Rg,(0,c.A)({ref:t,className:Sr(Tg(),n)},a))});Pg.displayName=Rg.displayName;const Og=wn("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Bg=wn("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]),Lg=wn("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),Mg=wn("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),zg=wn("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Ug=["value","onChange","className"];function Vg(e){let{value:t,onChange:n,className:a=""}=e,r=l(e,Ug);const[i,o]=(0,s.useState)(!1);return(0,Xt.jsxs)("div",{className:"relative",children:[(0,Xt.jsx)(Ag,(0,c.A)({type:i?"text":"password",value:t,onChange:n,className:"pr-10 ".concat(a)},r)),(0,Xt.jsx)("button",{type:"button",onClick:()=>o(e=>!e),className:"absolute right-3 top-1/2 -translate-y-1/2 text-ndor-ink-muted hover:text-ndor-ink transition-colors","aria-label":i?"Hide password":"Show password",tabIndex:-1,"data-testid":"".concat(r["data-testid"]||"password","-toggle"),children:i?(0,Xt.jsx)(Mg,{className:"h-4 w-4"}):(0,Xt.jsx)(zg,{className:"h-4 w-4"})})]})}function qg(e){let{compact:t=!1}=e;const n=t?"rounded-lg border border-ndor-edge bg-ndor-surface/60 p-3":"rounded-xl border border-ndor-edge bg-ndor-surface/60 p-5",a="text-[10px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui",r=t?"mt-2 space-y-1 text-[12px] text-ndor-ink-secondary leading-snug":"mt-3 space-y-1.5 text-sm text-ndor-ink-secondary leading-relaxed";return(0,Xt.jsxs)("div",{className:t?"grid grid-cols-2 gap-3":"grid grid-cols-2 gap-5",children:[(0,Xt.jsxs)("div",{className:n,"data-testid":"auth-brand-candidates-card",children:[(0,Xt.jsx)("p",{className:a,children:"For Candidates"}),(0,Xt.jsxs)("ul",{className:r,children:[(0,Xt.jsx)("li",{children:"Track roles"}),(0,Xt.jsx)("li",{children:"Analyse fit"}),(0,Xt.jsx)("li",{children:"Generate tailored CVs & cover letters"}),(0,Xt.jsx)("li",{children:"Assemble stronger application packs"})]})]}),(0,Xt.jsxs)("div",{className:n,"data-testid":"auth-brand-employers-card",children:[(0,Xt.jsx)("p",{className:a,children:"For Employers"}),(0,Xt.jsxs)("ul",{className:r,children:[(0,Xt.jsx)("li",{children:"Post roles"}),(0,Xt.jsx)("li",{children:"Screen applicants"}),(0,Xt.jsx)("li",{children:"Rank candidates with evidence"}),(0,Xt.jsx)("li",{children:"Run structured hiring workflows"})]})]})]})}function Wg(e){let{variant:t="desktop"}=e;return"mobile"===t?(0,Xt.jsx)("div",{"data-testid":"auth-brand-panel-mobile",className:"lg:hidden relative brand-hex-grid rounded-2xl border border-ndor-edge/70 bg-ndor-canvas/40 px-5 py-7 sm:px-7 sm:py-9 mb-6 sm:mb-8 overflow-hidden",children:(0,Xt.jsxs)("div",{className:"relative z-[1] flex flex-col gap-5 sm:gap-6",children:[(0,Xt.jsxs)("div",{className:"flex flex-col items-center text-center gap-3",children:[(0,Xt.jsx)(Wf,{variant:"symbol",size:64,className:"sm:hidden"}),(0,Xt.jsx)(Wf,{variant:"symbol",size:80,className:"hidden sm:block"}),(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsxs)("p",{className:"text-[28px] sm:text-[32px] font-serif-display font-semibold text-ndor-ink tracking-tight leading-none",children:["NDOR",(0,Xt.jsx)("span",{className:"text-gold-accent",children:"Flow"})]}),(0,Xt.jsx)("p",{className:"text-[10px] sm:text-[11px] uppercase tracking-[0.24em] text-ndor-ink-secondary font-mono-ui",children:"Decision Intelligence"})]})]}),(0,Xt.jsxs)("div",{className:"text-center space-y-1.5",children:[(0,Xt.jsx)("h2",{className:"text-[20px] sm:text-[22px] font-serif-display font-semibold text-ndor-ink leading-tight tracking-tight",children:"Every application, backed by evidence."}),(0,Xt.jsx)("p",{className:"text-[15px] sm:text-base font-serif-display italic text-gold-accent leading-snug",children:"Apply smarter. Interview stronger."})]}),(0,Xt.jsx)(qg,{compact:!0}),(0,Xt.jsxs)("div",{className:"flex items-center justify-center gap-3 pt-1",children:[(0,Xt.jsx)("span",{className:"inline-block h-[1px] w-8 bg-ndor-gold"}),(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.22em] text-ndor-ink-secondary font-mono-ui",children:"Premium \xb7 Audit-ready \xb7 Private"}),(0,Xt.jsx)("span",{className:"inline-block h-[1px] w-8 bg-ndor-gold"})]})]})}):(0,Xt.jsx)("div",{"data-testid":"auth-brand-panel-desktop",className:"absolute inset-0 flex items-center px-16 xl:px-24 py-12 overflow-y-auto",children:(0,Xt.jsxs)("div",{className:"relative z-[1] w-full max-w-2xl space-y-10",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-5",children:[(0,Xt.jsx)(Wf,{variant:"symbol",size:88}),(0,Xt.jsxs)("div",{className:"leading-none",children:[(0,Xt.jsxs)("p",{className:"text-5xl font-serif-display font-semibold tracking-tight text-ndor-ink",children:["NDOR",(0,Xt.jsx)("span",{className:"text-gold-accent",children:"Flow"})]}),(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.28em] text-ndor-ink-secondary font-mono-ui mt-3",children:"Decision Intelligence"})]})]}),(0,Xt.jsxs)("div",{className:"space-y-3",children:[(0,Xt.jsx)("h2",{className:"text-[34px] xl:text-[40px] font-serif-display font-semibold text-ndor-ink leading-[1.08] tracking-tight",children:"Every application, backed by evidence."}),(0,Xt.jsx)("p",{className:"text-xl xl:text-2xl font-serif-display italic text-gold-accent leading-snug",children:"Apply smarter. Interview stronger."}),(0,Xt.jsx)("p",{className:"text-sm xl:text-[15px] text-ndor-ink-secondary leading-relaxed max-w-lg pt-1",children:"NDORFlow helps you apply with the rigour employers respect. Evidence-led fit analysis, tailored CVs, and application packs \u2014 defensible line by line."})]}),(0,Xt.jsx)(qg,{}),(0,Xt.jsxs)("div",{className:"flex items-center gap-3 pt-1",children:[(0,Xt.jsx)("span",{className:"inline-block h-[1px] w-10 bg-ndor-gold"}),(0,Xt.jsx)("span",{className:"text-[11px] uppercase tracking-[0.25em] text-ndor-ink-secondary font-mono-ui",children:"Premium. Audit-ready. Private."})]})]})})}function Hg(){const{signIn:e,resendConfirmation:t}
2=tn(),[n]=Pt(),a="1"===n.get("just_signed_up"),[r,i]=(0,s.useState)(""),[o,l]=(0,s.useState)(""),[c,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(!1),[p,h]=(0,s.useState)(!1),[f,x]=(0,s.useState)("");return(0,Xt.jsxs)("div",{className:"flex flex-col min-h-screen bg-ndor-canvas","data-testid":"login-page",children:[(0,Xt.jsxs)("div",{className:"flex flex-1",children:[(0,Xt.jsx)("div",{className:"hidden lg:flex lg:flex-1 relative brand-hex-grid",children:(0,Xt.jsx)(Wg,{variant:"desktop"})}),(0,Xt.jsx)("div",{className:"flex flex-1 min-w-0 flex-col justify-center px-6 py-10 sm:py-12 lg:px-16 bg-ndor-surface",children:(0,Xt.jsxs)("div",{className:"mx-auto w-full max-w-md sm:max-w-lg lg:max-w-sm",children:[(0,Xt.jsx)(Wg,{variant:"mobile"}),(0,Xt.jsx)("div",{className:"hidden lg:flex mb-12 items-center gap-3",children:(0,Xt.jsx)(Wf,{variant:"symbol",size:44})}),(0,Xt.jsx)("h1",{className:"text-3xl sm:text-4xl font-serif-display font-semibold tracking-tight text-ndor-ink",children:"Welcome back"}),(0,Xt.jsx)("p",{className:"text-sm sm:text-[15px] text-ndor-ink-secondary mt-2",children:"Sign in to your account to continue."}),a&&(0,Xt.jsxs)("div",{className:"mt-5 flex items-start gap-2.5 rounded-lg border border-emerald-500/30 bg-emerald-500/10 p-3 text-sm text-emerald-200","data-testid":"login-just-signed-up-banner",children:[(0,Xt.jsx)(Og,{className:"h-4 w-4 shrink-0 mt-[2px]"}),(0,Xt.jsx)("span",{children:"Welcome back \u2014 sign in to activate your plan."})]}),(0,Xt.jsxs)("form",{onSubmit:async t=>{if(t.preventDefault(),d(""),h(!1),x(""),!r.trim()||!o)return void d("Please fill in all fields.");m(!0);const{error:n}=await e(r.trim(),o);n&&(d(n.message),h(!!n._isEmailUnverified),m(!1))},noValidate:!0,className:"mt-8 space-y-5",children:[c&&(0,Xt.jsxs)("div",{className:"rounded-lg bg-ndor-error-light border border-ndor-error-border p-3 text-sm text-ndor-error","data-testid":"login-error",children:[c,p&&(0,Xt.jsxs)("div",{className:"mt-2 pt-2 border-t border-ndor-error-border",children:["sent"===f?(0,Xt.jsxs)("p",{className:"text-ndor-success text-xs flex items-center gap-1.5",children:[(0,Xt.jsx)(Bg,{className:"h-3.5 w-3.5"})," Confirmation email resent."]}):(0,Xt.jsx)("button",{type:"button",onClick:async()=>{x("sending");const{error:e}=await t(r.trim());x(e?"error":"sent")},disabled:"sending"===f,className:"text-xs font-medium underline hover:no-underline disabled:opacity-50","data-testid":"login-resend-confirmation",children:"sending"===f?"Sending...":"Resend confirmation email"}),"error"===f&&(0,Xt.jsx)("p",{className:"text-xs mt-1",children:"Could not resend. Try again shortly."})]})]}),(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{htmlFor:"email",className:"text-ndor-ink",children:"Email"}),(0,Xt.jsx)(Ag,{id:"email",type:"email",placeholder:"[email protected]",value:r,onChange:e=>i(e.target.value),className:"h-11","data-testid":"login-email-input"})]}),(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{htmlFor:"password",className:"text-ndor-ink",children:"Password"}),(0,Xt.jsx)(Vg,{id:"password",placeholder:"Enter your password",value:o,onChange:e=>l(e.target.value),className:"h-11","data-testid":"login-password-input"})]}),(0,Xt.jsxs)(Rr,{type:"submit",className:"w-full h-11 font-medium",disabled:u,"data-testid":"login-submit-button",children:[u&&(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-2"}),u?"Signing in...":"Sign in"]}),(0,Xt.jsx)("div",{className:"text-right",children:(0,Xt.jsx)(Et,{to:"/forgot-password","data-testid":"login-forgot-password-link",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink hover:underline",children:"Forgot password?"})})]}),(0,Xt.jsxs)("p",{className:"mt-8 text-center text-sm text-ndor-ink-secondary font-manrope",children:["Don't have an account?"," ",(0,Xt.jsx)(Et,{to:"/signup",className:"font-medium text-ndor-ink hover:underline","data-testid":"goto-signup-link",children:"Sign up"})]})]})})]}),(0,Xt.jsx)(Xv,{variant:"auth"})]})}const Gg=wn("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),Kg=wn("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);function Yg(){const e="ABCDEFGHJKLMNPQRSTUVWXYZ23456789";let t="";for(let n=0;n<4;n++)t+=e[Math.floor(32*Math.random())];return t}function Jg(e){let{onChange:t,testId:n="signup-captcha"}=e;
2const a=(0,s.useRef)(null),[r,i]=(0,s.useState)(()=>Yg()),[o,l]=(0,s.useState)(""),[c,d]=(0,s.useState)(!1),u=(0,s.useCallback)(e=>{const t=a.current;t&&function(e,t){const n=e.getContext("2d"),{width:a,height:r}=e;n.clearRect(0,0,a,r),n.fillStyle="rgba(14,20,33,1)",n.fillRect(0,0,a,r);for(let s=0;s<60;s++)n.fillStyle=s%3===0?"rgba(201,164,92,0.35)":"rgba(91,124,255,0.25)",n.fillRect(Math.random()*a,Math.random()*r,Math.random()<.8?1:2,Math.random()<.8?1:2);n.strokeStyle="rgba(165,180,208,0.4)",n.lineWidth=1.2,n.beginPath(),n.moveTo(0,r*(.3+.4*Math.random())),n.bezierCurveTo(.3*a,r*Math.random(),.6*a,r*Math.random(),a,r*(.3+.4*Math.random())),n.stroke(),n.textBaseline="middle";for(let s=0;s<t.length;s++){const e=14+28*s,a=r/2+6*(Math.random()-.5),i=.35*(Math.random()-.5);n.save(),n.translate(e,a),n.rotate(i),n.fillStyle=s%2===0?"#E8EEF9":"#C9A45C",n.font='600 24px "Cormorant Garamond", serif',n.fillText(t[s],0,0),n.restore()}}(t,e)},[]);(0,s.useEffect)(()=>{u(r)},[r,u]),(0,s.useEffect)(()=>{const e=o.trim().length===r.length&&o.trim().toUpperCase()===r;e!==c&&(d(e),t&&t(e))},[o,r,c,t]);return(0,Xt.jsxs)("div",{"data-testid":n,className:"space-y-2",children:[(0,Xt.jsx)("label",{className:"block text-xs uppercase tracking-[0.16em] text-ndor-ink-secondary font-mono-ui",children:"Human check"}),(0,Xt.jsxs)("div",{className:"flex items-stretch gap-2",children:[(0,Xt.jsx)("canvas",{ref:a,width:140,height:44,className:"rounded-md border border-ndor-edge bg-ndor-surface-alt","aria-label":"CAPTCHA challenge image","data-testid":"".concat(n,"-canvas")}),(0,Xt.jsx)("button",{type:"button",onClick:()=>{l(""),i(Yg()),t&&t(!1)},"aria-label":"Refresh challenge",title:"New challenge","data-testid":"".concat(n,"-refresh"),className:"px-2 rounded-md border border-ndor-edge bg-ndor-surface-alt text-ndor-ink-secondary hover:text-ndor-ink hover:border-ndor-gold/50 transition-colors",children:(0,Xt.jsx)(Kg,{className:"h-4 w-4"})}),(0,Xt.jsx)("input",{type:"text",value:o,onChange:e=>l(e.target.value.slice(0,6)),placeholder:"Enter code",autoComplete:"off",maxLength:6,"aria-label":"Type the CAPTCHA code","data-testid":"".concat(n,"-input"),className:"flex-1 min-w-0 rounded-md border bg-ndor-surface-alt px-3 text-sm text-ndor-ink placeholder:text-ndor-ink-muted focus:outline-none transition-colors ".concat(c?"border-ndor-success/60 ring-1 ring-ndor-success/40":"border-ndor-edge focus:border-ndor-gold/40")})]}),!c&&o.length>=r.length&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-error",children:"Code does not match \u2014 try again."})]})}const $g=[{key:"length",label:"At least 8 characters",test:e=>e.length>=8},{key:"upper",label:"One uppercase letter",test:e=>/[A-Z]/.test(e)},{key:"lower",label:"One lowercase letter",test:e=>/[a-z]/.test(e)},{key:"digit",label:"One number",test:e=>/\d/.test(e)},{key:"symbol",label:"One special character",test:e=>/[^A-Za-z0-9]/.test(e)}];function Xg(){const{signUp:e,resendConfirmation:t}=tn(),[n,a]=(0,s.useState)(""),[r,i]=(0,s.useState)(""),[o,l]=(0,s.useState)(""),[d,u]=(0,s.useState)(""),[m,p]=(0,s.useState)(""),[h,f]=(0,s.useState)(""),[x,v]=(0,s.useState)(!1),[g,y]=(0,s.useState)("candidate"),[b,w]=(0,s.useState)(""),[j,k]=(0,s.useState)(!1),[N,_]=(0,s.useState)(!1),[D,C]=(0,s.useState)(""),A=(0,s.useMemo)(()=>$g.map(e=>(0,c.A)((0,c.A)({},e),{},{ok:e.test(m)})),[m]),S=A.every(e=>e.ok),E=m.length>0&&m===h,F=n.trim()&&r.trim()&&d.trim(),R="true"===String("true").toLowerCase(),I="candidate"===g||R&&"employer"===g,T=!j&&F&&S&&E&&x&&I,P=j?"":n.trim()&&r.trim()?d.trim()?S?E?x?I?"":"Choose whether you are signing up as a Candidate or an Employer.":"Complete the human check.":"Confirm-password must match your password.":"Password must satisfy every rule below.":"Enter your email address.":"Enter your first and last name.",O=async()=>{C("");const{error:e}=await t(d.trim());C(e?e.message:"Confirmation email resent.")};return N?(0,Xt.jsxs)("div",{className:"flex min-h-screen bg-ndor-canvas","data-testid":"signup-confirmation",children:[(0,Xt.jsx)("div",{className:"flex flex-1 flex-col justify-center px-6 py-12 lg:px-16 bg-ndor-surface",children:(0,Xt.jsxs)("div",{className:"mx-auto w-full max-w-sm text-center",children:[(0,Xt.jsx)("div",{className:"mb-8 flex justify-center",children:(0,Xt.jsx)(Wf,{variant:"symbol",size:56})}),(0,Xt.jsx)(Bg,{className:"h-12 w-12 mx-auto text-ndor-gold mb-4"}),(0,Xt.jsx)("h1",{className:"text-2xl font-serif-display font-semibold tracking-tight text-ndor-ink",children:"Check your email"}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-secondary mt-3 leading-relaxed",children:["We sent a confirmation link to ",(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:d}),". Click it, then sign in."]}),(0,Xt.jsx)(Rr,{type:"button",onClick:O,variant:"outline",className:"mt-6 border-ndor-edge bg-ndor-surface-alt","data-testid":"resend-button",children:"Resend confirmation email"}),D&&(0,Xt.jsx)("p",{className:"mt-3 text-xs text-ndor-ink-secondary","data-testid":"resend-status",children:D}),(0,Xt.jsx)("p",{className:"mt-8 text-sm text-ndor-ink-secondary",children:(0,Xt.jsx)(Et,{to:"/login",className:"text-ndor-info hover:text-ndor-primary-hover",children:"\u2190 Back to login"})})]})}),(0,Xt.jsx)("div",{className:"hidden lg:block lg:flex-1 relative brand-hex-grid",children:(0,Xt.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-12",children:(0,Xt.jsx)(Wf,{variant:"symbol",size:96,className:"brand-symbol-pulse"})})})]}):(0,Xt.jsxs)("div",{className:"flex flex-col min-h-screen bg-ndor-canvas","data-testid":"signup-page",children:[(0,Xt.jsxs)("div",{className:"flex flex-1",children:[(0,Xt.jsx)("div",{className:"hidden lg:flex lg:flex-1 relative brand-hex-grid",children:(0,Xt.jsx)(Wg,{variant:"desktop"})}),(0,Xt.jsx)("div",{className:"flex flex-1 min-w-0 flex-col justify-center px-6 py-10 sm:py-12 lg:px-16 bg-ndor-surface",children:(0,Xt.jsxs)("div",{className:"mx-auto w-full max-w-md
2sm:max-w-lg lg:max-w-md",children:[(0,Xt.jsx)(Wg,{variant:"mobile"}),(0,Xt.jsx)("div",{className:"hidden lg:flex mb-12 items-center gap-3",children:(0,Xt.jsx)(Wf,{variant:"symbol",size:44})}),(0,Xt.jsx)("h1",{className:"text-3xl sm:text-4xl font-serif-display font-semibold tracking-tight text-ndor-ink",children:"Create your account"}),(0,Xt.jsx)("p",{className:"text-sm sm:text-[15px] text-ndor-ink-secondary mt-2",children:"Candidates and employers. One workspace."}),(0,Xt.jsxs)("form",{onSubmit:async t=>{if(t.preventDefault(),w(""),!F)return void w("First name, last name, and email are required.");if(!S)return void w("Password does not satisfy all requirements.");if(!E)return void w("Passwords do not match.");if(!x)return void w("Please complete the CAPTCHA.");if(!I)return void w("Please choose Candidate or Employer.");k(!0),Ht("signup_started",{role:g});const{data:a,error:s}=await e(d.trim(),m,{first_name:n.trim(),last_name:r.trim(),nickname:o.trim()||null,role:g});s?(w(s.message),k(!1)):null!==a&&void 0!==a&&a.session?Ht("signup_completed",{role:g,confirmation_required:!1}):(_(!0),k(!1),Ht("signup_completed",{role:g,confirmation_required:!0}))},className:"mt-8 space-y-5","data-testid":"signup-form",children:[(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"first_name",className:"text-ndor-ink",children:"First name"}),(0,Xt.jsx)(Ag,{id:"first_name","data-testid":"first-name-input",autoComplete:"given-name",value:n,onChange:e=>a(e.target.value),required:!0,className:"bg-ndor-surface-alt border-ndor-edge text-ndor-ink"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"last_name",className:"text-ndor-ink",children:"Last name"}),(0,Xt.jsx)(Ag,{id:"last_name","data-testid":"last-name-input",autoComplete:"family-name",value:r,onChange:e=>i(e.target.value),required:!0,className:"bg-ndor-surface-alt border-ndor-edge text-ndor-ink"})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsxs)(Pg,{htmlFor:"nickname",className:"text-ndor-ink",children:["Nickname ",(0,Xt.jsx)("span",{className:"text-ndor-ink-muted font-normal",children:"(optional)"})]}),(0,Xt.jsx)(Ag,{id:"nickname","data-testid":"nickname-input",autoComplete:"nickname",value:o,onChange:e=>l(e.target.value),placeholder:"What should we call you?",className:"bg-ndor-surface-alt border-ndor-edge text-ndor-ink"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"email",className:"text-ndor-ink",children:"Email"}),(0,Xt.jsx)(Ag,{id:"email","data-testid":"email-input",type:"email",autoComplete:"email",value:d,onChange:e=>u(e.target.value),required:!0,className:"bg-ndor-surface-alt border-ndor-edge text-ndor-ink"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"password",className:"text-ndor-ink",children:"Password"}),(0,Xt.jsx)(Vg,{id:"password","data-testid":"password-input",autoComplete:"new-password",value:m,onChange:e=>p(e.target.value),required:!0}),(0,Xt.jsx)("ul",{className:"mt-2 grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1","data-testid":"password-checklist",children:A.map(e=>(0,Xt.jsxs)("li",{"data-testid":"rule-".concat(e.key,"-").concat(e.ok?"pass":"fail"),className:"flex items-center gap-1.5 text-xs ".concat(e.ok?"text-ndor-success":"text-ndor-ink-muted"),children:[e.ok?(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5"}):(0,Xt.jsx)(Gg,{className:"h-3.5 w-3.5"}),e.label]},e.key))})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"confirm_password",className:"text-ndor-ink",children:"Confirm password"}),(0,Xt.jsx)(Vg,{id:"confirm_password","data-testid":"confirm-password-input",autoComplete:"new-password",value:h,onChange:e=>f(e.target.value),required:!0}),h.length>0&&!E&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-error","data-testid":"confirm-password-mismatch",children:"Passwords do not match."}),E&&(0,Xt.jsxs)("p",{className:"text-xs text-ndor-success flex items-center gap-1.5","data-testid":"confirm-password-match",children:[(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5"})," Passwords match."]})]}),(0,Xt.jsx)(Jg,{onChange:v,testId:"signup-captcha"}),(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":"signup-role-selector",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"I'm signing up as"}),(0,Xt.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,Xt.jsxs)("button",{type:"button",onClick:()=>y("candidate"),"data-testid":"signup-role-candidate","aria-pressed":"candidate"===g,className:"rounded-lg border p-3 text-left transition-colors ".concat("candidate"===g?"border-ndor-gold bg-ndor-surface-alt ring-1 ring-ndor-gold/50":"border-ndor-edge hover:border-ndor-ink-muted"),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(En,{className:"h-4 w-4 text-ndor-ink-secondary"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"Candidate"})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1 leading-snug",children:"Track roles, analyse fit, tailor applications."})]}),(0,Xt.jsxs)("button",{type:"button",onClick:R?()=>y("employer"):void 0,disabled:!R,"data-testid":"signup-role-employer","aria-disabled":!R,"aria-pressed":R&&"employer"===g,className:"rounded-lg border p-3 text-left transition-colors ".concat(R?"employer"===g?"border-ndor-gold bg-ndor-surface-alt ring-1 ring-ndor-gold/50":"border-ndor-edge hover:border-ndor-ink-muted":"border-ndor-edge bg-ndor-surface-alt/30 curs
2or-not-allowed opacity-70"),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(kn,{className:"h-4 w-4 text-ndor-ink-muted"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"Employer"}),!R&&(0,Xt.jsx)("span",{className:"ml-auto text-[9px] uppercase tracking-[0.16em] font-mono-ui px-1.5 py-0.5 rounded border border-ndor-gold/40 text-ndor-gold bg-ndor-gold/5","data-testid":"signup-role-employer-coming-soon",children:"Coming soon"})]}),R?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1 leading-snug",children:"Post roles, screen evidence, rank applicants."}):(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted mt-1 leading-snug","data-testid":"signup-role-employer-waitlist-copy",children:["Employer workspace \u2014 coming soon. We're opening employer access after candidate launch. Contact"," ",(0,Xt.jsx)("a",{href:"mailto:[email protected]?subject=NDORFlow%20-%20Employer%20waitlist",className:"text-ndor-info hover:text-ndor-primary-hover underline","data-testid":"signup-role-employer-waitlist-link",onClick:e=>e.stopPropagation(),children:"[email protected]"})," ","and mention NDORFlow to join the waitlist."]})]})]})]}),b&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-error bg-ndor-error-light border border-ndor-error-border rounded-md px-3 py-2","data-testid":"signup-error",children:b}),(0,Xt.jsx)(Rr,{type:"submit",className:"w-full bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground",disabled:!T,"data-testid":"signup-submit",children:j?(0,Xt.jsxs)("span",{className:"inline-flex items-center",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-2"})," Creating account\u2026"]}):"Create account & enter"}),!T&&P&&(0,Xt.jsx)("p",{className:"text-center text-xs text-ndor-ink-muted -mt-2","data-testid":"signup-submit-helper",children:P}),(0,Xt.jsxs)("p",{className:"text-center text-sm text-ndor-ink-secondary",children:["Already have an account?"," ",(0,Xt.jsx)(Et,{to:"/login",className:"text-ndor-info hover:text-ndor-primary-hover","data-testid":"login-link",children:"Sign in"})]})]})]})})]}),(0,Xt.jsx)(Xv,{variant:"auth"})]})}const Qg=wn("mail-check",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]),Zg=wn("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);function ey(){const[e,t]=(0,s.useState)(""),[n,a]=(0,s.useState)(!1),[r,i]=(0,s.useState)(!1),[o,l]=(0,s.useState)("");return(0,Xt.jsxs)("div",{className:"flex flex-col min-h-screen bg-ndor-canvas","data-testid":"forgot-password-page",children:[(0,Xt.jsx)("div",{className:"flex flex-1 items-center justify-center px-6 py-12",children:(0,Xt.jsxs)("div",{className:"w-full max-w-md
2space-y-8",children:[(0,Xt.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,Xt.jsx)(Wf,{variant:"symbol",size:64}),(0,Xt.jsxs)("p",{className:"text-3xl font-serif-display font-semibold text-ndor-ink tracking-tight",children:["NDOR",(0,Xt.jsx)("span",{className:"text-gold-accent",children:"Flow"})]})]}),r?(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-edge bg-ndor-surface p-6 space-y-3 text-center","data-testid":"forgot-password-sent",children:[(0,Xt.jsx)(Qg,{className:"h-8 w-8 mx-auto text-ndor-gold"}),(0,Xt.jsx)("h1",{className:"text-xl font-serif-display font-semibold text-ndor-ink",children:"Check your inbox"}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed",children:["If an NDORFlow account exists for ",(0,Xt.jsx)("strong",{children:e.trim()}),", we've emailed you a link to reset your password. The link expires in 60 minutes."]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Didn't receive it? Check your spam folder, or try again with another email."}),(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",className:"mt-4","data-testid":"forgot-password-back-to-login",children:(0,Xt.jsxs)(Et,{to:"/login",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"}),"Back to sign in"]})})]}):(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-edge bg-ndor-surface p-6 space-y-5",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h1",{className:"text-xl font-serif-display font-semibold text-ndor-ink",children:"Reset your password"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-1",children:"Enter the email you signed up with. We'll send you a secure link to set a new password."})]}),o&&(0,Xt.jsx)("div",{className:"rounded-lg bg-ndor-error-light border border-ndor-error-border p-3 text-sm text-ndor-error","data-testid":"forgot-password-error",children:o}),(0,Xt.jsxs)("form",{onSubmit:async t=>{if(t.preventDefault(),l(""),e.trim()){a(!0);try{const t="".concat(window.location.origin,"/auth/reset"),{error:n}=await Mt.supabase.auth.resetPasswordForEmail(e.trim(),{redirectTo:t});0,i(!0)}finally{a(!1)}}else l("Please enter your email.")},noValidate:!0,className:"space-y-4",children:[(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{htmlFor:"forgot-email",className:"text-ndor-ink",children:"Email"}),(0,Xt.jsx)(Ag,{id:"forgot-email",type:"email",placeholder:"[email protected]",value:e,onChange:e=>t(e.target.value),className:"h-11","data-testid":"forgot-password-email-input"})]}),(0,Xt.jsxs)(Rr,{type:"submit",className:"w-full h-11 font-medium",disabled:n,"data-testid":"forgot-password-submit",children:[n&&(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-2"}),n?"Sending\u2026":"Send reset link"]})]}),(0,Xt.jsxs)("p",{className:"text-center text-sm text-ndor-ink-secondary",children:["Remembered your password?"," ",(0,Xt.jsx)(Et,{to:"/login",className:"font-medium text-ndor-ink hover:underline","data-testid":"forgot-password-login-link",children:"Sign in"})]}),(0,Xt.jsxs)("p",{className:"text-center text-xs text-ndor-ink-muted pt-1","data-testid":"forgot-email-hint",children:["Forgot which email you used? Contact"," ",(0,Xt.jsx)("a",{href:"mailto:[email protected]?subject=NDORFlow%20-%20Forgot%20account%20email",className:"text-ndor-info hover:text-ndor-primary-hover underline","data-testid":"forgot-email-support-link",children:"[email protected]"})," ","and mention NDORFlow."]})]})]})}),(0,Xt.jsx)(Xv,{variant:"auth"})]})}const ty=wn("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),ny=wn("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),ay=["message"];const ry=Array(12).fill(0),sy=e=>{let{visible:t,className:n}=e;return s.createElement("div",{className:["sonner-loading-wrapper",n].filter(
2Boolean).join(" "),"data-visible":t},s.createElement("div",{className:"sonner-spinner"},ry.map((e,t)=>s.createElement("div",{className:"sonner-loading-bar",key:"spinner-bar-".concat(t)}))))},iy=s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},s.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),oy=s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},s.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),ly=s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},s.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),cy=s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},s.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),dy=s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},s.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}));let uy=1;const my=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;const{message:n}=e,a=l(e,ay),r="number"===typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:uy++,s=this.toasts.find(e=>e.id===r),i=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),s?this.toasts=this.toasts.map(t=>t.id===r?(this.publish((0,c.A)((0,c.A)((0,c.A)({},t),e),{},{id:r,title:n})),(0,c.A)((0,c.A)((0,c.A)({},t),e),{},{id:r,dismissible:i,title:n})):t):this.addToast((0,c.A)((0,c.A)({title:n},a),{},{dismissible:i,id:r})),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create((0,c.A)((0,c.A)({},t),{},{message:e})),this.error=(e,t)=>this.create((0,c.A)((0,c.A)({},t),{},{message:e,type:"error"})),this.success=(e,t)=>this.create((0,c.A)((0,c.A)({},t),{},{type:"success",message:e})),this.info=(e,t)=>this.create((0,c.A)((0,c.A)({},t),{},{type:"info",message:e})),this.warning=(e,t)=>this.create((0,c.A)((0,c.A)({},t),{},{type:"warning",message:e})),this.loading=(e,t)=>
2this.create((0,c.A)((0,c.A)({},t),{},{type:"loading",message:e})),this.promise=(e,t)=>{if(!t)return;let n;void 0!==t.loading&&(n=this.create((0,c.A)((0,c.A)({},t),{},{promise:e,type:"loading",message:t.loading,description:"function"!==typeof t.description?t.description:void 0})));const a=Promise.resolve(e instanceof Function?e():e);let r,i=void 0!==n;const o=a.then(async e=>{r=["resolve",e];if(s.isValidElement(e))i=!1,this.create({id:n,type:"default",message:e});else if(py(e)&&!e.ok){i=!1;const a="function"===typeof t.error?await t.error("HTTP error! status: ".concat(e.status)):t.error,r="function"===typeof t.description?await t.description("HTTP error! status: ".concat(e.status)):t.description,o="object"===typeof a&&!s.isValidElement(a)?a:{message:a};this.create((0,c.A)({id:n,type:"error",description:r},o))}else if(e instanceof Error){i=!1;const a="function"===typeof t.error?await t.error(e):t.error,r="function"===typeof t.description?await t.description(e):t.description,o="object"===typeof a&&!s.isValidElement(a)?a:{message:a};this.create((0,c.A)({id:n,type:"error",description:r},o))}else if(void 0!==t.success){i=!1;const a="function"===typeof t.success?await t.success(e):t.success,r="function"===typeof t.description?await t.description(e):t.description,o="object"===typeof a&&!s.isValidElement(a)?a:{message:a};this.create((0,c.A)({id:n,type:"success",description:r},o))}}).catch(async e=>{if(r=["reject",e],void 0!==t.error){i=!1;const a="function"===typeof t.error?await t.error(e):t.error,r="function"===typeof t.description?await t.description(e):t.description,o="object"===typeof a&&!s.isValidElement(a)?a:{message:a};this.create((0,c.A)({id:n,type:"error",description:r},o))}}).finally(()=>{i&&(this.dismiss(n),n=void 0),null==t.finally||t.finally.call(t)}),l=()=>new Promise((e,t)=>o.then(()=>"reject"===r[0]?t(r[1]):e(r[1])).catch(t));return"string"!==typeof n&&"number"!==typeof n?{unwrap:l}:Object.assign(n,{unwrap:l})},this.custom=(e,t)=>{const n=(null==t?void 0:t.id)||uy++;return this.create((0,c.A)({jsx:e(n),id:n},t)),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},py=e=>e&&"object"===typeof e&&"ok"in e&&"boolean"===typeof e.ok&&"status"in e&&"number"===typeof e.status,hy=(e,t)=>{const n=(null==t?void 0:t.id)||uy++;return my.addToast((0,c.A)((0,c.A)({title:e},t),{},{id:n})),n},fy=Object.assign(hy,{success:my.success,info:my.info,warning:my.warning,error:my.error,custom:my.custom,message:my.message,promise:my.promise,dismiss:my.dismiss,loading:my.loading},{getHistory:()=>my.toasts,getToasts:()=>my.getActiveToasts()});function xy(e){return void 0!==e.label}!function(e){if(!e||"undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}
vendor: 14,864 bytes, line 2
2("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
2const vy=3,gy=14;function yy(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(Boolean).join(" ")}const by=e=>{var t,n,a,r,i,o,l,d,u;const{invert:m,toast:p,unstyled:h,interacting:f,setHeights:x,visibleToasts:v,heights:g,index:y,toasts:b,expanded:w,removeToast:j,defaultRichColors:k,closeButton:N,style:_,cancelButtonStyle:D,actionButtonStyle:C,className:A="",descriptionClassName:S="",duration:E,position:F,gap:R,expandByDefault:I,classNames:T,icons:P,closeButtonAriaLabel:O="Close toast"}=e,[B,L]=s.useState(null),[M,z]=s.useState(null),[U,V]=s.useState(!1),[q,W]=s.useState(!1),[H,G]=s.useState(!1),[K,Y]=s.useState(!1),[J,$]=s.useState(!1),[X,Q]=s.useState(0),[Z,ee]=s.useState(0),te=s.useRef(p.duration||E||4e3),ne=s.useRef(null),ae=s.useRef(null),re=0===y,se=y+1<=v,ie=p.type,oe=!1!==p.dism
vendor: 4,375 bytes, line 2
2issible,le=p.className||"",ce=p.descriptionClassName||"",de=s.useMemo(()=>g.findIndex(e=>e.toastId===p.id)||0,[g,p.id]),ue=s.useMemo(()=>{var e;return null!=(e=p.closeButton)?e:N},[p.closeButton,N]),me=s.useMemo(()=>p.duration||E||4e3,[p.duration,E]),pe=s.useRef(0),he=s.useRef(0),fe=s.useRef(0),xe=s.useRef(null),[ve,ge]=F.split("-"),ye=s.useMemo(()=>g.reduce((e,t,n)=>n>=de?e:e+t.height,0),[g,de]),be=(()=>{const[e,t]=s.useState(document.hidden);return s.useEffect(()=>{const e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),we=p.invert||m,je="loading"===ie;he.current=s.useMemo(()=>de*R+ye,[de,ye]),s.useEffect(()=>{te.current=me},[me]),s.useEffect(()=>{V(!0)},[]),s.useEffect(()=>{const e=ae.current;if(e){const t=e.getBoundingClientRect().height;return ee(t),x(e=>[{toastId:p.id,height:t,position:p.position},...e]),()=>x(e=>e.filter(e=>e.toastId!==p.id))}},[x,p.id]),s.useLayoutEffect(()=>{if(!U)return;const e=ae.current,t=e.style.height;e.style.height="auto";const n=e.getBoundingClientRect().height;e.style.height=t,ee(n),x(e=>e.find(e=>e.toastId===p.id)?e.map(e=>e.toastId===p.id?(0,c.A)((0,c.A)({},e),{},{height:n}):e):[{toastId:p.id,height:n,position:p.position},...e])},[U,p.title,p.description,x,p.id,p.jsx,p.action,p.cancel]);const ke=s.useCallback(()=>{W(!0),Q(he.current),x(e=>e.filter(e=>e.toastId!==p.id)),setTimeout(()=>{j(p)},200)},[p,j,x,he]);s.useEffect(()=>{if(p.promise&&"loading"===ie||p.duration===1/0||"loading"===p.type)return;let e;return w||f||be?(()=>{if(fe.current<pe.current){const e=(new Date).getTime()-pe.current;te.current=te.current-e}fe.current=(new Date).getTime()})():te.current!==1/0&&(pe.current=(new Date).getTime(),e=setTimeout(()=>{null==p.onAutoClose||p.onAutoClose.call(p,p),ke()},te.current)),()=>clearTimeout(e)},[w,f,p,ie,be,ke]),s.useEffect(()=>{p.delete&&(ke(),null==p.onDismiss||p.onDismiss.call(p,p))},[ke,p.delete]);const Ne=p.icon||(null==P?void 0:P[ie])||(e=>{switch(e){case"success":return iy;case"info":return ly;case"warning":return oy;case"error":return cy;default:return null}})(ie);var _e,De;return s.createElement("li",{tabIndex:0,ref:ae,className:yy(A,le,null==T?void 0:T.toast,null==p||null==(t=p.classNames)?void 0:t.toast,null==T?void 0:T.default,null==T?void 0:T[ie],null==p||null==(n=p.classNames)?void 0:n[ie]),"data-sonner-toast":"","data-rich-colors":null!=(_e=p.richColors)?_e:k,"data-styled":!Boolean(p.jsx||p.unstyled||h),"data-mounted":U,"data-promise":Boolean(p.promise),"data-swiped":J,"data-removed":q,"data-visible":se,"data-y-position":ve,"data-x-position":ge,"data-index":y,"data-front":re,"data-swiping":H,"data-dismissible":oe,"data-type":ie,"data-invert":we,"data-swipe-out":K,"data-swipe-direction":M,"data-expanded":Boolean(w||I&&U),"data-testid":p.testId,style:(0,c.A)((0,c.A)({"--index":y,"--toasts-before":y,"--z-index":b.length-y,"--offset":"".concat(q?X:he.current,"px"),"--initial-height":I?"auto":"".concat(Z,"px")},_),p.style),onDragEnd:()=>{G(!1),L(null),xe.current=null},onPointerDown:e=>{2!==e.button&&!je&&oe&&(ne.current=new Date,Q(he.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(G(!0),xe.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,n;if(K||!oe)return;xe.current=null;const a=Number((null==(e=ae.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),r=Number((null==(t=ae.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),s=(new Date).getTime()-(null==(n=ne.current)?void 0:n.getTime()),i="x"===B?a:r,o=Math.abs(i)/s;if(Math.abs(i)>=45||o>.11)return Q(he.current),null==p.onDismiss||p.onDismiss.call(p,p),z("x"===B?a>0?"right":"left":r>0?"down":"up"),ke(),void Y(!0);var l,c;null==(l=ae.current)||l.style.setProperty("--swipe-amount-x","0px"),null==(c=ae.current)||c.style.setProperty("--swipe-amount-y","0px"),$(!1),G(!1),L(null)},onPointerMove:t=>{var n,a,r;if(!xe.current||!oe)return;if((null==(n=window.getSelection())?void 0:n.toString().length)>0)return;const s=t.clientY-xe.current.y,i=t.clientX-xe.current.x;var o;const l=null!=(o=e.swipeDirections)?o:function(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}(F);!B&&(Math.abs(i)>1||Math.abs(s)>1)&&L(Math.abs(i)>Math.abs(s)?"x":"y");let c={x:0,y:0};const d=e=>1/(1.5+Math.abs(e)/20);
2if("y"===B){if(l.includes("top")||l.includes("bottom"))if(l.includes("top")&&s<0||l.includes("bottom")&&s>0)c.y=s;else{const e=s*d(s);c.y=Math.abs(e)<Math.abs(s)?e:s}}else if("x"===B&&(l.includes("left")||l.includes("right")))if(l.includes("left")&&i<0||l.includes("right")&&i>0)c.x=i;else{const e=i*d(i);c.x=Math.abs(e)<Math.abs(i)?e:i}(Math.abs(c.x)>0||Math.abs(c.y)>0)&&$(!0),null==(a=ae.current)||a.style.setProperty("--swipe-amount-x","".concat(c.x,"px")),null==(r=ae.current)||r.style.setProperty("--swipe-amount-y","".concat(c.y,"px"))}},ue&&!p.jsx&&"loading"!==ie?s.createElement("button",{"aria-label":O,"data-disabled":je,"data-close-button":!0,onClick:je||!oe?()=>{}:()=>{ke(),null==p.onDismiss||p.onDismiss.call(p,p)},className:yy(null==T?void 0:T.closeButton,null==p||null==(a=p.classNames)?void 0:a.closeButton)},null!=(De=null==P?void 0:P.close)?De:dy):null,(ie||p.icon||p.promise)&&null!==p.icon&&(null!==(null==P?void 0:P[ie])||p.icon)?s.createElement("div",{"data-icon":"",className:yy(null==T?void 0:T.icon,null==p||null==(r=p.classNames)?void 0:r.icon)},p.promise||"loading"===p.type&&!p.icon?p.icon||function(){var e,t;return(null==P?void 0:P.loading)?s.createElement("div",{className:yy(null==T?void 0:T.loader,null==p||null==(t=p.classNames)?void 0:t.loader,"sonner-loader"),"data-visible":"loading"===ie},P.loading):s.createElement(sy,{className:yy(null==T?void 0:T.loader,null==p||null==(e=p.classNames)?void 0:e.loader),visible:"loading"===ie})}():null,"loading"!==p.type?Ne:null):null,s.createElement("div",{"data-content":"",className:yy(null==T?void 0:T.content,null==p||null==(i=p.classNames)?void 0:i.content)},s.createElement("div",{"data-title":"",className:yy(null==T?void 0:T.title,null==p||null==(o=p.classNames)?void 0:o.title)},p.jsx?p.jsx:"function"===typeof p.title?p.title():p.title),p.description?s.createElement("div",{"data-description":"",className:yy(S,ce,null==T?void 0:T.description,null==p||null==(l=p.classNames)?void 0:l.description)},"function"===typeof p.description?p.description():p.description):null),s.isValidElement(p.cancel)?p.cancel:p.cancel&&xy(p.cancel)?s.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||D,onClick:e=>{xy(p.cancel)&&oe&&(null==p.cancel.onClick||p.cancel.onClick.call(p.cancel,e),ke())},className:yy(null==T?void 0:T.cancelButton,null==p||null==(d=p.classNames)?void 0:d.cancelButton)},p.cancel.label):null,s.isValidElement(p.action)?p.action:p.action&&xy(p.action)?s.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||C,onClick:e=>{xy(p.action)&&(null==p.action.onClick||p.action.onClick.call(p.action,e),e.defaultPrevented||ke())},className:yy(null==T?void 0:T.actionButton,null==p||null==(u=p.classNames)?void 0:u.actionButton)},p.action.label):null)};function wy(){if("undefined"===typeof window)return"ltr";if("undefined"===typeof document)return"ltr";const e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}function jy(e,t){const n={};return[e,t].forEach((e,t)=>{const a=1===t,r=a?"--mobile-offset":"--offset",s=a?"16px":"24px";function i(e){["top","right","bottom","left"].forEach(t=>{n["".concat(r,"-").concat(t)]="number"===typeof e?"".concat(e,"px"):e})}"number"===typeof e||"string"===typeof e?i(e):"object"===typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?n["".concat(r,"-").concat(t)]=s:n["".concat(r,"-").concat(t)]="number"===typeof e[t]?"".concat(e[t],"px"):e[t]}):i(s)}),n}const ky=s.forwardRef(function(e,t){const{id:n,invert:a,position:r="bottom-right",hotkey:i=["altKey","KeyT"],expand:o,closeButton:l,className:d,offset:u,mobileOffset:m,theme:p="light",richColors:h,duration:f,style:x,visibleToasts:v=vy,toastOptions:g,dir:y=wy(),gap:b=gy,icons:w,containerAriaLabel:j="Notifications"}=e,[k,N]=s.useState([]),_=s.useMemo(()=>n?k.filter(e=>e.toasterId===n):k.filter(e=>!e.toasterId),[k,n]),D=s.useMemo(()=>Array.from(new Set([r].concat(_.filter(e=>e.position).map(e=>e.position)))),[_,r]),[C,A]=s.useState([]),[S,E]=s.useState(!1),[F,R]=s.useState(!1),[I,T]=s.useState("system"!==p?p:"undefined"!==typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dar
2k":"light"),P=s.useRef(null),O=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),B=s.useRef(null),L=s.useRef(!1),M=s.useCallback(e=>{N(t=>{var n;return(null==(n=t.find(t=>t.id===e.id))?void 0:n.delete)||my.dismiss(e.id),t.filter(t=>{let{id:n}=t;return n!==e.id})})},[]);return s.useEffect(()=>my.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{N(t=>t.map(t=>t.id===e.id?(0,c.A)((0,c.A)({},t),{},{delete:!0}):t))}):setTimeout(()=>{Br.flushSync(()=>{N(t=>{const n=t.findIndex(t=>t.id===e.id);return-1!==n?[...t.slice(0,n),(0,c.A)((0,c.A)({},t[n]),e),...t.slice(n+1)]:[e,...t]})})})}),[k]),s.useEffect(()=>{if("system"!==p)return void T(p);if("system"===p&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?T("dark"):T("light")),"undefined"===typeof window)return;const e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",e=>{let{matches:t}=e;T(t?"dark":"light")})}catch(t){e.addListener(e=>{let{matches:t}=e;try{T(t?"dark":"light")}catch(mK){console.error(mK)}})}},[p]),s.useEffect(()=>{k.length<=1&&E(!1)},[k]),s.useEffect(()=>{const e=e=>{var t;const n=i.every(t=>e[t]||e.code===t);var a;n&&(E(!0),null==(a=P.current)||a.focus());"Escape"!==e.code||document.activeElement!==P.current&&!(null==(t=P.current)?void 0:t.contains(document.activeElement))||E(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i]),s.useEffect(()=>{if(P.current)return()=>{B.current&&(B.current.focus({preventScroll:!0}),B.current=null,L.current=!1)}},[P.current]),s.createElement("section",{ref:t,"aria-label":"".concat(j," ").concat(O),tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},D.map((t,n)=>{var r;const[i,p]=t.split("-");return _.length?s.createElement("ol",{key:t,dir:"auto"===y?wy():y,tabIndex:-1,ref:P,className:d,"data-sonner-toaster":!0,"data-sonner-theme":I,"data-y-position":i,"data-x-position":p,style:(0,c.A)((0,c.A)({"--front-toast-height":"".concat((null==(r=C[0])?void 0:r.height)||0,"px"),"--width":"".concat(356,"px"),"--gap":"".concat(b,"px")},x),jy(u,m)),onBlur:e=>{L.current&&!e.currentTarget.contains(e.relatedTarget)&&(L.current=!1,B.current&&(B.current.focus({preventScroll:!0}),B.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||L.current||(L.current=!0,B.current=e.relatedTarget)},onMouseEnter:()=>E(!0),onMouseMove:()=>E(!0),onMouseLeave:()=>{F||E(!1)},onDragEnd:()=>E(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||R(!0)},onPointerUp:()=>R(!1)},_.filter(e=>!e.position&&0===n||e.position===t).map((n,r)=>{var i,c;return s.createElement(by,{key:n.id,icons:w,index:r,toast:n,defaultRichColors:h,duration:null!=(i=null==g?void 0:g.duration)?i:f,className:null==g?void 0:g.className,descriptionClassName:null==g?void 0:g.descriptionClassName,invert:a,visibleToasts:v,closeButton:null!=(c=null==g?void 0:g.closeButton)?c:l,interacting:F,position:t,style:null==g?void 0:g.style,unstyled:null==g?void 0:g.unstyled,classNames:null==g?void 0:g.classNames,cancelButtonStyle:null==g?void 0:g.cancelButtonStyle,actionButtonStyle:null==g?void 0:g.actionButtonStyle,closeButtonAriaLabel:null==g?void 0:g.closeButtonAriaLabel,removeToast:M,toasts:_.filter(e=>e.position==n.position),heights:C.filter(e=>e.position==n.position),setHeights:A,expandByDefault:o,gap:b,expanded:S,swipeDirections:e.swipeDirections})})):null}))});function Ny(){const e=ke(),[t,n]=(0,s.useState)("pending"),[a,r]=(0,s.useState)(""),[i,o]=(0,s.useState)(""),[l,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)("");(0,s.useEffect)(()=>{let e=!1;const t=(window.location.hash||"").toLowerCase(),a=t.includes("type=recovery")&&(t.includes("access_token=")||t.includes("code=")),{data:{subscription:r}}=Mt.supabase.auth.onAuthStateChange((t,a)=>{e||"PASSWORD_RECOVERY"===t&&a&&n("ready")});if(a){const t=setTimeout(()=>{e||n(e=>"pending"===e?"invalid":e)},4e3);return()=>{var n;e=!0,clearTimeout(t),null===r||void 0===r||null===(n=r.unsubscribe)||void 0===n||n.call(r)}}return n("invalid"),()=>{var t;e=!0,null===r||void 0===r||null===(t=r.unsubscribe)||void 0===t||t.call(r)}},[]);return(0,Xt.jsxs)("div",{className:"flex flex-col min-h-screen bg-ndor-canvas","data-testid":"reset-password-page",children:[(0,Xt.jsx)("div",{className:"flex flex-1 items-center justify-center px-6 py-12",children:(0,Xt.jsxs)("div",{className:"w-full max-w-md
2space-y-8",children:[(0,Xt.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,Xt.jsx)(Wf,{variant:"symbol",size:64}),(0,Xt.jsxs)("p",{className:"text-3xl font-serif-display font-semibold text-ndor-ink tracking-tight",children:["NDOR",(0,Xt.jsx)("span",{className:"text-gold-accent",children:"Flow"})]})]}),"pending"===t&&(0,Xt.jsxs)("div",{className:"flex items-center justify-center gap-2 text-ndor-ink-muted text-sm","data-testid":"reset-password-pending",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," Verifying reset link\u2026"]}),"invalid"===t&&(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-error-border bg-ndor-error-light p-6 space-y-3 text-center","data-testid":"reset-password-invalid",children:[(0,Xt.jsx)(ty,{className:"h-8 w-8 mx-auto text-ndor-error"}),(0,Xt.jsx)("h1",{className:"text-xl font-serif-display font-semibold text-ndor-ink",children:"Reset link invalid or expired"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary",children:"Please request a new password reset link."}),(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",className:"mt-2",children:(0,Xt.jsx)("a",{href:"/forgot-password","data-testid":"reset-password-request-new",children:"Request new link"})})]}),"ready"===t&&(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-edge bg-ndor-surface p-6 space-y-5",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(ny,{className:"h-5 w-5 text-ndor-gold"}),(0,Xt.jsx)("h1",{className:"text-xl font-serif-display font-semibold text-ndor-ink",children:"Set a new password"})]}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-secondary",children:["Choose a password of at least ",8," characters. After saving, you'll be signed out and asked to sign in again with your new password."]}),d&&(0,Xt.jsx)("div",{className:"rounded-lg bg-ndor-error-light border border-ndor-error-border p-3 text-sm text-ndor-error","data-testid":"reset-password-error",children:d}),(0,Xt.jsxs)("form",{onSubmit:async t=>{if(t.preventDefault(),u(""),a.length<8)u("Password must be at least ".concat(8," characters."));else if(a===i){c(!0);try{const{error:t}=await Mt.supabase.auth.updateUser({password:a});if(t)return void u(t.message||"Could not update password. Please try again.");await Mt.supabase.auth.signOut(),fy.success("Password updated. Please sign in with your new password."),e("/login",{replace:!0})}finally{c(!1)}}else u("Passwords do not match.")},noValidate:!0,className:"space-y-4",children:[(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{htmlFor:"new-password",className:"text-ndor-ink",children:"New password"}),(0,Xt.jsx)(Vg,{id:"new-password",placeholder:"At least 8 characters",value:a,onChange:e=>r(e.target.value),className:"h-11","data-testid":"reset-password-new-input"})]}),(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{htmlFor:"confirm-password",className:"text-ndor-ink",children:"Confirm new password"}),(0,Xt.jsx)(Vg,{id:"confirm-password",placeholder:"Repeat your new password",value:i,onChange:e=>o(e.target.value),className:"h-11","data-testid":"reset-password-confirm-input"})]}),(0,Xt.jsxs)(Rr,{type:"submit",className:"w-full h-11 font-medium",disabled:l,"data-testid":"reset-password-submit",children:[l&&(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-2"}
2),l?"Updating\u2026":"Update password"]})]})]})]})}),(0,Xt.jsx)(Xv,{variant:"auth"})]})}const _y=["className"],Dy=["className"],Cy=["className"],Ay=["className"],Sy=["className"],Ey=["className"],Fy=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,_y);return(0,Xt.jsx)("div",(0,c.A)({ref:t,className:Sr("rounded-xl border bg-card text-card-foreground shadow",n)},a))});Fy.displayName="Card";const Ry=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Dy);return(0,Xt.jsx)("div",(0,c.A)({ref:t,className:Sr("flex flex-col space-y-1.5 p-6",n)},a))});Ry.displayName="CardHeader";const Iy=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Cy);return(0,Xt.jsx)("div",(0,c.A)({ref:t,className:Sr("font-semibold leading-none tracking-tight",n)},a))});Iy.displayName="CardTitle";const Ty=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Ay);return(0,Xt.jsx)("div",(0,c.A)({ref:t,className:Sr("text-sm text-muted-foreground",n)},a))});Ty.displayName="CardDescription";const Py=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Sy);return(0,Xt.jsx)("div",(0,c.A)({ref:t,className:Sr("p-6 pt-0",n)},a))});Py.displayName="CardContent";s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Ey);return(0,Xt.jsx)("div",(0,c.A)({ref:t,className:Sr("flex items-center p-6 pt-0",n)},a))}).displayName="CardFooter";const Oy=wn("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const By={loading:{title:"Verifying your invitation\u2026",icon:Lg,tone:"neutral"},not_authenticated:{title:"You need to sign in first",icon:Qg,tone:"neutral"},no_token:{title:"This invitation link is incomplete",icon:Oy,tone:"warn"},accepting:{title:"Joining the organisation\u2026",icon:Lg,tone:"neutral"},success:{title:"Welcome to the organisation",icon:Og,tone:"success"},not_found:{title:"Invitation not found",icon:Gg,tone:"error"},expired:{title:"This invitation has expired",icon:Gg,tone:"error"},revoked:{title:"This invitation has been revoked",icon:Gg,tone:"error"},already_accepted:{title:"This invitation has already been used",icon:Oy,tone:"warn"},wrong_email:{title:"This invitation is for a different email",icon:Gg,tone:"error"},other:{title:"We couldn't accept this invitation",icon:Gg,tone:"error"}},Ly={neutral:"border-zinc-200 dark:border-zinc-800",success:"border-green-500/40 bg-green-50 dark:bg-green-950/20",warn:"border-amber-500/40 bg-amber-500/10 dark:bg-amber-950/20",error:"border-red-500/40 bg-red-50 dark:bg-red-950/20"};function My(){const{user:e,loading:t}=tn(),{reload:n}=on(),[a]=Pt(),r=ke(),i=(a.get("token")||"").trim(),o=(0,s.useMemo)(()=>"/invitations/accept?token=".concat(encodeURIComponent(i)),[i]),[l,c]=(0,s.useState)("loading"),[d,u]=(0,s.useState)(""),[m,p]=(0,s.useState)(null),h=(0,s.useCallback)(async()=>{c("accepting"),u("");try{const t=await function(e){let{token:t}=e;return(0,zt.n)("/api/employer/v1/invitations/accept",{method:"POST",body:{token:t}})}({token:i});if(p((null===t||void 0===t?void 0:t.account_id)||null),null!==e&&void 0!==e&&e.id){!function(e){if(!e)return;const t=Jt();t&&t.setItem(Yt,String(e))}(e.id);try{await(null===n||void 0===n?void 0:n())}catch(a){}}c("success")}catch(mK){var t;const n=(null===mK||void 0===mK?void 0:mK.message)||(null===mK||void 0===mK||null===(t=mK.data)||void 0===t?void 0:t.detail)||"Acceptance failed",a=function(e){const t=String(e||"").toLowerCase();return t.includes("invitation not found")||t.includes("not found")?"not_found":t.includes("expired")?"expired":t.includes("revoked")?"revoked":t.includes("already accepted")||t.includes("not pending")?"already_accepted":t.includes("email mismatch")||t.includes("email does not match")?"wrong_email":"other"}(n);u(n),c(a)}},[i,e,n]);(0,s.useEffect)(()=>{t||(i?e?h():c("not_authenticated"):c("no_token"))},[t,e,i,h]),(0,s.useEffect)(()=>{if("success"!==l)return;const e=setTimeout(()=>r("/employer/members"),1500);return()=>clearTimeout(e)},[l,r]);const f=By[l]||By.other,x=f.icon,v=Ly[f.tone]||Ly.neutral,g="loading"===l||"accepting"===l;return(0,Xt.jsxs)("div",{className:"min-h-screen flex flex-col items-center justify-center bg-ndor-canvas p-4","data-testid":"inv
2itation-accept-page",children:[(0,Xt.jsx)("div",{className:"mb-6",children:(0,Xt.jsx)(Wf,{})}),(0,Xt.jsxs)(Fy,{className:"w-full max-w-md p-6 ".concat(v),"data-testid":"invitation-accept-state-".concat(l),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Xt.jsx)(x,{className:"h-6 w-6 ".concat(g?"animate-spin":"")}),(0,Xt.jsx)("h1",{className:"text-lg font-semibold","data-testid":"invitation-accept-title",children:f.title})]}),"no_token"===l&&(0,Xt.jsx)("p",{className:"mt-3 text-sm text-slate-300 dark:text-zinc-300",children:"The link you opened doesn't carry an invitation token. Ask the person who invited you to share the original email link."}),"not_authenticated"===l&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"mt-3 text-sm text-slate-300 dark:text-zinc-300",children:"Sign in or create an account using the email address that received this invitation. We'll bring you back to finish joining the organisation."}),(0,Xt.jsxs)("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row",children:[(0,Xt.jsx)(Et,{to:"/login?returnTo=".concat(encodeURIComponent(o)),className:"flex-1","data-testid":"invitation-accept-signin-link",children:(0,Xt.jsx)(Rr,{className:"w-full",children:"Sign in"})}),(0,Xt.jsx)(Et,{to:"/signup?returnTo=".concat(encodeURIComponent(o)),className:"flex-1","data-testid":"invitation-accept-signup-link",children:(0,Xt.jsx)(Rr,{variant:"outline",className:"w-full",children:"Create an account"})})]})]}),"success"===l&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("p",{className:"mt-3 text-sm text-green-800 dark:text-green-200",children:["You're now a member of the organisation.",m&&(0,Xt.jsxs)("span",{className:"ml-1 block font-mono text-xs opacity-60",children:["account ",m.slice(0,8),"\u2026"]})]}),(0,Xt.jsx)("p",{className:"mt-2 text-xs text-slate-300",children:"Taking you to your member workspace\u2026"}),(0,Xt.jsx)("div",{className:"mt-4",children:(0,Xt.jsx)(Et,{to:"/employer/members","data-testid":"invitation-accept-go-now",children:(0,Xt.jsx)(Rr,{className:"w-full",children:"Go to Members now"})})})]}),["not_found","expired","revoked","already_accepted","wrong_email","other"].includes(l)&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("p",{className:"mt-3 text-sm text-slate-200 dark:text-zinc-300",children:["expired"===l&&"Ask the admin who invited you to send a fresh invitation.","revoked"===l&&"The admin has cancelled this invitation. Ask them to send a new one if you still need access.","already_accepted"===l&&"This invitation has been used already. If you can't reach your workspace, ask an admin to verify your membership.","wrong_email"===l&&"The invitation was sent to a different email address. Sign in with the matching address, or ask the admin to issue a new invitation.","not_found"===l&&"Double-check the link, or ask the admin to send a fresh invitation.","other"===l&&"Please try again in a moment. If the issue persists, ask the admin to re-send the invitation."]}),d&&(0,Xt.jsxs)("p",{className:"mt-2 break-words text-xs text-slate-300 dark:text-slate-300","data-testid":"invitation-accept-error-detail",children:["Details: ",d]}),(0,Xt.jsx)("div",{className:"mt-4",children:(0,Xt.jsx)(Et,{to:"/","data-testid":"invitation-accept-home-link",children:(0,Xt.jsx)(Rr,{variant:"outline",className:"w-full",children:"Back to home"})})})]})]})]})}const zy=wn("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),Uy=["scope","children"];function Vy(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const a=t[0];if(1===t.length)return a;const r=()=>{const e=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const n=e.reduce((e,n)=>{let{useScope:a,scopeName:r}=n;const s=a(t)["__scope".concat(r)];return(0,c.A)((0,c.A)({},e),s)},{});return s.useMemo(()=>({["__scope".concat(a.scopeName)]:n}),[n])}};return r.scopeName=a.scopeName,r}const qy=["asChild"];var Wy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=aa("Primitive.".concat(t)),a=s.forwardRef((e,a)=>{const{asChild:r}=e,s=l(e,qy),i=r?n:t;return"undefined"!==typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,Xt.jsx)(i,(0,c.A)((0,c.A)({},s),{},{ref:a}))});return a.displayName="Primitive.".concat(t),(0,c.A)((0,c.A)({},e),{},{[t]:a})},{});const Hy=["__scopeProgress","value","max","getValueLabel"],Gy=["__scopeProgress"];var Ky="Progress",Yy=100,[Jy,$y]=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[];const a=()=>{const t=n.map(e=>s.createContext(e));return function(n){const a=(null===n||void 0===n?void 0:n[e])||t;return s.useMemo(()=>
2({["__scope".concat(e)]:(0,c.A)((0,c.A)({},n),{},{[e]:a})}),[n,a])}};return a.scopeName=e,[function(t,a){const r=s.createContext(a);r.displayName=t+"Context";const i=n.length;n=[...n,a];const o=t=>{var n;const{scope:a,children:o}=t,c=l(t,Uy),d=(null===a||void 0===a||null===(n=a[e])||void 0===n?void 0:n[i])||r,u=s.useMemo(()=>c,Object.values(c));return(0,Xt.jsx)(d.Provider,{value:u,children:o})};return o.displayName=t+"Provider",[o,function(n,o){var l;const c=(null===o||void 0===o||null===(l=o[e])||void 0===l?void 0:l[i])||r,d=s.useContext(c);if(d)return d;if(void 0!==a)return a;throw new Error("`".concat(n,"` must be used within `").concat(t,"`"))}]},Vy(a,...t)]}(Ky),[Xy,Qy]=Jy(Ky),Zy=s.forwardRef((e,t)=>{const{__scopeProgress:n,value:a=null,max:r,getValueLabel:s=nb}=e,i=l(e,Hy);var o,d;!r&&0!==r||sb(r)||console.error((o="".concat(r),d="Progress","Invalid prop `max` of value `".concat(o,"` supplied to `").concat(d,"`. Only numbers greater than 0 are valid max values. Defaulting to `").concat(Yy,"`.")));const u=sb(r)?r:Yy;null===a||ib(a,u)||console.error(function(e,t){return"Invalid prop `value` of value `".concat(e,"` supplied to `").concat(t,"`. The `value` prop must be:\n - a positive number\n - less than the value passed to `max` (or ").concat(Yy," if no `max` prop is set)\n - `null` or `undefined` if the progress is indeterminate.\n\nDefaulting to `null`.")}("".concat(a),"Progress"));const m=ib(a,u)?a:null,p=rb(m)?s(m,u):void 0;return(0,Xt.jsx)(Xy,{scope:n,value:m,max:u,children:(0,Xt.jsx)(Wy.div,(0,c.A)((0,c.A)({"aria-valuemax":u,"aria-valuemin":0,"aria-valuenow":rb(m)?m:void 0,"aria-valuetext":p,role:"progressbar","data-state":ab(m,u),"data-value":null!==m&&void 0!==m?m:void 0,"data-max":u},i),{},{ref:t}))})});Zy.displayName=Ky;var eb="ProgressIndicator",tb=s.forwardRef((e,t)=>{var n;const{__scopeProgress:a}=e,r=l(e,Gy),s=Qy(eb,a);return(0,Xt.jsx)(Wy.div,(0,c.A)((0,c.A)({"data-state":ab(s.value,s.max),"data-value":null!==(n=s.value)&&void 0!==n?n:void 0,"data-max":s.max},r),{},{ref:t}))});function nb(e,t){return"".concat(Math.round(e/t*100),"%")}function ab(e,t){return null==e?"indeterminate":e===t?"complete":"loading"}function rb(e){return"number"===typeof e}function sb(e){return rb(e)&&!isNaN(e)&&e>0}function ib(e,t){return rb(e)&&!isNaN(e)&&e<=t&&e>=0}tb.displayName=eb;var ob=Zy,lb=tb;const cb=["className","value"],db=s.forwardRef((e,t)=>{let{className:n,value:a}=e,r=l(e,cb);return(0,Xt.jsx)(ob,(0,c.A)((0,c.A)({ref:t,className:Sr("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",n)},r),{},{children:(0,Xt.jsx)(lb,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:"translateX(-".concat(100-(a||0),"%)")}})}))});function ub(e){let{step:t,totalSteps:n=2,stepLabel:a,children:r,testid:s="onboarding-shell"}=e;const i=Math.min(Math.max(Number(t)||1,1),n),o=Math.max(Number(n)||2,1),l=i/o*100;return(0,Xt.jsxs)("div",{className:"min-h-screen bg-ndor-canvas flex flex-col","data-testid":s,children:[(0,Xt.jsxs)("header",{className:"border-b border-ndor-edge bg-ndor-surface px-4 py-3 sm:px-6",children:[(0,Xt.jsxs)("div",{className:"max-w-5xl mx-auto flex items-center justify-between",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,Xt.jsx)(Wf,{variant:"symbol",size:28}),(0,Xt.jsx)("span",{className:"text-base font-serif-display font-semibold tracking-tight text-ndor-ink",children:"NDORFlow"})]}),(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-muted font-manrope","data-testid":"onboarding-step-indicator",children:["Step ",i," of ",o,a?" \xb7 ".concat(a):""]})]}),(0,Xt.jsx)("div",{className:"max-w-5xl mx-auto mt-2.5",children:(0,Xt.jsx)(db,{value:l,className:"h-1","data-testid":"onboarding-progress-bar"})})]}),(0,Xt.jsx)("main",{className:"flex-1 px-4 py-6 sm:py-10 sm:px-6 pb-24",children:r})]})}db.displayName=ob.displayName;const mb=wn("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),pb=wn("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}
2],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),hb=wn("upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),fb=["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document",".pdf",".doc",".docx"].join(",");function xb(e){return e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1024/1024).toFixed(1)," MB")}function vb(e){let{data:t,onChange:n}=e;const[a,r]=(0,s.useState)(!1),[i,o]=(0,s.useState)(""),l=(0,s.useRef)(null),c={state:{},event:()=>{},reset:()=>{}},d=async e=>{const t=null===e||void 0===e?void 0:e[0];if(c.event("file_selected",!!t),!t)return;const a=function(e){const t=(e||"").toLowerCase(),n=t.lastIndexOf(".");return n>=0?t.slice(n+1):""}(t.name);if(c.event("file_meta",{name:t.name,size:t.size,ext:a}),!["pdf","doc","docx"].includes(a))return c.event("validation_ok",!1),void o("Please upload a PDF or DOCX file.");if("doc"===a)return c.event("validation_ok",!1),void o("Legacy .doc isn't supported. Please re-export as .docx or .pdf.");if(t.size>10485760)return c.event("validation_ok",!1),void o("File is too large (".concat(xb(t.size),"). Max 10 MB."));c.event("validation_ok",!0),o(""),r(!0),c.event("upload_started",!0);try{const e=new FormData;e.append("file",t,t.name),e.append("original_filename",t.name),e.append("make_primary","true"),c.event("upload_endpoint","/api/base-cvs/upload");const a=await(0,zt.n)("/api/base-cvs/upload",{method:"POST",body:e});c.event("http_status",200),c.event("parsed_text_len",{len:(null===a||void 0===a?void 0:a.text_length)||0}),"empty"===(null===a||void 0===a?void 0:a.parse_status)&&o("We uploaded your CV but couldn't read any text from it \u2014 it may be a scanned image. Try a different export, or skip and add it later."),n({cv_id:a.cv_id,original_filename:a.original_filename||t.name,size_bytes:t.size,text_length:a.text_length||0,parse_status:a.parse_status,is_primary:!!a.is_primary})}catch(pK){const t=(null===pK||void 0===pK?void 0:pK.status)||0,n=(null===pK||void 0===pK?void 0:pK.data)&&(pK.data.detail||JSON.stringify(pK.data))||(null===pK||void 0===pK?void 0:pK.message)||"Upload failed.";c.event("http_status",t),c.event("parsed_text_len",{error:n}),o("string"===typeof n?n:"Upload failed. Please try again.")}finally{r(!1),l.current&&(l.current.value="")}},[u,m]=(0,s.useState)(!1),p=!(null===t||void 0===t||!t.cv_id);return(0,Xt.jsxs)("div",{className:"space-y-4 min-w-0 max-w-full overflow-x-hidden","data-testid":"onboarding-cv-step",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-ndor-gold/40 bg-ndor-gold/5 px-3 py-2.5","data-testid":"cv-onboarding-permanence-note",children:[(0,Xt.jsx)(mb,{className:"h-4 w-4 text-ndor-gold mt-0.5 shrink-0"}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsx)("strong",{children:"Choose carefully \u2014 this becomes your Source CV."})," NDORFlow reads it to understand your experience, but your uploaded Source CV is private reference material and is not previewed or exported. You can upload a new Source CV later from Documents if your experience changes."]})]}),i&&(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-lg bg-ndor-error-light border border-ndor-error-border p-3","data-testid":"cv-upload-error",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 text-ndor-error mt-0.5 shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed",children:i})]}),p?(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-edge bg-ndor-surface-alt/40 p-4 flex items-center gap-3","data-testid":"cv-uploaded-card",children:[(0,Xt.jsx)("div",{className:"w-11 h-11 rounded-lg bg-ndor-success-light flex items-center justify-center shrink-0",children:(0,Xt.jsx)(Og,{className:"h-5 w-5 text-ndor-success"})}),(0,Xt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate","data-testid":"cv-uploaded-filename",children:t.original_filename}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted",children:["success"===t.parse_status&&t.text_length?"Read ".concat(t.text_length.toLocaleStr
2ing()," characters"):"empty"===t.parse_status?"Couldn't read text \u2014 you can re-upload from your dashboard":"Saved","number"===typeof t.size_bytes&&" \xb7 ".concat(xb(t.size_bytes))]})]}),(0,Xt.jsx)(Rr,{type:"button",variant:"ghost",size:"icon",onClick:()=>{n(null),o(""),c.reset(),l.current&&(l.current.value="")},"data-testid":"cv-remove-button",className:"text-ndor-ink-muted hover:text-ndor-error shrink-0","aria-label":"Remove uploaded CV",children:(0,Xt.jsx)(pb,{className:"h-4 w-4"})})]}):(0,Xt.jsxs)("div",{onDragOver:e=>{e.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:e=>{var t;e.preventDefault(),m(!1),a||d(null===(t=e.dataTransfer)||void 0===t?void 0:t.files)},className:"relative flex flex-col items-center justify-center rounded-xl border-2 border-dashed transition-all text-center "+(u?"border-ndor-gold bg-ndor-gold/5":"border-ndor-edge hover:border-ndor-ink-muted bg-ndor-surface/30")+" py-10 px-5 sm:py-14","data-testid":"cv-upload-zone",children:[(0,Xt.jsx)("input",{ref:l,type:"file",accept:fb,onClick:()=>c.event("picker_tapped",!0),onChange:e=>d(e.target.files),disabled:a,"data-testid":"cv-file-input","aria-label":"Choose your CV file",className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer disabled:cursor-not-allowed z-10"}),(0,Xt.jsxs)("div",{className:"pointer-events-none flex flex-col items-center",children:[a?(0,Xt.jsx)(Lg,{className:"h-8 w-8 animate-spin text-ndor-ink-muted mb-3"}):(0,Xt.jsx)("div",{className:"w-12 h-12 rounded-full bg-ndor-surface-alt flex items-center justify-center mb-3",children:(0,Xt.jsx)(hb,{className:"h-5 w-5 text-ndor-ink-muted"})}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:a?"Reading your CV\u2026":"Upload your Source CV"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary mt-1 max-w-xs",children:"NDORFlow uses this as your baseline and improves it through generated CVs."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-2 hidden sm:block",children:"or drag & drop here"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-2",children:"PDF \xb7 DOCX \xb7 max 10 MB"})]})]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted flex items-start gap-1.5 leading-relaxed",children:[(0,Xt.jsx)(Nn,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),(0,Xt.jsx)("span",{children:"We read your CV to pull skills, years of experience, location and seniority \u2014 so you don't have to type it twice. This becomes your Source CV \u2014 every tailored CV variant and cover letter NDORFlow generates is built from it."})]})]})}const gb=[{key:"cv",subtitle:"Upload your CV \u2014 we'll read the rest."}],yb=["privacy_policy","cv_processing","job_search"];function bb(){var e,t,n;const{user:a,hasProfile:r,refreshProfile:i}=tn(),o=ke(),l=null!==a&&void 0!==a&&a.id?"ndor-onboarding-".concat(a.id):null,c=(0,s.useMemo)(()=>{if(!l)return null;try{const e=sessionStorage.getItem(l);if(!e)return null;const t=JSON.parse(e);return 3!==(null===t||void 0===t?void 0:t.v)?null:t}catch(e){return null}},[l]),[d,u]=(0,s.useState)(()=>{var e;return null!==(e=null===c||void 0===c?void 0:c.currentStep)&&void 0!==e?e:0}),[m,p]=(0,s.useState)(()=>{var e;return null!==(e=null===c||void 0===c?void 0:c.cvData)&&void 0!==e?e:null}),[h,f]=(0,s.useState)(!1),[x,v]=(0,s.useState)(!1),[g,y]=(0,s.useState)("");(0,s.useEffect)(()=>{if(l&&!x)try{sessionStorage.setItem(l,JSON.stringify({v:3,currentStep:d,cvData:m,savedAt:Date.now()}))}catch(e){}},[l,d,m,x]),(0,s.useEffect)(()=>{if(x&&l)try{sessionStorage.removeItem(l)}catch(e){}},[x,l]),(0,s.useEffect)(()=>{if(null===a||void 0===a||!a.id||r)return;let e=!1;return(async()=>{try{const t=await(0,zt.n)("/api/auth/me/access");if(e)return;
2!0===(null===t||void 0===t?void 0:t.employer_access)&&!0!==(null===t||void 0===t?void 0:t.candidate_access)&&o("/employer",{replace:!0})}catch(t){}})(),()=>{e=!0}},[null===a||void 0===a?void 0:a.id,r,o]),(0,s.useEffect)(()=>{if(null===a||void 0===a||!a.id)return;if(null!==m&&void 0!==m&&m.cv_id)return;if(h||x)return;let e=!1;return(async()=>{try{const t=await(0,zt.n)("/api/profile/me");if(e)return;const n=null===t||void 0===t?void 0:t.primary_cv;null!==n&&void 0!==n&&n.id&&p({cv_id:n.id,original_filename:n.original_filename||"Source CV",text_length:0,parse_status:"success",is_primary:!0})}catch(t){}})(),()=>{e=!0}},[null===a||void 0===a?void 0:a.id,null===m||void 0===m?void 0:m.cv_id,h,x]),(0,s.useEffect)(()=>{x?o("/onboarding/plan",{replace:!0,state:{from:"/onboarding"}}):!r||m||h||o("/dashboard",{replace:!0})},[x,r,o,m,h]);const b=((null===a||void 0===a||null===(e=a.user_metadata)||void 0===e?void 0:e.first_name)||(null===a||void 0===a||null===(t=a.user_metadata)||void 0===t||null===(n=t.full_name)||void 0===n?void 0:n.split(" ")[0])||"").trim()||"there";async function w(){const e=await async function(){var e;const{data:{session:t}}=await Mt.supabase.auth.getSession();return(null===t||void 0===t||null===(e=t.user)||void 0===e?void 0:e.id)||null}();if(!e)return{ok:!1,msg:"Session expired."};const t=(new Date).toISOString(),n=yb.map(n=>({user_id:e,consent_type:n,accepted:!0,policy_version:"1.0",accepted_at:t})),{error:a}=await Mt.supabase.from("consents").insert(n);return a?{ok:!1,msg:"Couldn't record consent: ".concat(a.message)}:{ok:!0}}const j="Finish setup";return(0,Xt.jsx)(ub,{step:1,totalSteps:2,stepLabel:"Upload your Source CV",testid:"onboarding-page",children:(0,Xt.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,Xt.jsxs)("h1",{className:"text-3xl sm:text-4xl font-serif-display font-semibold tracking-tight text-ndor-ink","data-testid":"onboarding-hello",children:["Hello, ",(0,Xt.jsx)("span",{className:"text-ndor-gold",children:b})]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-2 mb-6 font-manrope",children:gb[0].subtitle}),g&&(0,Xt.jsxs)("div",{className:"mb-5 rounded-lg bg-ndor-error-light border border-ndor-error-border p-3.5 flex items-start gap-2.5","data-testid":"onboarding-save-error",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 text-ndor-error shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-error",children:"Save failed"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-0.5",children:g})]})]}),(0,Xt.jsxs)("div",{className:"rounded-2xl border border-ndor-gold/40 bg-ndor-surface shadow-sm p-5 sm:p-6","data-testid":"onboarding-cv-card",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2.5 mb-4",children:[(0,Xt.jsx)("div",{className:"h-9 w-9 rounded-lg bg-ndor-gold/10 flex items-center justify-center",children:(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-ndor-gold"})}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h2",{className:"text-base font-semibold text-ndor-ink font-outfit",children:"Upload your Source CV"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted font-manrope",children:"One CV becomes your truth. Encrypted at rest, deletable on demand."})]})]}),(0,Xt.jsx)(vb,{data:m,onChange:p})]}),(0,Xt.jsxs)("p",{className:"mt-5 text-xs text-ndor-ink-muted leading-relaxed flex items-start gap-1.5 font-manrope","data-testid":"onboarding-terms-line",children:[(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-ndor-gold"}),(0,Xt.jsxs)("span",{children:["By tapping ",(0,Xt.jsx)("strong",{children:j}),", you agree to NDORFlow's"," ",(0,Xt.jsx)("a",{href:"/terms",target:"_blank",rel:"noreferrer",className:"text-ndor-ink hover:underline","data-testid":"onboarding-terms-tos",children:"Terms of Service"}),","," ",(0,Xt.jsx)("a",{href:"/privacy",target:"_blank",rel:"noreferrer",className:"text-ndor-ink hover:underline","data-testid":"onboarding-terms-privacy",children:"Privacy Policy"}),", and"," ",(0,Xt.jsx)("a",{href:"/refund",target:"_blank",rel:"noreferrer",className:"text-ndor-ink hover:underline","data-testid":"onboarding-terms-refund",children:"Refund Policy"})," ","and consent to NDORFlow processing your CV and searching jobs on your behalf."]})]}),(0,Xt.jsx)("div",{className:"mt-8 flex items-center justify-end gap-3","data-testid":"onboarding-footer",children:(0,Xt.jsxs)(Rr,{onClick:async function(){if(y(""),null!==a&&void 0!==a&&a.id){f(!0);try{if(null===m||void 0===m||!m.cv_id){const e="Please upload your CV to continue. This becomes your Source CV \u2014 every tailored CV variant and cover letter is generated from it.";return y(e),void fy.error(e)}const e=await async function(){return null!==m&&void 0!==m&&m.cv_id?{ok:!0,cv_id:m.cv_id}:{ok:!0,cv_id:null}}();if(!e.ok)return y(e.msg),void fy.error(e.msg);const t=await w();if(!t.ok)return y(t.msg),void fy.error(t.msg);await i(),v(!0)}catch(pK){const t="Unexpected error: ".concat((null===pK||void 0===pK?void 0:pK.message)||"Unknown",".");console.error("[Onboarding] uncaught:",pK),y(t),fy.error(t)}finally{f(!1)}}else y("You are not signed in. Please refresh.")},disabled:h,className:"min-w-[140px]","data-testid":"onboarding-next-button",children:[h&&(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}),!h&&j,!h&&(0,Xt.jsx)(zy,{className:"h-4 w-4 ml-1.5"})]})})]})})}const wb=["__scopeCheckbox","onKeyDown","onClick"],jb=["__scopeCheckbox","name","checked","defaultChecked","required","disabled","value","onCheckedChange","form"],kb=["__scopeCheckbox","forceMount"],Nb=["__scopeCheckbox"];var _b="Checkbox",[Db,Cb]=js(_b),[Ab,Sb]=Db(_b);function Eb(e){const{__scopeCheckbox:t,checked:n,children:a,defaultChecked:r,disabled:i,form:o,name:l,onCheckedChange:d,required:u,value:m="on",internal_do_not_use_render:p}=e,[h,f]=_s({prop:n,defaultProp:null!==r&&void 0!==r&&r,onChange:d,caller:_b}),[x,v]=s.useState(null),[g,y]=s.useState(null),b=s.useRef(!1),w=!x||(!!o||!!x.closest("form")),j={checked:h,disabled:i,setChecked:f,control:x,setControl:v,name:l,form:o,value:m,hasConsumerStoppedPropagationRef:b,required:u,defaultChecked:!Mb(r)&&r,isFormControl:w,bubbleInput:g,setBubbleInput:y};return(0,Xt.jsx)(Ab,(0,c.A)((0,c.A)({scope:t},j),{},{children:Lb(p)?p(j):a}))}var Fb="CheckboxTrigger",Rb=s.forwardRef((e,t)=>
2{let{__scopeCheckbox:n,onKeyDown:a,onClick:r}=e,i=l(e,wb);const{control:o,value:d,disabled:u,checked:m,required:p,setControl:h,setChecked:f,hasConsumerStoppedPropagationRef:x,isFormControl:v,bubbleInput:g}=Sb(Fb,n),y=Xn(t,h),b=s.useRef(m);return s.useEffect(()=>{const e=null===o||void 0===o?void 0:o.form;if(e){const t=()=>f(b.current);return e.addEventListener("reset",t),()=>e.removeEventListener("reset",t)}},[o,f]),(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button",role:"checkbox","aria-checked":Mb(m)?"mixed":m,"aria-required":p,"data-state":zb(m),"data-disabled":u?"":void 0,disabled:u,value:d},i),{},{ref:y,onKeyDown:ys(a,e=>{"Enter"===e.key&&e.preventDefault()}),onClick:ys(r,e=>{f(e=>!!Mb(e)||!e),g&&v&&(x.current=e.isPropagationStopped(),x.current||e.stopPropagation())})}))});Rb.displayName=Fb;var Ib=s.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:a,checked:r,defaultChecked:s,required:i,disabled:o,value:d,onCheckedChange:u,form:m}=e,p=l(e,jb);return(0,Xt.jsx)(Eb,{__scopeCheckbox:n,checked:r,defaultChecked:s,disabled:o,required:i,onCheckedChange:u,name:a,form:m,value:d,internal_do_not_use_render:e=>{let{isFormControl:a}=e;return(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Rb,(0,c.A)((0,c.A)({},p),{},{ref:t,__scopeCheckbox:n})),a&&(0,Xt.jsx)(Bb,{__scopeCheckbox:n})]})}})});Ib.displayName=_b;var Tb="CheckboxIndicator",Pb=s.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:a}=e,r=l(e,kb),s=Sb(Tb,n);return(0,Xt.jsx)($l,{present:a||Mb(s.checked)||!0===s.checked,children:(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({"data-state":zb(s.checked),"data-disabled":s.disabled?"":void 0},r),{},{ref:t,style:(0,c.A)({pointerEvents:"none"},e.style)}))})});Pb.displayName=Tb;var Ob="CheckboxBubbleInput",Bb=s.forwardRef((e,t)=>{let{__scopeCheckbox:n}=e,a=l(e,Nb);const{control:r,hasConsumerStoppedPropagationRef:i,checked:o,defaultChecked:d,required:u,disabled:m,name:p,value:h,form:f,bubbleInput:x,setBubbleInput:v}=Sb(Ob,n),g=Xn(t,v),y=Qf(o),b=jl(r);s.useEffect(()=>{const e=x;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set,a=!i.current;if(y!==o&&n){const t=new Event("click",{bubbles:a});e.indeterminate=Mb(o),n.call(e,!Mb(o)&&o),e.dispatchEvent(t)}},[x,y,o,i]);const w=s.useRef(!Mb(o)&&o);return(0,Xt.jsx)(Is.input,(0,c.A)((0,c.A)({type:"checkbox","aria-hidden":!0,defaultChecked:null!==d&&void 0!==d?d:w.current,required:u,disabled:m,name:p,value:h,form:f},a),{},{tabIndex:-1,ref:g,style:(0,c.A)((0,c.A)((0,c.A)({},a.style),b),{},{position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"})}))});
2function Lb(e){return"function"===typeof e}function Mb(e){return"indeterminate"===e}function zb(e){return Mb(e)?"indeterminate":e?"checked":"unchecked"}Bb.displayName=Ob;const Ub=["className"],Vb=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,Ub);return(0,Xt.jsx)(Ib,(0,c.A)((0,c.A)({ref:t,className:Sr("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",n)},a),{},{children:(0,Xt.jsx)(Pb,{className:Sr("flex items-center justify-center text-current"),children:(0,Xt.jsx)(Zm,{className:"h-4 w-4"})})}))});Vb.displayName=Ib.displayName;const qb=wn("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),Wb=[{key:"privacy_policy",label:"Privacy Policy",description:"I have read and agree to the NDORFlow Privacy Policy."},{key:"employer_terms",label:"Employer Terms",description:"I agree to the NDORFlow Employer Terms \u2014 including the PII-bou
2ndary rules, evidence-only screening, and candidate-controlled signal delivery."}];function Hb(){const{user:e,hasProfile:t,refreshProfile:n}=tn(),a=ke(),[r,i]=(0,s.useState)({}),[o,l]=(0,s.useState)(!1),[d,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)("");(0,s.useEffect)(()=>{t&&a("/employer",{replace:!0})},[t,a]),(0,s.useEffect)(()=>{if(!d)return;const e=setTimeout(()=>a("/employer",{replace:!0}),1400);return()=>clearTimeout(e)},[d,a]);const h=Wb.every(e=>!!r[e.key])&&!o&&!(null===e||void 0===e||!e.id);return d?(0,Xt.jsx)("div",{className:"min-h-screen bg-ndor-canvas flex items-center justify-center px-4","data-testid":"employer-onboarding-complete",children:(0,Xt.jsxs)("div",{className:"text-center max-w-sm",children:[(0,Xt.jsx)("div",{className:"mx-auto w-14 h-14 rounded-full bg-ndor-success-light flex items-center justify-center mb-5",children:(0,Xt.jsx)(Zm,{className:"h-7 w-7 text-ndor-success"})}),(0,Xt.jsx)("h1",{className:"text-2xl font-semibold text-ndor-ink font-outfit",children:"Consents recorded"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-2 font-manrope",children:"Taking you to your employer workspace\u2026"})]})}):(0,Xt.jsxs)("div",{className:"min-h-screen bg-ndor-canvas flex flex-col","data-testid":"employer-onboarding-page",children:[(0,Xt.jsx)("header",{className:"border-b border-ndor-edge bg-ndor-surface px-4 py-4 sm:px-6",children:(0,Xt.jsxs)("div",{className:"max-w-2xl mx-auto flex items-center gap-3",children:[(0,Xt.jsx)(Wf,{variant:"symbol",size:32}),(0,Xt.jsx)("span",{className:"text-lg font-serif-display font-semibold tracking-tight text-ndor-ink",children:"NDORFlow"}),(0,Xt.jsx)("span",{className:"ml-auto text-xs text-ndor-ink-muted font-manrope uppercase tracking-wider",children:"Employer access"})]})}),(0,Xt.jsx)("main",{className:"flex-1 px-4 py-10 sm:px-6",children:(0,Xt.jsxs)("div",{className:"max-w-2xl mx-auto space-y-6",children:[m&&(0,Xt.jsxs)("div",{className:"rounded-lg bg-ndor-error-light border border-ndor-error-border p-4 flex items-start gap-3","data-testid":"employer-onboarding-error",children:[(0,Xt.jsx)(ty,{className:"h-5 w-5 text-ndor-error shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-error",children:"Consent save failed"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-1",children:m})]})]}),(0,Xt.jsxs)("section",{"data-testid":"employer-onboarding-step-consents-body",className:"space-y-6",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold tracking-tight text-ndor-ink font-outfit flex items-center gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-5 w-5 text-ndor-ink-muted"}),"Review & consents"]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-1 font-manrope",children:"Confirm the platform consents below to continue to your employer workspace."})]}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface px-4 py-3","data-testid":"employer-onboarding-doctrine-note",children:(0,Xt.jsxs)("div",{className:"flex items-start gap-2 text-xs text-ndor-ink-muted leading-relaxed",children:[(0,Xt.jsx)(qb,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-ndor-gold"}),(0,Xt.jsx)("span",{children:"NDORFlow organisations are admin-provisioned. Creating an account does not create an organisation; workspaces are attached to your account through a valid invitation link or directly by a platform administrator. If you reached this page without an invitation, complete your consents and you will land on a holding page until your access is provisioned."})]})}),(0,Xt.jsxs)("div",{className:"space-y-4",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"Consents"}),Wb.map(e=>(0,Xt.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border border-ndor-edge p-4 cursor-pointer hover:bg-ndor-surface-alt/50 transition-colors",children:[(0,Xt.jsx)(Vb,{checked:!!r[e.key],onCheckedChange:()=>i(t=>(0,c.A)((0,c.A)({},t),{},{[e.key]:!t[e.key]})),className:"mt-0.5","data-testid":"employer-consent-".concat(e.key)}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink",children:[e.label,(0,Xt.jsx)("span",{className:"text-ndor-error ml-1",children:"*"})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-0.5 leading-relaxed",children:e.description})]})]},e.key)),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"* Required. Version 1.0 \u2014 timestamped at submission."})]})]})]})}),(0,Xt.jsx)("footer",{className:"border-t border-ndor-edge bg-ndor-surface px-4 py-4 sm:px-6",children:(0,Xt.jsx)("div",{className:"max-w-2xl mx-auto flex items-center justify-end",children:(0,Xt.jsxs)(Rr,{onClick:async function(){if(p(""),h){l(!0);try{const t=await async function(e){const t=Wb.filter(e=>!!r[e.key]).map(t=>({user_id:e,consent_type:t.key,accepted:!0,policy_version:"1.0",accepted_at:(new Date).toISOString()}));if(0===t.length)return{ok:!1,msg:"No consents accepted."};const{data:n,error:a}=await Mt.supabase.from("consents").insert(t).select();return a?{ok:!1,msg:"Consent save failed: ".concat(a.message)}:n&&0!==n.length?{ok:!0}:{ok:!1,msg:"Consent save blocked by RLS on public.consents."}}(e.id);if(!t.ok)return p(t.msg),void fy.error(t.msg);await n(),u(!0)}catch(pK){const t=(null===pK||void 0===pK?void 0:pK.message)||"Unexpected error.";p(t),fy.error(t)}finally{l(!1)}}},disabled:!h,"data-testid":"employer-onboarding-finish",children:[o&&(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}),o?"Saving\u2026":"Continue to workspace"]})})})]})}let Gb=null,Kb=null;function Yb(){var e;
2const[t,n]=(0,s.useState)(null!==(e=Gb)&&void 0!==e?e:2);return(0,s.useEffect)(()=>{let e=!0;return async function(){return null!=Gb?Gb:Kb||(Kb=(async()=>{try{const e=await(0,zt.n)("/api/jobs/analyze-fit/usage"),t=Number(null===e||void 0===e?void 0:e.limit);Gb=Number.isFinite(t)&&t>0?Math.floor(t):2}catch(e){Gb=2}finally{Kb=null}return Gb})(),Kb)}().then(t=>{e&&n(t)}),()=>{e=!1}},[]),{limit:t}}const Jb=new Map,$b=new Map,Xb=new Map;function Qb(){return Date.now()}function Zb(e,t){return e&&Qb()-e.ts<t}function ew(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6e4;const n=Jb.get(e);return n?{hit:!0,fresh:Zb(n,t),data:n.data}:{hit:!1}}async function tw(e,t){var n;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=null!==(n=a.ttlMs)&&void 0!==n?n:6e4,s=!1!==a.staleAccept,i=Jb.get(e);if(Zb(i,r))return i.data;const o=$b.get(e);if(o)return s&&i?i.data:o;const l=(async()=>{try{const n=await t();return Jb.set(e,{data:n,ts:Qb(),ttlMs:r}),function(e,t){const n=Xb.get(e);if(n)for(const r of n)try{r(t)}catch(a){}}(e,n),n}finally{$b.delete(e)}})();return $b.set(e,l),s&&i?(l.catch(()=>{}),i.data):l}function nw(e){const t=Array.isArray(e)?e:[e];for(const n of t){if(!n)continue;if(Jb.has(n)){Jb.delete(n),$b.delete(n);continue}const e="".concat(n,":");for(const t of Array.from(Jb.keys()))(t.startsWith(e)||t===n)&&(Jb.delete(t),$b.delete(t))}}const aw=e=>"applications:list:".concat(e||""),rw=()=>"application-packs:all",sw=()=>"cv-variants:all",iw=()=>"cover-letters:all",ow=e=>"jobs:by-id:".concat(e),lw=e=>"jobs:list:".concat(e||""),cw=()=>"dashboard:bundle",dw=()=>"account:plan",uw=()=>"usage:analyze-fit",mw=()=>"interview-prep:all",pw=e=>"source-cv:active:".concat(e||""),hw=e=>"uploaded-cvs:".concat(e||""),fw=e=>"baseline-fit:".concat(e||""),xw={preferred_regions:[],open_to_relocation:"conditional",relocation_regions:[],location_strictness:"balanced",include_cover_letter:!0,discoverable_to_employers:!1,preferred_titles:[],industries:[],excluded_keywords:[],employment_types:[],seniority_targets:[],remote_preferences:"any",salary_floor:null,salary_ceiling:null,salary_currency:"GBP",salary_period:"annual"},vw=["preferred_regions","relocation_regions","preferred_titles","industries","excluded_keywords","employment_types","seniority_targets"],gw=[{value:"full_time",label:"Full time"},{value:"part_time",label:"Part time"},{value:"contract",label:"Contract"},{value:"temp",label:"Temp / Temporary"},{value:"internship",label:"Internship"}],yw=[{value:"intern",label:"Intern"},{value:"junior",label:"Junior"},{value:"mid",label:"Mid"},{value:"senior",label:"Senior"},{value:"lead",label:"Lead"},{value:"director",label:"Director"},{value:"vp",label:"VP"},{value:"c_suite",label:"C-Suite"}],bw=[{value:"any",label:"Any \u2014 no preference"},{value:"remote_only",label:"Remote only"},{value:"hybrid",label:"Hybrid"},{value:"onsite_only",label:"On-site only"}],ww=["GBP","USD","EUR","AED","QAR","SAR","SGD","AUD","CAD","INR"],jw=[{value:"annual",label:"Annual"},{value:"monthly",label:"Monthly"}];function kw(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function Nw(e){if(!e||"object"!==typeof e)return 0;let t=0;for(const n of Object.keys(xw)){const a=e[n],r=xw[n];if(vw.includes(n))Array.isArray(a)&&a.length>0&&(t+=1);else if("salary_floor"!==n&&"salary_ceiling"!==n)"salary_currency"!==n&&"salary_period"!==n&&null!=a&&a!==r&&(t+=1);else if("salary_floor"===n){const n="number"===typeof a,r="number"===typeof e.salary_ceiling;(n||r)&&(t+=1)}}return t}function _w(e){if(null===e||void 0===e)return null;if("number"===typeof e&&Number.isFinite(e)&&e>=0)return Math.round(e);if("string"===typeof e){const t=e.trim().replace(/[, ]/g,"");if(!t)return null;const n=Number(t);if(Number.isFinite(n)&&n>=0)return Math.round(n)}return null}const Dw="ndor:dashboard-preferences-nudge:dismissed";function Cw(){const[e,t]=(0,s.useState)(null),[n,a]=(0,s.useState)(!0),[r,i]=(0,s.useState)(()=>function(){try{return"1"===window.localStorage.getItem(Dw)}catch(e){return!1}}()),o=(0,s.useCallback)(async()=>{a(!0);try{const e=await(0,zt.n)("/api/profile/preferences");t((null===e||void 0===e?void 0:e.preferences)||{})}catch(e){t(null)}finally{a(!1)}},[]);(0,s.useEffect)(()=>{o()},[o]),(0,s.useEffect)(()=>{const e=()=>o();return window.addEventListener("ndor:preferences-changed",e),()=>window.removeEventListener("ndor:preferences-changed",e)},[o]);const l=(0,s.useMemo)(()=>Nw(e),[e]);if(n)return null;if(r)return null;if(l>0)return null;const c=()=>{!function(){try{window.localStorage.setItem(Dw,"1")}catch(e){}}(),i(!0)};return(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface relative","data-testid":"dashboard-preferences-nudge",children:(0,Xt.jsxs)(Py,{className:"p-5 sm:p-6 flex flex-col sm:flex-row sm:items-center gap-4",children:[(0,Xt.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-full bg-ndor-gold/10 flex items-center justify-center",children:(0,Xt.jsx)(Kn,{className:"h-5 w-5 text-ndor-gold"})}),(0,Xt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Xt.jsx)("h3",{className:"text-sm font-semibold text-ndor-ink",children:"Make NDOR Analyse Fit personal."}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted mt-1 leading-relaxed",children:["Set salary, industry, seniority, and exclusions in"," ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:"Account \u2192 Preferences"})," ","so every fit score reflects what you actually want."]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:c,"data-testid":"dashboard-preferences-nudge-dismiss",children:"Maybe later"}),(0,Xt.jsx)(Et,{to:"/account?tab=preferences",children:(0,Xt.jsx)(Rr,{size:"sm","data-testid":"dashboard-preferences-nudge-cta",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:"Set preferences"})})]}),(0,Xt.jsx)("button",{type:"button","aria-label":"Dismiss",onClick:c,className:"absolute top-2 right-2 text-ndor-ink-muted hover:text-ndor-ink p-1","data-testid":"dashboard-preferences-nudge-close",children:(0,Xt.jsx)(xh,{className:"h-3.5 w-3.5"})})]})})}const Aw=wn("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]),Sw=wn("compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",ke
2y:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function Ew(e){let{to:t,label:n,blurb:a,testId:r}=e;return(0,Xt.jsxs)(Et,{to:t,"data-testid":r,className:" group flex items-start justify-between gap-3 rounded-md border border-ndor-edge bg-ndor-surface-alt px-3 py-2.5 hover:border-ndor-gold/40 hover:bg-ndor-surface transition-colors ",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2.5 min-w-0",children:[(0,Xt.jsx)(Fn,{className:"h-4 w-4 mt-0.5 shrink-0 text-ndor-gold"}),(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink leading-tight",children:n}),a?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-0.5 leading-snug",children:a}):null]})]}),(0,Xt.jsx)(Aw,{className:"h-3.5 w-3.5 mt-0.5 text-ndor-ink-muted group-hover:text-ndor-gold transition-colors shrink-0"})]})}function Fw(e){let{workspace:t,memberRole:n=null}=e;const a="candidate"===t,r="employer"===t,s=r&&("owner"===n||"admin"===n),i=a?"/how-it-works":"/employer/help/workflow";return(0,Xt.jsxs)("section",{className:"rounded-lg border border-ndor-edge bg-ndor-surface p-4 sm:p-5","data-testid":"help-orientation-".concat(t),"aria-label":"Help and orientation",children:[(0,Xt.jsxs)("header",{className:"flex items-center gap-2 mb-3",children:[(0,Xt.jsx)(Sw,{className:"h-4 w-4 text-ndor-gold"}),(0,Xt.jsx)("h2",{className:"text-sm font-semibold text-ndor-ink tracking-wide uppercase",children:"Help & orientation"})]}),(0,Xt.jsxs)("div",{className:"grid gap-2 sm:grid-cols-2",children:[(0,Xt.jsx)(Ew,{to:i,label:"How it works",blurb:"A short walkthrough of the platform's workflow doctrine.",testId:"help-orientation-".concat(t,"-how-it-works")}),a?(0,Xt.jsx)(Ew,{to:"/help/candidate",label:"Candidate User Guide",blurb:"Profile, CV, Analyse Fit, application packs, signals, privacy.",testId:"help-orientation-candidate-guide"}):null,r?(0,Xt.jsx)(Ew,{to:"/help/reviewer",label:"Reviewer User Guide",blurb:"Reviewer dossier, append-only notes, advance / hold / reject.",testId:"help-orientation-reviewer-guide"}):null,s?(0,Xt.jsx)(Ew,{to:"/help/employer",label:"Employer User Guide",blurb:"Workspace setup, roles, lifecycle, entitlements, governance.",testId:"help-orientation-employer-guide"}):null]})]})}const Rw=wn("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),Iw="ndor:first-run-mental-model:dismissed";function Tw(e){return e?"".concat(Iw,":").concat(e):"".concat(Iw,":anon")}function Pw(e){let{open:t,onOpenChange:n,userId:a,hideDismissCheckbox:r=!1}=e;const[i,o]=(0,s.useState)(!0);(0,s.useEffect)(()=>{t&&o(!0)},[t]);const l=(0,s.useCallback)(()=>{!r&&i&&function(e){try{window.localStorage.setItem(Tw(e),"1")}catch(t){}}(a),null===n||void 0===n||n(!1)},[i,r,n,a]);return(0,Xt.jsx)(rg,{open:t,onOpenChange:e=>{e?null===n||void 0===n||n(e):l()},children:(0,Xt.jsxs)(lg,{className:"max-w-xl max-h-[90vh] overflow-y-auto","data-testid":"first-run-mental-model-dialog",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{className:"text-xl sm:text-2xl font-serif-display tracking-tight",children:"Welcome to NDORFlow"}),(0,Xt.jsx)(mg,{className:"text-sm text-ndor-ink-secondary leading-relaxed",children:"NDORFlow is a web-based, mobile-adapted decision intelligence workspace for managing job targeting, CV tailoring, and application preparation."})]}),(0,Xt.jsxs)("div",{className:"space-y-5 py-2",children:[(0,Xt.jsxs)("section",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt/40 p-4","data-testid":"first-run-analyse-fit-block",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold"}),(0,Xt.jsx)("h3",{className:"text-sm font-semibold text-ndor-ink",children:"What Analyse Fit means"})]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed",children:"Analyse Fit compares your Source CV against a specific job description. It checks how well your current CV and profile evidence match the role before you decide whether to tailor your CV or create an application pack."}),(0,Xt.jsx)("p",{className:"mt-2 text-xs text-ndor-ink-muted leading-relaxed",children:"Your CV may look relevant by keywords, but Analyse Fit checks whether the evidence in your CV is strong enough for that particular role."}),(0,Xt.jsx)("p",{className:"mt-2 text-xs text-ndor-ink-muted leading-relaxed",children:"Analyse Fit reports are scrollable \u2014 continue downward to review detailed strengths, gaps, and recommendations."})]}),(0,Xt.jsxs)("section",{"data-testid":"first-run-basic-flow-block",children:[(0,Xt.jsx)("h3",{className:"text-sm font-semibold text-ndor-ink mb-2",children:"The basic flow"}),(0,Xt.jsxs)("ol",{className:"space-y-1.5 text-sm text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink shrink-0",children:"1."}),(0,Xt.jsx)("span",{children:"Upload your Source CV."})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink shrink-0",children:"2."}),(0,Xt.jsx)("span",{children:"Add or choose a job."})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink shrink-0",children:"3."}),(0,Xt.jsx)("span",{children:"Run Analyse Fit."})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink shrink-0",children:"4."}),(0,Xt.jsx)("span",{children:"Decide whether to tailor your CV or generate a cover letter."})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink shrink-0",children:"5."}),(0,Xt.jsx)("span",{children:"Create an application pack."})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink shrink-0",children:"6."}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Submit yourself"})," ","\u2014 NDORFlow never auto-applies."]})]})]})]}),(0,Xt.jsxs)("section",{className:"rounded-lg border border-ndor-gold/30 bg-ndor-gold/5 p-4","data-testid":"first-run-application-pack-block",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,Xt.jsx)(Rw,{className:"h-4 w-4 text-ndor-gold"}),(0,Xt.jsx)("h3",{className:"text-sm font-semibold text-ndor-ink",children:"What an Application Pack contains"})]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed",children:"A role-specific bundle containing the documents and intelligence you generated for that job, such as a tailored CV, cover letter, and interview-preparation insights."})]}),(0,Xt.jsxs)("section",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt/30 p-4","data-testid":"first-run-focus-flow-block",children:[(0,Xt.jsx)("h3",{className:"text-sm font-semibold text-ndor-ink mb-2",children:"If you\u2019re on Focus or Flow"}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink leading-relaxed",children:["Focus and Flow users also get access to ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Workflow"})," \u2014 a dedicated space for reviewing job matches and managing assisted application activity."]}),(0,Xt.jsxs)("p",{className:"mt-2 text-sm text-ndor-ink leading-relaxed",children:["On ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Flow"}),", NDORFlow goes further: it can run background Analyse Fit checks across the jobs pool and surface your strongest matches at the top as ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Top Opp
2ortunities"}),"."]}),(0,Xt.jsx)("p",{className:"mt-2 text-xs text-ndor-ink-secondary leading-relaxed",children:"You remain in control. NDORFlow never auto-tailors, never auto-applies, and never submits anything on your behalf."})]})]}),(0,Xt.jsxs)(dg,{className:"flex flex-col-reverse sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-2",children:[r?(0,Xt.jsx)("span",{}):(0,Xt.jsxs)("label",{className:"flex items-center gap-2 text-xs text-ndor-ink-secondary cursor-pointer select-none","data-testid":"first-run-dont-show-again-label",children:[(0,Xt.jsx)(Vb,{checked:i,onCheckedChange:e=>o(!0===e),"data-testid":"first-run-dont-show-again-checkbox"}),(0,Xt.jsx)("span",{children:"Don\u2019t show this again"})]}),(0,Xt.jsxs)(Rr,{onClick:l,"data-testid":"first-run-got-it-button",className:"w-full sm:w-auto",children:[(0,Xt.jsx)(xh,{className:"h-4 w-4 mr-1.5"})," Got it"]})]})]})})}const Ow=wn("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),Bw=wn("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);function Lw(e){if(!e)return"";try{return new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short"})}catch(t){return""}}function Mw(){const{user:e}=tn(),{greetingName:t}=xg(),{limit:n}=Yb(),[a,r]=(0,s.useState)([]),[i,o]=(0,s.useState)([]),[l,c]=(0,s.useState)([]),[d,u]=(0,s.useState)([]),[m,p]=(0,s.useState)(null),[h,f]=(0,s.useState)(!1),[x,v]=(0,s.useState)(()=>{const e=ew(cw(),18e4);return!(e.hit&&e.fresh)});(0,s.useEffect)(()=>{let e=!0;return(async()=>{try{const t=await tw(cw(),async()=>{const[e,t,n,a,r]=await Promise.all([(0,zt.n)("/api/jobs").catch(()=>[]),(0,zt.n)("/api/application-packs").catch(()=>[]),(0,zt.n)("/api/cv-variants").catch(()=>[]),(0,zt.n)("/api/cover-letters").catch(()=>[]),(0,zt.n)("/api/account/plan").catch(()=>null)]);return{j:e,p:t,v:n,l:a,pl:r}},{ttlMs:18e4});if(!e||!t)return;const{j:n,p:a,v:s,l:i,pl:l}=t,d=Array.isArray(n)?n:(null===n||void 0===n?void 0:n.items)||[],m=Array.isArray(a)?a:(null===a||void 0===a?void 0:a.items)||[];r(d.slice(0,5)),o(m.slice(0,5)),c(Array.isArray(s)?s.slice(0,5):[]),u(Array.isArray(i)?i.slice(0,5):[]),p(l)}finally{e&&v(!1)}})(),()=>{e=!1}},[]),(0,s.useEffect)(()=>{if(null===e||void 0===e||!e.id)return;(function(e){try{return"1"===window.localStorage.getItem(Tw(e))}catch(t){return!1}})(e.id)||f(!0);const t=()=>f(!0);return window.addEventListener("ndor:first-run-open",t),()=>window.removeEventListener("ndor:first-run-open",t)},[null===e||void 0===e?void 0:e.id]);const g=(()=>{const e=(null===m||void 0===m?void 0:m.plan_code)||"base";if(!("focus"===e||"flow"===e))return{value:"Base",helper:"".concat(n," free analyses per day"),testid:"dashboard-stat-usage-base"};const t=Math.max(0,(null===m||void 0===m?void 0:m.included_usage_remaining)||0),a=Math.max(0,(null===m||void 0===m?void 0:m.extra_usage_remaining)||0);return{value:(t+a).toLocaleString(),helper:a>0?"".concat(t," included + ").concat(a," extra"):"Credits remaining",testid:"dashboard-stat-usage-paid"}})();return(0,Xt.jsxs)("div",{"data-testid":"dashboard-page",className:"space-y-6 sm:space-y-8",children:[(0,Xt.jsx)(Pw,{open:h,onOpenChange:f,userId:null===e||void 0===e?void 0:e.id}),(0,Xt.jsx)("section",{className:"brand-hex-grid rounded-2xl border border-ndor-edge px-6 sm:px-8 py-7 sm:py-9 relative","data-testid":"dashboard-hero",children:(0,Xt.jsxs)("div",{className:"relative z-[1] flex flex-col md:flex-row md:items-end md:justify-between gap-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui",children:"Command Centre"}),(0,Xt.jsx)("h1",{className:"mt-1 text-3xl sm:text-4xl font-serif-display font-semibold tracking-tight text-ndor-ink","data-testid":"dashboard-greeting",children:t?(0,Xt.jsxs)(Xt.Fragment,{children:["Hello, ",(0,Xt.jsx)("span",{className:"text-gold-accent",children:t})]}):"Welcome back"}),(0,Xt.jsx)("p",{className:"mt-1.5 text-sm text-ndor-ink-secondary max-w-xl",children:"Manage your jobs, documents, and applications from one place."})]}),(0,Xt.jsx)("div",{className:"flex items-center gap-2",children:(0,Xt.jsx)(Et,{to:"/jobs",children:(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",className:"border-ndor-edge bg-ndor-surface-alt hover:bg-ndor-surface text-ndor-ink","data-testid":"dashboard-add-job-button",children:[(0,Xt.jsx)(Ow,{className:"h-4 w-4 mr-1"})," Add job"]})})})]})}),(0,Xt.jsx)(Cw,{}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface brand-card-hover","data-testid":"dashboard-stat-usage",children:(0,Xt.jsxs)(Py,{className:"p-5 flex items-center justify-between",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Credits"}),(0,Xt.jsx)("p",{className:"text-2xl font-serif-display font-semibold text-ndor-ink mt-1","data-testid":g.testid,children:x?"\u2014":g.value}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted mt-0.5 font-manrope",children:x?"":g.helper})]}),(0,Xt.jsx)("div",{className:"w-10 h-10 rounded-lg bg-ndor-info-light text-ndor-info flex items-center justify-center border border-ndor-edge",children:(0,Xt.jsx)(Bw,{className:"h-5 w-5"})})]})}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface brand-card-hover","data-testid":"dashboard-stat-jobs",children:(0,Xt.jsxs)(Py,{className:"p-5 flex items-center justify-between",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Tracked jobs"}),(0,Xt.jsx)("p",{className:"text-2xl font-serif-display font-semibold text-ndor-ink mt-1",children:x?"\u2014":a.length})]}),(0,Xt.jsx)("div",{className:"w-10 h-10 rounded-lg bg-ndor-success-light text-ndor-success flex items-center justify-center border border-ndor-edge",children:(0,Xt.jsx)(kn,{className:"h-5 w-5"})})]})}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface brand-card-hover","data-testid":"dashboard-stat-packs",children:(0,Xt.jsxs)(Py,{className:"p-5 flex items-center justify-between",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Application packs"}),(0,Xt.jsx)("p",{className:"text-2xl font-serif-display font-semibold text-ndor-ink mt-1",children:x?"\u2014":i.length})]}),(0,Xt.jsx)("div",{className:"w-10 h-10 rounded-lg bg-ndor-warning-light text-ndor-warning flex items-center justify-center border border-ndor-edge",children:(0,Xt.jsx)(_
2n,{className:"h-5 w-5"})})]})})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 sm:gap-6",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface brand-card-hover","data-testid":"dashboard-recent-jobs",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(kn,{className:"h-4 w-4 text-ndor-gold"})," Recent jobs"]}),(0,Xt.jsx)(Et,{to:"/jobs",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink",children:"See all \u2192"})]}),(0,Xt.jsx)(Py,{className:"space-y-1",children:x?(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"Loading\u2026"}):0===a.length?(0,Xt.jsxs)("div",{className:"py-6 text-center space-y-2",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"No jobs yet."}),(0,Xt.jsx)(Et,{to:"/jobs",children:(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",className:"border-ndor-edge bg-ndor-surface-alt",children:"Add a job"})})]}):a.map(e=>(0,Xt.jsxs)(Et,{to:"/jobs/".concat(e.id),className:"flex items-center justify-between px-3 py-2 rounded-md hover:bg-ndor-surface-alt transition-colors","data-testid":"dashboard-job-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:e.title||"Untitled"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted truncate",children:e.company||"\u2014"})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted whitespace-nowrap ml-3 font-mono-ui",children:Lw(e.created_at)})]},e.id))})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface brand-card-hover","data-testid":"dashboard-recent-packs",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(_n,{className:"h-4 w-4 text-ndor-gold"})," Recent application packs"]}),(0,Xt.jsx)(Et,{to:"/applications",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink",children:"See all \u2192"})]}),(0,Xt.jsx)(Py,{className:"space-y-1",children:x?(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"Loading\u2026"}):0===i.length?(0,Xt.jsxs)("div",{className:"py-6 text-center space-y-2",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"No application packs yet."}),(0,Xt.jsx)(Et,{to:"/applications",children:(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",className:"border-ndor-edge bg-ndor-surface-alt",children:"Start a pack"})})]}):i.map(e=>(0,Xt.jsxs)(Et,{to:"/applications/".concat(e.id),className:"flex items-center justify-between px-3 py-2 rounded-md hover:bg-ndor-surface-alt transition-colors","data-testid":"dashboard-pack-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:["Pack #",(e.id||"").slice(0,8)]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted truncate",children:["Status: ",e.pack_status||"\u2014"]})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted whitespace-nowrap ml-3 font-mono-ui",children:Lw(e.created_at)})]},e.id))})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface brand-card-hover","data-testid":"dashboard-recent-variants",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-ndor-gold"})," Recent CV variants"]}),(0,Xt.jsx)(Et,{to:"/documents",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink","data-testid":"dashboard-recent-variants-open",children:"Open library \u2192"})]}),(0,Xt.jsx)(Py,{className:"space-y-1",children:x?(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"Loading\u2026"}):0===l.length?(0,Xt.jsxs)("div",{className:"py-6 text-center space-y-2",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"No CV variants generated yet."}),(0,Xt.jsx)(Et,{to:"/jobs",children:(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",className:"border-ndor-edge bg-ndor-surface-alt","data-testid":"dashboard-recent-variants-empty-cta",children:"Browse jobs to start \u2192"})})]}):l.map(e=>(0,Xt.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 rounded-md hover:bg-ndor-surface-alt transition-colors","data-testid":"dashboard-variant-".concat(e.id),children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink truncate",children:e.variant_name||e.role_family||"Variant"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted whitespace-nowrap ml-3 font-mono-ui",children:Lw(e.created_at)})]},e.id))})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface brand-card-hover","data-testid":"dashboard-recent-letters",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bg,{className:"h-4 w-4 text-ndor-gold"})," Recent cover letters"]}),(0,Xt.jsx)(Et,{to:"/documents?tab=letters",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink",children:"Open \u2192"})]}),(0,Xt.jsx)(Py,{className:"space-y-1",children:x?(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"Loading\u2026"}):0===d.length?(0,Xt.jsxs)("div",{className:"py-6 text-center space-y-2",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"No cover letters yet."}),(0,Xt.jsx)(Et,{to:"/documents?tab=letters",children:(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",className:"border-ndor-edge bg-ndor-surface-alt",children:"Generate a cover letter"})})]}):d.map(e=>(0,Xt.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 rounded-md hover:bg-ndor-surface-alt transition-colors","data-testid":"dashboard-letter-".concat(e.id),children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink truncate",children:e.title||e.target_role||"Cover letter"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted whitespace-nowrap ml-3 font-mono-ui",children:Lw(e.created_at)})]},e.id))})]})]}),(0,Xt.jsx)(Fw,{workspace:"candidate"})]})}const zw=["className","variant"],Uw=pa("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Vw(e){let{className:t,variant:n}=e,a=l(e,zw);return(0,Xt.jsx)("div",(0,c.A)({className:Sr(Uw({variant:n}),t)},a))}const qw=wn("map-pin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]),Ww=["className"],Hw=s.forwardRef((e,t)=>
2{let{className:n}=e,a=l(e,Ww);return(0,Xt.jsx)("textarea",(0,c.A)({className:Sr("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:t},a))});function Gw(e){let{refreshCredits:t,action:n,onExhausted:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return!1;if(429===e.status){const r=e.data&&e.data.detail||{};if("USAGE_EXHAUSTED"===r.code){if("function"===typeof a)try{a(r)}catch(c){}else{const e=Number(r.required_usage)||null,t=Math.max(0,(Number(r.included_usage_remaining)||0)+(Number(r.extra_usage_remaining)||0)),a=n?"Not enough Credits for ".concat(n):"Not enough Credits",s=e?"".concat(t," available \xb7 ").concat(e," needed. Open Plan to add Credits."):"".concat(t," available. Open Plan to add Credits.");fy.error(a,{description:s,action:{label:"View plan",onClick:()=>{try{window.location.assign("/account?tab=plan")}catch(e){}}}})}if("function"===typeof t)try{t()}catch(d){}return!0}}if(402!==e.status)return!1;const r=e.data||{},s=Number(r.required)||null,i=Number(r.balance)||0,o=n?"Not enough Credits for ".concat(n):"Not enough Credits",l=s?"".concat(i," available \xb7 ").concat(s," needed. Open Plan for details."):"".concat(i," available. Open Plan for details.");if(fy.error(o,{description:l,action:{label:"View plan",onClick:()=>{try{window.location.assign("/account?tab=plan")}catch(e){}}}}),"function"===typeof t)try{t()}catch(u){}return!0}async function Kw(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return null;const a="cv"===e?"/api/cv-variants":"/api/cover-letters";try{const e=await(0,zt.n)(a);if(!Array.isArray(e)||0===e.length)return null;const t=e.slice().sort((e,t)=>{const n=new Date((null===e||void 0===e?void 0:e.created_at)||0).getTime();return new Date((null===t||void 0===t?void 0:t.created_at)||0).getTime()-n}),r="number"===typeof(null===n||void 0===n?void 0:n.submittedAtMs)?n.submittedAtMs-3e4:null;for(const n of t){const e=null!==n&&void 0!==n&&n.created_at?new Date(n.created_at).getTime():0;if(e&&!(null!=r&&e<r))return n}return null}catch(pK){return"undefined"!==typeof console&&console.warn&&console.warn("[timeoutRecovery] lookup failed",(null===pK||void 0===pK?void 0:pK.message)||pK),null}}function Yw(e){var t,n,a;if(!e)return!1;const r=null!==(t=null!==(n=e.status)&&void 0!==n?n:e.code)&&void 0!==t?t:null===(a=e.response)||void 0===a?void 0:a.status;if(504===r||503===r||502===r)return!0;if(0===r)return!0;const s=String(e.message||e.detail||e||"").toLowerCase();return!(!s.includes("upstream")||!s.includes("timeout"))||(!!s.includes("stream timeout")||(!!s.includes("failed to fetch")||(!!s.includes("network request failed")||"AbortError"===e.name)))}async function Jw(e){let{generate:t,kind:n,jobId:a,onRecoveryState:r,maxRetries:s=10,intervalMs:i=1e4}=e;const o=Date.now();try{return await t()}catch(pK){if(!Yw(pK)||!a)throw pK;null===r||void 0===r||r("checking");for(let t=0;t<s;t+=1){await new Promise(e=>setTimeout(e,i));const e=await Kw(n,a,{submittedAtMs:o});if(e)return null===r||void 0===r||r("recovered"),e}throw null===r||void 0===r||r("failed"),pK}}async function $w(e,t,n){if(!e)return null;try{const a=await(0,zt.n)("/api/jobs/".concat(e,"/best-fit")),r=(null===a||void 0===a?void 0:a.all_cached)||[];if(!r.length)return null;const s=(null===t||void 0===t?void 0:t.source_type)||null,i=(null===t||void 0===t?void 0:t.source_id)||null,o=n-3e4;for(const e of r){const t=null!==e&&void 0!==e&&e.evaluated_at?new Date(e.evaluated_at).getTime():0;if(t&&!(t<o))if(s&&i){if(e.source_type===s&&e.source_id===i)return e}else if("uploaded_cv"===e.source_type)return e}return null}catch(pK){return"undefined"!==typeof console&&console.warn&&console.warn("[timeoutRecovery] best-fit lookup failed",(null===pK||void 0===pK?void 0:pK.message)||pK),null}}Hw.displayName="Textarea";const Xw="ndor.addJobDialog.v1",Qw={title:"",company:"",location:"",employment_type:"",seniority_level:"",description:"",requirements_text:"",url:""},Zw=["Reading the job posting\u2026","Extracting job details\u2026","Analysing the role\u2026","Still working \u2014 preparing your result\u2026"],ej=["Saving your job\u2026","Almost done\u2026"],tj=()=>{try{if("undefined"===typeof window)return;window.sessionStorage.removeItem(Xw)}catch(e){}};function nj(e){let{onJobAdded:t}=e;const{refresh:n}=If(),a=ke(),r=(()=>{try{if("undefined"===typeof window)return null;const e=window.sessionStorage.getItem(Xw);if(!e)return null;const t=JSON.parse(e);return t&&"object"===typeof t?t:null}catch(e){return null}})(),i=Boolean(null===r||void 0===r?void 0:r.open),[o,l]=(0,s.use
2State)(i),[d,u]=(0,s.useState)(()=>{if(!i)return"smart";return"description"===(null===r||void 0===r?void 0:r.mode)?"description":"smart"}),[m,p]=(0,s.useState)(!1),[h,f]=(0,s.useState)(i&&r.smartUrl||""),[x,v]=(0,s.useState)(i&&r.smartRawText||""),[g,y]=(0,s.useState)(!1),[b,w]=(0,s.useState)(!1);(0,s.useEffect)(()=>{i&&null!==r&&void 0!==r&&r.blockedSiteAutoSwitched&&w(!0)},[]);const[j,k]=(0,s.useState)("idle"),[N,_]=(0,s.useState)(i&&r.form&&"object"===typeof r.form?(0,c.A)((0,c.A)({},Qw),r.form):(0,c.A)({},Qw)),[D,C]=(0,s.useState)(0),A=(0,s.useRef)(null);(0,s.useEffect)(()=>m?(C(0),A.current=setInterval(()=>{C(e=>e+1)},3500),()=>{A.current&&(clearInterval(A.current),A.current=null)}):(A.current&&(clearInterval(A.current),A.current=null),void C(0)),[m]);const S="smart"===d?Zw:ej,E=m?S[Math.min(D,S.length-1)]:null;(0,s.useEffect)(()=>{o?(e=>{try{if("undefined"===typeof window)return;window.sessionStorage.setItem(Xw,JSON.stringify(e))}catch(t){}})({open:o,mode:d,smartUrl:h,smartRawText:x,blockedSiteAutoSwitched:b,form:N}):tj()},[o,d,h,x,b,N]);const F=()=>{f(""),v(""),y(!1),w(!1),_((0,c.A)({},Qw)),u("smart"),k("idle"),tj()},R=e=>async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{onState:n,maxRetries:a=2,intervalMs:r=8e3}=t;try{return await(0,zt.n)("/api/jobs/ingest-url",{method:"POST",body:e})}catch(pK){if(!Yw(pK))throw pK;
2null===n||void 0===n||n("checking");for(let i=0;i<a;i+=1){await new Promise(e=>setTimeout(e,r));try{const t=await(0,zt.n)("/api/jobs/ingest-url",{method:"POST",body:e});return null===n||void 0===n||n("recovered"),t}catch(s){if(!Yw(s))throw s}}throw null===n||void 0===n||n("unknown"),pK}}(e,{onState:k}),I=e=>t=>{var n,a;return _((0,c.A)((0,c.A)({},N),{},{[e]:null!==(n=null===t||void 0===t||null===(a=t.target)||void 0===a?void 0:a.value)&&void 0!==n?n:t}))};return(0,Xt.jsxs)(rg,{open:o,onOpenChange:e=>{l(e),e||F()},children:[(0,Xt.jsx)(sg,{asChild:!0,children:(0,Xt.jsxs)(Rr,{"data-testid":"add-job-button",children:[(0,Xt.jsx)(Ow,{className:"h-4 w-4 mr-1.5"})," Add Job"]})}),(0,Xt.jsxs)(lg,{className:"max-w-lg max-h-[90vh] overflow-y-auto","data-testid":"add-job-dialog-content",onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,Xt.jsx)(cg,{children:(0,Xt.jsx)(ug,{className:"text-ndor-ink font-outfit",children:"Add a new job"})}),(0,Xt.jsxs)("div",{className:"flex gap-2 mt-2 mb-4 flex-wrap",children:[(0,Xt.jsxs)("button",{type:"button",onClick:()=>{u("smart"),w(!1)},"data-testid":"add-job-mode-smart",disabled:m,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ".concat("smart"===d?"bg-ndor-surface-alt text-ndor-ink":"text-ndor-ink-muted hover:text-ndor-ink"),children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4"})," Smart URL"]}),(0,Xt.jsxs)("button",{type:"button",onClick:()=>u("description"),"data-testid":"add-job-mode-description",disabled:m,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ".concat("description"===d?"bg-ndor-surface-alt text-ndor-ink":"text-ndor-ink-muted hover:text-ndor-ink"),children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4"})," Paste description"]})]}),"smart"===d&&(0,Xt.jsxs)("div",{className:"space-y-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Job URL *"}),(0,Xt.jsx)(Ag,{value:h,onChange:e=>{f(e.target.value),y(!1),k("idle")},placeholder:"https://...",className:"h-10","data-testid":"add-job-smart-url",disabled:m}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted","data-testid":"add-job-smart-helper",children:"Paste a job posting link and we'll try to extract the details automatically."})]}),"checking"===j&&(0,Xt.jsxs)("div",{role:"status","data-testid":"add-job-recovery-banner-checking",className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2 text-xs text-ndor-ink flex items-start gap-2",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"font-medium",children:"This is taking longer than usual."}),(0,Xt.jsx)("div",{className:"text-ndor-ink-muted",children:"The page may have been saved already \u2014 we're checking. Please don't close this dialog yet."})]})]}),"unknown"===j&&(0,Xt.jsxs)("div",{role:"alert","data-testid":"add-job-recovery-banner-unknown",className:"rounded-md border border-amber-300 bg-amber-500/10 px-3 py-2 text-xs text-amber-200 flex items-start gap-2",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"font-medium",children:"We couldn't confirm the import."}),(0,Xt.jsx)("div",{children:"The connection timed out, but the job may still have saved. Close this dialog and refresh your Jobs list to check before trying again. If it isn't there, paste the description below."})]})]}),(g||"unknown"===j)&&(0,Xt.jsxs)("div",{className:"space-y-1.5","data-testid":"add-job-smart-fallback-block",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Paste the job description instead"}),(0,Xt.jsx)(Hw,{value:x,onChange:e=>v(e.target.value),placeholder:"Some sites (LinkedIn, Indeed) block automated fetching. Paste the job text here and we'll still structure it.",rows:6,"data-testid":"add-job-smart-raw-text",disabled:m}),g&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-warning","data-testid":"add-job-smart-fallback-hint",children:"We couldn't read that URL automatically. Paste the description above and we'll structure it for you."})]})]}),"description"===d&&(0,Xt.jsxs)("div",{className:"space-y-4",children:[(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted","data-testid":"add-job-manual-helper",children:"If automatic import is blocked or incomplete, paste the job description here and add the job details manually."}),b&&(0,Xt.jsxs)("div",{role:"status","data-testid":"add-job-blocked-site-banner",className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2.5 text-xs text-ndor-ink-secondary flex items-start gap-2 leading-relaxed",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 text-ndor-gold shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"font-medium text-ndor-ink",children:"This site appears to block automated imports."}),(0,Xt.jsx)("div",{children:"You can still add the role manually below. Your original URL is preserved in the Source URL field and won't be charged or re-imported."})]})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Title *"}),(0,Xt.jsx)(Ag,{value:N.title,onChange:I("title"),placeholder:"Senior Engineer",className:"h-10","data-testid":"add-job-title",disabled:m})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Company"}),(0,Xt.jsx)(Ag,{value:N.company,onChange:I("company"),placeholder:"Acme Inc.",className:"h-10",disabled:m})]})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink-secondary text-xs",children:"Location"}),(0,Xt.jsx)(Ag,{value:N.location,onChange:I("location"),placeholder:"London, UK",className:"h-9",disabled:m})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink-secondary text-xs",children:"Employment type"}),(0,Xt.jsxs)(Vv,{value:N.employment_type,onValueChange:I("employment_type"),disabled:m,children:[(0,Xt.jsx)(Wv,{className:"h-9",children:(0,Xt.jsx)(qv,{placeholder:"Select"})}),(0,Xt.jsx)(Kv,{children:["full_time","part_time","contract","freelance","internship"].map(e=>(0,Xt.jsx)(Yv,{value:e,children:e.replace("_"," ")},e))})]})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink-secondary text-xs",children:"Seniority level"}),(0,Xt.jsxs)(Vv,{value:N.seniority_level,onValueChange:I("seniority_level"),disabled:m,children:[(0,Xt.jsx)(Wv,{className:"h-9",children:(0,Xt.jsx)(qv,{placeholder:"Select"})}),(0,Xt.jsx)(Kv,{children:["junior","mid","senior","lead","manager","director","executive"].map(e=>(0,Xt.jsx)(Yv,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Description *"}),(0,Xt.jsx)(Hw,{value:N.description,onChange:I("description"),placeholder:"Paste the full job description...",rows:5,"data-testid":"add-job-description",disabled:m})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink-secondary text-xs",children:"Requirements (optional)"}),(0,Xt.jsx)(Hw,{value:N.requirements_text,onChange:I("requirements_text"),placeholder:"Requirements, qualifications...",rows:3,disabled:m})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink-secondary text-xs",children:"Source URL (optional)"}),(0,Xt.jsx)(Ag,{value:N.url,onChange:I("url"),placeholder:"https://...",className:"h-9",disabled:m})]})]}),E&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"add-job-progress",className:"mt-4 flex items-center gap-2 text-xs text-ndor-ink-secondary",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0 text-ndor-ink-muted"}),(0,Xt.jsx)("span",{"data-testid":"add-job-progress-message",children:E})]}),(0,Xt.jsxs)("div",{className:"flex justify-end gap-2 mt-4 pt-4 border-t border-ndor-edge",children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:()=>l(!1),disabled:m,"data-testid":"add-job-cancel",children:"Cancel"}),(0,Xt.jsxs)(Rr,{onClick:async()=>
2{if("smart"!==d||h.trim())if("description"!==d||N.title.trim())if("description"!==d||N.description.trim()){p(!0),k("idle");try{var e,r,s;let o;if("smart"===d){const e={url:h.trim()};x.trim()&&(e.raw_text=x.trim()),o=await R(e)}else{const e=(0,c.A)({},N);Object.keys(e).forEach(t=>{e[t]||delete e[t]}),o=await(0,zt.n)("/api/jobs/manual-description",{method:"POST",body:e})}null!==(e=o)&&void 0!==e&&e.duplicate?fy.info("This job is already in your list \u2014 opened the existing entry."):(fy.success("Job added successfully."),"smart"===d&&n());try{nw(["jobs","dashboard:bundle"])}catch(i){}const u=(null===(r=o)||void 0===r?void 0:r.id)||null,m=Boolean(null===(s=o)||void 0===s?void 0:s.duplicate);l(!1),F(),null===t||void 0===t||t(),u&&!m&&a("/jobs/".concat(u,"?imported=1"))}catch(pK){Gw(pK,{refreshCredits:n,action:"job URL import"})||("smart"!==d||422!==(null===pK||void 0===pK?void 0:pK.status)&&!/blocks automated|automated access|paste the (description|job)/i.test((null===pK||void 0===pK?void 0:pK.message)||"")?"smart"===d&&"unknown"===j||fy.error(((e,t)=>{const n=((null===e||void 0===e?void 0:e.message)||"").trim(),a=null===e||void 0===e?void 0:e.status;return!n||/^internal server error\.?$/i.test(n)||/^server error\.?$/i.test(n)||/^request failed( with status code \d+)?\.?$/i.test(n)||a>=500&&a<600?"smart"===t?"Something went wrong on our side. Please try again in a moment \u2014 or paste the job description directly using Paste description.":"Something went wrong on our side. Please try again in a moment.":n||"Failed to add job."})(pK,d)):(_(e=>(0,c.A)((0,c.A)({},e),{},{url:h.trim()})),w(!0),u("description"),y(!1)))}finally{p(!1)}}else fy.error("Job description is required.");else fy.error("Job title is required.");else fy.error("Please paste a job URL.")},disabled:m,"data-testid":"add-job-submit",children:[m&&(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}),m?"smart"===d?"Extracting\u2026":"Saving\u2026":"smart"===d?"Extract & add":"Add Job"]})]})]})]})}const aj=wn("settings-2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);function rj(){const[e,t]=(0,s.useState)(null),[n,a]=(0,s.useState)(!0),[r,i]=(0,s.useState)(!1),o=(0,s.useCallback)(async()=>{a(!0);try{const e=await(0,zt.n)("/api/profile/preferences");t((null===e||void 0===e?void 0:e.preferences)||{}),i(Boolean(null===e||void 0===e?void 0:e.unmigrated))}catch(e){t(null)}finally{a(!1)}},[]);(0,s.useEffect)(()=>{o()},[o]),(0,s.useEffect)(()=>{const e=()=>o();return window.addEventListener("ndor:preferences-changed",e),()=>window.removeEventListener("ndor:preferences-changed",e)},[o]);const l=(0,s.useMemo)(()=>Nw(e),[e]),c=(0,s.useMemo)(()=>function(e){if(!e||"object"!==typeof e)return[];const t=[];Array.isArray(e.preferred_titles)&&e.preferred_titles.length&&t.push("Preferred titles: ".concat(e.preferred_titles.join(", "))),Array.isArray(e.industries)&&e.industries.length&&t.push("Industries: ".concat(e.industries.join(", "))),Array.isArray(e.seniority_targets)&&e.seniority_targets.length&&t.push("Seniority: ".concat(e.seniority_targets.join(", "))),Array.isArray(e.employment_types)&&e.employment_types.length&&t.push("Employment types: ".concat(e.employment_types.join(", "))),e.remote_preferences&&"any"!==e.remote_preferences&&t.push("Remote: ".concat(e.remote_preferences)),Array.isArray(e.preferred_regions)&&e.preferred_regions.length&&t.push("Locations: ".concat(e.preferred_regions.join(", "))),e.open_to_relocation&&"conditional"!==e.open_to_relocation&&t.push("Relocation: ".concat(e.open_to_relocation)),e.location_strictness&&"balanced"!==e.location_strictness&&t.push("Strictness: ".concat(e.location_strictness));const n=e.salary_floor,a=e.salary_ceiling,r=e.salary_currency||"GBP",s=e.salary_period||"annual";return"number"===typeof n&&"number"===typeof a?t.push("Salary: ".concat(n.toLocaleString(),"\u2013").concat(a.toLocaleString()," ").concat(r," (").concat(s,")")):"number"===typeof n?t.push("Salary: \u2265 ".concat(n.toLocaleString()," ").concat(r," (").concat(s,")")):"number"===typeof a&&t.push("Salary: \u2264 ".concat(a.toLocaleStr
2ing()," ").concat(r," (").concat(s,")")),Array.isArray(e.excluded_keywords)&&e.excluded_keywords.length&&t.push("Excluded: ".concat(e.excluded_keywords.join(", "))),t}(e),[e]);return n?null:0===l?(0,Xt.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded border border-ndor-edge bg-ndor-surface-alt/40 text-xs text-ndor-ink","data-testid":"jobs-preferences-hydration-banner-empty",children:[(0,Xt.jsx)(zf,{className:"h-4 w-4 text-ndor-ink-muted shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{className:"flex-1",children:[(0,Xt.jsx)("p",{className:"font-medium",children:"No preferences set yet."}),(0,Xt.jsxs)("p",{className:"text-ndor-ink-muted mt-0.5",children:["NDOR Analyse Fit will fall back to job-side signals only."," ",(0,Xt.jsx)(Et,{to:"/account?tab=preferences",className:"underline underline-offset-2 hover:text-ndor-ink-muted","data-testid":"jobs-preferences-hydration-banner-set-link",children:"Set your preferences"})," ","to make scoring personal \u2014 salary, industry, seniority, exclusions, and more."]})]})]}):(0,Xt.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded border border-ndor-edge bg-ndor-surface-alt/40 text-xs text-ndor-ink","data-testid":"jobs-preferences-hydration-banner",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-ink-muted shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Xt.jsxs)("p",{className:"font-medium flex items-center gap-1.5",children:[(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5 text-emerald-600"}),"NDOR Analyse Fit is using ",l," of your preference",1===l?"":"s","."]}),c.length>0&&(0,Xt.jsxs)("ul",{className:"text-ndor-ink-muted mt-1 space-y-0.5 list-disc pl-4 marker:text-ndor-ink-muted/60","data-testid":"jobs-preferences-hydration-summary",children:[c.slice(0,4).map(e=>(0,Xt.jsx)("li",{className:"truncate",children:e},e)),c.length>4&&(0,Xt.jsxs)("li",{className:"italic",children:["+ ",c.length-4," more\u2026"]})]}),r&&(0,Xt.jsx)("p",{className:"text-amber-200 mt-1",children:"Storage column missing \u2014 apply migration 023 to persist."})]}),(0,Xt.jsxs)(Et,{to:"/account?tab=preferences",className:"text-ndor-ink-muted hover:text-ndor-ink shrink-0 inline-flex items-center gap-1 text-[11px] underline underline-offset-2","data-testid":"jobs-preferences-hydration-banner-edit-link",children:[(0,Xt.jsx)(aj,{className:"h-3 w-3"}),"Edit"]})]})}const sj=["children"],ij=["children"];function oj(e){const t=lj(e),n=s.forwardRef((e,n)=>{const{children:a}=e,r=l(e,sj),i=s.Children.toArray(a),o=i.find(dj);if(o){const e=o.props.children,a=i.map(t=>t===o?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:s.isValidElement(e)?s.cloneElement(e,void 0,a):null}))}return(0,Xt.jsx)(t,(0,c.A)((0,c.A)({},r),{},{ref:n,children:a}))});return n.displayName="".concat(e,".Slot"),n}function lj(e){const t=s.forwardRef((e,t)=>{const{children:n}=e,a=l(e,ij);if(s.isValidElement(n)){const e=function(e){var t,n;let a=null===(t=Object.getOwnPropertyDescriptor(e.props,"ref"))||void 0===t?void 0:t.get,r=a&&"isReactWarning"in a&&a.isReactWarning;if(r)return e.ref;if(a=null===(n=Object.getOwnPropertyDescriptor(e,"ref"))||void 0===n?void 0:n.get,r=a&&"isReactWarning"in a&&a.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n),r=function(e,t){const n=(0,c.A)({},t);for(const a in t){const r=e[a],s=t[a];/^on[A-Z]/.test(a)?r&&s?n[a]=function(){const e=s(...arguments);return r(...arguments),e}:r&&(n[a]=r):"style"===a?n[a]=(0,c.A)((0,c.A)({},r),s):"className"===a&&(n[a]=[r,s].filter(Boolean).join(" "))}return(0,c.A)((0,c.A)({},e),n)}(a,n.props);return n.type!==s.Fragment&&(r.ref=t?$n(t,e):e),s.cloneElement(n,r)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName="".concat(e,".SlotClone"),t}var cj=Symbol("radix.slottable");function dj(e){return s.isValidElement(e)&&"function"===typeof e.type&&"__radixId"in e.type&&e.type.__radixId===cj}const uj=["__scopePopover"],mj=["__scopePopover"],pj=["forceMount"],hj=["__scopePopover","trapFocus","onOpenAutoFocus","onCloseAutoFocus","disableOutsidePointerEvents","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside"],fj=["__scopePopover"],xj=["__scopePopover"];
2var vj="Popover",[gj,yj]=js(vj,[Al]),bj=Al(),[wj,jj]=gj(vj),kj=e=>{const{__scopePopover:t,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:o=!1}=e,l=bj(t),d=s.useRef(null),[u,m]=s.useState(!1),[p,h]=_s({prop:a,defaultProp:null!==r&&void 0!==r&&r,onChange:i,caller:vj});return(0,Xt.jsx)(Wl,(0,c.A)((0,c.A)({},l),{},{children:(0,Xt.jsx)(wj,{scope:t,contentId:_i(),triggerRef:d,open:p,onOpenChange:h,onOpenToggle:s.useCallback(()=>h(e=>!e),[h]),hasCustomAnchor:u,onCustomAnchorAdd:s.useCallback(()=>m(!0),[]),onCustomAnchorRemove:s.useCallback(()=>m(!1),[]),modal:o,children:n})}))};kj.displayName=vj;var Nj="PopoverAnchor",_j=s.forwardRef((e,t)=>{const{__scopePopover:n}=e,a=l(e,uj),r=jj(Nj,n),i=bj(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:d}=r;return s.useEffect(()=>(o(),()=>d()),[o,d]),(0,Xt.jsx)(Hl,(0,c.A)((0,c.A)((0,c.A)({},i),a),{},{ref:t}))});_j.displayName=Nj;var Dj="PopoverTrigger",Cj=s.forwardRef((e,t)=>{const{__scopePopover:n}=e,a=l(e,mj),r=jj(Dj,n),s=bj(n),i=Xn(t,r.triggerRef),o=(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":Uj(r.open)},a),{},{ref:i,onClick:ys(e.onClick,r.onOpenToggle)}));return r.hasCustomAnchor?o:(0,Xt.jsx)(Hl,(0,c.A)((0,c.A)({asChild:!0},s),{},{children:o}))});Cj.displayName=Dj;var Aj="PopoverPortal",[Sj,Ej]=gj(Aj,{forceMount:void 0}),Fj=e=>{const{__scopePopover:t,forceMount:n,children:a,container:r}=e,s=jj(Aj,t);return(0,Xt.jsx)(Sj,{scope:t,forceMount:n,children:(0,Xt.jsx)($l,{present:n||s.open,children:(0,Xt.jsx)(Jl,{asChild:!0,container:r,children:a})})})};Fj.displayName=Aj;var Rj="PopoverContent",Ij=s.forwardRef((e,t)=>{const n=Ej(Rj,e.__scopePopover),{forceMount:a=n.forceMount}=e,r=l(e,pj),s=jj(Rj,e.__scopePopover);return(0,Xt.jsx)($l,{present:a||s.open,children:s.modal?(0,Xt.jsx)(Pj,(0,c.A)((0,c.A)({},r),{},{ref:t})):(0,Xt.jsx)(Oj,(0,c.A)((0,c.A)({},r),{},{ref:t}))})});Ij.displayName=Rj;var Tj=oj("PopoverContent.RemoveScroll"),Pj=s.forwardRef((e,t)=>{const n=jj(Rj,e.__scopePopover),a=s.useRef(null),r=Xn(t,a),i=s.useRef(!1);return s.useEffect(()=>{const e=a.current;if(e)return Fc(e)},[]),(0,Xt.jsx)(bd,{as:Tj,allowPinchZoom:!0,children:(0,Xt.jsx)(Bj,(0,c.A)((0,c.A)({},e),{},{ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ys(e.onCloseAutoFocus,e=>{var t;e.preventDefault(),i.current||null===(t=n.triggerRef.current)||void 0===t||t.focus()}),onPointerDownOutside:ys(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey,a=2===t.button||n;i.current=a},{checkForDefaultPrevented:!1}),onFocusOutside:ys(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})}))})}),Oj=s.forwardRef((e,t)=>{const n=jj(Rj,e.__scopePopover),a=s.useRef(!1),r=s.useRef(!1);return(0,Xt.jsx)(Bj,(0,c.A)((0,c.A)({},e),{},{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var s,i;(null===(s=e.onCloseAutoFocus)||void 0===s||s.call(e,t),t.defaultPrevented)||(a.current||null===(i=n.triggerRef.current)||void 0===i||i.focus(),t.preventDefault());a.current=!1,r.current=!1},onInteractOutside:t=>{var s,i;null===(s=e.onInteractOutside)||void 0===s||s.call(e,t),t.defaultPrevented||(a.current=!0,"pointerdown"===t.detail.originalEvent.type&&(r.current=!0));const o=t.target;(null===(i=n.triggerRef.current)||void 0===i?void 0:i.contains(o))&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&r.current&&t.preventDefault()}}))}),Bj=s.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:o,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:m}=e,p=l(e,hj),h=jj(Rj,n),f=bj(n);return di(),(0,Xt.jsx)(xi,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:s,children:(0,Xt.jsx)(si,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:m,onEscapeKeyDown:o,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>h.onOpenChange(!1),children:(0,Xt.jsx)(Gl,(0,c.A)((0,c.A)((0,c.A)({"data-state":Uj(h.open),role:"dialog",id:h.contentId},f),p),{},{ref:t,style:(0,c.A)((0,c.A)({},p.style),{"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"})}))})})}),Lj="PopoverClose",Mj=s.forwardRef((e,t)=>
2{const{__scopePopover:n}=e,a=l(e,fj),r=jj(Lj,n);return(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button"},a),{},{ref:t,onClick:ys(e.onClick,()=>r.onOpenChange(!1))}))});Mj.displayName=Lj;var zj=s.forwardRef((e,t)=>{const{__scopePopover:n}=e,a=l(e,xj),r=bj(n);return(0,Xt.jsx)(Kl,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});function Uj(e){return e?"open":"closed"}zj.displayName="PopoverArrow";var Vj=Fj,qj=Ij;const Wj=["className","align","sideOffset"],Hj=kj,Gj=Cj,Kj=s.forwardRef((e,t)=>{let{className:n,align:a="center",sideOffset:r=4}=e,s=l(e,Wj);return(0,Xt.jsx)(Vj,{children:(0,Xt.jsx)(qj,(0,c.A)({ref:t,align:a,sideOffset:r,className:Sr("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",n)},s))})});function Yj(e){return"yes"===e?"Open to relocation":"no"===e?"Not open to relocation":"Open conditionally"}function Jj(e){let{preferenceScoring:t,triggerTestId:n}=e;const a=t;if(!function(e){return Boolean(e&&e.explanation)}(a))return null;const r=a.explanation,s=null!==a.base_score&&null!==a.final_score;return(0,Xt.jsxs)(Hj,{children:[(0,Xt.jsx)(Gj,{asChild:!0,children:(0,Xt.jsx)("button",{type:"button",className:"inline-flex items-center justify-center h-5 w-5 rounded-full text-ndor-ink-muted hover:text-ndor-ink hover:bg-ndor-surface-alt/80 transition-colors","aria-label":"Why this match?",title:"Why this match?","data-testid":n,onClick:e=>e.stopPropagation(),children:(0,Xt.jsx)(An,{className:"h-3.5 w-3.5"})})}),(0,Xt.jsxs)(Kj,{align:"start",side:"bottom",className:"w-[320px] text-xs p-3 space-y-2.5","data-testid":"".concat(n,"-content"),children:[(0,Xt.jsx)("div",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Why this match?"}),s&&(0,Xt.jsxs)("div",{className:"font-mono text-[11px] text-ndor-ink space-y-0.5","data-testid":"".concat(n,"-math"),children:[(0,Xt.jsxs)("div",{children:["Base fit: ",(0,Xt.jsx)("span",{className:"font-semibold tabular-nums",children:a.base_score})]}),(0,Xt.jsxs)("div",{children:["Location adjustment:"," ",(0,Xt.jsxs)("span",{className:"font-semibold tabular-nums",children:["\xd7",a.location_multiplier]})]}),(0,Xt.jsxs)("div",{children:["Final:"," ",(0,Xt.jsx)("span",{className:"font-semibold tabular-nums",children:a.final_score})," \u2192 ",(0,Xt.jsx)("span",{className:"font-semibold",children:a.match_label})]})]}),!s&&(0,Xt.jsx)("div",{className:"text-[11px] text-ndor-ink-muted italic",children:"Not analysed yet \u2014 run Analyse Fit to see a base score."}),(0,Xt.jsxs)("div",{className:"pt-2 border-t border-ndor-edge text-[11px] text-ndor-ink leading-relaxed","data-testid":"".concat(n,"-reason"),children:[(0,Xt.jsx)("span",{className:"font-medium",children:"Reason:"})," ",r.reason||"\u2014"]}),(0,Xt.jsxs)("dl",{className:"text-[10px] text-ndor-ink-muted grid grid-cols-[auto_1fr] gap-x-2 gap-y-0.5 pt-1",children:[(0,Xt.jsx)("dt",{children:"Job location"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink truncate",title:r.job_location||"",children:r.job_location||(0,Xt.jsx)("span",{className:"italic",children:"unspecified"})}),(0,Xt.jsx)("dt",{children:"Preferred"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:r.preferred_regions&&r.preferred_regions.length>0?r.preferred_regions.join(", "):(0,Xt.jsx)("span",{className:"italic",children:"none set"})}),(0,Xt.jsx)("dt",{children:"Strictness"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:(i=r.location_strictness,"strict"===i?"Strict":"open"===i?"Open":"Balanced")}),(0,Xt.jsx)("dt",{children:"Relocation"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:Yj(r.open_to_relocation)}),(0,Xt.jsx)("dt",{children:"Matched?"}),(0,Xt.jsx)("dd",{className:r.location_match?"text-ndor-success":"text-ndor-ink-muted","data-testid":"".concat(n,"-matched"),children:r.location_match?"Yes":"No"})]})]})]});var i}Kj.displayName=qj.displayName;const $j="This decision was made based on your current profile fit. No detailed guidance was captured.",Xj={shortlist:"Why shortlist",apply_with_repositioning:"Tailoring advice",hold:"Why hold",reject:"Why reject"},Qj={high:"bg-ndor-success-light/60 text-ndor-success border-ndor-success/30",medium:"bg-ndor-warning-light/60 text-ndor-warning border-ndor-warning/30",low:"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge"},Zj={high:"High",medium:"Medium",low:"Low"};function ek(e){let{advice:t,decision:n,confidence:a,badgeLabel:r,className:i,testIdBase:o}=e;const l="string"===typeof t?t.trim():"",c=l.length>0,d=c?l:$j,u=Xj[n]||"Decision details",m=Qj[a]||null,p=Zj[a]||null,[h,f]=(0,s.use
2State)(!1);return(0,Xt.jsxs)(Hj,{open:h,onOpenChange:f,children:[(0,Xt.jsx)(Gj,{asChild:!0,children:(0,Xt.jsx)("button",{type:"button","aria-label":u,title:c?l:$j,"data-testid":"".concat(o,"-trigger"),"data-decision":n,"data-has-advice":c?"true":"false","data-confidence":a||"",onClick:e=>{e.preventDefault(),e.stopPropagation(),f(e=>!e)},className:"appearance-none bg-transparent border-0 p-0 cursor-pointer",children:(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] cursor-pointer ".concat(i),children:r})})}),(0,Xt.jsxs)(Kj,{align:"end",side:"bottom",className:"w-[320px] text-xs p-3 space-y-2","data-testid":"".concat(o,"-content"),onClick:e=>e.stopPropagation(),children:[(0,Xt.jsx)("div",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:u}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink leading-relaxed","data-testid":"".concat(o,"-body"),children:d}),p&&(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 pt-1","data-testid":"".concat(o,"-confidence"),children:[(0,Xt.jsx)("span",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Confidence:"}),(0,Xt.jsx)("span",{className:"inline-flex items-center rounded-md border px-1.5 py-0 text-[10px] font-medium ".concat(m),"data-testid":"".concat(o,"-confidence-chip"),"data-confidence":a,children:p})]}),!c&&(0,Xt.jsx)("p",{className:"text-[10px] italic text-ndor-ink-muted","data-testid":"".concat(o,"-fallback-note"),children:"No tailored guidance was captured for this analysis."})]})]})}const tk=["__scopeSwitch","name","checked","defaultChecked","required","disabled","value","onCheckedChange","form"],nk=["__scopeSwitch"],ak=["__scopeSwitch","control","checked","bubbles"];var rk="Switch",[sk,ik]=js(rk),[ok,lk]=sk(rk),ck=s.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:o,disabled:d,value:u="on",onCheckedChange:m,form:p}=e,h=l(e,tk),[f,x]=s.useState(null),v=Xn(t,e=>x(e)),g=s.useRef(!1),y=!f||(p||!!f.closest("form")),[b,w]=_s({prop:r,defaultProp:null!==i&&void 0!==i&&i,onChange:m,caller:rk});return(0,Xt.jsxs)(ok,{scope:n,checked:b,disabled:d,children:[(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button",role:"switch","aria-checked":b,"aria-required":o,"data-state":pk(b),"data-disabled":d?"":void 0,disabled:d,value:u},h),{},{ref:v,onClick:ys(e.onClick,e=>{w(e=>!e),y&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})})),y&&(0,Xt.jsx)(mk,{control:f,bubbles:!g.current,name:a,value:u,checked:b,required:o,disabled:d,form:p,style:{transform:"translateX(-100%)"}})]})});ck.displayName=rk;var dk="SwitchThumb",uk=s.forwardRef((e,t)=>{const{__scopeSwitch:n}=e,a=l(e,nk),r=lk(dk,n);return(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({"data-state":pk(r.checked),"data-disabled":r.disabled?"":void 0},a),{},{ref:t}))});uk.displayName=dk;var mk=s.forwardRef((e,t)=>{let{__scopeSwitch:n,control:a,checked:r,bubbles:i=!0}=e,o=l(e,ak);const d=s.useRef(null),u=Xn(d,t),m=Qf(r),p=jl(a);return s.useEffect(()=>{const e=d.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(m!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[m,r,i]),(0,Xt.jsx)("input",(0,c.A)((0,c.A)({type:"checkbox","aria-hidden":!0,defaultChecked:r},o),{},{tabIndex:-1,ref:u,style:(0,c.A)((0,c.A)((0,c.A)({},o.style),p),{},{position:"absolute",pointerEvents:"none",opacity:0,margin:0})}))});function pk(e){return e?"checked":"unchecked"}mk.displayName="SwitchBubbleInput";var hk=ck,fk=uk;const xk=["className"],vk=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,xk);return(0,Xt.jsx)(hk,(0,c.A)((0,c.A)({className:Sr("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n)},a),{},{ref:t,children:(0,Xt.jsx)(fk,{className:Sr("pointer-events-none block h-4 w-4 roun
2ded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}))});vk.displayName=hk.displayName;const gk={reject:{label:"Reject",className:"bg-ndor-error-light text-ndor-error border-ndor-error/20"},hold:{label:"Hold",className:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/20"},shortlist:{label:"Shortlist",className:"bg-ndor-success-light text-ndor-success border-ndor-success/20"},apply_with_repositioning:{label:"Tailor application",className:"bg-ndor-info-light text-ndor-info border-ndor-info/20"}},yk={"Strong match":"bg-ndor-success-light text-ndor-success border-ndor-success/20","Good match":"bg-ndor-info-light text-ndor-info border-ndor-info/20","Low relevance":"bg-ndor-warning-light text-ndor-warning border-ndor-warning/20"};const bk={draft:{label:"Draft",className:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/20"},ready:{label:"Ready",className:"bg-ndor-info-light text-ndor-info border-ndor-info/20"},submitted:{label:"Submitted",className:"bg-ndor-success-light text-ndor-success border-ndor-success/20"},archived:{label:"Archived",className:"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge"}};function wk(){const[e,t]=Pt(),n=e.get("company")||"",a=e.get("location")||"",r=e.get("source_kind")||"any",i=Math.max(1,parseInt(e.get("page")||"1",10)||1),o=e.get("q")||"",l=e.get("sort")||"newest",c=e.get("decision")||"",d=(0,s.useMemo)(()=>c.split(",").map(e=>e.trim()).filter(Boolean),[c]),u=e.get("has_pack")||"any",m=e.get("from")||"",p=e.get("to")||"",[h,f]=(0,s.useState)(n),[x,v]=(0,s.useState)(a),[g,y]=(0,s.useState)(o);(0,s.useEffect)(()=>{f(e=>e===n?e:n)},[n]),(0,s.useEffect)(()=>{v(e=>e===a?e:a)},[a]),(0,s.useEffect)(()=>{y(e=>e===o?e:o)},[o]);const b=(0,s.useCallback)(function(e){let{resetPage:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t(t=>{const a=new URLSearchParams(t);return Object.entries(e).forEach(e=>{let[t,n]=e;null===n||void 0===n||""===n?a.delete(t):a.set(t,String(n))}),n&&a.delete("page"),a},{replace:!1})},[t]);(0,s.useEffect)(()=>{const e=setTimeout(()=>{const e=h.trim();e!==n&&b({company:e||null},{resetPage:!0})},350);return()=>clearTimeout(e)},[h,n,b]),(0,s.useEffect)(()=>{const e=setTimeout(()=>{const e=x.trim();e!==a&&b({location:e||null},{resetPage:!0})},350);return()=>clearTimeout(e)},[x,a,b]),(0,s.useEffect)(()=>{const e=setTimeout(()=>{const e=g.trim();e!==o&&b({q:e||null},{resetPage:!0})},350);return()=>clearTimeout(e)},[g,o,b]);const[w,j]=(0,s.useState)(()=>{try{return"1"===localStorage.getItem("ndor.jobs.usePreferences")}catch(e){return!1}}),k=(0,s.useCallback)(e=>{j(e);try{localStorage.setItem("ndor.jobs.usePreferences",e?"1":"0")}catch(t){}},[]),[N,_]=(0,s.useState)([]),[D,C]=(0,s.useState)({}
2),[A,S]=(0,s.useState)(!0),[E,F]=(0,s.useState)(0),[R,I]=(0,s.useState)(null),[T,P]=(0,s.useState)(!1),[O,B]=(0,s.useState)(!1),[L,M]=(0,s.useState)(null),[z,U]=(0,s.useState)(null),V=(0,s.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,zt.n)("/api/jobs/analyze-fit/usage"),(0,zt.n)("/api/account/plan").catch(()=>null)]);M(e||null),U(t||null)}catch(e){}},[]);(0,s.useEffect)(()=>{V()},[V]);const q=(0,s.useMemo)(()=>{const e=new URLSearchParams;return e.set("page",String(i)),e.set("page_size",String(25)),n&&e.set("company",n),a&&e.set("location",a),o&&e.set("q",o),r&&"any"!==r&&e.set("source_kind",r),l&&"newest"!==l&&e.set("sort",l),d.length>0&&e.set("decision",d.join(",")),w&&e.set("use_preferences","true"),e.toString()},[i,n,a,o,r,l,d,w]),W=(0,s.useCallback)(async()=>{const e=lw(q),t=rw();ew(e,18e4).hit||S(!0);try{var n;const[a,r]=await Promise.all([tw(e,()=>(0,zt.n)("/api/jobs?".concat(q)),{ttlMs:18e4}),tw(t,()=>(0,zt.n)("/api/application-packs").catch(()=>[]),{ttlMs:18e4})]),s=Array.isArray(a)?a:(null===a||void 0===a?void 0:a.items)||[];_(s),F(null!==(n=null===a||void 0===a?void 0:a.total)&&void 0!==n?n:s.length),I(a&&Object.prototype.hasOwnProperty.call(a,"unfiltered_total")?a.unfiltered_total:null),P(Boolean(null===a||void 0===a?void 0:a.has_next)),B(Boolean(null===a||void 0===a?void 0:a.has_prev));const i=Array.isArray(r)?r:(null===r||void 0===r?void 0:r.items)||[],o={};for(const e of i)null!==e&&void 0!==e&&e.job_id&&!o[e.job_id]&&(o[e.job_id]=e);C(o)}catch(a){_([]),F(0),P(!1),B(!1)}finally{S(!1)}},[q]);(0,s.useEffect)(()=>{W(),V()},[W,V]);const H=(0,s.useMemo)(()=>{if(!m)return null;const e=new Date(m+"T00:00:00Z");return Number.isNaN(e.getTime())?null:e.getTime()},[m]),G=(0,s.useMemo)(()=>{if(!p)return null;const e=new Date(p+"T23:59:59Z");return Number.isNaN(e.getTime())?null:e.getTime()},[p]),K=(0,s.useMemo)(()=>{const e=d.includes("reject");return N.filter(t=>{var n;if("yes"===u&&!D[t.id])return!1;if("no"===u&&D[t.id])return!1;if(H||G){const e=t.created_at?new Date(t.created_at).getTime():null;if(!e||Number.isNaN(e))return!1;if(H&&e<H)return!1;if(G&&e>G)return!1}return!(!e&&"reject"===(null===t||void 0===t||null===(n=t.user_score)||void 0===n?void 0:n.final_decision))})},[N,D,u,H,G,d]),Y=(0,s.useMemo)(()=>K.filter(e=>!!e.user_score&&!D[e.id]),[K,D]),J=Boolean(n||a||o||r&&"any"!==r||l&&"newest"!==l||d.length>0||u&&"any"!==u||m||p),$=Boolean(n||r&&"any"!==r||u&&"any"!==u||m||p),[X,Q]=(0,s.use
2State)($);(0,s.useEffect)(()=>{$&&Q(!0)},[$]);const Z=0===E?0:25*(i-1)+1,ee=0===E?0:Math.min(25*i,E);return(0,Xt.jsxs)("div",{"data-testid":"jobs-page",className:"space-y-6 min-w-0 max-w-full overflow-x-hidden",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h2",{className:"text-2xl font-semibold tracking-tight text-ndor-ink font-outfit",children:"Jobs"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-1 font-manrope","data-testid":"jobs-total-count",children:E>0?"".concat(E.toLocaleString()," job").concat(1===E?"":"s").concat(J?" matching filters":" tracked"):J?"No jobs match these filters.":"Add jobs to start analysing your fit."})]}),(0,Xt.jsx)(nj,{onJobAdded:()=>{nw(["jobs","application-packs:all"]),b({},{resetPage:!0}),W()}})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-3 py-2 rounded border border-ndor-edge bg-ndor-surface-alt/40","data-testid":"jobs-preferences-bar",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,Xt.jsx)(vk,{id:"jobs-use-preferences",checked:w,onCheckedChange:k,"data-testid":"jobs-use-preferences-toggle"}),(0,Xt.jsx)("label",{htmlFor:"jobs-use-preferences",className:"text-sm text-ndor-ink cursor-pointer select-none",children:w?"Filtered by your preferences":"Showing all jobs"}),w&&(0,Xt.jsx)("span",{className:"text-xs text-ndor-ink-muted","data-testid":"jobs-preference-filter-note",children:"number"===typeof R?"Filtering by your preferences \u2014 showing ".concat(E.toLocaleString()," of ").concat(R.toLocaleString()," jobs."):"Filtering by your preferences"}),(()=>{if(z&&("focus"===z.plan_code||"flow"===z.plan_code)&&"active"===z.status){const e=Math.max(0,z.included_usage_remaining||0),t=Math.max(0,z.extra_usage_remaining||0);return(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-muted font-mono-ui tabular-nums","data-testid":"jobs-included-usage",title:"Included Credits remaining this cycle. Re-opening an already analysed job doesn't count.",children:["Included Credits remaining: ",e,t>0?" (+".concat(t," extra)"):""]})}if(L){const e=Math.max(0,L.limit||0),t=Math.min(Math.max(0,L.used||0),e);return(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-muted font-mono-ui tabular-nums","data-testid":"jobs-analyze-fit-usage",title:"New jobs you've analysed today. Re-opening an already analysed job doesn't count.",children:["Free analyses used: ",t," / ",e]})}return null})()]}),(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",size:"sm","data-testid":"jobs-open-preferences",children:(0,Xt.jsx)(Et,{to:"/account?tab=preferences",children:"Manage preferences in Account \u2192 Preferences"})})]}),(0,Xt.jsx)(rj,{}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"jobs-filter-bar",children:(0,Xt.jsxs)(Py,{className:"p-3 sm:p-4 space-y-3",children:[(0,Xt.jsxs)("div",{"data-testid":"jobs-filter-primary-row",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",htmlFor:"jobs-filter-title",children:"Search title"}),(0,Xt.jsx)(Ag,{id:"jobs-filter-title","data-testid":"jobs-filter-title",placeholder:"e.g. Senior Engineer",value:g,onChange:e=>y(e.target.value),className:"mt-1"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",htmlFor:"jobs-filter-location",children:"Location"}),(0,Xt.jsx)(Ag,{id:"jobs-filter-location","data-testid":"jobs-filter-location",placeholder:"e.g. Dublin",value:x,onChange:e=>v(e.target.value),className:"mt-1"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",htmlFor:"jobs-filter-sort",children:"Sort by"}),(0,Xt.jsxs)(Vv,{value:l,onValueChange:e=>b({sort:"newest"===e?null:e},{resetPage:!0}),children:[(0,Xt.jsx)(Wv,{id:"jobs-filter-sort","data-testid":"jobs-filter-sort",className:"mt-1",children:(0,Xt.jsx)(qv,{placeholder:"Newest"})}),(0,Xt.jsxs)(Kv,{children:[(0,Xt.jsx)(Yv,{value:"newest","data-testid":"jobs-filter-sort-newest",children:"Newest first"}),(0,Xt.jsx)(Yv,{value:"oldest","data-testid":"jobs-filter-sort-oldest",children:"Oldest first"}),(0,Xt.jsx)(Yv,{value:"fit_desc","data-testid":"jobs-filter-sort-fit-desc",children:"Fit: high to low"}),(0,Xt.jsx)(Yv,{value:"fit_asc","data-testid":"jobs-filter-sort-fit-asc",children:"Fit: low to high"}),(0,Xt.jsx)(Yv,{value:"company_asc","data-testid":"jobs-filter-sort-company-asc",children:"Company A\u2192Z"}),(0,Xt.jsx)(Yv,{value:"company_desc","data-testid":"jobs-filter-sort-company-desc",children:"Company Z\u2192A"})]})]})]})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2","data-testid":"jobs-filter-disclosure-row",children:[(0,Xt.jsxs)("button",{type:"button",onClick:()=>Q(e=>!e),"data-testid":"jobs-filter-more-toggle","aria-expanded":X,"aria-controls":"jobs-filter-more-panel",className:"inline-flex items-center gap-1.5 text-xs text-ndor-ink-secondary hover:text-ndor-ink transition-colors focus:outline-none focus-visible:ring-1 focus-visible:ring-ndor-edge rounded px-1 py-0.5",children:[(0,Xt.jsx)(Gn,{className:"h-3.5 w-3.5 transition-transform ".concat(X?"rotate-180":"")}),X?"Hide filters":"More filters",!X&&$&&(0,Xt.jsx)("span",{className:"ml-1 inline-flex items-center rounded-full bg-ndor-info-light px-1.5 py-0 text-[10px] font-medium text-ndor-info","data-testid":"jobs-filter-more-active-badge",children:"Active"})]}),J&&(0,Xt.jsxs)(Rr,{variant:"ghost",size:"sm",onClick:()=>{t(new URLSearchParams)},"data-testid":"jobs-filter-clear",className:"text-ndor-ink-muted shrink-0",children:[(0,Xt.jsx)(xh,{className:"h-3.5 w-3.5 mr-1"})," Clear filters"]})]}),X&&(0,Xt.jsxs)("div",{id:"jobs-filter-more-panel","data-testid":"jobs-filter-more-panel",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5 ga
2p-3 pt-3 border-t border-ndor-edge",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",htmlFor:"jobs-filter-company",children:"Company"}),(0,Xt.jsx)(Ag,{id:"jobs-filter-company","data-testid":"jobs-filter-company",placeholder:"e.g. Stripe",value:h,onChange:e=>f(e.target.value),className:"mt-1"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",htmlFor:"jobs-filter-kind",children:"Source"}),(0,Xt.jsxs)(Vv,{value:r,onValueChange:e=>b({source_kind:"any"===e?null:e},{resetPage:!0}),children:[(0,Xt.jsx)(Wv,{id:"jobs-filter-kind","data-testid":"jobs-filter-source-kind",className:"mt-1",children:(0,Xt.jsx)(qv,{placeholder:"Any"})}),(0,Xt.jsxs)(Kv,{children:[(0,Xt.jsx)(Yv,{value:"any","data-testid":"jobs-filter-source-any",children:"Any source"}),(0,Xt.jsx)(Yv,{value:"platform","data-testid":"jobs-filter-source-platform",children:"Platform (public)"}),(0,Xt.jsx)(Yv,{value:"user_import","data-testid":"jobs-filter-source-user",children:"My imports"})]})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",htmlFor:"jobs-filter-has-pack",children:"Pack"}),(0,Xt.jsxs)(Vv,{value:u,onValueChange:e=>b({has_pack:"any"===e?null:e},{resetPage:!0}),children:[(0,Xt.jsx)(Wv,{id:"jobs-filter-has-pack","data-testid":"jobs-filter-has-pack",className:"mt-1",children:(0,Xt.jsx)(qv,{placeholder:"Any"})}),(0,Xt.jsxs)(Kv,{children:[(0,Xt.jsx)(Yv,{value:"any","data-testid":"jobs-filter-has-pack-any",children:"Any"}),(0,Xt.jsx)(Yv,{value:"yes","data-testid":"jobs-filter-has-pack-yes",children:"Has pack"}),(0,Xt.jsx)(Yv,{value:"no","data-testid":"jobs-filter-has-pack-no",children:"No pack yet"})]})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",htmlFor:"jobs-filter-from",children:"From"}),(0,Xt.jsx)(Ag,{id:"jobs-filter-from",type:"date",value:m,onChange:e=>b({from:e.target.value||null},{resetPage:!0}),"data-testid":"jobs-filter-from",className:"mt-1"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",htmlFor:"jobs-filter-to",children:"To"}),(0,Xt.jsx)(Ag,{id:"jobs-filter-to",type:"date",value:p,onChange:e=>b({to:e.target.value||null},{resetPage:!0}),"data-testid":"jobs-filter-to",className:"mt-1"})]})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1","data-testid":"jobs-filter-decision-chips",children:[(0,Xt.jsx)("span",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted mr-1",children:"Decision"}),[{key:"shortlist",label:"Shortlist"},{key:"apply_with_repositioning",label:"Tailor"},{key:"hold",label:"Hold"},{key:"reject",label:"Reject"},{key:"unanalysed",label:"Unanalysed"}].map(e=>{const t=d.includes(e.key);return(0,Xt.jsx)("button",{type:"button",onClick:()=>{const n=t?d.filter(t=>t!==e.key):[...d,e.key];b({decision:n.length>0?n.join(","):null},{resetPage:!0})},"data-testid":"jobs-filter-decision-".concat(e.key),"data-active":t?"true":"false","aria-pressed":t,className:"px-2.5 py-1 rounded-full border text-xs font-medium transition-colors "+(t?"bg-ndor-ink text-ndor-surface border-ndor-ink":"bg-ndor-surface text-ndor-ink-secondary border-ndor-edge hover:border-ndor-ink/40 hover:text-ndor-ink"),children:e.label},e.key)})]})]})}),A&&(0,Xt.jsx)("div",{className:"flex items-center justify-center py-16","data-testid":"jobs-loading",children:(0,Xt.jsx)(Lg,{className:"h-6 w-6 animate-spin text-ndor-ink-muted"})}),!A&&0===K.length&&(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm border-dashed","data-testid":"jobs-empty-state",children:(0,Xt.jsxs)(Py,{className:"p-12 text-center",children:[(0,Xt.jsx)(kn,{className:"h-10 w-10 text-ndor-ink-muted mx-auto mb-4"}),w&&!J?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink","data-testid":"jobs-empty-state-prefs-title",children:"No jobs match your preferences"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1.5 max-w-sm mx-auto",children:"Adjust your preferences or view all jobs."}),(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",className:"mt-4",onClick:()=>k(!1),"data-testid":"jobs-empty-state-show-all",children:"Show all jobs"})]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:J?"No jobs match these filters":"No jobs yet"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1.5 max-w-xs mx-auto",children:J?"Try a broader company, location, or source. Jobs with an active application pack are tracked on the Applications page.":"Add a job by pasting a link or description, then run Source CV Baseline Fit to see how well your Source CV matches before tailoring."}),!J&&(0,Xt.jsxs)("div",{className:"mt-5 mx-auto max-w-md rounded-md border border-ndor-edge bg-ndor-surface-alt/40 p-3 text-left","data-testid":"jobs-empty-state-reviewer-hint",children:[(0,Xt.jsx)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Recommended next step"}),(0,Xt.jsxs)("ol",{className:"mt-2 space-y-1.5 text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"1."}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)(Et,{to:"/documents",className:"text-ndor-info hover:underline",children:"Upload your primary CV"})," ","from your Documents page if you haven't already."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"2."}),(0,Xt.jsxs)("span",{children:["Click ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Add Job"})," above to import a role by pasting its link or description."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"3."}),(0,Xt.jsxs)("span",{children:["Run ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Analyse Fit"})," on the imported job to see how well your CV matches."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"4."}),(0,Xt.jsx)("span",{children:"Generate a tailored CV, cover letter, and apply-ready application pack."})]})]})]})]})]})}),!A&&Y.length>=2&&(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 rounded-md border border-ndor-edge bg-ndor-info-light/60 px-3 py-2","data-testid":"jobs-bulk-start-pack-cta",children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink","data-testid":"jobs-bulk-start-pack-count",children:Y.length})," ","analysed jobs on this page don't yet have an application pack. Build one now to turn analysis into an apply-ready bundle."]}),(0,Xt.jsx)(Rr,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0 border-ndor-info/30 text-ndor-info hover:bg-ndor-surface","data-testid":"jobs-bulk-start-pack-button",children:(0,Xt.jsxs)(Et,{to:"/jobs/".concat(Y[0].id,"?startPack=1"),
2children:[(0,Xt.jsx)(Rw,{className:"h-3.5 w-3.5 mr-1.5"})," Start pack on the first"]})})]}),!A&&K.length>0&&(0,Xt.jsx)("div",{className:"space-y-3","data-testid":"jobs-list",children:K.map(e=>{const t=e.user_score,n=t?gk[t.final_decision]:null,a=D[e.id],r=a?bk[a.pack_status]:null,s=e.preference_scoring,i=(o=null===s||void 0===s?void 0:s.match_label)?o.startsWith("Strong match")?"Strong match":o.startsWith("Good match")?"Good match":o.startsWith("Low relevance")?"Low relevance":null:null;var o;const l=i?yk[i]:null;return(0,Xt.jsx)(Et,{to:"/jobs/".concat(e.id),className:"block group","data-testid":"job-row-".concat(e.id),children:(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm hover:shadow-md transition-shadow",children:(0,Xt.jsx)(Py,{className:"p-4 sm:p-5",children:(0,Xt.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)("h3",{className:"text-sm font-medium text-ndor-ink group-hover:underline truncate",children:e.title||"Untitled Job"}),"user_import"===e.source_kind&&(0,Xt.jsx)("span",{className:"inline-flex items-center text-[10px] font-semibold uppercase tracking-[0.16em] px-1.5 py-0.5 rounded border border-ndor-edge bg-ndor-surface-alt/70 text-ndor-ink-secondary font-mono-ui","data-testid":"job-private-pill",title:"This job is private to your account",children:"Private"})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-1.5 text-xs text-ndor-ink-muted",children:[e.company&&(0,Xt.jsxs)("span",{className:"flex items-center gap-1",children:[(0,Xt.jsx)(Pn,{className:"h-3.5 w-3.5"})," ",e.company]}),e.location&&(0,Xt.jsxs)("span",{className:"flex items-center gap-1",children:[(0,Xt.jsx)(qw,{className:"h-3.5 w-3.5"})," ",e.location]}),e.employment_type&&(0,Xt.jsx)("span",{className:"capitalize",children:e.employment_type.replace("_"," ")}),e.seniority_level&&(0,Xt.jsx)("span",{className:"capitalize",children:e.seniority_level})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap min-w-0 sm:justify-end sm:shrink-0",children:[(()=>{const t=!!D[e.id],n=!!e.user_score;return t?null:n?(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold uppercase tracking-[0.16em] px-1.5 py-0.5 rounded border border-ndor-success/20 bg-ndor-success-light text-ndor-success font-mono-ui","data-testid":"job-row-stage-analysed-".concat(e.id),title:"Source CV analysed for this role",children:[(0,Xt.jsx)(Kn,{className:"h-3 w-3"})," Analysed"]}):(0,Xt.jsx)("span",{className:"inline-flex items-center gap-1 text-[10px] font-semibold uppercase tracking-[0.16em] px-1.5 py-0.5 rounded border border-ndor-edge bg-ndor-surface-alt/70 text-ndor-ink-muted font-mono-ui","data-testid":"job-row-stage-unanalysed-".concat(e.id),children:"New"})})(),r&&(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] flex items-center gap-1 ".concat(r.className),"data-testid":"pack-progress-".concat(e.id),title:"Application pack: ".concat(r.label),children:[(0,Xt.jsx)(Rw,{className:"h-3 w-3"})," ",r.label]}),t?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("span",{className:"inline-flex items-baseline gap-1 px-2 py-0.5 rounded border border-ndor-edge bg-ndor-surface-alt/70 shrink-0",title:"Last analysed fit \u2014 the CV you last ran Analyse Fit with, vs this job. Application packs may show a different, pack-aware fit once a Tailored CV and cover letter are assigned.","data-testid":"job-row-fit-".concat(e.id),children:[(0,Xt.jsx)("span",{className:"text-[9px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Analysed"}),(0,Xt.jsx)("span",{className:"text-base font-semibold font-outfit text-ndor-ink tabular-nums",children:Math.round(100*(t.fit_score||0))})]}),w&&null!==(null===s||void 0===s?void 0:s.final_score)&&void 0!==(null===s||void 0===s?void 0:s.final_score)&&(0,Xt.jsxs)("span",{className:"inline-flex items-baseline gap-1 px-2 py-0.5 rounded border border-ndor-edge bg-ndor-surface shrink-0",title:"Preference-adjusted score = base ".concat(s.base_score)+" \xd7 location multiplier ".concat(s.location_multiplier),"data-testid":"job-row-match-score-".concat(e.id),children:[(0,Xt.jsx)("span",{className:"text-[9px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Match"}),(0,Xt.jsx)("span",{className:"text-base font-semibold font-outfit text-ndor-ink tabular-nums",children:Math.round(s.final_score)})]}),w&&i&&(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] ".concat(l),title:s.match_label,"data-testid":"job-row-match-label-".concat(e.id),children:s.match_label}),(0,Xt.jsx)(Jj,{preferenceScoring:s,triggerTestId:"job-row-why-".concat(e.id)})]}),n&&(0,Xt.jsx)(ek,{advice:"apply_with_repositioning"===t.final_decision?t.repositioning_advice:"shortlist"===t.final_decision?t.acceptance_reason:"reject"===t.final_decision?t.rejection_reason:"hold"===t.final_decision?t.hold_reason:null,decision:t.final_decision,confidence:t.decision_confidence,badgeLabel:n.label,className:n.className,testIdBase:"job-row-advice-".concat(e.id)})]}):(()=>{const t=z&&("focus"===z.plan_code||"flow"===z.plan_code)&&"active"===z.status,n=Number((null===z||void 0===z?void 0:z.included_usage_remaining)||0),a=Number((null===z||void 0===z?void 0:z.extra_usage_remaining)||0),r=n>0||a>0;if(t&&!r)return(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1","data-testid":"job-row-usage-exhausted-".concat(e.id),children:[(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] text-ndor-ink-muted border-ndor-edge",title:"You've used your included Credits.",children:"Credits exhausted"}),(0,Xt.jsx)(Et,{to:"/account?tab=plan",onClick:e=>e.stopPropagation(),className:"text-[10px] font-semibold text-ndor-primary hover:underline","data-testid":"job-row-add-credits-link-".concat(e.id),children:"Add Credits \u2192"})]});if(!t&&L&&0===L.remaining&&!r){const t=Math.max(1,Number(L.limit)||2);return(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1","data-testid":"job-row-limit-reached-".concat(e.id),children:[(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] text-ndor-ink-muted border-ndor-edge",title:"You've used your ".concat(t," free job analyses for today and have no top-up Credits."),children:"Daily limit reached"}),(0,Xt.jsx)(Et,{to:"/account?tab=plan",onClick:e=>e.stopPropagation(),className:"text-[10px] font-semibold text-ndor-primary hover:underline","data-testid":"job-row-upgrade-link-".concat(e.id),children:"Top up \u2192"})]})}return(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] text-ndor-ink-muted border-ndor-edge",children:[(0,Xt.jsx)(Kn,{className:"h-3 w-3 mr-1"})," Not analysed"]})})()]})]})})})},e.id)})}),!A&&N.length>0&&(O||T)&&(0,Xt.jsxs)("div",{className:"flex items-center justify-between pt-2","data-testid":"jobs-pagination",children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted font-mono-ui","data-testid":"jobs-page-state",children:["Showing ",(0,Xt.jsx)("span",{className:"tabular-nums",children:Z.toLocaleStr
2ing()}),"\u2013",(0,Xt.jsx)("span",{className:"tabular-nums",children:ee.toLocaleString()})," ","of ",(0,Xt.jsx)("span",{className:"tabular-nums",children:E.toLocaleString()})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:()=>b({page:Math.max(1,i-1)}),disabled:!O,"data-testid":"jobs-page-prev",children:[(0,Xt.jsx)(Wn,{className:"h-4 w-4 mr-1"})," Previous"]}),(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-muted font-mono-ui","data-testid":"jobs-page-indicator",children:["Page ",i]}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:()=>b({page:i+1}),disabled:!T,"data-testid":"jobs-page-next",children:["Next ",(0,Xt.jsx)(qn,{className:"h-4 w-4 ml-1"})]})]})]})]})}var jk=n(657),kk=n(266);const Nk=36e5;function _k(e,t,n,a){return e&&t&&n&&a?"ndor.run.".concat(e,".").concat(t,".").concat(n,".").concat(a):null}function Dk(e){let{actionCode:t,userId:n,jobId:a,sourceId:r,runId:s,startedAt:i,status:o,lastSeenAt:l}=e;const c=_k(t,n,a,r);if(!c||!s)return!1;const d={runId:s,startedAt:"number"===typeof i?i:Date.now(),status:o||"running",lastSeenAt:"number"===typeof l?l:Date.now(),cachedAt:Date.now()};try{return sessionStorage.setItem(c,JSON.stringify(d)),!0}catch(u){return!1}}function Ck(e){let{actionCode:t,userId:n,jobId:a,sourceId:r}=e;const s=_k(t,n,a,r);if(!s)return!1;try{return sessionStorage.removeItem(s),!0}catch(i){return!1}}function Ak(e){let{actionCode:t,userId:n,jobId:a,sourceId:r,status:s}=e;const i=function(e){let{actionCode:t,userId:n,jobId:a,sourceId:r}=e;const s=_k(t,n,a,r);if(!s)return null;try{const e=sessionStorage.getItem(s);if(!e)return null;const t=JSON.parse(e),n=Number(null===t||void 0===t?void 0:t.cachedAt)||0;return n?Date.now()-n>=Nk?null:"string"===typeof(null===t||void 0===t?void 0:t.runId)&&t.runId?t:null:null}catch(i){return null}}({actionCode:t,userId:n,jobId:a,sourceId:r});return!!i&&Dk({actionCode:t,userId:n,jobId:a,sourceId:r,runId:i.runId,startedAt:i.startedAt,status:s||i.status,lastSeenAt:Date.now()})}const Sk=[2e3,3e3,4e3,6e3,8e3];function Ek(e){return e&&"object"===typeof e&&"async_202"===e.served_via&&"string"===typeof e.run_id&&e.run_id.length>0}function Fk(e){return e&&"object"===typeof e&&"sync_200"===e.served_via&&e.result&&"object"===typeof e.result}function Rk(e,t){return new Promise((n,a)=>{var r;if(null!==t&&void 0!==t&&t.aborted)return void a(Ik());const s=setTimeout(()=>{var e;null===t||void 0===t||null===(e=t.removeEventListener)||void 0===e||e.call(t,"abort",i),n()},e);function i(){clearTimeout(s),a(Ik())}null===t||void 0===t||null===(r=t.addEventListener)||void 0===r||r.call(t,"abort",i,{once:!0})})}function Ik(){if("function"===typeof DOMException)return new DOMException("Polling aborted","AbortError");const e=new Error("Polling aborted");return e.name="AbortError",e}async function Tk(e){let{signal:t,markerScope:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=!1;const r=()=>{"undefined"!==typeof document&&"visible"===document.visibilityState&&(a=!0)};"undefined"!==typeof document&&"function"===typeof document.addEventListener&&document.addEventListener("visibilitychange",r);try{for(let i=0;i<30;i+=1){if(null!==t&&void 0!==t&&t.aborted)throw Ik();const r=Sk[Math.min(i,Sk.length-1)],o=a?0:r;if(a=!1,o>0&&await Rk(o,t),null!==t&&void 0!==t&&t.aborted)throw Ik();const l=await(0,zt.n)("/api/runs/".concat(e)),d=null===l||void 0===l?void 0:l.status;if(n&&d&&Ak((0,c.A)((0,c.A)({},n),{},{status:d})),"complete"===d||"failed"===d||"cancelled"===d){if("complete"===d)try{(0,kk.Di)()}catch(s){}return{id:l.run_id,status:l.status,result:l.result,served_via:l.served_via,error_code:l.error_code,error_detail:l.error_detail}}}const r=new Error("Fit analysis is still running after the maximum wait. Please try again in a moment.");throw r.code="POLL_TIMEOUT",r}finally{"undefined"!==typeof document&&"function"===typeof document.removeEventListener&&document.removeEventListener("visibilitychange",r)}}function Pk(e){var t,n,a,r,s,i,o,l,c,d,u,m,p,h,f;const x=e.result||{},v=x.fit_score_median,g=x.cv_sub_score_canonical,y="number"===typeof v?v/100:null,b=void 0!==x.cv_sub_score&&null!==x.cv_sub_score?x.cv_sub_score:null!==g&&void 0!==g?g:null;return{score:{id:x.job_score_id||null,fit_score:y,cv_sub_score:b,analyse_run_id:e.id||null,governance_decision:x.governance_decision||null,variance_band:x.variance_band||null,final_decision:x.final_decision||null},analysis:{fit_score:y,cv_sub_score:b,final_decision:null!==(t=x.final_decision)&&void 0!==t?t:null,salary_score:null!==(n=x.salary_score)&&void 0!==n?n:null,
2seniority_score:null!==(a=x.seniority_score)&&void 0!==a?a:null,location_score:null!==(r=x.location_score)&&void 0!==r?r:null,strategic_score:null!==(s=x.strategic_score)&&void 0!==s?s:null,risk_score:null!==(i=x.risk_score)&&void 0!==i?i:null,cv_sub_score_holistic:null!==(o=x.cv_sub_score_holistic)&&void 0!==o?o:null,cv_sub_score_strict:null!==(l=x.cv_sub_score_strict)&&void 0!==l?l:null,cv_sub_score_provisional:!!x.cv_sub_score_provisional,reasoning_summary:null!==(c=x.reasoning_summary)&&void 0!==c?c:"",key_strengths:null!==(d=x.key_strengths)&&void 0!==d?d:[],key_risks:null!==(u=x.key_risks)&&void 0!==u?u:[],score_explanation:null!==(m=x.score_explanation)&&void 0!==m?m:"",repositioning_advice:null!==(p=x.repositioning_advice)&&void 0!==p?p:"",interview_prep:null!==(h=x.interview_prep)&&void 0!==h?h:null},interview_prep:null!==(f=x.interview_prep)&&void 0!==f?f:null,billing:{cached:!1,was_free_fit:null,usage_consumed:null},_served_via:e.served_via||"poll_200"}}function Ok(e){var t,n,a,r;const s="number"===typeof(null===e||void 0===e?void 0:e.fit_score)?e.fit_score:null,i=null!=s?s/100:null,o=null!==(t=null===e||void 0===e||null===(n=e.reasoning_json)||void 0===n?void 0:n.cv_sub_score)&&void 0!==t?t:null;return{score:{id:(null===e||void 0===e?void 0:e.score_id)||null,fit_score:i,cv_sub_score:o,analyse_run_id:null,governance_decision:(null===e||void 0===e?void 0:e.final_decision)||null,variance_band:null},analysis:{fit_score:i,cv_sub_score:o},interview_prep:null!==(a=null===e||void 0===e||null===(r=e.reasoning_json)||void 0===r?void 0:r.interview_prep)&&void 0!==a?a:null,billing:{cached:!0,was_free_fit:null,usage_consumed:null},_served_via:"recovery_504"}}async function Bk(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{signal:a,onRecoveryState:r,userId:s,actionCode:i="analyse_fit"}=n;if(null!==a&&void 0!==a&&a.aborted)throw Ik();const o=Date.now(),l=(null===t||void 0===t?void 0:t.source_id)||null,d=s&&e&&l?{actionCode:i,userId:s,jobId:e,sourceId:l}:null;let u,m;try{u=await(0,zt.n)("/api/runs",{method:"POST",headers:{"X-Ndor-Dispatch-Surface":"workspace_analyse_fit_section_v1","X-Ndor-Bundle-Version":jk.A},body:{action_code:i,payload:(0,c.A)({job_id:e},t||{}),idempotency_key:null===t||void 0===t?void 0:t.idempotency_key}})}catch(pK){if("AbortError"===(null===pK||void 0===pK?void 0:pK.name))throw pK;if(!Yw(pK))throw pK;
2null===r||void 0===r||r("checking");for(let s=0;s<2;s+=1){if(null!==a&&void 0!==a&&a.aborted)throw Ik();if(await Rk(8e3,a),null!==a&&void 0!==a&&a.aborted)throw Ik();const n=await $w(e,t||{},o);if(n)return null===r||void 0===r||r("recovered"),Ok(n)}throw null===r||void 0===r||r("failed"),pK}if(Fk(u))return u.result;if(!Ek(u)){const e=new Error("Fit analysis dispatch returned an unexpected envelope shape.");throw e.code="UNEXPECTED_ENVELOPE",e}if(!function(){var e;const t=(null!==(e={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:"443",FAST_REFRESH:!0,REACT_APP_BACKEND_URL:"https://app.ndorflow.app",REACT_APP_SUPABASE_URL:"https://gxrskeymwyxkeadshzla.supabase.co",REACT_APP_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imd4cnNrZXltd3l4a2VhZHNoemxhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzU5OTEwMzIsImV4cCI6MjA5MTU2NzAzMn0.OUOJuRn9KdjSh2B3zls3Hn6cQm-zUq2fcUQZf4GRiKM",REACT_APP_STRIPE_TEST_MODE:"false",REACT_APP_WORKSPACE_MODE_ENABLED:"true",REACT_APP_EMPLOYER_SIGNUPS_ENABLED:"true"}.REACT_APP_RC_1_48_1_ASYNC)&&void 0!==e?e:"").trim().toLowerCase();return""===t||["1","true","yes","on"].includes(t)}()){const e=new Error("Fit analysis is still running. Async polling is disabled in this build.");throw e.code="ASYNC_POLLING_DISABLED",e.analyse_run_id=u.run_id,e}if(d&&Dk((0,c.A)((0,c.A)({},d),{},{runId:u.run_id,startedAt:o,status:u.status||"queued"})),null!==a&&void 0!==a&&a.aborted)throw d&&Ck(d),Ik();try{m=await Tk(u.run_id,{signal:a,markerScope:d})}catch(p){throw d&&Ck(d),p}if(d&&Ck(d),"failed"===m.status||"cancelled"===m.status){const e=new Error(m.error_detail||m.error_code||"Fit analysis did not complete.");throw e.code=m.error_code||"ANALYSE_RUN_FAILED",e.analyse_run_id=m.id,e.status=m.status,e}return Pk(m)}const Lk=new Set(["complete","failed","aborted"]),Mk=new Set(["dispatching","polling","recovering","recoverable_stall","stabilizing"]);function zk(e,t){let{targetKind:n,targetId:a,actionCode:r}=t;if(!e)return null;const s=[...Array.isArray(e.active)?e.active:[],...Array.isArray(e.recent)?e.recent:[]];let i=null;for(const o of s)o.target_kind===n&&o.target_id===a&&o.action_code===r&&(!i||(o.dispatched_at||"")>(i.dispatched_at||""))&&(i=o);return i}function Uk(e){let{targetKind:t,targetId:n,actionCode:a,enabled:r=!0,apiFetch:i,onTerminal:o,onRecovering:l,onNone:c,onError:d}=e;
2const[u,m]=(0,s.useState)("idle"),[p,h]=(0,s.useState)(null),f=(0,s.useRef)(!1),x=(0,s.useRef)(null),v=(0,s.useRef)({onTerminal:o,onRecovering:l,onNone:c,onError:d});v.current={onTerminal:o,onRecovering:l,onNone:c,onError:d};const g=(0,s.useCallback)(async()=>{if(r&&t&&n&&a){var e,s;if("function"!==typeof i)return m("none"),void(null===(e=(s=v.current).onNone)||void 0===e||e.call(s));m("reconciling");try{const e=await i("/api/operations/me/active",{method:"GET"});if(f.current)return;const r=zk(e,{targetKind:t,targetId:n,actionCode:a});var o,l,c,d;if(!r)return h(null),m("none"),void(null===(o=(l=v.current).onNone)||void 0===o||o.call(l));if(h(r),Lk.has(r.status))m("terminal"),null===(c=(d=v.current).onTerminal)||void 0===c||c.call(d,r);else if(Mk.has(r.status)){var u,p;m("recovering"),null===(u=(p=v.current).onRecovering)||void 0===u||u.call(p,r)}else{var x,g;m("none"),null===(x=(g=v.current).onNone)||void 0===x||x.call(g)}}catch(pK){var y,b;if(f.current)return;m("error"),null===(y=(b=v.current).onError)||void 0===y||y.call(b,pK)}}},[r,t,n,a,i]);(0,s.useEffect)(()=>(f.current=!1,g(),()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)}),[g]),(0,s.useEffect)(()=>{if(!r)return;const e=()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,g()},200)},t=()=>{"undefined"===typeof document||document.hidden||e()},n=()=>e();return"undefined"!==typeof document&&document.addEventListener("visibilitychange",t),"undefined"!==typeof window&&window.addEventListener("focus",n),()=>{"undefined"!==typeof document&&document.removeEventListener("visibilitychange",t),"undefined"!==typeof window&&window.removeEventListener("focus",n)}},[r,g]);return(0,s.useMemo)(()=>({status:u,operation:p,refetch:g}),[u,p,g])}const Vk="ndor_action_cooldowns_v1";function qk(e,t){return"cv_variant::".concat(e||"anon","::").concat(t||"unknown")}function Wk(e,t,n){return"analyse_fit::".concat(e||"anon","::").concat(t||"unknown","::").concat(n||"no_source")}function Hk(e,t,n){return"interview_prep::".concat(e||"anon","::").concat(t||"unknown","::").concat(n||"no_source")}const Gk=()=>{try{if("undefined"===typeof sessionStorage)return{};const e=sessionStorage.getItem(Vk);if(!e)return{};const t=JSON.parse(e);return t&&"object"===typeof t?t:{}}catch(e){return{}}},Kk=e=>{try{if("undefined"===typeof sessionStorage)return;sessionStorage.setItem(Vk,JSON.stringify(e))}catch(t){}};function Yk(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e5;if(!e)return;const n=Gk();n[e]={until:Date.now()+Math.max(0,Number(t)||0)},Kk(n)}function Jk(e){if(!e)return null;const t=Gk(),n=t[e];if(!n||"number"!==typeof n.until)return null;const a=n.until-Date.now();return a<=0?(delete t[e],Kk(t),null):{until:n.until,remainingMs:a}}function $k(e){const t=Math.max(0,Number(e)||0),n=Math.ceil(t/1e3),a=String(Math.floor(n/60)).padStart(2,"0"),r=String(n%60).padStart(2,"0");return"".concat(a,":").concat(r)}function Xk(e){const t=Jk(e),[n,a]=(0,s.useState)(t);return(0,s.useEffect)(()=>{if(!e)return;let t=!1;const n=()=>
2{if(t)return;const n=Jk(e);a(n)};n();const r=setInterval(n,1e3);return()=>{t=!0,clearInterval(r)}},[e]),n?{active:!0,remainingMs:n.remainingMs,label:$k(n.remainingMs)}:{active:!1,remainingMs:0,label:""}}const Qk=3e5;function Zk(e,t){return"inflight-analyze-fit:".concat(e||"anon",":").concat(t)}function eN(e,t){if("undefined"===typeof window)return null;if(!t)return null;try{const n=window.localStorage.getItem(Zk(e,t));if(!n)return null;const a=JSON.parse(n);if(!a||"object"!==typeof a)return null;const{startedAtMs:r,jobId:s}=a;return s!==t||"number"!==typeof r?null:{startedAtMs:r,jobId:s}}catch(n){return null}}function tN(e,t){if("undefined"!==typeof window&&t)try{window.localStorage.removeItem(Zk(e,t))}catch(n){}}function nN(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Qk;const a=eN(e,t,n);return!!a&&Date.now()-a.startedAtMs<n}const aN=6e5;function rN(e,t,n){return"".concat("ndor-idemp",":").concat(n,":").concat(e||"anon",":").concat(t||"")}function sN(){try{if("undefined"!==typeof crypto&&"function"===typeof crypto.randomUUID)return crypto.randomUUID()}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function iN(e,t,n){if(!n)return sN();const a=rN(e,t,n);try{const e=sessionStorage.getItem(a);if(e){const t=JSON.parse(e);if(t&&"object"===typeof t&&"string"===typeof t.key&&t.key.length>0&&"number"===typeof t.mintedAtMs&&Date.now()-t.mintedAtMs<aN)return t.key}}catch(s){}const r=sN();try{sessionStorage.setItem(a,JSON.stringify({key:r,mintedAtMs:Date.now()}))}catch(i){}return r}function oN(e,t,n){if(n)try{sessionStorage.removeItem(rN(e,t,n))}catch(a){}}function lN(e,t,n){if(!n)return null;try{const a=sessionStorage.getItem(rN(e,t,n));if(!a)return null;const r=JSON.parse(a);return(null===r||void 0===r?void 0:r.key)||null}catch(a){return null}}const cN=aN;function dN(e,t,n){return"".concat("ndor-gensession",":").concat(n,":").concat(e||"anon",":").concat(t||"")}function uN(e,t,n){try{const a=sessionStorage.getItem(dN(e,t,n));if(!a)return null;const r=JSON.parse(a);return r&&"object"===typeof r?"string"!==typeof r.idempotencyKey||"number"!==typeof r.mintedAtMs?null:r:null}catch(a){return null}}function mN(e,t,n,a){try{sessionStorage.setItem(dN(e,t,n),JSON.stringify(a))}catch(r){}}function pN(e,t,n){if(!n)return null;const a=uN(e,t,n);if(!a)return null;return Date.now()-a.mintedAtMs>=cN?null:a}function hN(e,t,n){const a=pN(e,t,n);if(a)return a;const r={idempotencyKey:iN(e,t,n),mintedAtMs:Date.now(),terminalSuccess:!1,terminalAtMs:null,hydrationStable:!1,hydrationStableAt:null};return mN(e,t,n,r),r}function fN(e,t,n){const a=uN(e,t,n);a&&(a.terminalSuccess=!0,a.terminalAtMs=Date.now(),mN(e,t,n,a))}function xN(e,t,n){const a=uN(e,t,n);a&&(a.hydrationStable=!0,a.hydrationStableAt=Date.now(),mN(e,t,n,a))}function vN(e,t,n){if(n){oN(e,t,n);try{sessionStorage.removeItem(dN(e,t,n))}catch(a){}}}function gN(e,t,n){const a=uN(e,t,n);return!!(a&&a.terminalSuccess&&a.terminalAtMs)&&Date.now()-a.terminalAtMs<3e4}function yN(e,t,n){const a=uN(e,t,n);return!a||!(!a.hydrationStable&&gN(e,t,n))&&(vN(e,t,n),!0)}const bN=250;function wN(e){let{enabled:t,fetchAndBind:n,debounceMs:a=bN,runOnMount:r=!1}=e;const i=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(!t)return;if("function"!==typeof n)return;let e=!1,s=null;async function o(){if(!e&&!i.current&&("undefined"===typeof document||"visible"===document.visibilityState)){i.current=!0;try{await n()}catch(t){}finally{i.current=!1}}}function l(){e||(s&&clearTimeout(s),s=setTimeout(o,a))}function c(){"undefined"!==typeof document&&"visible"===document.visibilityState&&l()}function d(){l()}return document.addEventListener("visibilitychange",c),window.addEventListener("popstate",d),r&&l(),()=>{e=!0,s&&clearTimeout(s),document.removeEventListener("visibilitychange",c),window.removeEventListener("popstate",d)}},[t,n,a,r])}const jN=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return String(e).padStart(t,"0")};function kN(e){const t=(String(null==e?"":e).trim()||"Untitled").slice(0,120);return"".concat(t," \u2014 ").concat(function(e){const t=e instanceof Date?e:new Date;return"".concat(t.getFullYear(),"-").concat(jN(t.getMonth()+1),"-").concat(jN(t.getDate()))+" ".concat(jN(t.getHours()),":").concat(jN(t.getMinutes()),":").concat(jN(t.getSeconds()))+".".concat(jN(t.getMilliseconds(),3))}()," \u2014 ").concat(function(){let e=0,t=0;try{if("undefined"!==typeof crypto&&"function"===typeof crypto.getRandomValues){const n=new Uint8Array(2);crypto.getRandomValues(n),e=n[0],t=n[1]}
2else e=Math.floor(256*Math.random()),t=Math.floor(256*Math.random())}catch(n){e=Math.floor(256*Math.random()),t=Math.floor(256*Math.random())}return"".concat(jN(e.toString(16),2)).concat(jN(t.toString(16),2)).toUpperCase()}())}function NN(){let{role:e,suffix:t=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=String(null==e?"":e).trim().slice(0,80)||"Tailored",a=null==t?"":String(t);return kN("".concat(n," CV").concat(a))}function _N(){let{company:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=String(null==e?"":e).trim().slice(0,80)||"Company";return kN("".concat(t," Cover Letter"))}function DN(){return kN("Application Pack")}function CN(e){return"".concat("ndor-wizard:").concat(e)}function AN(e){if(!e)return null;try{const t=sessionStorage.getItem(CN(e));if(!t)return null;const n=JSON.parse(t);return 1!==(null===n||void 0===n?void 0:n.v)?null:n}catch(t){return null}}function SN(e){if(e)try{sessionStorage.removeItem(CN(e))}catch(t){}}function EN(e){return"".concat("ndor-wizard-open:").concat(e)}const FN="workspace:ack:shown";function RN(){if("undefined"===typeof window)return!1;try{return"1"===window.sessionStorage.getItem(FN)}catch(e){return!1}}function IN(){const e=ke(),[t,n]=(0,s.useState)(!1),[a,r]=(0,s.useState)(null),[i,o]=(0,s.useState)(null),l=(0,s.useCallback)(t=>{t&&(RN()?e(t):(r(t),o(null),n(!0)))},[e]);return{guardedNavigate:l,guardedAction:(0,s.useCallback)(e=>{"function"===typeof e&&(RN()?e():(o(()=>e),r(null),n(!0)))},[]),dialogProps:{open:t,onConfirm:(0,s.useCallback)(()=>{!function(){if("undefined"!==typeof window)try{window.sessionStorage.setItem(FN,"1")}catch(e){}}(),n(!1);const t=a,s=i;r(null),o(null),t?e(t):s&&s()},[e,a,i]),onCancel:(0,s.useCallback)(()=>{n(!1),r(null),o(null)},[])}}}function TN(e){let{open:t,onConfirm:n,onCancel:a,intent:r="workspace"}=e;const s="analyse_fit"===r;return(0,Xt.jsx)(rg,{open:t,onOpenChange:e=>{e||a()},children:(0,Xt.jsxs)(lg,{"data-testid":"workspace-ack-dialog","data-intent":r,className:"sm:max-w-lg",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"workspace-ack-title",children:"Workspace Session Guidance"}),(0,Xt.jsx)(mg,{"data-testid":"workspace-ack-description",className:"pt-1",children:"A few quick notes so your session runs smoothly."})]}),s?(0,Xt.jsxs)("div",{className:"space-y-3 text-sm text-ndor-ink-muted leading-relaxed","data-testid":"workspace-ack-body","data-variant":"analyse_fit",children:[(0,Xt.jsx)("p",{"data-testid":"workspace-ack-af-body-line-1",children:"Analyse Fit may take a short time to complete."}),(0,Xt.jsx)("p",{"data-testid":"workspace-ack-af-body-line-2",children:"You may switch tabs, move to other windows, or navigate within the platform while analysis is running."}),(0,Xt.jsx)("p",{"data-testid":"workspace-ack-af-body-line-3",children:"Please avoid refreshing the page while analysis is still in progress."}),(0,Xt.jsx)("p",{"data-testid":"workspace-ack-af-body-line-4",children:"Once analysis completes, refreshing or revisiting the page is safe and results will reconnect automatically."})]}):(0,Xt.jsxs)("div",{className:"space-y-3 text-sm text-ndor-ink-muted leading-relaxed","data-testid":"workspace-ack-body","data-variant":"workspace",children:[(0,Xt.jsx)("p",{"data-testid":"workspace-ack-body-line-1",children:"You may switch tabs or move between workspace sections safely while generation is running."}),(0,Xt.jsx)("p",{"data-testid":"workspace-ack-body-line-2",children:"Please do not refresh or close this page until generation fully completes."}),(0,Xt.jsx)("p",{"data-testid":"workspace-ack-body-line-3",children:"If generation appears complete but results do not immediately appear, move to another workspace tab/section and return before attempting another run. A short refresh delay may occur while results reconnect."})]}),(0,Xt.jsxs)(dg,{className:"flex flex-col-reverse gap-2 pt-2 sm:flex-row sm:items-center sm:justify-end sm:gap-3",children:[(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:a,"data-testid":"workspace-ack-cancel-button",className:"w-full sm:w-auto",children:"Cancel"}),(0,Xt.jsx)(Rr,{variant:"default",size:"sm",onClick:n,"data-testid":"workspace-ack-confirm-button",className:"w-full sm:w-auto",children:"Continue"})]})]})})}function PN(e){if(null==e)return"\u2026";const t=Number(e);return Number.isFinite(t)?0===t?"Included with your plan":"".concat(t," credit").concat(1===t?"":"s"):"\u2026"}function ON(e){let{jobId:t,onCancel:n,rootTestId:a="apply-entry-card"}=e;ke();const{usageCosts:r}=If(),{guardedNavigate:s,dialogProps:i}=IN();return(0,Xt.jsxs)("section",{"data-testid":a,className:"rounded-xl border border-ndor-line bg-ndor-surface-alt p-5 sm:p-6 space-y-5","aria-labelledby":"apply-entry-card-heading",children:[(0,Xt.jsxs)("header",{className:"space-y-1.5",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.16em] text-ndor-ink-muted font-medium","data-testid":"apply-entry-eyebrow",children:"Application workspace"}),(0,Xt.jsx)("h2",{id:"apply-entry-card-heading",className:"text-lg font-semibold text-ndor-ink",children:"What to expect"})]}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-muted leading-relaxed","data-testid":"apply-entry-intro",children:["The workspace is a live session for tailoring your CV, drafting a cover letter, preparing for interview, and assembling an Application Pack. Each step is optional and runs only when"," ",(0,Xt.jsx)("em",{children:"you"})," click."]}),(0,Xt.jsxs)("ol",{className:"space-y-2 text-sm text-ndor-ink","data-testid":"apply-entry-steps",children:[(0,Xt.jsxs)("li",{className:"flex flex-col gap-0.5 sm:flex-row sm:items-baseline sm:justify-between sm:gap-3","data-testid":"apply-entry-cost-cv-improve",children:[(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("span",{className:"font-medium",children:"1. Tailor your CV"}),(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted",children:[" ","\u2014 rewrite your CV (also called a Resume) for this job"]})]}),(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums text-ndor-ink-muted",children:PN(null===r||void 0===r?void 0:r.cv_improve)})]}),(0,Xt.jsxs)("li",{className:"flex flex-col gap-0.5 sm:flex-row sm:items-baseline sm:justify-between sm:gap-3","data-testid":"apply-entry-cost-cover-letter",children:[(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("span",{className:"font-medium",children:"2. Cover letter"}),(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted",children:[" ","\u2014 drafted to your tone"]})]}),(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums text-ndor-ink-muted",children:PN(null===r||void 0===r?void 0:r.cover_letter)})]}),(0,Xt.jsxs)("li",{className:"flex flex-col gap-0.5 sm:flex-row sm:items-baseline sm:justify-between sm:gap-3","data-testid":"apply-entry-cost-interview-prep",children:[(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("span",{className:"font-medium",children:"3. Interview Prep"}),(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted",children:[" ","\u2014 5-bucket interview questions & guidance"]})]}),(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums text-ndor-ink-muted",children:PN(null===r||void 0===r?void 0:r.interview_prep)})]}),(0,Xt.jsxs)("li",{className:"flex flex-col gap-0.5 sm:flex-row sm:items-baseline sm:justify-between sm:gap-3","data-testid":"apply-entry-cost-application-pack",children:[(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("span",{className:"font-medium",children:"4. Ap
2plication Pack"}),(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted",children:[" ","\u2014 the bundle you submit"]})]}),(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums text-ndor-ink-muted",children:PN(null===r||void 0===r?void 0:r.application_pack)})]})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-line bg-ndor-surface px-4 py-3 space-y-1.5 text-[13px] text-ndor-ink-muted leading-relaxed","data-testid":"apply-entry-rules",children:[(0,Xt.jsxs)("p",{children:[(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium",children:"Steps you don\u2019t run are not charged."})," ","Each completed document is saved to your"," ",(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium",children:"Documents"})," ","library and stays available there."]}),(0,Xt.jsx)("p",{"data-testid":"apply-entry-session-note",children:"The workspace itself is a live session. If you leave before assembling the Application Pack, you can start a new session later \u2014 your completed CVs, cover letters and interview prep notes remain in Documents and an Application Pack can be reassembled from them."}),(0,Xt.jsxs)("p",{"data-testid":"apply-entry-cv-charge-waiver-note",children:["If your tailored CV does not improve on your Source CV\u2019s fit score, the CV tailoring charge is"," ",(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium",children:"waived automatically"})," ","\u2014 you only pay for a genuine uplift over your Source CV baseline."]})]}),(0,Xt.jsxs)("footer",{className:"flex flex-col-reverse gap-2 pt-1 sm:flex-row sm:items-center sm:justify-end sm:gap-3",children:[(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:n,"data-testid":"apply-entry-cancel-button",className:"w-full sm:w-auto",children:"Cancel"}),(0,Xt.jsx)(Rr,{variant:"default",size:"sm",onClick:()=>{s("/applications/workspace/".concat(t))},"data-testid":"apply-entry-confirm-button",className:"w-full sm:w-auto",children:"Open workspace"})]}),(0,Xt.jsx)(TN,(0,c.A)({},i))]})}function BN(e){let{action:t,className:n="",prefix:a="\xb7 ",showShortfall:r=!0}=e;const{usageCosts:s,planCode:i,includedUsageRemaining:o,extraUsageRemaining:l}=If(),c=Nf(s,t);if(null==c)return null;const d=r&&Cf({planCode:i,includedUsageRemaining:o,extraUsageRemaining:l,cost:c}),u=Df(i)?_f({includedUsageRemaining:o,extraUsageRemaining:l}):null;return(0,Xt.jsxs)("span",{className:"inline-flex items-baseline gap-1 ".concat(n),"data-testid":"price-label-".concat(t),"data-cost":c,"data-insufficient":d?"true":"false",children:[(0,Xt.jsxs)("span",{children:[a,(0,Xt.jsx)("span",{className:"font-mono-ui font-semibold",children:c})," ",(m=c,1===m?"Credit":"Credits")]}),d&&"number"===typeof u&&(0,Xt.jsxs)("span",{className:"text-ndor-warning text-[11px] font-mono-ui","data-testid":"price-label-shortfall-".concat(t),children:["(you have ",u,")"]})]});var m}function LN(e){let{className:t="",prefix:n="\xb7 ",showShortfall:a=!0}=e;const{usageCosts:r,planCode:s,includedUsageRemaining:i,extraUsageRemaining:o,freeFit:l}=If(),c=Nf(r,"analyze_fit"),d="number"===typeof(null===l||void 0===l?void 0:l.remaining)?l.remaining:null;if(null!=d&&d>0&&!Df(s))return(0,Xt.jsx)("span",{className:"inline-flex items-baseline gap-1 ".concat(t),"data-testid":"analyze-fit-cost-free","data-remaining-free":d,children:(0,Xt.jsxs)("span",{children:[n,(0,Xt.jsx)("span",{className:"text-ndor-success font-mono-ui font-semibold",children:"Free"}),(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted ml-1",children:["(",d," left today)"]})]})});if(null==c)return null;const u=a&&Cf({planCode:s,includedUsageRemaining:i,extraUsageRemaining:o,cost:c}),m=Df(s)?_f({includedUsageRemaining:i,extraUsageRemaining:o}):null;return(0,Xt.jsxs)("span",{className:"inline-flex items-baseline gap-1 ".concat(t),"data-testid":"analyze-fit-cost-paid","data-cost":c,"data-insufficient":u?"true":"false",children:[(0,Xt.jsxs)("span",{children:[n,(0,Xt.jsx)("span",{className:"font-mono-ui font-semibold",children:c})," ",1===c?"Credit":"Credits"]}),u&&"number"===typeof m&&(0,Xt.jsxs)("span",{className:"text-ndor-warning text-[11px] font-mono-ui","data-testid":"analyze-fit-cost-shortfall",children:["(you have ",m,")"]})]})}const MN=new Set(["p","div","section","article","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","br","hr"]),zN=new Set(["strong","b","em","i","u","a","span","code"]),UN=/<(\/?\s*)(p|br|h[1-6]|ul|ol|li|div|strong|b|em|i|a|span|hr|blockquote|section|article)\b/i,VN=/<\s*\/?\s*(p|br|h[1-6]|ul|ol|li|div|strong|b|em|i|a|span)\b/i;function qN(e,t){if(3===e.nodeType){const t=e.nodeValue;return t||null}if(1!==e.nodeType)return null;const n=(e.tagName||"").toLowerCase();if("script"===n||"style"===n||"noscript"===n||"iframe"===n||"object"===n||"embed"===n)return null;const a=[];
2e.childNodes.forEach((e,n)=>{const r=qN(e,"".concat(t,"-").concat(n));null!==r&&void 0!==r&&""!==r&&a.push(r)});const r=a.length>0;if("br"===n)return(0,Xt.jsx)("br",{},t);if("hr"===n)return(0,Xt.jsx)("hr",{className:"my-4 border-ndor-edge"},t);if("a"===n){const n=function(e){if(!e)return null;try{const t=String(e).trim();return t&&(/^https?:\/\//i.test(t)||t.startsWith("/")||t.startsWith("#"))?t:null}catch(t){return null}}(e.getAttribute("href"));return n?(0,Xt.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"text-ndor-primary underline underline-offset-2 hover:text-ndor-primary-hover",children:r?a:n},t):r?(0,Xt.jsx)("span",{children:a},t):null}return r?"h1"===n||"h2"===n?(0,Xt.jsx)("h3",{className:"text-base font-semibold text-ndor-ink mt-4 mb-1",children:a},t):"h3"===n||"h4"===n?(0,Xt.jsx)("h4",{className:"text-sm font-semibold text-ndor-ink mt-3 mb-1",children:a},t):"h5"===n||"h6"===n?(0,Xt.jsx)("h5",{className:"text-sm font-medium text-ndor-ink mt-2 mb-1",children:a},t):"p"===n||"div"===n||"section"===n||"article"===n?(0,Xt.jsx)("p",{className:"mb-2 leading-relaxed",children:a},t):"ul"===n?(0,Xt.jsx)("ul",{className:"list-disc pl-5 mb-2 space-y-1",children:a},t):"ol"===n?(0,Xt.jsx)("ol",{className:"list-decimal pl-5 mb-2 space-y-1",children:a},t):"li"===n?(0,Xt.jsx)("li",{className:"leading-relaxed",children:a},t):"blockquote"===n?(0,Xt.jsx)("blockquote",{className:"border-l-2 border-ndor-edge pl-3 italic text-ndor-ink-muted mb-2",children:a},t):"strong"===n||"b"===n?(0,Xt.jsx)("strong",{className:"font-semibold text-ndor-ink",children:a},t):"em"===n||"i"===n?(0,Xt.jsx)("em",{children:a},t):"u"===n?(0,Xt.jsx)("u",{children:a},t):"code"===n?(0,Xt.jsx)("code",{className:"font-mono text-[0.85em] bg-ndor-surface-alt px-1 rounded",children:a},t):zN.has(n)||MN.has(n)?(0,Xt.jsx)("span",{children:a},t):(0,Xt.jsx)(s.Fragment,{children:a},t):null}function WN(e){const t=e.replace(/\r\n?/g,"\n").split(/\n{2,}/).map(e=>e.trim()).filter(Boolean);return 0===t.length?null:t.map((e,t)=>(0,Xt.jsx)("p",{className:"mb-2 leading-relaxed whitespace-pre-wrap",children:e},"pp-".concat(t)))}function HN(e){let{text:t,className:n="",testid:a="job-detail-description"}=e;const r=(0,s.useMemo)(()=>{const e=function(e){const t=(e||"").trim();return t?VN.test(t)?"escaped_html":UN.test(t)?"html":"text":"empty"}(t);if("empty"===e)return null;let n=t;if("escaped_html"===e&&(n=function(e){if("undefined"===typeof document)return e;const t=document.createElement("textarea");return t.innerHTML=e,t.value}(t)),"html"===e||"escaped_html"===e){const e=function(e){try{const t=(new DOMParser).parseFromString("<!DOCTYPE html><body>".concat(e,"</body>"),"text/html").body;if(!t)return null;const n=[];return t.childNodes.forEach((e,t)=>{const a=qN(e,"root-".concat(t));null!==a&&void 0!==a&&""!==a&&n.push(a)}),n.length?n:null}catch(t){return null}}(n);if(e&&e.length>0)return e;return WN((n||"").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())}return WN(n)},[t]);return r?(0,Xt.jsx)("div",{className:"text-sm text-ndor-ink-secondary leading-relaxed font-manrope ".concat(n),"data-testid":a,children:r}):null}const GN=wn("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),KN=wn("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),YN=wn("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),JN=wn("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),$N=wn("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),XN=wn("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),QN=wn("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]),ZN=wn("brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]),e_=wn("trending-up",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]),t_=wn("trending-down",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);function n_(e){if(!e)return"";let t=String(e).replace(/^\W+/,"").trim();return t=t.replace(/\bweak articulating\b/gi,"weak articulation"),t=t.replace(/\barticulating of\b/gi,"articulation of"),t=t.replace(/\bin cover letter\b/gi,"in the cover letter"),t=t.replace(/\s+/g," ").trim(),t}const a_=/\s*\(?\b\d{1,3}\s*%\)?/g,r_=/\s*\(?\b\d{1,3}\s*\/\s*100\b\)?/g,s_=/\bscoring\s+(?:a\s+|an\s+)?\d{1,3}\b/gi,i_=/\b(salary|seniority|location|strategic|risk|cv\s+sub[-\s]?score|cv\s+verdict|overall\s+fit|fit\s+score)(\s+(?:score|sub[-\s]?score|fit))?\s+(?:at|of|=)\s+\d{1,3}\b/gi,o_=/ {2,}/g,l_=/ +([.,;:?!])/g,c_=/,\s*,/g,d_=/\.\s*\./g,u_=/\s+(?:at|of|=|with)\s*[.;,!?]?\s*$/i;function m_(e){if(!e||"string"!==typeof e)return"";let t=e;return t=t.replace(i_,e=>e.replace(/\s+(?:at|of|=)\s+\d{1,3}\s*$/i,"")),t=t.replace(s_,"scoring"),t=t.replace(r_,""),t=t.replace(a_,""),t=t.replace(o_," "),t=t.replace(l_,"$1"),t=t.replace(c_,","),t=t.replace(d_,"."),t=t.replace(u_,"."),t=t.trim(),t}const p_={reject:{label:"Reject",className:"bg-ndor-error-light text-ndor-error border-ndor-error/20"},hold:{label:"Hold",className:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/20"},shortlist:{label:"Shortlist",className:"bg-ndor-success-light text-ndor-success border-ndor-success/20"},apply_with_repositioning:{label:"Tailor application",className:"bg-ndor-info-light text-ndor-info border-ndor-info/20"}},h_={gaps_ge_3:e=>"Three or more significant gaps capped the overall fit at ".concat(e,"."),transition_role:e=>"Significant role transition capped the overall fit at ".concat(e,".")};function f_(e){return e>=70?"text-ndor-success":e>=45?"text-ndor-warning":"text-ndor-error"}const x_={Salary:"Salary alignment: how close the role pay band is to the candidate expectation.",Seniority:"Seniority fit: how closely the candidate level matches the role level.",Location:"Location alignment: geographic / remote compatibility.",Strategic:"Strategic fit: how central the candidate profile is to the role narrative.",Risk:"Risk: evidence gaps, red flags and application-risk factors. Lower = safer application."};function v_(e){let{icon:t,label:n,score:a}=e;const r=x_[n]||"";return(0,Xt.jsxs)("div",{className:"flex items-center gap-3",title:r,children:[(0,Xt.jsx)(t,{className:"h-4 w-4 text-ndor-ink-muted shrink-0"}),(0,Xt.jsx)("span",{className:"text-sm text-ndor-ink-secondary w-28 shrink-0",children:n}),(0,Xt.jsx)("div",{className:"flex-1 h-2 bg-ndor-surface-alt rounded-full overflow-hidden",children:(0,Xt.jsx)("div",{className:"h-full rounded-full transition-all ".concat(a>=70?"bg-ndor-success":a>=45?"bg-ndor-warning":"bg-ndor-error"),style:{width:"".concat(Math.min(a,100),"%")}})}),(0,Xt.jsx)("span",{className:"text-sm font-medium w-8 text-right ".concat(f_(a)),children:a})]})}function g_(e){let{icon:t,label:n,score:a,testid:r}=e;const s=function(e){return null==e?"text-ndor-ink-muted border-ndor-edge bg-ndor-surface-alt/50":e>=70?"text-ndor-success border-ndor-success/30 bg-ndor-success-light/40":e>=45?"text-ndor-warning border-ndor-warning/30 bg-ndor-warning-light/40":"text-ndor-error border-ndor-error/30 bg-ndor-error-light/40"}(a);return(0,Xt.jsxs)("div",{className:"flex items-center gap-2 rounded-md border px-2.5 py-1.5 ".concat(s),"data-testid":r,children:[(0,Xt.jsx)(t,{className:"h-3.5 w-3.5"}),(0,Xt.jsx)("span",{className:"text-[10px] font-mono-ui uppercase tracking-[0.14em]",children:n}),(0,Xt.jsx)("span",{className:"text-sm font-semibold tabular-nums",children:null==a?"\u2014":a})]})}function y_(e){var t,n;let{score:a,scope:r="pack"}=e;if(!a)return null;const s="job"===r,i=e=>{if(null==e)return null;const t="number"===typeof e?e:Number(e);return Number.isFinite(t)?Math.round(t>1?t:100*t):null},o=a.reasoning_json||{},l=null!==(t=null!==(n=i(o.overall_fit_score))&&void 0!==n?n:i(a.fit_score))&&void 0!==t?t:0,c=i(o.cv_sub_score),d=!0===o.cv_sub_score_provisional,u={salary_score:i(a.salary_score),seniority_score:i(a.seniority_score),location_score:i(a.location_score),strategic_score:i(a.strategic_score),risk_score:i(a.risk_score),final_decision:a.final_decision},m=p_[u.final_decision]||p_.hold,p=(o.key_strengths||[]).map(n_).filter(
2Boolean),h=(o.key_risks||[]).map(n_).filter(Boolean),f=o.reasoning_summary||"",x=m_(o.score_explanation||"").trim(),v=Array.isArray(o.bounds_applied)?o.bounds_applied:[],g=!0===o.refunded,y=function(e){let{gapCount:t,isTransition:n,boundsApplied:a}=e;const r=[],s=new Set((a||[]).map(e=>e.rule));return t>=3&&!s.has("gaps_ge_3")&&r.push("Three or more significant gaps limited the possible score range."),n&&!s.has("transition_role")&&r.push("A significant role transition constrained the achievable ceiling."),r}({gapCount:"number"===typeof o.gap_count?o.gap_count:0,isTransition:!0===o.is_transition_role,boundsApplied:v}),b=!!x||v.length>0||y.length>0||g;return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"fit-result-card",children:[(0,Xt.jsx)(Ry,{className:"pb-3",children:(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(XN,{className:"h-5 w-5 text-ndor-ink-muted"}),s?"Job-level fit":"Fit Analysis"]}),(0,Xt.jsx)(Vw,{variant:"outline",className:"".concat(m.className," font-medium"),"data-testid":"fit-decision-badge",children:m.label})]})}),(0,Xt.jsxs)(Py,{className:"space-y-6",children:[(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-4",children:[(0,Xt.jsx)("div",{className:"text-4xl font-bold font-outfit ".concat(f_(l)),"data-testid":"fit-score-value",children:l}),(0,Xt.jsx)("div",{children:(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted uppercase tracking-wide",children:"Overall Fit"})})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-2 sm:ml-auto items-center",children:[(0,Xt.jsx)(g_,{icon:Nn,label:"NDOR CV verdict",score:c,testid:"fit-sub-cv"}),d&&null!=c&&(0,Xt.jsx)("span",{className:"text-[11px] font-medium text-amber-200 dark:text-amber-300","data-testid":"cv-verdict-provisional-label",children:"Preview CV verdict \u2014 finalize to confirm"})]})]}),b&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/50 px-3 py-2.5","data-testid":"fit-score-explanation",children:[(0,Xt.jsxs)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.18em] text-ndor-gold flex items-center gap-1.5 mb-1",children:[(0,Xt.jsx)(Kn,{className:"h-3 w-3"})," Why this score"]}),x&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink leading-relaxed font-manrope",children:x}),(()=>{const e=[{label:"Salary",v:u.salary_score},{label:"Seniority",v:u.seniority_score},{label:"Location",v:u.location_score},{label:"Strategic",v:u.strategic_score},{label:"Risk",v:u.risk_score}].filter(e=>"number"===typeof e.v);if(0===e.length)return null;const t=e.reduce((e,t)=>e.v<=t.v?e:t);return t.v>=80?null:(0,Xt.jsxs)("p",{className:"mt-1.5 text-xs text-ndor-ink-secondary font-manrope","data-testid":"fit-score-largest-gap",children:["\u2022 Largest gap: ",(0,Xt.jsx)("span",{className:"font-medium",children:t.label})," \u2014 lowest assessed area."]})})(),v.length>0&&(0,Xt.jsx)("ul",{className:"mt-1.5 space-y-0.5","data-testid":"fit-score-bounds",children:v.map((e,t)=>(0,Xt.jsxs)("li",{className:"text-xs text-ndor-ink-secondary font-manrope",children:["\u2022 ",h_[e.rule]?h_[e.rule](e.cap):"Capped at ".concat(e.cap," (").concat(e.rule,").")]},t))}),y.length>0&&(0,Xt.jsx)("ul",{className:"mt-1.5 space-y-0.5","data-testid":"fit-score-transparency",children:y.map((e,t)=>(0,Xt.jsxs)("li",{className:"text-xs text-ndor-ink-muted font-manrope italic",children:["\xb7 ",e]},t))}),g&&(0,Xt.jsx)("p",{className:"mt-1.5 text-[11px] text-ndor-success font-manrope","data-testid":"fit-refund-notice",children:"Credit refunded \u2014 this variant scored below your Source CV baseline."})]}),f&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed font-manrope","data-testid":"fit-reasoning-summary",children:f}),(0,Xt.jsxs)("div",{className:"space-y-2.5",children:[(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted uppercase tracking-wide mb-1",children:"Score Breakdown"}),[{key:"salary",icon:QN,label:"Salary",v:u.salary_score},{key:"seniority",icon:kn,label:"Seniority",v:u.seniority_score},{key:"location",icon:qw,label:"Location",v:u.location_score},{key:"strategic",icon:ZN,label:"Strategic",v:u.strategic_score},{key:"risk",icon:Ln,label:"Risk",v:u.risk_score}].filter(e=>null!=e.v).map(e=>(0,Xt.jsx)(v_,{icon:e.icon,label:e.label,score:e.v},e.key))]}),(()=>{const e=[{label:"Salary",v:u.salary_score},{label:"Seniority",v:u.seniority_score},{label:"Location",v:u.location_score},{label:"Strategic",v:u.strategic_score},{label:"Risk",v:u.risk_score}].filter(e=>"number"===typeof e.v&&e.v<45);return 0===e.length?null:(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-warning/30 bg-ndor-warning-light/30 px-3 py-2.5","data-testid":"fit-low-score-callout",children:[(0,Xt.jsx)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.18em] text-ndor-warning mb-1",children:"Areas of weakness"}),(0,Xt.jsx)("ul",{className:"space-y-0.5",children:e.map(e=>{const t="Risk"===e.label;return(0,Xt.jsxs)("li",{className:"text-xs text-ndor-ink-secondary font-manrope","data-testid":"fit-low-score-".concat(e.label.toLowerCase()),children:["\u2022 ",(0,Xt.jsx)("span",{className:"font-medium",children:e.label})," ",t?(0,Xt.jsxs)(Xt.Fragment,{children:["signals evidence gaps or application risk factors (e.g. location not stated, short tenure streak, missing nice-to-haves)."," ",(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted",children:["A low Risk score does ",(0,Xt.jsx)("em",{children:"not"})," lower your overall fit \u2014 it flags things to pre-empt in the cover letter or interview."]})]}):(0,Xt.jsx)(Xt.Fragment,{children:"shows limited alignment with this role."})]},e.label)})})]})})(),(p.length>0||h.length>0)&&(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 pt-2 border-t border-ndor-edge",children:[p.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted uppercase tracking-wide mb-2 flex items-center gap-1.5",children:[(0,Xt.jsx)(e_,{className:"h-3.5 w-3.5 text-ndor-success"})," Strengths"]}),(0,Xt.jsx)("ul",{className:"space-y-1",children:p.map((e,t)=>(0,Xt.jsxs)("li",{className:"text-sm text-ndor-ink-secondary font-manrope",children:["\u2022 ",e]},t))})]}),h.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted uppercase tracking-wide mb-2 flex items-center gap-1.5",children:[(0,Xt.jsx)(t_,{className:"h-3.5 w-3.5 text-ndor-error"})," Risks"]}),(0,Xt.jsx)("ul",{className:"space-y-1",children:h.map((e,t)=>(0,Xt.jsxs)("li",{className:"text-sm text-ndor-ink-secondary font-manrope",children:["\u2022 ",e]},t))})]})]})]})]})}
2const b_=wn("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);function w_(e,t){return"".concat("inflight-cv",":").concat(e||"",":").concat(t||"")}function j_(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(t&&(n||a))try{sessionStorage.setItem(w_(e,t),JSON.stringify({submittedAtMs:Date.now(),title:n||null,variantId:a||null,startedAt:(new Date).toISOString()}))}catch(r){}}function k_(e,t){if(t)try{sessionStorage.removeItem(w_(e,t))}catch(n){}}function N_(e,t){if(!t)return null;try{const n=sessionStorage.getItem(w_(e,t));if(!n)return null;const a=JSON.parse(n);return a&&"object"===typeof a&&(a.submittedAtMs&&(a.variantId||a.title))?a:null}catch(n){return null}}function __(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();return null===e||void 0===e||!e.submittedAtMs||t-Number(e.submittedAtMs)>6e5}async function D_(e){if(!e)return null;try{const t=await(0,zt.n)("/api/cv-variants");return Array.isArray(t)&&0!==t.length&&t.find(t=>(null===t||void 0===t?void 0:t.title)===e||(null===t||void 0===t?void 0:t.variant_name)===e)||null}catch(t){return null}}function C_(e,t){return"".concat("inflight-letter",":").concat(e||"",":").concat(t||"")}function A_(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t&&n)try{sessionStorage.setItem(C_(e,t),JSON.stringify({submittedAtMs:Date.now(),title:n,runId:(null===a||void 0===a?void 0:a.runId)||null,startedAt:(new Date).toISOString()}))}catch(r){}}function S_(e,t){if(t)try{sessionStorage.removeItem(C_(e,t))}catch(n){}}function E_(e,t){if(!t)return null;try{const n=sessionStorage.getItem(C_(e,t));if(!n)return null;const a=JSON.parse(n);return a&&"object"===typeof a&&(a.title&&a.submittedAtMs)?a:null}catch(n){return null}}function F_(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();return null===e||void 0===e||!e.submittedAtMs||t-Number(e.submittedAtMs)>6e5}async function R_(e){if(!e)return null;try{const n=await(0,zt.n)("/api/cover-letters");if(!Array.isArray(n)||0===n.length)return null;const a=n.find(t=>t&&(t.title||"").trim()===e.trim());if(!a)return null;try{return await(0,zt.n)("/api/cover-letters/".concat(a.id))||a}catch(t){return a}}catch(n){return null}}function I_(e,t){return"".concat("inflight-fit",":").concat(e||"",":").concat(t||"")}function T_(e,t){if(t)try{sessionStorage.removeItem(I_(e,t))}catch(n){}}function P_(e,t){if(!t)return null;try{const a=sessionStorage.getItem(I_(e,t));if(!a)return null;const r=JSON.parse(a);if(!r||"object"!==typeof r)return null;if(!r.sourceType||!r.sourceId||!r.submittedAtMs)return null;if(Date.now()-Number(r.submittedAtMs)>6e5){try{sessionStorage.removeItem(I_(e,t))}catch(n){}return null}return r}catch(a){return null}}const O_=["Preparing your tailored CV\u2026","Analysing the job requirements\u2026","Aligning your experience\u2026","Finalising your document\u2026","Almost done\u2026"],B_={cv:O_,letter:["Drafting your letter\u2026","Matching tone and context\u2026","Preparing final wording\u2026","Almost done\u2026"],pack:["Building your application pack\u2026","Assembling documents\u2026","Preparing export assets\u2026","Finalising your pack\u2026"]};function L_(e,t){const[n,a]=(0,s.useState)(0),r=(0,s.useRef)(null);if((0,s.useEffect)(()=>e?(a(0),r.current=setInterval(()=>{a(e=>e+1)},3500),()=>{r.current&&(clearInterval(r.current),r.current=null)}):(r.current&&(clearInterval(r.current),r.current=null),void a(0)),[e]),!e)return null;const i=B_[t]||O_;return i[Math.min(n,i.length-1)]}const M_={cv:"We couldn't generate the tailored CV from this job yet. Please try again, or edit the job details.",letter:"The cover letter couldn't be completed because the job description appears incomplete.",pack:"Your application pack could not be assembled yet. Please retry in a moment."};function z_(e,t){var n,a,r,s,i;const o=(null===e||void 0===e?void 0:e.status)||(null===e||void 0===e||null===(n=e.response)||void 0===n?void 0:n.status),l=null===e||void 0===e||null===(a=e.data)||void 0===a||null===(r=a.detail)||void 0===r?void 0:r.code,c=null===e||void 0===e||null===(s=e.data)||void 0===s||null===(i=s.detail)||void 0===i?void 0:i.message,d=((null===e||void 0===e?void 0:e.message)||"").trim();if("USAGE_EXHAUSTED"===l)return null;if("FREE_DAILY_ANALYZE_LIMIT_REACHED"===l)return null;if(o>=400&&o<500&&c)return c;return!d||/^internal server error\.?$/i.test(d)||/^server error\.?$/i.test(d)||/^request failed( with status code \d+)?\.?$/i.test(d)||o>=500&&o<600?M_[t]||d||"Action failed.":d||M_[t]||"Action failed."}const U_=wn("phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]),V_=wn("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);function q_(e){const t=[];let n=0;const a=/(\*\*[^*]+\*\*)|(`[^`]+`)|(\*[^*\n]+\*|_[^_\n]+_)/g;let r,s=0;for(;null!==(r=a.exec(e));){r.index>n&&t.push(e.slice(n,r.index));const a=r[0];a.startsWith("**")?t.push((0,Xt.jsx)("strong",{children:a.slice(2,-2)},"b-".concat(s++))):a.startsWith("`")?t.push((0,Xt.jsx)("code",{className:"font-mono-ui text-[0.95em] bg-ndor-surface-alt px-1 rounded",children:a.slice(1,-1)},"c-".concat(s++))):t.push((0,Xt.jsx)("em",{children:a.slice(1,-1)},"i-".concat(s++))),n=r.index+a.length}return n<e.length&&t.push(e.slice(n)),t}function W_(e){let{text:t,className:n=""}=e;if(!t||"string"!==typeof t)return null;const a=t.replace(/\r\n?/g,"\n").split("\n"),r=[];let s=null;const i=()=>{s&&r.push(s),s=null};for(let o=0;o<a.length;o++){const e=a[o],t=e.trimEnd();if(""===t.trim()){i();continue}if(/^---+$/.test(t.trim())){i(),r.push({type:"hr"});continue}const n=/^(#{1,4})\s+(.+)$/.exec(t.trim());if(n){i(),r.push({type:"h",level:n[1].length,text:n[2]});continue}const l=/^\s*[-*\u2022]\s+(.+)$/.exec(e);l?(s&&"ul"===s.type||(i(),s={type:"ul",items:[]}),s.items.push(l[1])):(s&&"p"===s.type||(i(),s={type:"p",text:[]}),s.text.push(t.trim()))}return i(),(0,Xt.jsx)("div",{className:"space-y-3 ".concat(n),children:r.map((e,t)=>{if("hr"===e.type)return(0,Xt.jsx)("hr",{className:"border-ndor-edge"},t);if("h"===e.type){const n="h".concat(Math.min(e.level+1,4)),a=1===e.level?"text-lg font-serif-display text-ndor-ink mt-2 mb-1":2===e.level?"text-base font-medium text-ndor-ink mt-2 mb-1 uppercase tracking-[0.12em]":"text-sm font-medium text-ndor-ink mt-1 mb-0.5 uppercase tracking-[0.12em]";return(0,Xt.jsx)(n,{className:a,children:q_(e.text)},t)}return"ul"===e.type?(0,Xt.jsx)("ul",{className:"list-disc pl-5 space-y-1 text-sm text-ndor-ink leading-relaxed",children:e.items.map((e,t)=>(0,Xt.jsx)("li",{children:q_(e)},t))},t):(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink leading-relaxed",children:q_(e.text.join(" "))},t)})})}function H_(e){let{kind:t,value:n}=e;const a="email"===t?Bg:"phone"===t?U_:"location"===t?qw:V_,r="email"===t||"link"===t||"url"===t,s="email"===t?"mailto:".concat(n):r?n:null,i=(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-ndor-ink-secondary",children:[(0,Xt.jsx)(a,{className:"h-3 w-3 text-ndor-ink-muted shrink-0","aria-hidden":!0}),(0,Xt.jsx)("span",{className:"break-all",children:n})]});return s?(0,Xt.jsx)("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"hover:text-ndor-ink underline-offset-2 hover:underline",children:i}):i}function G_(e){var t;let{block:n}=e;if(!n||"object"!==typeof n)return null;switch(n.type){case"paragraph":return(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink leading-relaxed",children:n.text});case"list":return(0,Xt.jsx)("ul",{className:"".concat(n.ordered?"list-decimal":"list-disc"," pl-5 space-y-1 text-sm text-ndor-ink leading-relaxed"),children:(n.items||[]).map((e,t)=>(0,Xt.jsx)("li",{children:e},t))});case"experience_entry":return(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[n.role&&(0,Xt.jsx)("span",{className:"text-sm font-medium text-ndor-ink",children:n.role}),n.company&&(0,Xt.jsxs)("span",{className:"text-sm text-ndor-ink-secondary",children:["\u2014 ",n.company]}),n.location&&(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-muted",children:["\xb7 ",n.location]})]}),(n.start||n.end)&&(0,Xt.jsxs)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:[n.start||"?"," ",n.end?"\u2014 ".concat(n.end):""]}),(null===(t=n.bullets)||void 0===t?void 0:t.length)>0&&(0,Xt.jsx)("ul",{className:"list-disc pl-5 space-y-0.5 text-sm text-ndor-ink leading-relaxed",children:n.bullets.map((e,t)=>(0,Xt.jsx)("li",{children:e},t))})]});case"table":return(0,Xt.jsx)("div",{className:"overflow-x-auto -mx-2",children:(0,Xt.jsx)("table",{className:"w-full text-sm border-separate border-spacing-0",children:(0,Xt.jsx)("tbody",{children:(n.rows||[]).map((e,t)=>(0,Xt.jsx)("tr",{children:(e||[]).map((e,n)=>(0,Xt.jsx)("td",{className:"px-2 py-1 align-top border border-ndor-edge ".concat(0===t?"bg-ndor-surface-alt font-medium":""),children:e},n))},t))})})});default:return null}}function K_(e){let{structured:t}=e;const{header:n,sections:a}=t;return(0,Xt.jsxs)("div",{className:"space-y-5","data-testid":"cv-renderer-structured",children:[n&&(n.name||n.title||(n.contact||[]).length)&&(0,Xt.jsxs)("header",{className:"space-y-1.5 pb-3 border-b border-ndor-edge","data-testid":"cv-renderer-header",children:[n.name&&(0,Xt.jsx)("h2",{className:"text-xl sm:text-2xl font-serif-display text-ndor-ink leading-tight",children:n.name}),n.title&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary",children:n.title}),(n.contact||[]).length>0&&(0,Xt.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-1",children:(n.contact||[]).map((e,t)=>(0,Xt.jsx)(H_,{kind:e.kind,value:e.value},t))})]}),(a||[]).map((e,t)=>(0,Xt.jsxs)("section",{"data-testid":"cv-renderer-section-".concat(e.kind),className:"space-y-2",children:[(0,Xt.jsx)("h3",{className:"text-[11px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:e.heading}),(0,Xt.jsx)("div",{className:"space-y-3",children:(e.blocks||[]).map((e,t)=>(0,Xt.jsx)(G_,{block:e},t))})]},t))]})}function Y_(e){let{mode:t="source",data:n,showDisclaimer:a=!1,className:r=""}=e;if(!n||"object"!==typeof n)return(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted italic",children:"No content to display."});let s=null,i="fallback";if("source"===t){var o;const e=null===(o=n.parsed_json)||void 0===o?void 0:o.structured;e&&Array.isArray(e.sections)&&e.sections.length?(s=(0,Xt.jsx)(K_,{structured:e}),i="structured"):"string"===typeof n.parsed_text&&n.parsed_text.trim()&&(s=(0,Xt.jsx)(W_,{text:n.parsed_text}),i="markdown")}else{var l,c;const e=null!==(l=null!==(c=n.content_markdown)&&void 0!==c?c:n.generated_text)&&void 0!==l?l:"";"string"===typeof e&&e.trim()&&(s=(0,Xt.jsx)(W_,{text:e}),i="markdown")}if(!s){var d,u,m;const e="source"===t?null!==(d=n.parsed_text)&&void 0!==d?d:"":null!==(u=null!==(m=n.content_markdown)&&void 0!==m?m:n.generated_text)&&void 0!==u?u:"";s=(0,Xt.jsx)("pre",{className:"whitespace-pre-wrap text-sm text-ndor-ink leading-relaxed font-manrope","data-testid":"cv-renderer-fallback",children:e||"No content available."})}const p=a&&"source"===t&&"structured"===i;return(0,Xt.jsxs)("div",{className:"cv-renderer ".concat(r),"data-testid":"cv-renderer","data-mode":t,"data-
2path":i,children:[s,p&&(0,Xt.jsx)("p",{className:"mt-4 pt-3 border-t border-ndor-edge text-[11px] text-ndor-ink-muted italic leading-relaxed","data-testid":"cv-renderer-disclaimer",children:"Uploaded formatting may be normalized for optimal analysis and generation."})]})}const J_="Your selected CV, profile, preferences, salary, seniority, location, strategic alignment, risk and (when relevant) your cover letter. NDOR provides an application-readiness verdict beyond keyword matching.";const $_=function(e){let{variant:t="expanded",testIdSuffix:n=""}=e;const a=n?"analyse-fit-explainer-".concat(n):"analyse-fit-explainer";return"compact"===t?(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted italic leading-relaxed","data-testid":a,children:["NDOR Analyse-Fit evaluates ",J_.charAt(0).toLowerCase()+J_.slice(1)]}):(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt/30 p-3 space-y-1.5","data-testid":a,children:[(0,Xt.jsxs)("p",{className:"text-xs font-medium text-ndor-ink flex items-center gap-1.5",children:[(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5 text-ndor-gold"}),"What NDOR Analyse-Fit looks at"]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:J_}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted italic leading-relaxed",children:"Tip: a complete profile and accurate preferences materially improve result quality."})]})},X_={analyze_fit:"Analyse Fit",cv_improve:"Generate CV",cover_letter:"Generate cover letter",application_pack:"Create application pack"};function Q_(e){let{open:t,onOpenChange:n,onClose:a,planCode:r="focus",action:s=null,required:i=null,availableIncluded:o=null,availableExtra:l=null}=e;const c=ke(),d=e=>{"function"===typeof n&&n(e),e||"function"!==typeof a||a()},u="base"===r,m=u?"Daily free limit reached":"Credits exhausted",p=u?"You\u2019ve used your free analyses for today. Add extra Credits to continue now, or come back tomorrow.":"You\u2019ve used your available Credits. Add extra Credits to continue.",h=(Number.isFinite(Number(o))?Number(o):0)+(Number.isFinite(Number(l))?Number(l):0),f=Number.isFinite(Number(i))&&(null!=o||null!=l),x=X_[s]||null;return(0,Xt.jsx)(rg,{open:t,onOpenChange:d,children:(0,Xt.jsxs)(lg,{className:"sm:max-w-[460px]","data-testid":"usage-exhausted-modal","data-plan-code":r,"data-action":s||void 0,children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"usage-exhausted-modal-title",children:m}),(0,Xt.jsx)(mg,{className:"text-sm text-ndor-ink-secondary leading-relaxed","data-testid":"usage-exhausted-modal-body",children:p})]}),f&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2 text-xs text-ndor-ink-secondary leading-relaxed space-y-0.5","data-testid":"usage-exhausted-modal-breakdown",children:[x&&(0,Xt.jsxs)("p",{children:[(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"Action:"})," ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:x})]}),(0,Xt.jsxs)("p",{children:[(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"Credits required:"})," ",(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums text-ndor-ink",children:Number(i)})]}),(0,Xt.jsxs)("p",{children:[(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"Credits available:"})," ",(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums text-ndor-ink",children:h}),(null!=o||null!=l)&&(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted",children:[" ","(",Number(o)||0," included \xb7 ",Number(l)||0," extra)"]})]})]}),(0,Xt.jsxs)(dg,{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2",children:[(0,Xt.jsxs)(Rr,{variant:"outline",onClick:()=>{d(!1),c("/jobs")},"data-testid":"usage-exhausted-modal-back-to-jobs",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"}),"Back to jobs"]}),(0,Xt.jsxs)(Rr,{onClick:()=>{d(!1),c("/account?tab=plan")},"data-testid":"usage-exhausted-modal-add-usage",className:"bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground",children:[(0,Xt.jsx)(Ow,{className:"h-4 w-4 mr-1.5"}),"Add Credits"]})]})]})})}function Z_(e){var t,n;
2let{open:a,code:r,guidance:s,onClose:i,onStayWithSourceCv:o,onChooseStrongerCv:l,onGenerateNewCv:c,onContinueAnyway:d,busyAction:u}=e;const m="INFERIOR_VARIANT"===r,p=m?"This generated variant is weaker than your baseline":"Selected CV is weaker than your Source CV",h=m?"Your baseline (Source CV) scored ".concat(null!==(t=null===s||void 0===s?void 0:s.baseline_score)&&void 0!==t?t:"\u2014","/100 on this job. The selected variant previously scored ").concat(null!==(n=null===s||void 0===s?void 0:s.variant_score)&&void 0!==n?n:"\u2014","/100. Re-running Analyse Fit on the variant won't improve your competitiveness \u2014 and it will cost credits."):"Analyse Fit is most accurate when run against your primary Source CV (".concat((null===s||void 0===s?void 0:s.primary_cv_label)||"your master CV","). The CV you selected isn't your primary \u2014 running it would consume credits without improving your score.");return(0,Xt.jsx)(rg,{open:a,onOpenChange:e=>{e||null===i||void 0===i||i()},children:(0,Xt.jsxs)(lg,{className:"sm:max-w-lg","data-testid":"inferior-source-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)("div",{className:"mx-auto mb-2 w-10 h-10 rounded-full bg-amber-500/10 border border-amber-500/40 flex items-center justify-center",children:(0,Xt.jsx)(Oy,{className:"h-5 w-5 text-amber-600"})}),(0,Xt.jsx)(ug,{className:"text-center","data-testid":"inferior-source-modal-title",children:p}),(0,Xt.jsx)(mg,{className:"text-center text-sm leading-relaxed","data-testid":"inferior-source-modal-description",children:h})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 gap-2 mt-2",children:[(0,Xt.jsxs)(Rr,{onClick:o,disabled:"stay"===u,className:"justify-between bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted","data-testid":"inferior-source-modal-stay-source-btn",children:[(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4"}),"Stay with Source CV"]}),(0,Xt.jsx)(zy,{className:"h-4 w-4"})]}),(0,Xt.jsxs)(Rr,{variant:"outline",onClick:l,"data-testid":"inferior-source-modal-choose-btn",className:"justify-between",children:[(0,Xt.jsx)("span",{children:"Choose a stronger CV"}),(0,Xt.jsx)(zy,{className:"h-4 w-4 opacity-60"})]}),(0,Xt.jsxs)(Rr,{variant:"outline",onClick:c,"data-testid":"inferior-source-modal-generate-btn",className:"justify-between",children:[(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold"}),"Generate a new CV"]}),(0,Xt.jsx)(zy,{className:"h-4 w-4 opacity-60"})]})]}),(0,Xt.jsx)(dg,{className:"mt-3 flex-col-reverse sm:flex-row sm:justify-end gap-2 border-t pt-3",children:(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:d,disabled:"continue"===u,className:"text-xs text-ndor-ink-muted hover:text-ndor-ink","data-testid":"inferior-source-modal-continue-anyway-btn",children:"Continue anyway (will use credits)"})})]})})}function eD(e){let{open:t,onOpenChange:n,baselineVersion:a,currentVersion:r,onRefresh:i,onDecline:o,onCancel:l}=e;const[c,d]=(0,s.useState)(null);return(0,Xt.jsx)(rg,{open:t,onOpenChange:e=>!c&&(null===n||void 0===n?void 0:n(e)),children:(0,Xt.jsxs)(lg,{"data-testid":"baseline-refresh-modal",className:"sm:max-w-lg",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-5 w-5 text-amber-500","aria-hidden":!0}),"Updated scoring methodology"]}),(0,Xt.jsx)(mg,{className:"pt-2 text-sm leading-relaxed text-muted-foreground",children:"NDOR's scoring methodology has improved since your previous analysis. We can refresh your prior baseline at no charge to preserve the most accurate comparison."})]}),(0,Xt.jsxs)("div",{className:"space-y-3 py-2 text-sm",children:[(a||r)&&(0,Xt.jsxs)("div",{"data-testid":"baseline-refresh-modal-version-chip",className:"flex flex-wrap items-center gap-2 rounded-md bg-muted/40 px-3 py-2 text-xs",children:[(0,Xt.jsx)("span",{className:"font-medium text-muted-foreground",children:"Versions:"}),(0,Xt.jsxs)("span",{children:["Baseline:\xa0",(0,Xt.jsx)("span",{className:"font-mono",children:a||"unstamped"})]}
2),(0,Xt.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,Xt.jsxs)("span",{children:["Current:\xa0",(0,Xt.jsx)("span",{className:"font-mono",children:r||"\u2014"})]})]}),(0,Xt.jsxs)("ul",{className:"space-y-1.5 text-sm",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"mt-0.5 text-emerald-500",children:"\u2713"}),(0,Xt.jsxs)("span",{children:["Refreshing is ",(0,Xt.jsx)("strong",{children:"free"})," \u2014 no Credits charged."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"mt-0.5 text-emerald-500",children:"\u2713"}),(0,Xt.jsx)("span",{children:"Refresh preserves your charge protection (the \xb15 confidence band still waives charges when the tailored CV doesn't materially improve on the refreshed baseline)."})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Oy,{className:"mt-0.5 h-4 w-4 text-amber-500","aria-hidden":!0}),(0,Xt.jsx)("span",{children:"Skipping leaves no baseline to compare against \u2014 tailoring will charge in full regardless of quality improvement."})]})]})]}),(0,Xt.jsxs)(dg,{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,Xt.jsx)(Rr,{"data-testid":"baseline-refresh-modal-cancel-btn",variant:"ghost",onClick:function(){c||(null===l||void 0===l||l(),null===n||void 0===n||n(!1))},disabled:!!c,children:"Cancel"}),(0,Xt.jsxs)(Rr,{"data-testid":"baseline-refresh-modal-decline-btn",variant:"outline",onClick:async function(){if(!c){d("decline");try{await(null===o||void 0===o?void 0:o())}finally{d(null)}}},disabled:!!c,children:["decline"===c&&(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":!0}),"Continue Without Refresh"]}),(0,Xt.jsxs)(Rr,{"data-testid":"baseline-refresh-modal-refresh-btn",onClick:async function(){if(!c){d("refresh");try{await(null===i||void 0===i?void 0:i())}finally{d(null)}}},disabled:!!c,children:["refresh"===c&&(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin","aria-hidden":!0}),"Refresh My Baseline (Free)"]})]})]})})}const tD=["__scopeRadio","name","checked","required","disabled","value","onCheck","form"],nD=["__scopeRadio","forceMount"],aD=["__scopeRadio","control","checked","bubbles"],rD=["__scopeRadioGroup","name","defaultValue","value","required","disabled","orientation","dir","loop","onValueChange"],sD=["__scopeRadioGroup","disabled"],iD=["__scopeRadioGroup"];var oD="Radio",[lD,cD]=js(oD),[dD,uD]=lD(oD),mD=s.forwardRef((e,t)=>{const{__scopeRadio:n,name:a,checked:r=!1,required:i,disabled:o,value:d="on",onCheck:u,form:m}=e,p=l(e,tD),[h,f]=s.useState(null),x=Xn(t,e=>f(e)),v=s.useRef(!1),g=!h||(m||!!h.closest("form"));return(0,Xt.jsxs)(dD,{scope:n,checked:r,disabled:o,children:[(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button",role:"radio","aria-checked":r,"data-state":xD(r),"data-disabled":o?"":void 0,disabled:o,value:d},p),{},{ref:x,onClick:ys(e.onClick,e=>{r||null===u||void 0===u||u(),g&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})})),g&&(0,Xt.jsx)(fD,{control:h,bubbles:!v.current,name:a,value:d,checked:r,required:i,disabled:o,form:m,style:{transform:"translateX(-100%)"}})]})});mD.displayName=oD;var pD="RadioIndicator",hD=s.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:a}=e,r=l(e,nD),s=uD(pD,n);return(0,Xt.jsx)($l,{present:a||s.checked,children:(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({"data-state":xD(s.checked),"data-disabled":s.disabled?"":void 0},r),{},{ref:t}))})});hD.displayName=pD;var fD=s.forwardRef((e,t)=>{let{__scopeRadio:n,control:a,checked:r,bubbles:i=!0}=e,o=l(e,aD);const d=s.useRef(null),u=Xn(d,t),m=Qf(r),p=jl(a);return s.useEffect(()=>{const e=d.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(m!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[m,r,i]),(0,Xt.jsx)(Is.input,(0,c.A)((0,c.A)({type:"radio","aria-hidden":!0,defaultChecked:r},o),{},{tabIndex:-1,ref:u,style:(0,c.A)((0,c.A)((0,c.A)({},o.style),p),{},{position:"absolute",pointerEvents:"none",opacity:0,margin:0})}
2))});function xD(e){return e?"checked":"unchecked"}fD.displayName="RadioBubbleInput";var vD=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],gD="RadioGroup",[yD,bD]=js(gD,[oc,cD]),wD=oc(),jD=cD(),[kD,ND]=yD(gD),_D=s.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:a,defaultValue:r,value:s,required:i=!1,disabled:o=!1,orientation:d,dir:u,loop:m=!0,onValueChange:p}=e,h=l(e,rD),f=wD(n),x=Qs(u),[v,g]=_s({prop:s,defaultProp:null!==r&&void 0!==r?r:null,onChange:p,caller:gD});return(0,Xt.jsx)(kD,{scope:n,name:a,required:i,disabled:o,value:v,onValueChange:g,children:(0,Xt.jsx)(xc,(0,c.A)((0,c.A)({asChild:!0},f),{},{orientation:d,dir:x,loop:m,children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({role:"radiogroup","aria-required":i,"aria-orientation":d,"data-disabled":o?"":void 0,dir:x},h),{},{ref:t}))}))})});_D.displayName=gD;var DD="RadioGroupItem",CD=s.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:a}=e,r=l(e,sD),i=ND(DD,n),o=i.disabled||a,d=wD(n),u=jD(n),m=s.useRef(null),p=Xn(t,m),h=i.value===r.value,f=s.useRef(!1);return s.useEffect(()=>{const e=e=>{vD.includes(e.key)&&(f.current=!0)},t=()=>f.current=!1;return document.addEventListener("keydown",e),document.addEventListener("keyup",t),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",t)}},[]),(0,Xt.jsx)(vc,(0,c.A)((0,c.A)({asChild:!0},d),{},{focusable:!o,active:h,children:(0,Xt.jsx)(mD,(0,c.A)((0,c.A)((0,c.A)({disabled:o,required:i.required,
2checked:h},u),r),{},{name:i.name,ref:p,onCheck:()=>i.onValueChange(r.value),onKeyDown:ys(e=>{"Enter"===e.key&&e.preventDefault()}),onFocus:ys(r.onFocus,()=>{var e;f.current&&(null===(e=m.current)||void 0===e||e.click())})}))}))});CD.displayName=DD;var AD=s.forwardRef((e,t)=>{const{__scopeRadioGroup:n}=e,a=l(e,iD),r=jD(n);return(0,Xt.jsx)(hD,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});AD.displayName="RadioGroupIndicator";var SD=_D,ED=CD,FD=AD;const RD=["className"],ID=["className"],TD=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,RD);return(0,Xt.jsx)(SD,(0,c.A)((0,c.A)({className:Sr("grid gap-2",n)},a),{},{ref:t}))});TD.displayName=SD.displayName;const PD=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,ID);return(0,Xt.jsx)(ED,(0,c.A)((0,c.A)({ref:t,className:Sr("aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",n)},a),{},{children:(0,Xt.jsx)(FD,{className:"flex items-center justify-center",children:(0,Xt.jsx)(ep,{className:"h-3.5 w-3.5 fill-primary"})})}))});PD.displayName=ED.displayName;const OD="standard",BD=Object.freeze({style:OD,template_type:"standard_professional",tone_type:"analytical",length_preference:"flexible",additional_cv_context:""}),LD=Object.freeze({standard:{label:"Standard",blurb:"Balanced, evidence-led layout \u2014 most roles, most readers.",template_type:"standard_professional",tone_type:"analytical",length_preference:"flexible"},executive:{label:"Executive",blurb:"Leadership-led, outcomes-framed \u2014 director / VP / C-su
2ite roles.",template_type:"executive",tone_type:"strategic",length_preference:"two_page"},ats:{label:"ATS",blurb:"Plain, keyword-dense, screener-friendly \u2014 for high-automation funnels.",template_type:"ats_compact",tone_type:"analytical",length_preference:"one_page"}}),MD=Object.entries(LD).map(e=>{let[t,n]=e;return{value:t,label:n.label,blurb:n.blurb}}),zD=4e3,UD=OD,VD=BD;function qD(e){let{value:t,onChange:n}=e;return(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"CV style"}),(0,Xt.jsx)(TD,{value:t,onValueChange:n,className:"grid gap-1.5","data-testid":"generate-cv-options-style-group",children:MD.map(e=>(0,Xt.jsxs)(Pg,{htmlFor:"generate-cv-options-style-".concat(e.value),className:"flex items-start gap-2.5 rounded-md border px-3 py-2 cursor-pointer transition-colors "+(t===e.value?"border-ndor-gold bg-ndor-gold/5":"border-ndor-edge hover:border-ndor-ink-muted"),children:[(0,Xt.jsx)(PD,{value:e.value,id:"generate-cv-options-style-".concat(e.value),"data-testid":"generate-cv-options-style-".concat(e.value),className:"mt-0.5"}),(0,Xt.jsxs)("span",{className:"space-y-0.5",children:[(0,Xt.jsx)("span",{className:"block text-sm font-medium text-ndor-ink leading-tight",children:e.label}),(0,Xt.jsx)("span",{className:"block text-[11px] text-ndor-ink-secondary leading-relaxed",children:e.blurb})]})]},e.value))})]})}function WD(e){let{open:t,onOpenChange:n,onConfirm:a,generating:r=!1}=e;const[i,o]=(0,s.useState)(VD.style),[l,c]=(0,s.useState)(VD.additional_cv_context),{usageCosts:d}=If(),u=Nf(d,"cv_improve"),m=null==u?"":" \xb7 up to ".concat(u," ").concat(1===u?"Credit":"Credits"),p=e=>{e||(o(VD.style),c(VD.additional_cv_context)),"function"===typeof n&&n(e)},h=(l||"").trim(),f=h.length>zD,x=Math.max(0,zD-h.length);return(0,Xt.jsx)(kh,{open:t,onOpenChange:p,children:(0,Xt.jsxs)(Ah,{side:"right",className:"sm:max-w-[420px] flex flex-col gap-4","data-testid":"generate-cv-options-sheet",children:[(0,Xt.jsxs)(Sh,{children:[(0,Xt.jsxs)(Fh,{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold"}),"Configure your tailored CV"]}),(0,Xt.jsx)(Rh,{className:"text-xs leading-relaxed",children:"Pick a CV style. NDORFlow applies the validated tone and length defaults for that style. You can preview the result before locking it into your application pack."})]}),(0,Xt.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 pr-1",children:[(0,Xt.jsx)(qD,{value:i,onChange:o}),(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":"generate-cv-options-additional-context",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Additional CV context \xb7 optional"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-secondary leading-relaxed",children:"Add recent achievements, role changes, certifications, projects, metrics, or anything NDORFlow should consider when improving your CV."}),(0,Xt.jsx)("textarea",{value:l,onChange:e=>c(e.target.value),placeholder:"Example: Recently led a $50m infrastructure evaluation, completed a new certification, managed a team of analysts, or want to emphasise business development experience.",rows:5,maxLength:4200,disabled:r,"data-testid":"generate-cv-options-additional-context-input",className:"w-full rounded-md border border-ndor-edge bg-background text-sm text-ndor-ink leading-relaxed p-2.5 focus:outline-none focus:ring-2 focus:ring-ndor-gold/40 disabled:opacity-50 disabled:cursor-not-allowed"}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between text-[10px] text-ndor-ink-muted font-mono-ui",children:[(0,Xt.jsxs)("span",{"data-testid":"generate-cv-options-additional-context-charcount",children:[h.length," / ",zD," chars"]}),f?(0,Xt.jsxs)("span",{className:"text-ndor-error","data-testid":"generate-cv-options-additional-context-error",children:["Trim by ",h.length-zD," chars to continue."]}):0===h.length?(0,Xt.jsx)("span",{children:"Empty \u2014 generation behaves as before."}):(0,Xt.jsxs)("span",{children:[x," chars left."]})]})]})]}),(0,Xt.jsxs)(Eh,{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2",children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:()=>p(!1),disabled:r,"data-testid":"generate-cv-options-cancel",children:"Cancel"}),(0,Xt.jsxs)(Rr,{onClick:()=>
2{if(f)return;const e=LD[i]||LD[UD];a({template_type:e.template_type,tone_type:e.tone_type,length_preference:e.length_preference,additional_cv_context:h})},disabled:r||f,"data-testid":"generate-cv-options-confirm",children:[r?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5 mr-1.5"}),"Generate",m]})]})]})})}const HD=Object.values(LD).map(e=>({value:e.template_type,label:e.label,blurb:e.blurb})),GD=Array.from(new Set(Object.values(LD).map(e=>e.tone_type))).map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),KD=Array.from(new Set(Object.values(LD).map(e=>e.length_preference))).map(e=>({value:e,label:e.replace(/_/g," ")}));function YD(e){let{included:t,label:n,hint:a,testid:r}=e;return(0,Xt.jsxs)("li",{"data-testid":r,className:"flex items-start gap-2.5",children:[(0,Xt.jsx)("span",{className:"mt-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full shrink-0 "+(t?"bg-ndor-success-light text-ndor-success":"bg-ndor-surface-alt text-ndor-ink-muted border border-ndor-edge"),children:t?(0,Xt.jsx)(Zm,{className:"h-3 w-3"}):(0,Xt.jsx)(xh,{className:"h-3 w-3"})}),(0,Xt.jsxs)("div",{className:"text-sm leading-relaxed",children:[(0,Xt.jsx)("span",{className:t?"text-ndor-ink font-medium":"text-ndor-ink-muted line-through",children:n}),a&&(0,Xt.jsx)("span",{className:"block text-xs text-ndor-ink-muted mt-0.5",children:a})]})]})}function JD(e){let{open:t,onOpenChange:n,composition:a,creating:r,onCancel:i,onConfirm:o}=e;const l=!(null===a||void 0===a||!a.hasTailoredCv),c=!(null===a||void 0===a||!a.hasCoverLetter),d=!(null===a||void 0===a||!a.hasVariantFit),u=l&&d,m=l&&d,p=!l&&!c;(0,s.useEffect)(()=>{if(t)return()=>{}},[t]);const h=(0,s.useMemo)(()=>p?"baseline-only flow":u&&c?"full pack":u?"intelligence pack":l&&c?"tailored-CV pack with cover letter":l?"tailored-CV pack":c?"cover-letter pack":"pack",[p,u,l,c]);return(0,Xt.jsx)(rg,{open:t,onOpenChange:n,children:(0,Xt.jsxs)(lg,{className:"max-w-lg max-h-[calc(100dvh-2rem)] overflow-y-auto","data-testid":"final-pack-confirm-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"text-lg flex items-center gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-5 w-5 text-ndor-gold"}),"Confirm pack contents"]}),(0,Xt.jsx)(mg,{className:"sr-only",children:"Review exactly what your application pack will contain before it is created. Your uploaded Source CV is private reference material and is never exported."})]}),(0,Xt.jsxs)("div",{className:"space-y-4",children:[p?(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"final-pack-confirm-baseline-only-block",children:[(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink leading-relaxed",children:[(0,Xt.jsx)("span",{className:"font-medium",children:"Baseline Fit is diagnostic only."})," ","It tells you where your Source CV stands against this role, but it does NOT produce an exportable intelligence pack."]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed",children:"To create an exportable pack, generate a Tailored CV and run Variant Fit on it. You can also add a generated Cover Letter."}),(0,Xt.jsxs)("ul",{className:"space-y-2 pl-1","data-testid":"final-pack-confirm-baseline-only-checklist",children:[(0,Xt.jsx)(YD,{included:!1,label:"Tailored CV",hint:"Required \u2014 generate one in Step 1.",testid:"final-pack-confirm-row-tailored-cv"}),(0,Xt.jsx)(YD,{included:!1,label:"Variant Fit",hint:"Required \u2014 run on the tailored CV in Step 3.",testid:"final-pack-confirm-row-variant-fit"})]})]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed","data-testid":"final-pack-confirm-summary",children:["You're about to create a ",(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium",children:h})," for this job."]}),(0,Xt.jsxs)("ul",{className:"space-y-2.5","data-testid":"final-pack-confirm-composition",children:[(0,Xt.jsx)(YD,{included:l,label:"Tailored CV",hint:l?"Generated this flow.":"Not generated this flow.",testid:"final-pack-confirm-row-tailored-cv"}),(0,Xt.jsx)(YD,{included:c,label:"Cover letter",hint:c?"Generated this flow.":"Not generated this flow.",testid:"final-pack-confirm-row-cover-letter"}),(0,Xt.jsx)(YD,{included:u,label:"Interview Intelligence",hint:u?"Strengths, risks, talking points and likely interview questions.":"Excluded \u2014 requires a tailored CV AND a Variant Fit run.",testid:"final-pack-confirm-row-interview-intelligence"}),(0,Xt.jsx)(YD,{included:m,label:"Variant-Fit cover page",hint:m?"Included because you generated a tailored CV and ran Variant Fit.":"Excluded \u2014 requires a tailored CV AND a Variant Fit run.",testid:"final-pack-confirm-row-cover-sheet"}),(0,Xt.jsx)(YD,{included:!1,label:"Source CV",hint:"Never included, never exported, never previewed. Private reference material only.",testid:"final-pack-confirm-row-source-cv"})]})]}),(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2.5 text-xs text-ndor-ink-secondary leading-relaxed","data-testid":"final-pack-confirm-source-cv-disclaimer",children:"Your pack includes only what you generated or analysed in this flow. Your uploaded Source CV is private reference material only and is never exported. NDORFlow never auto-applies \u2014 final submission is always your decision."})]}),(0,Xt.jsxs)(dg,{className:"gap-2 sm:gap-2 sticky bottom-0 -mx-6 px-6 -mb-6 pb-6 pt-3 bg-background border-t border-ndor-edge/40",children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:i,disabled:r,"data-testid":"final-pack-confirm-cancel",className:"flex-1 sm:flex-none",children:"Cancel"}),(0,Xt.jsx)(Rr,{onClick:o,disabled:r||p,"data-testid":"final-pack-confirm-create",className:"flex-1 sm:flex-none bg-ndor-gold text-ndor-ink hover:bg-ndor-gold/90 font-medium",title:p?"Generate a Tailored CV and run Variant Fit to create an exportable pack.":void 0,children:r?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}),"Creating\u2026"]}):"Create Pack"})]})]})})}const $D=e=>{let{items:t}=e;return(0,Xt.jsx)("ul",{className:"space-y-1.5 text-[12px] text-ndor-ink leading-relaxed",children:t.map((e,t)=>(0,Xt.jsxs)("li",{className:"flex gap-2",children:[(0,Xt.jsx)("span",{className:"text-ndor-ink-muted shrink-0",children:"\u2022"}),(0,Xt.jsx)("span",{children:e})]},t))})},XD=e=>{let{items:t,k1:n,k2:a,label1:r,label2:s}=e;return(0,Xt.jsx)("ul",{className:"space-y-2 text-[12px] leading-relaxed",children:t.map((e,t)=>(0,Xt.jsxs)("li",{className:"border-l-2 border-ndor-edge pl-2.5 space-y-0.5",children:[(0,Xt.jsxs)("div",{className:"text-ndor-ink",children:[(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.12em] text-ndor-ink-muted mr-1.5",children:r}),e[n]]}),e[a]&&(0,Xt.jsxs)("div",{className:"text-ndor-ink-secondary",children:[(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.12em] text-ndor-ink-muted mr-1.5",children:s}),e[a]]})]},t))})},QD=e=>{let{icon:t,children:n}=e;return(0,Xt.jsxs)("h5",{className:"flex items-center gap-1.5 text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-medium mb-1.5",children:[t&&(0,Xt.jsx)(t,{className:"h-3 w-3"}),n]})},ZD=e=>{let{map:t}=e;const n=t||{};return(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"optimisation-improvement-map",children:[n.headline&&(0,Xt.jsx)("p",{className:"text-[13px] text-ndor-ink leading-relaxed font-medium",children:n.headline}),"number"===typeof n.score_delta&&0!==n.score_delta&&(0,Xt.jsxs)("div",{className:"text-[11px] text-ndor-success",children:["NDOR CV verdict moved ",n.score_delta>0?"+":"",(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums",children:n.score_delta})," points."]}),Array.isArray(n.gaps_closed)&&n.gaps_closed.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{icon:Kn,children:"Gaps closed"}),(0,Xt.jsx)("ul",{className:"space-y-2 text-[12px] leading-relaxed",children:n.gaps_closed.map((e,t)=>(0,Xt.jsxs)("li",{className:"border-l-2 border-ndor-success/40 pl-2.5 space-y-0.5","data-testid":"optimisation-gap-closed-row",children:[(0,Xt.jsx)("div",{className:"text-ndor-ink font-medium",children:e.gap}),e.evidence&&(0,Xt.jsxs)("div",{className:"text-ndor-ink-secondary",children:[(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.12em] text-ndor-ink-muted mr-1.5",children:"Now reads"}),e.evidence]}),(e.before||e.after)&&(0,Xt.jsxs)("div",{className:"text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsx)("span",{className:"opacity-70",children:"Before:"})," ",e.before||"absent"," \xb7"," ",(0,Xt.jsx)("span",{className:"opacity-70",children:"After:"})," ",e.after]})]},t))})]}),Array.isArray(n.ats_alignment_gains)&&n.ats_alignment_gains.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{children:"ATS alignment gains"}),(0,Xt.jsx)($D,{items:n.ats_alignment_gains})]}),Array.isArray(n.recruiter_objections_reduced)&&n.recruiter_objections_reduced.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{children:"Recruiter objections reduced"}),(0,Xt.jsx)(XD,{items:n.recruiter_objections_reduced,k1:"objection",label1:"Objection",k2:"mitigation",label2:"Now answered by"})]}),n.strategic_repositioning&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{children:"Strategic repositioning"}),(0,Xt.jsx)("p",{className:"text-[12px] text-ndor-ink leading-relaxed",children:n.strategic_repositioning})]}),Array.isArray(n.remaining_risks)&&n.remaining_risks.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{icon:Oy,children:"Remaining risks"}),(0,Xt.jsx)($D,{items:n.remaining_risks})]})]})},eC=e=>{let{map:t}=e;const n=t||{};return(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"optimisation-defensibility-map",children:[n.narrative_anchor&&(0,Xt.jsx)("p",{className:"text-[13px] text-ndor-ink leading-relaxed font-medium border-l-4 border-ndor-gold pl-3 py-1",children:n.narrative_anchor}),Array.isArray(n.fully_supported_claims)&&n.fully_supported_claims.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{icon:Bn,children:"Fully supported claims"}),(0,Xt.jsx)(XD,{items:n.fully_supported_claims,k1:"claim",label1:"Claim",k2:"evidence",label2:"Evidence in your CV"})]}),Array.isArray(n.transferable_claims)&&n.transferable_claims.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{children:"Transferable claims"}),(0,Xt.jsx)(XD,{items:n.transferable_claims,k1:"claim",label1:"Claim",k2:"bridge_logic",label2:"How to bridge"})]}),Array.isArray(n.moderate_risk_claims)&&n.moderate_risk_claims.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{icon:Oy,children:"Moderate-risk claims"}),(0,Xt.jsx)("ul",{className:"space-y-2 text-[12px] leading-relaxed",children:n.moderate_risk_claims.map((e,t)=>(0,Xt.jsxs)("li",{className:"border-l-2 border-ndor-warning/40 pl-2.5 space-y-0.5","data-testid":"optimisation-moderate-risk-row",children:[(0,Xt.jsx)("div",{className:"text-ndor-ink font-medium",children:e.claim}),e.mitigation&&(0,Xt.jsxs)("div",{className:"text-ndor-ink-secondary",children:[(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.12em] text-ndor-ink-muted mr-1.5",children:"If pushed back"}),e.mitigation]}),e.soften_alternative&&(0,Xt.jsxs)("div",{className:"text-[11px] text-ndor-ink-muted italic",children:['Or soften to: "',e.soften_alternative,'"']})]},t))})]}),Array.isArray(n.claims_requiring_interview_support)&&n.claims_requiring_interview_support.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{children:"Prepare a STAR story for"}),(0,Xt.jsx)(XD,{items:n.claims_requiring_interview_support,k1:"claim",label1:"Claim",k2:"interview_prep_tip",label2:"Prep tip"})]}),Array.isArray(n.remaining_risks)&&n.remaining_risks.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(QD,{icon:Oy,children:"Remaining risks"}),(0,Xt.jsx)($D,{items:n.remaining_risks})]})]})},tC=e=>{let{title:t,icon:n,defaultOpen:a=!1,testid:r,children:i}=e;
2const[o,l]=(0,s.useState)(a);return(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30","data-testid":r,children:[(0,Xt.jsxs)("button",{type:"button",onClick:()=>l(e=>!e),className:"w-full flex items-center justify-between gap-2 px-3 py-2 text-left hover:bg-ndor-surface-alt/50 rounded-md transition-colors","data-testid":"".concat(r,"-toggle"),children:[(0,Xt.jsxs)("span",{className:"flex items-center gap-2 text-[12px] font-medium text-ndor-ink",children:[n&&(0,Xt.jsx)(n,{className:"h-3.5 w-3.5 text-ndor-gold"}),t]}),o?(0,Xt.jsx)(Tv,{className:"h-3.5 w-3.5 text-ndor-ink-muted"}):(0,Xt.jsx)(Gn,{className:"h-3.5 w-3.5 text-ndor-ink-muted"})]}),o&&(0,Xt.jsx)("div",{className:"px-3 pb-3 pt-1",children:i})]})},nC=e=>{let{artifacts:t}=e;if(!t)return null;if(!1===t.generated)return(0,Xt.jsx)("div",{className:"rounded-md border border-dashed border-ndor-edge px-3 py-2 text-[11px] text-ndor-ink-muted","data-testid":"optimisation-artifacts-unavailable",children:"Defence report unavailable \u2014 please refresh in a moment."});const n=t.improvement_map||{},a=t.defensibility_map||{},r=n.headline||Array.isArray(n.gaps_closed)&&n.gaps_closed.length>0||n.strategic_repositioning,s=a.narrative_anchor||Array.isArray(a.fully_supported_claims)&&a.fully_supported_claims.length>0;return r||s?(0,Xt.jsxs)("div",{className:"space-y-2 pt-2 border-t border-ndor-edge/60",children:[r&&(0,Xt.jsx)(tC,{title:"Why am I stronger now?",icon:e_,testid:"optimisation-improvement-card",children:(0,Xt.jsx)(ZD,{map:n})}),s&&(0,Xt.jsx)(tC,{title:"How do I defend this at interview?",icon:Ln,testid:"optimisation-defensibility-card",children:(0,Xt.jsx)(eC,{map:a})})]}):null};function aC(e){try{const t="ndor_dashboard_first_action_fired";if("1"===sessionStorage.getItem(t))return;Ht("dashboard_first_action",{action_type:e}),sessionStorage.setItem(t,"1")}catch(t){}}
2const rC=[{key:"cv",label:"Choose CV",shortLabel:"CV"},{key:"letter",label:"Cover letter",shortLabel:"Letter"},{key:"fit",label:"Analyse Fit",shortLabel:"Fit"},{key:"review",label:"Review",shortLabel:"Review"}],sC=e=>"ndor_high_cv_confirmed_".concat(e);function iC(e){let{stepIdx:t}=e;return(0,Xt.jsx)("div",{className:"flex items-center gap-1 sm:gap-2 text-[11px] sm:text-xs","data-testid":"wizard-step-indicator",children:rC.map((e,n)=>(0,Xt.jsxs)(s.Fragment,{children:[(0,Xt.jsxs)("span",{className:"px-1.5 sm:px-2 py-0.5 rounded transition-colors whitespace-nowrap "+(n===t?"bg-ndor-gold/15 text-ndor-gold font-medium":n<t?"text-ndor-ink-muted":"text-ndor-ink-muted/50"),"data-testid":"wizard-step-".concat(e.key),children:[(0,Xt.jsxs)("span",{className:"sm:hidden",children:[n+1,". ",e.shortLabel]}),(0,Xt.jsxs)("span",{className:"hidden sm:inline",children:[n+1,". ",e.label]})]}),n<rC.length-1&&(0,Xt.jsx)("span",{className:"text-ndor-ink-muted/30",children:"\u2192"})]},e.key))})}function oC(e){var t,n,a,r,s,i,o,l;let{job:c,primaryCv:d,sourceFitNdor:u,sourceCvVerdict:m,hasBaselineFit:p,jobId:h,selectedCv:f,onSelectCv:x,generating:v,onGenerate:g,generatedResult:y,onPreviewVariant:b,progressMessage:w,creditsLoading:j,onBack:k,onContinue:N}=e;const{usageCosts:_}=If(),D=Nf(_,"cv_improve"),C=Nf(_,"analyze_fit"),A=null==D?"":"".concat(D," ").concat(1===D?"Credit":"Credits"),S=null==C?"":"".concat(C," ").concat(1===C?"Credit":"Credits"),E=Xk(qk(null===d||void 0===d?void 0:d.user_id,h)),F=!!f,R=(e,t)=>(null===f||void 0===f?void 0:f.type)===e&&(null==t||(null===f||void 0===f?void 0:f.id)===t),I=null!==(t=null===y||void 0===y?void 0:y.cv_sub_score_variant)&&void 0!==t?t:null,T=null!==(n=null!==(a=null===y||void 0===y?void 0:y.cv_sub_score_source)&&void 0!==a?a:m)&&void 0!==n?n:null,P=null!=I&&null!=T?I-T:null;return(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"wizard-step-2-pane",children:[y&&(0,Xt.jsxs)("div",{className:"rounded-lg border-2 p-3 space-y-2 "+(R("cv_variant",y.variant_id)?"border-ndor-gold bg-ndor-gold/5":"border-ndor-gold/40 bg-ndor-gold/[0.02]"),"data-testid":"wizard-cv-generated-card",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:y.variant_name||"Tailored Variant"}),(0,Xt.jsx)(Vw,{className:"text-[10px] uppercase tracking-[0.14em] bg-ndor-gold/15 text-ndor-gold border-0",children:y.reused?"Reused \xb7 saved earlier":"Tailored Variant \xb7 this attempt"})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed","data-testid":"wizard-cv-generated-saved-line",children:y.reused?(0,Xt.jsxs)(Xt.Fragment,{children:["We loaded your existing tailored CV for this job \u2014 no new Credits charged."," ","You can use it as-is or generate a fresh version below."]}):(0,Xt.jsxs)(Xt.Fragment,{children:["Saved to ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"Documents \u2192 CV Variants"}),"."]})}),(0,Xt.jsxs)("div",{className:"flex items-center gap-3 text-[11px] text-ndor-ink-secondary flex-wrap pt-0.5",children:[null!=y.cv_sub_score_variant?(0,Xt.jsxs)("span",{"data-testid":"wizard-cv-generated-cv-verdict",children:["NDOR CV verdict ",(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums",children:[y.cv_sub_score_variant,"/100"]}),null!=T&&null!=P&&(0,Xt.jsxs)("span",{className:"ml-1 "+(P>0?"text-ndor-success":"text-ndor-ink-muted"),children:["(",P>0?"+":"",P," vs Source ",T,"/100)"]})]}):(0,Xt.jsx)("span",{className:"italic text-ndor-ink-muted","data-testid":"wizard-cv-generated-no-baseline-note",children:"NDOR CV verdict not graded \u2014 no baseline on this role."}),(0,Xt.jsxs)("span",{"data-testid":"wizard-cv-generated-fit-score",children:["Overall Fit"," ",null!=y.fit_score_variant?(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums",children:[y.fit_score_variant,"/100"]}
2):(0,Xt.jsx)("span",{className:"italic text-ndor-ink-muted",children:"not yet run"}),(0,Xt.jsx)("span",{className:"text-ndor-ink-muted ml-1",children:"\xb7 informational"})]})]}),(0,Xt.jsx)("p",{className:"text-[11px] "+(y.charged?"text-ndor-warning":"text-ndor-ink-muted"),"data-testid":"wizard-cv-generated-charge-line",children:y.charged?"cv_quality_improved"===y.reason?"Material improvement achieved \u2014 ".concat(A," charged (\u0394 +").concat(null!==(r=y.delta)&&void 0!==r?r:"?"," pts vs Source CV)."):"no_baseline_protection"===y.reason?"".concat(A," charged \u2014 no Analyse Fit baseline existed, so improvement could not be measured."):"Tailoring complete \u2014 ".concat(A," charged."):"within_tolerance_band"===y.reason?"Within NDOR confidence band \u2014 generated CV is comparable to your Source CV (\u0394 ".concat((null!==(s=y.delta)&&void 0!==s?s:0)>=0?"+":"").concat(null!==(i=y.delta)&&void 0!==i?i:0," pts, \xb1").concat(null!==(o=y.tolerance_band)&&void 0!==o?o:5,"). No Credits charged."):"cv_quality_no_improvement"===y.reason?"No material uplift detected \u2014 generated CV scored below your Source CV (\u0394 ".concat(null!==(l=y.delta)&&void 0!==l?l:"?"," pts). No Credits charged."):"Tailoring not charged."})]}),(0,Xt.jsxs)("div",{className:"flex flex-col gap-1.5 shrink-0",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:()=>b(y.variant_id,y.variant_name),"data-testid":"wizard-cv-generated-preview",children:[(0,Xt.jsx)(zg,{className:"h-3.5 w-3.5 mr-1.5"})," Preview"]}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:()=>{var e;return x({type:"cv_variant",id:y.variant_id,score:null!==(e=y.cv_sub_score_variant)&&void 0!==e?e:null,name:y.variant_name,label:"Tailored Variant"})},"data-testid":"wizard-cv-generated-select",variant:R("cv_variant",y.variant_id)?"default":"secondary",children:[(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5 mr-1.5"}),R("cv_variant",y.variant_id)?"Selected":"Use this CV"]})]})]}),(0,Xt.jsx)(nC,{artifacts:y.optimisation_artifacts})]}),(0,Xt.jsx)("div",{className:"rounded-lg border p-3 transition-colors "+(R("base_cv")?"border-ndor-gold bg-ndor-gold/5":"border-ndor-edge"),"data-testid":"wizard-cv-option-source",children:(0,Xt.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,Xt.jsxs)("button",{type:"button",onClick:()=>x({type:"base_cv",id:null===d||void 0===d?void 0:d.id,score:null!==u&&void 0!==u?u:null,name:null===d||void 0===d?void 0:d.original_filename,label:"Source CV"}),disabled:!(null!==d&&void 0!==d&&d.id),className:"text-left min-w-0 flex-1","data-testid":"wizard-cv-option-source-select",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-ndor-ink-muted shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:"Use your Source CV"})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted truncate",children:(null===d||void 0===d?void 0:d.original_filename)||"\u2014"}),(0,Xt.jsxs)("div",{className:"flex items-center gap-3 text-[11px] mt-0.5 flex-wrap",children:[(0,Xt.jsx)("span",{className:"text-ndor-success","data-testid":"wizard-cv-source-no-charge",children:"No charge to use your Source CV."}),(0,Xt.jsxs)("span",{className:"text-ndor-ink-secondary","data-testid":"wizard-cv-source-cv-verdict",children:["NDOR CV verdict"," ",null!=m?(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums",children:[m,"/100"]}):(0,Xt.jsx)("span",{className:"italic text-ndor-ink-muted",children:"not yet run"})]}),(0,Xt.jsxs)("span",{className:"text-ndor-ink-secondary",children:["Overall Fit"," ",null!=u?(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums",children:[u,"/100"]}):(0,Xt.jsx)("span",{className:"italic text-ndor-ink-muted",children:"not yet run"})]})]})]})})}),(0,Xt.jsxs)("div",{className:"rounded-lg border p-3 space-y-2 "+(y?"border-ndor-edge/60 bg-ndor-surface-alt/20":"border-ndor-edge"),"data-testid":"wizard-cv-generate-block",children:[(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold"}),y?y.reused?"Generate a new version":"Generate another tailored CV":"Generate tailored CV"]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:(0,Xt.jsx)("strong",{children:"What may be charged:"})}),(0,Xt.jsxs)("ul",{className:"text-xs text-ndor-ink-secondary list-disc pl-5 space-y-0.5 leading-relaxed",children:[(0,Xt.jsxs)("li",{children:["CV tailoring is charged ",A||"\u2014"," only when the generated CV improves on the LLM-graded NDOR CV verdict of your Source CV."]}),(0,Xt.jsx)("li",{children:"If the generated CV does not improve, it is still saved for you to review, but no tailoring Credits are charged."}),(0,Xt.jsxs)("li",{children:["Variant Fit on the selected tailored CV is a separate, optional step in Step 3 (",S||"\u2014",") \u2014 never auto-run after generation. Source CV Baseline Fit is run separately from the Jobs page."]})]}),!p&&!y&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-warning/40 bg-ndor-warning/5 px-3 py-2 text-[11px] text-ndor-ink-secondary flex items-start gap-2","data-testid":"wizard-cv-no-baseline-warning",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 text-ndor-warning mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:["No Source CV Baseline Fit on this role yet. Tailoring will be charged regardless of outcome."," ",(0,Xt.jsx)(Et,{to:"/jobs/".concat(h),className:"text-ndor-gold underline font-medium","data-testid":"wizard-cv-no-baseline-warning-link",children:"Run Baseline Fit first to unlock billing protection"}),"."]})]}),(0,Xt.jsxs)(Rr,{onClick:g,disabled:v||j||E.active,variant:y?"outline":"default","data-testid":"wizard-cv-generate-button","data-cooldown-active":E.active?"1":"0","data-cooldown-remaining-ms":E.active?String(E.remainingMs):"",title:E.active?"Generate is on cooldown for ".concat(E.label,". This prevents accidental re-clicks while your wallet syncs."):void 0,children:[v?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5 mr-1.5"}),E.active?"Generate again in ".concat(E.label):"Generate".concat(null!=D?" \xb7 up to ".concat(D," ").concat(1===D?"Credit":"Credits"):"")]}),j&&!v&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"wizard-cv-credits-loading-hint",className:"mt-2 flex items-center gap-2 text-xs text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0"}),(0,Xt.jsx)("span",{children:"Loading your wallet\u2026"})]}),w&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"wizard-cv-progress",className:"mt-2 flex items-center gap-2 text-xs text-ndor-ink-secondary",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0 text-ndor-ink-muted"}),(0,Xt.jsx)("span",{"data-testid":"wizard-cv-progress-message",children:w})]})]}),(0,Xt.jsxs)("div",{className:"flex justify-between",children:[(0,Xt.jsxs)(Rr,{variant:"ghost",onClick:k,"data-testid":"wizard-step-2-back",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"})," Back"]}),(0,Xt.jsxs)(Rr,{onClick:N,disabled:!F,"data-testid":"wizard-step-2-next",children:["Next: Cover Letter ",(0,Xt.jsx)(zy,{className:"h-4 w-4 ml-1.5"})]})]})]})}function lC(e){var t,n,a,r;let{jobId:s,selectedCv:i,onAnalyse:o,analysing:l,bestFit:c,lastResult:d,baselineFit:u,creditsLoading:m,userId:p,onBack:h,onContinue:f}=e;const{usageCosts:x}=If(),v=Nf(x,"analyze_fit"),g=null==v?"":" \xb7 ".concat(v," ").concat(1===v?"Credit":"Credits"),y=(null===i||void 0===i?void 0:i.label)||"selected CV",b=Xk(Wk(p,s,(null===i||void 0===i?void 0:i.id)||"no_source")),w=!!d,j=!!(w&&null!==d&&void 0!==d&&d.sourceType&&null!==d&&void 0!==d&&d.sourceId&&null!==i&&void 0!==i&&i.id&&("cv_variant"===d.sourceType&&"cv_variant"===i.type&&d.sourceId===i.id||"uploaded_cv"===d.sourceType&&("base_cv"===i.type||"uploaded_cv"===i.type)&&d.sourceId===i.id)),k=!l&&j,N=null!==(t=null===d||void 0===d?void 0:d.newScore)&&void 0!==t?t:null,_=null!==(n=null===d||void 0===d?void 0:d.cvLabel)&&void 0!==n?n:y,D=(null===d||void 0===d?void 0:d.analysis)||(null===d||void 0===d?void 0:d.reasoning)||null,C="base_cv"===(null===i||void 0===i?void 0:i.type),A=null!==(a=null===u||void 0===u||null===(r=u.baseline)||void 0===r?void 0:r.fit_score)&&void 0!==a?a:null,S=null!=N&&null!=A&&"cv_variant"===(null===i||void 0===i?void 0:i.type),E=S?Math.round(N-A):null;return C?(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"wizard-step-fit-pane",children:[(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge p-4 space-y-2","data-testid":"wizard-step-fit-base-cv-notice",children:[(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-ndor-ink-muted"})," Analyse Fit not required"]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:"You selected your Source CV. Its baseline score for this job is already available on the Job page; running Analyse Fit again here would be redundant. Continue to Review to create your pack."})]}),(0,Xt.jsxs)("div",{className:"flex justify-between items-center",children:[(0,Xt.jsxs)(Rr,{variant:"ghost",onClick:h,"data-testid":"wizard-step-fit-back",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"})," Back"]}),(0,Xt.jsxs)(Rr,{onClick:f,"data-testid":"wizard-step-fit-next",children:["Next: Review ",(0,Xt.jsx)(zy,{className:"h-4 w-4 ml-1.5"})]})]})]}):(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"wizard-step-fit-pane",children:[(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge p-4 space-y-3",children:[(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold"})," Analyse Fit on selected CV"]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:["NDOR's strategic analysis runs against your"," ",(0,Xt.jsx)("span",{className:"font-medium",children:y})," and the job description. The cover letter is intentionally excluded
2so this score stays comparable to your Source-CV baseline. We display the latest result only \u2014 no historical runs."]}),(0,Xt.jsxs)(Rr,{onClick:()=>o(),disabled:l||!(null!==i&&void 0!==i&&i.id)||m||b.active,variant:"outline",size:"sm","data-testid":"wizard-step-fit-analyse-button","data-cooldown-active":b.active?"1":"0","data-cooldown-remaining-ms":b.active?String(b.remainingMs):"",title:b.active?"Analyse Fit is on cooldown for ".concat(b.label,". This prevents accidental re-clicks while your wallet syncs."):void 0,children:[l?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5 mr-1.5"}),b.active?"Run again in ".concat(b.label):w?"Re-run Analyse Fit".concat(g):"Analyse Fit".concat(g)]}),m&&!l&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"wizard-fit-credits-loading-hint",className:"mt-2 flex items-center gap-2 text-xs text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0"}),(0,Xt.jsx)("span",{children:"Loading your wallet\u2026"})]}),w&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30 p-3 space-y-2","data-testid":"wizard-step-fit-current-result",children:[(0,Xt.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-gold font-mono-ui",children:"Current result"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted truncate max-w-[55%]",title:_,children:_})]}),(0,Xt.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,Xt.jsx)("span",{className:"font-serif text-3xl leading-none text-ndor-ink","data-testid":"wizard-step-fit-score",children:N}),(0,Xt.jsx)("span",{className:"text-sm text-ndor-ink-muted",children:"/ 100 fit"}),S&&(0,Xt.jsxs)("span",{className:"ml-1 text-[11px] font-mono-ui tabular-nums px-1.5 py-0.5 rounded "+(E>0?"bg-ndor-success/15 text-ndor-success":E<0?"bg-ndor-warning/15 text-ndor-warning":"bg-ndor-surface-alt text-ndor-ink-muted"),"data-testid":"wizard-step-fit-delta-badge",title:"Compared to your Source CV baseline of ".concat(A,"/100"),children:[E>0?"+":"",E," vs Source CV"]})]}),(null===D||void 0===D?void 0:D.score_explanation)&&(0,Xt.jsx)("p",{className:"text-[12px] text-ndor-ink-secondary leading-relaxed","data-testid":"wizard-step-fit-explanation",children:D.score_explanation}),Array.isArray(null===D||void 0===D?void 0:D.key_strengths)&&D.key_strengths.length>0&&(0,Xt.jsxs)("div",{"data-testid":"wizard-step-fit-strengths",children:[(0,Xt.jsx)("p",{className:"text-[11px] font-medium text-ndor-ink mt-1",children:"Key strengths"}),(0,Xt.jsx)("ul",{className:"list-disc pl-5 text-[12px] text-ndor-ink-secondary leading-relaxed",children:D.key_strengths.slice(0,3).map((e,t)=>(0,Xt.jsx)("li",{children:e},t))})]}),Array.isArray(null===D||void 0===D?void 0:D.key_risks)&&D.key_risks.length>0&&(0,Xt.jsxs)("div",{"data-testid":"wizard-step-fit-risks",children:[(0,Xt.jsx)("p",{className:"text-[11px] font-medium text-ndor-ink mt-1",children:"Key risks"}),(0,Xt.jsx)("ul",{className:"list-disc pl-5 text-[12px] text-ndor-ink-secondary leading-relaxed",children:D.key_risks.slice(0,3).map((e,t)=>(0,Xt.jsx)("li",{children:e},t))})]})]}),!w&&(0,Xt.jsx)("p",{className:"text-[12px] text-ndor-ink-muted italic","data-testid":"wizard-step-fit-empty",children:"No fit analysis on file for this CV yet. Run one above to see your score, key strengths, and risks before continuing."})]}),(0,Xt.jsxs)("div",{className:"flex justify-between items-center",children:[(0,Xt.jsxs)(Rr,{variant:"ghost",onClick:h,"data-testid":"wizard-step-fit-back",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"})," Back"]}),(0,Xt.jsxs)(Rr,{onClick:f,disabled:!k,"data-testid":"wizard-step-fit-next",children:["Next: Review ",(0,Xt.jsx)(zy,{className:"h-4 w-4 ml-1.5"})]})]})]})}function cC(e){let{letterDraft:t,setLetterDraft:n,generating:a,onGenerate:r,onSkip:s,onBack:i,onContinue:o,hasLetter:l,progressMessage:c,creditsLoading:d}=e;const{usageCosts:u}=If(),m=Nf(u,"cover_letter"),p=null==m?"":"".concat(m," ").concat(1===m?"Credit":"Credits");return(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"wizard-step-3-pane",children:[(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge p-3 space-y-2",children:[(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bg,{className:"h-4 w-4 text-ndor-gold"})," Cover letter"]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:null==m?"Generate a cover letter for this job. You can edit and save before continuing.":"Generate a cover letter for this job. Cost: ".concat(p,". You can edit and save before continuing.")}),(0,Xt.jsxs)(Rr,{onClick:r,disabled:a||d,variant:"outline","data-testid":"wizard-letter-generate-button",children:[a?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5 mr-1.5"}),l?"Regenerate".concat(null!=m?" \xb7 ".concat(p):""):"Generate".concat(null!=m?" \xb7 ".concat(p):"")]}),d&&!a&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"wizard-letter-credits-loading-hint",className:"mt-2 flex items-center gap-2 text-xs text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0"}),(0,Xt.jsx)("span",{children:"Loading your wallet\u2026"})]}),c&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"wizard-letter-progress",className:"mt-2 flex items-center gap-2 text-xs text-ndor-ink-secondary",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0 text-ndor-ink-muted"}),(0,Xt.jsx)("span",{"data-testid":"wizard-letter-progress-message",children:c})]})]}),l&&(0,Xt.jsxs)("div",{className:"space-y-1.5","data-testid":"wizard-letter-editor",children:[(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Edit before saving (locks at Review)."}),(0,Xt.jsx)(Hw,{value:t,onChange:e=>n(e.target.value),rows:10,className:"font-manrope text-sm","data-testid":"wizard-letter-textarea"})]}),(0,Xt.jsxs)("div",{className:"flex justify-between items-center",children:[(0,Xt.jsxs)(Rr,{variant:"ghost",onClick:i,"data-testid":"wizard-step-3-back",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"})," Back"]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Xt.jsx)("button",{type:"button",onClick:s,className:"text-xs text-ndor-ink-muted hover:text-ndor-ink underline","data-testid":"wizard-letter-skip",children:"Skip cover letter"}),(0,Xt.jsxs)(Rr,{onClick:o,disabled:a,"data-testid":"wizard-step-3-next",children:["Next: Analyse Fit ",(0,Xt.jsx)(zy,{className:"h-4 w-4 ml-1.5"})]})]})]})]})}function dC(e){let{job:t,primaryCv:n,fitScore:a,fitDate:r,selectedCv:s,generatedResult:i,letterId:o,letterDraft:l,letterTitle:c,packName:d,setPackName:u,notes:m,setN
2otes:p,creating:h,onBack:f,onCreate:x,progressMessage:v,creditsLoading:g,onPreviewCv:y,onPreviewLetter:b,bestFit:w,onBackToFitStep:j}=e;const{usageCosts:k}=If(),N=Nf(k,"analyze_fit"),_=null==N?"":" \xb7 ".concat(N," ").concat(1===N?"Credit":"Credits"),D="cv_variant"===(null===s||void 0===s?void 0:s.type)&&null!=(null===i||void 0===i?void 0:i.cv_sub_score_variant)?i.cv_sub_score_variant:null,C="base_cv"===(null===s||void 0===s?void 0:s.type)&&null!=a?a:"cv_variant"===(null===s||void 0===s?void 0:s.type)&&null!=(null===i||void 0===i?void 0:i.fit_score_variant)?i.fit_score_variant:null;return(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"wizard-step-4-pane",children:[(0,Xt.jsxs)("div",{className:"space-y-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-ndor-ink-muted mb-1",children:"Pack name"}),(0,Xt.jsx)(Ag,{value:d,readOnly:!0,"data-testid":"wizard-review-pack-name"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted mt-1","data-testid":"wizard-review-pack-name-hint",children:"System-generated. You can rename your downloaded file locally."})]}),(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge p-3 space-y-1","data-testid":"wizard-review-job",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-ndor-ink-muted",children:"Job"}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink",children:[null===t||void 0===t?void 0:t.title," \xb7 ",null===t||void 0===t?void 0:t.company]})]}),(0,Xt.jsx)("div",{className:"rounded-lg border border-ndor-edge p-3 space-y-1","data-testid":"wizard-review-cv",children:(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-ndor-ink-muted",children:"Selected CV"}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink truncate",children:[null===s||void 0===s?void 0:s.label," \u2014 ",null===s||void 0===s?void 0:s.name]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted",children:[null!=D&&(0,Xt.jsxs)(Xt.Fragment,{children:["NDOR CV verdict ",D,"/100"]}),null!=D&&null!=C&&" \xb7 ",null!=C&&(0,Xt.jsxs)(Xt.Fragment,{children:["Overall Fit ",C,"/100",r&&"base_cv"===(null===s||void 0===s?void 0:s.type)?" \xb7 ".concat(new Date(r).toLocaleDateString()):""]}),null==D&&null==C&&"\u2014"]})]}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:y,"data-testid":"wizard-review-preview-cv",children:[(0,Xt.jsx)(zg,{className:"h-3.5 w-3.5 mr-1.5"})," Preview"]})]})}),(0,Xt.jsxs)("div",{className:"rounded-lg border p-3 space-y-1 "+(null!=(null===w||void 0===w?void 0:w.score)?"border-ndor-edge bg-ndor-surface-alt/30":"border-ndor-gold/40 bg-ndor-gold/[0.03]"),"data-testid":"wizard-review-fit",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-ndor-ink-muted",children:"Application-readiness (Analyse-Fit)"}),null!=(null===w||void 0===w?void 0:w.score)?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink","data-testid":"wizard-review-fit-score",children:["Latest fit:"," ",(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums",children:[w.score,"/100"]}),w.label&&(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted text-xs",children:[" \xb7 ","from ",(0,Xt.jsx)("span",{className:"italic",children:w.label})]})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-secondary leading-relaxed",children:"Used in your pack \u2014 unlocks NDOR's interview preparation panel (gap-aware questions, repositioning advice, risk briefings) on the pack page."})]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink flex items-center gap-1.5","data-testid":"wizard-review-fit-locked",children:[(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5 text-ndor-gold"}),"Interview Pack unavailable until Analyse Fit is completed for this application workflow."]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-secondary leading-relaxed",children:"Optional \u2014 your pack will still be created. With a valid Variant Fit on the selected tailored CV, the pack page surfaces gap-aware interview questions, repositioning advice, and risk briefings tailored to this role. Source-CV-only packs ship the Baseline Fit instead."}),(0,Xt.jsxs)("button",{type:"button",onClick:j,className:"text-[11px] underline text-ndor-ink-muted hover:text-ndor-ink","data-testid":"wizard-review-back-to-fit",children:["Back to Step 3 \xb7 Run Variant Fit",_]})]})]}),(0,Xt.jsx)("div",{className:"rounded-lg border border-ndor-edge p-3 space-y-1","data-testid":"wizard-review-letter",children:(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-ndor-ink-muted",children:"Cover letter"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink truncate",children:o?c||"Generated cover letter":"Skipped"}),o&&(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted flex items-center gap-1",children:[(0,Xt.jsx)(b_,{className:"h-3 w-3"})," Locked at review"]})]}),o&&(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:b,"data-testid":"wizard-review-preview-letter",children:[(0,Xt.jsx)(zg,{className:"h-3.5 w-3.5 mr-1.5"})," Preview"]})]})}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-ndor-ink-muted mb-1",children:"Notes"}),(0,Xt.jsx)(Hw,{value:m,onChange:e=>p(e.target.value),rows:2,placeholder:"e.g. follow up in 2 weeks","data-testid":"wizard-review-notes"})]})]}),(0,Xt.jsxs)("div",{className:"flex justify-between",children:[(0,Xt.jsxs)(Rr,{variant:"ghost",onClick:f,"data-testid":"wizard-step-4-back",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"})," Back"]}),(0,Xt.jsxs)(Rr,{onClick:x,disabled:h||!d.trim()||g,"data-testid":"wizard-step-4-create",children:[h?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}):(0,Xt.jsx)(Og,{className:"h-4 w-4 mr-1.5"}),"Create application pack \xb7 Free"]})]}),g&&!h&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"wizard-pack-credits-loading-hint",className:"flex items-center gap-2 text-xs text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0"}),(0,Xt.jsx)("span",{children:"Loading your wallet\u2026"})]}),v&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"wizard-pack-progress",className:"flex items-center gap-2 text-xs text-ndor-ink-secondary",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0 text-ndor-ink-muted"}),(0,Xt.jsx)("span",{"data-testid":"wizard-pack-progress-message",children:v})]}),(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2.5 sm:px-4 sm:py-3 text-xs text-ndor-ink-secondary leading-relaxed","data-testid":"wizard-review-value-block",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui mb-1.5",children:"What's in your pack"}),(0,Xt.jsxs)("ul",{className:"list-disc pl-5 space-y-0.5",children:[(0,Xt.jsxs)("li",{children:["An immutable application pack pinned to this job. The pack contains ",(0,Xt.jsx)("strong",{children:"only the artefacts you generated"})," \u2014 your tailored CV and/or cover letter \u2014 plus whichever fit analysis is bound (Source CV Baseline Fit, or a tailored Variant Fit)."]}),(0,Xt.jsx)("li",{children:"Source-CV-only path: pack carries the Source CV reference + Baseline Fit. No variant, no cover letter \u2014 and that's fine."}),(0,Xt.jsx)("li",{children:"Tracking on the Applications page (status, notes, follow-ups)."}),(0,Xt.jsx)("li",{children:"One-click export of whatever the pack contains, when you're ready to apply."}),(0,Xt.jsx)("li",{children:"Any tailored CV and any cover letter stay in your Documents library for re-use on similar roles."}),(0,Xt.jsx)("li",{children:"If a valid Variant Fit exists on the pack's tailored CV, NDOR's Interview Intelligence panel unlocks on the pack page. Source-CV-only packs export the baseline analysis without it."}),(0,Xt.jsx)("li",{children:"You remain in control of submission. NDOR never auto-applies on your behalf."})]})]})]})}function uC(e){let{open:t,onClose:n,title:a,mode:r,data:s,loading:i}=e;return(0,Xt.jsx)(rg,{open:t,onOpenChange:e=>!e&&n(),children:(0,Xt.jsxs)(lg,{className:"max-w-3xl max-h-[80vh] overflow-y-auto","data-testid":"wizard-preview-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[a,(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] tracking-[0.16em] uppercase border-ndor-edge text-ndor-ink-muted",children:[(0,Xt.jsx)(b_,{className:"h-2.5 w-2.5 mr-1"}),"Read-only"]})]}),(0,Xt.jsx)(mg,{className:"sr-only",children:"Read-only preview of the selected document. No edits are possible from this dialog."})]}),i?(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted mx-auto my-6"}):(0,Xt.jsx)(Y_,{mode:r||"source",data:s,showDisclaimer:!0})]})})}function mC(e){var t,n,a,r,i,o,l;let{open:d,onOpenChange:u,job:m,onPackCreated:p}=e;
2const h=ke(),f=null===m||void 0===m?void 0:m.id,[x,v]=(0,s.useState)(0),[g,y]=(0,s.useState)(null),[b,w]=(0,s.useState)(null),[j,k]=(0,s.useState)(null),[N,_]=(0,s.useState)(null),[D,C]=(0,s.useState)(!1),[A,S]=(0,s.useState)(null),[E,F]=(0,s.useState)(""),[R,I]=(0,s.useState)(null),[T,P]=(0,s.useState)(""),[O,B]=(0,s.useState)(!1),[L,M]=(0,s.useState)(""),[z,U]=(0,s.useState)(""),[V,q]=(0,s.useState)(""),[W,H]=(0,s.useState)(!1),G=L_(D,"cv"),K=L_(O,"letter"),Y=L_(W,"pack"),[J,$]=(0,s.useState)(!1),[X,Q]=(0,s.useState)(null),[Z,ee]=(0,s.useState)(!1),[te,ne]=(0,s.useState)(null),[ae,re]=(0,s.useState)(null),[se,ie]=(0,s.useState)(null),[oe,le]=(0,s.useState)(!1),[ce,de]=(0,s.useState)(null),[ue,me]=(0,s.useState)(null),[pe,he]=(0,s.useState)(null),[fe,xe]=(0,s.useState)(null),[ve,ge]=(0,s.useState)(null),[ye,be]=(0,s.useState)(null),[we,je]=(0,s.useState)(null),Ne=If(),[_e,De]=(0,s.useState)(!1),[Ce,Ae]=(0,s.useState)(null),Se=(0,s.useCallback)((e,t)=>{if(!Ne||Ne.loading)return!1;const n=Nf(Ne.usageCosts,e);if(null==n||0===n)return!0;return Number(Ne.includedUsageRemaining||0)+Number(Ne.extraUsageRemaining||0)>=n||(Ae({code:"USAGE_EXHAUSTED",message:"You don't have enough Credits for ".concat(t,"."),action_type:e,required_usage:n,included_usage_remaining:Number(Ne.includedUsageRemaining||0),extra_usage_remaining:Number(Ne.extraUsageRemaining||0),plan_code:Ne.planCode||null}),De(!0),!1)},[Ne]),Ee=!Ne||!!Ne.loading,Fe=(0,s.useRef)(!1),Re=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{Re.current&&(Re.current.abort(),Re.current=null)},[]),(0,s.useEffect)(()=>{if(!d||!f)return;let e=!0;Fe.current=!1;const t=AN(f);if(t){const e=t.stepIdx;let n=0;"number"===typeof e&&(n=e<=1?0:2===e?1:3===e?3:Math.max(0,Math.min(3,e))),v(n),_(t.selectedCv||null),S(t.generatedResult||null),I(t.letterId||null),F(t.letterDraft||""),M(t.letterDraft||""),P(t.letterTitle||""),U(t.packName||""),q(t.notes||""),t.bestFit&&ne(t.bestFit),t.step3LastResult&&de(t.step3LastResult)}else U((null===m||void 0===m||m.title,null===m||void 0===m||m.company,DN()));return Promise.resolve().then(()=>{e&&(Fe.current=!0)}),(async()=>{try{const l=await(0,zt.n)("/api/profile/me"),d=(null===l||void 0===l?void 0:l.primary_cv)||null;if(!e)return;y(d||null),d&&null!==m&&void 0!==m&&m.description;try{const t=await(0,zt.n)("/api/jobs/".concat(f,"/baseline-fit"));var n;if(e&&t)ie(t),null!=(null===(n=t.baseline)||void 0===n?void 0:n.fit_score)&&(w(t.baseline.fit_score),k(t.baseline.evaluated_at),ne(e=>{var n;const a=null!==(n=null===e||void 0===e?void 0:e.score)&&void 0!==n?n:-1;var r,s;return t.baseline.fit_score>a?{score:t.baseline.fit_score,sourceType:"uploaded_cv",sourceId:(null===(r=t.primary_cv)||void 0===r?void 0:r.id)||null,label:(null===(s=t.primary_cv)||void 0===s?void 0:s.filename)||"Source CV"}:e})),t.stale&&re(t.stale)}catch(a){}try{const n=N_(null===d||void 0===d?void 0:d.user_id,f),a=!(!t||!t.generatedResult);if(e&&n&&!a)if(__(n))k_(null===d||void 0===d?void 0:d.user_id,f),fy.info("We couldn't automatically restore your last generated CV. Check Documents \u2192 Variants.");else{const t=await D_(n.title);if(e&&t){const n=t.id||t.variant_id,a=t.title||t.variant_name;if(n&&a){S({variant_id:n,variant_name:a,recovered_inflight:!0}),_({type:"cv_variant",id:n,score:null,name:a,label:"Tailored Variant"}),k_(null===d||void 0===d?void 0:d.user_id,f),fy.success("We restored your generated CV. Just verifying the score\u2026");try{const t=await(0,zt.n)("/api/cv-variants/".concat(n,"/finalize-charge"),{method:"POST",body:{job_id:f}});if(e&&t&&(S((0,c.A)({variant_id:n,variant_name:a},t)),_(e=>{var a;return e&&e.id===n?(0,c.A)((0,c.A)({},e),{},{score:null!==(a=t.cv_sub_score_variant)&&void 0!==a?a:null}):e})),e&&"function"===typeof(null===Ne||void 0===Ne?void 0:Ne.refresh))try{Ne.refresh()}catch(r){}if(e)try{Yk(qk(null===g||void 0===g?void 0:g.user_id,f))}catch(s){}}catch(mK){console.warn("[Wizard] recovered-variant finalize-charge probe failed:",mK)}}}}}catch(i){}try{if(e&&!t.letterId){const t=E_(null===d||void 0===d?void 0:d.user_id,f);if(t&&!F_(t)){const n=await R_(t.title);e&&n&&n.id&&(I(n.id),F(n.content_markdown||""),M(n.content_markdown||""),P(n.title||t.title),S_(null===d||void 0===d?void 0:d.user_id,f),oN(null===d||void 0===d?void 0:d.user_id,f,"cover_letter"),fy.success("We restored your generated cover letter."))}}}catch(o){}}catch(pK){console.warn("[Wizard] bootstrap failed:",pK)}})(),()=>{e=!1}},[d,f,null===m||void 0===m?void 0:m.title,null===m||void 0===m?void 0:m.company,null===m||void 0===m?void 0:m.description]),(0,s.useEffect)(()=>{d&&f&&Fe.current&&function(e,t){if(!e)return;const n=AN(e)||{},a=(0,c.A)((0,c.A)({v:1,jobId:e},n),t);try{sessionStorage.setItem(CN(e),JSON.stringify(a))}catch(r){}}(f,{stepIdx:x,selectedCv:N,generatedResult:A,letterId:R,letterDraft:E,letterTitle:T,packName:z,notes:V,bestFit:te,
2step3LastResult:ce})},[d,f,x,N,A,R,E,T,z,V,te,ce]);const Ie=(0,s.useCallback)(e=>{Ae(e||null),De(!0)},[]),Te=(0,s.useCallback)(async()=>{if(f)try{const e=await(0,zt.n)("/api/jobs/".concat(f,"/best-fit")),t=Array.isArray(null===e||void 0===e?void 0:e.all_cached)?e.all_cached:[];me({jobId:f,primaryCvId:(null===g||void 0===g?void 0:g.id)||null,rows:t,fetchedAt:Date.now()})}catch(e){}},[f,null===g||void 0===g?void 0:g.id]);(0,s.useEffect)(()=>{me(e=>{if(!e)return e;return e.jobId!==f||e.primaryCvId!==((null===g||void 0===g?void 0:g.id)||null)?null:e})},[f,null===g||void 0===g?void 0:g.id]),(0,s.useEffect)(()=>{d&&f&&null!==g&&void 0!==g&&g.id&&Te()},[d,f,null===g||void 0===g?void 0:g.id,Te]),(0,s.useEffect)(()=>{var e,t,n,a,r,s,i,o,l;if(!d||!Fe.current)return;if(ce)return;if(!ue||!Array.isArray(ue.rows))return;if(null===N||void 0===N||!N.id||null===N||void 0===N||!N.type)return;if("base_cv"===N.type)return;const c="cv_variant"===N.type?"cv_variant":"uploaded_cv",u=ue.rows.find(e=>e&&e.source_type===c&&e.source_id===N.id);if(!u)return;const m=u.fit_score,p="number"===typeof m&&m<=1?Math.round(100*m):m;de({newScore:p,previousLatest:null,replaced:!1,analysis:u.reasoning_json||null,sourceType:u.source_type,sourceId:u.source_id,scoreId:null,scoreRow:{score_id:null!==(e=u.score_id)&&void 0!==e?e:null,fit_score:null!==m&&void 0!==m?m:null,final_decision:null!==(t=u.final_decision)&&void 0!==t?t:null,salary_score:null!==(n=u.salary_score)&&void 0!==n?n:null,seniority_score:null!==(a=u.seniority_score)&&void 0!==a?a:null,location_score:null!==(r=u.location_score)&&void 0!==r?r:null,strategic_score:null!==(s=u.strategic_score)&&void 0!==s?s:null,risk_score:null!==(i=u.risk_score)&&void 0!==i?i:null,evaluated_at:null!==(o=u.evaluated_at)&&void 0!==o?o:null,reasoning_json:null!==(l=u.reasoning_json)&&void 0!==l?l:null},cvLabel:u.label||null,_hydratedFromSnapshot:!0});try{const e=P_(null===g||void 0===g?void 0:g.user_id,f);e&&e.sourceType===u.source_type&&e.sourceId===u.source_id&&T_(null===g||void 0===g?void 0:g.user_id,f)}catch(h){}},[d,ue,null===N||void 0===N?void 0:N.id,null===N||void 0===N?void 0:N.type,ce]),(0,s.useEffect)(()=>{if(!d||!Fe.current)return;if(!f||null===g||void 0===g||!g.user_id)return;const e=P_(g.user_id,f);if(!e)return;if(ce&&ce.sourceType===e.sourceType&&ce.sourceId===e.sourceId)return void T_(g.user_id,f);let t=!0,n=0;le(!0);const a=async()=>{if(!t)return;n+=1;try{await Te()}catch(r){}if(!t)return;if(P_(g.user_id,f)){if(n>=10)return T_(g.user_id,f),void(t&&le(!1));setTimeout(a,8e3)}else{le(!1);try{var e;null===Ne||void 0===Ne||null===(e=Ne.refresh)||void 0===e||e.call(Ne)}catch(s){}}};return setTimeout(a,8e3),()=>{t=!1}},[d,f,null===g||void 0===g?void 0:g.user_id,Fe.current]);const Pe=async function(){let{sourceTypeOverride:e,sourceIdOverride:t,forceOverride:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const a=null!==e&&void 0!==e?e:"cv_variant"===(null===N||void 0===N?void 0:N.type)?"cv_variant":"uploaded_cv",r=null!==t&&void 0!==t?t:null===N||void 0===N?void 0:N.id;if(!r)return void fy.error("Select a CV in Step 2 first.");const s="cv_variant"===a?"variantFitGuard:".concat((null===g||void 0===g?void 0:g.user_id)||"",":").concat(f,":").concat(r):null;if(s)try{const e=sessionStorage.getItem(s);if(e){const t=JSON.parse(e),n=Number(null===t||void 0===t?void 0:t.cachedAt)||0;if(n&&Date.now()-n<18e5&&null!==t&&void 0!==t&&t.payload){var i,o,l,d,u,m,p,h,x,v,y,b,w,j,k,_,D;const e=t.payload,n=null!==(i=null!==(o=null===e||void 0===e||null===(l=e.analysis)||void 0===l?void 0:l.fit_score)&&void 0!==o?o:null===e||void 0===e||null===(d=e.score)||void 0===d?void 0:d.fit_score)&&void 0!==i?i:null,s=null!=n&&n<=1?Math.round(100*n):n;return de({newScore:s,previousLatest:null!==(u=null===te||void 0===te?void 0:te.score)&&void 0!==u?u:null,replaced:null!=s,analysis:(null===e||void 0===e?void 0:e.analysis)||null,sourceType:a,sourceId:r,scoreId:null,scoreRow:null!==e&&void 0!==e&&e.score?{score_id:null!==(m=e.score.id)&&void 0!==m?m:null,fit_score:null!==(p=e.score.fit_score)&&void 0!==p?p:null,final_decision:null!==(h=e.score.final_decision)&&void 0!==h?h:null,salary_score:null!==(x=e.score.salary_score)&&void 0!==x?x:null,seniority_score:null!==(v=e.score.seniority_score)&&void 0!==v?v:null,location_score:null!==(y=e.score.location_score)&&void 0!==y?y:null,
2strategic_score:null!==(b=e.score.strategic_score)&&void 0!==b?b:null,risk_score:null!==(w=e.score.risk_score)&&void 0!==w?w:null,evaluated_at:null!==(j=null!==(k=e.score.evaluated_at)&&void 0!==k?k:e.score.created_at)&&void 0!==j?j:null,reasoning_json:null!==(_=null!==(D=e.score.reasoning_json)&&void 0!==D?D:e.analysis)&&void 0!==_?_:{}}:null}),void fy.info("Reused your last variant Analyse Fit (within 30 min).")}}}catch(ae){}if(!Se("analyze_fit","Analyse Fit on selected CV"))return;le(!0),function(e,t,n){let{sourceType:a,sourceId:r}=n;if(t&&a&&r)try{sessionStorage.setItem(I_(e,t),JSON.stringify({submittedAtMs:Date.now(),sourceType:a,sourceId:r,startedAt:(new Date).toISOString()}))}catch(s){}}(null===g||void 0===g?void 0:g.user_id,f,{sourceType:a,sourceId:r});const C=hN(null===g||void 0===g?void 0:g.user_id,f,"analyse_fit").idempotencyKey;try{var A,S,E,F,R,I,T,P,O,B,L,M,z,U,V,q,W,H,G,K,Y,J,$;Re.current&&Re.current.abort(),Re.current=new AbortController;const e=await Bk(f,(0,c.A)({source_type:a,source_id:r,idempotency_key:C},n?{force_override:!0}:{}),{signal:Re.current.signal,onRecoveryState:e=>{"checking"===e?fy.info("This is taking longer than usual. We're checking your results..."):"recovered"===e&&fy.success("Your fit analysis was completed in the background.")}});fN(null===g||void 0===g?void 0:g.user_id,f,"analyse_fit");const t=null!==(A=null!==(S=null===e||void 0===e||null===(E=e.analysis)||void 0===E?void 0:E.fit_score)&&void 0!==S?S:null===e||void 0===e||null===(F=e.score)||void 0===F?void 0:F.fit_score)&&void 0!==A?A:null,i=null!=t&&t<=1?Math.round(100*t):t,o=null!==(R=null===te||void 0===te?void 0:te.score)&&void 0!==R?R:null;let l=null!=i;if(l&&ne({score:i,sourceType:a,sourceId:r,label:(null===N||void 0===N?void 0:N.label)||("cv_variant"===a?"CV variant":"Source CV")}),de({newScore:i,previousLatest:o,replaced:l,analysis:(null===e||void 0===e?void 0:e.analysis)||null,sourceType:a,sourceId:r,scoreId:!0===(null===e||void 0===e||null===(I=e.billing)||void 0===I?void 0:I.cached)?null:null!==(T=null===e||void 0===e||null===(P=e.score)||void 0===P?void 0:P.id)&&void 0!==T?T:null,scoreRow:null!==e&&void 0!==e&&e.score?{score_id:null!==(O=e.score.id)&&void 0!==O?O:null,fit_score:null!==(B=e.score.fit_score)&&void 0!==B?B:null,final_decision:null!==(L=e.score.final_decision)&&void 0!==L?L:null,salary_score:null!==(M=e.score.salary_score)&&void 0!==M?M:null,seniority_score:null!==(z=e.score.seniority_score)&&void 0!==z?z:null,location_score:null!==(U=e.score.location_score)&&void 0!==U?U:null,
2strategic_score:null!==(V=e.score.strategic_score)&&void 0!==V?V:null,risk_score:null!==(q=e.score.risk_score)&&void 0!==q?q:null,evaluated_at:null!==(W=null!==(H=e.score.evaluated_at)&&void 0!==H?H:e.score.created_at)&&void 0!==W?W:null,reasoning_json:null!==(G=null!==(K=e.score.reasoning_json)&&void 0!==K?K:e.analysis)&&void 0!==G?G:{}}:null}),Ht("analyze_fit_run",{cached:!(null===e||void 0===e||null===(Y=e.billing)||void 0===Y||!Y.cached),new_score:i,replaced:l,source_type:a}),aC("analyze_fit"),s&&null!=i)try{sessionStorage.setItem(s,JSON.stringify({cachedAt:Date.now(),payload:e}))}catch(re){}f&&nw("jobs:by-id:".concat(f)),nw(["jobs:list"]),fy.success(null!==e&&void 0!==e&&null!==(J=e.billing)&&void 0!==J&&J.cached?"Existing Analyse Fit loaded.":"Analyse Fit complete \u2014 your latest score for this job."),null===Ne||void 0===Ne||null===($=Ne.refresh)||void 0===$||$.call(Ne);try{Yk(Wk(null===g||void 0===g?void 0:g.user_id,f,r))}catch(se){}Te(),xN(null===g||void 0===g?void 0:g.user_id,f,"analyse_fit"),yN(null===g||void 0===g?void 0:g.user_id,f,"analyse_fit"),he(null)}catch(pK){var X,Q,Z,ee;if("AbortError"===(null===pK||void 0===pK?void 0:pK.name))return;const t=null===pK||void 0===pK||null===(X=pK.data)||void 0===X||null===(Q=X.detail)||void 0===Q?void 0:Q.code;if(409===(null===pK||void 0===pK?void 0:pK.status)&&("INFERIOR_SOURCE"===t||"INFERIOR_VARIANT"===t))return void he({code:t,guidance:pK.data.detail.guidance||{}});if(Gw(pK,{action:"Analyse Fit",onExhausted:Ie,refreshCredits:null===Ne||void 0===Ne?void 0:Ne.refresh}))return;fy.error((null===pK||void 0===pK||null===(Z=pK.data)||void 0===Z||null===(ee=Z.detail)||void 0===ee?void 0:ee.message)||(null===pK||void 0===pK?void 0:pK.message)||"Analyse Fit failed.")}finally{le(!1),xe(null),T_(null===g||void 0===g?void 0:g.user_id,f)}},[Oe,Be]=(0,s.useState)(!1),Le=e=>{var t,n,a;if(e.template_type===VD.template_type&&e.tone_type===VD.tone_type&&e.length_preference===VD.length_preference)return"";const r=(null===(t=HD.find(t=>t.value===e.template_type))||void 0===t?void 0:t.label)||e.template_type,s=(null===(n=GD.find(t=>t.value===e.tone_type))||void 0===n?void 0:n.label)||e.tone_type,i=(null===(a=KD.find(t=>t.value===e.length_preference))||void 0===a?void 0:a.label)||e.length_preference;return" \xb7 ".concat(r," \xb7 ").concat(s," \xb7 ").concat(i)},Me=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=NN({role:null===m||void 0===m?void 0:m.title,suffix:Le(e)});j_(null===g||void 0===g?void 0:g.user_id,f,r);const s=iN(null===g||void 0===g?void 0:g.user_id,f,"cv_variant"),i=await Jw({kind:"cv",jobId:f,onRecoveryState:e=>{"checking"===e?fy.info("This is taking longer than usual. We're checking your results..."):"recovered"===e?fy.success("Your result was completed successfully."):"failed"===e&&fy.warning("We're unable to confirm the result reached you. Before clicking Generate again, please open Documents \u2192 CV Variants \u2014 your document may already be there.",{duration:9e3})},generate:()=>(0,zt.n)("/api/cv-variants/generate",{method:"POST",body:{base_cv_id:g.id,job_id:f,job_text:m.description,title:r,template_type:e.template_type,tone_type:e.tone_type,length_preference:e.length_preference,additional_cv_context:e.additional_cv_context||"",force_generate:!!n,high_cv_generate_confirmed:!!a,idempotency_key:s}})}),o=(null===i||void 0===i?void 0:i.variant_id)||(null===i||void 0===i?void 0:i.id);if(!o)throw new Error("Variant id missing in response.");const l={job_id:f};t&&(l.refresh_decision=t);const c=await(0,zt.n)("/api/cv-variants/".concat(o,"/finalize-charge"),{method:"POST",body:l});return oN(null===g||void 0===g?void 0:g.user_id,f,"cv_variant"),{variant:i,variantId:o,charge:c}},ze=async(e,t)=>{try{const t=await(0,zt.n)("/api/jobs/".concat(f,"/baseline-status"));if("stale_refresh_available"===(null===t||void 0===t?void 0:t.baseline_status))return void ge({baseline_version:t.baseline_version,current_version:t.current_version,opts:e})}catch(mK){console.warn("[RC 1.47.2] baseline-status pre-flight failed:",(null===mK||void 0===mK?void 0:mK.message)||mK)}C(!0);try{let d,u=!1;try{const e=await(0,zt.n)("/api/application-packs?job_id=".concat(encodeURIComponent(f),"&page_size=1"));u=(Array.isArray(e)?e:(null===e||void 0===e?void 0:e.items)||[]).some(e=>(null===e||void 0===e?void 0:e.job_id)===f&&!(null===e||void 0===e||!e.cv_variant_id))}catch(m){}try{d=await Me(e,null,u,t)}catch(mK){var n,a,r,s,i,o,l,c;if(409===(null===mK||void 0===mK?void 0:mK.status)&&"BASELINE_VERSION_STALE"===(null===mK||void 0===mK||null===(n=mK.data)||void 0===n||null===(a=n.detail)||void 0===a?void 0:a.code))return void ge({baseline_version:mK.data.detail.baseline_version,current_version:mK.data.detail.current_version,opts:e});if(409===(null===mK||void 0===mK?void 0:mK.status)&&"analyse_fit_reject"===(null===mK||void 0===mK||null===(r=mK.data)||void 0===r||null===(s=r.detail)||void 0===s?void 0:s.error))return void be({fit_score:null!==(i=mK.data.detail.fit_score)&&void 0!==i?i:null,cv_sub_score:null!==(o=mK.data.detail.cv_sub_score)&&void 0!==o?o:null,threshold:null!==(l=mK.data.detail.threshold)&&void 0!==l?l:null,final_decision:null!==(c=mK.data.detail.final_decision)&&void 0!==c?c:null,opts:e});throw mK}const p=Nf(Ne.usageCosts,"cv_improve"),h=null==p?"Credits":"".concat(p," ").concat(1===p?"Credit":"Credits");Ue(d,h)}catch(pK){var d,u;if(Gw(pK,{action:"Generate CV",onExhausted:Ie,refreshCredits:null===Ne||void 0===Ne?void 0:Ne.refresh}))return;const t=z_(pK,"cv");fy.error(t||(null===pK||void 0===pK||null===(d=pK.data)||void 0===d||null===(u=d.detail)||void 0===u?void 0:u.message)||(null===pK||void 0===pK?void 0:pK.message)||"Generation failed.")}finally{C(!1)}},Ue=(e,t)=>{var n,a;let{variant:r,variantId:s,charge:i}=e;const o=(0,c.A)({variant_id:s,variant_name:r.variant_name},i);var l;if(S(o),k_(null===g||void 0===g?void 0:g.user_id,f),_({type:"cv_variant",id:s,score:null!==(n=i.cv_sub_score_variant)&&void 0!==n?n:null,name:r.variant_name,label:"Tailored Variant"}),i.charged)if("cv_quality_improved"===i.reason)fy.success("Material improvement achieved \u2014 ".concat(t," charged (\u0394 +").concat(null!==(l=i.delta)&&void 0!==l?l:"?"," pts vs Source CV)."));else if("presentation_optimisation_high_cv"===i.reason){var d,u,m;const e=null!==(d=i.charge_percentage)&&void 0!==d?d:50;fy.info("Presentation optimisation applied \u2014 ".concat(e,"% of ").concat(t," charged (Source CV already \u226580; \u0394 ").concat((null!==(u=i.delta)&&void 0!==u?u:0)>=0?"+":"").concat(null!==(m=i.delta)&&void 0!==m?m:0," pts)."))}else"no_baseline_protection"===i.reason?i.stale_baseline_ignored?fy.info("".concat(t," charged \u2014 prior baseline was outdated and was not used for this comparison.")):fy.success("Tailoring complete \u2014 ".concat(t," charged (no Analyse Fit baseline existed).")):fy.success("Tailoring complete \u2014 ".concat(t," charged."));else if("within_tolerance_band"===i.reason){var p,h,x;fy.success("Within NDOR confidence band \u2014 no charge (\u0394 ".concat((null!==(p=i.delta)&&void 0!==p?p:0)>=0?"+":"").concat(null!==(h=i.delta)&&void 0!==h?h:0," pts, \xb1").concat(null!==(x=i.tolerance_band)&&void 0!==x?x:5,")."))}
2else"cv_quality_no_improvement"===i.reason?fy.success("No material uplift detected \u2014 generated CV did not exceed your Source CV. No Credits charged."):fy.success("Tailoring complete \u2014 no charge.");Ht("tailored_cv_generated",{charged:!!i.charged,reason:i.reason||null,baseline_status:i.baseline_status||null,stale_baseline_ignored:!!i.stale_baseline_ignored}),aC("tailored_cv"),Be(!1),null===Ne||void 0===Ne||null===(a=Ne.refresh)||void 0===a||a.call(Ne);try{Yk(qk(null===g||void 0===g?void 0:g.user_id,f))}catch(v){}nw(["cv-variants:all","jobs","dashboard:bundle"]),Te()},Ve=(0,s.useCallback)(async()=>{if(R&&E!==L)try{await(0,zt.n)("/api/cover-letters/".concat(R),{method:"PATCH",body:{content_markdown:E}}),M(E)}catch(e){}},[R,E,L]),qe=(0,s.useCallback)(async()=>{1===x&&await Ve(),v(e=>Math.min(e+1,rC.length-1))},[x,Ve]),We={hasTailoredCv:"cv_variant"===(null===N||void 0===N?void 0:N.type),hasCoverLetter:!!R,hasVariantFit:!("cv_variant"!==(null===N||void 0===N?void 0:N.type)||"cv_variant"!==(null===ce||void 0===ce?void 0:ce.sourceType)||(null===ce||void 0===ce?void 0:ce.sourceId)!==N.id),hasBaselineAnchor:!(null===g||void 0===g||!g.id)},He=async()=>{if(null!==N&&void 0!==N&&N.id&&null!==g&&void 0!==g&&g.id&&Se("application_pack","Create application pack")){H(!0);try{var e,t,n,a,r,s,i,o,l,c,d,m,x,v,y;const H=(null===ce||void 0===ce?void 0:ce.sourceType)&&(null===ce||void 0===ce?void 0:ce.sourceId)&&("cv_variant"===ce.sourceType&&"cv_variant"===N.type&&ce.sourceId===N.id||"uploaded_cv"===ce.sourceType&&"base_cv"===N.type&&ce.sourceId===N.id);let K=!(!H||null===ce||void 0===ce||!ce.scoreId)?ce.scoreId:null;const Y=null==K&&"base_cv"===N.type&&(null===se||void 0===se||null===(e=se.baseline)||void 0===e?void 0:e.score_id)&&(null===se||void 0===se||null===(t=se.primary_cv)||void 0===t?void 0:t.id)&&(null===g||void 0===g?void 0:g.id)&&se.primary_cv.id===g.id;Y&&(K=se.baseline.score_id);let J=null;if(H&&null!==ce&&void 0!==ce&&ce.scoreRow)J=ce.scoreRow;else if(Y){var b,w,j,k,_,D,C,S,E,F,I,T,P,O,B,L,M,U,q,W,G;const e=se.baseline;J={score_id:null!==(b=e.score_id)&&void 0!==b?b:null,fit_score:null!==(w=e.fit_score)&&void 0!==w?w:null,final_decision:null!==(j=e.final_decision)&&void 0!==j?j:null,salary_score:null!==(k=null!==(_=e.salary_score)&&void 0!==_?_:null===(D=e.sub_scores)||void 0===D?void 0:D.salary)&&void 0!==k?k:null,seniority_score:null!==(C=null!==(S=e.seniority_score)&&void 0!==S?S:null===(E=e.sub_scores)||void 0===E?void 0:E.seniority)&&void 0!==C?C:null,location_score:null!==(F=null!==(I=e.location_score)&&void 0!==I?I:null===(T=e.sub_scores)||void 0===T?void 0:T.location)&&void 0!==F?F:null,strategic_score:null!==(P=null!==(O=e.strategic_score)&&void 0!==O?O:null===(B=e.sub_scores)||void 0===B?void 0:B.strategic)&&void 0!==P?P:null,risk_score:null!==(L=null!==(M=e.risk_score)&&void 0!==M?M:null===(U=e.sub_scores)||void 0===U?void 0:U.risk)&&void 0!==L?L:null,evaluated_at:null!==(q=e.evaluated_at)&&void 0!==q?q:null,reasoning_json:null!==(W=null!==(G=e.reasoning_json)&&void 0!==G?G:e.reasoning)&&void 0!==W?W:{}}}const $=(()=>{if("cv_variant"===N.type){const e=null===A||void 0===A?void 0:A.cv_sub_score_variant;if(null!=e)return{cv_sub_score:e,cv_sub_score_provisional:!(null===A||void 0===A||!A.cv_sub_score_provisional)}}if("base_cv"===N.type){var e,t,n,a,r;const s=null!==(e=null!==(t=null===se||void 0===se||null===(n=se.baseline)||void 0===n||null===(a=n.reasoning_json)||void 0===a?void 0:a.cv_sub_score)&&void 0!==t?t:null===se||void 0===se||null===(r=se.baseline)||void 0===r?void 0:r.cv_sub_score)&&void 0!==e?e:null;if(null!=s)return{cv_sub_score:s,cv_sub_score_provisional:!1}}return null})(),X=null!==se&&void 0!==se&&null!==(n=se.baseline)&&void 0!==n&&n.score_id&&(null===se||void 0===se||null===(a=se.primary_cv)||void 0===a?void 0:a.id)===(null===g||void 0===g?void 0:g.id)?{score_id:se.baseline.score_id,fit_score:null!==(r=se.baseline.fit_score)&&void 0!==r?r:null,evaluated_at:null!==(s=se.baseline.evaluated_at)&&void 0!==s?s:null,cv_sub_score:null!==(i=null!==(o=null===se||void 0===se||null===(l=se.baseline)||void 0===l||null===(c=l.reasoning_json)||void 0===c?void 0:c.cv_sub_score)&&void 0!==o?o:null===se||void 0===se||null===(d=se.baseline)||void 0===d?void 0:d.cv_sub_score)&&void 0!==i?i:null,cv_sub_score_provisional:!!(null!==(m=null===se||void 0===se||null===(x=se.baseline)||void 0===x||null===(v=x.reasoning_json)||void 0===v?void 0:v.cv_sub_score_provisional)&&void 0!==m?m:null===se||void 0===se||null===(y=se.baseline)||void 0===y?void 0:y.cv_sub_score_provisional)}
2:null,Q={version:1,captured_at:(new Date).toISOString(),binding:{cv_kind:"cv_variant"===N.type?"tailored_variant":"source_cv",cv_variant_id:"cv_variant"===N.type?N.id:null,base_cv_id:g.id,cv_label:N.label||null},fit:J,cv_verdict:$,source_baseline:X},Z={job_id:f,base_cv_id:g.id,cv_variant_id:"cv_variant"===N.type?N.id:null,cover_letter_id:R||null,analyse_fit_id:K,pack_status:"draft",pack_name:z.trim(),notes:V,pack_snapshot:Q},ee=await(0,zt.n)("/api/application-packs",{method:"POST",body:Z});SN(f),u(!1),null===p||void 0===p||p(ee),fy.success("Application pack created."),Ht("application_pack_generated",{has_cover_letter:!!R,used_variant:"cv_variant"===N.type}),aC("application_pack"),nw(["applications","application-packs:all","jobs","dashboard:bundle"]),h("/applications?highlight=".concat(encodeURIComponent(ee.id)))}catch(pK){var K,Y,J,$;if(Gw(pK,{action:"Create application pack",onExhausted:Ie,refreshCredits:null===Ne||void 0===Ne?void 0:Ne.refresh}))return;const t=(null===pK||void 0===pK?void 0:pK.status)||(null===pK||void 0===pK||null===(K=pK.response)||void 0===K?void 0:K.status),n=null===pK||void 0===pK||null===(Y=pK.data)||void 0===Y?void 0:Y.detail;if(409===t&&n&&"object"===typeof n&&"duplicate_active_pack"===n.error&&n.existing_pack_id){const e=n.existing_pack_id;return fy.info(n.message||"You already have an active pack for this job.",{action:{label:"Open existing pack",onClick:()=>h("/applications/".concat(e))}}),SN(f),void u(!1)}fy.error((null===pK||void 0===pK||null===(J=pK.data)||void 0===J||null===($=J.detail)||void 0===$?void 0:$.message)||z_(pK,"pack")||(null===pK||void 0===pK?void 0:pK.message)||"Failed to create pack.")}finally{H(!1)}}},[Ge,Ke]=(0,s.useState)(!1),Ye=!!D||!!O||!!oe||!!W;return(0,s.useEffect)(()=>{if(!d||!Ye)return;const e=e=>(e.preventDefault(),e.returnValue="","");return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[d,Ye]),(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(rg,{open:d,onOpenChange:e=>{e||!Ye?u(e):Ke(!0)},children:(0,Xt.jsxs)(lg,{className:"max-w-2xl max-h-[92vh] sm:max-h-[90vh] overflow-y-auto p-4 sm:p-6","data-testid":"job-application-wizard",children:[(0,Xt.jsxs)(cg,{className:"space-y-2 sm:space-y-3 pb-2 sm:pb-3",children:[(0,Xt.jsx)(ug,{className:"text-base sm:text-lg",children:"Apply to this job"}),(0,Xt.jsx)(mg,{className:"sr-only",children:"Forward-only 4-step application flow: choose or generate a tailored CV (or use your Source CV), optionally generate a cover letter, optionally run Variant Fit on a tailored CV, then review and create the application pack. Each step is optional except CV selection. You remain in control \u2014 NDOR never auto-applies on your behalf."}),(0,Xt.jsx)(iC,{stepIdx:x})]}),0===x&&(0,Xt.jsx)(oC,{job:m,primaryCv:g,sourceFitNdor:b,sourceCvVerdict:null!==(t=null===se||void 0===se||null===(n=se.baseline)||void 0===n||null===(a=n.sub_scores)||void 0===a?void 0:a.cv_sub_score)&&void 0!==t?t:null,hasBaselineFit:null!=b,jobId:f,selectedCv:N,onSelectCv:_,generating:D,onGenerate:()=>{var e;null!==g&&void 0!==g&&g.id?null!==m&&void 0!==m&&null!==(e=m.description)&&void 0!==e&&e.trim()?Se("cv_improve","Generate CV")&&Be(!0):fy.error("Job has no description text."):fy.error("No Source CV.")},progressMessage:G,creditsLoading:Ee,generatedResult:A,onPreviewVariant:(e,t)=>(async(e,t)=>{if(e){ee(!0),Q({title:t||"Variant",mode:"variant",data:null});try{const n=await(0,zt.n)("/api/cv-variants/".concat(e));Q({title:n.variant_name||t||"Variant",mode:"variant",data:n})}catch(pK){Q({title:"Preview unavailable",mode:"variant",data:{content_markdown:(null===pK||void 0===pK?void 0:pK.message)||""}})}finally{ee(!1)}}})(e,t),onBack:()=>u(!1),onContinue:qe}),1===x&&(0,Xt.jsx)(cC,{letterDraft:E,setLetterDraft:F,generating:O,onGenerate:async()=>{var e;if(null!==m&&void 0!==m&&null!==(e=m.description)&&void 0!==e&&e.trim()){if(Se("cover_letter","Generate cover letter")){B(!0);try{var t;const e="cv_variant"===(null===N||void 0===N?void 0:N.type)?N.id:null,n=_N({company:null===m||void 0===m?void 0:m.company}),a=iN(null===g||void 0===g?void 0:g.user_id,f,"cover_letter");A_(null===g||void 0===g?void 0:g.user_id,f,n);const r=await Jw({kind:"letter",jobId:f,onRecoveryState:e=>{"checking"===e?fy.info("This is taking longer than usual. We're checking your results..."):"recovered"===e?fy.success("Your result was completed successfully."):"failed"===e&&fy.warning("We're unable to confirm the result reached you. Before clicking Generate again, please open Documents \u2192 Cover Letters \u2014 your document may already be there.",{duration:9e3})},generate:()=>(0,zt.n)("/api/cover-letters/generate",{method:"POST",body:{job_text:m.description,title:n,base_cv_id:null===g||void 0===g?void 0:g.id,cv_variant_id:e,tone_type:"analytical",idempotency_key:a}})}),s=(null===r||void 0===r?void 0:r.cover_letter_id)||(null===r||void 0===r?void 0:r.id),i=(null===r||void 0===r?void 0:r.generated_text)||(null===r||void 0===r?void 0:r.content_markdown)||"";I(s),F(i),M(i),P((null===r||void 0===r?void 0:r.title)||n),oN(null===g||void 0===g?void 0:g.user_id,f,"cover_letter"),S_(null===g||void 0===g?void 0:g.user_id,f),nw(["cover-letters:all","dashboard:bundle"]),fy.success("Cover letter generated."),Ht("cover_letter_generated"),aC("cover_letter"),null===Ne||void 0===Ne||null===(t=Ne.refresh)||void 0===t||t.call(Ne)}catch(pK){var n,a;if(Gw(pK,{action:"Generate cover letter",onExhausted:Ie,refreshCredits:null===Ne||void 0===Ne?void 0:Ne.refresh}))return;const t=z_(pK,"letter");fy.error(t||(null===pK||void 0===pK||null===(n=pK.data)||void 0===n||null===(a=n.detail)||void 0===a?void 0:a.message)||(null===pK||void 0===pK?void 0:pK.message)||"Cover letter generation failed.")}finally{B(!1)}}}else fy.error("Job has no description text.")},progressMessage:K,creditsLoading:Ee,hasLetter:!!R,onSkip:()=>{I(null),F(""),P(""),v(2)},onBack:()=>v(0),onContinue:qe}),2===x&&(0,Xt.jsx)(lC,{jobId:f,selectedCv:N,onAnalyse:Pe,analysing:oe,bestFit:te,lastResult:ce,baselineFit:se,creditsLoading:Ee,userId:null===g||void 0===g?void 0:g.user_id,onBack:()=>v(1),onContinue:qe}),3===x&&(0,Xt.jsx)(dC,{job:m,primaryCv:g,fitScore:b,fitDate:j,selectedCv:N,generatedResult:A,letterId:R,letterDraft:E,letterTitle:T,packName:z,setPackName:U,notes:V,setNotes:q,creating:W,onBack:()=>v(2),onCreate:()=>{null!==N&&void 0!==N&&N.id&&null!==g&&void 0!==g&&g.id&&Se("application_pack","Create application pack")&&$(!0)},progressMessage:Y,creditsLoading:Ee,onPreviewCv:async()=>
2{if(N&&"cv_variant"===N.type){ee(!0),Q({title:(null===N||void 0===N?void 0:N.name)||"Variant",mode:"variant",data:null});try{const e=await(0,zt.n)("/api/cv-variants/".concat(N.id));Q({title:e.variant_name||"Variant",mode:"variant",data:e})}catch(pK){Q({title:"Preview unavailable",mode:"variant",data:{content_markdown:(null===pK||void 0===pK?void 0:pK.message)||""}})}finally{ee(!1)}}},onPreviewLetter:()=>{Q({title:T||"Cover letter",mode:"letter",data:{content_markdown:E||""}})},bestFit:te,onBackToFitStep:()=>v(2)})]})}),(0,Xt.jsx)(uC,{open:!!X,onClose:()=>Q(null),title:null===X||void 0===X?void 0:X.title,mode:null===X||void 0===X?void 0:X.mode,data:null===X||void 0===X?void 0:X.data,loading:Z}),(0,Xt.jsx)(Q_,{open:_e,onClose:()=>De(!1),planCode:(null===Ce||void 0===Ce?void 0:Ce.plan_code)||(null===Ne||void 0===Ne?void 0:Ne.planCode)||null,action:(null===Ce||void 0===Ce?void 0:Ce.action_type)||null,required:null!==(r=null===Ce||void 0===Ce?void 0:Ce.required_usage)&&void 0!==r?r:null,availableIncluded:null!==(i=null===Ce||void 0===Ce?void 0:Ce.included_usage_remaining)&&void 0!==i?i:null,availableExtra:null!==(o=null===Ce||void 0===Ce?void 0:Ce.extra_usage_remaining)&&void 0!==o?o:null}),(0,Xt.jsx)(Z_,{open:Boolean(pe),code:(null===pe||void 0===pe?void 0:pe.code)||null,guidance:(null===pe||void 0===pe?void 0:pe.guidance)||{},onClose:()=>he(null),onStayWithSourceCv:async()=>{var e;xe("stay");const t=null===pe||void 0===pe||null===(e=pe.guidance)||void 0===e?void 0:e.primary_cv_id;if(!t)return fy.error("Could not resolve your primary Source CV."),void xe(null);await Pe({sourceTypeOverride:"uploaded_cv",sourceIdOverride:t})},onChooseStrongerCv:()=>{he(null),v(0)},onGenerateNewCv:()=>{he(null),v(0)},onContinueAnyway:async()=>{xe("continue"),await Pe({forceOverride:!0})},busyAction:fe}),(0,Xt.jsx)(WD,{open:Oe,onOpenChange:Be,onConfirm:async e=>{var t,n,a;if(null===g||void 0===g||!g.id)return void fy.error("No Source CV.");if(null===m||void 0===m||null===(t=m.description)||void 0===t||!t.trim())return void fy.error("Job has no description text.");if(!Se("cv_improve","Generate CV"))return;const r={template_type:(null===e||void 0===e?void 0:e.template_type)||VD.template_type,tone_type:(null===e||void 0===e?void 0:e.tone_type)||VD.tone_type,length_preference:(null===e||void 0===e?void 0:e.length_preference)||VD.length_preference,additional_cv_context:((null===e||void 0===e?void 0:e.additional_cv_context)||"").trim()},s=null===se||void 0===se||null===(n=se.baseline)||void 0===n||null===(a=n.sub_scores)||void 0===a?void 0:a.cv_sub_score;let i=!1;try{i="1"===sessionStorage.getItem(sC(f))}catch(o){}"number"===typeof s&&s>=80&&!i?je({source_cv_score:s,opts:r}):await ze(r,!1)},generating:D}),(0,Xt.jsx)(JD,{open:J,onOpenChange:e=>{W||$(e)},composition:We,creating:W,onCancel:()=>$(!1),onConfirm:()=>{$(!1),He()}}),(0,Xt.jsx)(eD,{open:Boolean(ve),onOpenChange:e=>!e&&ge(null),baselineVersion:null===ve||void 0===ve?void 0:ve.baseline_version,currentVersion:null===ve||void 0===ve?void 0:ve.current_version,onRefresh:async()=>{if(!ve)return;const e=ve;try{await(0,zt.n)("/api/jobs/".concat(f,"/refresh-baseline"),{method:"POST"}),fy.success("Baseline refreshed \u2014 no Credits charged.")}catch(mK){var t,n;return void fy.error((null===mK||void 0===mK||null===(t=mK.data)||void 0===t||null===(n=t.detail)||void 0===n?void 0:n.message)||(null===mK||void 0===mK?void 0:mK.message)||"Baseline refresh failed.")}ge(null),C(!0);try{const t=await Me(e.opts,"refreshed"),n=Nf(Ne.usageCosts,"cv_improve"),a=null==n?"Credits":"".concat(n," ").concat(1===n?"Credit":"Credits");Ue(t,a)}catch(pK){var a,r;if(Gw(pK,{action:"Generate CV",onExhausted:Ie,refreshCredits:null===Ne||void 0===Ne?void 0:Ne.refresh}))return;const t=z_(pK,"cv");fy.error(t||(null===pK||void 0===pK||null===(a=pK.data)||void 0===a||null===(r=a.detail)||void 0===r?void 0:r.message)||(null===pK||void 0===pK?void 0:pK.message)||"Generation failed.")}finally{C(!1)}},onDecline:async()=>{if(!ve)return;const e=ve;ge(null),C(!0);try{const t=await Me(e.opts,"declined"),n=Nf(Ne.usageCosts,"cv_improve"),a=null==n?"Credits":"".concat(n," ").concat(1===n?"Credit":"Credits");Ue(t,a)}catch(pK){var t,n;if(Gw(pK,{action:"Generate CV",onExhausted:Ie,refreshCredits:null===Ne||void 0===Ne?void 0:Ne.refresh}))return;const a=z_(pK,"cv");fy.error(a||(null===pK||void 0===pK||null===(t=pK.data)||void 0===t||null===(n=t.detail)||void 0===n?void 0:n.message)||(null===pK||void 0===pK?void 0:pK.message)||"Generation failed.")}finally{C(!1)}},onCancel:()=>ge(null)}),(0,Xt.jsx)(rg,{open:Boolean(ye),onOpenChange:e=>!e&&be(null),children:(0,Xt.jsxs)(lg,{className:"sm:max-w-md","data-testid":"wizard-reject-warn-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"wizard-reject-warn-title",children:"Low fit detected \u2014 generate anyway?"}),(0,Xt.jsxs)(mg,{"data-testid":"wizard-reject-warn-description",className:"text-sm text-ndor-ink-secondary",children:["Your latest Source CV Analyse Fit for this role landed",null!=(null===ye||void 0===ye?void 0:ye.fit_score)?(0,Xt.jsxs)(Xt.Fragment,{children:[" at ",(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums",children:[ye.fit_score,"/100"]})]}):(0,Xt.jsx)(Xt.Fragment,{children:" in the low-fit band"})," ","with a verdict of"," ",(0,Xt.jsx)("span",{className:"font-medium",children:(null===ye||void 0===ye?void 0:ye.final_decision)||"reject"}),". NDORFlow governance treats this as a directional signal \u2014 not a hard block. You can still generate a tailored CV if you have additional context to add or simply want to proceed."]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2 mt-2",children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:()=>{be(null)},disabled:D,"data-testid":"wizard-reject-warn-cancel",children:"Cancel"}),(0,Xt.jsxs)(Rr,{onClick:async()=>
2{if(!ye)return;const e=ye;be(null),C(!0);try{const t=await Me(e.opts,null,!0),n=Nf(Ne.usageCosts,"cv_improve"),a=null==n?"Credits":"".concat(n," ").concat(1===n?"Credit":"Credits");Ue(t,a)}catch(pK){var t,n;if(Gw(pK,{action:"Generate CV",onExhausted:Ie,refreshCredits:null===Ne||void 0===Ne?void 0:Ne.refresh}))return;const a=z_(pK,"cv");fy.error(a||(null===pK||void 0===pK||null===(t=pK.data)||void 0===t||null===(n=t.detail)||void 0===n?void 0:n.message)||(null===pK||void 0===pK?void 0:pK.message)||"Generation failed.")}finally{C(!1)}},disabled:D,"data-testid":"wizard-reject-warn-confirm",children:[D?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}):(0,Xt.jsx)(Kn,{className:"h-4 w-4 mr-1.5"}),"Generate Anyway"]})]})]})}),(0,Xt.jsx)(rg,{open:Boolean(we),onOpenChange:e=>!e&&je(null),children:(0,Xt.jsxs)(lg,{className:"sm:max-w-md","data-testid":"wizard-high-cv-warn-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"wizard-high-cv-warn-title",children:"Your Source CV is already strong"}),(0,Xt.jsxs)(mg,{"data-testid":"wizard-high-cv-warn-description",className:"text-sm text-ndor-ink-secondary",children:["Your current Source CV scores"," ",(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums","data-testid":"wizard-high-cv-warn-score",children:[null!==(l=null===we||void 0===we?void 0:we.source_cv_score)&&void 0!==l?l:"","/100"]})," ","on this role. Further optimisation may mainly improve presentation and clarity rather than your underlying fit."," ",(0,Xt.jsx)("span",{className:"font-medium",children:"If you continue, this will use Credits \u2014 50% of the standard tailoring cost for a presentation-only refinement, or the full cost when the new variant beats your Source CV by 6 points or more."})]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2 mt-2",children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:()=>{je(null)},disabled:D,"data-testid":"wizard-high-cv-warn-cancel",children:"Use current CV"}),(0,Xt.jsxs)(Rr,{onClick:async()=>{if(!we)return;const e=we;try{sessionStorage.setItem(sC(f),"1")}catch(t){}je(null),await ze(e.opts,!0)},disabled:D,"data-testid":"wizard-high-cv-warn-confirm",children:[D?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}):(0,Xt.jsx)(Kn,{className:"h-4 w-4 mr-1.5"}),"Generate anyway"]})]})]})}),(0,Xt.jsx)(rg,{open:Ge,onOpenChange:e=>!e&&Ke(!1),children:(0,Xt.jsxs)(lg,{className:"max-w-md","data-testid":"wizard-cancel-warn-dialog",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"wizard-cancel-warn-title",children:"Work in progress"}),(0,Xt.jsxs)(mg,{className:"text-sm leading-relaxed",children:[(0,Xt.jsx)("span",{className:"block mb-2 text-foreground",children:"If you close this wizard now:"}),(0,Xt.jsxs)("ul",{className:"list-disc pl-5 space-y-1 text-foreground",children:[(0,Xt.jsx)("li",{children:"Completed steps may already be charged."}),(0,Xt.jsx)("li",{children:"In-flight generation may still complete and be charged."}),(0,Xt.jsx)("li",{children:"Generated documents may appear in Documents/CV Variants."}),(0,Xt.jsx)("li",{children:"Cancelling closes the wizard UI but may not cancel backend work."})]})]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2 mt-2",children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:()=>Ke(!1),"data-testid":"wizard-cancel-warn-stay",children:"Stay"}),(0,Xt.jsx)(Rr,{variant:"destructive",onClick:()=>{Ke(!1),u(!1)},"data-testid":"wizard-cancel-warn-close-anyway",children:"Close anyway"})]})]})})]})}const pC="ndor:apply-clarifier:session-dismissed",hC="ndor:apply-clarifier:persist-dismissed";function fC(e){let{open:t,onContinue:n,onCancel:a}=e;const[r,i]=(0,s.useState)(!1);(0,s.useEffect)(()=>{t&&i(!1)},[t]);return(0,Xt.jsx)(rg,{open:t,onOpenChange:e=>{e||null===a||void 0===a||a()},children:(0,Xt.jsxs)(lg,{className:"max-w-xl max-h-[calc(100dvh-2rem)] overflow-y-auto","data-testid":"apply-flow-clarifier-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"text-base sm:text-lg flex items-center gap-2",children:[(0,Xt.jsx)(GN,{className:"h-4 w-4 text-ndor-gold"}),"How the Apply flow works"]}),(0,Xt.jsx)(mg,{className:"text-[13px] text-ndor-ink-secondary leading-relaxed",children:"You're about to open the application wizard. Here's what you'll choose, what's optional, and what each choice includes in the resulting pack \u2014 so you can decide where to spend Credits."})]}),(0,Xt.jsxs)("ul",{className:"space-y-3 text-[13px] leading-relaxed text-ndor-ink-secondary",children:[(0,Xt.jsxs)("li",{className:"flex gap-3","data-testid":"apply-clarifier-path-source-cv",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-ndor-gold shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium",children:"Source CV only"}),(0,Xt.jsxs)("ul",{className:"list-disc list-outside pl-4 space-y-1 mt-1",children:[(0,Xt.jsx)("li",{children:"Source CV is private reference material."}),(0,Xt.jsx)("li",{children:"Baseline Fit is diagnostic only."}),(0,Xt.jsx)("li",{children:"A Source-CV-only flow does not create an exportable pack."}),(0,Xt.jsx)("li",{children:"To create exportable outputs, generate a Tailored CV and/or Cover Letter."}),(0,Xt.jsxs)("li",{children:["Interview Intelligence requires ",(0,Xt.jsx)("strong",{children:"Tailored CV + Variant Fit"}),"."]})]})]})]}),(0,Xt.jsxs)("li",{className:"flex gap-3","data-testid":"apply-clarifier-path-variant",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium",children:"Tailored CV (optional)"}),(0,Xt.jsxs)("p",{children:["Generating a ",(0,Xt.jsx)("strong",{children:"tailored Variant"})," adapts your Source CV to this specific role. Tailoring is charged"," ",(0,Xt.jsx)("em",{children:"only when"})," the variant improves on your Source CV's NDOR verdict \u2014 otherwise it's saved for review at no charge. A tailored Variant also unlocks running"," ",(0,Xt.jsx)("strong",{children:"Variant Fit"})," on the Variant in Step 3, which surfaces Interview Intelligence on the pack page."]})]})]}),(0,Xt.jsxs)("li",{className:"flex gap-3","data-testid":"apply-clarifier-path-cover-letter",children:[(0,Xt.jsx)(Bg,{className:"h-4 w-4 text-ndor-gold shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium",children:"Cover letter (optional)"}),(0,Xt.jsx)("p",{children:"You can generate a cover letter against your selected CV. It becomes an exportable artefact in the pack and stays in your Documents library for re-use on similar roles. Skip this
2step entirely if you don't need one."})]})]}),(0,Xt.jsxs)("li",{className:"flex gap-3","data-testid":"apply-clarifier-credits",children:[(0,Xt.jsx)(Sn,{className:"h-4 w-4 text-ndor-gold shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium",children:"Credits"}),(0,Xt.jsxs)("p",{children:["Three actions can spend Credits: tailoring a CV (only if it improves), generating a cover letter, and running Variant Fit. Selecting an existing CV, browsing variants, opening the pack page, and exporting are ",(0,Xt.jsx)("strong",{children:"free"}),". Source CV Baseline Fit lives on the Jobs page and is separate from this wizard."]})]})]})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-gold/30 bg-ndor-gold/5 px-3 py-2.5 text-[12px] text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsxs)("p",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"Pack composition."})," ","Your pack contains ",(0,Xt.jsx)("em",{children:"only what you generated and chose"}),". A Source-CV-only flow is diagnostic and is not an exportable pack \u2014 generate a Tailored CV and/or Cover Letter to produce exportable outputs. Interview Intelligence requires"," ",(0,Xt.jsx)("strong",{children:"Tailored CV + Variant Fit"}),"."]}),(0,Xt.jsxs)("p",{className:"mt-1.5",children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"You stay in control."})," ","NDORFlow never auto-applies and never auto-tailors. Every submission is yours \u2014 pack creation only assembles the documents and tracking; you click ",(0,Xt.jsx)("em",{children:"Apply"})," on the employer's site yourself when you're ready."]})]}),(0,Xt.jsxs)("label",{className:"flex items-center gap-2 text-[12px] text-ndor-ink-muted cursor-pointer select-none","data-testid":"apply-clarifier-persist-label",children:[(0,Xt.jsx)(Vb,{checked:r,onCheckedChange:e=>i(!!e),"data-testid":"apply-clarifier-persist-checkbox"}),"Don't show this again on this device."]}),(0,Xt.jsxs)(dg,{className:"gap-2 sm:gap-2 sticky bottom-0 -mx-6 px-6 -mb-6 pb-6 pt-3 bg-background border-t border-ndor-edge/40",children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:a,"data-testid":"apply-clarifier-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{onClick:()=>{try{sessionStorage.setItem(pC,"1"),r&&localStorage.setItem(hC,"1")}catch(e){}null===n||void 0===n||n()},className:"bg-ndor-gold text-ndor-ink hover:bg-ndor-gold/90 font-semibold","data-testid":"apply-clarifier-continue",children:"Continue to wizard"})]})]})})}function xC(e){let{open:t,onContinue:n,onCancel:a}=e;return(0,Xt.jsx)(rg,{open:t,onOpenChange:e=>{e||a()},children:(0,Xt.jsxs)(lg,{className:"max-w-md","data-testid":"wizard-entry-notice-dialog",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"wizard-entry-notice-title",children:"Opening your application workspace"}),(0,Xt.jsxs)(mg,{className:"text-sm leading-relaxed text-foreground space-y-3",children:[(0,Xt.jsx)("span",{className:"block",children:"You can leave the workspace at any point."}),(0,Xt.jsx)("span",{className:"block",children:"Generated documents are saved to your Documents library as soon as they complete, so you can return to them from there even after leaving the workspace."}),(0,Xt.jsx)("span",{className:"block",children:"The workspace itself is a live session. If you leave before assembling the Application Pack, you can start a new session later \u2014 the Pack can be reassembled from your saved documents."}),(0,Xt.jsx)("span",{className:"block",children:"You may skip Analyse Fit and still create an Application Pack. Interview Prep is only available after a completed Analyse Fit tied to that workflow."})]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2 mt-2",children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:a,"data-testid":"wizard-entry-notice-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{onClick:n,"data-testid":"wizard-entry-notice-continue",children:"Continue"})]})]})})}const vC=["title","company","location","employment_type","seniority_level","description","requirements_text","salary_currency","url"];function gC(){var e,t,n,a;const{id:r}
2=_e(),[i,o]=Pt(),l="1"===i.get("imported"),[d,u]=(0,s.useState)(l);(0,s.useEffect)(()=>{l&&u(!0)},[l]);const m=(0,s.useCallback)(()=>{u(!1),o(e=>{const t=new URLSearchParams(e);return t.delete("imported"),t},{replace:!0})},[o]),{user:p}=tn(),{isOperator:h}=pn(),{guardedAction:f,dialogProps:x}=IN(),{refresh:v,includedUsageRemaining:g,extraUsageRemaining:y}=If(),[b,w]=(0,s.useState)(null),[j,k]=(0,s.useState)(!0),[N,_]=(0,s.useState)(!1),[D,C]=(0,s.useState)(!1),[A,S]=(0,s.useState)(!1),[E,F]=(0,s.useState)(null),[R,I]=(0,s.useState)(""),[T,P]=(0,s.useState)(!1),[O,B]=(0,s.useState)(!1),[L,M]=(0,s.useState)(null),[z,U]=(0,s.useState)([]),[V,q]=(0,s.useState)([]),[W,H]=(0,s.useState)([]),[G,K]=(0,s.useState)([]),[Y,J]=(0,s.useState)(""),[$,X]=(0,s.useState)(null),Q=Xk(Wk(null===p||void 0===p?void 0:p.id,r,(null===$||void 0===$||null===(e=$.primary_cv)||void 0===e?void 0:e.id)||"baseline")),[Z,ee]=(0,s.useState)(!1),[te,ne]=(0,s.useState)(!1);(0,s.useEffect)(()=>{r&&function(e){if(!e)return!1;try{const n=localStorage.getItem(EN(e));if(!n)return!1;const a=JSON.parse(n);if(!a||"number"!==typeof a.markedAtMs)return!1;if(Date.now()-a.markedAtMs>864e5){try{localStorage.removeItem(EN(e))}catch(t){}return!1}return!0}catch(n){return!1}}(r)&&ee(!0)},[r]),(0,s.useEffect)(()=>{r&&(Z?function(e){if(e)try{localStorage.setItem(EN(e),JSON.stringify({markedAtMs:Date.now()}))}catch(t){}}(r):function(e){if(e)try{localStorage.removeItem(EN(e))}catch(t){}}(r))},[r,Z]);const[ae,re]=(0,s.useState)(!1),[se,ie]=(0,s.useState)(!1),oe=(ke(),()=>{ne(!0)}),[le,ce]=(0,s.useState)(null),[de,ue]=(0,s.useState)(null),[me,pe]=(0,s.useState)(!1),[he,fe]=(0,s.useState)("focus"),xe=(0,s.useRef)(null),ve=(0,s.useRef)(null),ge=(0,s.useCallback)(async()=>{try{const[e,t]=await Promise.all([tw(uw(),()=>(0,zt.n)("/api/jobs/analyze-fit/usage"),{ttlMs:6e4}),tw(dw(),()=>(0,zt.n)("/api/account/plan").catch(()=>null),{ttlMs:6e4})]);ce(e||null),ue(t||null)}catch(e){}},[]);(0,s.useEffect)(()=>{ge()},[ge]);const ye=(0,s.useCallback)(async()=>{try{const e=await tw(ow(r),()=>(0,zt.n)("/api/jobs/".concat(r)),{ttlMs:3e5});w(e)}catch(pK){I(pK.message||"Failed to load job.")}finally{k(!1)}},[r]);(0,s.useEffect)(()=>{ye()},[ye]);const be=(0,s.useRef)(null),we=(0,s.useCallback)(()=>{var e;null===(e=be.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},[]),je=(0,s.useRef)(!1),Ne=(0,s.useCallback)(async()=>{if(null!==p&&void 0!==p&&p.id&&r&&!je.current&&!N)if(null!==b&&void 0!==b&&b.user_score)eN(p.id,r)&&(tN(p.id,r),F(null));else{if(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Qk;const a=eN(e,t,n);return!!a&&Date.now()-a.startedAtMs>=n}(p.id,r))return tN(p.id,r),void F("expired");if(nN(p.id,r)){je.current=!0,F("checking");try{const n=await(0,zt.n)("/api/jobs/".concat(r));if(null!==n&&void 0!==n&&n.user_score){w(n),tN(p.id,r),F("recovered");try{v()}catch(e){}try{nw(["jobs","dashboard:bundle"])}catch(t){}fy.success("Your fit analysis was completed in the background."),setTimeout(()=>F(null),4e3)}else{const e=eN(p.id,r);if(!e)return void F(null);Date.now()-(e.startedAtMs||0)>=9e4?(tN(p.id,r),F("expired")):F("inflight")}}catch(n){F("inflight")}finally{je.current=!1}}}},[null===p||void 0===p?void 0:p.id,r,N,null===b||void 0===b?void 0:b.user_score,v]);wN({enabled:!j&&!(null===p||void 0===p||!p.id)&&!!r,fetchAndBind:Ne,runOnMount:!0}),Uk({targetKind:"job",targetId:r,actionCode:"analyse_fit",enabled:!j&&!(null===p||void 0===p||!p.id)&&!!r,apiFetch:(e,t)=>(0,zt.n)(e,t),onRecovering:async e=>{const t=null===e||void 0===e?void 0:e.result_envelope_ref;if(t&&!N&&!A){S(!0);try{const e=await Tk(t,{});if("failed"===e.status||"cancelled"===e.status){try{tN(null===p||void 0===p?void 0:p.id,r)}catch(n){}return}const u=Pk(e),m=null===u||void 0===u?void 0:u.score;if(m&&"undefined"!==typeof m.fit_score){w(e=>(0,c.A)((0,c.A)({},e),{},{user_score:m}));try{nw(ow(r))}catch(a){}try{const e=await(0,zt.n)("/api/jobs/".concat(r));e&&w(e)}catch(s){}try{nw(["jobs","dashboard:bundle",uw(),dw(),fw(r)])}catch(i){}if("function"===typeof v)try{await v()}catch(o){}try{tN(null===p||void 0===p?void 0:p.id,r)}catch(l){}try{fy.success("Your fit analysis was completed in the background.")}catch(d){}}}catch(u){}finally{S(!1)}}},onTerminal:async e=>{try{tN(null===p||void 0===p?void 0:p.id,r)}catch(t){}try{if(null!==b&&void 0!==b&&b.user_score)return;const e=await(0,zt.n)("/api/jobs/".concat(r));if(e){w(e);try{nw(["jobs","dashboard:bundle",uw(),dw(),fw(r)])}catch(n){}if(e.user_score)try{fy.success("Your fit analysis was completed in the background.")}catch(a){}}}catch(s){}},onNone:()=>{try{tN(null===p||void 0===p?void 0:p.id,r)}catch(e){}}}),(0,s.useEffect)(()=>{let e=!0;return(async()=>
2{if(null!==p&&void 0!==p&&p.id){try{const t=await tw(hw(p.id),async()=>{const{data:e,error:t}=await Mt.supabase.from("base_cvs").select("id, original_filename, is_primary, parsed_text").eq("user_id",p.id).order("created_at",{ascending:!1});if(t)throw new Error(t.message);return e||[]},{ttlMs:3e5});e&&U(t||[])}catch(t){}try{const t=await tw(sw(),()=>(0,zt.n)("/api/cv-variants"),{ttlMs:3e5});e&&q(t||[])}catch(t){}try{const t=await tw(iw(),()=>(0,zt.n)("/api/cover-letters"),{ttlMs:3e5});e&&H(t||[])}catch(t){}try{const t=await tw(rw(),()=>(0,zt.n)("/api/application-packs"),{ttlMs:3e5});e&&K(t||[])}catch(t){}try{const t=await tw(fw(r),()=>(0,zt.n)("/api/jobs/".concat(r,"/baseline-fit")).catch(()=>null),{ttlMs:3e5});e&&t&&X(t)}catch(t){}}})(),()=>{e=!1}},[null===p||void 0===p?void 0:p.id,r]);const De=Boolean(de&&("focus"===de.plan_code||"flow"===de.plan_code)&&"active"===de.status),Ce=De?Math.max(0,(de.included_usage_remaining||0)+(de.extra_usage_remaining||0)):null,Ae=De&&0===Ce,Se=((e,t)=>{const n=null===b||void 0===b||null===(e=b.user_score)||void 0===e||null===(t=e.reasoning_json)||void 0===t?void 0:t.cv_sub_score;if(null==n)return null;const a=Number(n);return Number.isFinite(a)?a<=1?Math.round(100*a):Math.round(a):null})(),Ee=async()=>{var e;if(nN(null===p||void 0===p?void 0:p.id,r))return void fy.info("You're already analysing this job \u2014 we'll show the result as soon as it completes.");const t=(null===$||void 0===$||null===(e=$.primary_cv)||void 0===e?void 0:e.id)||null;if(null===b||void 0===b||!b.user_score){const e=Number((null===de||void 0===de?void 0:de.included_usage_remaining)||0),t=Number((null===de||void 0===de?void 0:de.extra_usage_remaining)||0),n=e>0||t>0,a=!!(le&&Number(le.remaining)>0);if(De&&Ae)return fe((null===de||void 0===de?void 0:de.plan_code)||"focus"),void pe(!0);if(!De&&!a&&!n)return fe("base"),void pe(!0)}_(!0),function(e,t){if("undefined"!==typeof window&&t)try{window.localStorage.setItem(Zk(e,t),JSON.stringify({startedAtMs:Date.now(),jobId:t}))}catch(n){}}(null===p||void 0===p?void 0:p.id,r),F(null);try{var n,a,s;const e=hN(null===p||void 0===p?void 0:p.id,r,"analyse_fit").idempotencyKey,i=t?{source_type:"uploaded_cv",source_id:t,idempotency_key:e}:{idempotency_key:e};ve.current&&ve.current.abort(),ve.current=new AbortController;const o=await Bk(r,i,{signal:ve.current.signal,onRecoveryState:e=>{"checking"===e?fy.info("This is taking longer than usual. We're checking your results..."):"recovered"===e&&fy.success("Your fit analysis was completed in the background.")}});fN(null===p||void 0===p?void 0:p.id,r,"analyse_fit"),w(e=>(0,c.A)((0,c.A)({},e),{},{user_score:o.score})),C(!0);try{try{nw(ow(r))}catch(u){}const e=await(0,zt.n)("/api/jobs/".concat(r));e&&w(e)}catch(m){}try{nw(["jobs","dashboard:bundle",uw(),dw(),fw(r)])}catch(h){}try{const e=t||"baseline";Yk(Wk(null===p||void 0===p?void 0:p.id,r,e))}catch(f){}tN(null===p||void 0===p?void 0:p.id,r),F(null),Promise.resolve().then(()=>{xe.current&&xe.current.scrollIntoView({behavior:"smooth",block:"start"})}),null!==o&&void 0!==o&&null!==(n=o.billing)&&void 0!==n&&n.cached?fy.success("Existing analysis loaded."):null!==o&&void 0!==o&&null!==(a=o.billing)&&void 0!==a&&a.was_free_fit?fy.success("Fit analysis complete."):1===(null===o||void 0===o||null===(s=o.billing)||void 0===s?void 0:s.usage_consumed)?fy.success("Fit analysis complete \u2014 1 included Credit charged."):fy.success("Fit analysis complete."),await Promise.allSettled([(async()=>{try{await v()}catch(e){}})(),(async()=>{try{await ge()}catch(e){}})(),(async()=>{try{const e=await(0,zt.n)("/api/jobs/".concat(r,"/baseline-fit"));e&&X(e)}catch(e){}})()]),xN(null===p||void 0===p?void 0:p.id,r,"analyse_fit"),yN(null===p||void 0===p?void 0:p.id,r,"analyse_fit")}catch(pK){var i,o;if("AbortError"===(null===pK||void 0===pK?void 0:pK.name))return;const t=null===pK||void 0===pK?void 0:pK.status,n=null===pK||void 0===pK?void 0:pK.code,a=String((null===pK||void 0===pK?void 0:pK.message)||""),s=!t||t>=500||408===t||"POLL_TIMEOUT"===n||"UNEXPECTED_ENVELOPE"===n||"ASYNC_POLLING_DISABLED"===n||/failed to fetch|network request failed|stream timeout|upstream.*timeout|^timeout/i.test(a),c=null===pK||void 0===pK||null===(i=pK.data)||void 0===i||null===(o=i.detail)||void 0===o?void 0:o.code;var l,d;if(429===(null===pK||void 0===pK?void 0:pK.status)&&"USAGE_EXHAUSTED"===c)ge(),fe((null===pK||void 0===pK||null===(l=pK.data)||void 0===l||null===(d=l.detail)||void 0===d?void 0:d.plan_code)||"focu
2s"),pe(!0),tN(null===p||void 0===p?void 0:p.id,r);else if(429===(null===pK||void 0===pK?void 0:pK.status)&&"FREE_DAILY_ANALYZE_LIMIT_REACHED"===c)ge(),fe("base"),pe(!0),tN(null===p||void 0===p?void 0:p.id,r);else if(Gw(pK,{refreshCredits:v,action:"fit analysis"}))s||tN(null===p||void 0===p?void 0:p.id,r);else{const t=function(e){var t,n;const a=null===e||void 0===e?void 0:e.status,r=null===e||void 0===e||null===(t=e.data)||void 0===t||null===(n=t.detail)||void 0===n?void 0:n.code,s=((null===e||void 0===e?void 0:e.message)||"").trim();return"USAGE_EXHAUSTED"===r||"FREE_DAILY_ANALYZE_LIMIT_REACHED"===r?null:/missing\s+(cv|source\s*cv|primary\s*cv)/i.test(s)?"Please add a Source CV before running Analyse Fit. You can upload one from your Documents page.":/insufficient\s+(job\s*description|description)|description\s+too\s+short/i.test(s)?"This job's description is too short to analyse reliably. Please paste the full description and try again.":/extraction\s+(failed|incomplete)/i.test(s)?"We couldn't extract enough detail from this job posting. Please paste the full description and try again.":408===a||/timeout|timed?\s*out/i.test(s)?"Analyse Fit took longer than expected. The result may still arrive shortly \u2014 please wait a moment, or try again.":a>=400&&a<500&&s&&!/^request failed/i.test(s)?s:!s||/^internal server error\.?$/i.test(s)||/^server error\.?$/i.test(s)||/^request failed( with status code \d+)?\.?$/i.test(s)||a>=500&&a<600?"Something went wrong on our side. Please try again in a moment \u2014 your credits were not charged for failed analyses.":s||"Analyse Fit failed."}(pK);t?fy.error(t):fy.error(pK.message||"Analysis failed."),s||tN(null===p||void 0===p?void 0:p.id,r)}}finally{C(!1),_(!1)}};const Fe=()=>{M(Object.fromEntries(vC.map(e=>{var t;return[e,null!==(t=null===b||void 0===b?void 0:b[e])&&void 0!==t?t:""]}))),P(!0)},Re=(e,t)=>{M(n=>(0,c.A)((0,c.A)({},n),{},{[e]:t}))};if(j)return(0,Xt.jsx)("div",{className:"flex items-center justify-center py-20","data-testid":"job-detail-loading",children:(0,Xt.jsx)(Lg,{className:"h-6 w-6 animate-spin text-ndor-ink-muted"})});if(R||!b)return(0,Xt.jsxs)("div",{className:"text-center py-20","data-testid":"job-detail-error",children:[(0,Xt.jsx)(ty,{className:"h-8 w-8 text-ndor-ink-muted mx-auto mb-3"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary",children:R||"Job not found."}),(0,Xt.jsx)(Et,{to:"/jobs",children:(0,Xt.jsx)(Rr,{variant:"ghost",className:"mt-4",children:"Back to Jobs"})})]});const Ie=!!(d&&b&&(b.description||"").replace(/\s+/g," ").trim().length>0);return(0,Xt.jsxs)("div",{className:"space-y-6 min-w-0 max-w-full overflow-x-hidden","data-testid":"job-detail-page",children:[(0,Xt.jsxs)(Et,{to:"/jobs",className:"inline-flex items-center gap-1.5 text-sm text-ndor-ink-secondary hover:text-ndor-ink transition-colors","data-testid":"job-detail-back",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4"})," Back to Jobs"]}),d&&b&&(0,Xt.jsx)("div",{role:"status","aria-live":"polite",className:"rounded-xl border border-ndor-success/30 bg-ndor-success-light/40 px-4 py-3","data-testid":"job-detail-imported-banner",children:(0,Xt.jsxs)("div",{className:"flex items-start gap-3",children:[(0,Xt.jsx)(GN,{className:"h-5 w-5 text-ndor-success shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink","data-testid":"job-detail-imported-banner-title",children:"Imported job ready"}),(0,Xt.jsx)("button",{type:"button",onClick:m,className:"text-ndor-ink-muted hover:text-ndor-ink transition-colors shrink-0","aria-label":"Dismiss imported job banner","data-testid":"job-detail-imported-banner-dismiss",children:(0,Xt.jsx)(xh,{className:"h-4 w-4"})})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary mt-0.5",children:"We extracted these details. Review them before running Analyse Fit."}),(0,Xt.jsxs)("dl",{className:"mt-2 grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted uppercase tracking-[0.14em] text-[10px] font-mono-ui",children:"Title"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink truncate","data-testid":"job-detail-imported-banner-job-title",children:b.title||"Untitled Job"})]}),b.company&&(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted uppercase tracking-[0.14em] text-[10px] font-mono-ui",children:"Company"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink truncate","data-testid":"job-detail-imported-banner-company",children:b.company})]}),b.location&&(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted uppercase tracking-[0.14em] text-[10px] font-mono-ui",children:"Location"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink truncate","data-testid":"job-detail-imported-banner-location",children:b.location})]}),b.url&&(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted uppercase tracking-[0.14em] text-[10px] font-mono-ui",children:"Source URL"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink truncate",children:(0,Xt.jsxs)("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",className:"text-ndor-info hover:underline truncate inline-flex items-center gap-1","data-testid":"job-detail-imported-banner-source-url",children:[(0,Xt.jsx)("span",{className:"truncate",children:b.url}),(0,Xt.jsx)(KN,{className:"h-3 w-3 shrink-0"})]})})]})]}),Ie?(0,Xt.jsxs)("button",{type:"button",onClick:we,className:"mt-2 inline-flex items-center gap-1 text-xs text-ndor-info hover:underline focus:outline-none focus-visible:ring-1 focus-visible:ring-ndor-info rounded","data-testid":"job-detail-imported-banner-view-description",children:[(0,Xt.jsx)(YN,{className:"h-3 w-3 shrink-0"}),"View full job description below"]}
2):(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-secondary mt-2 leading-relaxed","data-testid":"job-detail-imported-banner-no-description",children:["No full description was extracted. You can"," ",(0,Xt.jsx)("button",{type:"button",onClick:Fe,className:"text-ndor-info hover:underline focus:outline-none focus-visible:ring-1 focus-visible:ring-ndor-info rounded",children:"edit the job details"})," ","to add one."]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"border-ndor-success/40 text-ndor-success hover:bg-ndor-surface",onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},"data-testid":"job-detail-imported-banner-analyze",children:[(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5 mr-1.5"})," Analyse Fit"]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:Fe,"data-testid":"job-detail-imported-banner-edit",children:[(0,Xt.jsx)(JN,{className:"h-3.5 w-3.5 mr-1.5"})," Edit details"]}),(0,Xt.jsx)(Rr,{asChild:!0,size:"sm",variant:"ghost",className:"text-ndor-ink-secondary","data-testid":"job-detail-imported-banner-back",children:(0,Xt.jsxs)(Et,{to:"/jobs",children:[(0,Xt.jsx)(Zg,{className:"h-3.5 w-3.5 mr-1.5"})," Back to Jobs"]})})]})]})]})}),"platform"===(null===b||void 0===b?void 0:b.source_kind)&&((null===b||void 0===b?void 0:b.hidden_by_source_404)||(null===b||void 0===b?void 0:b.hidden_by_staleness))&&(0,Xt.jsxs)("div",{className:"rounded-xl border px-4 py-3 flex items-start gap-3 ".concat(b.hidden_by_source_404?"border-ndor-error/30 bg-ndor-error-light/40":"border-ndor-warning/30 bg-ndor-warning-light/40"),"data-testid":b.hidden_by_source_404?"job-detail-source-404-banner":"job-detail-stale-banner",children:[(0,Xt.jsx)(zf,{className:"h-4 w-4 mt-0.5 shrink-0 ".concat(b.hidden_by_source_404?"text-ndor-error":"text-ndor-warning")}),(0,Xt.jsx)("div",{className:"text-sm",children:b.hidden_by_source_404?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium",children:"This posting is no longer listed at the source."}),(0,Xt.jsx)("p",{className:"text-ndor-ink-secondary text-xs mt-0.5",children:"We kept the record for your history, but the company's careers page no longer exposes this role. You can still open the original URL \u2014 it may 404."})]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium",children:"This posting may no longer be active."}),(0,Xt.jsx)("p",{className:"text-ndor-ink-secondary text-xs mt-0.5",children:"We haven't confirmed it in the last three scans of its source. It could still be live \u2014 check the original URL before investing effort."})]})})]}),(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[(0,Xt.jsx)("div",{className:"min-w-0 flex-1",children:T?(0,Xt.jsxs)("div",{className:"space-y-3 max-w-2xl",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"Title *"}),(0,Xt.jsx)(Ag,{value:L.title||"",onChange:e=>Re("title",e.target.value),"data-testid":"job-edit-title"})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"Company"}),(0,Xt.jsx)(Ag,{value:L.company||"",onChange:e=>Re("company",e.target.value),"data-testid":"job-edit-company"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"Location"}),(0,Xt.jsx)(Ag,{value:L.location||"",onChange:e=>Re("location",e.target.value),"data-testid":"job-edit-location"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"Employment type"}),(0,Xt.jsx)(Ag,{value:L.employment_type||"",onChange:e=>Re("employment_type",e.target.value),placeholder:"e.g. full_time, contract","data-testid":"job-edit-employment-type"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"Seniority"}),(0,Xt.jsx)(Ag,{value:L.seniority_level||"",onChange:e=>Re("seniority_level",e.target.value),placeholder:"e.g. senior, lead","data-testid":"job-edit-seniority"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"Salary currency"}),(0,Xt.jsx)(Ag,{value:L.salary_currency||"",onChange:e=>Re("salary_currency",e.target.value),placeholder:"e.g. USD, QAR","data-testid":"job-edit-salary-currency"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"URL"}),(0,Xt.jsx)(Ag,{value:L.url||"",onChange:e=>Re("url",e.target.value),placeholder:"https://\u2026","data-testid":"job-edit-url"})]})]})]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold tracking-tight text-ndor-ink font-outfit","data-testid":"job-detail-title",children:!b.title||/^untitled job$/i.test(b.title.trim())?(0,Xt.jsx)("span",{className:"italic text-ndor-ink-muted cursor-pointer underline-offset-2 hover:underline",onClick:Fe,"data-testid":"job-detail-title-fallback",title:"Click to add a title",children:"Imported job (title not detected \u2014 click to edit)"}):b.title}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 mt-2 text-sm text-ndor-ink-secondary",children:[b.company&&(0,Xt.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,Xt.jsx)(Pn,{className:"h-4 w-4"})," ",b.company]}),b.location&&(0,Xt.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,Xt.jsx)(qw,{className:"h-4 w-4"})," ",b.location]}),b.employment_type&&(0,Xt.jsx)(Vw,{variant:"outline",className:"text-xs capitalize",children:b.employment_type.replace("_"," ")}),b.seniority_level&&(0,Xt.jsx)(Vw,{variant:"outline",className:"text-xs capitalize",children:b.seniority_level})]})]})}),(0,Xt.jsx)("div",{className:"flex gap-2 shrink-0 flex-wrap w-full sm:w-auto","data-testid":"job-detail-action-row",children:T?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)(Rr,{variant:"ghost",size:"sm",onClick:()=>{M(null),P(!1)},disabled:O,"data-testid":"job-edit-cancel",children:[(0,Xt.jsx)(xh,{className:"h-4 w-4 mr-1.5"})," Cancel"]}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:async()=>
2{if(!L)return;const e={};for(const r of vC){var t,n;const a=null!==(t=null===b||void 0===b?void 0:b[r])&&void 0!==t?t:"",s=null!==(n=L[r])&&void 0!==n?n:"";String(a)!==String(s)&&(e[r]=""===s?null:s)}if(0===Object.keys(e).length)return fy.info("No changes to save."),void P(!1);B(!0);try{const t=await(0,zt.n)("/api/jobs/".concat(r),{method:"PATCH",body:e});w(t),fy.success("Job updated."),P(!1),M(null);try{nw([ow(r),"jobs","dashboard:bundle"])}catch(a){}}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to update job.")}finally{B(!1)}},disabled:O,"data-testid":"job-edit-save",children:[O?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}):(0,Xt.jsx)($N,{className:"h-4 w-4 mr-1.5"}),"Save"]})]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:Fe,"data-testid":"job-edit-button",className:"flex-1 sm:flex-none",children:[(0,Xt.jsx)(JN,{className:"h-4 w-4 mr-1.5"})," Edit"]}),b.url&&(0,Xt.jsx)("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",className:"flex-1 sm:flex-none",children:(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",className:"w-full sm:w-auto","data-testid":"job-view-source-button",children:[(0,Xt.jsx)(KN,{className:"h-4 w-4 mr-1.5"})," View Source"]})}),(0,Xt.jsxs)(Rr,{onClick:oe,disabled:!(null!==b&&void 0!==b&&b.user_score)||N||"checking"===E||"inflight"===E,title:null!==b&&void 0!==b&&b.user_score?N||"checking"===E||"inflight"===E?"One moment \u2014 finishing your Analyse Fit before opening the workspace.":"Open the application workspace \u2014 a live session for tailoring your CV, cover letter and interview prep.":"Run Analyse Fit first \u2014 Apply opens the workspace once we have a fit score for this job.",className:"hidden sm:inline-flex w-full sm:w-auto bg-ndor-gold text-ndor-ink hover:bg-ndor-gold/90 font-semibold disabled:opacity-60 disabled:cursor-not-allowed","data-testid":"job-detail-apply-button",children:[(0,Xt.jsx)(GN,{className:"h-4 w-4 mr-1.5"}),"Apply to this job"]}),!(null!==b&&void 0!==b&&b.user_score)&&(0,Xt.jsxs)("p",{className:"w-full sm:w-auto text-[11px] text-ndor-ink-muted sm:max-w-[260px] leading-snug","data-testid":"job-detail-apply-locked-hint",children:["Apply opens a workspace where we'll tailor your CV, cover letter and interview prep to this role."," ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Analyse Fit"})," first so we have a fit score to work from."]})]})})]}),!T&&!te&&(0,Xt.jsx)("div",{className:"fixed inset-x-0 bottom-0 z-40 sm:hidden border-t border-ndor-edge bg-ndor-surface/95 backdrop-blur p-3","data-testid":"job-detail-apply-sticky",children:(0,Xt.jsxs)(Rr,{onClick:oe,disabled:!(null!==b&&void 0!==b&&b.user_score)||N||"checking"===E||"inflight"===E,title:null!==b&&void 0!==b&&b.user_score?N||"checking"===E||"inflight"===E?"One moment \u2014 finishing your Analyse Fit before opening the workspace.":"Open the application workspace.":"Run Analyse Fit first \u2014 Apply opens the workspace once we have a fit score.",className:"w-full bg-ndor-gold text-ndor-ink hover:bg-ndor-gold/90 font-semibold disabled:opacity-60 disabled:cursor-not-allowed","data-testid":"job-detail-apply-button-mobile",children:[(0,Xt.jsx)(GN,{className:"h-4 w-4 mr-1.5"}),null!==b&&void 0!==b&&b.user_score?"Apply to this job":"Analyse Fit first to Apply"]})}),te&&(0,Xt.jsx)("div",{className:"mb-6",children:(0,Xt.jsx)(ON,{jobId:r,onCancel:()=>ne(!1)})}),(0,Xt.jsx)(fC,{open:ae,onContinue:()=>{re(!1),ie(!0)},onCancel:()=>re(!1)}),(0,Xt.jsx)(xC,{open:se,onContinue:()=>{ie(!1),ee(!0)},onCancel:()=>ie(!1)}),(0,Xt.jsx)(mC,{open:Z,onOpenChange:ee,job:b,onPackCreated:()=>{}}),!T&&(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge bg-ndor-surface px-4 py-3 sm:px-5 sm:py-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between","data-testid":"job-detail-score-summary",children:[(0,Xt.jsxs)("div",{className:"flex items-stretch gap-3 sm:gap-5",children:[(0,Xt.jsx)("div",{className:"flex items-center self-start","data-testid":"job-detail-score-summary-context-chip",children:(0,Xt.jsx)("span",{className:"inline-flex items-center rounded-full border border-ndor-edge bg-ndor-surface-alt/60 px-2 py-0.5 text-[9px] uppercase tracking-[0.16em] text-ndor-ink-muted font-mono-ui",children:"Source CV \xb7 baseline"})}),(0,Xt.jsxs)("div",{className:"flex flex-col","data-testid":"job-detail-score-summary-cv-verdict",children:[(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"NDOR CV verdict"}),(0,Xt.jsxs)("span",{className:"text-2xl font-serif-display text-ndor-ink leading-none mt-1",children:[null!=Se?Se:(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"\u2014"}),(0,Xt.jsx)("span",{className:"text-xs text-ndor-ink-muted ml-1",children:"/100"})]}),(0,Xt.jsx)("span",{className:"text-[10px] text-ndor-ink-muted mt-1",children:null!=Se?"LLM-graded CV quality vs JD":"Run Analyse Fit to score this role"})]}),null!=(null===b||void 0===b||null===(t=b.user_score)||void 0===t?void 0:t.fit_score)&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("div",{className:"w-px bg-ndor-edge self
2-stretch","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"flex flex-col","data-testid":"job-detail-score-summary-fit",children:[(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Overall Fit"}),(0,Xt.jsxs)("span",{className:"text-2xl font-serif-display text-ndor-ink leading-none mt-1",children:[Math.round(Number(b.user_score.fit_score)<=1?100*Number(b.user_score.fit_score):Number(b.user_score.fit_score)),(0,Xt.jsx)("span",{className:"text-xs text-ndor-ink-muted ml-1",children:"/100"})]}),(0,Xt.jsx)("span",{className:"text-[10px] text-ndor-ink-muted mt-1",children:"Holistic candidate\u2013role fit \xb7 informational"})]})]})]}),null==Se?(0,Xt.jsx)("button",{type:"button",onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},className:"rounded-full border border-ndor-gold/50 bg-ndor-gold/10 px-3 py-1.5 text-[11px] text-ndor-gold hover:bg-ndor-gold/20 self-start sm:self-center font-mono-ui uppercase tracking-[0.12em]","data-testid":"job-detail-score-summary-run-analyse-fit-cta",children:"Run Analyse Fit \u2193"}):(0,Xt.jsx)("button",{type:"button",onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},className:"text-xs text-ndor-ink-secondary hover:text-ndor-ink underline self-start sm:self-center","data-testid":"job-detail-score-summary-jump-to-breakdown",children:"View detailed breakdown \u2193"})]}),(0,Xt.jsx)(gs,{}),!T&&(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface brand-card-hover","data-testid":"analyze-fit-card",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 border-b border-ndor-edge",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold"}),"Analyse Fit with Source CV"]}),(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.2em] text-ndor-ink-muted font-mono-ui mt-1",children:"Mission Control \xb7 Fit Analysis"})]}),(0,Xt.jsxs)(Py,{className:"space-y-4 pt-5",children:[(0,Xt.jsx)($_,{variant:"expanded",testIdSuffix:"job-detail"}),(null===$||void 0===$?void 0:$.stale)&&!(null!==$&&void 0!==$&&$.baseline)&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-warning/40 bg-ndor-warning/5 px-3 py-2 text-xs text-ndor-ink-secondary flex items-start gap-2","data-testid":"job-detail-stale-baseline-strip",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 text-ndor-warning mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:["Previous Analyse Fit: ",(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums",children:[$.stale.fit_score,"/100"]}),"\xa0against ",(0,Xt.jsx)("span",{className:"font-medium",children:$.stale.stale_cv_label}),". \xa0That score is no longer valid because your Source CV has changed. \xa0Run Analyse Fit again on your current Source CV to refresh the diagnostic."]})]}),((e,t,n)=>{const a=null===b||void 0===b||null===(e=b.user_score)||void 0===e||null===(t=e.reasoning_json)||void 0===t?void 0:t.source_id,r=null===$||void 0===$||null===(n=$.primary_cv)||void 0===n?void 0:n.id;return!!a&&!!r&&a!==r?(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-warning/40 bg-ndor-warning/5 px-3 py-2 text-xs text-ndor-ink-secondary flex items-start gap-2","data-testid":"job-detail-source-cv-changed-hint",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 text-ndor-warning mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:["Your Source CV has changed since this analysis."," ","Run Analyse Fit again to refresh the diagnostic for this role."]})]}):null})(),(N||D)&&!E&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"analyze-fit-dispatch-strip","data-stabilising":D?"1":"0",className:"rounded-md border border-ndor-gold/40 bg-ndor-gold/5 px-3 py-2.5 text-xs text-ndor-ink flex items-start gap-2 leading-relaxed",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0 mt-0.5 text-ndor-gold"}),(0,Xt.jsx)("span",{children:D?"Finalising your fit \u2014 refreshing wallet and breakdown\u2026":"Analysing your fit \u2014 feel free to switch tabs. We\u2019ll keep the result safe and update this card the moment it\u2019s ready."})]}),"checking"===E&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"analyze-fit-rehydration-checking",className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2 text-xs text-ndor-ink flex items-start gap-2",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0 mt-0.5"}),(0,Xt.jsx)("span",{children:"Still checking your analysis\u2026"})]}),"inflight"===E&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"analyze-fit-rehydration-inflight",className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2 text-xs text-ndor-ink-secondary flex items-start gap-2 leading-relaxed",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0 mt-0.5 text-ndor-ink-muted"}),(0,Xt.jsx)("span",{children:"Your Analyse Fit is still running in the background. We'll show the result here as soon as it's ready \u2014 feel free to keep working."})]}),"recovered"===E&&(0,Xt.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"analyze-fit-rehydration-recovered",className:"rounded-md border border-ndor-success/30 bg-ndor-success-light/40 px-3 py-2 text-xs text-ndor-success flex items-start gap-2",children:[(0,Xt.jsx)(GN,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,Xt.jsx)("span",{children:"Analysis recovered \u2014 your fit score is below."})]}),"expired"===E&&(0,Xt.jsxs)("div",{role:"alert","data-testid":"analyze-fit-rehydration-expired",className:"rounded-md border border-amber-300 bg-amber-500/10 px-3 py-2 text-xs text-amber-200 flex items-start gap-2 leading-relaxed",children:[(0,Xt.jsx)(ty,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,Xt.jsx)("span",{children:"We couldn't confirm your previous Analyse Fit. Your credits were not charged for failed analyses \u2014 please try again when ready."})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[1fr_auto] gap-3 items-end",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5","data-testid":"job-detail-baseline-source-display",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink-secondary text-[11px] uppercase tracking-[0.16em] font-mono-ui",children:"Source CV (baseline)"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate","data-testid":"job-detail-primary-cv-name",children:(null===$||void 0===$||null===(n=$.primary_cv)||void 0===n?void 0:n.filename)||"Source CV"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Baseline Analyse Fit always uses your current Source CV."})]}),(0,Xt.jsxs)(Rr,{onClick:()=>f(Ee),disabled:N||D||!(null!==$&&void 0!==$&&null!==(a=$.primary_cv)&&void 0!==a&&a.id)||Q.active||"checking"===E||"inflight"===E,"data-testid":"analyze-fit-button","data-cooldown-active":Q.active?"1":"0","data-cooldown-remaining-ms":Q.active?String(Q.remainingMs):"","data-rehydration-status":E||"",title:"checking"===E?"Refreshing analysis \u2014 please wait for the current result to settle.":"inflight"===E?"Analysis is still updating in the background. We'll re-enable this once the result lands.":Q.active?"Analyse Fit is on cooldown for ".concat(Q.label,". This prevents accidental re-clicks while your wallet syncs."):void 0,className:"bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground",children:[N||D||"checking"===E||"inflight"===E?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}):(0,Xt.jsx)(Kn,{className:"h-4 w-4 mr-1.5"}),"checking"===E?"Refreshing analysis\u2026":"inflight"===E?"Analysis is still updating\u2026":Q.active?"Run again in ".concat(Q.label):D?"Finalising\u2026":N?"Analysing...":null!==$&&void 0!==$&&$.baseline?"Re-analyse Fit":"Analyse Fit",!N&&!D&&!Q.active&&"checking"!==E&&"inflight"!==E&&(0,Xt.jsx)(LN,{className:"ml-2 text-white/80 text-[11px]"})]})]}),!b.user_score&&(De?(0,Xt.jsx)("div",{className:"flex flex-col gap-0.5 text-xs","data-testid":"analyze-fit-usage-hint",children:Ae?(0,Xt.jsx)("span",{className:"text-ndor-warning","data-testid":"analyze-fit-usage-exhausted",children:"You've used your included Credits. Add extra Credits or renew your plan to continue."}):(0,Xt.jsxs)("span",{className:"text-ndor-ink-secondary","data-testid":"analyze-fit-usage-remaining",children:["Included Credits remaining: ",Ce]})}):le&&(0,Xt.jsxs)("div",{className:"flex flex-col gap-0.5 text-xs","data-testid":"analyze-fit-quota-hint",children:[(()=>{const e=Math.max(0,le.remaining||0),t=Math.max(1,Number(le.limit)||2);return e>0?(0,Xt.jsxs)("span",{className:"text-ndor-ink-secondary","data-testid":"analyze-fit-quota-remaining",children:["You have ",e," free analyses left today."]}):(0,Xt.jsxs)("span",{className:"text-ndor-warning","data-testid":"analyze-fit-quota-reached",children:["You've used your ",t," free job analyses for today."]})})(),(0,Xt.jsx)("span",{className:"text-ndor-ink-muted","data-testid":"analyze-fit-quota-reset",children:"Your allowance resets at 00:00 UTC."})]})),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted flex items-center gap-1.5","data-testid":"analyze-fit-source-hint",children:[(0,Xt.jsx)("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-ndor-ink-muted"}),"Analyse Fit on your Source CV. Includes CV review. Cost: ",(0,Xt.jsx)(BN,{action:"analyze_fit",prefix:""}),"."]})]})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,Xt.jsx)("div",{className:"lg:col-span-2 space-y-6",children:T?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsx)(Iy,{className:"text-base font-medium text-ndor-ink",children:"Description"})}),(0,Xt.jsx)(Py,{children:(0,Xt.jsx)(Hw,{rows:10,value:L.description||"",onChange:e=>Re("description",e.target.value),placeholder:"Paste or correct the job description\u2026","data-testid":"job-edit-description"})})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsx)(Iy,{className:"text-base font-medium text-ndor-ink",children:"Requirements"})}),(0,Xt.jsx)(Py,{children:(0,Xt.jsx)(Hw,{rows:8,value:L.requirements_text||"",onChange:e=>Re("requirements_text",e.target.value),placeholder:"Key requirements, skills, qualifications\u2026","data-testid":"job-edit-requirements"})})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Edits update this job record only. Existing fit analyses, CV variants, and cover letters are not re-generated \u2014 re-run them manually when ready."})]}):(0,Xt.jsxs)(Xt.Fragment,{children:[b.description&&(0,Xt.jsxs)(Fy,{ref:be,className:"border-ndor-edge shadow-sm","data-testid":"job-detail-description-card",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsx)(Iy,{className:"text-base font-medium text-ndor-ink",children:"Description"})}
2),(0,Xt.jsx)(Py,{children:(0,Xt.jsx)(HN,{text:b.description,testid:"job-detail-description"})})]}),b.requirements_text&&(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsx)(Iy,{className:"text-base font-medium text-ndor-ink",children:"Requirements"})}),(0,Xt.jsx)(Py,{children:(0,Xt.jsx)(HN,{text:b.requirements_text,testid:"job-detail-requirements"})})]}),!b.description&&!b.requirements_text&&(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm border-dashed",children:(0,Xt.jsx)(Py,{className:"p-8 text-center",children:(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"No description available for this job."})})})]})}),(0,Xt.jsx)("div",{className:"space-y-4",children:b.user_score?(0,Xt.jsx)("div",{ref:xe,"data-testid":"job-detail-fit-breakdown",children:(0,Xt.jsx)(y_,{score:b.user_score,scope:"job"})}):(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm border-dashed",children:(0,Xt.jsxs)(Py,{className:"p-6 text-center",children:[(0,Xt.jsx)(Kn,{className:"h-8 w-8 text-ndor-ink-muted mx-auto mb-3"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No analysis yet"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:'Click "Analyse Fit" to see how well you match this role.'})]})})})]}),(0,Xt.jsx)(Q_,{open:me,onOpenChange:pe,planCode:he}),(0,Xt.jsx)(TN,(0,c.A)((0,c.A)({},x),{},{intent:"analyse_fit"}))]})}const yC=3e5;function bC(){var e;const{user:t}=tn(),[n,a]=(0,s.useState)(()=>{var e;const n=ew(pw(null===t||void 0===t?void 0:t.id),yC);return n.hit&&null!==(e=n.data)&&void 0!==e?e:null}),[r,i]=(0,s.useState)(()=>{if(null===t||void 0===t||!t.id)return!1;return!ew(pw(null===t||void 0===t?void 0:t.id),yC).hit}),[o,l]=(0,s.useState)(""),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(!1),[p,h]=(0,s.use
2State)(""),f=(0,s.useRef)(null),x=(0,s.useCallback)(async()=>{if(null!==t&&void 0!==t&&t.id)try{const e=await tw(pw(t.id),async()=>{const{data:e,error:n}=await Mt.supabase.from("base_cvs").select("id, file_url, original_filename, is_primary, parsed_text, parsed_json, created_at, updated_at").eq("user_id",t.id).eq("is_primary",!0).maybeSingle();if(n)throw new Error(n.message);return e||null},{ttlMs:yC});a(e||null)}catch(pK){l((null===pK||void 0===pK?void 0:pK.message)||"Failed to load Source CV.")}finally{i(!1)}else i(!1)},[null===t||void 0===t?void 0:t.id]);(0,s.useEffect)(()=>{null!==t&&void 0!==t&&t.id&&x()},[null===t||void 0===t?void 0:t.id]);const v=(0,s.useCallback)(()=>{var e;h(""),null===(e=f.current)||void 0===e||e.click(),d(!1)},[]),g=(0,s.useCallback)(async e=>{var n,a;const r=null===(n=e.target)||void 0===n||null===(a=n.files)||void 0===a?void 0:a[0];if(e.target&&(e.target.value=""),r){m(!0),h("");try{const e=new FormData;e.append("file",r),e.append("original_filename",r.name),e.append("make_primary","true");const n=await(0,zt.n)("/api/base-cvs/upload",{method:"POST",body:e});if(!n||!n.cv_id)throw new Error("Upload succeeded but the response was empty.");fy.success("Source CV updated. Future analyses will use the new file."),nw(pw(null===t||void 0===t?void 0:t.id)),await x()}catch(pK){const t=(null===pK||void 0===pK?void 0:pK.detail)||(null===pK||void 0===pK?void 0:pK.message)||"Upload failed. Please try again.";h("string"===typeof t?t:"Upload failed. Please try again."),fy.error("Could not update Source CV.")}finally{m(!1)}}},[x]);return r?(0,Xt.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})}):(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"cv-library-page",children:[o&&(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-lg bg-ndor-error-light border border-ndor-error-border p-3","data-testid":"cv-library-fetch-error",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 text-ndor-error mt-0.5 shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary",children:o})]}),n?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-edge bg-ndor-surface-alt/40 p-4 flex flex-col sm:flex-row sm:items-center gap-3","data-testid":"cv-library-source-card","data-build":"RC1.49.x-SOURCE_CV_REPLACE_OPTION_A-2026-05-07",children:[(0,Xt.jsx)("div",{className:"w-11 h-11 rounded-lg bg-ndor-success-light flex items-center justify-center shrink-0",children:(0,Xt.jsx)(Og,{className:"h-5 w-5 text-ndor-success"})}),(0,Xt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate","data-testid":"cv-library-source-filename",children:n.original_filename||"Source CV"}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-secondary","data-testid":"cv-library-source-status",children:[null!==n&&void 0!==n&&null!==(e=n.parsed_json)&&void 0!==e&&e.text_length?"Parsed \xb7 ".concat(Number(n.parsed_json.text_length).toLocaleString()," chars"):"Saved",n.created_at&&" \xb7 Uploaded ".concat(new Date(n.created_at).toLocaleDateString())]})]}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:()=>{h(""),d(!0)},disabled:u,"data-testid":"cv-library-replace-upload-button",className:"shrink-0 self-stretch sm:self-auto",children:[u?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(Kg,{className:"h-4 w-4 mr-1.5"}),u?"Uploading\u2026":"Replace Source CV"]})]}),p&&(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md bg-ndor-error-light border border-ndor-error-border p-3","data-testid":"cv-library-upload-error",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 text-ndor-error mt-0.5 shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary",children:p})]}),(0,Xt.jsxs)("p",{className:"flex items-start gap-2 text-[11px] text-ndor-ink-secondary leading-relaxed","data-testid":"cv-library-source-trust-note",children:[(0,Xt.jsx)(Bn,{className:"h-3.5 w-3.5 text-ndor-success mt-0.5 shrink-0"}),(0,Xt.jsx)("span",{children:"Stored as parsed text only \u2014 never previewed or exported. Replacing it doesn\u2019t affect packs already created."})]})]}):(0,Xt.jsxs)("div",{className:"rounded-xl border-2 border-dashed border-ndor-warning/50 bg-ndor-warning-light/30 p-5 text-center","data-testid":"cv-library-missing-state",children:[(0,Xt.jsx)("div",{className:"mx-auto w-11 h-11 rounded-full bg-ndor-warning-light flex items-center justify-center mb-3",children:(0,Xt.jsx)(ty,{className:"h-5 w-5 text-ndor-warning"})}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No Source CV on file"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary mt-1.5 max-w-md mx-auto leading-relaxed",children:"Your Source CV is set during onboarding. If you don\u2019t see one here, please contact support so we can restore your account state."}),(0,Xt.jsxs)("div",{className:"mt-5 mx-auto max-w-md rounded-md border border-ndor-edge bg-ndor-surface-alt/40 p-3 text-left","data-testid":"documents-source-empty-reviewer-hint",children:[(0,Xt.jsx)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Recommended next step"}),(0,Xt.jsxs)("ol",{className:"mt-2 space-y-1.5 text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"1."}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Upload your first Source CV"})," ","\u2014 this is the starting point before any job analysis. It\u2019s normally captured during onboarding."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"2."}),(0,Xt.jsxs)("span",{children:["Once your Source CV is on file, head to ",(0,Xt.jsx)(Et,{to:"/jobs",className:"text-ndor-info hover:underline",children:"Browse jobs"})," to import a role."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"3."}),(0,Xt.jsxs)("span",{children:["Run ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Analyse Fit"})," to see how your CV matches the role."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"4."}),(0,Xt.jsx)("span",{children:"Generate a tailored CV, cover letter, and apply-ready application pack."})]})]})]})]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted flex items-start gap-1.5 leading-relaxed",children:[(0,Xt.jsx)(Nn,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),(0,Xt.jsx)("span",{children:"You have one Source CV. CV variants and cover letters for specific jobs are generated from it inside the job application flow."})]}),(0,Xt.jsx)("input",{ref:f,type:"file",accept:".pdf,.docx",className:"hidden",onChange:g,"data-testid":"cv-library-replace-file-input"}),(0,Xt.jsx)(rg,{open:c,onOpenChange:d,children:(0,Xt.jsxs)(lg,{className:"max-w-md","data-testid":"cv-library-replace-confirm-dialog",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{className:"text-lg font-semibold tracking-tight",children:"Upload a new Source CV?"}),(0,Xt.jsx)(mg,{className:"text-sm text-ndor-ink-secondary",children:"Just so you know
2what changes and what doesn\u2019t."})]}),(0,Xt.jsxs)("ul",{className:"space-y-2 py-2 text-sm text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Og,{className:"h-4 w-4 text-ndor-success mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"Future analyses and new generated documents"})," ","(Analyse Fit runs, tailored CV variants, cover letters, application packs) will use the new Source CV."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-ink-muted mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"Existing application packs and generated documents stay unchanged"})," ","\u2014 they remain tied to the Source CV used when they were created."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-ink-muted mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:["Uploaded Source CVs remain"," ",(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"private reference material"})," ","\u2014 they are not previewed or exported anywhere in NDORFlow."]})]})]}),(0,Xt.jsxs)(dg,{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2",children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:()=>d(!1),"data-testid":"cv-library-replace-cancel-button",className:"w-full sm:w-auto",children:"Cancel"}),(0,Xt.jsxs)(Rr,{onClick:v,"data-testid":"cv-library-replace-confirm-button",className:"w-full sm:w-auto",children:[(0,Xt.jsx)(hb,{className:"h-4 w-4 mr-1.5"}),"Choose file\u2026"]})]})]})})]})}const wC=wn("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),jC=[{value:"draft",label:"Draft"},{value:"ready",label:"Ready"},{value:"submitted",label:"Submitted"},{value:"archived",label:"Archived"}],kC=[{value:"newest",label:"Newest first"},{value:"oldest",label:"Oldest first"},{value:"updated_desc",label:"Recently updated"},{value:"status_asc",label:"Status (Draft \u2192 Archived)"},{value:"fit_desc",label:"Best fit first"},{value:"fit_asc",label:"Worst fit first"}];function NC(e){let{qFromUrl:t,statusesFromUrl:n,sortFromUrl:a,total:r,unfilteredTotal:i,onQChange:o,onStatusToggle:l,onSortChange:c,onClearFilters:d}=e;const[u,m]=(0,s.useState)(t||"");(0,s.useEffect)(()=>{m(e=>e===(t||"")?e:t||"")},[t]),(0,s.useEffect)(()=>{const e=setTimeout(()=>{const e=u.trim();e!==(t||"")&&o(e)},350);return()=>clearTimeout(e)},[u,t,o]);const p=t&&t.length>0||n.length>0||a&&"newest"!==a;return(0,Xt.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"packs-filters",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,Xt.jsxs)("div",{className:"relative flex-1 min-w-[220px] max-w-md",children:[(0,Xt.jsx)(wC,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-ndor-ink-muted pointer-events-none"}),(0,Xt.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),placeholder:"Search pack name\u2026",className:"h-9 w-full rounded-md border border-ndor-edge bg-ndor-surface pl-8 pr-3 text-sm placeholder:text-ndor-ink-muted focus:outline-none focus:ring-1 focus:ring-ndor-info","data-testid":"packs-filter-q-input","aria-label":"Search packs by name"})]}),(0,Xt.jsxs)(Vv,{value:a||"newest",onValueChange:c,children:[(0,Xt.jsx)(Wv,{className:"h-9 w-[200px] text-sm","data-testid":"packs-filter-sort-trigger",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:kC.map(e=>(0,Xt.jsx)(Yv,{value:e.value,"data-testid":"packs-filter-sort-option-".concat(e.value),children:e.label},e.value))})]}),p&&(0,Xt.jsxs)(Rr,{variant:"ghost",size:"sm",onClick:d,className:"text-ndor-ink-muted","data-testid":"packs-filter-clear-btn",children:[(0,Xt.jsx)(xh,{className:"h-3 w-3 mr-1"}),"Clear filters"]})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"packs-filter-status-chips",children:[(0,Xt.jsx)("span",{className:"text-[11px] uppercase tracking-[0.16em] text-ndor-ink-muted font-mono-ui mr-1",children:"Status"}),jC.map(e=>{const t=n.includes(e.value);return(0,Xt.jsx)(Vw,{variant:"outline",role:"button",tabIndex:0,onClick:()=>l(e.value),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),l(e.value))},className:"cursor-pointer text-[11px] select-none ".concat(t?"bg-ndor-info-light text-ndor-info border-ndor-info/40":"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge hover:border-ndor-ink-muted"),"data-testid":"packs-filter-status-".concat(e.value),"data-active":t?"1":"0",children:e.label},e.value)})]}),p&&null!=i&&(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted","data-testid":"packs-filter-counter",children:["Showing ",(0,Xt.jsx)("span",{className:"tabular-nums font-medium text-ndor-ink",children:r.toLocaleStr
2ing()})," ","of ",(0,Xt.jsx)("span",{className:"tabular-nums",children:i.toLocaleString()})," pack",1===i?"":"s"]})]})}function _C(e){let{page:t,pageSize:n,total:a,hasPrev:r,hasNext:s,onPageChange:i}=e;if(!r&&!s)return null;const o=0===a?0:(t-1)*n+1,l=Math.min(a,t*n);return(0,Xt.jsxs)("div",{className:"flex items-center justify-between pt-2","data-testid":"packs-pagination",children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted font-mono-ui","data-testid":"packs-page-state",children:["Showing ",(0,Xt.jsx)("span",{className:"tabular-nums",children:o.toLocaleString()}),"\u2013",(0,Xt.jsx)("span",{className:"tabular-nums",children:l.toLocaleString()})," ","of ",(0,Xt.jsx)("span",{className:"tabular-nums",children:a.toLocaleString()})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:()=>i(Math.max(1,t-1)),disabled:!r,"data-testid":"packs-page-prev",children:[(0,Xt.jsx)(Wn,{className:"h-4 w-4 mr-1"})," Previous"]}),(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-muted font-mono-ui","data-testid":"packs-page-indicator",children:["Page ",t]}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:()=>i(t+1),disabled:!s,"data-testid":"packs-page-next",children:["Next ",(0,Xt.jsx)(qn,{className:"h-4 w-4 ml-1"})]})]})]})}NC.defaultProps={qFromUrl:"",sortFromUrl:"newest",unfilteredTotal:null};const DC=wn("shield-question",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),CC=wn("circle-minus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),AC=wn("download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),SC=wn("panels-top-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]),EC={explicit_apply_to:'from "apply to" mention',signature_block:"from signature block",inferred_from_domain:"inferred from domain",generic_mailbox:"generic careers mailbox"};function FC(e){var t,n,a,r;let{open:i,onOpenChange:o,pack:l,onDraftCreated:c}=e;const d="Application \u2014 ".concat((null===l||void 0===l||null===(t=l.job)||void 0===t?void 0:t.title)||"Role"," at ").concat((null===l||void 0===l||null===(n=l.job)||void 0===n?void 0:n.company)||"Company"),u="Hi,\n\nPlease find attached my application for the ".concat((null===l||void 0===l||null===(a=l.job)||void 0===a?void 0:a.title)||"role")+"".concat(null!==l&&void 0!==l&&null!==(r=l.job)&&void 0!==r&&r.company?" at ".concat(l.job.company):"",".\n\n")+"I'd welcome the chance to discuss how my experience maps to what you're looking for.\n\nBest regards,",[m,p]=(0,s.useState)(""),[h,f]=(0,s.useState)(null),[x,v]=(0,s.useState)(d),[g,y]=(0,s.useState)(u),[b,w]=(0,s.useState)(!1),[j,k]=(0,s.useState)(!1),{refresh:N}=If(),_=(0,s.useCallback)(async()=>{if(null!==l&&void 0!==l&&l.id){w(!0);try{const{suggestions:e=[]}=await(0,zt.n)("/api/application-packs/".concat(l.id,"/recruiter-email-suggestion"));e.length>0?(p(e[0].email),f(e[0].source)):f(null),N()}catch(pK){Gw(pK,{refreshCredits:N,action:"a recruiter-email suggestion"}),f(null)}finally{w(!1)}}},[null===l||void 0===l?void 0:l.id,N]);(0,s.useEffect)(()=>{i&&(v(d),y(u),p(""),f(null),_())},[i,null===l||void 0===l?void 0:l.id]);const D=j||!m||!x||!(null!==l&&void 0!==l&&l.id);return(0,Xt.jsx)(rg,{open:i,onOpenChange:o,children:(0,Xt.jsxs)(lg,{className:"max-w-lg","data-testid":"send-gmail-dialog",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Bg,{className:"h-5 w-5"})," Send via Gmail"]}),(0,Xt.jsx)(mg,{children:"Stage a Gmail draft with the exported bundle attached. Review and send inside Gmail."})]}),(0,Xt.jsxs)("div",{className:"space-y-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsxs)(Pg,{className:"text-xs",children:["Recipient",b&&(0,Xt.jsxs)("span",{className:"ml-2 inline-flex items-center text-xs text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-3 w-3 animate-spin mr-1"})," finding recruiter email\u2026"]}),!b&&h&&(0,Xt.jsxs)("span",{className:"ml-2 inline-flex items-center text-xs text-ndor-ink-muted",children:[(0,Xt.jsx)(Kn,{className:"h-3 w-3 mr-1"})," ",EC[h]||h]})]}),(0,Xt.jsx)(Ag,{type:"email",value:m,onChange:e=>p(e.target.value),placeholder:"[email protected]","data-testid":"send-gmail-recipient-input"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-xs",children:"Subject"}),(0,Xt.jsx)(Ag,{value:x,onChange:e=>v(e.target.value),"data-testid":"send-gmail-subject-input"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-xs",children:"Body"}),(0,Xt.jsx)(Hw,{rows:6,value:g,onChange:e=>y(e.target.value),"data-testid":"send-gmail-body-input"})]})]}),(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:()=>o(!1),disabled:j,"data-testid":"send-gmail-cancel",children:"Cancel"}),(0,Xt.jsxs)(Rr,{onClick:async()=>{k(!0);try{const e=await(0,zt.n)("/api/application-packs/".concat(l.id,"/gmail/create-draft"),{method:"POST",body:{recipient_email:m,subject:x,body:g}});fy.success("Draft staged in Gmail."),c&&c(e),o(!1)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Could not create Gmail draft.")}finally{k(!1)}},disabled:D,"data-testid":"send-gmail-submit",children:[j&&(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}),"Create draft in Gmail"]})]})]})})}const RC=[{value:"draft",label:"Draft",className:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/30"},{value:"ready",label:"Ready",className:"bg-ndor-info-light text-ndor-info border-ndor-info/30"},{value:"submitted",label:"Submitted",className:"bg-ndor-success-light text-ndor-success border-ndor-success/30"},{value:"archived",label:"Archived",className:"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge"}];function IC(e){var t,n;const a=(null===e||void 0===e?void 0:e.pack_snapshot)||{},r=!(null===e||void 0===e||!e.base_cv_id),s=(()=>{const e=null===a||void 0===a?void 0:a.source_baseline;if(!e||"object"!==typeof e)return null;if("number"===typeof e.cv_sub_score)return e.cv_sub_score;const t=e.sub_scores;return t&&"object"===typeof t&&"number"===typeof t.cv_sub_score?t.cv_sub_score:null})(),i=!(null===e||void 0===e||!e.cv_variant_id),o=function(e){let{variantExists:t,sourceSub:n,tailoredSub:a}=e;return t?"number"!==typeof a?{kind:"na",text:"N/A",raw:null}:"number"!==typeof n?{kind:"legacy",text:String(a),raw:a}:a-n>=6?{kind:"score",text:String(a),raw:a}:{kind:"not_needed",text:"Not needed",raw:a}:{kind:"na",text:"N/A",raw:null}}({variantExists:i,sourceSub:s,tailoredSub:(()=>{const t=null===a||void 0===a?void 0:a.cv_verdict;return t&&"object"===typeof t&&"number"===typeof t.cv_sub_score?t.cv_sub_score:"number"===typeof t?t:null!==e&&void 0!==e&&e.cv_variant&&"number"===typeof e.cv_variant.cv_sub_score_at_finalize?e.cv_variant.cv_sub_score_at_finalize:null})()});let l,c,d;r?"number"===typeof s?(l="score",c=String(s),d=s):(l="legacy",c="\u2014",d=null):(l="absent",c=null,d=null);const u=!(null===e||void 0===e||!e.cover_letter_id),m=a.interview_prep,p=null===a||void 0===a||null===(t=a.fit)||void 0===t||null===(n=t.reasoning_json)||void 0===n?void 0:n.interview_prep,h=!!(m&&"object"===typeof m&&Object.keys(m).length>0||p&&"object"===typeof p&&Object.keys(p).length>0);return[{kind:"base_cv",label:"Source CV",metricLabel:"CV sub-score",included:r,score:d,scoreText:c,scoreKind:l,id:(null===e||void 0===e?void 0:e.base_cv_id)||null,Icon:Nn},{kind:"variant",label:"Tailored CV",metricLabel:"CV sub-score",included:i,score:"score"===o.kind||"legacy"===o.kind?o.raw:null,scoreText:"na"===o.kind?"N/A":o.text,scoreKind:o.kind,id:(null===e||void 0===e?void 0:e.cv_variant_id)||null,Icon:Nn},{kind:"letter",label:"Cover Letter",metricLabel:null,included:u,score:null,scoreText:null,scoreKind:"absent",id:(null===e||void 0===e?void 0:e.cover_letter_id)||null,Icon:Bg},{kind:"interview_prep",label:"Interview Prep",metricLabel:null,included:h,score:null,scoreText:null,scoreKind:"absent",id:null,Icon:Kn}]}function TC(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch(t){return""}}function PC(e){let{row:t}=e;return(0,Xt.jsxs)("span",{"data-testid":"application-pack-strip-chip-".concat(t.kind),"data-included":t.included?"true":"false","data-score-text":t.scoreText||"","data-score-kind":t.scoreKind||"","data-metric-label":t.metricLabel||"","aria-label":[t.label,t.metricLabel,t.scoreText||(t.included?"":"not included")].filter(
2Boolean).join(" "),className:["inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full","text-[11px] font-medium border",t.included?"bg-ndor-success-light/60 text-ndor-success border-ndor-success/30":"bg-transparent text-ndor-ink-secondary border-ndor-edge line-through decoration-ndor-ink-muted/60"].join(" "),children:[t.included?(0,Xt.jsx)(Og,{className:"h-3 w-3","aria-hidden":!0}):(0,Xt.jsx)(CC,{className:"h-3 w-3 opacity-70","aria-hidden":!0}),(0,Xt.jsx)("span",{className:"no-underline",children:t.label}),t.scoreText&&(0,Xt.jsx)("span",{className:["tabular-nums font-semibold no-underline","number"===typeof t.score&&"score"===t.scoreKind?(n=t.score,"number"!==typeof n?"text-ndor-ink-muted":n>=70?"text-ndor-success":n>=40?"text-ndor-warning":"text-ndor-danger"):"text-ndor-ink-muted"].join(" "),"data-testid":"application-pack-strip-chip-".concat(t.kind,"-score"),children:t.scoreText})]});var n}function OC(e){let t,{row:n,packSnap:a,onPreview:r}=e;return t=n.included?"score"===n.scoreKind&&"number"===typeof n.score?"Included \xb7 ".concat(n.metricLabel||"score"," ").concat(n.score):"not_needed"===n.scoreKind?"Included \xb7 No material improvement":"legacy"===n.scoreKind&&n.scoreText?"Included \xb7 ".concat(n.metricLabel||"score"," ").concat(n.scoreText," (legacy)"):"na"===n.scoreKind||"N/A"===n.scoreText?"Included \xb7 ".concat(n.metricLabel||"score"," N/A"):n.scoreText?"Included \xb7 ".concat(n.metricLabel||"score"," ").concat(n.scoreText):"Included":"Not included",(0,Xt.jsxs)("button",{type:"button","data-testid":"application-pack-preview-".concat("base_cv"===n.kind?"source-cv":"variant"===n.kind?"tailored-cv":"letter"===n.kind?"letter":"ip","-").concat(a.id),"data-included":n.included?"true":"false",onClick:()=>n.included&&r(n),disabled:!n.included,title:n.included?"Preview ".concat(n.label):"".concat(n.label," is not included on this pack"),className:["group/tile flex items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition w-full","bg-ndor-surface/70",n.included?"border-ndor-edge hover:border-ndor-ink-muted hover:bg-ndor-surface cursor-pointer":"border-ndor-edge/50 opacity-60 cursor-not-allowed"].join(" "),children:[(0,Xt.jsx)(n.Icon,{className:["h-4 w-4 shrink-0",n.included?"text-ndor-ink":"text-ndor-ink-muted"].join(" "),"aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsx)("p",{className:"text-[12px] font-medium text-ndor-ink truncate",children:n.label}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted truncate",children:t})]}),n.included?(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] text-ndor-ink-muted",children:[(0,Xt.jsx)(zg,{className:"h-3 w-3","aria-hidden":!0}),(0,Xt.jsx)(qn,{className:"h-3 w-3 opacity-60 transition-transform group-hover/tile:translate-x-0.5","aria-hidden":!0})]}):(0,Xt.jsx)(b_,{className:"h-3 w-3 text-ndor-ink-muted/60","aria-hidden":!0})]})}function BC(e){let{open:t,onOpenChange:n,row:a,ipPayload:r,fallbackTailoredName:i,fallbackLetterName:o,sourceCvName:l}=e;const[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[p,h]=(0,s.use
2State)("");(0,s.useEffect)(()=>{if(!t||!a)return d(null),void h("");if("interview_prep"===a.kind){const e=r||{},t=[];if(e.headline&&t.push(e.headline),Array.isArray(e.likely_questions)&&e.likely_questions.length){t.push(""),t.push("Likely questions:");for(const n of e.likely_questions){const e=n.category?" (".concat(n.category,")"):"";t.push("\u2022 ".concat(n.question).concat(e))}}return void d({kind:"text",text:t.join("\n")||null})}if(!a.id)return void d(null);const e="variant"===a.kind?"/api/cv-variants/".concat(a.id):"letter"===a.kind?"/api/cover-letters/".concat(a.id):"base_cv"===a.kind?"/api/base-cvs/".concat(a.id):null;if(!e)return void d(null);let n=!0;return m(!0),h(""),(0,zt.n)(e).then(e=>{n&&d({kind:a.kind,data:e})}).catch(e=>{n&&h((null===e||void 0===e?void 0:e.message)||"Failed to load preview.")}).finally(()=>{n&&m(!1)}),()=>{n=!1}},[t,a,r]);const f=a?"variant"===a.kind?"Tailored CV \u2014 ".concat(i||"preview"):"letter"===a.kind?"Cover Letter \u2014 ".concat(o||"preview"):"base_cv"===a.kind?"Source CV \u2014 ".concat(l||"preview"):"Interview Prep preview":"Preview",x="base_cv"===(null===a||void 0===a?void 0:a.kind)?"source":"variant"===(null===a||void 0===a?void 0:a.kind)?"variant":"letter"===(null===a||void 0===a?void 0:a.kind)?"letter":null;return(0,Xt.jsx)(kh,{open:t,onOpenChange:n,children:(0,Xt.jsxs)(Ah,{side:"right",className:"w-full sm:max-w-2xl overflow-y-auto","data-testid":"application-card-preview-drawer","data-preview-kind":(null===a||void 0===a?void 0:a.kind)||"",children:[(0,Xt.jsxs)(Sh,{children:[(0,Xt.jsxs)(Fh,{className:"flex items-center gap-2","data-testid":"application-card-preview-title",children:[f,(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] tracking-[0.16em] uppercase border-ndor-edge text-ndor-ink-muted",children:[(0,Xt.jsx)(b_,{className:"h-2.5 w-2.5 mr-1"}),"Read-only"]})]}),(0,Xt.jsx)(Rh,{children:"Editing happens in the Workspace. Previews here are read-only."})]}),(0,Xt.jsxs)("div",{className:"mt-4",children:[u&&(0,Xt.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})}),!u&&p&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-danger","data-testid":"application-card-preview-error",children:p}),!u&&!p&&c&&"text"===c.kind&&c.text&&(0,Xt.jsx)("pre",{className:"whitespace-pre-wrap text-sm leading-relaxed text-ndor-ink-secondary font-sans","data-testid":"application-card-preview-body",children:c.text}),!u&&!p&&c&&"text"===c.kind&&!c.text&&(0,Xt.jsx)("p",{className:"text-ndor-ink-muted italic text-sm","data-testid":"application-card-preview-empty",children:"No content available for this preview."}),!u&&!p&&c&&x&&(0,Xt.jsx)("div",{"data-testid":"application-card-preview-body",children:(0,Xt.jsx)(Y_,{mode:x,data:c.data})})]})]})})}function LC(e){var t,a,r,i,o,l,d;let{pack:u,job:m,variant:p,letter:h,selected:f,onToggleSelected:x,expanded:v,onToggleExpanded:g,isPulsing:y,onPackUpdated:b}=e;ke();const{guardedNavigate:w,dialogProps:j}=IN(),k=(0,s.useMemo)(()=>m&&!m.__removed?m.title:m&&m.__removed||u.job_id?"Job removed by source":"Pack without linked job",[m,u.job_id]),N=m&&!m.__removed?m.company:null,_=m&&!m.__removed?m.location:null,D=u.pack_status||"draft",C=(A=D,RC.find(e=>e.value===A)||RC[0]);var A;const S=function(e){const t=String(e||"").toLowerCase();return t?"shortlist"===t||"pass"===t||"strong"===t?{label:"Shortlist",tone:"positive",Icon:Bn,className:"bg-ndor-success-light text-ndor-success border-ndor-success/30"}:"reject"===t||"fail"===t||"poor"===t?{label:"Reject",tone:"negative",Icon:mb,className:"bg-ndor-danger-light text-ndor-danger border-ndor-danger/30"}:"hold"===t||"borderline"===t||"review"===t||"maybe"===t?{label:"Review",tone:"caution",Icon:Oy,className:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/30"}:{label:t.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),tone:"neutral",Icon:DC,className:"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge"}:null}((null===u||void 0===u||null===(t=u.canonical_fit)||void 0===t?void 0:t.final_decision)||(null===u||void 0===u||null===(a=u.pack_snapshot)||void 0===a||null===(r=a.fit)||void 0===r?void 0:r.final_decision)||null),E=(0,s.useMemo)(()=>IC(u),[u]),F=(0,s.useMemo)(()=>E.filter(e=>
2"base_cv"!==e.kind),[E]),[R,I]=(0,s.useState)(D),[T,P]=(0,s.useState)(u.notes||""),[O,B]=(0,s.useState)(!1);(0,s.useEffect)(()=>{v||(I(D),P(u.notes||""))},[u.id,u.notes,u.pack_status,v]);const L=R!==D||(T||"")!==(u.notes||""),[M,z]=(0,s.useState)(!1),[U,V]=(0,s.useState)(!1),[q,W]=(0,s.useState)(!1),[H,G]=(0,s.useState)(null),[K,Y]=(0,s.useState)(!1),J=(0,s.useCallback)(async()=>{Y(!0);try{const e=await(0,zt.n)("/api/gmail/status");return W(!!e.connected),G(e.email||null),!!e.connected}catch(e){return W(!1),G(null),!1}finally{Y(!1)}},[]);(0,s.useEffect)(()=>{function e(e){var t;W(!0),G((null===e||void 0===e||null===(t=e.detail)||void 0===t?void 0:t.email)||null)}return window.addEventListener("ndorflow-gmail-connected",e),()=>window.removeEventListener("ndorflow-gmail-connected",e)},[]);const[$,X]=(0,s.useState)(null);return(0,Xt.jsxs)(Fy,{"data-testid":"application-pack-row-".concat(u.id),"data-pulse":y?"true":void 0,"data-expanded":v?"true":void 0,"data-pack-status":D,className:["group overflow-hidden transition-all duration-200","border border-ndor-edge bg-ndor-surface/95 backdrop-blur-sm","rounded-2xl shadow-sm",f?"border-ndor-ink-muted bg-ndor-surface-alt/40":"hover:border-ndor-ink-muted/70",y?"ring-2 ring-ndor-gold/60 animate-pulse":"",v?"shadow-md":""].join(" "),children:[(0,Xt.jsxs)("div",{className:"flex items-stretch gap-3 px-4 py-3.5 sm:px-5",children:[(0,Xt.jsx)("div",{className:"pt-1 shrink-0",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:"presentation",children:(0,Xt.jsx)(Vb,{checked:f,onCheckedChange:e=>null===x||void 0===x?void 0:x(u.id,!!e),"aria-label":"Select pack ".concat(u.id),"data-testid":"application-pack-select-".concat(u.id)})}),(0,Xt.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[(0,Xt.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[(0,Xt.jsx)(kn,{className:"h-4 w-4 text-ndor-ink-secondary shrink-0","aria-hidden":!0}),(0,Xt.jsx)("button",{type:"button",onClick:()=>null===g||void 0===g?void 0:g(u.id),className:"text-sm font-semibold text-ndor-ink hover:underline truncate text-left","data-testid":"application-pack-title-".concat(u.id),"aria-expanded":v,children:k})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-ndor-ink-secondary",children:[N&&(0,Xt.jsx)("span",{"data-testid":"application-pack-company-".concat(u.id),children:N}),_&&(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,Xt.jsx)(qw,{className:"h-3 w-3","aria-hidden":!0}),_]}),(0,Xt.jsxs)("span",{children:["Created ",TC(u.created_at)]}),u.updated_at&&u.updated_at!==u.created_at&&(0,Xt.jsxs)("span",{children:["\xb7 Updated ",TC(u.updated_at)]})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap justify-end",children:[(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] uppercase tracking-[0.12em] px-2 py-0.5 ".concat(C.className),"data-testid":"application-pack-status-".concat(u.id),children:C.label}),S&&(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] uppercase tracking-[0.12em] px-2 py-0.5 inline-flex items-center gap-1 ".concat(S.className),"data-testid":"application-pack-recommendation-".concat(u.id),"data-tone":S.tone,children:[(0,Xt.jsx)(S.Icon,{className:"h-3 w-3","aria-hidden":!0}),S.label]})]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2","data-testid":"application-pack-row-actions-".concat(u.id),children:[(0,Xt.jsx)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"application-pack-strip-".concat(u.id),children:E.map(e=>(0,Xt.jsx)(PC,{row:e},e.kind))}),(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap sm:justify-end",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-[11px]",onClick:async()=>{if(!M){z(!0);try{const{supabase:t}=await Promise.resolve().then(n.bind(n,820)),{data:{session:a}}=await t.auth.getSession();if(null===a||void 0===a||!a.access_token)throw new Error("Not authenticated.");const r=await fetch("".concat("https://app.ndorflow.app","/api/application-packs/").concat(u.id,"/export-bundle"),{headers:{Authorization:"Bearer ".concat(a.access_token)}});if(!r.ok){let t="Download failed (".concat(r.status,")");try{t=(await r.json()).detail||t}catch(e){}throw new Error(t)}const s=(r.headers.get("Content-Disposition")||"").match(/filename="([^"]+)"/),i=s?s[1]:"ApplicationPack.zip",o=await r.blob(),l=URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=i,document.body.appendChild(c),c.click(),c.remove(),setTimeout(()=>URL.revokeObjectURL(l),1500),fy.success("Downloaded ".concat(i))}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Download failed.")}finally{z(!1)}}},disabled:M,"data-testid":"application-pack-download-".concat(u.id),title:"Download Application Pack",children:[M?(0,Xt.jsx)(Lg,{className:"h-3 w-3 mr-1 animate-spin"}):(0,Xt.jsx)(AC,{className:"h-3 w-3 mr-1"}),"Download"]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-[11px]",onClick:async()=>
2{if(K)return;if(await J())V(!0);else try{const{auth_url:e}=await(0,zt.n)("/api/gmail/oauth/start");window.open(e,"ndorflow-gmail-oauth","width=540,height=680"),fy.info("Connect Gmail in the popup, then click Send via Gmail again.")}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Could not start Gmail OAuth.")}},disabled:K,"data-testid":"application-pack-send-gmail-".concat(u.id),title:q?"Send via Gmail (".concat(H||"connected",")"):"Send via Gmail",children:[K?(0,Xt.jsx)(Lg,{className:"h-3 w-3 mr-1 animate-spin"}):(0,Xt.jsx)(_n,{className:"h-3 w-3 mr-1"}),"Send via Gmail"]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-[11px]",onClick:()=>{if(!u.job_id)return;const e=new URLSearchParams;u.cv_variant_id?(e.set("last_variant_id",u.cv_variant_id),e.set("source_cv_id",u.cv_variant_id),e.set("source_cv_type","cv_variant")):u.base_cv_id&&(e.set("source_cv_id",u.base_cv_id),e.set("source_cv_type","base_cv")),u.cover_letter_id&&e.set("cover_letter_id",u.cover_letter_id),u.interview_prep_id&&e.set("interview_prep_id",u.interview_prep_id),e.set("from_pack",u.id||"1");const t=e.toString(),n="/applications/workspace/".concat(u.job_id).concat(t?"?".concat(t):"");w(n)},disabled:!u.job_id,"data-testid":"application-pack-open-workspace-".concat(u.id),title:"Open Workspace",children:[(0,Xt.jsx)(SC,{className:"h-3 w-3 mr-1"}),"Open Workspace"]}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",className:"h-7 px-2 text-[11px] text-ndor-ink-secondary",onClick:()=>null===g||void 0===g?void 0:g(u.id),"data-testid":"application-pack-expand-".concat(u.id),"aria-expanded":v,children:v?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Tv,{className:"h-3 w-3 mr-1"}),"Collapse"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Gn,{className:"h-3 w-3 mr-1"}),"Details"]})})]})]})]})]}),v&&(0,Xt.jsx)("div",{className:"border-t border-ndor-edge bg-ndor-surface-alt/30 px-5 py-4","data-testid":"application-pack-expanded-".concat(u.id),children:(0,Xt.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-5",children:[(0,Xt.jsxs)("div",{className:"lg:col-span-2 space-y-3",children:[(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsx)("label",{htmlFor:"status-".concat(u.id),className:"text-[10px] uppercase tracking-[0.12em] text-ndor-ink-muted font-medium",children:"Status"}),(0,Xt.jsxs)(Vv,{value:R,onValueChange:I,children:[(0,Xt.jsx)(Wv,{id:"status-".concat(u.id),className:"h-9 text-xs","data-testid":"application-pack-status-select-".concat(u.id),children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:RC.map(e=>(0,Xt.jsx)(Yv,{value:e.value,"data-testid":"application-pack-status-option-".concat(e.value),children:e.label},e.value))})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsx)("label",{htmlFor:"notes-".concat(u.id),className:"text-[10px] uppercase tracking-[0.12em] text-ndor-ink-muted font-medium",children:"Notes"}),(0,Xt.jsx)(Hw,{id:"notes-".concat(u.id),value:T,onChange:e=>P(e.target.value),placeholder:"Private notes about this application\u2026",rows:6,className:"text-xs resize-y min-h-[7rem]","data-testid":"application-pack-notes-".concat(u.id)})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",className:"h-8 px-3 text-[11px]",onClick:()=>{I(D),P(u.notes||"")},disabled:!L||O,"data-testid":"application-pack-cancel-".concat(u.id),children:[(0,Xt.jsx)(xh,{className:"h-3 w-3 mr-1"}),"Cancel"]}),(0,Xt.jsxs)(Rr,{size:"sm",className:"h-8 px-3 text-[11px]",onClick:async()=>{if(L&&!O){B(!0);try{const e={};R!==D&&(e.pack_status=R),(T||"")!==(u.notes||"")&&(e.notes=T);const t=await(0,zt.n)("/api/application-packs/".concat(u.id),{method:"PATCH",body:e});fy.success("Changes saved."),nw(["applications","application-packs:all"]),null===b||void 0===b||b(t)}catch(mK){var e;fy.error((null===mK||void 0===mK||null===(e=mK.data)||void 0===e?void 0:e.detail)||(null===mK||void 0===mK?void 0:mK.message)||"Save failed.")}finally{B(!1)}}},disabled:!L||O,"data-testid":"application-pack-save-".concat(u.id),children:[O?(0,Xt.jsx)(Lg,{className:"h-3 w-3 mr-1 animate-spin"}):(0,Xt.jsx)($N,{className:"h-3 w-3 mr-1"}),"Save"]})]})]}),(0,Xt.jsxs)("div",{className:"lg:col-span-3 space-y-2",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.12em] text-ndor-ink-muted font-medium",children:"Preview included artefacts"}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2","data-testid":"application-pack-preview-tiles-".concat(u.id),children:F.map(e=>(0,Xt.jsx)(OC,{row:e,packSnap:u,onPreview:X},e.kind))})]})]})}),(0,Xt.jsx)(BC,{open:!!$,onOpenChange:e=>{e||X(null)},row:$,ipPayload:(null===u||void 0===u||null===(i=u.pack_snapshot)||void 0===i?void 0:i.interview_prep)||(null===u||void 0===u||null===(o=u.pack_snapshot)||void 0===o||null===(l=o.fit)||void 0===l||null===(d=l.reasoning_json)||void 0===d?void 0:d.interview_prep)||null,fallbackTailoredName:(null===p||void 0===p?void 0:p.variant_name)||(null===p||void 0===p?void 0:p.role_family)||"",fallbackLetterName:(null===h||void 0===h?void 0:h.title)||(null===h||void 0===h?void 0:h.target_role)||"",sourceCvName:(null===u||void 0===u?void 0:u.base_cv)&&(u.base_cv.file_name||u.base_cv.name)||""}),(0,Xt.jsx)(FC,{open:U,onOpenChange:V,pack:(0,c.A)((0,c.A)({},u),{},{job:m}),onDraftCreated:()=>{fy.success("Draft staged in Gmail."),nw(["applications","application-packs:all"])}}),(0,Xt.jsx)(TN,(0,c.A)({},j))]})}function MC(e){var t,n,a,r;const s=[];return null!==(t=e.archived)&&void 0!==t&&t.length&&s.push("".concat(e.archived.length," archived")),null!==(n=e.already_archived)&&void 0!==n&&n.length&&s.push("".concat(e.already_archived.length," already archived")),null!==(a=e.invalid_transition)&&void 0!==a&&a.length&&s.push("".concat(e.invalid_transition.length," can't be archived directly (walk through submitted first)")),null!==(r=e.not_found)&&void 0!==r&&r.length&&s.push("".concat(e.not_found.length," not found")),s.join(" \xb7 ")||"No changes"}function zC(e){var t,n;const a=[];return null!==(t=e.deleted)&&void 0!==t&&t.length&&a.push("".concat(e.deleted.length," deleted")),null!==(n=e.not_found)&&void 0!==n&&n.length&&a.push("".concat(e.not_found.length," not found")),a.join(" \xb7 ")||"No changes"}function UC(){const[e,t]=Pt(),n=e.get("q")||"",a=e.get("sort")||"newest",r=e.get("status")||"",i=(0,s.useMemo)(()=>r.split(",").map(e=>
2e.trim()).filter(Boolean),[r]),o=Math.max(1,parseInt(e.get("page")||"1",10)||1),l=Math.max(1,parseInt(e.get("page_size")||String(25),10)||25),[d,u]=(0,s.useState)([]),[m,p]=(0,s.useState)(0),[h,f]=(0,s.useState)(null),[x,v]=(0,s.useState)(!1),[g,y]=(0,s.useState)(!1),[b,w]=(0,s.useState)({}),[j,k]=(0,s.useState)({}),[N,_]=(0,s.useState)({}),[D,C]=(0,s.useState)(!0),A=e.get("highlight")||null,[S,E]=(0,s.useState)(null),F=(0,s.useRef)(!1),[R,I]=(0,s.useState)({}),[T,P]=(0,s.useState)(!1),[O,B]=(0,s.useState)(null),L=(0,s.useCallback)(e=>{B(t=>t===e?null:e)},[]),M=(0,s.useCallback)(function(e){let{resetPage:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t(t=>{const a=new URLSearchParams(t);return Object.entries(e).forEach(e=>{let[t,n]=e;null===n||void 0===n||""===n?a.delete(t):a.set(t,String(n))}),n&&a.delete("page"),a},{replace:!1})},[t]),z=(0,s.useCallback)(e=>M({q:e||null},{resetPage:!0}),[M]),U=(0,s.useCallback)(e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e);const n=Array.from(t).join(",");M({status:n||null},{resetPage:!0})},[i,M]),V=(0,s.useCallback)(e=>M({sort:"newest"===e?null:e},{resetPage:!0}),[M]),q=(0,s.useCallback)(()=>{t(new URLSearchParams)},[t]),W=(0,s.useCallback)(e=>M({page:e>1?e:null}),[M]),H=(0,s.useCallback)(()=>{const e=new URLSearchParams;return e.set("page",String(o)),e.set("page_size",String(l)),a&&"newest"!==a&&e.set("sort",a),i.length>0&&e.set("status",i.join(",")),n&&e.set("q",n),e.toString()},[o,l,a,i,n]);function G(e){let t=[];return Array.isArray(e)?(t=e,p(e.length),v(!1),y(!1),f(null)):e&&Array.isArray(e.items)?(t=e.items,p(Number(e.total)||0),v(Boolean(e.has_next)),y(Boolean(e.has_prev)),f("number"===typeof e.unfiltered_total?e.unfiltered_total:null)):(t=[],p(0),v(!1),y(!1),f(null)),u(t),I(e=>{const n=new Set(t.map(e=>e.id)),a={};return Object.keys(e).forEach(e=>{n.has(e)&&(a[e]=!0)}),a}),t}const K=(0,s.useCallback)(async()=>{const e=H(),t=aw(e),n=sw(),a=iw();ew(t,18e4).hit||C(!0);try{const[r,s,i]=await Promise.all([tw(t,()=>(0,zt.n)("/api/application-packs?".concat(e)).catch(()=>null),{ttlMs:18e4}),tw(n,()=>(0,zt.n)("/api/cv-variants").catch(()=>[]),{ttlMs:3e5}),tw(a,()=>(0,zt.n)("/api/cover-letters").catch(()=>[]),{ttlMs:3e5})]),o=G(r);k(Object.fromEntries((s||[]).map(e=>[e.id,e]))),_(Object.fromEntries((i||[]).map(e=>[e.id,e])));const l=Array.from(new Set(o.map(e=>e.job_id).filter(Boolean))),c=await Promise.all(l.map(async e=>{try{const t=await tw(ow(e),()=>(0,zt.n)("/api/jobs/".concat(e)),{ttlMs:3e5});return[e,t]}catch(mK){return[e,404===(null===mK||void 0===mK?void 0:mK.status)?{__removed:!0}:null]}})),d=Object.fromEntries(c.filter(e=>{let[,t]=e;return null!==t}));w(d)}finally{C(!1)}},[H]);(0,s.useEffect)(()=>{K()},[K]),(0,s.useEffect)(()=>{async function e(e){if(null!==e&&void 0!==e&&e.data&&"ndorflow-gmail"===e.data.source&&"ok"===e.data.status&&e.data.payload)try{await(0,zt.n)("/api/gmail/oauth/finalize",{method:"POST",body:e.data.payload});const t=e.data.payload.email_address||null;fy.success("Gmail connected".concat(t?" as ".concat(t):"",".")),window.dispatchEvent(new CustomEvent("ndorflow-gmail-connected",{detail:{email:t}}))}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Gmail finalize failed.")}}return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]);const Y=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(Y.current)return;Y.current=!0;const e=ew(aw(H()),18e4);e.hit&&e.data&&(G(e.data),e.fresh&&C(!1))},[]),(0,s.useEffect)(()=>{const e=function(e,t){let n=Xb.get(e);return n||(n=new Set,Xb.set(e,n)),n.add(t),()=>{const n=Xb.get(e);n&&(n.delete(t),0===n.size&&Xb.delete(e))}}(aw(H()),e=>{G(e)});return e},[H]);const J=(0,s.useMemo)(()=>d.map(e=>({pack:e,job:b[e.job_id],variant:j[e.cv_variant_id],letter:e.cover_letter_id?N[e.cover_letter_id]:null})),[d,b,j,N]);(0,s.useEffect)(()=>{if(!A||D||F.current)return;const e=J.some(e=>e.pack.id===A);if(!e)return;F.current=!0,E(A),requestAnimationFrame(()=>{const e=document.querySelector('[data-testid="application-pack-row-'.concat(A,'"]'));e&&"function"===typeof e.scrollIntoView&&e.scrollIntoView({behavior:"smooth",block:"center"})});const n=setTimeout(()=>E(null),2500),a=setTimeout(()=>{t(e=>{const t=new URLSearchParams(e);return t.delete("highlight"),t},{replace:!0})},2700);return()=>{clearTimeout(n),clearTimeout(a)}},[A,D,J,t]);const $=Object.keys(R).length,X=(0,s.useMemo)(()=>Object.keys(R),[R]),Q=(0,s.useMemo)(()=>J.map(e=>{let{pack:t}=e;return t.id}),[J]),Z=Q.length>0&&Q.every(e=>R[e]),ee=(0,s.useCallback)((e,t)=>{I(n=>{const a=(0,c.A)({},n);return t?a[e]=!0:delete a[e],a})},[]),te=(0,s.useCallback)(()=>{I(e=>{if(Q.length>0&&Q.every(t=>e[t])){const t=(0,c.A)({},e);for(const e of Q)delete t[e];return t}const t=(0,c.A)({},e);for(const n of Q)t[n]=!0;return t})},[Q]),ne=(0,s.useCallback)(()=>I({}),[]),ae=(0,s.useCallback)(async()=>
2{if(!T&&0!==X.length){P(!0);try{const e=await(0,zt.n)("/api/application-packs/bulk-archive",{method:"POST",body:{pack_ids:X}});fy.success("Bulk archive",{description:MC(e)}),ne(),nw(["applications","application-packs:all"]),await K()}catch(mK){fy.error("Bulk archive failed",{description:mK.message})}finally{P(!1)}}},[T,X,ne,K]),re=(0,s.useCallback)(async()=>{if(T||0===X.length)return;if(window.confirm("Delete ".concat(X.length," pack").concat(1===X.length?"":"s","? ")+"Linked CVs, cover letters, and jobs stay intact.")){P(!0);try{const e=await(0,zt.n)("/api/application-packs/bulk-delete",{method:"POST",body:{pack_ids:X}});fy.success("Bulk delete",{description:zC(e)}),ne(),nw(["applications","application-packs:all"]),await K()}catch(mK){fy.error("Bulk delete failed",{description:mK.message})}finally{P(!1)}}},[T,X,ne,K]);return(0,Xt.jsxs)("div",{"data-testid":"applications-page",className:"space-y-6",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h2",{className:"text-2xl font-semibold tracking-tight text-ndor-ink font-outfit",children:"Applications"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-1 font-manrope",children:"Your application packs \u2014 each pinned to one job. A pack contains whatever you generated: your Source CV with Baseline Fit, or a tailored Variant CV with Variant Fit, plus an optional cover letter. Track status and export here."})]}),(0,Xt.jsx)(NC,{qFromUrl:n,statusesFromUrl:i,sortFromUrl:a,total:m,unfilteredTotal:h,onQChange:z,onStatusToggle:U,onSortChange:V,onClearFilters:q}),$>0&&(0,Xt.jsxs)("div",{"data-testid":"bulk-action-bar",className:"sticky top-0 z-10 -mx-2 px-4 py-2 rounded-md border border-ndor-edge bg-ndor-surface-alt shadow-sm flex items-center justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Xt.jsxs)("label",{className:"flex items-center gap-2 text-xs text-ndor-ink-muted cursor-pointer select-none","data-testid":"bulk-select-all-label",children:[(0,Xt.jsx)(Vb,{checked:Z,onCheckedChange:te,"aria-label":Z?"Clear all visible":"Select all visible","data-testid":"bulk-select-all-toggle"}),Z?"Clear all visible":"Select all visible"]}),(0,Xt.jsxs)("span",{className:"text-sm text-ndor-ink font-medium","data-testid":"bulk-selected-count",children:[$," selected"]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:ae,disabled:T,"data-testid":"bulk-archive-btn",children:[T?(0,Xt.jsx)(Lg,{className:"h-3 w-3 mr-1 animate-spin"}):(0,Xt.jsx)(Vn,{className:"h-3 w-3 mr-1"}),"Archive"]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:re,disabled:T,className:"text-ndor-danger hover:text-ndor-danger","data-testid":"bulk-delete-btn",children:[T?(0,Xt.jsx)(Lg,{className:"h-3 w-3 mr-1 animate-spin"}):(0,Xt.jsx)(pb,{className:"h-3 w-3 mr-1"}),"Delete"]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:ne,disabled:T,"data-testid":"bulk-clear-btn",children:[(0,Xt.jsx)(xh,{className:"h-3 w-3 mr-1"}),"Clear"]})]})]}),D?(0,Xt.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,Xt.jsx)(Lg,{className:"h-6 w-6 animate-spin text-ndor-ink-muted"})}):0===d.length?(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm",children:(0,Xt.jsxs)(Py,{className:"py-10 text-center space-y-2",children:[(0,Xt.jsx)(Rw,{className:"h-6 w-6 mx-auto text-ndor-ink-muted"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink font-medium",children:n||i.length>0?"No packs match these filters":"No application packs yet"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted max-w-sm mx-auto",children:n||i.length>0?"Try a different name or status, or clear filters to see all packs.":(0,Xt.jsxs)(Xt.Fragment,{children:["Open a job, click ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Start application pack"}),", and link a Source CV + CV variant to begin tracking."]})}),n||i.length>0?(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:q,className:"text-ndor-info","data-testid":"applications-empty-clear-filters",children:"Clear filters"}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Et,{to:"/jobs",className:"inline-block pt-3",children:(0,Xt.jsx)("span",{className:"text-xs text-ndor-info hover:underline","data-testid":"applications-empty-jobs-link",children:"Browse jobs \u2192"})}),(0,Xt.jsxs)("div",{className:"mt-5 mx-auto max-w-md rounded-md border border-ndor-edge bg-ndor-surface-alt/40 p-3 text-left","data-testid":"applications-empty-reviewer-hint",children:[(0,Xt.jsx)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Recommended next step"}),(0,Xt.jsxs)("ol",{className:"mt-2 space-y-1.5 text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"1."}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)(Et,{to:"/jobs",className:"text-ndor-info hover:underline",children:"Import or choose a job"})," from the Jobs page."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"2."}),(0,Xt.jsxs)("span",{children:["Run ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Analyse Fit"})," on the job using your Source CV."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"3."}),(0,Xt.jsxs)("span",{children:["Create an ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"application pack"})," from the job \u2014 it shows up here for tracking and export."]}
2)]})]})]})]})]})}):(0,Xt.jsx)("div",{className:"space-y-2.5","data-testid":"applications-list",children:J.map(e=>{let{pack:t,job:n,variant:a,letter:r}=e;return(0,Xt.jsx)(LC,{pack:t,job:n,variant:a,letter:r,selected:!!R[t.id],onToggleSelected:ee,expanded:O===t.id,onToggleExpanded:L,isPulsing:S===t.id,onPackUpdated:e=>{u(n=>n.map(n=>n.id===t.id?(0,c.A)((0,c.A)({},n),e):n))}},t.id)})}),!D&&d.length>0&&(0,Xt.jsx)(_C,{page:o,pageSize:l,total:m,hasPrev:g,hasNext:x,onPageChange:W})]})}const VC=wn("receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]),qC=wn("refresh-ccw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);function WC(e){if(null===e||void 0===e)return null;const t="number"===typeof e?e:Number(e);if(!Number.isFinite(t))return null;const n=t<=1?Math.round(100*t):Math.round(t);return Math.min(100,Math.max(0,n))}function HC(e){if(null===e||void 0===e)return null;const t="number"===typeof e?e:Number(e);return Number.isFinite(t)?t>0?"+".concat(Math.round(t)):t<0?"\u2212".concat(Math.abs(Math.round(t))):"".concat("\xb1","0"):null}function GC(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function KC(e){if(!e)return null;return{shortlist:"Shortlist",apply_with_repositioning:"Apply with repositioning",hold:"Hold",skip:"Skip"}[e]||e}const YC={success:"bg-ndor-success-light text-ndor-success border-ndor-success/20",info:"bg-ndor-info-light text-ndor-info border-ndor-info/20",warning:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/30",muted:"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge"};function JC(e){let{k:t,v:n,testId:a}=e;return(0,Xt.jsxs)("div",{className:"flex items-baseline justify-between gap-3 py-1.5 border-b border-ndor-edge last:border-b-0","data-testid":"pack-receipt-row-".concat(a),children:[(0,Xt.jsx)("dt",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui shrink-0",children:t}),(0,Xt.jsx)("dd",{className:"text-sm text-ndor-ink text-right",children:null===n||void 0===n||""===n?(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"\u2014"}):n})]})}function $C(e){let{status:t}=e;return(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] ".concat(YC[t.tone]||YC.muted),children:t.label})}function XC(e){var t;let{pack:n}=e;const[a,r]=(0,s.useState)(!1),{usageCosts:i}=If(),o=Nf(i,"cv_improve");if(!n)return null;const l=n.binding||{},c=n.canonical_fit||null,d=n.cv_variant||null,u=n.base_cv||null,m=n.cover_letter||null,p=d&&d.optimisation_artifacts||null,h=p&&p.analytics_metadata||null,f=function(e,t,n){return null!==t&&void 0!==t&&t.charged_at?{label:"Finalized",tone:"success"}:null!==e&&void 0!==e&&e.cv_sub_score_provisional?{label:"Preview \u2014 finalize to confirm",tone:"warning"}:"source_cv"===(null===n||void 0===n?void 0:n.cv_kind)?{label:"Source CV grade",tone:"info"}:{label:"\u2014",tone:"muted"}}(c,d,l),x=function(e,t,n){if(!e)return{label:"Not finalized",tone:"muted"};const a=e.charge_reason;if(e.charged_at){if("cv_quality_improved"===a){if(null!==n&&void 0!==n){const e=1===n?"Credit":"Credits";return{label:"".concat(n," ").concat(e," \u2014 quality uplift"),tone:"success"}}return{label:"Quality uplift",tone:"success"}}if("presentation_optimisation_high_cv"===a){if(null!==n&&void 0!==n){const e=Math.max(1,Math.round(n/2)),t=1===e?"Credit":"Credits";return{label:"".concat(e," ").concat(t," \u2014 presentation optimisation"),tone:"info"}}return{label:"Presentation optimisation",tone:"info"}}return"within_tolerance_band"===a?{label:"Waived \u2014 within \xb15 tolerance band",tone:"info"}:"regression"===a||"cv_quality_no_improvement"===a?{label:"Waived \u2014 variant did n
2ot improve",tone:"muted"}:{label:a||"Charged",tone:"muted"}}return null===t||void 0===t||t.cv_kind,{label:"Not finalized",tone:"muted"}}(d,l,o),v="stale_refresh_available"===(null===c||void 0===c?void 0:c.rubric_status);return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"pack-receipt-panel",children:[(0,Xt.jsx)(Ry,{className:"pb-2",children:(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(VC,{className:"h-4 w-4 text-ndor-ink-muted"}),"Receipt & provenance"]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted mt-1",children:"What was selected, what was assessed, and what was charged for this pack."})]}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>r(e=>!e),className:"text-xs text-ndor-info shrink-0","data-testid":"pack-receipt-toggle",children:a?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Tv,{className:"h-3.5 w-3.5 mr-1"})," Hide details"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Gn,{className:"h-3.5 w-3.5 mr-1"})," Show details"]})})]})}),(0,Xt.jsxs)(Py,{className:"space-y-3",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-baseline gap-2 text-sm pt-1","data-testid":"pack-receipt-provenance",children:[(0,Xt.jsx)("span",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Prep based on:"}),(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium",children:(null===l||void 0===l?void 0:l.cv_label)||"\u2014"}),(0,Xt.jsx)($C,{status:f})]}),a&&(0,Xt.jsxs)("div",{className:"space-y-4 pt-1","data-testid":"pack-receipt-detail",children:[(0,Xt.jsxs)("section",{children:[(0,Xt.jsx)("h4",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui mb-1",children:"Selected documents"}),(0,Xt.jsxs)("dl",{children:[(0,Xt.jsx)(JC,{k:"Source CV",v:null===u||void 0===u?void 0:u.original_filename,testId:"source-cv"}),(0,Xt.jsx)(JC,{k:"Tailored Variant",v:(null===d||void 0===d?void 0:d.variant_name)||("tailored_variant"===(null===l||void 0===l?void 0:l.cv_kind)?null===l||void 0===l?void 0:l.cv_label:null),testId:"tailored-variant"}),(0,Xt.jsx)(JC,{k:"Cover letter",v:(null===m||void 0===m?void 0:m.title)||(m?null:"Not included"),testId:"cover-letter"})]})]}),(0,Xt.jsxs)("section",{children:[(0,Xt.jsx)("h4",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui mb-1",children:"Canonical fit"}),(0,Xt.jsxs)("dl",{children:[(0,Xt.jsx)(JC,{k:"NDOR fit score",v:WC(null===c||void 0===c?void 0:c.fit_score),testId:"fit-score"}),(0,Xt.jsx)(JC,{k:"NDOR CV verdict",v:null===c||void 0===c?void 0:c.cv_sub_score,testId:"cv-verdict"}),(0,Xt.jsx)(JC,{k:"Verdict status",v:(0,Xt.jsx)($C,{status:f}),testId:"verdict-status"}),(0,Xt.jsx)(JC,{k:"Final decision",v:KC(null===c||void 0===c?void 0:c.final_decision),testId:"final-decision"}),(0,Xt.jsx)(JC,{k:"Evaluated",v:GC(null===c||void 0===c?void 0:c.evaluated_at),testId:"evaluated"})]})]}),(0,Xt.jsxs)("section",{children:[(0,Xt.jsx)("h4",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui mb-1",children:"Charge"}),(0,Xt.jsxs)("dl",{children:[(0,Xt.jsx)(JC,{k:"Charge outcome",v:(0,Xt.jsx)($C,{status:x}),testId:"charge-outcome"}),(0,Xt.jsx)(JC,{k:"\u0394 vs Source",v:HC(null===h||void 0===h?void 0:h.variant_uplift_delta),testId:"delta"}),(0,Xt.jsx)(JC,{k:"Source CV verdict at finalize",v:null===h||void 0===h?void 0:h.source_cv_sub_score,testId:"source-cv-sub-score"}),(0,Xt.jsx)(JC,{k:"Variant CV verdict at finalize",v:null!==(t=null===d||void 0===d?void 0:d.cv_sub_score_at_finalize)&&void 0!==t?t:null===h||void 0===h?void 0:h.variant_cv_sub_score,testId:"variant-cv-sub-score"}),(0,Xt.jsx)(JC,{k:"Tolerance band",v:"".concat("\xb1","5 points"),testId:"tolerance-band"}),(0,Xt.jsx)(JC,{k:"Finalized at",v:GC(null===d||void 0===d?void 0:d.charged_at),testId:"finalized-at"})]})]}),(0,Xt.jsxs)("section",{children:[(0,Xt.jsx)("h4",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui mb-1",children:"Build attestation"}),(0,Xt.jsxs)("dl",{children:[(0,Xt.jsx)(JC,{k:"Rubric version",v:null===c||void 0===c?void 0:c.rubric_version,testId:"rubric-version"}),(0,Xt.jsx)(JC,{k:"Scoring model",v:null===c||void 0===c?void 0:c.scoring_model_version,testId:"scoring-model-version"}),(0,Xt.jsx)(JC,{k:"Build label",v:n.current_version,testId:"current-version"}),(0,Xt.jsx)(JC,{k:"Rubric status",v:v?(0,Xt.jsx)("span",{className:"inline-flex items-center gap-2",children:(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] ".concat(YC.warning),children:[(0,Xt.jsx)(qC,{className:"h-3 w-3 mr-1"}),"Rubric updated since this score"]})}):"Current",testId:"rubric-status"})]})]}),(0,Xt.jsxs)("p",{className:"text-[11px] italic text-ndor-ink-muted flex items-center gap-1.5 pt-1","data-testid":"pack-receipt-footer",children:[(0,Xt.jsx)(Bn,{className:"h-3 w-3"}),"Read-only attestation \u2014 does not trigger a re-grade or charge."]})]})]})]})}XC.defaultProps={pack:null};const QC=wn("scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}
2],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]),ZC={pursue:"bg-ndor-success-light text-ndor-success border-ndor-success/20",tailor:"bg-ndor-info-light text-ndor-info border-ndor-info/20",reposition:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/20",develop:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/20",manual_review:"bg-ndor-danger-light text-ndor-danger border-ndor-danger/20",monitor:"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge",no_run:"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge"};function eA(e){let{icon:t,label:n,value:a,tone:r,testid:s}=e;const i={ok:"bg-ndor-success-light text-ndor-success border-ndor-success/20",neutral:"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge",warn:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/20",bad:"bg-ndor-danger-light text-ndor-danger border-ndor-danger/20"}[r]||"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge";return(0,Xt.jsxs)("div",{"data-testid":s,className:"inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-medium ".concat(i),children:[(0,Xt.jsx)(t,{className:"h-3.5 w-3.5","aria-hidden":!0}),(0,Xt.jsx)("span",{className:"text-ndor-ink-muted/90",children:n}),(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium",children:a})]})}function tA(e){let{pack:t}=e;if(!t)return null;const n=t.cv_variant,a=t.cover_letter,r=t.canonical_fit,s=t.fit_status||"missing";let i;i=n?{icon:Og,label:"Variant",value:"Tailored CV ready",tone:"ok"}:t.base_cv_id?{icon:Og,label:"CV",value:"Source CV",tone:"ok"}:{icon:ep,label:"Variant",value:"Not bound",tone:"bad"};const o=a?{icon:Og,label:"Cover letter",value:"Attached",tone:"ok"}:{icon:Bg,label:"Cover letter",value:"\u2014",tone:"neutral"},l=e=>{if(null==e||Number.isNaN(Number(e)))return null;const t=Number(e);return Math.round(t<=1?100*t:t)};let d;if("current"===s&&r){const e=l(r.fit_score);d={icon:Bw,label:"Canonical fit",value:"".concat(null!==e&&void 0!==e?e:"\u2014","/100"),tone:"ok"}}else if("stale_rubric"===s&&r){const e=l(r.fit_score);d={icon:pg,label:"Canonical fit",value:"".concat(null!==e&&void 0!==e?e:"\u2014","/100 \xb7 rubric updated"),tone:"warn"}}else d="initial_source_cv"===s?{icon:Oy,label:"Canonical fit",value:"Source CV baseline only",tone:"warn"}:"tombstoned_variant_body"===s?{icon:Oy,label:"Canonical fit",value:"Variant body expired",tone:"warn"}:"stale"===s?{icon:pg,label:"Canonical fit",value:"Stale",tone:"warn"}:{icon:ep,label:"Canonical fit",value:"Not analysed",tone:"bad"};const u=r&&(r.final_decision||r.governance_decision)||null,m=function(e){if(!e||"string"!==typeof e)return"no_run";const t=e.split(/[/\xb7\s]/)[0].trim().toLowerCase();return Object.prototype.hasOwnProperty.call(ZC,t)?t:"no_run"}(u||"no_run"),p=u?u.replaceAll("_"," "):"Not analysed";return(0,Xt.jsxs)("div",{"data-testid":"pack-readiness-strip",className:"flex flex-wrap items-center gap-2 rounded-xl border border-ndor-edge bg-ndor-surface px-3 py-2.5",role:"status","aria-label":"Pack readiness",children:[(0,Xt.jsx)("span",{className:"text-[11px] uppercase tracking-wider text-ndor-ink-muted font-medium pl-1 pr-2",children:"Pack readiness"}),(0,Xt.jsx)(eA,(0,c.A)((0,c.A)({},i),{},{testid:"pack-readiness-variant"})),(0,Xt.jsx)(eA,(0,c.A)((0,c.A)({},o),{},{testid:"pack-readiness-cover-letter"})),(0,Xt.jsx)(eA,(0,c.A)((0,c.A)({},d),{},{testid:"pack-readiness-canonical-fit"})),(0,Xt.jsxs)("div",{"data-testid":"pack-readiness-governance-verdict",className:"inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-medium ".concat(ZC[m]),children:[(0,Xt.jsx)(QC,{className:"h-3.5 w-3.5","aria-hidden":!0}),(0,Xt.jsx)("span",{className:"text-ndor-ink-muted/90",children:"Governance"}),(0,Xt.jsx)("span",{className:"font-medium uppercase tracking-wide",children:p})]}),(0,Xt.jsx)(Nn,{className:"hidden","aria-hidden":!0})," "]})}function nA(e){return e&&"string"===typeof e?e.length>12?"".concat(e.slice(0,8),"\u2026"):e:"\u2014"}function aA(e){if(!e||"string"!==typeof e)return"\u2014";try{const t=new Date(e);
2return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1})}catch(t){return e}}function rA(e){let{label:t,value:n,full:a,testid:r}=e;return(0,Xt.jsxs)("div",{"data-testid":r,className:"flex items-baseline justify-between gap-3 border-b border-ndor-edge last:border-0 py-1.5",children:[(0,Xt.jsx)("span",{className:"text-xs text-ndor-ink-muted",children:t}),(0,Xt.jsx)("span",{className:"font-mono-ui text-[11px] text-ndor-ink truncate text-right",title:a||n,children:n})]})}function sA(e){let{trustAnchors:t}=e;const n=t||{},a=n.pack_run_id||null,r=n.canonical_run_id||null,s=n.matrix_version||null,i=n.generated_at||null,o=n.pack_version||null,l=n.governance_decision||null;return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"pack-trust-card",children:[(0,Xt.jsxs)(Ry,{className:"pb-2",children:[(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-gold","aria-hidden":!0}),"Trust attestation"]}),(0,Xt.jsx)("p",{"data-testid":"pack-trust-card-subline",className:"text-[11px] text-ndor-ink-muted leading-relaxed",children:"These anchors are stamped into the exported PDF properties pane (Producer \xb7 Keywords) so a recruiter can verify provenance directly from Acrobat."})]}),(0,Xt.jsxs)(Py,{className:"space-y-0",children:[(0,Xt.jsx)(rA,{label:"Pack run ID",value:nA(a),full:a||"\u2014",testid:"pack-trust-row-pack-run-id"}),(0,Xt.jsx)(rA,{label:"Canonical run ID",value:nA(r),full:r||"\u2014",testid:"pack-trust-row-canonical-run-id"}),(0,Xt.jsx)(rA,{label:"Governance matrix",value:s||"\u2014",full:s||"\u2014",testid:"pack-trust-row-matrix-version"}),(0,Xt.jsx)(rA,{label:"Governance verdict",value:l?l.toUpperCase():"\u2014",testid:"pack-trust-row-verdict"}),(0,Xt.jsx)(rA,{label:"Pack version",value:o||"\u2014",testid:"pack-trust-row-pack-version"}),(0,Xt.jsx)(rA,{label:"Generated",value:aA(i),full:i||"\u2014",testid:"pack-trust-row-generated-at"}),(0,Xt.jsx)("p",{"data-testid":"pack-trust-card-footer",className:"text-[11px] text-ndor-ink-muted pt-2",children:"Read-only attestation \u2014 does not trigger a re-grade or charge."})]})]})}const iA={draft:{label:"Draft",className:"bg-ndor-warning-light text-ndor-warning border-ndor-warning/20"},ready:{label:"Ready",className:"bg-ndor-info-light text-ndor-info border-ndor-info/20"},submitted:{label:"Submitted",className:"bg-ndor-success-light text-ndor-success border-ndor-success/20"},archived:{label:"Archived",className:"bg-ndor-surface-alt text-ndor-ink-muted border-ndor-edge"}};function oA(){var e,t,n,a,r,i;const{id:o}=_e(),l=ke(),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!0),[p,h]=(0,s.use
2State)(!1),[f]=(0,s.useState)(!1),[x,v]=(0,s.useState)(!1),[g,y]=(0,s.useState)(!1),[b,w]=(0,s.useState)(null),[j,k]=(0,s.useState)(!1),[N,_]=(0,s.useState)([]),[D,C]=(0,s.useState)("draft"),[A,S]=(0,s.useState)(""),[E,F]=(0,s.useState)(""),[R,I]=(0,s.useState)(null),T=(0,s.useCallback)(async()=>{m(!0);try{const e=await(0,zt.n)("/api/application-packs/".concat(o));d(e),C(e.pack_status||"draft"),S(e.notes||""),F(e.pack_name||"")}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to load pack."),l("/applications")}finally{m(!1)}},[o,l]);(0,s.useEffect)(()=>{T()},[T]),(0,s.useEffect)(()=>{if(!c)return void I(null);const e=c.canonical_fit;I(e?{fit_score:e.fit_score,reasoning_json:e.reasoning||{}}:null)},[c]);const P=(0,s.useCallback)(async()=>{try{const e=await(0,zt.n)("/api/gmail/status");y(!!e.connected),w(e.email||null)}catch(e){}},[]),O=(0,s.useCallback)(async()=>{try{const e=await(0,zt.n)("/api/application-packs/".concat(o,"/send-receipts"));_(Array.isArray(e)?e:[])}catch(e){}},[o]);(0,s.useEffect)(()=>{P(),O()},[P,O]),(0,s.useEffect)(()=>{async function e(e){if(null!==e&&void 0!==e&&e.data&&"ndorflow-gmail"===e.data.source&&"ok"===e.data.status&&e.data.payload)try{await(0,zt.n)("/api/gmail/oauth/finalize",{method:"POST",body:e.data.payload}),fy.success("Gmail connected as ".concat(e.data.payload.email_address,".")),P()}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Gmail finalize failed.")}}return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[P]);const B=c&&(D!==(c.pack_status||"draft")||(A||"")!==(c.notes||""));if(u)return(0,Xt.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,Xt.jsx)(Lg,{className:"h-6 w-6 animate-spin text-ndor-ink-muted"})});if(!c)return null;const{job:L,base_cv:M,cv_variant:z,cover_letter:U}=c,V=iA[c.pack_status]||iA.draft,q=!!z,W=!!U,H=(null===c||void 0===c?void 0:c.pack_snapshot)||{},G=null===H||void 0===H?void 0:H.interview_prep,K=null===H||void 0===H||null===(e=H.fit)||void 0===e||null===(t=e.reasoning_json)||void 0===t?void 0:t.interview_prep,Y=!!(G&&"object"===typeof G&&Object.keys(G).length>0||K&&"object"===typeof K&&Object.keys(K).length>0),J=q||W||Y,$=J?"Download the application pack ZIP.":"This pack has no generated artefacts yet. Generate a Tailored CV, Cover Letter, or Interview Prep to create an exportable pack.",X={draft:"Draft",ready:"Ready",submitted:"Submitted",archived:"Archived"},Q=c.allowed_status_transitions&&c.allowed_status_transitions.length>0?c.allowed_status_transitions:[c.pack_status||"draft"];return(0,Xt.jsxs)("div",{"data-testid":"application-pack-detail-page",className:"space-y-5 max-w-4xl",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsxs)(Et,{to:"/applications",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink inline-flex items-center gap-1 mb-2",children:[(0,Xt.jsx)(Zg,{className:"h-3 w-3"})," Back to applications"]}),(0,Xt.jsxs)("h2",{className:"text-xl sm:text-2xl font-semibold tracking-tight text-ndor-ink font-outfit flex items-center gap-2",children:[(0,Xt.jsx)(Rw,{className:"h-5 w-5 text-ndor-ink-muted shrink-0"}),(0,Xt.jsx)("span",{className:"whitespace-nowrap",children:"Application pack"}),(0,Xt.jsx)(Vw,{variant:"outline",className:"text-xs shrink-0 ".concat(V.className),"data-testid":"pack-status-badge",children:V.label})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsxs)(Rr,{size:"sm",onClick:async()=>{v(!0);try{const{data:{session:t}}=await Mt.supabase.auth.getSession();if(null===t||void 0===t||!t.access_token)throw new Error("Not authenticated.");const n=await fetch("".concat("https://app.ndorflow.app","/api/application-packs/").concat(o,"/export-bundle"),{headers:{Authorization:"Bearer ".concat(t.access_token)}});if(!n.ok){let t="Export failed (".concat(n.status,")");try{t=(await n.json()).detail||t}catch(e){}throw new Error(t)}const a=(n.headers.get("Content-Disposition")||"").match(/filename="([^"]+)"/),r=a?a[1]:"ApplicationPack.zip",s=await n.blob(),i=URL.createObjectURL(s),l=document.createElement("a");l.href=i,l.download=r,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(i),fy.success("Bundle downloaded.")}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Bundle export failed.")}finally{v(!1)}},disabled:x||p||f||!J,"data-testid":"pack-export-bundle-button",title:$,className:"bg-ndor-gold text-ndor-ink hover:bg-ndor-gold/90 font-medium",children:[x?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}):(0,Xt.jsx)(AC,{className:"h-4 w-4 mr-1.5"}),"Download Application Pack"]}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:()=>{g?k(!0):(async()=>{try{const{auth_url:e}=await(0,zt.n)("/api/gmail/oauth/start");
2window.open(e,"ndorflow-gmail-oauth","width=540,height=680")}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Could not start Gmail OAuth.")}})()},disabled:x||p||f||!z&&!U,"data-testid":"pack-send-gmail-trigger",title:g?"Send via Gmail (".concat(b||"connected",")"):"Connect Gmail to send",children:[(0,Xt.jsx)(_n,{className:"h-4 w-4 mr-1.5"}),g?"Send via Gmail (".concat(b||"connected",")"):"Connect Gmail to send"]})]})]}),!J&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted -mt-2","data-testid":"pack-export-baseline-only-notice",children:"This pack has no generated artefacts yet. Generate a Tailored CV, Cover Letter, or Interview Prep to create an exportable pack."}),(0,Xt.jsxs)("div",{className:"space-y-5","data-testid":"pack-tab-overview",children:[(0,Xt.jsx)(tA,{pack:c}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm",children:[(0,Xt.jsx)(Ry,{className:"pb-3",children:(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(kn,{className:"h-4 w-4 text-ndor-ink-muted"})," Job"]})}),(0,Xt.jsx)(Py,{className:"space-y-2",children:L?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(Et,{to:"/jobs/".concat(L.id),className:"text-base font-medium text-ndor-ink hover:underline","data-testid":"pack-job-link",children:L.title}),L.url&&(0,Xt.jsxs)("a",{href:L.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink inline-flex items-center gap-1",children:[(0,Xt.jsx)(KN,{className:"h-3 w-3"})," source"]})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-ndor-ink-muted",children:[L.company&&(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,Xt.jsx)(Pn,{className:"h-3 w-3"}),L.company]}),L.location&&(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,Xt.jsx)(qw,{className:"h-3 w-3"}),L.location]})]})]}):(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Job row unavailable."})})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm",children:[(0,Xt.jsx)(Ry,{className:"pb-3",children:(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"Pack details"})}),(0,Xt.jsxs)(Py,{className:"space-y-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"Pack name"}),(0,Xt.jsx)(Ag,{value:E,readOnly:!0,"data-testid":"pack-name-input"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"pack-name-hint",children:"System-generated. You can rename your downloaded file locally."})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5 max-w-xs",children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"Status"}),(0,Xt.jsxs)(Vv,{value:D,onValueChange:C,children:[(0,Xt.jsx)(Wv,{"data-testid":"pack-status-select",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:Q.map(e=>(0,Xt.jsx)(Yv,{value:e,"data-testid":"pack-status-option-".concat(e),children:X[e]||e},e))})]}),"archived"===c.pack_status?(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Archived packs are final. Delete if you no longer need it."}):Q.length<=1?null:(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Moves forward only: draft \u2192 ready \u2192 submitted \u2192 archived (or archive a draft)."})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-xs text-ndor-ink-muted",children:"Notes"}),(0,Xt.jsx)(Hw,{value:A,onChange:e=>S(e.target.value),placeholder:"e.g. referred by Jane, follow up in 2 weeks",rows:3,"data-testid":"pack-notes-input"})]}),(0,Xt.jsx)("div",{className:"flex justify-end",children:(0,Xt.jsxs)(Rr,{onClick:async()=>{if(B){h(!0);try{const e={};D!==c.pack_status&&(e.pack_status=D),(A||"")!==(c.notes||"")&&(e.notes=A),await(0,zt.n)("/api/application-packs/".concat(o),{method:"PATCH",body:e}),fy.success("Pack updated."),await T()}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to update pack.")}finally{h(!1)}}},disabled:!B||p,"data-testid":"pack-save-button",children:[p?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}):(0,Xt.jsx)($N,{className:"h-4 w-4 mr-1.5"}),"Save changes"]})})]})]}),(0,Xt.jsx)(XC,{pack:c}),(0,Xt.jsx)(sA,{trustAnchors:{pack_run_id:(null===c||void 0===c?void 0:c.cv_variant_id)||null,canonical_run_id:(null===c||void 0===c||null===(n=c.canonical_fit)||void 0===n?void 0:n.analyse_run_id)||(null===c||void 0===c||null===(a=c.canonical_fit)||void 0===a?void 0:a.run_id)||null,matrix_version:"matrix_v1_opportunity_preserving",generated_at:(null===c||void 0===c?void 0:c.updated_at)||(null===c||void 0===c?void 0:c.created_at)||null,pack_version:"RC 1.48.4B \xb7 pack ".concat(((null===c||void 0===c?void 0:c.id)||"").slice(0,8)),governance_decision:(null===c||void 0===c||null===(r=c.canonical_fit)||void 0===r?void 0:r.governance_decision)||(null===c||void 0===c||null===(i=c.canonical_fit)||void 0===i?void 0:i.final_decision)||null}}),N.length>0&&(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"pack-send-receipts",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsxs)(Iy,{className:"text-base font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bg,{className:"h-4 w-4"})," Gmail drafts"]})}),(0,Xt.jsx)(Py,{className:"space-y-2",children:N.map(e=>(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 text-sm border-b border-ndor-edge last:border-0 pb-2 last:pb-0","data-testid":"pack-send-receipt-row",children:[(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsxs)("div",{className:"truncate text-ndor-ink",children:[(0,Xt.jsx)("span",{className:"font-medium",children:e.subject}),(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted",children:[" \u2192 ",e.recipient_email]})]}),(0,Xt.jsxs)("div",{className:"text-[11px] text-ndor-ink-muted",children:[new Date(e.created_at).toLocaleStr
2ing()," \xb7 ",e.attachment_format.toUpperCase()," \xb7"," ","draft_created"===e.status?"Draft staged":"draft_create_failed"===e.status?"Failed: ".concat(e.error_message||"see logs"):e.status]})]}),e.gmail_draft_url&&(0,Xt.jsx)("a",{href:e.gmail_draft_url,target:"_blank",rel:"noopener noreferrer",children:(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",children:[(0,Xt.jsx)(KN,{className:"h-3.5 w-3.5 mr-1.5"})," Open"]})})]},e.id))})]})]}),(0,Xt.jsx)(FC,{open:j,onOpenChange:k,pack:c,onDraftCreated:()=>O()})]})}const lA=[{slug:"cv",label:"CV",shortLabel:"CV",Icon:Nn},{slug:"letter",label:"Cover Letter",shortLabel:"Letter",Icon:Bg},{slug:"interview",label:"Interview Prep",shortLabel:"Prep",Icon:Kn},{slug:"pack",label:"Application Pack",shortLabel:"Pack",Icon:kn}],cA=lA.map(e=>e.slug);function dA(e){let{activeSlug:t,onSelect:n,completed:a={},furthestIndex:r,disabled:s=!1}=e;const i=lA.findIndex(e=>e.slug===t),o="number"===typeof r;return(0,Xt.jsx)("nav",{"aria-label":"Application workspace sections","data-testid":"workspace-section-nav",className:"flex flex-nowrap items-center gap-1.5 sm:gap-2 overflow-x-auto snap-x snap-mandatory scrollbar-hide -mx-1 px-1",children:lA.map((e,t)=>{const l=t===i,c=!!a[e.slug],d=o&&t>r||s;return(0,Xt.jsxs)("button",{type:"button",onClick:()=>{d||null===n||void 0===n||n(e.slug)},disabled:d,"data-testid":"workspace-section-nav-".concat(e.slug),"aria-current":l?"step":void 0,"aria-disabled":d?"true":void 0,className:["snap-start shrink-0 flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs font-medium transition whitespace-nowrap",l?"border-ndor-gold bg-ndor-gold/10 text-ndor-ink shadow-sm":d?"border-ndor-line text-ndor-ink-muted/50 cursor-not-allowed":"border-ndor-line text-ndor-ink-muted hover:border-ndor-line-strong hover:text-ndor-ink"].join(" "),children:[c?(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5 text-emerald-600 shrink-0","aria-hidden":!0}):(0,Xt.jsx)(e.Icon,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,Xt.jsx)("span",{className:"sm:hidden",children:e.shortLabel}),(0,Xt.jsx)("span",{className:"hidden sm:inline",children:e.label})]},e.slug)})})}var uA=Symbol("radix.slottable");function mA(e){const t=e=>{let{children:t}=e;return(0,Xt.jsx)(Xt.Fragment,{children:t})};return t.displayName="".concat(e,".Slottable"),t.__radixId=uA,t}const pA=["__scopeAlertDialog"],hA=["__scopeAlertDialog"],fA=["__scopeAlertDialog"],xA=["__scopeAlertDialog"],vA=["__scopeAlertDialog","children"],gA=["__scopeAlertDialog"],yA=["__scopeAlertDialog"],bA=["__scopeAlertDialog"],wA=["__scopeAlertDialog"];var jA="AlertDialog",[kA,NA]=js(jA,[Fp]),_A=Fp(),DA=e=>{const{__scopeAlertDialog:t}=e,n=l(e,pA),a=_A(t);return(0,Xt.jsx)(lh,(0,c.A)((0,c.A)((0,c.A)({},a),n),{},{modal:!0}))};DA.displayName=jA;var CA=s.forwardRef((e,t)=>{const{__scopeAlertDialog:n}=e,a=l(e,hA),r=_A(n);return(0,Xt.jsx)(ch,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});CA.displayName="AlertDialogTrigger";var AA=e=>{const{__scopeAlertDialog:t}=e,n=l(e,fA),a=_A(t);return(0,Xt.jsx)(dh,(0,c.A)((0,c.A)({},a),n))};AA.displayName="AlertDialogPortal";var SA=s.forwardRef((e,t)=>{const{__scopeAlertDialog:n}=e,a=l(e,xA),r=_A(n);return(0,Xt.jsx)(uh,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});SA.displayName="AlertDialogOverlay";var EA="AlertDialogContent",[FA,RA]=kA(EA),IA=mA("AlertDialogContent"),TA=s.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:a}=e,r=l(e,vA),i=_A(n),o=s.useRef(null),d=Xn(t,o),u=s.useRef(null);return(0,Xt.jsx)(rh,{contentName:EA,titleName:PA,docsSlug:"alert-dialog",children:(0,Xt.jsx)(FA,{scope:n,cancelRef:u,children:(0,Xt.jsxs)(mh,(0,c.A)((0,c.A)((0,c.A)({role:"alertdialog"},i),r),{},{ref:d,onOpenAutoFocus:ys(r.onOpenAutoFocus,e=>{var t;e.preventDefault(),null===(t=u.current)||void 0===t||t.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,Xt.jsx)(IA,{children:a}),(0,Xt.jsx)(VA,{contentRef:o})]}))})})});TA.displayName=EA;var PA="AlertDialogTitle",OA=s.forwardRef((e,t)=>{const{__scopeAlertDialog:n}=e,a=l(e,gA),r=_A(n);return(0,Xt.jsx)(ph,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});OA.displayName=PA;var BA="AlertDialogDescription",LA=s.forwardRef((e,t)=>
2{const{__scopeAlertDialog:n}=e,a=l(e,yA),r=_A(n);return(0,Xt.jsx)(hh,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});LA.displayName=BA;var MA=s.forwardRef((e,t)=>{const{__scopeAlertDialog:n}=e,a=l(e,bA),r=_A(n);return(0,Xt.jsx)(fh,(0,c.A)((0,c.A)((0,c.A)({},r),a),{},{ref:t}))});MA.displayName="AlertDialogAction";var zA="AlertDialogCancel",UA=s.forwardRef((e,t)=>{const{__scopeAlertDialog:n}=e,a=l(e,wA),{cancelRef:r}=RA(zA,n),s=_A(n),i=Xn(t,r);return(0,Xt.jsx)(fh,(0,c.A)((0,c.A)((0,c.A)({},s),a),{},{ref:i}))});UA.displayName=zA;var VA=e=>{let{contentRef:t}=e;const n="`".concat(EA,"` requires a description for the component to be accessible for screen reader users.\n\nYou can add a description to the `").concat(EA,"` by passing a `").concat(BA,"` component as a child, which also benefits sighted users by adding visible context to the dialog.\n\nAlternatively, you can use your own component as a description by assigning it an `id` and passing the same value to the `aria-describedby` prop in `").concat(EA,"`. If the description is confusing or duplicative for sighted users, you can use the `@radix-ui/react-visually-hidden` primitive as a wrapper around your description component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/alert-dialog");return s.useEffect(()=>{var e;document.getElementById(null===(e=t.current)||void 0===e?void 0:e.getAttribute("aria-describedby"))||console.warn(n)},[n,t]),null},qA=SA,WA=TA,HA=MA,GA=UA,KA=OA,YA=LA;const JA=["className"],$A=["className"],XA=["className"],QA=["className"],ZA=["className"],eS=["className"],tS=["className"],nS=["className"],aS=DA,rS=CA,sS=AA,iS=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,JA);return(0,Xt.jsx)(qA,(0,c.A)((0,c.A)({className:Sr("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n)},a),{},{ref:t}))});iS.displayName=qA.displayName;const oS=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,$A);return(0,Xt.jsxs)(sS,{children:[(0,Xt.jsx)(iS,{}),(0,Xt.jsx)(WA,(0,c.A)({ref:t,className:Sr("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n)},a))]})});oS.displayName=WA.displayName;const lS=e=>{let{className:t}=e,n=l(e,XA);return(0,Xt.jsx)("div",(0,c.A)({className:Sr("flex flex-col space-y-2 text-center sm:text-left",t)},n))};lS.displayName="AlertDialogHeader";const cS=e=>{let{className:t}=e,n=l(e,QA);return(0,Xt.jsx)("div",(0,c.A)({className:Sr("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t)},n))};cS.displayName="AlertDialogFooter";const dS=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,ZA);return(0,Xt.jsx)(KA,(0,c.A)({ref:t,className:Sr("text-lg font-semibold",n)},a))});dS.displayName=KA.displayName;const uS=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,eS);return(0,Xt.jsx)(YA,(0,c.A)({ref:t,className:Sr("text-sm text-muted-foreground",n)},a))});uS.displayName=YA.displayName;const mS=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,tS);return(0,Xt.jsx)(HA,(0,c.A)({ref:t,className:Sr(Fr(),n)},a))});mS.displayName=HA.displayName;const pS=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,nS);return(0,Xt.jsx)(GA,(0,c.A)({ref:t,className:Sr(Fr({variant:"outline"}),"mt-2 sm:mt-0",n)},a))});pS.displayName=GA.displayName;const hS=wn("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const fS=function(e){let{className:t,testId:n}=e;return(0,Xt.jsxs)("span",{role:"status","aria-label":"Loaded from history","data-testid":n||"workspace-loaded-from-history-badge",className:Sr("inline-flex items-center gap-1 rounded-full","border border-amber-500/40 bg-amber-500/10","px-2 py-0.5 text-[10px] font-medium uppercase","tracking-wide text-amber-200",t),children:[(0,Xt.jsx)(hS,{className:"h-3 w-3","aria-hidden":"true"}),(0,Xt.jsx)("span",{children:"Loaded from history"})]})};function xS(e){return"string"!==typeof e||0===e.length?e:e.replace(/^[ \t]*#{1,6}[ \t]+/gm,"").replace(/^([ \t]*)[-*+][ \t]+/gm,"$1\u2022 ").replace(/^[ \t]*(?:-{3,}|\*{3,}|_{3,})[ \t]*$/gm,"").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/(\*\*\*|___)(.+?)\1/g,"$2").replace(/(\*\*|__)(.+?)\1/g,"$2").replace(/(?<![*_])([*_])([^*_\n]+?)\1(?![*_])/g,"$2")}Object.freeze({wrap_polling_helper:"lib/cvVariantPolling.js::generateCvVariantWithPolling",url_param_contract:["source_cv_type=cv_variant","source_cv_id={id}"],inflight_marker_key:"inflight-cv-variant:${userId}:${jobId}",side_effects_owned_by_adapter:[],side_effects_owned_by_section:["idempotency_key derivation (getOrMintIdempotencyKey)","inflight marker write/clear (writeInflightCvMar
2ker / clearInflightCvMarker)","finalize-charge call","URL param writes (source_cv_id, source_cv_type, last_variant_id)","credits.refresh()","cooldown start","emit pack:artefact_ready (post-finalize-charge)"]});const vS=new EventTarget,gS=Object.freeze({START:"operation:start",PROGRESS:"operation:progress",RECOVERING:"operation:recovering",RECOVERABLE_STALL:"operation:recoverable_stall",STABILIZING:"operation:stabilizing",COMPLETE:"operation:complete",FAIL:"operation:fail",ABORT:"operation:abort",PACK_ARTEFACT_READY:"pack:artefact_ready"});function yS(e,t){if(!e||"string"!==typeof e)throw new Error("emit: type is required");if(!Object.values(gS).includes(e))throw new Error("emit: unknown event type '".concat(e,"'"));vS.dispatchEvent(new CustomEvent(e,{detail:t||{}}))}function bS(e,t){if(!e||"string"!==typeof e)throw new Error("subscribe: type is required");if("function"!==typeof t)throw new Error("subscribe: handler must be a function");const n=e=>t(e.detail);return vS.addEventListener(e,n),()=>vS.removeEventListener(e,n)}const wS=["promise"],jS=["promise"],kS=Object.freeze({IDLE:"idle",DISPATCHING:"dispatching",POLLING:"polling",RECOVERING:"recovering",RECOVERABLE_STALL:"recoverable_stall",STABILIZING:"stabilizing",COMPLETE:"complete",FAILED:"failed",ABORTED:"aborted"}),NS=new Set([kS.DISPATCHING,kS.POLLING,kS.RECOVERING,kS.RECOVERABLE_STALL,kS.STABILIZING]),_S=new Map;function DS(e,t){return"".concat(e||"","::").concat(t||"")}function CS(e){const t=new Set(["cv_variant","cover_letter","interview_prep","analyse_fit"]);if(!t.has(e))throw new Error("OperationLifecycleController: unknown actionCode '".concat(e,"'. ")+"Allowed: ".concat([...t].join(", "),"."))}function AS(e){let{jobId:t,actionCode:n,runId:a=null,idempotencyKey:r=null,run:s}=e;if(!t)throw new Error("dispatch: jobId is required");if(!n)throw new Error("dispatch: actionCode is required");if("function"!==typeof s)throw new Error("dispatch: run must be a function returning a Promise");CS(n);const i=DS(t,n),o=_S.get(i);if(o&&NS.has(o.status))return o.promise;const l=(async()=>{try{var e;SS(i,{status:kS.DISPATCHING}),await Promise.resolve();const a=await s({onPolling:()=>SS(i,{status:kS.POLLING}),onProgress:(e,a)=>{var r;return yS(gS.PROGRESS,{jobId:t,actionCode:n,runId:(null===(r=_S.get(i))||void 0===r?void 0:r.runId)||null,status:e,progressLabel:a||null})},onRunIdReady:e=>{SS(i,{runId:e})}});return SS(i,{status:kS.STABILIZING,terminalEnvelope:a}),yS(gS.STABILIZING,{jobId:t,actionCode:n,runId:(null===(e=_S.get(i))||void 0===e?void 0:e.runId)||null,envelope:a}),a}catch(pK){var a;throw SS(i,{status:kS.FAILED,error:pK}),yS(gS.FAIL,{jobId:t,actionCode:n,runId:(null===(a=_S.get(i))||void 0===a?void 0:a.runId)||null,error:{message:null===pK||void 0===pK?void 0:pK.message,code:null===pK||void 0===pK?void 0:pK.code,status:null===pK||void 0===pK?void 0:pK.status}}),pK}})();return _S.set(i,{jobId:t,actionCode:n,runId:a,idempotencyKey:r,status:kS.DISPATCHING,startedAt:Date.now(),promise:l,error:null,terminalEnvelope:null}),yS(gS.START,{jobId:t,actionCode:n,runId:a,idempotencyKey:r}),l}function SS(e,t){const n=_S.get(e);n&&_S.set(e,(0,c.A)((0,c.A)({},n),t))}function ES(e,t){const n=_S.get(DS(e,t));if(!n)return null;const{promise:a}=n;return l(n,wS)}function FS(e){for(const t of function(e){const t=[];for(const[n,a]of _S)if(!e||n.startsWith("".concat(e,"::"))){const{promise:e}=a,n=l(a,jS);t.push(n)}return t}(e))if(NS.has(t.status))return!0;return!1}const RS=new Set(["cv_variant","cover_letter","interview_prep","analyse_fit"]);function IS(e,t){if(t&&!RS.has(t))throw new Error("useOperationLifecycle: unknown actionCode '".concat(t,"'"));const[n,a]=(0,s.useState)(()=>e&&t?ES(e,t):null),[r,i]=(0,s.useState)(()=>!!e&&FS(e));(0,s.useEffect)(()=>{if(!e||!t)return;const n=()=>{a(ES(e,t)),i(FS(e))},r=[gS.START,gS.PROGRESS,gS.STABILIZING,gS.COMPLETE,gS.FAIL,gS.ABORT].map(a=>bS(a,a=>{a.jobId===e&&(a.actionCode===t?n():i(FS(e)))}));return n(),()=>{r.forEach(e=>e&&e())}},[e,t]);const o=(0,s.useCallback)(n=>AS((0,c.A)({jobId:e,actionCode:t},n)),[e,t]),l=(0,s.useCallback)(n=>function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"user_aborted";const a=DS(e,t),r=_S.get(a);return!(!r||!NS.has(r.status))&&(SS(a,{status:kS.ABORTED,error:{message:n}}),yS(gS.ABORT,{jobId:e,actionCode:t,runId:r.runId,reason:n}),!0)}
2(e,t,n),[e,t]),d=(0,s.useCallback)(n=>function(e){let{jobId:t,actionCode:n,runId:a,idempotencyKey:r=null,run:s}=e;if(!t)throw new Error("attachExistingRun: jobId is required");if(!n)throw new Error("attachExistingRun: actionCode is required");if(!a)throw new Error("attachExistingRun: runId is required");if("function"!==typeof s)throw new Error("attachExistingRun: run must be a function");CS(n);const i=DS(t,n),o=_S.get(i);return o&&NS.has(o.status)?o.promise:AS({jobId:t,actionCode:n,runId:a,idempotencyKey:r,run:s})}((0,c.A)({jobId:e,actionCode:t},n)),[e,t]),u=(0,s.useCallback)(n=>function(e,t){var n;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const r=DS(e,t),s=_S.get(r);return!!s&&s.status!==kS.COMPLETE&&(s.status===kS.STABILIZING||s.status===kS.POLLING||s.status===kS.DISPATCHING)&&(SS(r,{status:kS.COMPLETE,terminalEnvelope:a||s.terminalEnvelope||null}),yS(gS.COMPLETE,{jobId:e,actionCode:t,runId:(null===(n=_S.get(r))||void 0===n?void 0:n.runId)||null,envelope:a||s.terminalEnvelope||null}),!0)}(e,t,n),[e,t]),m=(0,s.useCallback)(n=>function(e,t,n){var a;const r=DS(e,t),s=_S.get(r);return!!s&&!!NS.has(s.status)&&(SS(r,{status:kS.FAILED,error:n||{message:"failed"}}),yS(gS.FAIL,{jobId:e,actionCode:t,runId:(null===(a=_S.get(r))||void 0===a?void 0:a.runId)||null,error:n?{message:n.message,code:n.code,status:n.status}:{message:"failed"}}),!0)}(e,t,n),[e,t]);return{status:(null===n||void 0===n?void 0:n.status)||kS.IDLE,runId:(null===n||void 0===n?void 0:n.runId)||null,terminalEnvelope:(null===n||void 0===n?void 0:n.terminalEnvelope)||null,error:(null===n||void 0===n?void 0:n.error)||null,idempotencyKey:(null===n||void 0===n?void 0:n.idempotencyKey)||null,isAnyRunning:r,dispatch:o,abort:l,attach:d,markComplete:u,markFailed:m}}let TS=null;function PS(){return null===TS&&(TS=function(){if("undefined"===typeof window)return!1;try{if("1"===new URLSearchParams(window.location.search).get("action_trace"))return!0}catch(t){}try{var e;if("true"===(null===(e=window.localStorage)||void 0===e?void 0:e.getItem("NDORFLOW_ACTION_TRACE")))return!0}catch(n){}return!1}()),TS}function OS(e,t,n){if(!PS())return;const a="[NDOR_TRACE ".concat(e||"unknown"," ").concat(t,"]");try{const e=n?JSON.parse(JSON.stringify(n,BS)):null;console.info(a,e)}catch(mK){console.info(a,"[unserialisable payload]",String((null===mK||void 0===mK?void 0:mK.message)||mK))}}function BS(e,t){return void 0===t?null:t}const LS=Object.freeze({dispatching:"Preparing your tailored CV\u2026",running:"Tailoring your CV\u2026",polling:"Tailoring your CV\u2026",aggregating:"Analysing the job requirements\u2026",hydrating:"Updating your documents\u2026",finalizing:"Finalising your tailored CV\u2026",stabilizing:"Saving your tailored CV\u2026",complete:"Tailored CV ready.",failed:"CV generation hit a snag."}),MS=Object.freeze({dispatching:"Preparing your cover letter\u2026",running:"Drafting your cover letter\u2026",polling:"Drafting your cover letter\u2026",aggregating:"Matching your experience to the role\u2026",hydrating:"Updating your documents\u2026",finalizing:"Finalising your cover letter\u2026",stabilizing:"Updating your documents\u2026",complete:"Cover letter ready.",failed:"Cover letter generation hit a snag."}),zS=Object.freeze({dispatching:"Preparing interview context\u2026",running:"Building interview questions\u2026",polling:"Building interview questions\u2026",aggregating:"Analysing likely interview themes\u2026",hydrating:"Updating your documents\u2026",finalizing:"Preparing strategic guid
2ance\u2026",stabilizing:"Updating your documents\u2026",complete:"Interview Prep ready.",failed:"Interview Prep hit a snag."}),US=Object.freeze({dispatching:"Preparing\u2026",running:"Working on it\u2026",polling:"Working on it\u2026",complete:"Ready.",failed:"That action failed."}),VS=Object.freeze({cv_variant:LS,cover_letter:MS,interview_prep:zS,analyse_fit:US});function qS(e,t,n){if(!t||"idle"===t)return null;const a=VS[e]||US;return n&&a[n]?a[n]:a[t]||a.running||null}Object.freeze({CV_VARIANT_COPY:LS,COVER_LETTER_COPY:MS,INTERVIEW_PREP_COPY:zS,FALLBACK_COPY:US});const WS="cv_variant";let HS=!1,GS=[];const KS=new Map;function YS(){return HS||(HS=!0,GS.push(bS(gS.COMPLETE,e=>{OS((null===e||void 0===e?void 0:e.actionCode)||"unknown","lifecycle_complete_event",{jobId:null===e||void 0===e?void 0:e.jobId,runId:null===e||void 0===e?void 0:e.runId}),function(e,t){const n=KS.get(e);if(n)for(const a of n)try{a(t)}catch(mK){console.warn("[lifecycleSubscribers] invalidator threw",mK)}}(null===e||void 0===e?void 0:e.actionCode,e)})),GS.push(bS(gS.FAIL,e=>{OS((null===e||void 0===e?void 0:e.actionCode)||"unknown","lifecycle_fail_event",{jobId:null===e||void 0===e?void 0:e.jobId,error:null===e||void 0===e?void 0:e.error})}))),JS}function JS(){GS.forEach(e=>{try{e&&e()}catch(t){}}),GS=[],HS=!1}Object.freeze({wrap_polling_helper:"lib/coverLetterPolling.js::generateCoverLetterWithPolling",url_param_contract:["cover_letter_id={id}"],inflight_marker_key:"inflight-cover-letter:${userId}:${jobId}",side_effects_owned_by_adapter:[],side_effects_owned_by_section:["idempotency_key derivation (getOrMintIdempotencyKey)","inflight marker write/clear (writeInflightLetterMarker / clearInflightLetterMarker)","URL param writes (cover_letter_id) \u2014 synchronous on success","cache invalidation (cover-letters:all)","awaited credits.refresh() inside the stabilization chain","lifecycle markComplete after all stabilization lands"]});Object.freeze({wrap_polling_helper:"lib/interviewPrepPolling.js::generateInterviewPrepWithPolling",poll_resume_helper:"lib/interviewPrepPolling.js::pollInterviewPrepUntilTerminal",url_param_contract:["interview_prep_id={id} (written SYNC on async_202)"],inflight_marker_key:"inflight-interview-prep:${userId}:${jobId}",side_effects_owned_by_adapter:[],side_effects_owned_by_section:["idempotency_key derivation (getOrMintIdempotencyKey)","inflight marker write/patch/clear","URL param writes (interview_prep_id) \u2014 synchronous on async_202 + on success","cache invalidation (jobs, dashboard:bundle)","awaited credits.refresh() inside the stabilization chain","lifecycle markComplete after all stabilization lands","cooldown start (interviewPrepCooldownKey)"]});Object.freeze({wrap_polling_helper:"lib/analyseFitPolling.js::runAnalyzeFitWithPolling",url_param_contract:["analyse_fit_run_id={id} (synthesised from analyse_runs)"],inflight_marker_key:"inflight-fit:${userId}:${jobId}",cache_invalidations:["analyse_fit","best_fit"],side_effects_on_complete:["creditsContext.refresh()","emit operation:complete","emit pack:artefact_ready (analyse_fit)"]});const $S=new Set(["dispatching","polling","stabilizing"]);function XS(e){let{jobId:t,actionCode:n,progressLabel:a=null}=e;const{status:r}=IS(t,n);if(!$S.has(r))return null;const s=qS(n,r,a)||"Working on it\u2026";return(0,Xt.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full border border-ndor-edge bg-ndor-surface-alt/60 px-3 py-1 text-xs text-ndor-ink-secondary","data-testid":"workspace-activity-indicator","data-action-code":n,"data-status":r,role:"status","aria-live":"polite",children:[(0,Xt.jsx)(Lg,{className:"h-3 w-3 animate-spin text-ndor-gold","aria-hidden":!0}),(0,Xt.jsx)("span",{"data-testid":"workspace-activity-indicator-message",children:s})]})}const QS=e=>"ndor_high_cv_confirmed_".concat(e);function ZS(e){var t,a,r;let{job:i,jobId:o,primaryCv:l,onExit:d,onContinue:u,onBusyChange:m,workspaceBusy:p=!1,lookupStatus:h="ready",loadedFromHistory:f=!1,rootTestId:x="workspace-cv-section"}=e;const v=If(),g=null===v||void 0===v?void 0:v.usageCosts,y=!v||!!v.loading,[b,w]=Pt(),j=Nf(g,"cv_improve"),k=null==j?null:"".concat(j," ").concat(1===j?"Credit":"Credits"),[N,_]=(0,s.use
2State)(()=>{const e=b.get("source_cv_id"),t=b.get("source_cv_type");return!e||"cv_variant"!==t&&"base_cv"!==t?null:{type:t,id:e,name:"cv_variant"===t?"Tailored Variant":"Source CV"}});(0,s.useEffect)(()=>{N||null!==l&&void 0!==l&&l.id&&_({type:"base_cv",id:l.id,name:l.original_filename||"Source CV"})},[null===l||void 0===l?void 0:l.id]),(0,s.useEffect)(()=>{null!==l&&void 0!==l&&l.id&&_(e=>{if(!e)return e;if("base_cv"!==e.type)return e;if(e.id!==l.id)return e;const t=l.original_filename||"Source CV";return e.name===t?e:(0,c.A)((0,c.A)({},e),{},{name:t})})},[null===l||void 0===l?void 0:l.id,null===l||void 0===l?void 0:l.original_filename]);const[D,C]=(0,s.useState)(null),[A,S]=(0,s.useState)(!1);(0,s.useEffect)(()=>{null===m||void 0===m||m(A)},[A,m]);const[E,F]=(0,s.useState)(!1),[R,I]=(0,s.useState)(!1),[T,P]=(0,s.useState)("idle"),[O,B]=(0,s.useState)(null),{status:L,markComplete:M,markFailed:z}=IS(o,"cv_variant");(0,s.useEffect)(()=>{YS()},[]),(0,s.useEffect)(()=>{var e,t;return t=e=>{OS("cv_variant","cache_invalidated",{jobId:null===e||void 0===e?void 0:e.jobId});try{window.dispatchEvent(new CustomEvent("ndor:cv-variants:invalidated",{detail:e}))}catch(t){}},(e="cv_variant")&&"function"===typeof t?(KS.has(e)||KS.set(e,new Set),KS.get(e).add(t),()=>{const n=KS.get(e);n&&n.delete(t)}):()=>{}},[]),(0,s.useEffect)(()=>{if(!o||null===l||void 0===l||!l.user_id)return;let e=!1;return(async()=>{const t=new Set;try{const e=N_(l.user_id,o);null!==e&&void 0!==e&&e.variantId&&t.add(e.variantId)}catch(a){}const n=b.get("last_variant_id");if(n&&t.add(n),t.size)for(const i of t){if(e)return;let t;try{t=await(0,zt.n)("/api/cv-variants/".concat(i))}catch(r){t=null}if(e)return;if(!t||"object"!==typeof t)continue;const n=(t.run_status||"complete").toLowerCase(),a="complete"===n,l=!t.charged_at;if(a&&l){OS("cv_variant","orphan_sweep_finalize_charge",{variantId:i,run_status:n,charge_reason:t.charge_reason||null});try{if(await(0,zt.n)("/api/cv-variants/".concat(i,"/finalize-charge"),{method:"POST",body:{job_id:o}}),"function"===typeof(null===v||void 0===v?void 0:v.refresh))try{await v.refresh()}catch(s){}}catch(pK){console.warn("[Workspace CvSection] orphan sweep finalize-charge skipped:",i,(null===pK||void 0===pK?void 0:pK.status)||(null===pK||void 0===pK?void 0:pK.message))}}}})(),()=>{e=!0}},[o,null===l||void 0===l?void 0:l.user_id]),(0,s.useEffect)(()=>{if(!o||null===l||void 0===l||!l.user_id)return;if(b.get("last_variant_id"))return;try{const e=N_(l.user_id,o);if(null!==e&&void 0!==e&&e.variantId)return}catch(t){}let e=!1;return(async()=>{try{const a=await(0,zt.n)("/api/cv-variants/by-job/".concat(encodeURIComponent(o),"?latest=true"));if(e)return;if(!a||!0!==a.found)return;const r=a.cv_variant_id;if(!r)return;try{const e=new URLSearchParams(b);e.set("last_variant_id",r),"function"===typeof w&&w(e,{replace:!0})}catch(t){}try{xN(l.user_id,o,"cv_variant"),yN(l.user_id,o,"cv_variant")}catch(n){}}catch(pK){console.warn("[Workspace CvSection] by-job lookup skipped:",(null===pK||void 0===pK?void 0:pK.status)||(null===pK||void 0===pK?void 0:pK.message))}})(),()=>{e=!0}},[o,null===l||void 0===l?void 0:l.user_id]);const[U,V]=(0,s.useState)(null),[q,W]=(0,s.useState)(null),[H,G]=(0,s.useState)(null),[K,Y]=(0,s.useState)(!1),[J,$]=(0,s.useState)(null),[X,Q]=(0,s.use
2State)(!1),[Z,ee]=(0,s.useState)(!1),[te,ne]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!o||null===l||void 0===l||!l.user_id)return;let e=!1;return(async()=>{try{const t=await(0,zt.n)("/api/jobs/".concat(o,"/baseline-fit"));e||ne(t||null)}catch(t){}})(),()=>{e=!0}},[o,null===l||void 0===l?void 0:l.user_id]),(0,s.useEffect)(()=>{if(null===N||void 0===N||!N.id||null===N||void 0===N||!N.type)return;const e=new URLSearchParams(b),t=e.get("source_cv_id"),n=e.get("source_cv_type");if(t===N.id&&n===N.type)return;const a=!!t&&(t!==N.id||n!==N.type);e.set("source_cv_id",N.id),e.set("source_cv_type",N.type),a&&(e.delete("cover_letter_id"),e.delete("interview_prep_id"),e.delete("analyse_fit_id"),e.delete("analyse_fit_source_type"),e.delete("analyse_fit_source_id")),w(e,{replace:!0})},[null===N||void 0===N?void 0:N.id,null===N||void 0===N?void 0:N.type]);const ae=b.get("last_variant_id"),re=(0,s.useCallback)(async()=>{if(ae&&o&&(null===D||void 0===D?void 0:D.variant_id)!==ae&&!A)try{var e,t,n;const i=await(0,zt.n)("/api/cv-variants/".concat(ae));if(!i||!i.id)return;const l=i.content_json&&"object"===typeof i.content_json?i.content_json:{},c=i.optimisation_artifacts&&"object"===typeof i.optimisation_artifacts?i.optimisation_artifacts:{},d=c.analytics_metadata&&"object"===typeof c.analytics_metadata?c.analytics_metadata:{},u=null!==(e=null!==(t=i.cv_sub_score_at_finalize)&&void 0!==t?t:l.cv_sub_score_variant)&&void 0!==e?e:null,m=null!==(n=d.source_cv_sub_score)&&void 0!==n?n:null;let p=d.variant_uplift_delta;if(null==p&&null!=u&&null!=m){const e=Number(u)-Number(m);p=Number.isFinite(e)?e:null}C({variant_id:i.id,variant_name:i.variant_name||i.name||null,generated_text:i.content_markdown||i.generated_text||null,role_family:i.role_family||null,fit_summary:l,cv_sub_score_variant:u,cv_sub_score_source:m,created_at:i.created_at||null,reused:!0,charged:!!i.charged_at,reason:i.charge_reason||null,delta:p,tolerance_band:5,optimisation_artifacts:i.optimisation_artifacts||null});try{"function"===typeof(null===v||void 0===v?void 0:v.refresh)&&v.refresh()}catch(a){}try{window.dispatchEvent(new CustomEvent("ndor:cv-variants:invalidated",{detail:{jobId:o,variantId:i.id,reason:"rehydrate_rebind"}}))}catch(r){}try{yS(gS.PACK_ARTEFACT_READY,{jobId:o,actionCode:"cv_variant",artefactId:i.id,reused:!0})}catch(s){}}catch(i){}},[ae,o,null===D||void 0===D?void 0:D.variant_id,A]);(0,s.useEffect)(()=>{if(!ae||!o)return;let e=!1;return(async()=>{e||await re()})(),()=>{e=!0}},[re,ae]),wN({enabled:!!ae&&!!o&&!A,fetchAndBind:re}),(0,s.useEffect)(()=>{if(!o||null===l||void 0===l||!l.user_id||null===l||void 0===l||!l.id)return;let e=!1;return(async(t,n)=>{const a=N_(l.user_id,o);if(!a)return;if(__(a))return k_(l.user_id,o),void(e||P("exhausted"));if(a.variantId){const t=40,n=3e3;let r=null;for(let s=0;s<t&&!e;s+=1){if(s>0){if(e||P("recovering"),await new Promise(e=>setTimeout(e,n)),e)return;if(__(a))return k_(l.user_id,o),void(e||P("exhausted"))}try{r=await(0,zt.n)("/api/cv-variants/".concat(a.variantId))}catch(p){r=null}if(e)return;if(!r)break;const t=(r.run_status||"complete").toLowerCase();if("complete"===t)break;if("failed"===t)return k_(l.user_id,o),void(e||P("failed"));e||P("recovering")}if(e)return;if(r&&"complete"===(r.run_status||"complete").toLowerCase()){const t=r.id,n=r.variant_name||a.title||"Tailored Variant";C({variant_id:t,variant_name:n,generated_text:r.content_markdown,recovered_inflight:!0}),_({type:"cv_variant",id:t,name:n}),k_(l.user_id,o),e||P("recovered"),fy.success("We restored your generated CV.");try{const a=await(0,zt.n)("/api/cv-variants/".concat(t,"/finalize-charge"),{method:"POST",body:{job_id:o}});if(!e&&a&&C((0,c.A)({variant_id:t,variant_name:n,generated_text:r.content_markdown,recovered_inflight:!0},a)),"function"===typeof(null===v||void 0===v?void 0:v.refresh))try{await v.refresh()}catch(h){}try{Yk(qk(l.user_id,o))}catch(f){}}catch(pK){console.warn("[Workspace CvSection] B1 recovered finalize-charge probe failed:",pK)}return}}let r=null;for(let o=0;o<4&&!e;o+=1){if(o>0&&(e||P("recovering"),await new Promise(e=>setTimeout(e,2e3)),e))return;if(r=await D_(a.title),e)return;if(r)break;0===o&&(e||P("recovering"))}if(e)return;if(!r)return k_(l.user_id,o),void(e||P("exhausted"));if(r.base_cv_id!==l.id)return console.warn("[Workspace CvSection] discarding recovered variant: base_cv_id mismatch",{variantBaseCv:r.base_cv_id,primaryCv:l.id}),void k_(l.user_id,o);const s=lN(l.user_id,o,"cv_variant"),i=(null===(t=r)||void 0===t||null===(n=t.content_json)||void 0===n?void 0:n.idempotency_key)||null;if(s&&i&&s!==i)return console.warn("[Workspace CvSection] discarding recovered variant: idempotency_key mismatch"),void k_(l.user_id,o);const d=r.id||r.variant_id,u=r.variant_name||r.title||a.title;
2if(!d||!u)return;if(e)return;let m=null;try{const e=await(0,zt.n)("/api/cv-variants/".concat(d));e&&"object"===typeof e&&(m=e.content_markdown||e.content_json&&e.content_json.generated_text||null)}catch(x){}if(!e){C({variant_id:d,variant_name:u,recovered_inflight:!0,generated_text:m}),_({type:"cv_variant",id:d,name:u}),e||P("idle"),k_(l.user_id,o),fy.success("We restored your generated CV.");try{const t=await(0,zt.n)("/api/cv-variants/".concat(d,"/finalize-charge"),{method:"POST",body:{job_id:o}});if(!e&&t&&C((0,c.A)({variant_id:d,variant_name:u},t)),"function"===typeof(null===v||void 0===v?void 0:v.refresh))try{await v.refresh()}catch(g){}try{Yk(qk(l.user_id,o))}catch(y){}}catch(pK){console.warn("[Workspace CvSection] recovered finalize-charge probe failed:",pK)}}})(),()=>{e=!0}},[o,null===l||void 0===l?void 0:l.user_id,null===l||void 0===l?void 0:l.id]);const se=b.get("source_cv_type"),ie=b.get("source_cv_id");(0,s.useEffect)(()=>{if(!o||null===l||void 0===l||!l.user_id||null===l||void 0===l||!l.id)return;if("cv_variant"!==se)return;if(!ie)return;if(D)return;if(A)return;if(N_(l.user_id,o))return;let e=!1;return F(!0),(async()=>{try{var t,n,a,r,s,i,o,c,d,u,m;const p=await(0,zt.n)("/api/cv-variants/".concat(ie));if(e||!p)return;if(p.base_cv_id&&p.base_cv_id!==l.id)return void console.warn("[Workspace CvSection] URL-bound variant base_cv_id mismatch \u2014 ignored.");const h=p.id||ie,f=p.variant_name||p.title||"Tailored Variant",x=p.content_json||{},v=p.optimisation_artifacts&&"object"===typeof p.optimisation_artifacts?p.optimisation_artifacts:{},g=v.analytics_metadata&&"object"===typeof v.analytics_metadata?v.analytics_metadata:{},y=null!==(t=null!==(n=p.cv_sub_score_at_finalize)&&void 0!==n?n:x.cv_sub_score_variant)&&void 0!==t?t:null,b=null!==(a=g.source_cv_sub_score)&&void 0!==a?a:null;let w=g.variant_uplift_delta;if(null==w&&null!=y&&null!=b){const e=Number(y)-Number(b);w=Number.isFinite(e)?e:null}C({variant_id:h,variant_name:f,reused:!0,charged:!!p.charged_at,reason:p.charge_reason||null,delta:w,tolerance_band:5,cv_sub_score_variant:y,cv_sub_score_source:b,fit_summary:null!==(r=null!==(s=x.fit_summary)&&void 0!==s?s:p.fit_summary)&&void 0!==r?r:x,cv_verdict:null!==(i=x.cv_verdict)&&void 0!==i?i:p.cv_verdict,improvement_map:null!==(o=x.improvement_map)&&void 0!==o?o:p.improvement_map,defensibility_map:null!==(c=x.defensibility_map)&&void 0!==c?c:p.defensibility_map,optimisation_artifacts:null!==(d=p.optimisation_artifacts)&&void 0!==d?d:x.optimisation_artifacts,generated_text:null!==(u=null!==(m=x.generated_text)&&void 0!==m?m:p.content_markdown)&&void 0!==u?u:p.generated_text})}catch(pK){console.warn("[Workspace CvSection] URL-bound variant rehydrate failed:",pK)}finally{F(!1)}})(),()=>{e=!0}},[o,null===l||void 0===l?void 0:l.user_id,null===l||void 0===l?void 0:l.id,se,ie]);const oe=async function(){var e,t,a;let{refreshDecision:r=null,forceGenerate:s=!1,highCvConfirmed:d=!1,cvOptions:u=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const m=NN({role:null===i||void 0===i?void 0:i.title}),p=u||BD,h=u&&u._snapshot||null;let f,x="none";"string"===typeof(null===h||void 0===h?void 0:h.job_text)&&h.job_text.trim()?(f=h.job_text,x="snapshot"):"string"===typeof(null===i||void 0===i?void 0:i.description)&&i.description.trim()?(f=i.description,x="closure"):f="";const g=(null===h||void 0===h?void 0:h.base_cv_id)||(null===l||void 0===l?void 0:l.id),y=(null===h||void 0===h?void 0:h.base_cv_user_id)||(null===l||void 0===l?void 0:l.user_id);if(!f)try{const e=await(0,zt.n)("/api/jobs/".concat(o));"string"===typeof(null===e||void 0===e?void 0:e.description)&&e.description.trim()&&(f=e.description,x="refetch")}catch(F){}if(!f)return fy.error("We couldn't read the full job description. Please refresh and try again \u2014 no Credits charged.",{duration:9e3}),null;j_(y,o,m);const j=hN(y,o,"cv_variant").idempotencyKey;OS("cv_variant","dispatch_start",{jobId:o,idempotencyKey:j,baseCvId:g,title:m}),B("dispatching");const k=await AS({jobId:o,actionCode:"cv_variant",idempotencyKey:j,run:async e=>async function(e){let{requestBody:t,apiPost:a,apiGet:r,onRunStatus:s,onRunIdReady:i,callbacks:o,telemetryHeaders:l}=e;if(!t)throw new Error("cvVariantAdapter.run: requestBody is required");if("function"!==typeof a)throw new Error("cvVariantAdapter.run: apiPost must be a function");if("function"!==typeof r)throw new Error("cvVariantAdapter.run: apiGet must be a function");const{generateCvVariantWithPolling:c}=await Promise.resolve().then(n.bind(n,695)),d=s;return c({requestBody:t,apiPost:a,apiGet:r,onRunStatus:e=>{try{null!==o&&void 0!==o&&o.onProgress&&o.onProgress(e,e),"running"===e&&null!==o&&void 0!==o&&o.onPolling&&o.onPolling()}catch(t){}if("function"===typeof d)try{d(e)}catch(n){}},onRunIdReady:i,telemetryHeaders:l})}({callbacks:(0,c.A)((0,c.A)({},e),{},{onProgress:(t,n)=>{try{B(n||t)}catch(r){}try{var a;null===e||void 0===e||null===(a=e.onProgress)||void 0===a||a.call(e,t,n)}catch(s){}}}),onRunIdReady:e=>{try{j_(y,o,m,e)}catch(t){}},telemetryHeaders:{"X-Ndor-Job-Text-Source":x},requestBody:{base_cv_id:g,job_id:o,job_text:f,title:m,template_type:p.template_type,tone_type:p.tone_type,length_preference:p.length_preference,additional_cv_context:p.additional_cv_context||"",force_generate:!!s,high_cv_generate_confirmed:!!d,idempotency_key:j},apiPost:async(e,t)=>(0,zt.n)(e,(0,c.A)((0,c.A)({},t),{},{body:(0,c.A)((0,c.A)({},t&&t.body?t.body:{}),{},{idempotency_key:j})})),apiGet:(e,t)=>(0,zt.n)(e,t),onRunStatus:e=>{"running"===e?fy.info("This is taking longer than usual. We're checking your results..."):"failed"===e&&fy.warning("We're unable to confirm the result reached you. Before clicking Generate again, please open Documents \u2192 CV Variants \u2014 your document may already be there.",{duration:9e3})}})});OS("cv_variant","terminal_payload_received",{variantId:(null===k||void 0===k?void 0:k.variant_id)||(null===k||void 0===k?void 0:k.id),contentLen:((null===k||void 0===k?void 0:k.generated_text)||"").length,idempotent_replay:!(null===k||void 0===k||!k.idempotent_replay),served_via:(null===k||void 0===k?void 0:k.served_via)||null});const N=(null===k||void 0===k?void 0:k.variant_id)||(null===k||void 0===k?void 0:k.id);if(!N)throw new Error("Variant id missing in response.");j_(l.user_id,o,m,N);const D={job_id:o};r&&(D.refresh_decision=r),B("finalizing"),OS("cv_variant","finalize_charge_request",{variantId:N,refresh_decision:r||null});const A=await(0,zt.n)("/api/cv-variants/".concat(N,"/finalize-charge"),{method:"POST",body:D});OS("cv_variant","finalize_charge_response",{variantId:N,charged:!(null===A||void 0===A||!A.charged),reused:!(null===A||void 0===A||!A.reused),reason:(null===A||void 0===A?void 0:A.reason)||null,usage_consumed:null!==(e=null===A||void 0===A?void 0:A.usage_consumed)&&void 0!==e?e:null}),B("hydrating");let S=k;try{S=await async function(e,t){let{apiGet:n}=t;if(!e||"object"!==typeof e){const e=new Error("Verifier: terminal payload is missing.");
2throw e.code="cv_variant_terminal_payload_missing",e.recoverable=!0,e}const a=e.variant_id||e.id;if(!a){const e=new Error("Verifier: variant_id missing from terminal payload.");throw e.code="cv_variant_id_missing",e.recoverable=!1,e}if("string"===typeof e.generated_text&&e.generated_text.length>0)return OS(WS,"verify_fresh_payload_ok",{variantId:a,contentLen:e.generated_text.length}),e;let r;OS(WS,"verify_stale_payload_refetching",{variantId:a});try{r=await n("/api/cv-variants/".concat(a))}catch(mK){OS(WS,"verify_refetch_failed",{variantId:a,error:null===mK||void 0===mK?void 0:mK.message});const t=new Error("Verifier: could not refetch CV variant from backend.");throw t.code="cv_variant_refetch_failed",t.cause=mK,t.recoverable=!0,t}if(!r||"object"!==typeof r){const e=new Error("Verifier: refetched row missing.");throw e.code="cv_variant_refetch_empty",e.recoverable=!0,e}const s=r.run_status||(r.content_markdown?"complete":"pending"),i=r.content_markdown||r.generated_text||"";if("complete"!==s||!i){OS(WS,"verify_authoritative_still_incomplete",{variantId:a,runStatus:s,contentLen:i.length});const e=new Error("Verifier: authoritative row is still incomplete.");throw e.code="cv_variant_authoritative_incomplete",e.recoverable=!0,e}const o=(0,c.A)((0,c.A)({variant_id:r.id||a,variant_name:r.variant_name||e.variant_name,role_family:r.role_family||e.role_family,fit_summary:r.content_json||e.fit_summary||{},generated_text:i,created_at:r.created_at||e.created_at,run_status:"complete"},e),{},{generated_text:i,variant_id:r.id||a});return OS(WS,"verify_hydrated_from_authoritative_row",{variantId:a,contentLen:i.length}),o}(k,{apiGet:(e,t)=>(0,zt.n)(e,t)}),OS("cv_variant","verified",{variantId:N,hydrated_from_authoritative:S!==k})}catch(R){if(OS("cv_variant","verifier_recoverable_post_charge",{variantId:N,code:(null===R||void 0===R?void 0:R.code)||null,recoverable:!(null===R||void 0===R||!R.recoverable)}),null===R||void 0===R||!R.recoverable)throw R;S=k}fN(l.user_id,o,"cv_variant"),k_(l.user_id,o);const E=(null===(t=S)||void 0===t?void 0:t.variant_name)||(null===k||void 0===k?void 0:k.variant_name)||m;C((0,c.A)({variant_id:N,variant_name:E,generated_text:(null===(a=S)||void 0===a?void 0:a.generated_text)||(null===k||void 0===k?void 0:k.generated_text)},A));{const e=new URLSearchParams(b);e.get("last_variant_id")!==N&&(e.set("last_variant_id",N),w(e,{replace:!0}))}if(_({type:"cv_variant",id:N,name:E}),fy.success(null!==A&&void 0!==A&&A.reused?"Loaded from your history \u2014 no new Credits charged. Click Regenerate below to spend Credits on a fresh tailored CV.":"Tailored CV ready."),"function"===typeof(null===v||void 0===v?void 0:v.refresh))try{await v.refresh()}catch(I){}OS("cv_variant","credits_refresh_called",{variantId:N});try{yS(gS.PACK_ARTEFACT_READY,{jobId:o,actionCode:"cv_variant",artefactId:N,reused:!(null===A||void 0===A||!A.reused)})}catch(T){}try{Yk(qk(null===l||void 0===l?void 0:l.user_id,o))}catch(P){}B(null);try{nw(["cv-variants:all","dashboard:bundle"])}catch(O){}try{M({variantId:N,reused:!(null===A||void 0===A||!A.reused)})}catch(L){}OS("cv_variant","operation_closed",{variantId:N,reused:!(null===A||void 0===A||!A.reused)}),xN(l.user_id,o,"cv_variant"),yN(l.user_id,o,"cv_variant")},le=async function(){let{refreshDecision:e=null,forceGenerate:t=!1,highCvConfirmed:n=!1,cvOptions:a=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return await oe({refreshDecision:e,forceGenerate:t,highCvConfirmed:n,cvOptions:a})}catch(pK){var r,s,i,c,d,u,m,p;if(409===(null===pK||void 0===pK?void 0:pK.status)&&"BASELINE_VERSION_STALE"===(null===pK||void 0===pK||null===(r=pK.data)||void 0===r||null===(s=r.detail)||void 0===s?void 0:s.code))return V({baseline_version:pK.data.detail.baseline_version,current_version:pK.data.detail.current_version,highCvConfirmed:n,cvOptions:a,forceGenerateHint:t,busy:null}),null;if(409===(null===pK||void 0===pK?void 0:pK.status)&&"analyse_fit_reject"===(null===pK||void 0===pK||null===(i=pK.data)||void 0===i||null===(c=i.detail)||void 0===c?void 0:c.error))return W({fit_score:null!==(d=pK.data.detail.fit_score)&&void 0!==d?d:null,cv_sub_score:null!==(u=pK.data.detail.cv_sub_score)&&void 0!==u?u:null,threshold:null!==(m=pK.data.detail.threshold)&&void 0!==m?m:null,final_decision:null!==(p=pK.data.detail.final_decision)&&void 0!==p?p:null,highCvConfirmed:n,cvOptions:a,busy:!1}),null;if(Gw(pK,{action:"Generate CV",refreshCredits:null===v||void 0===v?void 0:v.refresh}))return null;if(pK&&!0===pK.recoverable)return fy.info("Your CV variant is still generating in the background. Please check Documents \u2192 CV Variants in a minute.",{duration:9e3}),null;const f=null===pK||void 0===pK?void 0:pK.status;"number"===typeof f&&f>=500?fy.error("Sorry \u2014 we couldn't generate your CV just now. Your credits weren't charged. Please try again in a moment, or contact support if this keeps happening.",{duration:9e3}):fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to generate CV.");try{null!==l&&void 0!==l&&l.user_id&&o&&k_(l.user_id,o)}catch(h){}return null}finally{try{z({message:"generation_path_exited"})}catch(f){}}},ce="base_cv"===(null===N||void 0===N?void 0:N.type),de="cv_variant"===(null===N||void 0===N?void 0:N.type),ue=Xk(qk(null===l||void 0===l?void 0:l.user_id,o)),me=(0,s.useMemo)(()=>ue.active?"Generate again in ".concat(ue.label):null!==D&&void 0!==D&&D.variant_id?"Regenerate CV":"Generate CV",[null===D||void 0===D?void 0:D.variant_id,null===N||void 0===N?void 0:N.type,null===N||void 0===N?void 0:N.id,ue.active,ue.label]),pe=(0,s.useMemo)(()=>{const e=null===D||void 0===D?void 0:D.generated_text;if(!e||"string"!==typeof e)return null;const t=xS(e).trimStart();if(R)return t.length>4e3?"".concat(t.slice(0,4e3).trimEnd(),"\u2026"):t;const n=t.split("\n").slice(0,6).join("\n");return n.length>1200?"".concat(n.slice(0,1200).trimEnd(),"\u2026"):n},[null===D||void 0===D?void 0:D.generated_text,R]),he=((null===D||void 0===D?void 0:D.generated_text)||"").length,fe=he>0&&(pe||"").length<he,xe="dispatching"===L||"polling"===L||"stabilizing"===L;return(0,Xt.jsxs)("div",{"data-testid":x,className:"flex flex-col gap-5 min-w-0 max-w-full",children:[(0,Xt.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,Xt.jsx)("h2",{className:"text-lg font-semibold text-ndor-ink",children:"Tailored CV"}),"checking"===h&&(0,Xt.jsxs)("span",{role:"status","aria-live":"polite","data-testid":"workspace-cv-lookup-checking",className:"inline-flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-3 w-3 animate-spin","aria-hidden":"true"}),"Checking for existing application materials\u2026"]}),"ready"===h&&f&&(null===D||void 0===D?void 0:D.variant_id)&&(0,Xt.jsx)(fS,{testId:"workspace-cv-loaded-from-history-badge"}),null!=k&&(0,Xt.jsx)(Vw,{className:"text-[10px] uppercase tracking-[0.14em] bg-ndor-gold/15 text-ndor-gold border-0","data-testid":"workspace-cv-price-label",children:k})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Tailoring is optional \u2014 Continue with your Source CV anytime."}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2 min-h-[20px]","data-testid":"workspace-cv-lifecycle-status",children:[(0,Xt.jsx)(XS,{jobId:o,actionCode:"cv_variant",progressLabel:O}),"idle"!==L&&"complete"!==L&&(0,Xt.jsx)("span",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-cv-lifecycle-message",children:qS("cv_variant",L,O)})]})]}),(0,Xt.jsxs)("button",{type:"button","data-testid":"workspace-cv-source-card",onClick:()=>(null===l||void 0===l?void 0:l.id)&&_({type:"base_cv",id:l.id,name:l.original_filename||"Source CV"}),disabled:!(null!==l&&void 0!==l&&l.id),className:"rounded-lg border p-3 space-y-1 text-left transition disabled:opacity-50 "+(ce?"border-ndor-gold bg-ndor-gold/5":"border-ndor-line hover:border-ndor-line-strong"),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-ndor-ink-muted shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:(null===l||void 0===l?void 0:l.original_filename)||"Source CV"}),(0,Xt.jsx)(Vw,{className:"text-[10px] uppercase tracking-[0.14em] bg-ndor-line/40 text-ndor-ink-muted border-0",children:"Source CV"}),ce&&(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5 text-ndor-success ml-auto","aria-hidden":!0})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:null!==l&&void 0!==l&&l.id?"Use as-is \u2014 no Credits charged.":"Upload a Source CV in Documents \u2192 CVs first."})]}),E&&!D&&(0,Xt.jsxs)("div",{"data-testid":"workspace-cv-restoring-banner",className:"rounded-lg border border-ndor-line bg-ndor-bg-subtle p-3 flex items-center gap-2",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin text-ndor-gold","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed",children:[(0,Xt.jsx)("p",{className:"font-medium",children:"Restoring your tailored CV\u2026"}),(0,Xt.jsx)("p",{className:"text-ndor-ink-muted",children:"We're reading your saved variant \u2014 no Credits charged."})]})]}),D&&(0,Xt.jsxs)("button",{type:"button","data-testid":"workspace-cv-generated-card","data-cv-context-source-type":b.get("source_cv_type")||"","data-cv-context-source-id":b.get("source_cv_id")||"","data-row-variant-id":D.variant_id||"","data-row-base-cv-id":(null===l||void 0===l?void 0:l.id)||"",onClick:()=>_({type:"cv_variant",id:D.variant_id,name:D.variant_name}),className:"rounded-lg border-2 p-3 space-y-2 text-left transition "+(de?"border-ndor-gold bg-ndor-gold/5":"border-ndor-gold/40 bg-ndor-gold/[0.02] hover:border-ndor-gold"),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:D.variant_name||"Tailored Variant"}),(0,Xt.jsx)(Vw,{className:"text-[10px] uppercase tracking-[0.14em] bg-ndor-gold/15 text-ndor-gold border-0",children:"cv_variant"===(null===N||void 0===N?void 0:N.type)&&(null===N||void 0===N?void 0:N.id)===D.variant_id?D.recovered_inflight?"Recovered \xb7 just now":D.reused?"Reused \xb7 saved earlier":"Tailored Variant \xb7 this attempt":"Previously generated"}),de&&(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5 text-ndor-success ml-auto","aria-hidden":!0})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed",children:D.recovered_inflight?"Restored from your last Generate attempt \u2014 no new Credits charged.":D.reused?"We loaded your existing tailored CV for this job \u2014 no new Credits charged.":"Saved to Documents \u2192 CV Variants."}),(null!=D.delta||null!=D.cv_sub_score_variant)&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-cv-generated-score-line",children:[null!=D.delta&&(0,Xt.jsxs)("span",{"data-testid":"workspace-cv-generated-delta",children:["\u0394"," ",(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums",children:[D.delta>0?"+":"",D.delta]})," ","pts vs Source CV"]}),null!=D.delta&&null!=D.cv_sub_score_variant&&(0,Xt.jsx)("span",{className:"mx-1.5",children:"\xb7"}),null!=D.cv_sub_score_variant&&(0,Xt.jsxs)("span",{"data-testid":"workspace-cv-generated-cv-verdict",children:["CV verdict"," ",(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums",children:[D.cv_sub_score_variant,"/100"]})]})]}),D.reason&&(0,Xt.jsxs)("p",{className:"text-[11px] "+(D.charged?"text-ndor-warning":"text-ndor-ink-muted"),"data-testid":"workspace-cv-generated-charge-line",children:["cv_qual
2ity_improved"===D.reason&&"Material improvement achieved \u2014 charged.","no_baseline_protection"===D.reason&&"Charged \u2014 no fit baseline existed, so improvement could not be measured.","within_tolerance_band"===D.reason&&"Within NDOR confidence band \u2014 comparable to your Source CV. No Credits charged.","cv_quality_no_improvement"===D.reason&&"No material uplift detected \u2014 generated CV scored below your Source CV. No Credits charged.","presentation_optimisation_high_cv"===D.reason&&"High-CV presentation polish \u2014 partial charge.",null!=D.usage_consumed&&(0,Xt.jsxs)("span",{className:"ml-1",children:["\xb7 Charged"," ",(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums","data-testid":"workspace-cv-generated-usage-consumed",children:D.usage_consumed})," ","credit",1===D.usage_consumed?"":"s",null!=D.charge_percentage&&" (".concat(D.charge_percentage,"%)")]})]}),!D.recovered_inflight&&null==D.reason&&null==D.delta&&null==D.usage_consumed&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-cv-billing-unavailable",children:["Billing details \u2014 ",(0,Xt.jsx)("span",{"aria-hidden":!0,children:"\u2014"})," ",(0,Xt.jsx)("span",{className:"sr-only",children:"not available for this saved variant."})]})]}),D&&D.optimisation_artifacts&&(D.optimisation_artifacts.improvement_map||D.optimisation_artifacts.defensibility_map)&&(0,Xt.jsx)("div",{"data-testid":"workspace-cv-optimisation-explainer","data-has-improvement-map":null!==(t=D.optimisation_artifacts)&&void 0!==t&&t.improvement_map?"true":"false","data-has-defensibility-map":null!==(a=D.optimisation_artifacts)&&void 0!==a&&a.defensibility_map?"true":"false",className:"px-4 pb-3",children:(0,Xt.jsx)(nC,{artifacts:D.optimisation_artifacts})}),D&&pe&&(0,Xt.jsxs)("div",{"data-testid":"workspace-cv-draft-preview-card",className:"-mt-1 px-4 pb-3",children:[(0,Xt.jsxs)("pre",{"data-testid":"workspace-cv-draft-preview",className:"font-mono-ui text-[11px] text-ndor-ink-muted whitespace-pre-wrap break-words leading-relaxed border-t border-ndor-line pt-2 m-0",children:[pe,fe&&!R&&"\n\u2026"]}),fe&&(0,Xt.jsx)("button",{type:"button","data-testid":"workspace-cv-draft-preview-toggle",onClick:()=>I(e=>!e),className:"mt-1.5 text-[11px] font-medium text-ndor-gold hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ndor-gold/50 rounded",children:R?"Collapse":"Expand"})]}),!D&&!xe&&"recovering"===T&&(0,Xt.jsxs)("div",{"data-testid":"workspace-cv-recovering-banner",role:"status","aria-live":"polite",className:"rounded-lg border border-ndor-gold/40 bg-ndor-gold/[0.04] p-3 flex items-start gap-2",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 text-ndor-gold shrink-0 animate-spin mt-0.5","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed space-y-0.5",children:[(0,Xt.jsx)("p",{className:"font-medium",children:"Generating your tailored CV\u2026"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"We're finishing your last Generate attempt \u2014 no new Credits will be charged."})]})]}),!D&&!xe&&"exhausted"===T&&(0,Xt.jsxs)("div",{"data-testid":"workspace-cv-recovery-exhausted-banner",role:"status","aria-live":"polite",className:"rounded-lg border border-ndor-edge bg-ndor-surface p-3 flex items-start gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 text-ndor-ink-muted shrink-0 mt-0.5","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed space-y-0.5",children:[(0,Xt.jsx)("p",{className:"font-medium",children:"We couldn't automatically restore your last generated CV."}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted",children:["Check"," ",(0,Xt.jsx)("a",{href:"/documents",className:"underline decoration-dotted underline-offset-2 hover:text-ndor-ink",children:"Documents \u2192 CV Variants"})," ","\u2014 no new Credits were charged."]})]})]}),!D&&!xe&&"failed"===T&&(0,Xt.jsxs)("div",{"data-testid":"workspace-cv-recovery-failed-banner",role:"status","aria-live":"polite",className:"rounded-lg border border-amber-400/40 bg-amber-500/10/60 p-3 flex items-start gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 text-amber-600 shrink-0 mt-0.5","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed space-y-0.5",children:[(0,Xt.jsx)("p",{className:"font-medium",children:"Your last CV generation didn't complete."}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Click Generate to try again \u2014 no Credits were charged."})]})]}),U&&(0,Xt.jsxs)("div",{"data-testid":"workspace-cv-baseline-guard",role:"alert",className:"rounded-lg border-2 border-amber-400/40 bg-amber-500/10/60 p-3 space-y-3",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-amber-600 shrink-0 mt-0.5","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed space-y-1.5",children:[(0,Xt.jsx)("p",{className:"font-medium text-sm","data-testid":"workspace-cv-baseline-guard-title",children:"Updated scoring methodology"}),(0,Xt.jsx)("p",{className:"text-ndor-ink-muted",children:"NDOR's scoring methodology has improved since your previous anal
2ysis. We can refresh your prior baseline at no charge to preserve the most accurate comparison."}),(U.baseline_version||U.current_version)&&(0,Xt.jsxs)("div",{"data-testid":"workspace-cv-baseline-guard-version-chip",className:"flex flex-wrap items-center gap-2 rounded-md bg-ndor-surface/60 px-2 py-1 text-[11px]",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink-muted",children:"Versions:"}),(0,Xt.jsxs)("span",{children:["Baseline:\xa0",(0,Xt.jsx)("span",{className:"font-mono",children:U.baseline_version||"unstamped"})]}),(0,Xt.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,Xt.jsxs)("span",{children:["Current:\xa0",(0,Xt.jsx)("span",{className:"font-mono",children:U.current_version||"\u2014"})]})]}),(0,Xt.jsxs)("ul",{className:"space-y-1 text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-1.5",children:[(0,Xt.jsx)("span",{className:"mt-0.5 text-emerald-600",children:"\u2713"}),(0,Xt.jsxs)("span",{children:["Refreshing is ",(0,Xt.jsx)("strong",{children:"free"})," \u2014 no Credits charged."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-1.5",children:[(0,Xt.jsx)("span",{className:"mt-0.5 text-emerald-600",children:"\u2713"}),(0,Xt.jsx)("span",{children:"Refresh preserves your charge protection (the \xb15 confidence band still waives charges when the tailored CV doesn't materially improve on the refreshed baseline)."})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-1.5",children:[(0,Xt.jsx)(Oy,{className:"mt-0.5 h-3 w-3 text-amber-600 shrink-0","aria-hidden":!0}),(0,Xt.jsx)("span",{children:"Skipping leaves no baseline to compare against \u2014 tailoring will charge in full regardless of quality improvement."})]})]})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 flex-wrap",children:[(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>{V(null)},disabled:!!U.busy,"data-testid":"workspace-cv-baseline-guard-cancel-btn",children:"Cancel"}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:async()=>{if(!U)return;const e=U;V(null),S(!0);try{await le({refreshDecision:"declined",forceGenerate:!!e.forceGenerateHint,highCvConfirmed:e.highCvConfirmed,cvOptions:e.cvOptions})}finally{S(!1)}},disabled:!!U.busy,"data-testid":"workspace-cv-baseline-guard-decline-btn",children:["decline"===U.busy&&(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Continue Without Refresh"]}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:async()=>{if(!U)return;const e=U;V((0,c.A)((0,c.A)({},e),{},{busy:"refresh"}));try{await(0,zt.n)("/api/jobs/".concat(o,"/refresh-baseline"),{method:"POST"}),fy.success("Baseline refreshed \u2014 no Credits charged.")}catch(mK){var t,n;return V((0,c.A)((0,c.A)({},e),{},{busy:null})),void fy.error((null===mK||void 0===mK||null===(t=mK.data)||void 0===t||null===(n=t.detail)||void 0===n?void 0:n.message)||(null===mK||void 0===mK?void 0:mK.message)||"Baseline refresh failed.")}V(null),S(!0);try{await le({refreshDecision:"refreshed",forceGenerate:!!e.forceGenerateHint,highCvConfirmed:e.highCvConfirmed,cvOptions:e.cvOptions})}finally{S(!1)}},disabled:!!U.busy,"data-testid":"workspace-cv-baseline-guard-refresh-btn",children:["refresh"===U.busy&&(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Refresh My Baseline (Free)"]})]})]}),q&&(0,Xt.jsxs)("div",{"data-testid":"workspace-cv-reject-guard",role:"alert",className:"rounded-lg border-2 border-ndor-warning/40 bg-ndor-warning/[0.05] p-3 space-y-3",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 text-ndor-warning shrink-0 mt-0.5","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed space-y-1",children:[(0,Xt.jsx)("p",{className:"font-medium text-sm","data-testid":"workspace-cv-reject-guard-title",children:"Low fit detected \u2014 generate anyway?"}),(0,Xt.jsxs)("p",{className:"text-ndor-ink-muted","data-testid":"workspace-cv-reject-guard-description",children:["Your baseline fit assessment for this role landed",null!=q.fit_score?(0,Xt.jsxs)(Xt.Fragment,{children:[" ","at"," ",(0,Xt.jsxs)("span",{className:"font-mono tabular-nums","data-testid":"workspace-cv-reject-guard-score",children:[q.fit_score,"/100"]})]}):(0,Xt.jsx)(Xt.Fragment,{children:" in the low-fit band"})," ","with a verdict of"," ",(0,Xt.jsx)("span",{className:"font-medium",children:q.final_decision||"reject"}),". NDORFlow governance treats this as a directional signal \u2014 not a hard block. You can still generate a tailored CV if you have additional context to add or simply want to proceed."," ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-warning","data-testid":"workspace-cv-reject-guard-charge-notice",children:"Proceeding here is an explicit override: generation will incur the FULL Credit cost even if the resulting score change is within the usual tolerance band."})]})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 flex-wrap",children:[(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:()=>{W(null)},disabled:A,"data-testid":"workspace-cv-reject-guard-cancel-btn",children:"Cancel"}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:async()=>
2{if(!q)return;const e=q;W(null),S(!0);try{await le({forceGenerate:!0,highCvConfirmed:e.highCvConfirmed,cvOptions:e.cvOptions})}finally{S(!1)}},disabled:A||p,"data-testid":"workspace-cv-reject-guard-confirm-btn",children:[A?(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5"}),"Generate Anyway"]})]})]}),J&&(0,Xt.jsxs)("div",{"data-testid":"cv-regenerate-confirm",role:"alertdialog","aria-modal":"true","aria-labelledby":"cv-regenerate-confirm-title",className:"my-4 rounded-lg border border-amber-500/60 bg-amber-500/10 p-4 text-sm",children:[(0,Xt.jsx)("div",{id:"cv-regenerate-confirm-title",className:"font-medium text-amber-100 mb-1.5",children:"Regenerate tailored CV?"}),(0,Xt.jsx)("div",{className:"text-amber-50/80 mb-3",children:"You already have a tailored CV for this job. Generating a new one will spend Credits and replace the version shown above."}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>$(null),"data-testid":"cv-regenerate-cancel",children:"Keep existing"}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm","data-testid":"cv-regenerate-confirm-go",disabled:A||y||!(null!==l&&void 0!==l&&l.id)||p,onClick:()=>{try{vN(null===l||void 0===l?void 0:l.user_id,o,"cv_variant")}catch(e){}$(null),Y(!0)},children:[(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5"}),"Regenerate"]})]})]}),H&&(0,Xt.jsxs)("div",{"data-testid":"workspace-cv-high-cv-guard",role:"alert",className:"rounded-lg border-2 border-ndor-gold/40 bg-ndor-gold/[0.04] p-3 space-y-3",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold shrink-0 mt-0.5","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed space-y-1",children:[(0,Xt.jsx)("p",{className:"font-medium text-sm","data-testid":"workspace-cv-high-cv-guard-title",children:"Your Source CV is already strong"}),(0,Xt.jsxs)("p",{className:"text-ndor-ink-muted","data-testid":"workspace-cv-high-cv-guard-description",children:["Your current Source CV scores"," ",(0,Xt.jsxs)("span",{className:"font-mono tabular-nums","data-testid":"workspace-cv-high-cv-guard-score",children:[null!==(r=H.source_cv_score)&&void 0!==r?r:"","/100"]})," ","on this role. Further optimisation may mainly improve presentation and clarity rather than your underlying fit."," ",(0,Xt.jsx)("span",{className:"font-medium","data-testid":"workspace-cv-high-cv-guard-charge-notice",children:"Proceeding is an explicit override: this uses Credits at 50% of the standard tailoring cost for a presentation-only refinement, or the full cost when the new variant beats your Source CV by 6 points or more."})]})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 flex-wrap",children:[(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:()=>{G(null)},disabled:A,"data-testid":"workspace-cv-high-cv-guard-cancel-btn",children:"Use current CV"}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:async()=>{if(!H)return;const e=H;try{sessionStorage.setItem(QS(o),"1")}catch(t){}G(null),S(!0);try{await le({forceGenerate:!!e.forceGenerateHint,highCvConfirmed:!0,cvOptions:e.cvOptions})}finally{S(!1)}},disabled:A||p,"data-testid":"workspace-cv-high-cv-guard-confirm-btn",children:[A?(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5"}),"Generate anyway"]})]})]}),(0,Xt.jsxs)("footer",{"data-testid":"workspace-section-footer",className:"sticky bottom-0 z-10 -mx-3 sm:-mx-4 px-3 sm:px-4 py-3 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] flex flex-col xs:flex-row xs:flex-wrap xs:items-center xs:justify-between gap-2 border-t border-border/60 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:[(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:d,"data-testid":"workspace-cv-exit-button",className:"w-full xs:w-auto px-2 sm:px-3",children:[(0,Xt.jsx)(Zg,{className:"mr-1 sm:mr-1.5 h-3.5 w-3.5"}),(0,Xt.jsx)("span",{className:"hidden sm:inline",children:"Exit workspace"}),(0,Xt.jsx)("span",{className:"sm:hidden",children:"Exit"})]}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:async()=>{var e;null!==l&&void 0!==l&&l.id?null!==i&&void 0!==i&&null!==(e=i.description)&&void 0!==e&&e.trim()?((e,t)=>
2{if(y)return!1;const n=Nf(g,e);if(null==n||0===n)return!0;const a=Number((null===v||void 0===v?void 0:v.includedUsageRemaining)||0)+Number((null===v||void 0===v?void 0:v.extraUsageRemaining)||0);return a>=n||(fy.error("Not enough Credits for ".concat(t),{description:"".concat(a," available \xb7 ").concat(n," needed. Open Plan to add Credits."),action:{label:"View plan",onClick:()=>{try{window.location.assign("/account?tab=plan")}catch(e){}}}}),!1)})("cv_improve","Generate CV")&&(null!==D&&void 0!==D&&D.variant_id?$({source:"cv_generate"}):Y(!0)):fy.error("Job has no description text."):fy.error("No Source CV. Upload one in Documents \u2192 CVs.")},disabled:A||y||!(null!==l&&void 0!==l&&l.id)||!!U||!!q||!!H||ue.active||"dispatching"===L||"polling"===L||"stabilizing"===L||p||K||X||"ready"!==h,"data-testid":"workspace-cv-generate-button","data-controller-status":L,"data-cooldown-active":ue.active?"1":"0","data-cooldown-remaining-ms":ue.active?String(ue.remainingMs):"",title:ue.active?"Generate is on cooldown for ".concat(ue.label,". This prevents accidental re-clicks while your wallet syncs."):void 0,className:"w-full xs:w-auto xs:flex-1 xs:min-w-0 sm:flex-none px-2 sm:px-3",children:[A?(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin shrink-0"}):(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5 shrink-0"}),(0,Xt.jsx)("span",{className:"hidden xs:inline truncate","aria-hidden":"true",children:me}),(0,Xt.jsx)("span",{className:"xs:hidden truncate","aria-hidden":"true",children:ue.active?"Wait":me.startsWith("Re")?"Regen":"Generate"}),(0,Xt.jsx)("span",{className:"sr-only",children:me})]}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:()=>{null!==D&&void 0!==D&&D.variant_id&&"base_cv"===(null===N||void 0===N?void 0:N.type)?ee(!0):null===u||void 0===u||u()},"data-testid":"workspace-section-continue-button",className:"w-full xs:w-auto px-2 sm:px-3",children:["Continue",(0,Xt.jsx)(zy,{className:"ml-1 sm:ml-1.5 h-3.5 w-3.5"})]})]}),y&&!A&&(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-cv-credits-loading-hint",children:"Loading your wallet\u2026"}),(0,Xt.jsx)(WD,{open:K,onOpenChange:Y,onConfirm:async e=>{var t,n,a,r,s;Y(!1),Q(!0);const d={job_text:"string"===typeof(null===i||void 0===i?void 0:i.description)&&i.description.trim()?i.description:null,base_cv_id:null!==(t=null===l||void 0===l?void 0:l.id)&&void 0!==t?t:null,base_cv_user_id:null!==(n=null===l||void 0===l?void 0:l.user_id)&&void 0!==n?n:null,job_title:null!==(a=null===i||void 0===i?void 0:i.title)&&void 0!==a?a:null,captured_at:Date.now()},u=(0,c.A)((0,c.A)({},e),{},{_snapshot:d});try{const e=await(0,zt.n)("/api/jobs/".concat(o,"/baseline-status"));if("stale_refresh_available"===(null===e||void 0===e?void 0:e.baseline_status))return V({baseline_version:e.baseline_version,current_version:e.current_version,highCvConfirmed:!1,cvOptions:u,forceGenerateHint:!1,busy:null}),void Q(!1)}catch(mK){console.warn("[Workspace CvSection] baseline-status pre-flight failed:",(null===mK||void 0===mK?void 0:mK.message)||mK)}let m=!1;try{const e=await(0,zt.n)("/api/application-packs?job_id=".concat(encodeURIComponent(o),"&page_size=1"));m=(Array.isArray(e)?e:(null===e||void 0===e?void 0:e.items)||[]).some(e=>(null===e||void 0===e?void 0:e.job_id)===o&&!(null===e||void 0===e||!e.cv_variant_id))}catch(f){}const p=null===te||void 0===te||null===(r=te.baseline)||void 0===r||null===(s=r.sub_scores)||void 0===s?void 0:s.cv_sub_score;let h=!1;try{h="1"===sessionStorage.getItem(QS(o))}catch(x){}if("number"===typeof p&&p>=80&&!h)return G({source_cv_score:p,cvOptions:u,forceGenerateHint:m,busy:!1}),void Q(!1);S(!0);try{await le({forceGenerate:m,highCvConfirmed:!1,cvOptions:u})}finally{S(!1),Q(!1)}},generating:A}),(0,Xt.jsx)(aS,{open:Z,onOpenChange:ee,children:(0,Xt.jsxs)(oS,{"data-testid":"workspace-cv-continue-warning-dialog",children:[(0,Xt.jsxs)(lS,{children:[(0,Xt.jsx)(dS,{children:"Continue with your Source CV?"}),(0,Xt.jsxs)(uS,{children:["You have a tailored CV ready, but your active selection is your Source CV. If you continue, the rest of the flow (Cover Letter, Analyse Fit, Application Pack) will use the ",(0,Xt.jsx)("strong",{children:"Source CV"}),". Your tailored CV stays saved in ",(0,Xt.jsx)("strong",{children:"Documents \u2192 CV Variants"}),"."]})]}),(0,Xt.jsxs)(cS,{children:[(0,Xt.jsx)(pS,{"data-testid":"workspace-cv-continue-warning-cancel-btn",children:"Cancel"}),(0,Xt.jsx)(mS,{onClick:()=>{ee(!1),null===u||void 0===u||u()},"data-testid":"workspace-cv-continue-warning-confirm-btn",children:"Use Source CV anyway"})]})]})})]})}var eE=n(960);const tE=[750,1500,3e3];function nE(e){return new Promise(t=>setTimeout(t,e))}async function aE(e){const{action:t,path:n,headers:a,apiGet:r,isComplete:s,envelope:i,envelopeIsFresh:o,backoffMs:l=tE,logId:c}=e;if(!r||"function"!==typeof r)throw new Error("hydrateWithRetry: apiGet is required");if(!n){const e=new Error("hydrateWithRetry: canonical GET path is required");throw e.code="".concat(t,"_hydrate_missing_path"),e}if("function"!==typeof s)throw new Error("hydrateWithRetry: isComplete predicate is required");if(i&&"function"===typeof o&&o(i))return OS(t,"post_terminal_envelope_fresh",{logId:c}),i;const d=[0,...l];let u=null,m=null;for(let h=0;h<d.length;h+=1){d[h]>0&&await nE(d[h]);try{const e=await r(n,a?{headers:a}:void 0);if(e&&"object"===typeof e){if(u=e,s(e))return OS(t,"post_terminal_hydrate_ok",{logId:c,attempt:h,totalWaitMs:d.slice(0,h+1).reduce((e,t)=>
2e+t,0)}),e;OS(t,"post_terminal_hydrate_incomplete_retry",{logId:c,attempt:h,run_status:e.run_status||e.status})}}catch(mK){m=mK,OS(t,"post_terminal_hydrate_read_error_retry",{logId:c,attempt:h,error:null===mK||void 0===mK?void 0:mK.message})}}const p=new Error("".concat(t,": artefact saved but preview is still refreshing."));throw p.code="".concat(t,"_hydrate_exhausted"),p.recoverable=!0,p.lastRow=u,p.lastReadError=m,OS(t,"post_terminal_hydrate_exhausted",{logId:c,last_status:u?u.run_status||u.status:null}),p}function rE(e){if(!e||"object"!==typeof e)return!1;if("complete"!==(e.status||e.run_status||"complete").toString().toLowerCase())return!1;const t=e.content_markdown||e.generated_text||"";return"string"===typeof t&&t.length>0}function sE(e){if(!e||"object"!==typeof e)return!1;if(!e.cover_letter_id&&!e.id)return!1;const t=e.generated_text||e.content_markdown||"";return"string"===typeof t&&t.length>0}function iE(e){let{envelope:t,letterId:n,apiGet:a,logId:r}=e;return n?aE({action:"cover_letter",path:"/api/cover-letters/".concat(n),apiGet:a,envelope:t,envelopeIsFresh:sE,isComplete:rE,logId:r||n}):Promise.reject(Object.assign(new Error("verifyAndHydrateCoverLetter: letterId required"),{code:"cover_letter_id_missing",recoverable:!1}))}function oE(e){if(!e||"object"!==typeof e)return!1;const t=(e.status||e.run_status||"").toString().toLowerCase();if(t&&"complete"!==t)return!1;const n=e.result||e,a=null===n||void 0===n?void 0:n.interview_prep;if(!a||"object"!==typeof a)return!1;const r=Object.keys(a);return 0!==r.length&&r.some(e=>{const t=a[e];return Array.isArray(t)||"string"===typeof t?t.length>0:!(!t||"object"!==typeof t)&&Object.keys(t).length>0})}function lE(e){return!(!e||"object"!==typeof e)&&(!!(e.interview_prep_id||e.run_id||e.id)&&!!(e.interview_prep&&"object"===typeof e.interview_prep&&Object.keys(e.interview_prep).length>0))}function cE(e){let{envelope:t,ipId:n,apiGet:a,logId:r}=e;return n?aE({action:"interview_prep",path:"/api/interview-prep/".concat(n),headers:{"X-Envelope":"rc_1_52_canonical"},apiGet:a,envelope:t,envelopeIsFresh:lE,isComplete:oE,logId:r||n}):Promise.reject(Object.assign(new Error("verifyAndHydrateInterviewPrep: ipId required"),{code:"interview_prep_id_missing",recoverable:!1}))}function dE(e){let{job:t,jobId:a,primaryCv:r,onContinue:i,onBack:o,onBusyChange:l,workspaceBusy:d=!1,lookupStatus:u="ready",loadedFromHistory:m=!1,rootTestId:p="workspace-letter-section"}=e;const h=If(),f=null===h||void 0===h?void 0:h.usageCosts,x=!h||!!h.loading,v=Nf(f,"cover_letter"),g=null==v?null:"".concat(v," ").concat(1===v?"Credit":"Credits"),[y,b]=Pt(),w=y.get("source_cv_id")||(null===r||void 0===r?void 0:r.id)||null,j=y.get("source_cv_type")||"base_cv",k="cv_variant"===j?w:null,[N,_]=(0,s.useState)(null),[D,C]=(0,s.useState)(""),[A,S]=(0,s.useState)(""),[E,F]=(0,s.use
2State)(!1);(0,s.useEffect)(()=>{null===l||void 0===l||l(E)},[E,l]);const[R,I]=(0,s.useState)(!1),{status:T,markComplete:P,markFailed:O}=IS(a,"cover_letter"),[B,L]=(0,s.useState)(null),[M,z]=(0,s.useState)(null),[U,V]=(0,s.useState)(null),[q,W]=(0,s.useState)(null),[H,G]=(0,s.useState)(null),[K,Y]=(0,s.useState)(!1),[J,$]=(0,s.useState)(null),[X,Q]=(0,s.useState)(!1),[Z,ee]=(0,s.useState)(!1),[te,ne]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!N)return;const e=new URLSearchParams(y);e.get("cover_letter_id")!==N&&(e.set("cover_letter_id",N),b(e,{replace:!0}))},[N]);const ae=y.get("cover_letter_id"),re=(0,s.useCallback)(async()=>{if(ae&&a&&null!==r&&void 0!==r&&r.id&&N!==ae&&!E&&!R){Y(!0);try{var e,t;const o=await(0,zt.n)("/api/cover-letters/".concat(ae));if(!o)return;const l=o.metadata&&"object"===typeof o.metadata?o.metadata:o.content_json&&"object"===typeof o.content_json?o.content_json:{},c=null!==(e=o.base_cv_id)&&void 0!==e?e:null,d=null!==(t=o.cv_variant_id)&&void 0!==t?t:null;if(null!==y.get("from_pack")){if(c&&c!==r.id)return}else{if(c&&c!==r.id)return;if(d!==k)return}if(o.job_id&&o.job_id!==a)return;_(o.id),S(o.title||""),C(o.content_markdown||o.generated_text||""),W(d),G(c),l.billing&&"object"===typeof l.billing&&z(l.billing),"string"===typeof l.charge_reason&&V(l.charge_reason);try{"function"===typeof(null===h||void 0===h?void 0:h.refresh)&&h.refresh()}catch(n){}try{nw(["cover-letters:all","dashboard:bundle"])}catch(s){}try{yS(gS.PACK_ARTEFACT_READY,{jobId:a,actionCode:"cover_letter",artefactId:o.id,reused:!0})}catch(i){}}catch(o){}finally{Y(!1)}}},[ae,a,null===r||void 0===r?void 0:r.id,k,N,E,R]);(0,s.useEffect)(()=>{if(!ae)return;let e=!1;return(async()=>{e||await re()})(),()=>{e=!0}},[re,ae]),wN({enabled:!!ae&&!!a&&!(null===r||void 0===r||!r.id)&&!E&&!R,fetchAndBind:re}),(0,s.useEffect)(()=>{if(!a||null===r||void 0===r||!r.user_id)return;if(N)return;let e=!1;try{const t=E_(r.user_id,a);e=!(!t||F_(t))}catch(c){}if(!e&&!Z&&!E)return;let t=!1,n=null,s=!1;async function i(){if(!t&&!s){s=!0;try{var e,n,i,o,l,c,d,u,m;const s=new URLSearchParams;s.set("latest","true"),"cv_variant"===j&&w?s.set("cv_variant_id",w):"base_cv"===j&&w&&s.set("base_cv_id",w);const A=await(0,zt.n)("/api/cover-letters/by-job/".concat(encodeURIComponent(a),"?").concat(s.toString()));if(t||!A||!0!==A.found)return;const E=A.cover_letter_id;if(!E)return;let F;try{F=await iE({envelope:{cover_letter_id:E,generated_text:A.content_markdown||null,content_markdown:A.content_markdown||null,title:A.title||null},letterId:E,apiGet:(e,t)=>(0,zt.n)(e,t)})}catch(p){if(!0===(null===p||void 0===p?void 0:p.recoverable))return;return void OS("cover_letter","live_binder_hydrate_failed",{letterId:E,code:null===p||void 0===p?void 0:p.code})}if(t)return;const R=(null===(e=F)||void 0===e?void 0:e.generated_text)||(null===(n=F)||void 0===n?void 0:n.content_markdown)||A.content_markdown||"";if(!R)return;_(E),C(R),S(A.title||(null===(i=F)||void 0===i?void 0:i.title)||""),W(null!==(o=null!==(l=A.cv_variant_id)&&void 0!==l?l:null===(c=F)||void 0===c?void 0:c.cv_variant_id)&&void 0!==o?o:null),G(null!==(d=null!==(u=A.base_cv_id)&&void 0!==u?u:null===(m=F)||void 0===m?void 0:m.base_cv_id)&&void 0!==d?d:null),$(null),I(!1);try{const e=new URLSearchParams(y);e.get("cover_letter_id")!==E&&(e.set("cover_letter_id",E),"function"===typeof b&&b(e,{replace:!0}))}catch(f){}try{S_(r.user_id,a),oN(r.user_id,a,"cover_letter")}catch(x){}try{ee(!1)}catch(v){}try{"function"===typeof(null===h||void 0===h?void 0:h.refresh)&&h.refresh()}catch(g){}try{nw(["cover-letters:all","dashboard:bundle"])}catch(k){}try{yS(gS.PACK_ARTEFACT_READY,{jobId:a,actionCode:"cover_letter",artefactId:E,reused:!0})}catch(N){}try{P({letterId:E,reused:!0})}catch(D){}fy.success("Cover letter ready."),OS("cover_letter","live_binder_bound",{letterId:E})}catch(pK){OS("cover_letter","live_binder_check_failed",{code:null===pK||void 0===pK?void 0:pK.code,status:null===pK||void 0===pK?void 0:pK.status})}finally{s=!1}}}function o(){"undefined"!==typeof document&&"visible"===document.visibilityState&&(n&&clearTimeout(n),n=setTimeout(i,250))}i();const l=setInterval(()=>{"undefined"!==typeof document&&"visible"!==document.visibilityState||i()},12e3);return"undefined"!==typeof document&&document.addEventListener("visibilitychange",o),()=>{t=!0,n&&clearTimeout(n),clearInterval(l),"undefined"!==typeof document&&document.removeEventListener("visibilitychange",o)}},[a,null===r||void 0===r?void 0:r.user_id,N,Z,E]),(0,s.useEffect)(()=>
2{if(!a||null===r||void 0===r||!r.user_id||null===r||void 0===r||!r.id)return;let e=!1;return(async(t,n)=>{const s=E_(r.user_id,a);if(!s)return;if(F_(s))return S_(r.user_id,a),void fy.info("We couldn't automatically restore your last generated cover letter. Check Documents \u2192 Cover Letters.");let i=null;if(s.runId)try{var o;const t=await(0,eE.q)(s.runId,{apiGet:(e,t)=>(0,zt.n)(e,t)});if(e)return;i={id:t.cover_letter_id||t.run_id||s.runId,title:t.title||s.title,content_markdown:t.content_markdown||"",base_cv_id:t.base_cv_id||r.id,cv_variant_id:null!==(o=t.cv_variant_id)&&void 0!==o?o:k,content_json:t.content_json||null}}catch(pK){if(e)return;if("cover_letter_failed"===(null===pK||void 0===pK?void 0:pK.code))return void S_(r.user_id,a)}const l=i||await R_(s.title);if(e||!l)return;if(l.base_cv_id!==r.id)return console.warn("[Workspace CoverLetterSection] discarding recovered letter: base_cv_id mismatch",{letterBaseCv:l.base_cv_id,primaryCv:r.id}),void S_(r.user_id,a);const c=null!==(t=l.cv_variant_id)&&void 0!==t?t:null;if(c!==k)return console.warn("[Workspace CoverLetterSection] discarding recovered letter: cv_variant_id mismatch",{letterVariant:c,workspaceVariant:k}),void S_(r.user_id,a);const d=lN(r.user_id,a,"cover_letter"),u=(null===l||void 0===l||null===(n=l.content_json)||void 0===n?void 0:n.idempotency_key)||null;if(d&&u&&d!==u)return console.warn("[Workspace CoverLetterSection] discarding recovered letter: idempotency_key mismatch"),void S_(r.user_id,a);const m=l.id||l.cover_letter_id;if(m&&!e){_(m),C(l.content_markdown||""),S(l.title||s.title),I(!0),S_(r.user_id,a),oN(r.user_id,a,"cover_letter");try{if("function"===typeof b){const e=new URLSearchParams(y);e.set("cover_letter_id",m),b(e,{replace:!0})}}catch(p){}fy.success("We restored your generated cover letter.")}})(),()=>{e=!0}},[a,null===r||void 0===r?void 0:r.user_id,null===r||void 0===r?void 0:r.id,k]);const se=async function(){var e;let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(null===r||void 0===r||!r.id)return void fy.error("No Source CV. Upload one in Documents \u2192 CVs.");if(null===t||void 0===t||null===(e=t.description)||void 0===e||!e.trim())return void fy.error("Job has no description text.");if(!((e,t)=>{if(x)return!1;const n=Nf(f,e);if(null==n||0===n)return!0;const a=Number((null===h||void 0===h?void 0:h.includedUsageRemaining)||0)+Number((null===h||void 0===h?void 0:h.extraUsageRemaining)||0);return a>=n||(fy.error("Not enough Credits for ".concat(t),{description:"".concat(a," available \xb7 ").concat(n," needed. Open Plan to add Credits."),action:{label:"View plan",onClick:()=>{try{window.location.assign("/account?tab=plan")}catch(e){}}}}),!1)})("cover_letter","Generate cover letter"))return;if(N&&(null===s||void 0===s||!s.force))return void ne({source:"cl_generate"});if(null!==s&&void 0!==s&&s.force)try{oN(r.user_id,a,"cover_letter")}catch(j){}const i=_N({company:null===t||void 0===t?void 0:t.company});A_(r.user_id,a,i);const o=iN(r.user_id,a,"cover_letter");F(!0),L("dispatching"),OS("cover_letter","dispatch_start",{jobId:a,idempotency_key:o});try{var l,d,u,m;const e=await AS({jobId:a,actionCode:"cover_letter",idempotencyKey:o,run:async e=>{let{callbacks:s}=e;return async function(e){let{requestBody:t,apiPost:a,apiGet:r,onRunStatus:s,onRunIdReady:i,callbacks:o}=e;if(!t)throw new Error("coverLetterAdapter.run: requestBody is required");if("function"!==typeof a)throw new Error("coverLetterAdapter.run: apiPost must be a function");if("function"!==typeof r)throw new Error("coverLetterAdapter.run: apiGet must be a function");const{generateCoverLetterWithPolling:l}=await Promise.resolve().then(n.bind(n,960)),c=s;return l({requestBody:t,apiPost:a,apiGet:r,onRunStatus:e=>{try{null!==o&&void 0!==o&&o.onProgress&&o.onProgress(e,e),"running"===e&&null!==o&&void 0!==o&&o.onPolling&&o.onPolling()}catch(t){}if("function"===typeof c)try{c(e)}catch(n){}},onRunIdReady:i})}({requestBody:{job_text:t.description,job_id:a,title:i,base_cv_id:r.id,cv_variant_id:k,tone_type:"analytical",idempotency_key:o},apiPost:async(e,t)=>(0,zt.n)(e,(0,c.A)((0,c.A)({},t),{},{body:(0,c.A)((0,c.A)({},t&&t.body?t.body:{}),{},{idempotency_key:o})})),apiGet:(e,t)=>(0,zt.n)(e,t),onRunIdReady:e=>{try{!function(e,t,n){if(t&&n&&"object"===typeof n)try{const a=sessionStorage.getItem(C_(e,t)),r=a?JSON.parse(a):null,
2s=(0,c.A)((0,c.A)({},r&&"object"===typeof r?r:{}),n);s.submittedAtMs||(s.submittedAtMs=Date.now()),s.startedAt||(s.startedAt=(new Date).toISOString()),sessionStorage.setItem(C_(e,t),JSON.stringify(s))}catch(a){}}(r.user_id,a,{runId:e})}catch(t){}},onRunStatus:e=>{"running"===e?(L("polling"),fy.info("This is taking longer than usual. We're checking your results...")):"failed"===e&&fy.warning("We're unable to confirm the result reached you. Before clicking Generate again, please open Documents \u2192 Cover Letters \u2014 your document may already be there.",{duration:9e3})},callbacks:s})}});if(!e)return;const s=(null===e||void 0===e?void 0:e.cover_letter_id)||(null===e||void 0===e?void 0:e.id);if(!s)throw new Error("Letter id missing in response.");let f;OS("cover_letter","terminal_payload_received",{letterId:s,has_content:!!(null!==e&&void 0!==e&&e.generated_text||null!==e&&void 0!==e&&e.content_markdown)}),L("hydrating");try{f=await iE({envelope:e,letterId:s,apiGet:(e,t)=>(0,zt.n)(e,t)})}catch(D){OS("cover_letter","post_terminal_hydrate_failed",{letterId:s,code:null===D||void 0===D?void 0:D.code}),$({letterId:s}),_(s);try{oN(r.user_id,a,"cover_letter"),S_(r.user_id,a)}catch(A){}if("function"===typeof(null===h||void 0===h?void 0:h.refresh))try{await h.refresh()}catch(E){}nw(["cover-letters:all","dashboard:bundle"]),fy.info("Cover letter generated and saved. Refreshing preview\u2026",{duration:6e3});try{P({letterId:s,reused:!1,hydrationPending:!0})}catch(R){}return}const x=(null===(l=f)||void 0===l?void 0:l.generated_text)||(null===(d=f)||void 0===d?void 0:d.content_markdown)||"";oN(r.user_id,a,"cover_letter"),S_(r.user_id,a),_(s);try{const e=new URLSearchParams(y);e.set("cover_letter_id",s),b(e,{replace:!0})}catch(T){}if(C(x),$(null),S((null===e||void 0===e?void 0:e.title)||(null===(u=f)||void 0===u?void 0:u.title)||i),I(!1),z(e&&"object"===typeof e.billing?e.billing:null),V(null!==(m=null===e||void 0===e?void 0:e.charge_reason)&&void 0!==m?m:null),nw(["cover-letters:all","dashboard:bundle"]),OS("cover_letter","cache_invalidated",{keys:["cover-letters:all","dashboard:bundle"]}),fy.success("Cover letter generated."),L("stabilizing"),"function"===typeof(null===h||void 0===h?void 0:h.refresh))try{await h.refresh()}catch(B){}OS("cover_letter","credits_refresh_completed",{letterId:s});try{var p,v;yS(gS.PACK_ARTEFACT_READY,{jobId:a,actionCode:"cover_letter",artefactId:s,reused:!!(null!==e&&void 0!==e&&null!==(p=e.billing)&&void 0!==p&&p.idempotent||null!==e&&void 0!==e&&null!==(v=e.billing)&&void 0!==v&&v.cached)})}catch(M){}L(null);try{var g,w;P({letterId:s,reused:!!(null!==e&&void 0!==e&&null!==(g=e.billing)&&void 0!==g&&g.idempotent||null!==e&&void 0!==e&&null!==(w=e.billing)&&void 0!==w&&w.cached)})}catch(U){}OS("cover_letter","operation_closed",{letterId:s})}catch(pK){if(Gw(pK,{action:"Generate cover letter",refreshCredits:null===h||void 0===h?void 0:h.refresh}))return;if(pK&&!0===pK.recoverable){try{ee(!0)}catch(q){}return void fy.info("Your cover letter is still generating in the background. Please check Documents \u2192 Cover Letters in a minute.",{duration:9e3})}const t=null===pK||void 0===pK?void 0:pK.status;"number"===typeof t&&t>=500?fy.error("Sorry \u2014 we couldn't generate your cover letter just now. Your credits weren't charged. Please try again in a moment, or contact support if this keeps happening.",{duration:9e3}):fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to generate cover letter.");try{null!==r&&void 0!==r&&r.user_id&&a&&S_(r.user_id,a)}catch(W){}}finally{F(!1),L(null);try{O({message:"generation_path_exited"})}catch(H){}}},ie=(0,s.useMemo)(()=>N?"Regenerate Cover Letter":"Generate Cover Letter",[N]),oe=(0,s.useMemo)(()=>"cv_variant"===j?"tailored CV variant":(null===r||void 0===r?void 0:r.original_filename)||"Source CV",[j,null===r||void 0===r?void 0:r.original_filename]),le=(0,s.useMemo)(()=>D?D.split("\n").slice(0,6).join("\n"):"",[D]);return(0,Xt.jsxs)("div",{"data-testid":p,className:"flex flex-col gap-5 min-w-0 max-w-full",children:[(0,Xt.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,Xt.jsx)("h2",{className:"text-lg font-semibold text-ndor-ink",children:"Cover Letter"}),"checking"===u&&(0,Xt.jsxs)("span",{role:"status","aria-live":"polite","data-testid":"workspace-letter-lookup-checking",className:"inline-flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-3 w-3 animate-spin","aria-hidden":"true"}),"Checking for existing application materials\u2026"]}),"ready"===u&&m&&N&&(0,Xt.jsx)(fS,{testId:"workspace-letter-loaded-from-history-badge"}),(0,Xt.jsx)(XS,{jobId:a,actionCode:"cover_letter",progressLabel:B}),null!=g&&(0,Xt.jsx)(Vw,{className:"text-[10px] uppercase tracking-[0.14em] bg-ndor-gold/15 text-ndor-gold border-0","data-testid":"workspace-letter-price-label",children:g})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"A cover letter is optional \u2014 Continue without one anytime."})]}),(0,Xt.jsxs)("div",{"data-testid":"workspace-letter-source-card",className:"rounded-lg border border-ndor-line p-3 space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(Bg,{className:"h-4 w-4 text-ndor-ink-muted shrink-0"}),(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:["Generated against ",oe]})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Change this on the previous step if needed."})]}),K&&!N&&(0,Xt.jsxs)("div",{"data-testid":"workspace-letter-restoring-banner",className:"rounded-lg border border-ndor-line bg-ndor-bg-subtle p-3 flex items-center gap-2",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin text-ndor-gold","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed",children:[(0,Xt.jsx)("p",{className:"font-medium",children:"Restoring your cover letter\u2026"}),(0,Xt.jsx)("p",{className:"text-ndor-ink-muted",children:"We're reading your saved letter \u2014 no Credits charged."})]})]}),N&&(0,Xt.jsxs)("div",{"data-testid":"workspace-letter-generated-card","data-cv-context-source-type":j,"data-cv-context-source-id":w||"","data-row-cv-variant-id":q||"","data-row-base-cv-id":H||"",className:"rounded-lg border-2 border-ndor-gold/40 bg-ndor-gold/[0.02] p-3 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:A||"Cover letter"}),(0,Xt.jsx)(Vw,{className:"text-[10px] uppercase tracking-[0.14em] bg-ndor-gold/15 text-ndor-gold border-0",children:R?"Recovered \xb7 just now":"Cover letter \xb7 this attempt"}),(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5 text-ndor-success ml-auto","aria-hidden":!0})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed",children:R?"Restored from your last Generate attempt \u2014 no new Credits charged.":"Saved to Documents \u2192 Cover Letters."}),M?(0,Xt.jsxs)("p",{className:"text-[11px] "+(M.charged?"text-ndor-warning":"text-ndor-ink-muted"),"data-testid":"workspace-letter-billing-line",children:[M.idempotent?"Idempotent replay \u2014 no new Credits charged.":M.charged?"Charged successfully.":"Generated \u2014 no Credits charged.",null!=M.usage_consumed&&(0,Xt.jsxs)("span",{className:"ml-1",children:["\xb7 Charged"," ",(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums","data-testid":"workspace-letter-billing-usage-consumed",children:M.usage_consumed})," ","credit",1===M.usage_consumed?"":"s"]}),M.usage_source&&(0,Xt.jsxs)("span",{className:"ml-1 text-ndor-ink-muted",children:["\xb7 from"," ",(0,Xt.jsx)("span",{className:"font-mono-ui","data-testid":"workspace-letter-billing-usage-source",children:M.usage_source})]}),M.plan_code&&(0,Xt.jsxs)("span",{className:"ml-1 text-ndor-ink-muted",children:["\xb7 plan"," ",(0,Xt.jsx)("span",{className:"font-mono-ui","data-testid":"workspace-letter-billing-plan-code",children:M.plan_code})]}),U&&"cover_letter_generated"!==U&&"idempotent_replay"!==U&&(0,Xt.jsxs)("span",{className:"ml-1 text-ndor-ink-muted",children:["\xb7"," ",(0,Xt.jsx)("span",{"data-testid":"workspace-letter-billing-reason",children:U})]})]}):(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-letter-billing-unavailable",children:["Billing details \u2014 ",(0,Xt.jsx)("span",{"aria-hidden":!0,
2children:"\u2014"})," ",(0,Xt.jsx)("span",{className:"sr-only",children:"not available for this saved letter."})]}),le&&(0,Xt.jsxs)("pre",{"data-testid":"workspace-letter-draft-preview",className:"font-mono-ui text-[11px] text-ndor-ink-muted whitespace-pre-wrap leading-relaxed border-t border-ndor-line pt-2",children:[le,D.split("\n").length>6&&"\n\u2026"]}),J&&(0,Xt.jsxs)("div",{"data-testid":"workspace-letter-hydration-pending",className:"flex items-center gap-2 rounded-md border border-ndor-info-border bg-ndor-info-light/60 px-3 py-2 mt-2",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 text-ndor-info shrink-0 animate-spin"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-secondary flex-1 leading-relaxed",children:"Generated and saved. Refreshing preview\u2026"}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"h-7 px-3 text-[11px]",onClick:async()=>{const e=(null===J||void 0===J?void 0:J.letterId)||N;if(e){Q(!0);try{const t=await iE({envelope:null,letterId:e,apiGet:(e,t)=>(0,zt.n)(e,t)}),n=(null===t||void 0===t?void 0:t.content_markdown)||(null===t||void 0===t?void 0:t.generated_text)||"";if(!n)return void fy.info("Still saving. Try again in a few seconds.");_(e),C(n),S((null===t||void 0===t?void 0:t.title)||A||""),$(null),fy.success("Cover letter ready.")}catch(mK){!0===(null===mK||void 0===mK?void 0:mK.recoverable)?fy.info("Cover letter is still saving. Please retry in a few seconds or open Documents \u2192 Cover Letters."):fy.error((null===mK||void 0===mK?void 0:mK.message)||"Could not refresh preview.")}finally{Q(!1)}}},disabled:X,"data-testid":"workspace-letter-hydration-retry-button",children:[X?(0,Xt.jsx)(Lg,{className:"h-3 w-3 mr-1 animate-spin"}):(0,Xt.jsx)(Kg,{className:"h-3 w-3 mr-1"}),"Refresh preview"]})]})]}),te&&(0,Xt.jsxs)("div",{"data-testid":"cl-regenerate-confirm",role:"alertdialog","aria-modal":"true","aria-labelledby":"cl-regenerate-confirm-title",className:"my-4 rounded-lg border border-amber-500/60 bg-amber-500/10 p-4 text-sm",children:[(0,Xt.jsx)("div",{id:"cl-regenerate-confirm-title",className:"font-medium text-amber-100 mb-1.5",children:"Regenerate cover letter?"}),(0,Xt.jsx)("div",{className:"text-amber-50/80 mb-3",children:"You already have a cover letter for this job. Generating a new one will spend Credits and replace the version shown above."}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>ne(null),"data-testid":"cl-regenerate-cancel",children:"Keep existing"}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:()=>{ne(null),se({force:!0})},disabled:E||x||!(null!==r&&void 0!==r&&r.id),"data-testid":"cl-regenerate-confirm-go",children:[(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5"}),"Regenerate cover letter"]})]})]}),(0,Xt.jsxs)("footer",{"data-testid":"workspace-section-footer",className:"sticky bottom-0 z-10 -mx-3 sm:-mx-4 px-3 sm:px-4 py-3 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] flex flex-col xs:flex-row xs:flex-wrap xs:items-center xs:justify-between gap-2 border-t border-border/60 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:[(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:o,"data-testid":"workspace-section-back-button",className:"w-full xs:w-auto px-2 sm:px-3",children:[(0,Xt.jsx)(Zg,{className:"mr-1 sm:mr-1.5 h-3.5 w-3.5"}),(0,Xt.jsx)("span",{className:"hidden sm:inline",children:"Back to CV"}),(0,Xt.jsx)("span",{className:"sm:hidden",children:"Back"})]}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:se,disabled:E||x||!(null!==r&&void 0!==r&&r.id)||d||"dispatching"===T||"polling"===T||"stabilizing"===T||"ready"!==u,"data-testid":"workspace-letter-generate-button","data-controller-status":T,className:"w-full xs:w-auto xs:flex-1 xs:min-w-0 sm:flex-none px-2 sm:px-3",children:[E?(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin shrink-0"}):(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5 shrink-0"}),(0,Xt.jsx)("span",{className:"hidden xs:inline truncate","aria-hidden":"true",children:ie}),(0,Xt.jsx)("span",{className:"xs:hidden truncate","aria-hidden":"true",children:ie.startsWith("Re")?"Regen":"Generate"}),(0,Xt.jsx)("span",{className:"sr-only",children:ie})]}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:i,"data-testid":"workspace-section-continue-button",className:"w-full xs:w-auto px-2 sm:px-3",children:["Continue",(0,Xt.jsx)(zy,{className:"ml-1 sm:ml-1.5 h-3.5 w-3.5"})]})]}),x&&!E&&(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-letter-credits-loading-hint",children:"Loading your wallet\u2026"})]})}var uE=n(997);function mE(e,t){return"".concat("inflight-interview-prep",":").concat(e||"",":").concat(t||"")}function pE(e,t){if(!t)return null;try{const n=sessionStorage.getItem(mE(e,t));if(!n)return null;const a=JSON.parse(n);return a&&"object"===typeof a&&(a.idempotencyKey&&a.submittedAtMs)?a:null}catch(n){return null}}function hE(e,t){if(t)try{sessionStorage.removeItem(mE(e,t))}catch(n){}}function fE(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();return null===e||void 0===e||!e.submittedAtMs||t-Number(e.submittedAtMs)>6e5}Object.freeze({generic:{label:"Generic",questions:[],areas:[],notes:[]}
2,technical:{label:"Technical",questions:[],areas:[],notes:[]},strategic:{label:"Strategic",questions:[],areas:[],notes:[]},behavioural:{label:"Behavioural",questions:[],areas:[],notes:[]},gap_risk:{label:"Gap / Risk",questions:[],areas:[],notes:[]}});function xE(e){if(!e||"object"!==typeof e)return{headline:"",decisionContext:"",preparationPriorities:[],buckets:{generic:{label:"Generic",questions:[],areas:[],notes:[]},technical:{label:"Technical",questions:[],areas:[],notes:[]},strategic:{label:"Strategic",questions:[],areas:[],notes:[]},behavioural:{label:"Behavioural",questions:[],areas:[],notes:[]},gap_risk:{label:"Gap / Risk",questions:[],areas:[],notes:[]}},generated:!1,isLegacyOrEmpty:!0};const t={headline:"",decisionContext:"",preparationPriorities:[],buckets:{generic:{label:"Generic",questions:[],areas:[],notes:[]},technical:{label:"Technical",questions:[],areas:[],notes:[]},strategic:{label:"Strategic",questions:[],areas:[],notes:[]},behavioural:{label:"Behavioural",questions:[],areas:[],notes:[]},gap_risk:{label:"Gap / Risk",questions:[],areas:[],notes:[]}},generated:!1,isLegacyOrEmpty:!0};t.headline="string"===typeof e.headline?e.headline.trim():"",t.decisionContext="string"===typeof e.decision_context?e.decision_context.trim().toLowerCase():"",t.preparationPriorities=Array.isArray(e.preparation_priorities)?e.preparation_priorities.filter(e=>"string"===typeof e&&e.trim()):[];const n=Array.isArray(e.likely_questions)?e.likely_questions:[];for(const o of n){if(!o||"object"!==typeof o)continue;const e="string"===typeof o.question?o.question.trim():"";if(!e)continue;const n="string"===typeof o.category?o.category.trim().toLowerCase():"";let a;switch(n){case"technical":a="technical";break;case"behavioural":a="behavioural";break;case"gap_probe":a="gap_risk";break;default:a="generic"}t.buckets[a].questions.push({question:e,category:n||"fit"})}const a=Array.isArray(e.technical_scrutiny_areas)?e.technical_scrutiny_areas:[];for(const o of a){if(!o||"object"!==typeof o)continue;const e="string"===typeof o.area?o.area.trim():"";e&&t.buckets.technical.areas.push({area:e,why:"string"===typeof o.why_probed?o.why_probed.trim():"",focus:"string"===typeof o.preparation_focus?o.preparation_focus.trim():""})}const r=Array.isArray(e.behavioural_scrutiny_areas)?e.behavioural_scrutiny_areas:[];for(const o of r){if(!o||"object"!==typeof o)continue;const e="string"===typeof o.area?o.area.trim():"";e&&t.buckets.behavioural.areas.push({area:e,why:"string"===typeof o.why_probed?o.why_probed.trim():"",starAnchor:"string"===typeof o.star_anchor_hint?o.star_anchor_hint.trim():""})}const s=Array.isArray(e.cv_vulnerability_points)?e.cv_vulnerability_points:[];for(const o of s){if(!o||"object"!==typeof o)continue;const e="string"===typeof o.vulnerability?o.vulnerability.trim():"";e&&t.buckets.gap_risk.areas.push({vulnerability:e,framing:"string"===typeof o.likely_recruiter_framing?o.likely_recruiter_framing.trim():"",strategy:"string"===typeof o.truthful_response_strategy?o.truthful_response_strategy.trim():"",soften:"string"===typeof o.soften_alternative?o.soften_alternative.trim():""})}t.buckets.strategic.notes=Array.isArray(e.positioning_recommendations)?e.positioning_recommendations.filter(e=>"string"===typeof e&&e.trim()):[];const i=Object.values(t.buckets).some(e=>e.questions.length>0||e.areas.length>0||e.notes.length>0)||t.preparationPriorities.length>0||!!t.headline;return t.generated="boolean"===typeof e.generated?!!e.generated&&i:i,t.isLegacyOrEmpty=!i,t}const vE=Object.freeze(["generic","technical","strategic","behavioural","gap_risk"]);function gE(e){let{interviewPrep:t}=e;const n=(0,s.useMemo)(()=>xE(t||null),[t]);return n.isLegacyOrEmpty?(0,Xt.jsx)("div",{"data-testid":"workspace-fit-prep-empty",className:"rounded-md border border-dashed border-border/60 bg-background/50 p-3 text-[11px] text-ndor-ink-muted leading-relaxed",children:(0,Xt.jsx)("p",{children:"Interview prep content is not available for this run. Generate a fresh run to surface tailored questions and guidance."})}):(0,Xt.jsxs)("div",{"data-testid":"workspace-fit-prep-buckets",className:"space-y-3 pt-1",children:[n.headline&&(0,Xt.jsx)("p",{"data-testid":"workspace-fit-prep-headline",className:"text-[12px] text-ndor-ink leading-relaxed font-medium",children:xS(n.headline)}),n.preparationPriorities.length>0&&(0,Xt.jsxs)("div",{"data-testid":"workspace-fit-prep-priorities",className:"rounded-md border border-border/40 bg-ndor-gold/[0.04] p-2.5 space-y-1",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.14em] text-ndor-gold font-semibold",children:"Top priorities"}),(0,Xt.jsx)("ul",{className:"text-[12px] text-ndor-ink leading-relaxed space-y-1 list-none",children:n.preparationPriorities.map((e,t)=>(0,Xt.jsxs)("li",{"data-testid":"workspace-fit-prep-priority-".concat(t),className:"flex gap-1.5",children:[(0,Xt.jsx)("span",{className:"text-ndor-gold shrink-0",children:"\u2022"}),(0,Xt.jsx)("span",{children:xS(e)})]},t))})]}),vE.map(e=>{const t=n.buckets[e],a=t.questions.length+t.areas.length+t.notes.length;return 0===a?null:(0,Xt.jsxs)("details",{"data-testid":"workspace-fit-prep-bucket-".concat(e),className:"group rounded-md border border-border/50 bg-background/60 open:bg-background/80 transition",children:[(0,Xt.jsxs)("summary",{"data-testid":"workspace-fit-prep-bucket-".concat(e,"-summary"),className:"flex items-center gap-2 px-3 py-2 cursor-pointer select-none list-none [&::-webkit-details-marker]:hidden",children:[(0,Xt.jsx)("span",{className:"text-[12px] font-medium text-ndor-ink flex-1",children:t.label}),(0,Xt.jsx)(Vw,{className:"text-[10px] tabular-nums bg-ndor-line/40 text-ndor-ink-muted border-0",children:a}
2),(0,Xt.jsx)("span",{"aria-hidden":!0,className:"text-ndor-ink-muted text-[10px] transition-transform group-open:rotate-90",children:"\u25b6"})]}),(0,Xt.jsxs)("div",{className:"px-3 pb-3 pt-1 space-y-2.5 text-[12px] text-ndor-ink leading-relaxed",children:[t.questions.length>0&&(0,Xt.jsx)("ul",{"data-testid":"workspace-fit-prep-bucket-".concat(e,"-questions"),className:"space-y-1.5 list-none",children:t.questions.map((e,t)=>(0,Xt.jsxs)("li",{className:"flex gap-1.5",children:[(0,Xt.jsx)("span",{className:"text-ndor-gold shrink-0",children:"Q."}),(0,Xt.jsx)("span",{children:xS(e.question)})]},t))}),t.areas.length>0&&(0,Xt.jsx)("ul",{"data-testid":"workspace-fit-prep-bucket-".concat(e,"-areas"),className:"space-y-2 list-none",children:t.areas.map((t,n)=>(0,Xt.jsxs)("li",{className:"rounded-md border border-border/30 bg-background/70 p-2 space-y-0.5",children:[(0,Xt.jsx)("p",{className:"font-medium text-ndor-ink",children:xS(t.area||t.vulnerability||"")}),t.why&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsx)("span",{className:"font-medium",children:"Why probed:"})," ",xS(t.why)]}),t.focus&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsx)("span",{className:"font-medium",children:"Prep focus:"})," ",xS(t.focus)]}),t.starAnchor&&(0,Xt.jsxs)("p",{"data-testid":"workspace-fit-prep-bucket-".concat(e,"-star-").concat(n),className:"text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsx)("span",{className:"font-medium",children:"STAR anchor:"})," ",xS(t.starAnchor)]}),t.framing&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsx)("span",{className:"font-medium",children:"Likely framing:"})," ",xS(t.framing)]}),t.strategy&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsx)("span",{className:"font-medium",children:"Strategy:"})," ",xS(t.strategy)]}),t.soften&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsx)("span",{className:"font-medium",children:"Soften:"})," ",xS(t.soften)]})]},n))}),t.notes.length>0&&(0,Xt.jsx)("ul",{"data-testid":"workspace-fit-prep-bucket-".concat(e,"-notes"),className:"space-y-1 list-none",children:t.notes.map((e,t)=>(0,Xt.jsxs)("li",{className:"flex gap-1.5",children:[(0,Xt.jsx)("span",{className:"text-ndor-gold shrink-0",children:"\u2022"}),(0,Xt.jsx)("span",{children:xS(e)})]},t))})]})]},e)})]})}const yE="ndor.workspace.interview_prep.unlock.v1";function bE(){if("undefined"===typeof window||!window.localStorage)return{};try{const e=window.localStorage.getItem(yE);if(!e)return{};const t=JSON.parse(e);return t&&"object"===typeof t&&!Array.isArray(t)?t:{}}catch(e){return{}}}function wE(e){let{userId:t,jobId:n,sourceType:a,sourceId:r}=e;if(!t||!n)return null;const s=a||"unknown",i=r||"unknown";return"".concat(t,"::").concat(n,"::").concat(s,"::").concat(i)}function jE(e){var t;const n=wE(e||{});if(!n)return null;const a=bE()[n];return a&&1===a.v&&null!==(t=a.payload)&&void 0!==t?t:null}function kE(e){var t,a,r,i,o,l,d,u;let{job:m,jobId:p,primaryCv:h,onContinue:f,onBack:x,onBusyChange:v,workspaceBusy:g=!1,lookupStatus:y="ready",loadedFromHistory:b=!1,rootTestId:w="workspace-fit-section"}=e;const j=If(),k=null===j||void 0===j?void 0:j.usageCosts,N=!j||!!j.loading,_=Nf(k,"interview_prep"),D=null==_?null:"".concat(_," ").concat(1===_?"Credit":"Credits"),[C,A]=Pt(),S=C.get("source_cv_type")||"base_cv",E=C.get("source_cv_id")||(null===h||void 0===h?void 0:h.id)||null,F="cv_variant"===S?"cv_variant":"uploaded_cv",[R,I]=(0,s.useState)(null),[T,P]=(0,s.useState)(!1),O=Xk(Hk(null===h||void 0===h?void 0:h.user_id,p,E));(0,s.useEffect)(()=>{null===v||void 0===v||v(T)},[T,v]);const{status:B,markComplete:L,markFailed:M}=IS(p,"interview_prep"),[z,U]=(0,s.useState)(null),[V,q]=(0,s.useState)(!0),[W,H]=(0,s.useState)(!1),[G,K]=(Uk({targetKind:"job",targetId:p,actionCode:"interview_prep",enabled:!(!p||null===h||void 0===h||!h.user_id),apiFetch:(e,t)=>(0,zt.n)(e,t),onTerminal:e=>{try{if(null!==e&&void 0!==e&&e.result_envelope_ref&&!C.get("interview_prep_id")){const t=new URLSearchParams(C);
2t.set("interview_prep_id",e.result_envelope_ref),"function"===typeof A&&A(t,{replace:!0})}}catch(t){}try{hE(null===h||void 0===h?void 0:h.user_id,p)}catch(n){}},onNone:()=>{try{hE(null===h||void 0===h?void 0:h.user_id,p)}catch(e){}},onRecovering:()=>{try{H(!0)}catch(e){}}}),(0,s.useState)(null)),[Y,J]=(0,s.useState)(null),[$,X]=(0,s.useState)(!1),[Q,Z]=(0,s.useState)(null),ee=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!p||null===h||void 0===h||!h.user_id||!E)return void q(!1);I(e=>e?e.sourceType===F&&e.sourceId===E?e:null:e);const e=jE({userId:h.user_id,jobId:p,sourceType:F,sourceId:E});if(e&&(I((n={sourceType:F,sourceId:E},(t=e)?{score:t.score||null,analysis:null,interview_prep:t.interview_prep||null,billing:(0,c.A)((0,c.A)({},t.billing||{}),{},{cached:!0}),sourceType:n.sourceType,sourceId:n.sourceId}:null)),"function"===typeof(null===j||void 0===j?void 0:j.refresh)))try{j.refresh()}catch(a){}var t,n;q(!1)},[p,null===h||void 0===h?void 0:h.user_id,E,F]),(0,s.useEffect)(()=>{if(!p||null===h||void 0===h||!h.user_id)return;if(null!==R&&void 0!==R&&R.interview_prep_id)return;if(T)return;const e=pE(h.user_id,p);if(!e)return;if(fE(e))return void hE(h.user_id,p);if(!e.runId)return;let t=!1;return H(!0),(async()=>{try{const r=await(0,uE.K)(e.runId,{});if(t)return;const s={interview_prep_id:(null===r||void 0===r?void 0:r.interview_prep_id)||e.runId,score:(null===r||void 0===r?void 0:r.score)||null,interview_prep:(null===r||void 0===r?void 0:r.interview_prep)||null,billing:(0,c.A)((0,c.A)({},(null===r||void 0===r?void 0:r.billing)||{}),{},{cached:!0}),sourceType:F,sourceId:E,analysis:null};I(s);try{const e=new URLSearchParams(C);e.set("interview_prep_id",s.interview_prep_id),"function"===typeof A&&A(e,{replace:!0})}catch(n){}if(hE(h.user_id,p),oN(h.user_id,p,"interview_prep"),oN(h.user_id,p,"interview_prep:force"),fy.success("Interview Prep ready \u2014 recovered after refresh."),"function"===typeof(null===j||void 0===j?void 0:j.refresh))try{j.refresh()}catch(a){}}catch(pK){if(t)return;null!==pK&&void 0!==pK&&pK.recoverable||hE(h.user_id,p)}finally{t||H(!1)}})(),()=>{t=!0}},[p,null===h||void 0===h?void 0:h.user_id,E,F]),(0,s.useEffect)(()=>{if(!p||null===h||void 0===h||!h.user_id)return;if(null!==R&&void 0!==R&&R.interview_prep_id)return;if(C.get("interview_prep_id"))return;const e=(()=>{try{return pE(h.user_id,p)}catch(e){return null}})();if(null!==e&&void 0!==e&&e.runId)return;if(T)return;let t=!1;return(async()=>{try{var e;const a=new URLSearchParams;a.set("latest","true"),"cv_variant"===S&&E?a.set("cv_variant_id",E):"base_cv"===S&&E&&a.set("base_cv_id",E);const r=await(0,zt.n)("/api/interview-prep/by-job/".concat(encodeURIComponent(p),"?").concat(a.toString()));if(t)return;if(!r||!0!==r.found)return;const s=r.interview_prep_id||(null===(e=r.result)||void 0===e?void 0:e.interview_prep_id);if(!s)return;try{const e=new URLSearchParams(C);e.set("interview_prep_id",s),"function"===typeof A&&A(e,{replace:!0})}catch(n){}}catch(pK){OS("interview_prep","by_job_lookup_failed",{code:null===pK||void 0===pK?void 0:pK.code,status:null===pK||void 0===pK?void 0:pK.status})}})(),()=>{t=!0}},[p,null===h||void 0===h?void 0:h.user_id,E,F]),(0,s.useEffect)(()=>{if(!p||null===h||void 0===h||!h.user_id)return;if(null!==R&&void 0!==R&&R.interview_prep_id)return;let e=!1;try{const t=pE(h.user_id,p);e=!(!t||fE(t))}catch(o){}if(!e&&!W&&!T)return;let t=!1,n=null,a=!1;async function r(){if(!t&&!a){a=!0;try{var e,n,r;const a=new URLSearchParams;a.set("latest","true"),"cv_variant"===S&&E?a.set("cv_variant_id",E):"base_cv"===S&&E&&a.set("base_cv_id",E);const x=await(0,zt.n)("/api/interview-prep/by-job/".concat(encodeURIComponent(p),"?").concat(a.toString()));if(t||!x||!0!==x.found)return;const v=x.interview_prep_id||(null===(e=x.result)||void 0===e?void 0:e.interview_prep_id);if(!v)return;let g;try{g=await cE({envelope:{interview_prep_id:v,interview_prep:null},ipId:v,apiGet:(e,t)=>(0,zt.n)(e,t)})}catch(s){if(!0===(null===s||void 0===s?void 0:s.recoverable))return;return void OS("interview_prep","live_binder_hydrate_failed",{ipId:v,code:null===s||void 0===s?void 0:s.code})}if(t)return;const y=(null===(n=g)||void 0===n?void 0:n.result)||g,b=null===y||void 0===y?void 0:y.interview_prep;if(!b||"object"!==typeof b||0===Object.keys(b).length)return;
2const w={interview_prep_id:v,score:(null===y||void 0===y?void 0:y.score)||null,interview_prep:b,billing:(0,c.A)((0,c.A)({},(null===(r=g)||void 0===r?void 0:r.billing)||{}),{},{cached:!0}),sourceType:F,sourceId:E,analysis:null};I(w);try{const e=new URLSearchParams(C);e.get("interview_prep_id")!==v&&(e.set("interview_prep_id",v),"function"===typeof A&&A(e,{replace:!0}))}catch(i){}try{hE(h.user_id,p),oN(h.user_id,p,"interview_prep"),oN(h.user_id,p,"interview_prep:force")}catch(o){}try{H(!1)}catch(l){}try{"function"===typeof(null===j||void 0===j?void 0:j.refresh)&&j.refresh()}catch(d){}try{nw(["interview-prep:all","jobs","dashboard:bundle"])}catch(u){}try{yS(gS.PACK_ARTEFACT_READY,{jobId:p,actionCode:"interview_prep",artefactId:v,reused:!0})}catch(m){}try{L({interviewPrepId:v,reused:!0})}catch(f){}fy.success("Interview Prep ready."),OS("interview_prep","live_binder_bound",{ipId:v})}catch(pK){OS("interview_prep","live_binder_check_failed",{code:null===pK||void 0===pK?void 0:pK.code,status:null===pK||void 0===pK?void 0:pK.status})}finally{a=!1}
2}}function s(){"undefined"!==typeof document&&"visible"===document.visibilityState&&(n&&clearTimeout(n),n=setTimeout(r,250))}r();const i=setInterval(()=>{"undefined"!==typeof document&&"visible"!==document.visibilityState||r()},12e3);return"undefined"!==typeof document&&document.addEventListener("visibilitychange",s),()=>{t=!0,n&&clearTimeout(n),clearInterval(i),"undefined"!==typeof document&&document.removeEventListener("visibilitychange",s)}},[p,null===h||void 0===h?void 0:h.user_id,null===R||void 0===R?void 0:R.interview_prep_id,W,T,E,F]);const te=C.get("interview_prep_id"),ne=(0,s.useCallback)(async()=>{if(te&&p&&null!==h&&void 0!==h&&h.user_id&&E&&(null===R||void 0===R?void 0:R.interview_prep_id)!==te&&!T)try{var e,t;const o=await(0,zt.n)("/api/interview-prep/".concat(te),{method:"GET",headers:{"X-Envelope":"rc_1_52_canonical"}});if(!o||"complete"!==(o.status||"").toLowerCase())return;const l=o.result||{},d=(null===l||void 0===l?void 0:l.job_id)||(null===o||void 0===o?void 0:o.job_id);if(d&&d!==p)return;if(!(null!==C.get("from_pack"))){var n,a;const e=null!==(n=null===l||void 0===l?void 0:l.linked_cv_variant_id)&&void 0!==n?n:null,t=null!==(a=null===l||void 0===l?void 0:l.linked_base_cv_id)&&void 0!==a?a:null;if("cv_variant"===S){if(e!==E)return void OS("interview_prep","url_bound_rebind_ctx_mismatch",{ipId:te,expected:{sourceCvType:S,sourceCvId:E},actual:{linkedVariantId:e,linkedBaseCvId:t}})}else{if(null!==e)return void OS("interview_prep","url_bound_rebind_ctx_mismatch",{ipId:te,expected:{sourceCvType:S,sourceCvId:E},actual:{linkedVariantId:e,linkedBaseCvId:t}});if(t&&E&&t!==E)return void OS("interview_prep","url_bound_rebind_ctx_mismatch",{ipId:te,expected:{sourceCvType:S,sourceCvId:E},actual:{linkedVariantId:e,linkedBaseCvId:t}})}}I({interview_prep_id:l.interview_prep_id||te,score:l.score||null,interview_prep:l.interview_prep||null,billing:(0,c.A)((0,c.A)({},o.billing||{}),{},{cached:!0}),sourceType:F,sourceId:E,linked_cv_variant_id:null!==(e=null===l||void 0===l?void 0:l.linked_cv_variant_id)&&void 0!==e?e:null,linked_base_cv_id:null!==(t=null===l||void 0===l?void 0:l.linked_base_cv_id)&&void 0!==t?t:null,analysis:null});try{"function"===typeof(null===j||void 0===j?void 0:j.refresh)&&j.refresh()}catch(r){}try{nw(["interview-prep:all","jobs","dashboard:bundle"])}catch(s){}try{yS(gS.PACK_ARTEFACT_READY,{jobId:p,actionCode:"interview_prep",artefactId:l.interview_prep_id||te,reused:!0})}catch(i){}}catch(o){}},[te,p,null===h||void 0===h?void 0:h.user_id,E,F,T,null===R||void 0===R?void 0:R.interview_prep_id]);(0,s.useEffect)(()=>{if(!te)return;let e=!1;return(async()=>{e||await ne()})(),()=>{e=!0}},[ne,te]),wN({enabled:!!te&&!!p&&!(null===h||void 0===h||!h.user_id)&&!!E&&!T,fetchAndBind:ne});const ae=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!0!==e.userInitiated)return void console.warn("[InterviewPrep] handleRun blocked \u2014 userInitiated flag missing. Workspace Interview Prep only runs on explicit Generate button click.");const t=!0===e.force;if(E){if(((e,t)=>{if(N)return!1;const n=Nf(k,e);if(null==n||0===n)return!0;const a=Number((null===j||void 0===j?void 0:j.includedUsageRemaining)||0)+Number((null===j||void 0===j?void 0:j.extraUsageRemaining)||0);return a>=n||(fy.error("Not enough Credits for ".concat(t),{description:"".concat(a," available \xb7 ").concat(n," needed. Open Plan to add Credits."),action:{label:"View plan",onClick:()=>{try{window.location.assign("/account?tab=plan")}catch(e){}}}}),!1)})("interview_prep","Interview Prep")){if(ee.current)try{ee.current.abort()}catch(_){}ee.current=new AbortController,t&&K(e=>e?(0,c.A)((0,c.A)({},e),{},{busy:!0}):e),P(!0),U("dispatching"),OS("interview_prep","dispatch_start",{jobId:p,force:!!t});try{var a,r,s,i,o;if(null===m||void 0===m||null===(a=m.description)||void 0===a||!a.trim())return fy.error("Job description is missing. Reload the page."),void P(!1);const e=t?"interview_prep:force":"interview_prep";t&&oN(null===h||void 0===h?void 0:h.user_id,p,e);const x=iN(null===h||void 0===h?void 0:h.user_id,p,e);!function(e,t){let{idempotencyKey:n,runId:a,sourceCvId:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t&&n)try{sessionStorage.setItem(mE(e,t),JSON.stringify({submittedAtMs:Date.now(),idempotencyKey:n,runId:a||null,jobId:t,sourceCvId:r||null,startedAt:(new Date).toISOString()}))}catch(s){}}(null===h||void 0===h?void 0:h.user_id,p,{idempotencyKey:x,runId:null,
2sourceCvId:E});const v=await AS({jobId:p,actionCode:"interview_prep",idempotencyKey:x,run:async e=>{let{callbacks:a}=e;return async function(e){let{requestArgs:t,callbacks:a}=e;if(!t)throw new Error("interviewPrepAdapter.run: requestArgs is required");if("object"!==typeof t)throw new Error("interviewPrepAdapter.run: requestArgs must be an object");const{generateInterviewPrepWithPolling:r}=await Promise.resolve().then(n.bind(n,997)),s=t.onRunIdReady;return r((0,c.A)((0,c.A)({},t),{},{onRunIdReady:e=>{try{null!==a&&void 0!==a&&a.onProgress&&a.onProgress("running","running"),null!==a&&void 0!==a&&a.onPolling&&a.onPolling()}catch(t){}if("function"===typeof s)try{s(e)}catch(n){}}}))}({requestArgs:{jobId:p,jobText:m.description,sourceType:F,sourceId:E,baseCvId:null===h||void 0===h?void 0:h.id,title:(null===m||void 0===m?void 0:m.title)||"Interview Prep",idempotencyKey:x,forceRegenerate:!!t,signal:ee.current.signal,onRunIdReady:e=>{if(e){U("polling"),function(e,t,n){if(t&&n)try{const a=sessionStorage.getItem(mE(e,t));if(!a)return;const r=JSON.parse(a);if(!r||"object"!==typeof r)return;r.runId=n,sessionStorage.setItem(mE(e,t),JSON.stringify(r))}catch(a){}}(null===h||void 0===h?void 0:h.user_id,p,e);try{const t=new URLSearchParams(C);t.set("interview_prep_id",e),"function"===typeof A&&A(t,{replace:!0})}catch(t){}}}},callbacks:a})}});if(!v){try{hE(null===h||void 0===h?void 0:h.user_id,p),oN(null===h||void 0===h?void 0:h.user_id,p,"interview_prep"),oN(null===h||void 0===h?void 0:h.user_id,p,"interview_prep:force")}catch(D){}return}const g=(null===v||void 0===v?void 0:v.interview_prep_id)||(null===v||void 0===v?void 0:v.run_id);let y=null!==(r=null===v||void 0===v?void 0:v.interview_prep)&&void 0!==r?r:null,b=(null===v||void 0===v?void 0:v.score)||null,w=!1;if(g){U("hydrating");try{const e=await cE({envelope:v,ipId:g,apiGet:(e,t)=>(0,zt.n)(e,t)}),t=(null===e||void 0===e?void 0:e.result)||e;null!==t&&void 0!==t&&t.interview_prep&&"object"===typeof t.interview_prep&&Object.keys(t.interview_prep).length>0&&(y=t.interview_prep,b=t.score||b)}catch(S){if(OS("interview_prep","post_terminal_hydrate_failed",{ipId:g,code:null===S||void 0===S?void 0:S.code}),!0!==(null===S||void 0===S?void 0:S.recoverable))throw S;w=!0}}const k={interview_prep_id:g||null,score:b,interview_prep:y,billing:null!==(s=null===v||void 0===v?void 0:v.billing)&&void 0!==s?s:{cached:!1},sourceType:F,sourceId:E};if(I((0,c.A)((0,c.A)({},k),{},{analysis:null})),J(w?{ipId:g}:null),g)try{const e=new URLSearchParams(C);e.set("interview_prep_id",g),"function"===typeof A&&A(e,{replace:!0})}catch(R){}nw(["interview-prep:all","jobs","dashboard:bundle"]),K(null);try{oN(null===h||void 0===h?void 0:h.user_id,p,"interview_prep"),oN(null===h||void 0===h?void 0:h.user_id,p,"interview_prep:force"),hE(null===h||void 0===h?void 0:h.user_id,p)}catch(T){}if(w?fy.info("Interview prep generated and saved. Refreshing preview\u2026",{duration:6e3}):null!==v&&void 0!==v&&null!==(i=v.billing)&&void 0!==i&&i.cached||null!==v&&void 0!==v&&null!==(o=v.billing)&&void 0!==o&&o.idempotent||null!==v&&void 0!==v&&v.idempotent_replay?fy.success("Existing interview prep loaded \u2014 no Credits charged."):fy.success("Interview Prep ready."),U("stabilizing"),"function"===typeof(null===j||void 0===j?void 0:j.refresh))try{await j.refresh()}catch(O){}OS("interview_prep","credits_refresh_completed",{});try{var l,d;yS(gS.PACK_ARTEFACT_READY,{jobId:p,actionCode:"interview_prep",artefactId:(null===v||void 0===v?void 0:v.interview_prep_id)||(null===v||void 0===v?void 0:v.run_id)||null,reused:!!(null!==v&&void 0!==v&&null!==(l=v.billing)&&void 0!==l&&l.cached||null!==v&&void 0!==v&&null!==(d=v.billing)&&void 0!==d&&d.idempotent||null!==v&&void 0!==v&&v.idempotent_replay)})}catch(B){}try{Yk(Hk(h.user_id,p,E))}catch(z){}U(null);try{var u,f;L({interviewPrepId:(null===v||void 0===v?void 0:v.interview_prep_id)||(null===v||void 0===v?void 0:v.run_id)||null,reused:!!(null!==v&&void 0!==v&&null!==(u=v.billing)&&void 0!==u&&u.cached||null!==v&&void 0!==v&&null!==(f=v.billing)&&void 0!==f&&f.idempotent||null!==v&&void 0!==v&&v.idempotent_replay)})}catch(V){}OS("interview_prep","operation_closed",{interviewPrepId:(null===v||void 0===v?void 0:v.interview_prep_i
2d)||(null===v||void 0===v?void 0:v.run_id)||null})}catch(pK){var x,v;if(!0===(null===pK||void 0===pK?void 0:pK.recoverable)||"AbortError"===(null===pK||void 0===pK?void 0:pK.name)){try{H(!0)}catch(q){}return void fy.info("Interview Prep is still generating in the background. It will appear automatically when ready \u2014 no need to re-click.")}const t=null===pK||void 0===pK||null===(x=pK.data)||void 0===x||null===(v=x.detail)||void 0===v?void 0:v.code;var g,y,b,w;if(409===(null===pK||void 0===pK?void 0:pK.status)&&("INFERIOR_SOURCE"===t||"INFERIOR_VARIANT"===t))return void K({code:t,message:(null===pK||void 0===pK||null===(g=pK.data)||void 0===g||null===(y=g.detail)||void 0===y?void 0:y.message)||null,guidance:(null===pK||void 0===pK||null===(b=pK.data)||void 0===b||null===(w=b.detail)||void 0===w?void 0:w.guidance)||{},busy:!1});if(Gw(pK,{action:"Interview Prep",refreshCredits:null===j||void 0===j?void 0:j.refresh}))return;try{hE(null===h||void 0===h?void 0:h.user_id,p)}catch(W){}fy.error((null===pK||void 0===pK?void 0:pK.message)||"Interview Prep failed.")}finally{P(!1),U(null),K(e=>e?(0,c.A)((0,c.A)({},e),{},{busy:!1}):e);try{M({message:"generation_path_exited"})}catch(G){}}}}else fy.error("Select a CV first (go back to the CV step).")},re=!(null===R||void 0===R||null===(t=R.billing)||void 0===t||!t.cached),se=!(null===R||void 0===R||null===(a=R.billing)||void 0===a||!a._recovered_inflight),ie=(0,s.useMemo)(()=>xE((null===R||void 0===R?void 0:R.interview_prep)||null),[null===R||void 0===R?void 0:R.interview_prep]),oe=(0,s.useMemo)(()=>"cv_variant"===S?"tailored CV variant":(null===h||void 0===h?void 0:h.original_filename)||"Source CV",[S,null===h||void 0===h?void 0:h.original_filename]),le=(0,s.useMemo)(()=>R?"Regenerate Interview Prep":"Generate Interview Prep",[R]),ce=T;return(0,Xt.jsxs)("div",{"data-testid":w,className:"flex flex-col gap-5 min-w-0 max-w-full",children:[(0,Xt.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,Xt.jsx)("h2",{className:"text-lg font-semibold text-ndor-ink",children:"Interview Prep"}),"checking"===y&&(0,Xt.jsxs)("span",{role:"status","aria-live":"polite","data-testid":"workspace-fit-lookup-checking",className:"inline-flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-3 w-3 animate-spin","aria-hidden":"true"}),"Checking for existing application materials\u2026"]}),"ready"===y&&b&&(null===R||void 0===R?void 0:R.interview_prep_id)&&(0,Xt.jsx)(fS,{testId:"workspace-fit-loaded-from-history-badge"}),(0,Xt.jsx)(XS,{jobId:p,actionCode:"interview_prep",progressLabel:z}),null!=D&&(0,Xt.jsx)(Vw,{className:"text-[10px] uppercase tracking-[0.14em] bg-ndor-gold/15 text-ndor-gold border-0","data-testid":"workspace-fit-price-label",children:D})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Optional \u2014 Continue without one and skip to the Application Pack."})]}),(0,Xt.jsxs)("div",{"data-testid":"workspace-fit-source-card",className:"rounded-lg border border-ndor-line p-3 space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(XN,{className:"h-4 w-4 text-ndor-ink-muted shrink-0"}),(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:["Analysing ",oe]})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Change this on the CV step if needed."})]}),V&&!R&&!T&&(0,Xt.jsxs)("div",{"data-testid":"workspace-fit-restoring-banner",className:"rounded-lg border border-ndor-line bg-ndor-bg-subtle p-3 flex items-center gap-2",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin text-ndor-gold","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed",children:[(0,Xt.jsx)("p",{className:"font-medium",children:"Restoring your interview prep\u2026"}),(0,Xt.jsx)("p",{className:"text-ndor-ink-muted",children:"We're reading your saved interview prep \u2014 no Credits charged."})]})]}),G&&(0,Xt.jsxs)("div",{"data-testid":"workspace-fit-inferior-guard",role:"alert",className:"rounded-lg border-2 border-ndor-warning/40 bg-ndor-warning/[0.05] p-3 space-y-3",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 text-ndor-warning shrink-0 mt-0.5","aria-hidden":!0}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink leading-relaxed space-y-1",children:[(0,Xt.jsx)("p",{className:"font-medium text-sm","data-testid":"workspace-fit-inferior-guard-title",children:"INFERIOR_VARIANT"===G.code?"This tailored variant looks weaker than your Source CV.":"This CV looks weaker than your current baseline."}),(0,Xt.jsx)("p",{className:"text-ndor-ink-muted","data-testid":"workspace-fit-inferior-guard-copy",children:"Running Interview Prep on it would normally cost you Credits without improving how competitive you appear for this role. You can keep your existing analysis, or proceed anyway."})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 flex-wrap",children:[(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:()=>K(null),disabled:!!G.busy,"data-testid":"workspace-fit-inferior-guard-cancel",children:"Keep existing analysis"}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:()=>ae({force:!0,userInitiated:!0}),disabled:!!G.busy||N||!E,"data-testid":"workspace-fit-inferior-guard-force",children:[G.busy?(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5"}),"Analyse anyway"]})]})]}
2),Q&&(0,Xt.jsxs)("div",{className:"my-4 rounded-lg border border-amber-500/60 bg-amber-500/10 p-4 text-sm","data-testid":"ip-regenerate-confirm",role:"alertdialog","aria-modal":"true","aria-labelledby":"ip-regenerate-confirm-title",children:[(0,Xt.jsx)("div",{id:"ip-regenerate-confirm-title",className:"font-medium text-amber-100 mb-1.5",children:"Regenerate Interview Prep?"}),(0,Xt.jsx)("div",{className:"text-amber-50/80 mb-3",children:"You already have an Interview Prep for this job. Generating a new one will charge another 15 credits and replace the version shown above."}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>Z(null),"data-testid":"ip-regenerate-cancel",children:"Keep existing"}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:()=>{Z(null),ae({force:!0,userInitiated:!0})},"data-testid":"ip-regenerate-confirm-go",disabled:T||N||!E,children:[(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5"}),"Generate new (15 credits)"]})]})]}),R&&(0,Xt.jsxs)("div",{"data-testid":"workspace-fit-result-card","data-cv-context-source-type":S,"data-cv-context-source-id":E||"","data-row-cv-variant-id":(null===R||void 0===R?void 0:R.linked_cv_variant_id)||"","data-row-base-cv-id":(null===R||void 0===R?void 0:R.linked_base_cv_id)||"",className:"rounded-lg border-2 border-ndor-gold/40 bg-ndor-gold/[0.02] p-3 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink","data-testid":ie.generated?"workspace-fit-prep-ready-header":"workspace-fit-prep-not-ready-header",children:ie.generated?"Interview prep ready":"Interview Prep \u2014 not yet generated for this run"}),ie.generated&&(0,Xt.jsx)(Vw,{className:"text-[10px] uppercase tracking-[0.14em] bg-ndor-gold/15 text-ndor-gold border-0",children:se?"Recovered \xb7 just now":re?"Existing analysis \xb7 no charge":"Fresh run \xb7 this attempt"}),ie.generated&&(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5 text-ndor-success ml-auto","aria-hidden":!0})]}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed flex items-center gap-1.5",children:[(0,Xt.jsx)(zf,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),ie.generated?se?"Restored from your last Run attempt \u2014 no new Credits charged.":re?"Loaded from your prior run for this CV \u2014 no Credits charged.":"Saved to your job history.":"Click Run Interview Prep below to generate the 5-bucket prep for this CV."]}),(null!=(null===R||void 0===R||null===(r=R.billing)||void 0===r?void 0:r.usage_consumed)||null!=(null===R||void 0===R||null===(i=R.billing)||void 0===i?void 0:i.free_fit_used))&&(0,Xt.jsxs)("p",{className:"text-[11px] "+(null!=(null===R||void 0===R||null===(o=R.billing)||void 0===o?void 0:o.usage_consumed)&&R.billing.usage_consumed>0?"text-ndor-warning":"text-ndor-ink-muted"),"data-testid":"workspace-fit-billing-line",children:[null!=(null===R||void 0===R||null===(l=R.billing)||void 0===l?void 0:l.usage_consumed)&&(0,Xt.jsxs)("span",{children:["Charged"," ",(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums","data-testid":"workspace-fit-billing-usage-consumed",children:R.billing.usage_consumed})," ","credit",1===R.billing.usage_consumed?"":"s"]}),(null===R||void 0===R||null===(d=R.billing)||void 0===d?void 0:d.free_fit_used)&&(0,Xt.jsx)("span",{className:"ml-1","data-testid":"workspace-fit-billing-free-fit-used",children:"\xb7 Used your free analysis allowance"})]}),(null===R||void 0===R||null===(u=R.billing)||void 0===u?void 0:u.refunded)&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-success leading-relaxed flex items-start gap-1.5","data-testid":"workspace-fit-refund-line",children:[(0,Xt.jsx)(Og,{className:"h-3 w-3 shrink-0 mt-0.5","aria-hidden":!0}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("span",{className:"font-medium",children:"Credits refunded."})," ",(R.billing.refund_reason,"Credits returned to your wallet automatically."),R.billing.refund_reason&&(0,Xt.jsxs)("span",{className:"ml-1 text-ndor-ink-muted","data-testid":"workspace-fit-refund-reason",children:["(reason: ",(0,Xt.jsx)("code",{className:"font-mono-ui",children:R.billing.refund_reason}),")"]})]})]}),(0,Xt.jsx)(gE,{interviewPrep:null===R||void 0===R?void 0:R.interview_prep}),Y&&(0,Xt.jsxs)("div",{"data-testid":"workspace-ip-hydration-pending",className:"flex items-center gap-2 rounded-md border border-ndor-info-border bg-ndor-info-light/60 px-3 py-2 mt-3",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 text-ndor-info shrink-0 animate-spin"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-secondary flex-1 leading-relaxed",children:"Generated and saved. Refreshing preview\u2026"}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"h-7 px-3 text-[11px]",onClick:async()=>{const e=(null===Y||void 0===Y?void 0:Y.ipId)||(null===R||void 0===R?void 0:R.interview_prep_i
2d);if(e){X(!0);try{const t=await cE({envelope:null,ipId:e,apiGet:(e,t)=>(0,zt.n)(e,t)}),n=(null===t||void 0===t?void 0:t.result)||t,a=null===n||void 0===n?void 0:n.interview_prep;if(!a||"object"!==typeof a||0===Object.keys(a).length)return void fy.info("Still saving. Try again in a few seconds.");I(r=>(0,c.A)((0,c.A)({},r||{}),{},{interview_prep_id:e,interview_prep:a,score:n.score||(null===r||void 0===r?void 0:r.score)||null,billing:(0,c.A)((0,c.A)({},(null===t||void 0===t?void 0:t.billing)||(null===r||void 0===r?void 0:r.billing)||{}),{},{cached:!0}),analysis:null})),J(null),fy.success("Interview prep ready.")}catch(mK){!0===(null===mK||void 0===mK?void 0:mK.recoverable)?fy.info("Interview prep is still saving. Please retry in a few seconds or open Documents \u2192 Interview Prep."):fy.error((null===mK||void 0===mK?void 0:mK.message)||"Could not refresh preview.")}finally{X(!1)}}},disabled:$,"data-testid":"workspace-ip-hydration-retry-button",children:[$?(0,Xt.jsx)(Lg,{className:"h-3 w-3 mr-1 animate-spin"}):(0,Xt.jsx)(Kg,{className:"h-3 w-3 mr-1"}),"Refresh preview"]})]})]}),(0,Xt.jsxs)("footer",{"data-testid":"workspace-section-footer",className:"sticky bottom-0 z-10 -mx-3 sm:-mx-4 px-3 sm:px-4 py-3 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] flex flex-col xs:flex-row xs:flex-wrap xs:items-center xs:justify-between gap-2 border-t border-border/60 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:[(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:x,"data-testid":"workspace-section-back-button",className:"w-full xs:w-auto px-2 sm:px-3",children:[(0,Xt.jsx)(Zg,{className:"mr-1 sm:mr-1.5 h-3.5 w-3.5"}),(0,Xt.jsx)("span",{className:"hidden sm:inline",children:"Back to Cover Letter"}),(0,Xt.jsx)("span",{className:"sm:hidden",children:"Back"})]}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:()=>{null!==R&&void 0!==R&&R.interview_prep_id?Z({force:!1}):ae({userInitiated:!0})},disabled:T||N||!E||O.active||g||"dispatching"===B||"polling"===B||"stabilizing"===B||"ready"!==y,"data-controller-status":B,"data-testid":"workspace-fit-analyse-button","data-cooldown-active":O.active?"1":"0","data-cooldown-remaining-ms":O.active?String(O.remainingMs):"",title:O.active?"Generate is on cooldown for ".concat(O.label,". This prevents accidental re-clicks while your wallet syncs."):void 0,className:"w-full xs:w-auto xs:flex-1 xs:min-w-0 sm:flex-none px-2 sm:px-3",children:[T?(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin shrink-0"}):(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5 shrink-0"}),(()=>{const e=O.active?"Run again in ".concat(O.label):le,t=O.active?"Wait":"string"===typeof le&&le.startsWith("Re")?"Regen":"Generate";return(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("span",{className:"hidden xs:inline truncate","aria-hidden":"true",children:e}),(0,Xt.jsx)("span",{className:"xs:hidden truncate","aria-hidden":"true",children:t}),(0,Xt.jsx)("span",{className:"sr-only",children:e})]})})()]}),(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:f,disabled:ce,"data-testid":"workspace-section-continue-button",className:"w-full xs:w-auto px-2 sm:px-3",children:["Continue",(0,Xt.jsx)(zy,{className:"ml-1 sm:ml-1.5 h-3.5 w-3.5"})]})]}),N&&!T&&(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-fit-credits-loading-hint",children:"Loading your wallet\u2026"})]})}const NE=wn("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);function _E(e,t,n){return e&&t&&n?"variantFitGuard:".concat(e,":").concat(t,":").concat(n):null}function DE(e){let{userId:t,jobId:n,variantId:a}=e;const r=_E(t,n,a);if(!r)return null;try{const e=sessionStorage.getItem(r);if(!e)return null;const t=JSON.parse(e),n=Number(null===t||void 0===t?void 0:t.cachedAt)||0;if(!n)return null;if(Date.now()-n>=18e5)return null;const a=null===t||void 0===t?void 0:t.payload;return a&&"object"===typeof a?a:null}catch(s){return null}}function CE(e){let{job:t,jobId:n,primaryCv:a,onContinue:r,onBack:i,onBusyChange:o,workspaceBusy:l=!1,rootTestId:c="workspace-pack-section"}=e;const d=ke(),u=If(),m=null===u||void 0===u?void 0:u.usageCosts,p=!u||!!u.loading,h=Nf(m,"application_pack"),f=h,x=null==h?null:0===h?"Included":"".concat(h," ").concat(1===h?"Credit":"Credits"),[v]=Pt(),g=v.get("source_cv_type")||"base_cv",y=v.get("source_cv_id")||(null===a||void 0===a?void 0:a.id)||null,b="cv_variant"===g?y:null,w=v.get("
2cover_letter_id")||null,j="cv_variant"===g?"cv_variant":"uploaded_cv",k=v.get("analyse_fit_id")||null,N=v.get("analyse_fit_source_type")||null,_=v.get("analyse_fit_source_id")||null,D=!(!k||N!==j||_!==y),C=(0,s.useMemo)(()=>"cv_variant"!==j?null:null!==a&&void 0!==a&&a.user_id&&n&&y?DE({userId:a.user_id,jobId:n,variantId:y}):null,[j,null===a||void 0===a?void 0:a.user_id,n,y]),[A,S]=(0,s.useState)(null),[E,F]=(0,s.useState)(null),[R,I]=(0,s.useState)(!0);(0,s.useEffect)(()=>{if(!n||null===a||void 0===a||!a.user_id||!y)return;let e=!1;return I(!0),(async()=>{try{const[a,r]=await Promise.allSettled([(0,zt.n)("/api/jobs/".concat(n,"/best-fit")),(0,zt.n)("/api/jobs/".concat(n,"/baseline-fit"))]);if(e)return;if("fulfilled"===a.status){var t;const e=(Array.isArray(null===(t=a.value)||void 0===t?void 0:t.all_cached)?a.value.all_cached:[]).find(e=>(null===e||void 0===e?void 0:e.source_type)===j&&(null===e||void 0===e?void 0:e.source_id)===y);S(e||null)}"fulfilled"===r.status&&F(r.value||null)}catch(a){}finally{I(!1)}})(),()=>{e=!0}},[n,null===a||void 0===a?void 0:a.user_id,y,j]);
2const[T,P]=(0,s.useState)(!1),[O,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!n)return;B(null),P(!1);let e=!1;return(async()=>{try{const t=await(0,zt.n)("/api/application-packs?job_id=".concat(encodeURIComponent(n),"&page_size=1"));if(e)return;const a=(Array.isArray(null===t||void 0===t?void 0:t.items)?t.items:Array.isArray(t)?t:[]).find(e=>(null===e||void 0===e?void 0:e.pack_status)&&"archived"!==e.pack_status);B(a||null)}catch(t){}finally{e||P(!0)}})(),()=>{e=!0}},[n]);const L=n?"workspace:createdPack:".concat(n):null,[M,z]=(0,s.useState)(()=>{if("undefined"===typeof window||!L)return null;try{const e=window.sessionStorage.getItem(L);if(!e)return null;const t=JSON.parse(e);return t&&"object"===typeof t&&t.id?t:null}catch(e){return null}});(0,s.useEffect)(()=>{if("undefined"!==typeof window&&L)try{const e=window.sessionStorage.getItem(L),t=e?JSON.parse(e):null;z(t&&"object"===typeof t&&t.id?t:null)}catch(e){z(null)}else z(null)},[L]),(0,s.useEffect)(()=>{if("undefined"!==typeof window&&L)try{if(M&&M.id){const e={id:M.id,created_at:M.created_at,billing:M.billing};window.sessionStorage.setItem(L,JSON.stringify(e))}}catch(e){}},[M,L]),(0,s.useEffect)(()=>{if(L&&T&&M&&M.id&&(null===O||void 0===O?void 0:O.id)!==M.id){z(null);try{"undefined"!==typeof window&&window.sessionStorage.removeItem(L)}catch(e){}}},[O,T,M,L]);const[U,V]=(0,s.useState)(!1);(0,s.useEffect)(()=>{null===o||void 0===o||o(U)},[U,o]);const[q,W]=(0,s.useState)({row:null,status:"absent",errorCode:null,payload:null}),H="complete"===q.status,G=H;(0,s.useEffect)(()=>{if(!n||null===a||void 0===a||!a.user_id||!y)return;let e=!1;const t=new URLSearchParams({document_type:"interview_prep",job_id:n,limit:"5"});"cv_variant"===j?t.set("cv_variant_id",y):t.set("base_cv_id",y);const r=v.get("interview_prep_id");return(async()=>{try{var a;let l=null;try{l=await(0,zt.n)("/api/application-documents?".concat(t.toString()))}catch(i){l=null}if(e)return;let c=null;if(Array.isArray(l)&&l.length)c=l.find(e=>"complete"===(null===e||void 0===e?void 0:e.run_status))||l.find(e=>"running"===(null===e||void 0===e?void 0:e.run_status))||l.find(e=>"queued"===(null===e||void 0===e?void 0:e.run_status))||l.find(e=>"failed"===(null===e||void 0===e?void 0:e.run_status))||l[0]||null;else if(r)try{const e=await(0,zt.n)("/api/interview-prep/".concat(r),{headers:{"X-Envelope":"rc_1_52_canonical"}});var s;if(e&&(e.status||e.run_status))c={id:e.run_id||r,run_status:(e.status||"").toLowerCase()||e.run_status,run_error_code:e.error_code||null,run_error_detail:e.error_detail||null,content_json:{job_id:n,interview_prep:(null===(s=e.result)||void 0===s?void 0:s.interview_prep)||(null===e||void 0===e?void 0:e.interview_prep)||null},created_at:e.created_at||null}}catch(o){}if(e)return;if(!c)return void W({row:null,status:"absent",errorCode:null,payload:null});const d=(c.run_status||"").toLowerCase()||"absent",u="complete"===d&&(null===(a=c.content_json)||void 0===a?void 0:a.interview_prep)||null;W({row:c,status:d,errorCode:c.run_error_code||null,payload:u})}catch(l){e||W({row:null,status:"absent",errorCode:null,payload:null})}})(),()=>{e=!0}},[n,null===a||void 0===a?void 0:a.user_id,y,j,v]);const K=async()=>{var e,t,r,s,i,o,l,c,h;if(null===a||void 0===a||!a.id)return void fy.error("No Source CV. Upload one in Documents \u2192 CVs.");if(!((e,t)=>{if(p)return!1;const n=Nf(m,e);if(null==n||0===n)return!0;const a=Number((null===u||void 0===u?void 0:u.includedUsageRemaining)||0)+Number((null===u||void 0===u?void 0:u.extraUsageRemaining)||0);return a>=n||(fy.error("Not enough Credits for ".concat(t),{description:"".concat(a," available \xb7 ").concat(n," needed. Open Plan to add Credits."),action:{label:"View plan",onClick:()=>{try{window.location.assign("/account?tab=plan")}catch(e){}}}}),!1)})("application_pack","Create application pack"))return;let f=null;D?f=k:null!==A&&void 0!==A&&A.score_id?f=A.score_id:"uploaded_cv"===j&&y&&null!==E&&void 0!==E&&null!==(e=E.baseline)&&void 0!==e&&e.score_id&&(null===E||void 0===E||null===(t=E.primary_cv)||void 0===t?void 0:t.id)===a.id&&(f=E.baseline.score_id);let x=null;var v,g,N,_,S,F,R,I;if(A)x={score_id:A.score_id,fit_score:A.fit_score,source_type:A.source_type,source_id:A.source_id,reasoning_json:null!==(v=A.reasoning_json)&&void 0!==v?v:null,salary_score:null!==(g=A.salary_score)&&void 0!==g?g:null,seniority_score:null!==(N=A.seniority_score)&&void 0!==N?N:null,location_score:null!==(_=A.location_score)&&void 0!==_?_:null,strategic_score:null!==(S=A.strategic_score)&&void 0!==S?S:null,risk_score:null!==(F=A.risk_score)&&void 0!==F?F:null,final_decision:null!==(R=A.final_decision)&&void 0!==R?R:null,scored_with_letter:null!==(I=A.scored_with_letter)&&void 0!==I?I:null};else if("cv_variant"===j&&C){const e=DE({userId:a.user_id,jobId:n,variantId:y});e&&(x=function(e){var t,n,a,r,s,i,o,l,c,d,u,m,p,h;const f=null===e||void 0===e?void 0:e.score;return f?{score_id:null!==(t=f.id)&&void 0!==t?t:null,fit_score:null!==(n=f.fit_score)&&void 0!==n?n:null,final_decision:null!==(a=f.final_decision)&&void 0!==a?a:null,salary_score:null!==(r=f.salary_score)&&void 0!==r?r:null,seniority_score:null!==(s=f.seniority_score)&&void 0!==s?s:null,location_score:null!==(i=f.location_score)&&void 0!==i?i:null,
2strategic_score:null!==(o=f.strategic_score)&&void 0!==o?o:null,risk_score:null!==(l=f.risk_score)&&void 0!==l?l:null,evaluated_at:null!==(c=null!==(d=f.evaluated_at)&&void 0!==d?d:f.created_at)&&void 0!==c?c:null,reasoning_json:null!==(u=null!==(m=f.reasoning_json)&&void 0!==m?m:null===e||void 0===e?void 0:e.analysis)&&void 0!==u?u:{},source_type:"cv_variant",source_id:null!==(p=null===e||void 0===e||null===(h=e.billing)||void 0===h?void 0:h.source_id)&&void 0!==p?p:null}:null}(e))}const T=null!==E&&void 0!==E&&null!==(r=E.baseline)&&void 0!==r&&r.score_id&&(null===E||void 0===E||null===(s=E.primary_cv)||void 0===s?void 0:s.id)===a.id?E.baseline:null,O=q.payload||null,L={binding:{cv_variant_id:b,cover_letter_id:w,analyse_fit_id:f},fit:x,cv_verdict:null!==(i=null!==(o=null===A||void 0===A||null===(l=A.reasoning_json)||void 0===l?void 0:l.cv_sub_score)&&void 0!==o?o:null===(c=x)||void 0===c||null===(h=c.reasoning_json)||void 0===h?void 0:h.cv_sub_score)&&void 0!==i?i:null,source_baseline:T,interview_prep:O};V(!0);try{const e={job_id:n,base_cv_id:a.id,cv_variant_id:b,cover_letter_id:w,analyse_fit_id:f,pack_status:"draft",pack_name:DN(),notes:null,pack_snapshot:L},t=await(0,zt.n)("/api/application-packs",{method:"POST",body:e});if(z(t),B(t),P(!0),nw(["applications","application-packs:all","jobs","dashboard:bundle"]),fy.success("Application pack created."),"function"===typeof(null===u||void 0===u?void 0:u.refresh))try{u.refresh()}catch(G){}}catch(pK){var M,U,W,H;const t=(null===pK||void 0===pK?void 0:pK.status)||(null===pK||void 0===pK||null===(M=pK.response)||void 0===M?void 0:M.status),n=null===pK||void 0===pK||null===(U=pK.data)||void 0===U?void 0:U.detail;if(409===t&&n&&"object"===typeof n&&"duplicate_active_pack"===n.error&&n.existing_pack_id)return B({id:n.existing_pack_id,pack_status:n.existing_pack_status,pack_name:n.existing_pack_name,created_at:n.existing_pack_created_at}),void fy.info(n.message||"You already have an active pack for this job.",{action:{label:"View in Applications",onClick:()=>d("/applications?highlight=".concat(encodeURIComponent(n.existing_pack_id)))}});if(Gw(pK,{action:"Create application pack",refreshCredits:null===u||void 0===u?void 0:u.refresh}))return;fy.error((null===pK||void 0===pK||null===(W=pK.data)||void 0===W||null===(H=W.detail)||void 0===H?void 0:H.message)||(null===pK||void 0===pK?void 0:pK.message)||"Failed to create pack.")}finally{V(!1)}},Y="cv_variant"===g,J=!!(Y||w||H),$=U||R||p||!(null!==a&&void 0!==a&&a.id)||!!M||!J||l;return(0,Xt.jsxs)("div",{"data-testid":c,className:"flex flex-col gap-5 min-w-0 max-w-full",children:[(0,Xt.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,Xt.jsx)("h2",{className:"text-lg font-semibold text-ndor-ink",children:"Application Pack"}),null!=x&&(0,Xt.jsx)(Vw,{className:"text-[10px] uppercase tracking-[0.14em] bg-ndor-gold/15 text-ndor-gold border-0","data-testid":"workspace-pack-price-label",children:x})]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted","data-testid":"workspace-pack-tagline",children:["Bundles your tailored CV ",w?"+ cover letter ":"","+ interview prep into one Application Pack you can share."," ",(0,Xt.jsx)("span",{className:"text-ndor-ink-muted/80",children:"All three documents stay saved in Documents, so a Pack can be reassembled later from there if needed."})]})]}),R&&(0,Xt.jsxs)("div",{"data-testid":"workspace-pack-restoring-banner",className:"rounded-md border border-border/50 bg-background/60 p-2.5 flex items-center gap-2 text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin shrink-0","aria-hidden":!0}),(0,Xt.jsx)("span",{children:"Restoring your application pack state\u2026"})]}),(0,Xt.jsxs)("div",{"data-testid":"workspace-pack-summary-card",className:"rounded-lg border border-ndor-line p-3 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(NE,{className:"h-4 w-4 text-ndor-ink-muted shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"Pack will bundle:"})]}),J?(0,Xt.jsxs)("ul",{className:"text-[12px] text-ndor-ink-muted leading-relaxed space-y-1 pl-5 list-disc",children:[Y?(0,Xt.jsx)("li",{"data-testid":"workspace-pack-summary-tailored-cv",children:"Tailored CV \u2014 included"}):(0,Xt.jsx)("li",{"data-testid":"workspace-pack-summary-source-cv",children:"Source CV used \u2014 not exported"}),(0,Xt.jsxs)("li",{"data-testid":"workspace-pack-summary-letter",children:["Cover Letter \u2014 ",w?"included":"skipped"]}),(0,Xt.jsxs)("li",{"data-testid":"workspace-pack-summary-fit",children:["Interview Prep \u2014 ",H?"included":"skipped"]})]}):(0,Xt.jsx)("p",{"data-testid":"workspace-pack-summary-empty",className:"text-[12px] text-ndor-ink-muted leading-relaxed",children:"No generated artefacts yet \u2014 generate at least one artefact (Tailored CV, Cover Letter, or Interview Prep) to create a pack."})]}
2),!G&&!R&&(0,Xt.jsxs)("div",{"data-testid":"workspace-pack-interview-locked",className:"rounded-lg border border-ndor-line bg-ndor-bg-subtle p-3 space-y-2",children:[(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink flex items-center gap-1.5","data-testid":"workspace-pack-interview-locked-copy",children:[(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5 text-ndor-gold shrink-0"}),"Interview Pack unavailable until Interview Prep is generated for this application workflow."]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed",children:"Optional \u2014 your pack will still be created. Generate Interview Prep on the previous step to unlock gap-aware interview questions, repositioning advice, and risk briefings tailored to this role."})]}),O&&!M&&O.id!==(null===M||void 0===M?void 0:M.id)&&(0,Xt.jsxs)("div",{"data-testid":"workspace-pack-existing-notice",className:"rounded-lg border border-ndor-line bg-ndor-bg-subtle p-3 space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(zf,{className:"h-4 w-4 text-ndor-ink-muted shrink-0"}),(0,Xt.jsx)("p",{className:"text-xs font-medium text-ndor-ink-muted","data-testid":"workspace-pack-existing-notice-label",children:"Most recent previously generated pack"})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed pl-6","data-testid":"workspace-pack-existing-notice-name",children:O.pack_name||"An earlier pack exists for this job."}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted/80 leading-relaxed pl-6","data-testid":"workspace-pack-existing-notice-hint",children:"Historical context only \u2014 not the current session's pack. Open it from the Applications page if you need to review it."})]}),M&&(0,Xt.jsxs)("div",{"data-testid":"workspace-pack-created-card",className:"rounded-lg border-2 border-ndor-success/40 bg-ndor-success/[0.05] p-3 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(Og,{className:"h-4 w-4 text-ndor-success shrink-0"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate",children:"Pack created."})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed",children:"Saved to Applications. The pack is highlighted there \u2014 you can review, export, or share it from the Applications list."}),((e,t)=>{const n=null!==(e=null===M||void 0===M||null===(t=M.billing)||void 0===t?void 0:t.usage_consumed)&&void 0!==e?e:null===M||void 0===M?void 0:M.usage_consumed;var a;return null!=n?(0,Xt.jsxs)("p",{className:"text-[11px] "+(n>0?"text-ndor-warning":"text-ndor-ink-muted"),"data-testid":"workspace-pack-billing-line",children:["Charged"," ",(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums","data-testid":"workspace-pack-billing-usage-consumed",children:n})," ","credit",1===n?"":"s",(null===M||void 0===M||null===(a=M.billing)||void 0===a?void 0:a.plan_code)&&(0,Xt.jsxs)("span",{className:"ml-1 text-ndor-ink-muted",children:["\xb7 plan"," ",(0,Xt.jsx)("span",{className:"font-mono-ui","data-testid":"workspace-pack-billing-plan-code",children:M.billing.plan_code})]})]}):0===f?(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-pack-billing-included",children:"Included \xb7 0 Credits charged."}):(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-pack-billing-unavailable",children:["Billing details \u2014 ",(0,Xt.jsx)("span",{"aria-hidden":!0,children:"\u2014"})," ",(0,Xt.jsx)("span",{className:"sr-only",children:"not available for this saved pack."})]})})()]}),(0,Xt.jsxs)("footer",{"data-testid":"workspace-section-footer",className:"sticky bottom-0 z-10 -mx-3 sm:-mx-4 px-3 sm:px-4 py-3 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] flex flex-col xs:flex-row xs:flex-wrap xs:items-center xs:justify-between gap-2 border-t border-border/60 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:[!M&&(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:i,"data-testid":"workspace-section-back-button",className:"w-full xs:w-auto px-2 sm:px-3",children:[(0,Xt.jsx)(Zg,{className:"mr-1 sm:mr-1.5 h-3.5 w-3.5"}),(0,Xt.jsx)("span",{className:"hidden sm:inline",children:"Back to Interview Prep"}),(0,Xt.jsx)("span",{className:"sm:hidden",children:"Back"})]}),(()=>{const e=(null===M||void 0===M?void 0:M.id)||null;return e?(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:()=>d("/applications?highlight=".concat(encodeURIComponent(e))),"data-testid":"workspace-pack-create-button",className:"w-full xs:w-auto xs:flex-1 xs:min-w-0 sm:flex-none px-2 sm:px-3",children:[(0,Xt.jsx)("span",{className:"hidden xs:inline truncate",children:"Open Application Pack"}),(0,Xt.jsx)("span",{className:"xs:hidden truncate",children:"Open Pack"}),(0,Xt.jsx)(zy,{className:"ml-1 sm:ml-1.5 h-3.5 w-3.5 shrink-0"})]}):(0,Xt.jsxs)(Rr,{variant:"default",size:"sm",onClick:K,disabled:$,"data-testid":"workspace-pack-create-button",className:"w-full xs:w-auto xs:flex-1 xs:min-w-0 sm:flex-none px-2 sm:px-3",children:[U?(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin shrink-0"}):(0,Xt.jsx)(Kn,{className:"mr-1.5 h-3.5 w-3.5 shrink-0"}),(0,Xt.jsx)("span",{className:"hidden xs:inline truncate",children:"Create Application Pack"}),(0,Xt.jsx)("span",{className:"xs:hidden truncate",children:"Create Pack"})]})})()]}),!M&&"running"===q.status&&(0,Xt.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-200","data-testid":"workspace-pack-interview-prep-running-banner",children:[(0,Xt.jsx)("span",{className:"font-semibold",children:"Interview Prep is still generating."})," ","If you create the pack now, it will be assembled without the Interview Intelligence PDF + Cover Sheet. Wait for generation to complete, or proceed if you don't need them."]}),!M&&"queued"===q.status&&(0,Xt.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-200","data-testid":"workspace-pack-interview-prep-queued-banner",children:[(0,Xt.jsx)("span",{className:"font-semibold",children:"Interview Prep is queued."})," ","The pack will be created without it if you proceed now."]}),!M&&"failed"===q.status&&(0,Xt.jsxs)("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-rose-200","data-testid":"workspace-pack-interview-prep-failed-banner",children:[(0,Xt.jsx)("span",{className:"font-semibold",children:"Interview Prep generation failed"})," ",q.errorCode?"(".concat(q.errorCode,"). "):". ","The pack will be created without it. You can retry Interview Prep separately and create a fresh pack afterwards."]}),p&&!U&&(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"workspace-pack-credits-loading-hint",children:"Loading your wallet\u2026"})]})}const AE=Object.freeze({cv:!1,coverLetter:!1,interviewPrep:!1}),SE=Object.freeze({cvVariantId:null,coverLetterId:null,interviewPrepId:null});function EE(){let{jobId:e,userId:t,sourceCvId:n=null,sourceCvType:a=null,primaryCvId:r=null,fromPack:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};
2const[o,l]=(0,s.useState)("idle"),[c,d]=(0,s.useState)(AE),[u,m]=(0,s.useState)(SE),[p,h]=Pt(),f=(0,s.useRef)(h);(0,s.useEffect)(()=>{f.current=h},[h]);const x=(0,s.useRef)(p);return(0,s.useEffect)(()=>{x.current=p},[p]),(0,s.useEffect)(()=>{if(!e||!t)return l("idle"),d(AE),void m(SE);let s=!1;l("checking");const o=a||(r?"base_cv":null),c=n||(a?null:r),u=(()=>{const e=new URLSearchParams;return e.set("latest","true"),"cv_variant"===o&&c?e.set("cv_variant_id",c):"base_cv"===o&&c&&e.set("base_cv_id",c),e.toString()})(),p=(()=>{const e=new URLSearchParams;return e.set("latest","true"),"base_cv"===o&&c&&e.set("base_cv_id",c),e.toString()})();return(async(t,n,a,r)=>{const[o,c,h]=await Promise.allSettled([(0,zt.n)("/api/cv-variants/by-job/".concat(encodeURIComponent(e),"?").concat(p)),(0,zt.n)("/api/cover-letters/by-job/".concat(encodeURIComponent(e),"?").concat(u)),(0,zt.n)("/api/interview-prep/by-job/".concat(encodeURIComponent(e),"?").concat(u))]);if(s)return;const v="fulfilled"===o.status&&!0===(null===(t=o.value)||void 0===t?void 0:t.found)?o.value:null,g="fulfilled"===c.status&&!0===(null===(n=c.value)||void 0===n?void 0:n.found)?c.value:null,y="fulfilled"===h.status&&!0===(null===(a=h.value)||void 0===a?void 0:a.found)?h.value:null,b=(null===v||void 0===v?void 0:v.cv_variant_id)||null,w=(null===g||void 0===g?void 0:g.cover_letter_id)||null,j=(null===y||void 0===y?void 0:y.interview_prep_id)||(null===y||void 0===y||null===(r=y.result)||void 0===r?void 0:r.interview_prep_id)||null;try{const e=new URLSearchParams(x.current);let t=!1;i||(b&&e.get("last_variant_id")!==b&&(e.set("last_variant_id",b),t=!0),w&&e.get("cover_letter_id")!==w&&(e.set("cover_letter_id",w),t=!0),j&&e.get("interview_prep_id")!==j&&(e.set("interview_prep_id",j),t=!0)),t&&"function"===typeof f.current&&f.current(e,{replace:!0})}catch(mK){console.warn("[useWorkspaceArtefactDiscovery] URL stamp skipped:",(null===mK||void 0===mK?void 0:mK.message)||mK)}d({cv:!!v,coverLetter:!!g,interviewPrep:!!y}),m({cvVariantId:b,coverLetterId:w,interviewPrepId:j}),l("ready")})(),()=>{s=!0}},[e,t,n,a,r,i]),{lookupStatus:o,loadedFromHistory:c,resultMeta:u}}function FE(){const e=ke(),{jobId:t}
2=_e(),[n,a]=Pt(),{user:r}=tn(),i=n.get("section"),o="fit"===i?"interview":i,l=cA.includes(o)?o:"cv";(0,s.useEffect)(()=>{if(i!==l){const e=new URLSearchParams(n);e.set("section",l),a(e,{replace:!0})}},[l]);const[d,u]=(0,s.useState)(null),[m,p]=(0,s.useState)(null),[h,f]=(0,s.useState)(!0),[x,v]=(0,s.useState)(null);(0,s.useEffect)(()=>{let n=!1;return f(!0),v(null),(async()=>{try{const[r,s]=await Promise.allSettled([(0,zt.n)("/api/jobs/".concat(t)),(0,zt.n)("/api/profile/me")]);if(n)return;if("rejected"===r.status){const t=r.reason,n=null===t||void 0===t?void 0:t.status;return 404===n||403===n?void e("/jobs",{replace:!0}):void v((null===t||void 0===t?void 0:t.message)||"Failed to load job.")}var a;if(u(r.value||null),"fulfilled"===s.status)p((null===(a=s.value)||void 0===a?void 0:a.primary_cv)||null)}catch(pK){n||v((null===pK||void 0===pK?void 0:pK.message)||"Network error.")}finally{n||f(!1)}})(),()=>{n=!0}},[t,e]);const g=(0,s.useMemo)(()=>m&&null!==r&&void 0!==r&&r.id?(0,c.A)((0,c.A)({},m),{},{user_id:r.id}):m,[m,null===r||void 0===r?void 0:r.id]),[y,b]=(0,s.useState)({}),w=(0,s.useCallback)(e=>b(t=>(0,c.A)((0,c.A)({},t),{},{cv_variant:!!e})),[]),j=(0,s.useCallback)(e=>b(t=>(0,c.A)((0,c.A)({},t),{},{cover_letter:!!e})),[]),k=(0,s.useCallback)(e=>b(t=>(0,c.A)((0,c.A)({},t),{},{interview_prep:!!e})),[]),N=(0,s.useCallback)(e=>b(t=>(0,c.A)((0,c.A)({},t),{},{application_pack:!!e})),[]),{isAnyRunning:_}=IS(t,"cv_variant"),D=(0,s.useMemo)(()=>_||Object.values(y).some(Boolean),[_,y]),C=n.get("source_cv_id"),A=n.get("source_cv_type"),S=null!==n.get("from_pack"),{lookupStatus:E,loadedFromHistory:F}=EE({jobId:t,userId:null===g||void 0===g?void 0:g.user_id,sourceCvId:C,sourceCvType:A,primaryCvId:null===g||void 0===g?void 0:g.id,fromPack:S}),[R,I]=(0,s.useState)(null),[T,P]=(0,s.useState)(null),O=(0,s.useCallback)(function(e){I({to:e,popstate:arguments.length>1&&void 0!==arguments[1]&&arguments[1]}),P(D?"busy":"idle")},[D]),B=(0,s.useCallback)(()=>{I(null),P(null)},[]),L=(0,s.useCallback)(()=>{const t=R;I(null),P(null),t&&(t.popstate?window.history.back():t.to&&e(t.to))},[R,e]),M=null!==R;(0,s.useEffect)(()=>{const e="/applications/workspace/".concat(t),n=t=>{if(t.defaultPrevented)return;if(0!==t.button)return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;const n=t.target.closest&&t.target.closest("a[href]");if(!n)return;const a=n.getAttribute("href");if(!a)return;if(/^(https?:|mailto:|tel:|#)/.test(a))return;const[r]=a.split("?");r!==e&&r!==window.location.pathname&&(t.preventDefault(),t.stopPropagation(),O(a))};return document.addEventListener("click",n,!0),()=>document.removeEventListener("click",n,!0)},[t,O]),(0,s.useEffect)(()=>{window.history.pushState(null,"",window.location.href);const e=()=>{null===R&&(window.history.pushState(null,"",window.location.href),O(null,!0))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[R,O]),(0,s.useEffect)(()=>{if(!D)return;const e=e=>(e.preventDefault(),e.returnValue="","");return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[D]);const[z,U]=(0,s.useState)(()=>{const e=cA.indexOf(l);return e<0?0:e});(0,s.useEffect)(()=>{const e=cA.indexOf(l);e>z&&U(e)},[l]);const V=()=>{const e=cA.indexOf(l);if(e<0||e>=cA.length-1)return;const t=e+1;t>z&&U(t);const r=cA[t],s=new URLSearchParams(n);s.set("section",r),a(s,{replace:!1})},q=()=>{const e=cA.indexOf(l);if(e<=0)return;const t=cA[e-1],r=new URLSearchParams(n);r.set("section",t),a(r,{replace:!1})};return h?(0,Xt.jsx)("div",{"data-testid":"workspace-loading",className:"flex h-[60vh] items-center justify-center",children:(0,Xt.jsx)(Lg,{className:"h-6 w-6 animate-spin text-ndor-ink-muted"})}):x?(0,Xt.jsxs)("div",{"data-testid":"workspace-error",className:"mx-auto flex max-w-md flex-col items-center gap-3 py-16 text-center",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:x}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:()=>e("/jobs"),"data-testid":"workspace-error-back",children:[(0,Xt.jsx)(Zg,{className:"mr-1.5 h-3.5 w-3.5"}),"Back to Jobs"]})]}):(0,Xt.jsxs)("div",{"data-testid":"application-workspace-page",className:"mx-auto flex max-w-4xl flex-col gap-6 px-2 sm:px-4 py-6 min-w-0 max-w-full sm:max-w-4xl overflow-x-clip",children:[(0,Xt.jsxs)("div",{"data-testid":"workspace-sticky-header",className:"sticky top-0 z-20 -mx-4 px-4 pt-2 pb-3 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 border-b border-border/60 flex flex-col gap-3",children:[(0,Xt.jsxs)("header",{className:"flex flex-col gap-1.5 min-w-0",children:[(0,Xt.jsxs)("button",{type:"button",onClick:()=>O("/jobs/".concat(t)),className:"inline-flex w-full max-w-full items-center gap-1 text-xs text-ndor-ink-muted hover:text-ndor-ink min-w-0","data-testid":"workspace-back-to-job",children:[(0,Xt.jsx)(Zg,{className:"h-3 w-3 shrink-0"}),(0,Xt.jsx)("span",{className:"block truncate min-w-0",children:(null===d||void 0===d?void 0:d.title)||"Job detail"})]}),(0,Xt.jsx)("h1",{className:"text-xl sm:text-2xl font-semibold text-ndor-ink",children:"Application workspace"}),(0,Xt.jsxs)("p",{className:"text-xs sm:text-sm text-ndor-ink-muted","data-testid":"workspace-intro-tagline",children:["A live session for tailoring your CV, drafting your cover letter, preparing for interview, and assembling an Application Pack.",(0,Xt.jsxs)("span",{className:"hidden sm:inline",children:[" ",(0,Xt.jsx)("span",{className:"text-ndor-ink-muted/70",children:"Completed documents are saved to your Documents library. Generate actions pause while a step is running \u2014 section navigation stays available."})]})]})]}),(0,Xt.jsx)(dA,{activeSlug:l,onSelect:e=>{if(!cA.includes(e))return;if(cA.indexOf(e)>z)return;const t=new URLSearchParams(n);t.set("section",e),a(t,{replace:!1})},furthestIndex:z,disabled:!1})]}),(0,Xt.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"workspace-sections-root",children:[(0,Xt.jsx)("div",{"data-section":"cv","data-testid":"workspace-section-cv","data-active":"cv"===l?"true":"false",hidden:"cv"!==l,children:(0,Xt.jsx)(ZS,{job:d,jobId:t,primaryCv:g,onExit:()=>{O("/jobs/".concat(t))},onContinue:V,onBusyChange:w,workspaceBusy:D,lookupStatus:E,loadedFromHistory:F.cv,rootTestId:"workspace-cv-section"})}),(0,Xt.jsx)("div",{"data-section":"letter","data-testid":"workspace-section-letter","data-active":"letter"===l?"true":"false",hidden:"letter"!==l,children:(0,Xt.jsx)(dE,{job:d,jobId:t,primaryCv:g,onContinue:V,onBack:q,onBusyChange:j,workspaceBusy:D,lookupStatus:E,loadedFromHistory:F.coverLetter,rootTestId:"workspace-letter-section"})}),(0,Xt.jsx)("div",{"data-section":"interview","data-testid":"workspace-section-interview","data-active":"interview"===l?"true":"false",hidden:"interview"
2!==l,children:(0,Xt.jsx)(kE,{job:d,jobId:t,primaryCv:g,onContinue:V,onBack:q,onBusyChange:k,workspaceBusy:D,lookupStatus:E,loadedFromHistory:F.interviewPrep,rootTestId:"workspace-fit-section"})}),(0,Xt.jsx)("div",{"data-section":"pack","data-testid":"workspace-section-pack","data-active":"pack"===l?"true":"false",hidden:"pack"!==l,children:(0,Xt.jsx)(CE,{job:d,jobId:t,primaryCv:g,onContinue:V,onBack:q,onBusyChange:N,workspaceBusy:D,rootTestId:"workspace-pack-section"})})]}),(0,Xt.jsx)(rg,{open:M,onOpenChange:e=>{e||B()},children:(0,Xt.jsxs)(lg,{className:"max-w-md","data-testid":"busy"===T?"workspace-exit-warning-busy":"workspace-exit-warning-idle",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"flex items-center gap-2 text-lg font-semibold tracking-tight",children:["busy"===T&&(0,Xt.jsx)(Oy,{className:"h-5 w-5 text-ndor-warning shrink-0","aria-hidden":!0}),(0,Xt.jsx)("span",{"data-testid":"workspace-exit-warning-title",children:"busy"===T?"Generation is still in progress":"Leave this workflow?"})]}),(0,Xt.jsx)(mg,{className:"sr-only","data-testid":"workspace-exit-warning-mode",children:"busy"===T?"active-generation-warning":"idle-workspace-warning"})]}),(0,Xt.jsx)("div",{className:"space-y-3 py-1 text-sm text-ndor-ink-secondary leading-relaxed","data-testid":"workspace-exit-warning-body",children:"busy"===T?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{children:"Your document is still being generated. If you leave now, credits may still be charged because generation has already started, and the preview may not appear here immediately."}),(0,Xt.jsxs)("p",{children:["Completed documents should still be available later in"," ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Documents"}),"."]}),(0,Xt.jsx)("p",{className:"text-ndor-ink",children:"We strongly recommend waiting for this step to finish before leaving."})]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("p",{children:["You are leaving this application workflow. Documents you have already generated are saved in"," ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Documents"}
2),", but this workflow session will close and you may need to restart the application pack flow when you return."]}),(0,Xt.jsx)("p",{children:"We recommend completing the workflow before exploring other areas."})]})}),(0,Xt.jsxs)(dg,{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2",children:[(0,Xt.jsx)(Rr,{variant:"busy"===T?"outline":"ghost",onClick:L,"data-testid":"workspace-exit-warning-leave",className:"w-full sm:w-auto",children:"busy"===T?"Leave anyway":"Leave workspace"}),(0,Xt.jsx)(Rr,{variant:"default",onClick:B,"data-testid":"workspace-exit-warning-stay",className:"w-full sm:w-auto",autoFocus:!0,children:"busy"===T?"Stay until it finishes":"Stay and continue"})]})]})})]})}const RE=["name","min","max","step","orientation","disabled","minStepsBetweenThumbs","defaultValue","value","onValueChange","onValueCommit","inverted","form"],IE=["min","max","dir","inverted","onSlideStart","onSlideMove","onSlideEnd","onStepKeyDown"],TE=["min","max","inverted","onSlideStart","onSlideMove","onSlideEnd","onStepKeyDown"],PE=["__scopeSlider","onSlideStart","onSlideMove","onSlideEnd","onHomeKeyDown","onEndKeyDown","onStepKeyDown"],OE=["__scopeSlider"],BE=["__scopeSlider"],LE=["__scopeSlider","index","name"],ME=["__scopeSlider","value"];var zE=["PageUp","PageDown"],UE=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],VE={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},qE="Slider",[WE,HE,GE]=Ks(qE),[KE,YE]=js(qE,[GE]),[JE,$E]=KE(qE),XE=s.forwardRef((e,t)=>{const{name:n,min:a=0,max:r=100,step:i=1,orientation:o="horizontal",disabled:d=!1,minStepsBetweenThumbs:u=0,defaultValue:m=[a],value:p,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:x=!1,form:v}=e,g=l(e,RE),y=s.useRef(new Set),b=s.useRef(0),w="horizontal"===o?eF:tF,[j=[],k]=_s({prop:p,defaultProp:m,onChange:e=>{var t;null===(t=[...y.current][b.current])||void 0===t||t.focus(),h(e)}}),N=s.useRef(j);function _(e,t){let{commit:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{commit:!1};const s=function(e){return(String(e).split(".")[1]||"").length}(i),o=function(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}(Math.round((e-a)/i)*i+a,s),l=Hf(o,[a,r]);k(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;const a=[...e];return a[n]=t,a.sort((e,t)=>e-t)}(e,l,t);if(function(e,t){if(t>0){const n=function(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}(e);return Math.min(...n)>=t}return!0}(a,u*i)){b.current=a.indexOf(l);const t=String(a)!==String(e);return t&&n&&f(a),t?a:e}return e})}return(0,Xt.jsx)(JE,{scope:e.__scopeSlider,name:n,disabled:d,min:a,max:r,valueIndexToChangeRef:b,thumbs:y.current,values:j,orientation:o,form:v,children:(0,Xt.jsx)(WE.Provider,{scope:e.__scopeSlider,children:(0,Xt.jsx)(WE.Slot,{scope:e.__scopeSlider,children:(0,Xt.jsx)(w,(0,c.A)((0,c.A)({"aria-disabled":d,"data-disabled":d?"":void 0},g),{},{ref:t,onPointerDown:ys(g.onPointerDown,()=>{d||(N.current=j)}),min:a,max:r,inverted:x,onSlideStart:d?void 0:function(e){const t=function(e,t){if(1===e.length)return 0;const n=e.map(e=>Math.abs(e-t)),a=Math.min(...n);return n.indexOf(a)}(j,e);_(e,t)},onSlideMove:d?void 0:function(e){_(e,b.current)},onSlideEnd:d?void 0:function(){const e=N.current[b.current];j[b.current]!==e&&f(j)},onHomeKeyDown:()=>!d&&_(a,0,{commit:!0}),onEndKeyDown:()=>!d&&_(r,j.length-1,{commit:!0}),onStepKeyDown:e=>{let{event:t,direction:n}=e;if(!d){const e=zE.includes(t.key)||t.shiftKey&&UE.includes(t.key)?10:1,a=b.current;_(j[a]+i*e*n,a,{commit:!0})}}}))})})})});XE.displayName=qE;var[QE,ZE]=KE(qE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),eF=s.forwardRef((e,t)=>{const{min:n,max:a,dir:r,inverted:i,onSlideStart:o,onSlideMove:d,onSlideEnd:u,onStepKeyDown:m}=e,p=l(e,IE),[h,f]=s.useState(null),x=Xn(t,e=>f(e)),v=s.useRef(void 0),g=Qs(r),y="ltr"===g,b=y&&!i||!y&&i;function w(e){const t=v.current||h.getBoundingClientRect(),r=mF([0,t.width],b?[n,a]:[a,n]);return v.current=t,r(e-t.left)}return(0,Xt.jsx)(QE,{scope:e.__scopeSlider,startEdge:b?"left":"right",endEdge:b?"right":"left",direction:b?1:-1,size:"width",children:(0,Xt.jsx)(nF,(0,c.A)((0,c.A)({dir:g,"data-orientation":"horizontal"},p),{},{ref:x,style:(0,c.A)((0,c.A)({},p.style),{},{"--radix-slider-thumb-transform":"translateX(-50%)"}),onSlideStart:e=>{const t=w(e.clientX);null===o||void 0===o||o(t)},onSlideMove:e=>{const t=w(e.clientX);null===d||void 0===d||d(t)},onSlideEnd:()=>{v.current=void 0,null===u||void 0===u||u()},onStepKeyDown:e=>
2{const t=VE[b?"from-left":"from-right"].includes(e.key);null===m||void 0===m||m({event:e,direction:t?-1:1})}}))})}),tF=s.forwardRef((e,t)=>{const{min:n,max:a,inverted:r,onSlideStart:i,onSlideMove:o,onSlideEnd:d,onStepKeyDown:u}=e,m=l(e,TE),p=s.useRef(null),h=Xn(t,p),f=s.useRef(void 0),x=!r;function v(e){const t=f.current||p.current.getBoundingClientRect(),r=mF([0,t.height],x?[a,n]:[n,a]);return f.current=t,r(e-t.top)}return(0,Xt.jsx)(QE,{scope:e.__scopeSlider,startEdge:x?"bottom":"top",endEdge:x?"top":"bottom",size:"height",direction:x?1:-1,children:(0,Xt.jsx)(nF,(0,c.A)((0,c.A)({"data-orientation":"vertical"},m),{},{ref:h,style:(0,c.A)((0,c.A)({},m.style),{},{"--radix-slider-thumb-transform":"translateY(50%)"}),onSlideStart:e=>{const t=v(e.clientY);null===i||void 0===i||i(t)},onSlideMove:e=>{const t=v(e.clientY);null===o||void 0===o||o(t)},onSlideEnd:()=>{f.current=void 0,null===d||void 0===d||d()},onStepKeyDown:e=>{const t=VE[x?"from-bottom":"from-top"].includes(e.key);null===u||void 0===u||u({event:e,direction:t?-1:1})}}))})}),nF=s.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:a,onSlideMove:r,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:o,onStepKeyDown:d}=e,u=l(e,PE),m=$E(qE,n);return(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({},u),{},{ref:t,onKeyDown:ys(e.onKeyDown,e=>{"Home"===e.key?(i(e),e.preventDefault()):"End"===e.key?(o(e),e.preventDefault()):zE.concat(UE).includes(e.key)&&(d(e),e.preventDefault())}),onPointerDown:ys(e.onPointerDown,e=>{const t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),m.thumbs.has(t)?t.focus():a(e)}),onPointerMove:ys(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&r(e)}),onPointerUp:ys(e.onPointerUp,e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),s(e))})}))}),aF="SliderTrack",rF=s.forwardRef((e,t)=>{const{__scopeSlider:n}=e,a=l(e,OE),r=$E(aF,n);return(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation},a),{},{ref:t}))});rF.displayName=aF;var sF="SliderRange",iF=s.forwardRef((e,t)=>{const{__scopeSlider:n}=e,a=l(e,BE),r=$E(sF,n),i=ZE(sF,n),o=Xn(t,s.useRef(null)),d=r.values.length,u=r.values.map(e=>uF(e,r.min,r.max)),m=d>1?Math.min(...u):0,p=100-Math.max(...u);return(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0},a),{},{ref:o,style:(0,c.A)((0,c.A)({},e.style),{},{[i.startEdge]:m+"%",[i.endEdge]:p+"%"})}))});iF.displayName=sF;var oF="SliderThumb",lF=s.forwardRef((e,t)=>{const n=HE(e.__scopeSlider),[a,r]=s.useState(null),i=Xn(t,e=>r(e)),o=s.useMemo(()=>a?n().findIndex(e=>e.ref.current===a):-1,[n,a]);return(0,Xt.jsx)(cF,(0,c.A)((0,c.A)({},e),{},{ref:i,index:o}))}),cF=s.forwardRef((e,t)=>{const{__scopeSlider:n,index:a,name:r}=e,i=l(e,LE),o=$E(oF,n),d=ZE(oF,n),[u,m]=s.useState(null),p=Xn(t,e=>m(e)),h=!u||(o.form||!!u.closest("form")),f=jl(u),x=o.values[a],v=void 0===x?0:uF(x,o.min,o.max),g=function(e,t){return t>2?"Value ".concat(e+1," of ").concat(t):2===t?["Minimum","Maximum"][e]:void 0}(a,o.values.length),y=null===f||void 0===f?void 0:f[d.size],b=y?function(e,t,n){const a=e/2,r=mF([0,50],[0,a]);return(a-r(t)*n)*n}(y,v,d.direction):0;return s.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),(0,Xt.jsxs)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[d.startEdge]:"calc(".concat(v,"% + ").concat(b,"px)")},children:[(0,Xt.jsx)(WE.ItemSlot,{scope:e.__scopeSlider,children:(0,Xt.jsx)(Is.span,(0,c.A)((0,c.A)({role:"slider","aria-label":e["aria-label"]||g,"aria-valuemin":o.min,"aria-valuenow":x,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0},i),{},{ref:p,style:void 0===x?{display:"none"}:e.style,onFocus:ys(e.onFocus,()=>{o.valueIndexToChangeRef.current=a})}))}),h&&(0,Xt.jsx)(dF,{name:null!==r&&void 0!==r?r:o.name?o.name+(o.values.length>1?"[]":""):void 0,form:o.form,value:x},a)]})});lF.displayName=oF;var dF=s.forwardRef((e,t)=>{let{__scopeSlider:n,value:a}=e,r=l(e,ME);const i=s.useRef(null),o=Xn(i,t),d=Qf(a);return s.useEffect(()=>{const e=i.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"value").set;if(d!==a&&n){const t=new Event("input",{bubbles:!0});n.call(e,a),e.dispatchEvent(t)}},[d,a]),(0,Xt.jsx)(Is.input,(0,c.A)((0,c.A)({style:{display:"none"}},r),{},{ref:o,defaultValue:a}))});function uF(e,t,n){return Hf(100/(n-t)*(e-t),[0,100])}function mF(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const a=(t[1]-t[0])/(e[1]-e[0]);return t[0]+a*(n-e[0])}}dF.displayName="RadioBubbleInput";var pF=XE,hF=rF,fF=iF,xF=lF;const vF=["className"],gF=s.forwardRef((e,t)=>
2{let{className:n}=e,a=l(e,vF);return(0,Xt.jsxs)(pF,(0,c.A)((0,c.A)({ref:t,className:Sr("relative flex w-full touch-none select-none items-center",n)},a),{},{children:[(0,Xt.jsx)(hF,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:(0,Xt.jsx)(fF,{className:"absolute h-full bg-primary"})}),(0,Xt.jsx)(xF,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}))});function yF(e){let{open:t,onOpenChange:n,requiredUsage:a,availableUsage:r,actionLabel:s="this action"}=e;const i=ke(),o=Number.isFinite(a)?a:null,l=Number.isFinite(r)?r:null,c=null!=o&&null!=l?"You need ".concat(o," ").concat(1===o?"Credit":"Credits"," to generate ").concat(s,". You currently have ").concat(l,"."):"You don\u2019t have enough Credits to generate ".concat(s,".");return(0,Xt.jsx)(rg,{open:t,onOpenChange:n,children:(0,Xt.jsxs)(lg,{className:"sm:max-w-[460px]","data-testid":"insufficient-usage-modal","data-required-usage":null!==o&&void 0!==o?o:"","data-available-usage":null!==l&&void 0!==l?l:"",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"insufficient-usage-modal-title",children:"Not enough Credits"}),(0,Xt.jsxs)(mg,{className:"text-sm text-ndor-ink-secondary leading-relaxed","data-testid":"insufficient-usage-modal-body",children:[c," ","Adding extra Credits continues immediately and never expires until used. Your plan\u2019s included Credits refresh on its own schedule."]})]}),(0,Xt.jsxs)(dg,{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2",children:[(0,Xt.jsxs)(Rr,{variant:"outline",onClick:()=>n(!1),"data-testid":"insufficient-usage-modal-cancel",children:[(0,Xt.jsx)(xh,{className:"h-4 w-4 mr-1.5"}),"Cancel"]}),(0,Xt.jsxs)(Rr,{onClick:()=>{n(!1),i("/account?tab=plan&addUsage=1")},"data-testid":"insufficient-usage-modal-add-usage",className:"bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground",children:[(0,Xt.jsx)(Ow,{className:"h-4 w-4 mr-1.5"}),"Add Credits"]})]})]})})}function bF(e){let{mode:t,events:n,dailyBudget:a}=e;if("assisted_review"!==t)return null;const{scored:r,queued:s}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date;const n=new Date(t);n.setHours(0,0,0,0);const a=n.getTime();let r=0,s=0;for(const i of e||[]){const e=new Date((null===i||void 0===i?void 0:i.created_at)||0).getTime();!Number.isFinite(e)||e<a||("auto_scored"===i.kind?r+=1:"queued"===i.kind&&(s+=1))}return{scored:r,queued:s}}(n),i=Number.isFinite(a)?a:10,o=0===r&&0===s;return(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-edge bg-ndor-surface-alt/40 px-4 py-3 flex items-center gap-3","data-testid":"automation-auto-discovery-chip",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold shrink-0","aria-hidden":!0}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary font-manrope leading-snug",children:o?(0,Xt.jsx)("span",{"data-testid":"automation-auto-discovery-chip-zero",children:"NDORFlow has not run Analyse Fit on any new roles yet today."}):(0,Xt.jsxs)("span",{"data-testid":"automation-auto-discovery-chip-stats",children:["NDORFlow ran Analyse Fit against your Source CV on"," ",(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-ink tabular-nums","data-testid":"automation-auto-discovery-chip-scored",children:r})," / ",(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-ink tabular-nums","data-testid":"automation-auto-discovery-chip-budget",children:i})," ","new roles today \xb7"," ",(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-gold tabular-nums","data-testid":"automation-auto-discovery-chip-queued",children:s})," ","reached your Review Queue"]})})]})}gF.displayName=pF.displayName;const wF=wn("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]),jF=wn("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),kF=wn("pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]),NF=wn("sliders-vertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]),_F={manual_review:"manual",assisted_review:"assisted",automatic:"automatic"},DF={manual:"manual_review",assisted:"assisted_review",automatic:"automatic"},CF={manual_review:"manual",assisted_review:"assist",automatic:"auto"},AF=[{key:"manual_review",label:"Manual Review",icon:zg,short:"You browse, score, and apply yourself.",long:"Browse the jobs catalogue and run Analyse Fit yourself when a role catches your eye. You decide which roles to pursue and create every application pack manually. NDORFlow provides the scoring and tooling; nothing runs in the background."},{key:"assisted_review",label:"Assisted Review",icon:Ln,short:"NDORFlow analyses fit against your Source CV in batches; you review and apply.",long:"NDORFlow runs Analyse Fit against your Source CV in the background, up to your daily budget, and lists matches that beat your fit threshold in your Review Queue. When you open one, the fit score is already done and free to view; you only pay again if you swap in a different CV before applying. You still pick the CV, generate any cover letter, assemble the pack, and submit each application yourself."},{key:"automatic",label:"Automation (Flow)",icon:Cn,short:"NDORFlow automatically pre-screens jobs and analyses the strongest matches in the background.",long:"NDORFlow automatically pre-screens jobs and fully analyses the strongest matches in the background. You can pause this at any time. No Credits are used for background analysis."}];
2function SF(e){try{return new Date(e).toLocaleString("en-GB",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"})}catch(t){return e}}function EF(e){const t=e=>(e||"").slice(0,8),n=e.payload_json||{};switch(e.kind){case"mode_changed":return(0,Xt.jsxs)(Xt.Fragment,{children:["Switched mode to ",(0,Xt.jsx)("span",{className:"text-ndor-gold font-mono-ui",children:(a=n.to,(AF.find(e=>e.key===DF[a])||{}).label||a)}),"."]});case"threshold_changed":return(0,Xt.jsxs)(Xt.Fragment,{children:["Threshold changed to ",(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-gold",children:n.to}),"."]});case"budget_changed":return(0,Xt.jsxs)(Xt.Fragment,{children:["Daily score budget set to ",(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-gold",children:n.to}),"."]});case"paused":return(0,Xt.jsx)(Xt.Fragment,{children:(0,Xt.jsx)("span",{className:"text-ndor-warning",children:"Paused."})});case"resumed":return(0,Xt.jsx)(Xt.Fragment,{children:(0,Xt.jsx)("span",{className:"text-ndor-success",children:"Resumed."})});case"queued":return(0,Xt.jsxs)(Xt.Fragment,{children:["Queued role ",(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-ink-secondary",children:t(e.job_id)})," at fit ",(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-gold",children:null!=n.queue_score?Math.round(100*Number(n.queue_score)):"\u2014"}),"."]});case"approved":return(0,Xt.jsxs)(Xt.Fragment,{children:["Approved role ",(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-ink-secondary",children:t(e.job_id)})," \u2014 pack dialog opened. No application was sent."]});case"dismissed":return(0,Xt.jsxs)(Xt.Fragment,{children:["Dismissed role ",(0,Xt.jsx)("span",{className:"font-mono-ui text-ndor-ink-secondary",children:t(e.job_id)})," from your review queue."]});case"scan_run":return(0,Xt.jsxs)(Xt.Fragment,{children:["Scan: ",(0,Xt.jsxs)("span",{className:"font-mono-ui text-ndor-ink-secondary",children:["added ",n.added||0]}),", below-threshold ",n.skipped_below_threshold||0,", terminal ",n.skipped_terminal||0,", budget-capped ",n.skipped_budget||0,"."]});default:return e.kind}var a}function FF(){var e,t,n,a,r,i,o,l;const{user:d}=tn(),u=ke(),[m,p]=(0,s.useState)("base"),[h,f]=(0,s.useState)(["manual"]),[x,v]=(0,s.useState)("manual_review"),[g,y]=(0,s.useState)(85),[b,w]=(0,s.useState)(85),[j,k]=(0,s.useState)(!1),[N,_]=(0,s.useState)(10),[D,C]=(0,s.useState)(!1),[A,S]=(0,s.useState)(!0),[E,F]=(0,s.use
2State)([]),[R,I]=(0,s.useState)([]),[T,P]=(0,s.useState)([]),[O,B]=(0,s.useState)(!1),[L,M]=(0,s.useState)(!1),[z,U]=(0,s.useState)(null),[V,q]=(0,s.useState)(!0),[W,H]=(0,s.useState)(!1),[G,K]=(0,s.useState)(null),[Y,J]=(0,s.useState)(!1),[$,X]=(0,s.useState)(!1),Q=(0,s.useCallback)(async()=>{var e,t;const n=await(0,zt.n)("/api/automation/settings"),a=DF[n.automation_mode]||"manual_review";v(a),y(null!==(e=n.automation_threshold)&&void 0!==e?e:85),w(null!==(t=n.automation_threshold)&&void 0!==t?t:85),k(!!n.automation_paused),_(Number.isFinite(n.automation_daily_score_budget)?n.automation_daily_score_budget:10),C(!!n._unmigrated)},[]),Z=(0,s.useCallback)(async()=>{H(!0);try{const e=await(0,zt.n)("/api/automation/queue");F(Array.isArray(null===e||void 0===e?void 0:e.items)?e.items:[])}finally{H(!1)}},[]),ee=(0,s.useCallback)(async()=>{const e=await(0,zt.n)("/api/automation/events?limit=50");I(Array.isArray(null===e||void 0===e?void 0:e.items)?e.items:[])},[]),te=(0,s.useCallback)(async()=>{try{var e;const t=await(0,zt.n)("/api/profile/preferences"),n=null===t||void 0===t||null===(e=t.preferences)||void 0===e?void 0:e.include_cover_letter;"boolean"===typeof n&&S(n)}catch(t){}},[]),ne=(0,s.useCallback)(async()=>{J(!0);try{const e=await(0,zt.n)("/api/automation/flow-status");K(e||null)}catch(e){K(null)}finally{J(!1)}},[]),ae=(0,s.useCallback)(async e=>{X(!0);try{await(0,zt.n)("/api/automation/settings",{method:"PATCH",body:{flow_automation_paused:!!e}}),fy.success(e?"Flow is paused \u2014 no background scoring will run.":"Flow is running \u2014 background scoring resumes."),await ne()}catch(mK){fy.error("Could not update Flow automation: ".concat((null===mK||void 0===mK?void 0:mK.message)||mK))}finally{X(!1)}},[ne]),re=(0,s.useCallback)(async()=>{try{const e=await(0,zt.n)("/api/account/plan");if(e&&"object"===typeof e){p(e.plan_code||"base");const t=Array.isArray(e.allowed_account_modes)?e.allowed_account_modes:["manual"];f(t)}}catch(e){}},[]),[se,ie]=(0,s.useState)(null),[oe,le]=(0,s.useState)(8),ce=(0,s.useCallback)(async()=>{M(!0);try{var e;const t=await(0,zt.n)("/api/automation/top-opportunities?limit=10");B(!(null===t||void 0===t||!t.enabled)),P(Array.isArray(null===t||void 0===t?void 0:t.items)?t.items:[]),null!=(null===t||void 0===t||null===(e=t.usage_costs)||void 0===e?void 0:e.application_pack)&&le(Number(t.usage_costs.application_pack)),null!=(null===t||void 0===t?void 0:t.usage_remaining)&&ie(Number(t.usage_remaining))}catch(t){B(!1),P([])}finally{M(!1)}},[]),[de,ue]=(0,s.useState)(!1),[me,pe]=(0,s.useState)(null),[he,fe]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(null===d||void 0===d||!d.id)return;let e=!0;return(async()=>{q(!0);try{await Promise.all([Q(),Z(),ee(),te(),re(),ce(),ne(),(async()=>{const{data:t}=await Mt.supabase.from("base_cvs").select("id, original_filename, is_primary").eq("user_id",d.id).eq("is_primary",!0).maybeSingle();e&&U(t||null)})()])}catch(pK){e&&fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to load workflow state.")}finally{e&&q(!1)}})(),()=>{e=!1}},[null===d||void 0===d?void 0:d.id,Q,Z,ee,te,re,ce,ne]),(0,s.useEffect)(()=>{try{localStorage.removeItem("ndor.automation.include_cover_letter")}catch(e){}},[]);const xe=(0,s.useCallback)(async e=>{try{await(0,zt.n)("/api/automation/settings",{method:"PATCH",body:e}),await Promise.all([Q(),Z(),ee()])}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to update settings.")}},[Q,Z,ee]);(0,s.useEffect)(()=>{if("undefined"===typeof window)return;if("#review-queue"!==window.location.hash)return;if(V)return;const e=setTimeout(()=>{const e=document.getElementById("review-queue");e&&e.scrollIntoView({behavior:"smooth",block:"start"})},80);return()=>clearTimeout(e)},[V]);const ve=()=>{const e=!j;k(e),xe({automation_paused:e})},ge=(ye=b)>=90?{label:"Elite only \u2014 fewer applications, higher quality.",tone:"text-ndor-gold"}:ye>=85?{label:"Selective \u2014 stronger fit, fewer applications.",tone:"text-ndor-info"}:ye>=80?{label:"Balanced \u2014 wider reach with quality control.",tone:"text-ndor-success"}
2:{label:"Broad \u2014 maximum coverage.",tone:"text-ndor-ink-secondary"};var ye;const be=AF.find(e=>e.key===x)||AF[0],we=(0,s.useMemo)(()=>{const e="base"===m,t="flow"===m;return{isBase:e,isFlow:t,controlsEnabled:!e,modeDisabled:t=>{if(e)return!0;const n=CF[t];return!(n&&h.includes(n))},lockLabel:n=>"automatic"===n?t?null:"Available on Flow":e?"Available on Focus":null,banner:e?{title:"Assisted Review is available on Focus. Automation (Flow) is available on Flow.",body:"Manual Review is enabled. Focus unlocks Assisted Review (NDORFlow analyses fit against your Source CV in the background). Flow unlocks Automation (NDORFlow automatically pre-screens jobs and fully analyses the strongest matches in the background \u2014 no Credits used). NDORFlow never auto-applies on any plan.",tone:"base"}:t?{title:"Automation (Flow) available",body:"Pick Automation (Flow) to run the background loop, Assisted Review for on-demand batches, or Manual Review for full manual control. Each card is the master switch \u2014 your selection here decides whether Flow automation runs. NDORFlow never auto-applies.",tone:"flow"}:{title:"Assisted Review is enabled",body:"NDORFlow runs Analyse Fit against your Source CV in the background, up to your daily budget, and lists matches above your threshold in your Review Queue. You still pick the CV and submit every application yourself. Automation (Flow) \u2014 automatic background analysis with no daily cap and no Credits used \u2014 is available on Flow.",tone:"focus"}}},[m,h]),je=(0,s.useMemo)(()=>(E||[]).map(e=>(0,c.A)((0,c.A)({},e),{},{fit:null!=e.queue_score?Math.round(100*Number(e.queue_score)):null})),[E]);return"base"===m?(0,Xt.jsx)("div",{"data-testid":"automation-base-locked-card",className:"space-y-6 sm:space-y-8",children:(0,Xt.jsx)("section",{className:"rounded-2xl border border-ndor-edge bg-gradient-to-br from-ndor-surface-alt/40 to-ndor-surface px-6 sm:px-10 py-10 sm:py-14",children:(0,Xt.jsxs)("div",{className:"max-w-2xl",children:[(0,Xt.jsxs)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui flex items-center gap-1.5",children:[(0,Xt.jsx)(Cn,{className:"h-3 w-3"}),"Plan \xb7 Base"]}),(0,Xt.jsx)("h1",{className:"mt-3 text-3xl sm:text-4xl font-serif-display font-semibold tracking-tight text-ndor-ink",children:"Workflow is a paid surface."}),(0,Xt.jsx)("p",{className:"mt-4 text-base text-ndor-ink-secondary leading-relaxed",children:"On Base you run Analyse Fit yourself, two free runs per day. Workflow surfaces \u2014 Assisted Review, the Review Queue and Flow's Top Opportunities \u2014 only matter once NDORFlow is doing background work for you."}),(0,Xt.jsxs)("ul",{className:"mt-6 space-y-2.5 text-sm text-ndor-ink-secondary",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2.5",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-info mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"Focus"})," unlocks"," ",(0,Xt.jsx)("strong",{children:"Assisted Review"})," \u2014 NDORFlow runs Analyse Fit against your Source CV in the background, drops matches above your threshold into the Review Queue, and never charges your Credits for the background pass."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2.5",children:[(0,Xt.jsx)(Cn,{className:"h-4 w-4 text-ndor-gold mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"Flow"})," adds"," ",(0,Xt.jsx)("strong",{children:"Automation (Flow)"})," \u2014 continuous background scoring while enabled, paused-by-default, surfaces the strongest matches in Top Opportunities. Pre-screens jobs cheaply first; only survivors reach NDOR. No Credits used for the background pass."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2.5",children:[(0,Xt.jsx)(Ln,{className:"h-4 w-4 text-ndor-ink-muted mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:["NDORFlow ",(0,Xt.jsx)("strong",{children:"never auto-applies"})," and"," ",(0,Xt.jsx)("strong",{children:"never auto-tailors"})," on any plan."]})]})]}),(0,Xt.jsxs)("div",{className:"mt-7 flex flex-col sm:flex-row gap-3",children:[(0,Xt.jsx)(Et,{to:"/account?tab=plan",children:(0,Xt.jsx)(Rr,{size:"sm",className:"w-full sm:w-auto bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground","data-testid":"automation-base-locked-upgrade",children:"See plan options"})}),(0,Xt.jsx)(Et,{to:"/how-it-works",children:(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",className:"w-full sm:w-auto border-ndor-edge bg-ndor-surface-alt hover:bg-ndor-surface text-ndor-ink","data-testid":"automation-base-locked-howitworks",children:"How it works"})}),(0,Xt.jsx)(Et,{to:"/jobs",children:(0,Xt.jsxs)(Rr,{variant:"ghost",size:"sm",className:"w-full sm:w-auto text-ndor-ink-secondary hover:text-ndor-ink","data-testid":"automation-base-locked-browse-jobs",children:["Browse jobs ",(0,Xt.jsx)(zy,{className:"h-3.5 w-3.5 ml-1.5"})]})})]})]})})}):(0,Xt.jsxs)("div",{"data-testid":"automation-page",className:"space-y-6 sm:space-y-8",children:[(0,Xt.jsx)("section",{className:"rounded-2xl border px-6 sm:px-8 py-6 sm:py-7 ".concat("flow"===we.banner.tone?"border-ndor-gold/40 bg-gradient-to-br from-ndor-gold-soft/50 to-ndor-surface-alt/20":"focus"===we.banner.tone?"border-ndor-info/30 bg-ndor-info-light/40":"border-ndor-edge bg-ndor-surface-alt/40"),"data-testid":"automation-plan-banner","data-plan-code":m,children:(0,Xt.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-5",children:[(0,Xt.jsxs)("div",{className:"max-w-3xl",children:[(0,Xt.jsxs)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui flex items-center gap-1.5","data-testid":"automation-plan-banner-eyebrow",children:[(0,Xt.jsx)(Cn,{className:"h-3 w-3"}),"Plan \xb7 ","base"===m?"Base":"focus"===m?"Focus":"Flow"]}),(0,Xt.jsx)("h2",{className:"mt-2 text-2xl sm:text-3xl font-serif-display font-semibold tracking-tight text-ndor-ink","data-testid":"automation-plan-banner-title",children:we.banner.title}),(0,Xt.jsx)("p",{className:"mt-2.5 text-sm text-ndor-ink-secondary leading-relaxed","data-testid":"automation-plan-banner-body",children:we.banner.body})]}),(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 shrink-0",children:[we.isBase&&(0,Xt.jsx)(Et,{to:"/account?tab=plan",className:"order-1",children:(0,Xt.jsx)(Rr,{size:"sm",className:"w-full sm:w-auto bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground","data-testid":"automation-plan-upgrade-cta",children:"See plan options"})}),(0,Xt.jsx)(Et,{to:"/jobs",className:"order-2",children:(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",className:"w-full sm:w-auto border-ndor-edge bg-ndor-surface-alt hover:bg-ndor-surface text-ndor-ink","data-testid":"automation-back-to-jobs",children:"Back to jobs"})})]})]})}),we.isFlow&&(null===G||void 0===G?void 0:G.flow_loop_eligible)&&(0,Xt.jsxs)(Fy,{className:"border-ndor-gold/40 bg-ndor-surface-alt/30","data-testid":"flow-loop-status-card",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 border-b border-ndor-gold/20 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(wF,{
2className:"h-4 w-4 text-ndor-gold"}),(0,Xt.jsx)(Iy,{className:"text-base font-serif-display font-semibold text-ndor-ink",children:"Automation (Flow)"}),(0,Xt.jsx)("span",{"data-testid":"flow-loop-state-badge","data-state":G.flow_automation_paused?"paused":"running",className:"ml-2 inline-flex items-center text-[10px] uppercase tracking-[0.18em] px-1.5 py-0.5 rounded border font-mono-ui ".concat(G.flow_automation_paused?"border-ndor-edge bg-ndor-surface text-ndor-ink-muted":"border-ndor-gold/40 bg-ndor-gold-soft text-ndor-gold"),children:G.flow_automation_paused?"Paused":"Running"})]}),(0,Xt.jsx)(Rr,{size:"sm",variant:G.flow_automation_paused?"default":"outline",disabled:$,onClick:()=>ae(!G.flow_automation_paused),"data-testid":"flow-loop-pause-toggle",className:G.flow_automation_paused?"bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground":"border-ndor-edge",children:$?"Saving\u2026":G.flow_automation_paused?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(jF,{className:"h-3 w-3 mr-1"})," Turn on"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(kF,{className:"h-3 w-3 mr-1"})," Pause"]})})]}),(0,Xt.jsxs)(Py,{className:"pt-4 space-y-3",children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed","data-testid":"flow-loop-credit-safety-copy",children:["NDORFlow automatically pre-screens jobs and fully analyses the strongest matches in the background. ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:"No Credits are used for background analysis"})," \u2014 it's covered by your Flow subscription. You only spend Credits when you click",(0,Xt.jsx)("em",{children:" Reanalyse"})," against a different CV before applying. NDORFlow never auto-applies. You can pause this at any time."]}),G.preferences_missing_warning&&(0,Xt.jsxs)("div",{className:"rounded-md border border-amber-300/40 bg-amber-500/10/60 px-3 py-2 text-[12px] text-amber-200 flex items-start gap-2","data-testid":"flow-loop-preferences-warning",children:[(0,Xt.jsx)(zf,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:["Add your preferred roles, locations, and industries on",(0,Xt.jsx)(Et,{to:"/profile",className:"underline mx-1",children:"your profile"}),"to sharpen ranking. Flow still runs against your CV \u2014 preferences refine the order, they don't block scoring."]})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3","data-testid":"flow-loop-today-metrics",children:[(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface px-3 py-2",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Analysed today"}),(0,Xt.jsx)("p",{className:"mt-1 text-xl font-serif-display text-ndor-ink","data-testid":"flow-loop-jobs-analysed",children:null!==(e=null===(t=G.today)||void 0===t?void 0:t.jobs_analyzed)&&void 0!==e?e:0})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface px-3 py-2",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Above threshold"}),(0,Xt.jsx)("p",{className:"mt-1 text-xl font-serif-display text-emerald-200","data-testid":"flow-loop-jobs-above-threshold",children:null!==(n=null===(a=G.today)||void 0===a?void 0:a.jobs_above_threshold)&&void 0!==n?n:0})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface px-3 py-2",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Below threshold"}),(0,Xt.jsx)("p",{className:"mt-1 text-xl font-serif-display text-ndor-ink-muted","data-testid":"flow-loop-jobs-below-threshold",children:null!==(r=null===(i=G.today)||void 0===i?void 0:i.jobs_below_threshold)&&void 0!==r?r:0})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface px-3 py-2",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Daily cap"}),(0,Xt.jsxs)("p",{className:"mt-1 text-xl font-serif-display text-ndor-ink","data-testid":"flow-loop-daily-cap",children:[(null===(o=G.today)||void 0===o?void 0:o.daily_cap)||"\u2014",null!=(null===(l=G.today)||void 0===l?void 0:l.remaining_today)&&(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-muted font-sans ml-1.5",children:["\xb7 ",G.today.remaining_today," left"]})]})]})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted font-mono-ui","data-testid":"flow-loop-helper",children:G.flow_automation_paused?"Flow is paused \u2014 no background scoring will run until you turn it on.":"Flow is running. The strongest matches surface in Top Opportunities".concat(Y?" (refreshing\u2026)":"",".")})]})]}),we.isFlow&&O&&(0,Xt.jsxs)(Fy,{className:"border-ndor-gold/40 bg-gradient-to-br from-ndor-gold-soft/40 to-ndor-surface-alt/20","data-testid":"automation-top-opportunities",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 border-b border-ndor-gold/20 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold"}),(0,Xt.jsx)(Iy,{className:"text-base font-serif-display font-semibold text-ndor-ink",children:"Top Opp
2ortunities"}),(0,Xt.jsx)("span",{className:"ml-2 inline-flex items-center text-[10px] uppercase tracking-[0.18em] px-1.5 py-0.5 rounded border border-ndor-gold/40 bg-ndor-gold-soft text-ndor-gold font-mono-ui","data-testid":"automation-top-opportunities-flow-badge",children:"Flow"})]}),(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui","data-testid":"automation-top-opportunities-count",children:L?"Refreshing\u2026":"".concat(T.length," ").concat(1===T.length?"role":"roles"," surfaced")})]}),(0,Xt.jsxs)(Py,{className:"pt-4",children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-secondary mb-3 leading-relaxed",children:["NDORFlow runs Analyse Fit against your ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:"Source CV"})," continuously across the jobs pool and surfaces the strongest matches here. Every fit listed below is already done and free to view \u2014 click any role to open the application wizard. You only pay again if you swap in a different CV before applying. NDORFlow never auto-applies."]}),(0,Xt.jsxs)("ul",{className:"mb-4 space-y-1.5 text-[11px] text-ndor-ink-muted leading-relaxed font-mono-ui","data-testid":"automation-subnotes",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"mt-1 h-1 w-1 flex-shrink-0 rounded-full bg-ndor-gold/60"}
2),(0,Xt.jsx)("span",{children:"Background Analyse Fits run under your Flow plan and do not charge user Credits. Flow background scoring is operator-absorbed. You only spend Credits when you re-analyse against a different CV before applying."})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"mt-1 h-1 w-1 flex-shrink-0 rounded-full bg-ndor-gold/60"}),(0,Xt.jsxs)("span",{children:["Automation Analyse Fits are stored as ordinary"," ",(0,Xt.jsx)("code",{className:"text-[10px]",children:"job_scores"})," rows. If you upload a new Source CV later, prior fits remain free to reopen against the older CV; new analysis against the new CV is a fresh paid action."]})]})]}),L&&0===T.length?(0,Xt.jsx)("p",{className:"py-6 text-center text-sm text-ndor-ink-muted",children:"Loading top opportunities\u2026"}):0===T.length?(0,Xt.jsxs)("div",{className:"py-6 text-center space-y-1","data-testid":"automation-top-opportunities-empty",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"No opportunities yet. The automation loop runs in the background \u2014 top matches will appear here as new roles are evaluated."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary",children:"Make sure you have a primary Source CV uploaded so analysis can run."})]}):(0,Xt.jsx)("ul",{className:"divide-y divide-ndor-edge/60",children:T.map(e=>{var t;return(0,Xt.jsxs)("li",{className:"py-3 flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-start sm:gap-4","data-testid":"automation-top-opportunity-row-".concat(e.job_id),children:[(0,Xt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Xt.jsx)(Et,{to:"/jobs/".concat(e.job_id),className:"text-base sm:text-sm font-medium text-ndor-ink hover:underline break-words sm:truncate block leading-snug","data-testid":"automation-top-opportunity-title-".concat(e.job_id),children:e.title||"Untitled role"}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted mt-0.5",children:[(0,Xt.jsx)("span",{"data-testid":"automation-top-opportunity-company-".concat(e.job_id),children:e.company||"\u2014"}),e.location?(0,Xt.jsxs)("span",{children:[" \xb7 ",e.location]}):null]}),e.summary?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary mt-1.5 line-clamp-2","data-testid":"automation-top-opportunity-summary-".concat(e.job_id),children:e.summary}):null]}),(0,Xt.jsxs)("span",{className:"self-start sm:self-auto inline-flex items-baseline gap-1 text-xs font-mono-ui px-2 py-0.5 rounded border shrink-0 ".concat(Number(null!==(t=e.fit_score)&&void 0!==t?t:0)>=90?"text-ndor-gold bg-ndor-gold-soft/40 border-ndor-gold/30":"text-ndor-info bg-ndor-info-light border-ndor-info/20"),"data-testid":"automation-top-opportunity-fit-".concat(e.job_id),children:[(0,Xt.jsx)("span",{className:"text-[9px] uppercase tracking-[0.16em] opacity-70",children:"Fit"}),(0,Xt.jsx)("span",{className:"text-sm font-semibold tabular-nums",children:null!=e.fit_score?Math.round(Number(e.fit_score)):"\u2014"})]}),(0,Xt.jsxs)("div",{className:"flex gap-2 w-full sm:w-auto",children:[(0,Xt.jsx)(Et,{to:"/jobs/".concat(e.job_id),className:"flex-1 sm:flex-none",children:(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",className:"w-full border-ndor-edge bg-ndor-surface-alt hover:bg-ndor-surface text-ndor-ink","data-testid":"automation-top-opportunity-review-".concat(e.job_id),children:"Review"})}),(0,Xt.jsxs)(Rr,{size:"sm",className:"flex-1 sm:flex-none bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground",onClick:()=>{if(null!=se&&se<oe)return pe(oe),fe(se),void ue(!0);u("/jobs/".concat(e.job_id))},"data-testid":"automation-top-opportunity-pack-".concat(e.job_id),children:["Open in wizard ",(0,Xt.jsx)(zy,{className:"h-3.5 w-3.5 ml-1"})]})]})]},e.id||e.job_id)})})]})]}),(0,Xt.jsx)("section",{className:"brand-hex-grid rounded-2xl border border-ndor-edge px-6 sm:px-8 py-7 sm:py-8 relative","data-testid":"automation-hero",children:(0,Xt.jsxs)("div",{className:"relative z-[1] flex flex-col lg:flex-row lg:items-end lg:justify-between gap-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui",children:"Operational"}),(0,Xt.jsx)("h1",{className:"mt-1 text-3xl sm:text-4xl font-serif-display font-semibold tracking-tight text-ndor-ink","data-testid":"automation-operational-title",children:"automatic"===x?"Automation (Flow)":"assisted_review"===x?"Assisted Workflow":"Manual Workflow"}),(0,Xt.jsx)("p",{className:"mt-1.5 text-sm text-ndor-ink-secondary max-w-xl",children:"automatic"===x?"NDORFlow automatically pre-screens jobs and fully analyses the strongest matches in the background. You can pause this at any time. No Credits are used for background analysis.":"assisted_review"===x?"Backgroun
2d Analyse Fit against your Source CV, batched to your daily budget. Matches above your threshold appear in your Review Queue. Background Flow automation is OFF in this mode.":"You browse, score, and apply yourself. Nothing runs in the background \u2014 Flow automation is OFF in this mode."}),(0,Xt.jsxs)("div",{className:"mt-4 flex items-center gap-2 flex-wrap",children:[(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-[0.18em] px-2 py-1 rounded-md border border-ndor-gold/40 bg-ndor-gold-soft text-ndor-gold font-mono-ui","data-testid":"automation-mode-badge",children:[(0,Xt.jsx)(be.icon,{className:"h-3 w-3"}),"Mode \xb7 ",be.label]}),(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[11px] uppercase tracking-[0.18em] px-2 py-1 rounded-md border border-ndor-edge bg-ndor-surface-alt text-ndor-ink-secondary font-mono-ui","data-testid":"automation-threshold-badge",children:["Threshold \xb7 ",g]}),j&&(0,Xt.jsx)("span",{className:"inline-flex items-center gap-1.5 text-[11px] uppercase tracking-[0.18em] px-2 py-1 rounded-md border border-ndor-warning/40 bg-ndor-warning-light text-ndor-warning font-mono-ui","data-testid":"automation-paused-badge",children:"Paused"})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(()=>{const e="assisted_review"===x||"automatic"===x,t=!we.controlsEnabled||!e;return(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:ve,disabled:t,"aria-disabled":t,"data-testid":"automation-pause-toggle","data-pause-applies":e?"true":"false",title:e?void 0:"Pause/Resume only applies to Assisted Review and Automation (Flow). Manual Review runs nothing in the background.",className:"border-ndor-edge ".concat(j?"bg-ndor-surface text-ndor-success":"bg-ndor-surface-alt text-ndor-ink"," hover:bg-ndor-surface ").concat(t?"opacity-50 cursor-not-allowed":""),children:j?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(jF,{className:"h-4 w-4 mr-1.5"})," Resume workflow"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(kF,{className:"h-4 w-4 mr-1.5"})," Pause workflow"]})})})(),(0,Xt.jsx)(Rr,{size:"sm",onClick:()=>{const e=document.getElementById("review-queue");e&&e.scrollIntoView({behavior:"smooth",block:"start"})},className:"bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground","data-testid":"automation-jump-to-queue",children:"Jump to Review Queue"})]})]})}),(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-warning/30 bg-ndor-warning-light/50 px-4 py-3 flex items-start gap-3","data-testid":"automation-status-banner",children:[(0,Xt.jsx)(zf,{className:"h-4 w-4 text-ndor-warning mt-0.5 shrink-0"}),(0,Xt.jsxs)("div",{className:"text-sm",children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium",children:"This system helps you review and act \u2014 you remain in control."}),(0,Xt.jsx)("p",{className:"text-ndor-ink-secondary text-xs mt-0.5",children:"NDOR organises and prioritises opportunities; every decision and every application stays with you. Nothing is sent on your behalf."})]})]}),D&&(0,Xt.jsx)("div",{className:"rounded-xl border border-ndor-error/30 bg-ndor-error-light/40 px-4 py-3 text-sm text-ndor-ink","data-testid":"automation-unmigrated-banner",children:"Workflow backend migrations are not yet applied on this environment. Settings and queue will return defaults until an admin applies migrations 018/019/020."}),(0,Xt.jsx)(bF,{mode:x,events:R,dailyBudget:N}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[2fr_1fr] gap-6",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"automation-mode-card",children:[(0,Xt.jsx)(Ry,{className:"pb-2 border-b border-ndor-edge",children:(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Cn,{className:"h-4 w-4 text-ndor-gold"})," Workflow Mode"]})}),(0,Xt.jsx)(Py,{className:"pt-5 grid grid-cols-1 md:grid-cols-3 gap-3",children:AF.map(e=>{const t=e.key===x,n=we.modeDisabled(e.key),a=we.lockLabel(e.key);return(0,Xt.jsxs)("button",{type:"button",onClick:()=>!n&&(e=>{if(e===x)return;if(!AF.find(t=>t.key===e))return;const t=CF[e];if(t&&!h.includes(t))return;const n=_F[e];if(!n)return;v(e),xe({automation_mode:n,flow_automation_paused:"automatic"!==e}),ne()})(e.key),disabled:n,"data-testid":"automation-mode-".concat(e.key),"data-mode-locked":n?"true":"false","aria-pressed":t,"aria-disabled":n,className:"relative text-left rounded-xl border p-4 transition-all brand-card-hover\n ".concat(n?"border-ndor-edge bg-ndor-surface-alt/30 opacity-60 cursor-not-allowed grayscale":t?"border-ndor-gold/60 bg-ndor-gold-soft/30":"border-ndor-edge bg-ndor-surface-alt/50 hover:border-ndor-gold/30"),children:[t&&!n&&(0,Xt.jsx)("span",{"aria-hidden":!0,
2className:"absolute top-3 right-3 h-2 w-2 rounded-full bg-ndor-gold"}),n&&a&&(0,Xt.jsx)("span",{className:"absolute top-3 right-3 text-[9px] font-mono-ui uppercase tracking-[0.18em] px-1.5 py-0.5 rounded border border-ndor-edge bg-ndor-surface text-ndor-ink-muted","data-testid":"automation-mode-".concat(e.key,"-lock-label"),children:a}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(e.icon,{className:"h-4 w-4 ".concat(t?"text-ndor-gold":"text-ndor-ink-muted")}),(0,Xt.jsx)("p",{className:"text-sm font-serif-display font-semibold text-ndor-ink",children:e.label})]}),(0,Xt.jsx)("p",{className:"mt-2 text-xs text-ndor-ink-secondary leading-relaxed",children:e.long})]},e.key)})})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"automation-rules-card",children:[(0,Xt.jsx)(Ry,{className:"pb-2 border-b border-ndor-edge",children:(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(NF,{className:"h-4 w-4 text-ndor-gold"})," Rules & Preferences"]})}),(0,Xt.jsxs)(Py,{className:"pt-5 space-y-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Source CV"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink mt-1 truncate","data-testid":"automation-rule-source-cv",children:(null===z||void 0===z?void 0:z.original_filename)||(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"No primary Source CV set yet."})})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Include Cover Letter"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary mt-0.5",children:"Saved to your profile \u2014 used when you generate a pack."})]}),(0,Xt.jsx)(vk,{checked:A,onCheckedChange:async e=>{const t=A;S(e);try{await(0,zt.n)("/api/profile/preferences",{method:"POST",body:{include_cover_letter:e}})}catch(pK){S(t),fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to save preference.")}},disabled:!we.controlsEnabled,"aria-disabled":!we.controlsEnabled,"data-testid":"automation-cover-toggle"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:"Target locations / role preferences"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-0.5",children:"Coming next \u2014 will use your profile preferences."})]})]})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"automation-threshold-card",children:[(0,Xt.jsx)(Ry,{className:"pb-2 border-b border-ndor-edge",children:(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(wF,{className:"h-4 w-4 text-ndor-gold"})," Fit Threshold"]})}),(0,Xt.jsxs)(Py,{className:"pt-5",children:[(0,Xt.jsxs)("div",{className:"flex items-end justify-between gap-4 mb-3",children:[(0,Xt.jsx)("p",{className:"text-5xl font-serif-display font-semibold text-ndor-ink leading-none","data-testid":"automation-threshold-value",children:b}),(0,Xt.jsx)("p",{className:"text-sm ".concat(ge.tone),"data-testid":"automation-threshold-helper",children:ge.label})]}),(0,Xt.jsx)(gF,{min:70,max:95,step:1,value:[b],onValueChange:e=>{const t=Array.isArray(e)?e[0]:e;w(t)},onValueCommit:e=>{const t=Array.isArray(e)?e[0]:e;t!==g&&(y(t),xe({automation_threshold:t}))},disabled:!we.controlsEnabled,"aria-disabled":!we.controlsEnabled,"data-testid":"automation-threshold-slider",className:"my-2 ".concat(we.controlsEnabled?"":"opacity-50 pointer-events-none")}),(0,Xt.jsxs)("div",{className:"flex justify-between text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui mt-1",children:[(0,Xt.jsx)("span",{children:"Broad \xb7 70"}),(0,Xt.jsx)("span",{children:"Balanced \xb7 80"}),(0,Xt.jsx)("span",{children:"Selective \xb7 85"}),(0,Xt.jsx)("span",{children:"Elite \xb7 90+"})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary mt-3",children:"Lower threshold = broader coverage. Higher threshold = narrower, higher-quality targeting. Only jobs with a fit score at or above the threshold reach the approval queue."})]})]}),(0,Xt.jsxs)("div",{id:"review-queue",className:"grid grid-cols-1 lg:grid-cols-2 gap-6 items-stretch scroll-mt-24",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface h-full flex flex-col min-h-[22rem]","data-testid":"automation-queue-card",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 border-b border-ndor-edge flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-ndor-gold"}),"assisted_review"===x?"Review Queue":"Prioritised Opportunities"]}),(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui","data-testid":"automation-queue-status",children:W?"Scanning opportunities\u2026":"".concat(je.length," ").concat(1===je.length?"role":"roles"," \u2265 ").concat(g)})]}),(0,Xt.jsx)(Py,{className:"pt-2 flex-1 min-h-0 overflow-y-auto",children:V?(0,Xt.jsx)("p",{className:"py-8 text-center text-sm text-ndor-ink-muted",children:"Loading opportunities\u2026"}):0===je.length?(0,Xt.jsxs)("div",{className:"py-8 text-center space-y-1","data-testid":"automation-queue-empty",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"manual_review"===x?"Manual Review does not surface a review queue. Switch to Assisted Review to let NDORFlow run Analyse Fit against your Source CV in the background.":j?"Workflow is paused \u2014 no new items are being queued.":"No scored jobs currently meet your selected threshold."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary",children:"Lower the threshold, or run Analyse Fit on more jobs to see them here."})]}):(0,Xt.jsx)("ul",{className:"divide-y divide-ndor-edge",children:je.map(e=>{var t,n;return(0,Xt.jsxs)("li",{className:"py-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3","data-testid":"automation-queue-row-".concat(e.job_id),children:[(0,Xt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Xt.jsx)(Et,{to:"/jobs/".concat(e.job_id),className:"text-base sm:text-sm font-medium text-ndor-ink hover:underline break-words sm:truncate block leading-snug","data-testid":"automation-queue-title-".concat(e.job_id),children:e.title||"Untitled role"}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted sm:truncate mt-0.5 flex items-center gap-1.5 flex-wrap",children:[(0,Xt.jsx)("span",{children:e.company||"\u2014"}),"platform"===e.source_kind&&(0,Xt.jsx)("span",{className:"inline-flex items-center gap-1 px-1.5 py-[1px] rounded border border-ndor-info/30 bg-ndor-info-light text-[9px] font-mono-ui uppercase tracking-[0.16em] text-ndor-info","data-testid":"automation-queue-source-platform-".concat(e.job_id),title:"Public role from a shared platform source",children:"Public"})]})]}),(0,Xt.jsxs)("span",{className:"self-start sm:self-auto inline-flex items-baseline gap-1 text-xs font-mono-ui px-2 py-0.5 rounded border shrink-0 ".concat((null!==(t=e.fit)&&void 0!==t?t:0)>=90?"text-ndor-gold bg-ndor-gold-soft/40 border-ndor-gold/30":"text-ndor-info bg-ndor-info-light border-ndor-info/20"),"data-testid":"automation-queue-fit-".concat(e.job_id),children:[(0,Xt.jsx)("span",{className:"text-[9px] uppercase tracking-[0.16em] opacity-70",children:"Fit"}),(0,Xt.jsx)("span",{className:"text-sm font-semibold tabular-nums",children:null!==(n=e.fit)&&void 0!==n?n:"\u2014"})]}),"assisted_review"===x?(0,Xt.jsxs)("div",{className:"flex gap-2 w-full sm:w-auto",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"flex-1 sm:flex-none border-ndor-success/40 text-ndor-success bg-ndor-success-light/40 hover:bg-ndor-success-light hover:border-ndor-success",onClick:()=>(async e=>{try{await(0,zt.n)("/api/automation/queue/".concat(e.job_id,"/approve"),{method:"POST"}),F(t=>t.filter(t=>t.job_id!==e.job_id)),ee(),u("/jobs/".concat(e.job_id))}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to approve.")}})(e),"data-testid":"automation-queue-approve-".concat(e.job_id),children:[(0,Xt.jsx)(Og,{className:"h-4 w-4 mr-1.5"})," Approve"]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"flex-1 sm:flex-none border-ndor-error/40 text-ndor-error bg-ndor-error-light/40 hover:bg-ndor-error-light hover:border-ndor-error",onClick:()=>(async e=>{const t=E;F(t=>t.filter(t=>t.job_id!==e.job_id));try{await(0,zt.n)("/api/automation/queue/".concat(e.job_id,"/dismiss"),{method:"POST"}),ee()}catch(pK){F(t),fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to dismiss.")}})(e),"data-testid":"automation-queue-decline-".concat(e.job_id),children:[(0,Xt.jsx)(Gg,{className:"h-4 w-4 mr-1.5"})," Dismiss"]})]}):(0,Xt.jsx)(Et,{to:"/jobs/".concat(e.job_id),className:"w-full sm:w-auto",children:(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"w-full sm:w-auto border-ndor-edge bg-ndor-surface-alt hover:bg-ndor-surface text-ndor-ink",children:["Open ",(0,Xt.jsx)(zy,{className:"h-3.5 w-3.5 ml-1"})]})})]},e.job_id)})})})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface h-full flex flex-col min-h-[22rem]","data-testid":"automation-ledger-card",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 border-b border-ndor-edge flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-serif-display font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(wF,{
2className:"h-4 w-4 text-ndor-gold"})," Activity Log"]}),(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui","data-testid":"automation-ledger-count",children:0===R.length?"No events yet":"".concat(R.length," ").concat(1===R.length?"event":"events").concat(R.length>10?" \xb7 scroll for more":"")})]}),(0,Xt.jsx)(Py,{className:"pt-2 flex-1 min-h-0 flex flex-col",children:0===R.length?(0,Xt.jsx)("p",{className:"py-8 text-center text-sm text-ndor-ink-secondary","data-testid":"automation-ledger-empty",children:"No activity yet. Your settings changes and queue actions will be logged here. Nothing in this log represents a submitted application."}):(0,Xt.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1","data-testid":"automation-ledger-scroll",children:(0,Xt.jsx)("ul",{className:"divide-y divide-ndor-edge",children:R.map((e,t)=>(0,Xt.jsxs)("li",{className:"py-2.5 flex items-start gap-3","data-testid":"automation-ledger-row-".concat(e.kind,"-").concat(t),children:[(0,Xt.jsx)("span",{className:"text-[11px] font-mono-ui text-ndor-ink-muted tracking-wide whitespace-nowrap pt-0.5",children:SF(e.created_at)}),(0,Xt.jsx)("span",{className:"text-sm text-ndor-ink flex-1",children:EF(e)})]},e.id||t))})})})]})]}),(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-edge bg-ndor-surface-alt/50 px-5 py-4 flex items-start gap-3","data-testid":"automation-safety-note",children:[(0,Xt.jsx)(Ln,{className:"h-4 w-4 text-ndor-gold mt-0.5 shrink-0"}),(0,Xt.jsxs)("div",{className:"text-sm",children:[(0,Xt.jsx)("p",{className:"text-ndor-ink font-medium",children:"You remain in control."}),(0,Xt.jsx)("p",{className:"text-ndor-ink-secondary text-xs mt-0.5 leading-relaxed",children:"NDORFlow never submits an application on your behalf \u2014 on any plan, in any mode. Approving a role in Assisted Review or clicking a row in Top Opportunities opens that job's detail page; you pick the CV, run any extra Analyse Fit, generate the cover letter, assemble the pack, and submit each application yourself. Pause at any time to stop new items being scored."})]})]}),(0,Xt.jsx)(yF,{open:de,onOpenChange:ue,requiredUsage:me,availableUsage:he,actionLabel:"this application pack"})]})}const RF=["className"],IF=["className"],TF=["className"],PF=["className"],OF=["className"],BF=["className"],LF=["className"],MF=["className"],zF=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,RF);return(0,Xt.jsx)("div",{className:"relative w-full overflow-auto",children:(0,Xt.jsx)("table",(0,c.A)({ref:t,className:Sr("w-full caption-bottom text-sm",n)},a))})});zF.displayName="Table";const UF=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,IF);return(0,Xt.jsx)("thead",(0,c.A)({ref:t,className:Sr("[&_tr]:border-b",n)},a))});UF.displayName="TableHeader";const VF=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,TF);return(0,Xt.jsx)("tbody",(0,c.A)({ref:t,className:Sr("[&_tr:last-child]:border-0",n)},a))});VF.displayName="TableBody";s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,PF);return(0,Xt.jsx)("tfoot",(0,c.A)({ref:t,className:Sr("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",n)},a))}).displayName="TableFooter";const qF=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,OF);return(0,Xt.jsx)("tr",(0,c.A)({ref:t,className:Sr("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n)},a))});qF.displayName="TableRow";const WF=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,BF);return(0,Xt.jsx)("th",(0,c.A)({ref:t,className:Sr("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",n)},a))});WF.displayName="TableHead";const HF=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,LF);return(0,Xt.jsx)("td",(0,c.A)({ref:t,className:Sr("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",n)},a))});HF.displayName="TableCell";function GF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:120;if(!e)return"";const n=String(e);return n.length>t?"".concat(n.slice(0,t),"\u2026"):n}function KF(e){if(!e)return"\u2014";const t=new Date(e);
2return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"2-digit",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function YF(e){switch(e){case"succeeded":return"bg-emerald-500/10 text-emerald-200 border-emerald-500/40";case"failed":return"bg-rose-500/10 text-rose-200 border-rose-500/40";case"running":return"bg-sky-500/10 text-sky-200 border-sky-500/40";case"pending":return"bg-ndor-surface-alt text-slate-200 border-slate-200";default:return"bg-ndor-surface-alt text-slate-300 border-slate-200"}}function JF(){const[e,t]=(0,s.useState)([]),[n,a]=(0,s.useState)(!0),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[m,p]=(0,s.useState)({}),h=(0,s.useCallback)(async()=>{a(!0),i(null),l(!1);try{const e=await(0,zt.n)("/api/admin/sources/freshness");t(Array.isArray(null===e||void 0===e?void 0:e.items)?e.items:[]),u(new Date)}catch(pK){403===(null===pK||void 0===pK?void 0:pK.status)?l(!0):i((null===pK||void 0===pK?void 0:pK.message)||"Failed to load source freshness.")}finally{a(!1)}},[]);return(0,s.useEffect)(()=>{h()},[h]),o?(0,Xt.jsxs)("div",{"data-testid":"admin-sources-forbidden",className:"mx-auto max-w-xl py-16 px-4 text-center",children:[(0,Xt.jsx)(mb,{className:"mx-auto mb-4 h-10 w-10 text-slate-300"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Admin only"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-slate-300",children:"You need operator access to view source freshness."})]}):(0,Xt.jsxs)("div",{"data-testid":"admin-sources-page",className:"mx-auto max-w-[1400px] px-4 py-8 space-y-4",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold text-ndor-ink",children:"Source Freshness"}),(0,Xt.jsx)("p",{className:"mt-1 text-sm text-slate-300",children:"Operator view of configured ingestion sources. Health is maintained by the ingestion worker on every run."}),d&&(0,Xt.jsxs)("p",{"data-testid":"admin-sources-fetched-at",className:"mt-1 text-xs text-slate-300",children:["Fetched ",d.toLocaleString()]})]}),(0,Xt.jsxs)(Rr,{"data-testid":"admin-sources-refresh-btn",variant:"outline",onClick:h,disabled:n,children:[n?(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}):(0,Xt.jsx)(Kg,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),r&&(0,Xt.jsx)("div",{"data-testid":"admin-sources-error",className:"rounded-md border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:r}),(0,Xt.jsx)("div",{className:"rounded-md border border-slate-200 bg-ndor-surface overflow-x-auto",children:(0,Xt.jsxs)(zF,{"data-testid":"admin-sources-table",children:[(0,Xt.jsx)(UF,{children:(0,Xt.jsxs)(qF,{children:[(0,Xt.jsx)(WF,{children:"Source"}),(0,Xt.jsx)(WF,{children:"Type"}),(0,Xt.jsx)(WF,{children:"Enabled"}),(0,Xt.jsx)(WF,{children:"Cadence"}),(0,Xt.jsx)(WF,{children:"Last run"}),(0,Xt.jsx)(WF,{children:"Last OK"}),(0,Xt.jsx)(WF,{className:"text-right",children:"Fails"}),(0,Xt.jsx)(WF,{className:"text-right",children:"Active"}),(0,Xt.jsx)(WF,{className:"text-right",children:"Stale"}),(0,Xt.jsx)(WF,{className:"text-right",children:"404"}),(0,Xt.jsx)(WF,{children:"Latest task"}),(0,Xt.jsx)(WF,{children:"Last error"}),(0,Xt.jsx)(WF,{className:"text-right",children:"Run"})]})}),(0,Xt.jsxs)(VF,{children:[n&&0===e.length&&(0,Xt.jsx)(qF,{children:(0,Xt.jsxs)(HF,{colSpan:13,className:"py-10 text-center text-sm text-slate-300","data-testid":"admin-sources-loading",children:[(0,Xt.jsx)(Lg,{className:"mx-auto mb-2 h-5 w-5 animate-spin"}),"Loading source freshness\u2026"]})}),!n&&0===e.length&&!r&&(0,Xt.jsx)(qF,{children:(0,Xt.jsx)(HF,{colSpan:13,className:"py-10 text-center text-sm text-slate-300","data-testid":"admin-sources-empty",children:"No ingestion sources configured."})}),e.map(e=>{var t,n,a;return(0,Xt.jsxs)(qF,{"data-testid":"admin-sources-row-".concat(e.id),children:[(0,Xt.jsx)(HF,{className:"font-medium text-ndor-ink",children:e.name||"\u2014"}),(0,Xt.jsx)(HF,{className:"text-slate-300",children:e.source_type||"\u2014"}),(0,Xt.jsx)(HF,{children:(0,Xt.jsx)(Vw,{variant:"outline",className:e.enabled?"bg-emerald-500/10 text-emerald-200 border-emerald-500/40":"bg-ndor-surface-alt text-slate-300 border-slate-200",children:e.enabled?"on":"off"})}),(0,Xt.jsx)(HF,{className:"text-slate-300",children:e.cadence||"\u2014"}),(0,Xt.jsx)(HF,{className:"text-slate-300 whitespace-nowrap",children:KF(e.last_run_at)}),(0,Xt.jsx)(HF,{className:"text-slate-300 whitespace-nowrap",children:KF(e.last_ok_at)}),(0,Xt.jsx)(HF,{className:"text-right tabular-nums ".concat((e.consecutive_failures||0)>0?"text-rose-200 font-medium":"text-slate-300"),children:e.consecutive_failures||0}),(0,Xt.jsx)(HF,{className:"text-right tabular-nums text-slate-200",children:null!==(t=e.active_jobs)&&void 0!==t?t:0}),(0,Xt.jsx)(HF,{className:"text-right tabular-nums text-slate-300",children:null!==(n=e.hidden_stale)&&void 0!==n?n:0}),(0,Xt.jsx)(HF,{className:"text-right tabular-nums text-slate-300",children:null!==(a=e.hidden_404)&&void 0!==a?a:0}),(0,Xt.jsx)(HF,{children:e.latest_task_status?(0,Xt.jsx)(Vw,{variant:"outline",className:YF(e.latest_task_status),children:e.latest_task_status}):(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})}),(0,Xt.jsx)(HF,{className:"text-xs text-rose-200 max-w-[280px]",title:e.last_error||"",children:GF(e.last_error)||(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})}),(0,Xt.jsx)(HF,{className:"text-right",children:(()=>{const t=m[e.id],n="running"===(null===t||void 0===t?void 0:t.status);return(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2",children:["enqueued"===(null===t||void 0===t?void 0:t.status)&&(0,Xt.jsxs)("span",{"data-testid":"admin-sources-run-enqueued-".concat(e.id),className:"inline-flex items-center gap-1 text-xs text-emerald-200",children:[(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5"})," Enqueued"]}),"already_running"===(null===t||void 0===t?void 0:t.status)&&(0,Xt.jsxs)("span",{"data-testid":"admin-sources-run-already-".concat(e.id),className:"inline-flex items-center gap-1 text-xs text-slate-300",children:[(0,Xt.jsx)(zf,{className:"h-3.5 w-3.5"})," Already running"]}),"error"===(null===t||void 0===t?void 0:t.status)&&(0,Xt.jsxs)("span",{"data-testid":"admin-sources-run-error-".concat(e.id),title:t.message,className:"inline-flex items-center gap-1 text-xs text-rose-200 max-w-[200px] truncate",children:[(0,Xt.jsx)(ty,{className:"h-3.5 w-3.5"})," ",t.message]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"enqueued"===(null===t||void 0===t?void 0:t.status)||"already_running"===(null===t||void 0===t?void 0:t.status)?"outline":"default",onClick:()=>async function(e){const t=e.id;p(e=>(0,c.A)((0,c.A)({},e),{},{[t]:{status:"running"}}));try{const e=await(0,zt.n)("/api/admin/sources/".concat(t,"/run_n
2ow"),{method:"POST"});p(n=>(0,c.A)((0,c.A)({},n),{},{[t]:{status:(null===e||void 0===e?void 0:e.status)||"enqueued"}}))}catch(pK){var n;const a=null===pK||void 0===pK||null===(n=pK.data)||void 0===n?void 0:n.detail;p(n=>(0,c.A)((0,c.A)({},n),{},{[t]:{status:"error",message:"string"===typeof a&&a||(null===pK||void 0===pK?void 0:pK.message)||"Run failed"}}))}}(e),disabled:n||!e.enabled,"data-testid":"admin-sources-run-btn-".concat(e.id),title:e.enabled?"Enqueue a manual ingestion run":"Source is disabled",children:[n?(0,Xt.jsx)(Lg,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):(0,Xt.jsx)(jF,{className:"mr-1 h-3.5 w-3.5"}),"Run now"]})]})})()})]},e.id)})]})]})})]})}function $F(e){return e&&"string"===typeof e?e.toLowerCase().replace(/[\u2018\u2019\u201C\u201D]/g,"").replace(/[^a-z0-9\s&]/g," ").replace(/\b(careers?|jobs?|inc|incorporated|corp|corporation|co|company|ltd|limited|plc|llc|llp|group|holdings?|the|and|&)\b/g," ").replace(/\s+/g," ").trim():""}function XF(e,t){const n=$F(e),a=$F(t);if(!n||!a)return!1;const r=n.length<=a.length?n:a,s=n.length<=a.length?a:n;return!(r.length<3)&&s.includes(r)}function QF(e,t,n){const a={matched:!1,match_type:null};if(!e||"seedable_now"!==e.status_bucket)return a;
2if(!Array.isArray(t)||0===t.length)return a;const r=function(e){const t=new Map;for(const a of e||[]){var n;const e=null===a||void 0===a||null===(n=a.config_json)||void 0===n?void 0:n._detected_from_url;"string"===typeof e&&e&&t.set(e,a)}return t}(t),s=e.careers_url&&r.get(e.careers_url);if(s){var i;const e=(null===n||void 0===n?void 0:n[s.id])||null;return{matched:!0,match_type:"detected_from_url",source_id:s.id,source_name:s.name,source_type:s.source_type,enabled:s.enabled,active_jobs:null!==(i=null===e||void 0===e?void 0:e.active_jobs)&&void 0!==i?i:null}}const o=function(e){if(!e)return null;if(e.suggested_adapter)return e.suggested_adapter;const t=e.detected_family;return t&&t.endsWith("_board")?t:null}(e);if(!o)return a;const l=t.filter(e=>e.source_type===o);for(const d of l)if(XF(e.company_name,d.name)){var c;const e=(null===n||void 0===n?void 0:n[d.id])||null;return{matched:!0,match_type:"name_family",source_id:d.id,source_name:d.name,source_type:d.source_type,enabled:d.enabled,active_jobs:null!==(c=null===e||void 0===e?void 0:e.active_jobs)&&void 0!==c?c:null}}return a}s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,MF);return(0,Xt.jsx)("caption",(0,c.A)({ref:t,className:Sr("mt-4 text-sm text-muted-foreground",n)},a))}).displayName="TableCaption";const ZF=wn("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),eR=wn("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),tR={seedable_now:{label:"Seedable now",tone:"bg-emerald-500/10 text-emerald-200 border-emerald-500/40"},pending_family_adapter:{label:"Pending family",tone:"bg-amber-500/10 text-amber-200 border-amber-500/40"},bespoke_required:{label:"Bespoke",tone:"bg-ndor-surface-alt text-slate-300 border-slate-200"}},nR={high:"bg-emerald-500/10 text-emerald-200 border-emerald-500/40",medium:"bg-sky-500/10 text-sky-200 border-sky-500/40",low:"bg-amber-500/10 text-amber-200 border-amber-500/40",unknown:"bg-ndor-surface-alt text-slate-300 border-slate-200"};function aR(e){return e?e.replace(/_pending$/,"").replace(/_board$/,"").replace(/_/g," "):"\u2014"}function rR(e){let{row:t,coverage:n}=e;if("seedable_now"!==t.status_bucket)return(0,Xt.jsx)("span",{className:"text-slate-300 text-xs",children:"\u2014"});const a=t.company_name.toLowerCase().replace(/\s+/g,"-");if(null===n||void 0===n||!n.matched)return(0,Xt.jsx)("span",{"data-testid":"admin-catalogue-coverage-not-seeded-".concat(a),className:"text-xs text-slate-300",children:"Not seeded"});const{active_jobs:r,enabled:s,match_type:i,source_name:o}=n;let l,c="bg-emerald-500/10 text-emerald-200 border-emerald-500/40",d=(0,Xt.jsx)(wF,{className:"h-3 w-3"});!1===s?(c="bg-amber-500/10 text-amber-200 border-amber-500/40",d=(0,Xt.jsx)(ZF,{className:"h-3 w-3"}),l="Seeded \xb7 disabled"):"number"===typeof r&&r>0?l="Ingesting ".concat(r):0===r?(c="bg-ndor-surface-alt text-slate-300 border-slate-200",d=(0,Xt.jsx)(ZF,{className:"h-3 w-3"}),l="Seeded \xb7 empty"):l="Seeded";const u="name_family"===i;return(0,Xt.jsxs)("div",{className:"flex flex-col gap-0.5","data-testid":"admin-catalogue-coverage-".concat(a),children:[(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs w-fit ".concat(c),title:o||"",children:[d,(0,Xt.jsx)("span",{"data-testid":"admin-catalogue-coverage-".concat(a,"-label"),children:l})]}),u&&(0,Xt.jsx)("span",{className:"text-[10px] text-slate-300","data-testid":"admin-catalogue-coverage-".concat(a,"-fallback"),title:"Matched by source_type + name \u2014 not by exact URL.",children:"name match"})]})}function sR(){const[e,t]=(0,s.useState)(null),[n,a]=(0,s.useState)([]),[r,i]=(0,s.useState)([]),[o,l]=(0,s.useState)(!0),[d,u]=(0,s.useState)(null),[m,p]=(0,s.useState)(!1),[h,f]=(0,s.useState)(""),[x,v]=(0,s.useState)("all"),[g,y]=(0,s.useState)("all"),[b,w]=(0,s.use
2State)({}),[j,k]=(0,s.useState)(null),[N,_]=(0,s.useState)(null),[D,C]=(0,s.useState)(null),A=(0,s.useCallback)(async()=>{l(!0),u(null),p(!1);try{const[e,n,r]=await Promise.all([(0,zt.n)("/api/admin/catalogue"),(0,zt.n)("/api/admin/sources").catch(e=>{if(403===(null===e||void 0===e?void 0:e.status))throw e;return{items:[]}}),(0,zt.n)("/api/admin/sources/freshness").catch(()=>({items:[]}))]);t(e),a((null===n||void 0===n?void 0:n.items)||[]),i((null===r||void 0===r?void 0:r.items)||[])}catch(pK){403===(null===pK||void 0===pK?void 0:pK.status)?p(!0):u((null===pK||void 0===pK?void 0:pK.message)||"Failed to load catalogue.")}finally{l(!1)}},[]);(0,s.useEffect)(()=>{A()},[A]);const S=(0,s.useMemo)(()=>{if(null===e||void 0===e||!e.items)return[];const t=new Set;return e.items.forEach(e=>e.detected_family&&t.add(e.detected_family)),Array.from(t).sort()},[e]),E=(0,s.useMemo)(()=>{if(null===e||void 0===e||!e.items)return[];const t=h.trim().toLowerCase();return e.items.filter(e=>("all"===x||e.status_bucket===x)&&(("all"===g||(e.detected_family||"none")===g)&&!(t&&!e.company_name.toLowerCase().includes(t))))},[e,h,x,g]),F=(0,s.useMemo)(()=>{const t={total:0,seedable_now:0,pending_family_adapter:0,bespoke_required:0};return null!==e&&void 0!==e&&e.items&&(t.total=e.items.length,e.items.forEach(e=>{t[e.status_bucket]=(t[e.status_bucket]||0)+1})),t},[e]),R=(0,s.useMemo)(()=>function(e,t,n){const a={};for(const s of n||[])s&&s.id&&(a[s.id]=s);const r={};for(const s of e||[])s&&s.careers_url&&(r[s.careers_url]=QF(s,t,a));return r}((null===e||void 0===e?void 0:e.items)||[],n,r),[e,n,r]),I=(0,s.useMemo)(()=>{const t={seeded:0,ingesting:0,seeded_empty:0,not_seeded:0};if(null===e||void 0===e||!e.items)return t;for(const n of e.items){if("seedable_now"!==n.status_bucket)continue;const e=R[n.careers_url];null!==e&&void 0!==e&&e.matched?(t.seeded+=1,(e.active_jobs||0)>0?t.ingesting+=1:t.seeded_empty+=1):t.not_seeded+=1}return t},[e,R]);return m?(0,Xt.jsxs)("div",{"data-testid":"admin-catalogue-forbidden",className:"mx-auto max-w-xl py-16 px-4 text-center",children:[(0,Xt.jsx)(mb,{className:"mx-auto mb-4 h-10 w-10 text-slate-300"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Admin only"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-slate-300",children:"You need operator access to view the employer catalogue."})]}):(0,Xt.jsxs)("div",{"data-testid":"admin-catalogue-page",className:"mx-auto max-w-[1500px] px-4 py-8 space-y-5",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(eR,{className:"h-6 w-6 text-slate-200"}),(0,Xt.jsx)("h1",{className:"text-2xl font-semibold text-ndor-ink",children:"Employer catalogue"})]}),(0,Xt.jsxs)("p",{className:"mt-1 text-sm text-slate-300 max-w-2xl",children:["Global roster of ",F.total," employers, classified by detected ATS family. Seed the ones on supported adapters today; the rest are flagged with the future RC slice that will unlock them."]}),(null===e||void 0===e?void 0:e.generated_at)&&(0,Xt.jsxs)("p",{className:"mt-1 text-xs text-slate-300","data-testid":"admin-catalogue-generated-at",children:["Catalogue generated ",new Date(e.generated_at).toLocaleString()]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)(Rr,{"data-testid":"admin-catalogue-regenerate-btn",variant:"default",onClick:async function(){_("running"),C(null);try{const e=await(0,zt.n)("/api/admin/catalogue/regenerate",{method:"POST"});_("ok"),C("Regenerated ".concat(e.total," employers (").concat(e.seedable_now," seedable)")),await A(),w({})}catch(pK){var e;_("error");const n=null===pK||void 0===pK||null===(e=pK.data)||void 0===e?void 0:e.detail;C("string"===typeof n&&n||(null===pK||void 0===pK?void 0:pK.message)||"Regeneration failed.")}},disabled:"running"===N||o,title:"Re-run the 108-employer probe and rewrite the catalogue artifacts.",children:["running"===N?(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}):(0,Xt.jsx)(Kn,{className:"mr-2 h-4 w-4"}),"running"===N?"Regenerating\u2026":"Regenerate catalogue"]}),(0,Xt.jsxs)(Rr,{"data-testid":"admin-catalogue-refresh-btn",variant:"outline",onClick:A,disabled:o||"running"===N,children:[o?(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}):(0,Xt.jsx)(Kg,{className:"mr-2 h-4 w-4"}),"Refresh"]})]})]}),"ok"===N&&D&&(0,Xt.jsxs)("div",{"data-testid":"admin-catalogue-regen-ok",className:"rounded-md border border-emerald-500/40 bg-emerald-500/10 px-4 py-2 text-sm text-emerald-200 flex items-center gap-2",children:[(0,Xt.jsx)(Og,{className:"h-4 w-4"})," ",D]}),"error"===N&&D&&(0,Xt.jsxs)("div",{"data-testid":"admin-catalogue-regen-error",className:"rounded-md border border-rose-500/40 bg-rose-500/10 px-4 py-2 text-sm text-rose-200 flex items-center gap-2",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4"})," ",D]}),(0,Xt.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[{key:"total",label:"Total",value:F.total,tone:"bg-ndor-surface-alt text-slate-100"},{key:"seedable_now",label:"Seedable now",value:F.seedable_now,tone:"bg-emerald-500/10 text-emerald-200"},{key:"pending_family_adapter",label:"Pending family adapter",value:F.pending_family_adapter,tone
2:"bg-amber-500/10 text-amber-200"},{key:"bespoke_required",label:"Bespoke required",value:F.bespoke_required,tone:"bg-ndor-surface-alt text-slate-200"}].map(e=>(0,Xt.jsxs)("div",{className:"rounded-md border border-slate-200 px-4 py-3 ".concat(e.tone),"data-testid":"admin-catalogue-stat-".concat(e.key),children:[(0,Xt.jsx)("div",{className:"text-xs uppercase tracking-wide opacity-70",children:e.label}),(0,Xt.jsx)("div",{className:"mt-1 text-2xl font-semibold tabular-nums",children:e.value})]},e.key))}),F.seedable_now>0&&(0,Xt.jsxs)("div",{"data-testid":"admin-catalogue-coverage-summary",className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-slate-300 border-l-2 border-emerald-300 pl-3",children:[(0,Xt.jsx)("span",{className:"font-medium text-slate-200",children:"Coverage"}),(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1 text-emerald-200",children:[(0,Xt.jsx)(wF,{className:"h-3.5 w-3.5"}),(0,Xt.jsx)("span",{"data-testid":"admin-catalogue-coverage-ingesting",children:I.ingesting})," ","ingesting"]}),(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1 text-slate-300",children:[(0,Xt.jsx)(ZF,{className:"h-3.5 w-3.5"}),(0,Xt.jsx)("span",{"data-testid":"admin-catalogue-coverage-empty",children:I.seeded_empty})," ","seeded \xb7 empty"]}),(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1 text-slate-300",children:[(0,Xt.jsx)("span",{"data-testid":"admin-catalogue-coverage-not-seeded",children:I.not_seeded})," ","not seeded yet"]}),(0,Xt.jsxs)("span",{className:"text-slate-300",children:["(out of ",F.seedable_now," seedable employers)"]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col md:flex-row gap-2 md:items-center",children:[(0,Xt.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,Xt.jsx)(wC,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-300"}),(0,Xt.jsx)(Ag,{"data-testid":"admin-catalogue-search",placeholder:"Search company name\u2026",className:"pl-8",value:h,onChange:e=>f(e.target.value)})]}),(0,Xt.jsxs)(Vv,{value:x,onValueChange:v,children:[(0,Xt.jsx)(Wv,{className:"w-52","data-testid":"admin-catalogue-bucket-filter",children:(0,Xt.jsx)(qv,{placeholder:"All statuses"})}),(0,Xt.jsxs)(Kv,{children:[(0,Xt.jsx)(Yv,{value:"all",children:"All statuses"}),(0,Xt.jsx)(Yv,{value:"seedable_now",children:"Seedable now"}),(0,Xt.jsx)(Yv,{value:"pending_family_adapter",children:"Pending family"}),(0,Xt.jsx)(Yv,{value:"bespoke_required",children:"Bespoke"})]})]}),(0,Xt.jsxs)(Vv,{value:g,onValueChange:y,children:[(0,Xt.jsx)(Wv,{className:"w-56","data-testid":"admin-catalogue-family-filter",children:(0,Xt.jsx)(qv,{placeholder:"All families"})}),(0,Xt.jsxs)(Kv,{children:[(0,Xt.jsx)(Yv,{value:"all",children:"All families"}),(0,Xt.jsx)(Yv,{value:"none",children:"(none detected)"}),S.map(e=>(0,Xt.jsx)(Yv,{value:e,children:aR(e)},e))]})]}),(0,Xt.jsxs)("div",{className:"text-xs text-slate-300 md:ml-auto","data-testid":"admin-catalogue-match-count",children:[E.length," of ",F.total," matching"]})]}),d&&(0,Xt.jsx)("div",{"data-testid":"admin-catalogue-error",className:"rounded-md border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:d}),(0,Xt.jsx)("div",{className:"rounded-md border border-slate-200 bg-ndor-surface overflow-x-auto",children:(0,Xt.jsxs)(zF,{"data-testid":"admin-catalogue-table",children:[(0,Xt.jsx)(UF,{children:(0,Xt.jsxs)(qF,{children:[(0,Xt.jsx)(WF,{children:"Company"}),(0,Xt.jsx)(WF,{children:"Careers URL"}),(0,Xt.jsx)(WF,{children:"Family"}),(0,Xt.jsx)(WF,{children:"Confidence"}),(0,Xt.jsx)(WF,{children:"Status"}),(0,Xt.jsx)(WF,{children:"Coverage"}),(0,Xt.jsx)(WF,{children:"Unlock"}),(0,Xt.jsx)(WF,{className:"text-right",children:"Action"})]})}),(0,Xt.jsxs)(VF,{children:[o&&(0,Xt.jsx)(qF,{children:(0,Xt.jsxs)(HF,{colSpan:8,className:"py-10 text-center text-sm text-slate-300",children:[(0,Xt.jsx)(Lg,{className:"mx-auto mb-2 h-5 w-5 animate-spin"}),"Loading catalogue\u2026"]})}),!o&&0===E.length&&(0,Xt.jsx)(qF,{children:(0,Xt.jsx)(HF,{colSpan:8,className:"py-10 text-center text-sm text-slate-300",children:"No employers match these filters."})}),!o&&E.map(e=>{const t=tR[e.status_bucket]||tR.bespoke_required,n=b[e.careers_url],r=R[e.careers_url]||{matched:!1};return(0,Xt.jsxs)(qF,{"data-testid":"admin-catalogue-row-".concat(e.company_name.toLowerCase().replace(/\s+/g,"-")),children:[(0,Xt.jsxs)(HF,{children:[(0,Xt.jsx)("div",{className:"font-medium text-ndor-ink",children:e.company_name}),(0,Xt.jsx)("div",{className:"text-xs text-slate-300",children:e.category})]}),(0,Xt.jsx)(HF,{className:"max-w-[320px] text-xs",children:(0,Xt.jsx)("a",{href:e.careers_url,target:"_blank",rel:"noopener noreferrer",className:"text-sky-200 hover:underline break-all",children:e.careers_url})}),(0,Xt.jsx)(HF,{className:"text-slate-200",children:aR(e.detected_family)}),(0,Xt.jsx)(HF,{children:(0,Xt.jsx)(Vw,{variant:"outline",className:nR[e.confidence]||nR.unknown,children:e.confidence})}),(0,Xt.jsx)(HF,{children:(0,Xt.jsx)(Vw,{variant:"outline",className:t.tone,children:t.label})}),(0,Xt.jsx)(HF,{children:(0,Xt.jsx)(rR,{row:e,coverage:r})}),(0,Xt.jsx)(HF,{className:"text-xs text-slate-300",children:e.unlock_slice&&"\u2014"!==e.unlock_slice?e.unlock_slice:(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})}),(0,Xt.jsx)(HF,{className:"text-right",children:"seedable_now"===e.status_bucket?(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2",children:["created"===(null===n||void 0===n?void 0:n.status)&&(0,Xt.jsxs)("span",{"data-testid":"admin-catalogue-seed-created",className:"inline-flex items-center gap-1 text-xs text-emerald-200",children:[(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5"})," Created"]}),"already_exists"===(null===n||void 0===n?void 0:n.status)&&(0,Xt.jsxs)("span",{"data-testid":"admin-catalogue-seed-exists",className:"inline-flex items-center gap-1 text-xs text-slate-300",children:[(0,Xt.jsx)(zf,{className:"h-3.5 w-3.5"})," Already exists"]}),"error"===(null===n||void 0===n?void 0:n.status)&&(0,Xt.jsxs)("span",{"data-testid":"admin-catalogue-seed-error",title:n.message,className:"inline-flex items-center gap-1 text-xs text-rose-200 max-w-[220px] truncate",children:[(0,Xt.jsx)(ty,{className:"h-3.5 w-3.5"})," ",n.message]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"created"===(null===n||void 0===n?void 0:n.status)||"already_exists"===(null===n||void 0===n?void 0:n.status)?"outline":"default",onClick:()=>async function(e){const t=e.careers_url;w(e=>(0,c.A)((0,c.A)({},e),{},{[t]:{status:"pending"}}));try{const n=await(0,zt.n)("/api/admin/catalogue/seed",{method:"POST",body:{company_name:e.company_name,careers_url:e.careers_url}});if(w(e=>(0,c.A)((0,c.A)({},e),{},{[t]:{status:n.status,source_id:n.source_id}})),"created"===n.status||"already_exists"===n.status)try{const[e,t]=await Promise.all([(0,zt.n)("/api/admin/sources"),(0,zt.n)("/api/admin/sources/freshness")]);a((null===e||void 0===e?void 0:e.items)||[]),i((null===t||void 0===t?void 0:t.items)||[])}catch(r){}}catch(pK){var n;const a=null===pK||void 0===pK||null===(n=pK.data)||void 0===n?void 0:n.detail,r="string"===typeof a&&a||a&&a.message||(null===pK||void 0===pK?void 0:pK.message)||"Seed failed.";w(e=>(0,c.A)((0,c.A)({},e),{},{[t]:{status:"error",message:r}}))}}(e),disabled:"pending"===(null===n||void 0===n?void 0:n.status),"data-testid":"admin-catalogue-seed-btn-".concat(e.company_name.toLowerCase().replace(/\s+/g,"-")),children:["pending"===(null===n||void 0===n?void 0:n.status)?(0,Xt.jsx)(Lg,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):null,"created"===(null===n||void 0===n?void 0:n.status)||"already_exists"===(null===n||void 0===n?void 0:n.status)?"Seed again":"Seed Source"]})]}):(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",onClick:()=>k(e),"data-testid":"admin-catalogue-why-btn-".concat(e.company_name.toLowerCase().replace(/\s+/g,"-")),children:"View Why"})})]},e.careers_url)})]})]})}),(0,Xt.jsx)(rg,{open:!!j,onOpenChange:e=>!e&&k(null),children:(0,Xt.jsx)(lg,{"data-testid":"admin-catalogue-why-dialog",children:j&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{children:[j.company_name," \u2014 why isn't this seedable?"]}),(0,Xt.jsxs)(mg,{children:["Detection classified this employer as"," ",(0,Xt.jsx)("span",{className:"font-medium text-slate-100",children:aR(j.detected_family)})," ","(",j.confidence,")."]})]}),(0,Xt.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Status"}),(0,Xt.jsx)(Vw,{variant:"outline",className:(tR[j.status_bucket]||tR.bespoke_required).tone,children:(tR[j.status_bucket]||tR.bespoke_required).label})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Unlock slice"}),(0,Xt.jsx)("div",{className:"text-slate-200",children:j.unlock_slice||"custom per-company adapter required"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Careers
2URL"}),(0,Xt.jsx)("a",{href:j.careers_url,target:"_blank",rel:"noopener noreferrer",className:"text-sky-200 hover:underline text-xs break-all",children:j.careers_url})]}),j.final_url&&j.final_url!==j.careers_url&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Final URL (after redirect)"}),(0,Xt.jsx)("div",{className:"text-xs text-slate-300 break-all",children:j.final_url})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Detection trail"}),(0,Xt.jsxs)("ul",{className:"mt-1 space-y-1 text-xs text-slate-300 list-disc list-inside",children:[(j.notes||[]).map((e,t)=>(0,Xt.jsx)("li",{children:e},t)),(!j.notes||!j.notes.length)&&(0,Xt.jsx)("li",{className:"list-none text-slate-300",children:"No notes captured."})]})]})]})]})})})]})}const iR=[{value:"visible",label:"Visible (default)"},{value:"stale",label:"Hidden by staleness"},{value:"404",label:"Hidden by source 404"},{value:"any",label:"Any (all rows)"}],oR=[{value:"__all__",label:"All source kinds"},{value:"platform",label:"Platform (adapters)"},{value:"user_import",label:"User import"}];function lR(e){return"number"!==typeof e?"\u2014":e.toLocaleString()}function cR(e){if(!e)return"\u2014";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"2-digit",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function dR(e){let{label:t,value:n,testId:a,tone:r}=e;const s={default:"text-ndor-ink",warn:"text-amber-200",bad:"text-rose-200",ok:"text-emerald-200"}[r||"default"];return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":a,children:[(0,Xt.jsx)(Ry,{className:"pb-1",children:(0,Xt.jsx)(Iy,{className:"text-xs font-medium uppercase tracking-wider text-ndor-ink-muted",children:t})}),(0,Xt.jsx)(Py,{children:(0,Xt.jsx)("p",{className:"text-3xl font-mono tabular-nums ".concat(s),children:lR(n)})})]})}function uR(){var e;const[t,n]=(0,s.useState)(!1),[a,r]=(0,s.useState)(null),[i,o]=(0,s.useState)(!0),[l,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(null),[m,p]=(0,s.useState)(!0),[h,f]=(0,s.useState)(null),[x,v]=(0,s.useState)(1),[g]=(0,s.useState)(50),[y,b]=(0,s.useState)(""),[w,j]=(0,s.useState)(""),[k,N]=(0,s.useState)("__all__"),[_,D]=(0,s.use
2State)("visible"),C=(0,s.useCallback)(async()=>{o(!0),c(null);try{const e=await(0,zt.n)("/api/admin/jobs/inventory?top_companies=20");r(e||null)}catch(pK){403===(null===pK||void 0===pK?void 0:pK.status)?n(!0):c((null===pK||void 0===pK?void 0:pK.message)||"Failed to load inventory.")}finally{o(!1)}},[]),A=(0,s.useCallback)(async()=>{p(!0),f(null);try{const e=new URLSearchParams({page:String(x),page_size:String(g),hidden:_});y.trim()&&e.set("q",y.trim()),k&&"__all__"!==k&&e.set("source_kind",k);const t=await(0,zt.n)("/api/admin/jobs/list?".concat(e.toString()));u(t||null)}catch(pK){403===(null===pK||void 0===pK?void 0:pK.status)?n(!0):f((null===pK||void 0===pK?void 0:pK.message)||"Failed to load jobs list.")}finally{p(!1)}},[x,g,y,k,_]);(0,s.useEffect)(()=>{C()},[C]),(0,s.useEffect)(()=>{A()},[A]),(0,s.useEffect)(()=>{v(1)},[y,k,_]);const S=(null===a||void 0===a?void 0:a.totals)||{},E=(null===a||void 0===a?void 0:a.by_source_kind)||{},F=(null===a||void 0===a?void 0:a.by_company_top)||[],R=(0,s.useMemo)(()=>Object.entries(E).sort((e,t)=>t[1]-e[1]),[E]);if(t)return(0,Xt.jsxs)("div",{"data-testid":"admin-jobs-forbidden",className:"mx-auto max-w-xl py-16 px-4 text-center",children:[(0,Xt.jsx)(mb,{className:"mx-auto mb-4 h-10 w-10 text-slate-300"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Admin only"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:"You need operator access to view the jobs inventory."})]});const I=Math.max(1,Math.ceil(((null===d||void 0===d?void 0:d.total)||0)/g));return(0,Xt.jsxs)("div",{className:"mx-auto max-w-[1400px] px-4 py-8 space-y-8","data-testid":"admin-jobs-inventory-page",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(zn,{className:"h-5 w-5 text-ndor-ink-muted"}),"Jobs Inventory"]}),(0,Xt.jsx)("p",{className:"mt-1 text-sm text-ndor-ink-muted",children:"Operator view of the real jobs database. Counts are live \u2014 refresh to re-read."})]}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:()=>{C(),A()},disabled:i||m,"data-testid":"admin-jobs-refresh",children:[i||m?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(Kg,{className:"h-4 w-4 mr-1.5"}),"Refresh"]})]}),l&&(0,Xt.jsx)("div",{className:"rounded-md border border-rose-500/40 bg-rose-500/10 text-rose-200 text-sm px-3 py-2","data-testid":"admin-jobs-inventory-error",children:l}),(0,Xt.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[(0,Xt.jsx)(dR,{label:"Total jobs",value:S.total,testId:"admin-jobs-stat-total"}),(0,Xt.jsx)(dR,{label:"Visible",value:S.visible,testId:"admin-jobs-stat-visible",tone:"ok"}),(0,Xt.jsx)(dR,{label:"Hidden \xb7 stale",value:S.hidden_by_staleness,testId:"admin-jobs-stat-hidden-stale",tone:"warn"}),(0,Xt.jsx)(dR,{label:"Hidden \xb7 404",value:S.hidden_by_source_404,testId:"admin-jobs-stat-hidden-404",tone:"bad"})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"admin-jobs-by-source-kind",children:[(0,Xt.jsx)(Ry,{className:"pb-2",children:(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"By source kind"})}),(0,Xt.jsxs)(Py,{children:[i&&(0,Xt.jsx)("div",{className:"py-6 flex items-center justify-center text-ndor-ink-muted",children:(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})}),!i&&0===R.length&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted py-4",children:"No jobs indexed yet."}),!i&&R.length>0&&(0,Xt.jsxs)(zF,{children:[(0,Xt.jsx)(UF,{children:(0,Xt.jsxs)(qF,{children:[(0,Xt.jsx)(WF,{children:"Source kind"}),(0,Xt.jsx)(WF,{className:"text-right",children:"Count"})]})}),(0,Xt.jsx)(VF,{children:R.map(e=>{let[t,n]=e;return(0,Xt.jsxs)(qF,{"data-testid":"admin-jobs-kind-row-".concat(t),children:[(0,Xt.jsx)(HF,{className:"font-mono text-xs",children:t}),(0,Xt.jsx)(HF,{className:"text-right tabular-nums",children:lR(n)})]},t)})})]})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"admin-jobs-by-company-top",children:[(0,Xt.jsx)(Ry,{className:"pb-2",children:(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"Top 20 companies (visible)"})}),(0,Xt.jsxs)(Py,{children:[i&&(0,Xt.jsx)("div",{className:"py-6 flex items-center justify-center text-ndor-ink-muted",children:(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})}),!i&&0===F.length&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted py-4",children:"No companies to report."}),!i&&F.length>0&&(0,Xt.jsxs)(zF,{children:[(0,Xt.jsx)(UF,{children:(0,Xt.jsxs)(qF,{children:[(0,Xt.jsx)(WF,{children:"Company"}),(0,Xt.jsx)(WF,{className:"text-right",children:"Visible jobs"})]})}),(0,Xt.jsx)(VF,{children:F.map((e,t)=>(0,Xt.jsxs)(qF,{"data-testid":"admin-jobs-company-row-".concat(t),children:[(0,Xt.jsx)(HF,{children:e.company}),(0,Xt.jsx)(HF,{className:"text-right tabular-nums",children:lR(e.count)})]},"".concat(e.company,"-").concat(t)))})]})]})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"admin-jobs-list-card",children:[(0,Xt.jsxs)(Ry,{className:"pb-3",children:[(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"Jobs list"}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-2",children:[(0,Xt.jsxs)("form",{className:"flex items-center gap-2",onSubmit:e=>{e.preventDefault(),b(w)},children:[(0,Xt.jsx)(Ag,{placeholder:"Search title or company\u2026",value:w,onChange:e=>j(e.target.value),className:"h-9 w-64","data-testid":"admin-jobs-search-input"}),(0,Xt.jsx)(Rr,{type:"submit",size:"sm",variant:"outline","data-testid":"admin-jobs-search-submit",children:"Search"}),y&&(0,Xt.jsx)(Rr,{type:"button",size:"sm",variant:"ghost",onClick:()=>{j(""),b("")},"data-testid":"admin-jobs-search-clear",children:"Clear"})]}),(0,Xt.jsxs)(Vv,{value:k,onValueChange:N,children:[(0,Xt.jsx)(Wv,{className:"h-9 w-[200px]","data-testid":"admin-jobs-filter-kind",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:oR.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]}),(0,Xt.jsxs)(Vv,{value:_,onValueChange:D,children:[(0,Xt.jsx)(Wv,{className:"h-9 w-[220px]","data-testid":"admin-jobs-filter-hidden",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:iR.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]})]})]}),(0,Xt.jsxs)(Py,{children:[h&&(0,Xt.jsx)("div",{className:"rounded-md border border-rose-500/40 bg-rose-500/10 text-rose-200 text-sm px-3 py-2 mb-3","data-testid":"admin-jobs-list-error",children:h}),(0,Xt.jsx)("div",{className:"overflow-x-auto",children:(0,Xt.jsxs)(zF,{children:[(0,Xt.jsx)(UF,{children:(0,Xt.jsxs)(qF,{children:[(0,Xt.jsx)(WF,{children:"Title"}),(0,Xt.jsx)(WF,{children:"Company"}),(0,Xt.jsx)(WF,{children:"Location"}),(0,Xt.jsx)(WF,{children:"Source"}),(0,Xt.jsx)(WF,{children:"Visibility"}),(0,Xt.jsx)(WF,{children:"Created"}),(0,Xt.jsx)(WF,{children:"Last seen"})]})}),(0,Xt.jsxs)(VF,{children:[m&&(0,Xt.jsx)(qF,{children:(0,Xt.jsx)(HF,{colSpan:7,className:"py-6",children:(0,Xt.jsx)("div",{className:"flex items-center justify-center text-ndor-ink-muted",children:(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})})})}),!m&&0===((null===d||void 0===d||null===(e=d.items)||void 0===e?void 0:e.length)||0)&&(0,Xt.jsx)(qF,{children:(0,Xt.jsx)(HF,{colSpan:7,className:"py-6 text-center text-sm text-ndor-ink-muted","data-testid":"admin-jobs-list-empty",children:y||"__all__"!==k||"visible"!==_?"No jobs match this filter.":"No jobs found."})}),!m&&((null===d||void 0===d?void 0:d.items)||[]).map(e=>{const t=Boolean(e.hidden_by_staleness),n=Boolean(e.hidden_by_source_404);return(0,Xt.jsxs)(qF,{"data-testid":"admin-jobs-row-".concat(e.id),children:[(0,Xt.jsx)(HF,{className:"max-w-[300px]",children:(0,Xt.jsx)("a",{href:e.url||"#",target:"_blank",rel:"noreferrer noopener",className:"text-ndor-ink hover:text-ndor-gold truncate block",title:e.title,children:e.title||(0,Xt.jsx)("span",{className:"text-ndor-ink-muted italic",children:"(untitled)"})})}),(0,Xt.jsx)(HF,{className:"max-w-[180px] truncate",title:e.company||"",children:e.company||(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"\u2014"})}),(0,Xt.jsx)(HF,{className:"max-w-[180px] truncate",title:e.location||"",children:e.location||(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"\u2014"})}),(0,Xt.jsx)(HF,{children:(0,Xt.jsx)("span",{className:"font-mono text-xs text-ndor-ink-muted",children:e.source_kind||"\u2014"})}),(0,Xt.jsxs)(HF,{children:[t&&(0,Xt.jsxs)(Vw,{variant:"outline",className:"bg-amber-500/10 text-amber-200 border-amber-500/40 mr-1 text-[11px]",children:[(0,Xt.jsx)(Mg,{className:"h-3 w-3 mr-1"})," stale"]}),n&&(0,Xt.jsxs)(Vw,{variant:"outline",className:"bg-rose-500/10 text-rose-200 border-rose-500/40 text-[11px]",children:[(0,Xt.jsx)(Mg,{className:"h-3 w-3 mr-1"})," 404"]}),!t&&!n&&(0,Xt.jsxs)(Vw,{variant:"outline",className:"bg-emerald-500/10 text-emerald-200 border-emerald-500/40 text-[11px]",children:[(0,Xt.jsx)(zg,{className:"h-3 w-3 mr-1"})," visible"]})]}),(0,Xt.jsx)(HF,{className:"whitespace-nowrap text-xs text-ndor-ink-muted",children:cR(e.created_at)}),(0,Xt.jsx)(HF,{className:"whitespace-nowrap text-xs text-ndor-ink-muted",children:cR(e.last_seen_at)})]},e.id)})]})]})}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between mt-3 text-xs text-ndor-ink-muted","data-testid":"admin-jobs-pagination",children:[(0,Xt.jsx)("span",{children:d?"Showing page ".concat(d.page||x," of ").concat(I," \xb7 ").concat(lR(d.total||0)," total"):"\u2014"}),(0,Xt.jsxs)("div",{className:"flex items-center gap-1",children:[(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",onClick:()=>v(e=>Math.max(1,e-1)),disabled:x<=1||m,"data-testid":"admin-jobs-page-prev",children:(0,Xt.jsx)(Wn,{className:"h-4 w-4"})}),(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",onClick:()=>v(e=>e+1),disabled:!(null!==d&&void 0!==d&&d.has_more)||m,"data-testid":"admin-jobs-page-next",children:(0,Xt.jsx)(qn,{className:"h-4 w-4"})})]})]})]})]})]})}function mR(e){if(!e)return"\u2014";try{return new Date(e).toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"})}catch(t){return e.slice(0,10)}}function pR(e){let{status:t}=e;const n="live"===t?"state-pill state-pill--accepted":"draft"===t?"state-pill state-pill--draft":"state-pill state-pill--muted";return(0,Xt.jsx)("span",{className:n,children:t})}function hR(){return(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm animate-pulse",children:(0,Xt.jsxs)(Py,{className:"p-5 space-y-4",children:[(0,Xt.jsx)("div",{className:"h-4 w-48 rounded bg-ndor-surface-alt"}),(0,Xt.jsx)("div",{className:"h-3 w-3/4 rounded bg-ndor-surface-alt"}),(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)("div",{className:"h-3 w-full rounded bg-ndor-surface-alt"}),(0,Xt.jsx)("div",{className:"h-3 w-5/6 rounded bg-ndor-surface-alt"}),(0,Xt.jsx)("div",{className:"h-3 w-2/3 rounded bg-ndor-surface-alt"})]})]})})}function fR(e){var t;let{cluster:n,onOpen:a}=e;return(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm state-rail--pending","data-testid":"duplicate-cluster-".concat(n.cluster_id),children:(0,Xt.jsxs)(Py,{className:"p-5 space-y-4",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-3",children:[(0,Xt.jsx)(Mn,{className:"h-4 w-4 text-ndor-ink-muted"}),(0,Xt.jsxs)("div",{className:"text-sm font-medium text-ndor-ink font-mono-ui","data-testid":"duplicate-cluster-id-".concat(n.cluster_id),children:["Cluster #",n.cluster_id.slice(0,8)]}),(0,Xt.jsxs)("span",{className:"state-pill state-pill--pending","data-testid":"duplicate-cluster-size-".concat(n.cluster_id),children:[n.cluster_size," roles"]})]}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",onClick:()=>a(n),"data-testid":"duplicate-cluster-details-".concat(n.cluster_id),children:"View details \u2192"})]}),(null===(t=n.similarity_reasons)||void 0===t?void 0:t.length)>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mb-1.5",children:"Why flagged"}),(0,Xt.jsxs)("ul",{className:"space-y-0.5 text-xs text-ndor-ink-secondary","data-testid":"duplicate-cluster-reasons-".concat(n.cluster_id),children:[n.similarity_reasons.slice(0,4).map((e,t)=>(0,Xt.jsxs)("li",{className:"leading-relaxed",children:["\u2022 ",e]},t)),n.similarity_reasons.length>4&&(0,Xt.jsxs)("li",{className:"text-ndor-ink-muted italic",children:["+ ",n.similarity_reasons.length-4," more"]})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mb-2",children:"Roles in this cluster"}),(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge overflow-hidden",children:n.roles.map((e,t)=>(0,Xt.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 text-xs ".concat(t>0?"border-t border-ndor-edge":""),"data-testid":"duplicate-cluster-role-".concat(e.id),children:[(0,Xt.jsx)(pR,{status:e.status}),(0,Xt.jsx)("div",{className:"flex-1 min-w-0 truncate text-ndor-ink font-medium",children:e.title||"(untitled)"}),(0,Xt.jsx)("div",{className:"text-ndor-ink-secondary truncate w-[180px] shrink-0",children:e.organisation_name||"\u2014"}),(0,Xt.jsx)("div",{className:"text-ndor-ink-muted shrink-0 w-[80px] text-right",children:mR(e.created_at)})]},e.id))})]})]})})}function xR(e){var t;let{cluster:n,open:a,onOpenChange:r}=e;return n?(0,Xt.jsx)(rg,{open:a,onOpenChange:r,children:(0,Xt.jsxs)(lg,{className:"max-w-5xl","data-testid":"duplicate-cluster-detail-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{children:"Duplicate cluster"}),(0,Xt.jsxs)(mg,{children:["Read-only supervisory view of ",n.cluster_size," ","potentially-similar roles. No action can be taken from this view \u2014 open a role to review it."]})]}),(0,Xt.jsxs)("div",{className:"space-y-5",children:[(0,Xt.jsx)("div",{className:"grid gap-3 ".concat(2===n.roles.length?"grid-cols-2":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3"),"data-testid":"duplicate-cluster-grid",children:n.roles.map(e=>(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge p-3 space-y-2 text-xs bg-ndor-surface-alt/40","data-testid":"duplicate-cluster-role-detail-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,Xt.jsx)(pR,{status:e.status}),(0,Xt.jsx)(Et,{to:"/employer/roles/".concat(e.id),className:"text-ndor-ink-secondary hover:text-ndor-ink underline decoration-dotted underline-offset-2","data-testid":"duplicate-cluster-role-link-".concat(e.id),children:"Open role \u2192"})]}),(0,Xt.jsx)("div",{className:"text-sm font-semibold text-ndor-ink leading-tight",children:e.title||"(untitled)"}),(0,Xt.jsxs)("div",{className:"space-y-1.5 pt-1 border-t border-ndor-edge",children:[(0,Xt.jsx)(vR,{label:"Organisation",value:e.organisation_name}),(0,Xt.jsx)(vR,{label:"Domain",value:e.domain}),(0,Xt.jsx)(vR,{label:"Created",value:mR(e.created_at)}),(0,Xt.jsx)(vR,{label:"Role ID",value:(0,Xt.jsx)("span",{className:"font-mono-ui text-[10px]",children:e.id})})]})]},e.id))}),(null===(t=n.similarity_reasons)||void 0===t?void 0:t.length)>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mb-2",children:"Why these were flagged as similar"}),(0,Xt.jsx)("ul",{className:"space-y-1 text-xs text-ndor-ink-secondary","data-testid":"duplicate-cluster-detail-reasons",children:n.similarity_reasons.map((e,t)=>(0,Xt.jsxs)("li",{className:"leading-relaxed",children:["\u2022 ",e]},t))})]})]})]})}):null}function vR(e){let{label:t,value:n}=e;return(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted w-24 shrink-0",children:t}),(0,Xt.jsx)("span",{className:"text-ndor-ink flex-1 min-w-0 break-words text-right",children:n||"\u2014"})]})}
2function gR(){const[e,t]=(0,s.useState)(!0),[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(null),c=(0,s.useCallback)(async()=>{t(!0),a(null);try{const e=await(0,zt.n)("/api/admin/duplicate-clusters");i(e)}catch(pK){var e;a((null===pK||void 0===pK||null===(e=pK.data)||void 0===e?void 0:e.detail)||(null===pK||void 0===pK?void 0:pK.message)||"Failed to load clusters.")}finally{t(!1)}},[]);(0,s.useEffect)(()=>{c()},[c]);const d=(null===r||void 0===r?void 0:r.clusters)||[];return(0,Xt.jsxs)("div",{className:"max-w-5xl mx-auto space-y-6 p-6",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Ln,{className:"h-5 w-5 text-ndor-ink-muted"}),"Duplicate clusters"]}),(0,Xt.jsx)("p",{className:"mt-1 text-sm text-ndor-ink-muted",children:"Potential duplicate roles across organisations. Review only."})]}),!e&&!n&&r&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt px-3 py-2 text-[11px] text-ndor-ink-secondary leading-relaxed flex items-start gap-2","data-testid":"duplicate-clusters-summary",children:[(0,Xt.jsx)(zf,{className:"h-3.5 w-3.5 mt-0.5 text-ndor-ink-muted shrink-0"}),(0,Xt.jsxs)("span",{children:["Scanned ",r.total_roles_scanned," role",1===r.total_roles_scanned?"":"s",". Found"," ",r.total_clusters," cluster",1===r.total_clusters?"":"s",". Clusters show transitively-similar roles using the same scoring logic surfaced to employers."]})]}),e&&(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"duplicate-clusters-loading",children:[(0,Xt.jsx)(hR,{}),(0,Xt.jsx)(hR,{}),(0,Xt.jsx)(hR,{})]}),!e&&n&&(0,Xt.jsx)(Fy,{className:"border-rose-500/40 bg-rose-500/10 shadow-none","data-testid":"duplicate-clusters-error",children:(0,Xt.jsxs)(Py,{className:"py-4 flex items-start gap-2 text-sm text-rose-900",children:[(0,Xt.jsx)(ty,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"font-medium",children:"Could not load clusters"}),(0,Xt.jsx)("p",{className:"text-xs text-rose-200 mt-1",children:n}),(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:c,className:"mt-3","data-testid":"duplicate-clusters-retry",children:"Retry"})]})]})}),!e&&!n&&0===d.length&&(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"duplicate-clusters-empty",children:(0,Xt.jsxs)(Py,{className:"py-14 text-center",children:[(0,Xt.jsx)(Ln,{className:"mx-auto mb-3 h-8 w-8 text-ndor-ink-muted"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No duplicate clusters"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1 max-w-md mx-auto",children:"No overlapping roles detected."})]})}),!e&&!n&&d.length>0&&(0,Xt.jsx)("div",{className:"space-y-3","data-testid":"duplicate-clusters-list",children:d.map(e=>(0,Xt.jsx)(fR,{cluster:e,onOpen:l},e.cluster_id))}),(0,Xt.jsx)(xR,{cluster:o,open:!!o,onOpenChange:e=>{e||l(null)}})]})}
2const yR=[{key:"limits.free_daily_analyze_fit",label:"Free-tier daily Analyse-Fit quota",summary:"Per-user daily quota of free job analyses for Base / no-entitlement users. Resets at 00:00 UTC.",icon:Bw,unit:"",editable:!0,valueType:"int",min:0,max:50,step:1,confirmOnSave:!1},{key:"automation.flow_queue_threshold",label:"Flow queue admission threshold",summary:"Minimum fit_score (0\u2013100) required to admit a job into the Flow automation_queue.",icon:XN,unit:"/ 100",editable:!0,valueType:"int",min:0,max:100,step:1,confirmOnSave:!1},{key:"automation.max_users_per_tick",label:"Max users per automation tick",summary:"Hard cap on the number of users processed in a single Flow automation tick. Settings can lower but never raise the in-code ceiling.",icon:Tn,unit:"",editable:!0,valueType:"int",min:0,max:20,step:1,confirmOnSave:!0,spendBounded:!0},{key:"automation.max_jobs_per_user_per_tick",label:"Max jobs per user per tick",summary:"Hard cap on jobs analysed per user per tick. Bounds LLM spend per tick.",icon:Cn,unit:"",editable:!0,valueType:"int",min:0,max:3,step:1,confirmOnSave:!0,spendBounded:!0},{key:"automation.candidate_pool_size",label:"Candidate-pool window size",summary:"Per-tick candidate-jobs read window before per-user filtering.",icon:zn,unit:"",editable:!0,valueType:"int",min:0,max:100,step:1,confirmOnSave:!0,spendBounded:!0},{key:"LIMITS.CV_GENERATION_MIN_FIT",label:"Analyse Fit minimum score",summary:'Minimum Overall Fit / Analyse-Fit score (0\u2013100, holistic) required to allow tailored-CV generation. Tied to fit_score, NOT the strict NDOR CV verdict (cv_sub_score) \u2014 a low CV verdict reflects CV-writing quality, not candidate suitability. Below this floor the wizard refuses to call the LLM and asks the user to pick a better-matched role or upload a more relevant Source CV. final_decision == "reject" still blocks regardless of this value.',icon:XN,unit:"/ 100",editable:!0,valueType:"int",min:0,max:100,step:1,confirmOnSave:!1}],bR=new Set(yR.map(e=>e.key));function wR(e){if(!e)return"\u2014";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function jR(e){if(null!==(null===e||void 0===e?void 0:e.value_int)&&void 0!==(null===e||void 0===e?void 0:e.value_int))return{value:String(e.value_int),kind:"int"};if(null!==e&&void 0!==e&&e.value_text)return{value:e.value_text,kind:"text"};if(null!==(null===e||void 0===e?void 0:e.value_json)&&void 0!==(null===e||void 0===e?void 0:e.value_json))try{return{value:JSON.stringify(e.value_json,null,2),kind:"json"}}catch(t){return{value:"[unserialisable JSON]",kind:"json"}}return{value:"\u2014",kind:"empty"}}function kR(e){var t,n;let{meta:a,row:r,fallback:i,onSaved:o}=e;const l=a.icon||Rn,c=!!r,d=c?jR(r):{value:String(null!==i&&void 0!==i?i:"\u2014"),kind:"fallback"}
2,[u,m]=(0,s.useState)(!1),[p,h]=(0,s.useState)(String(c?null!==(t=r.value_int)&&void 0!==t?t:"":null!==i&&void 0!==i?i:"")),[f,x]=(0,s.useState)(!1),[v,g]=(0,s.useState)(null),[y,b]=(0,s.useState)(!1);(0,s.useEffect)(()=>{var e;u||h(String(c?null!==(e=r.value_int)&&void 0!==e?e:"":null!==i&&void 0!==i?i:""))},[r,c,i,u]);const w=()=>{var e;m(!1),g(null),h(String(c?null!==(e=r.value_int)&&void 0!==e?e:"":null!==i&&void 0!==i?i:""))},j=()=>{const e=(()=>{if(""===p||null===p||void 0===p)return"Value required.";const e=Number(p);return Number.isFinite(e)?Number.isInteger(e)?"number"===typeof a.min&&e<a.min?"Must be \u2265 ".concat(a.min,"."):"number"===typeof a.max&&e>a.max?"Must be \u2264 ".concat(a.max," (in-code ceiling)."):null:"Must be an integer.":"Must be a number."})();e?g(e):a.confirmOnSave?b(!0):k()},k=async()=>{x(!0),g(null),b(!1);const e=Number(p);try{const t=await(0,zt.n)("/api/admin/settings/".concat(encodeURIComponent(a.key)),{method:"PUT",body:{value_int:e}}),n=(null===t||void 0===t?void 0:t.setting)||t;fy.success("Updated \xb7 ".concat(a.label),{description:"".concat(a.key," \u2192 ").concat(e)}),m(!1),o&&o(n)}catch(mK){const t=(null===mK||void 0===mK?void 0:mK.message)||"Save failed.";g(t),fy.error("Save failed",{description:t})}finally{x(!1)}};return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface brand-card-hover","data-testid":"admin-setting-card-".concat(a.key),children:[(0,Xt.jsxs)(Py,{className:"p-5 sm:p-6 space-y-4",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-3 min-w-0",children:[(0,Xt.jsx)("div",{className:"w-10 h-10 rounded-lg bg-ndor-info-light text-ndor-info flex items-center justify-center border border-ndor-edge shrink-0",children:(0,Xt.jsx)(l,{className:"h-5 w-5"})}),(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("h3",{className:"text-sm sm:text-[15px] font-serif-display font-semibold text-ndor-ink leading-snug","data-testid":"admin-setting-label-".concat(a.key),children:a.label}),(0,Xt.jsx)("p",{className:"text-[10px] sm:text-[11px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui mt-0.5 break-all","data-testid":"admin-setting-key-".concat(a.key),children:a.key})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[c?(0,Xt.jsx)(Vw,{variant:"outline",className:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200 text-[10px] uppercase tracking-wide whitespace-nowrap","data-testid":"admin-setting-source-".concat(a.key),children:"From DB"}):(0,Xt.jsx)(Vw,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 text-amber-200 text-[10px] uppercase tracking-wide whitespace-nowrap","data-testid":"admin-setting-source-".concat(a.key),children:"Default"}),a.editable&&!u?(0,Xt.jsx)(Rr,{variant:"ghost",size:"icon",className:"h-7 w-7 text-ndor-ink-muted hover:text-ndor-ink",onClick:()=>{g(null),m(!0)},"aria-label":"Edit ".concat(a.label),title:"Edit value","data-testid":"admin-setting-edit-".concat(a.key),children:(0,Xt.jsx)(JN,{className:"h-3.5 w-3.5"})}):null]})]}),u?(0,Xt.jsxs)("div",{className:"space-y-2.5","data-testid":"admin-setting-editor-".concat(a.key),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Ag,{type:"number",inputMode:"numeric",step:null!==(n=a.step)&&void 0!==n?n:1,min:a.min,max:a.max,value:p,onChange:e=>{h(e.target.value),g(null)},onKeyDown:e=>{"Enter"===e.key&&j(),"Escape"===e.key&&w()},disabled:f,autoFocus:!0,className:"h-11 w-28 text-2xl font-serif-display font-semibold tabular-nums","aria-label":"".concat(a.label," value"),"data-testid":"admin-setting-input-".concat(a.key)}),a.unit?(0,Xt.jsx)("span",{className:"text-sm text-ndor-ink-muted font-mono-ui",children:a.unit}):null,(0,Xt.jsxs)("div",{className:"flex items-center gap-1 ml-auto",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"default",onClick:j,disabled:f,className:"h-9 bg-ndor-ink text-ndor-canvas hover:bg-ndor-ink/90","data-testid":"admin-setting-save-".concat(a.key),children:[f?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):(0,Xt.jsx)(Zm,{className:"h-3.5 w-3.5 mr-1.5"}),"Save"]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:w,disabled:f,className:"h-9","data-testid":"admin-setting-cancel-".concat(a.key),children:[(0,Xt.jsx)(xh,{className:"h-3.5 w-3.5 mr-1"}),"Cancel"]})]})]}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted font-mono-ui",children:["Allowed range: ",a.min,"\u2013",a.max,a.spendBounded?" (in-code ceiling \u2014 settings can lower spend but not exceed it)":""]}),v?(0,Xt.jsxs)("p",{className:"text-[12px] text-ndor-error flex items-center gap-1.5","data-testid":"admin-setting-error-".concat(a.key),children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 shrink-0"}),v]}):null]}
2):(0,Xt.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,Xt.jsx)("p",{className:"text-3xl sm:text-4xl font-serif-display font-semibold text-ndor-ink tabular-nums","data-testid":"admin-setting-value-".concat(a.key),children:d.value}),a.unit?(0,Xt.jsx)("span",{className:"text-sm text-ndor-ink-muted font-mono-ui",children:a.unit}):null]}),(0,Xt.jsx)("p",{className:"text-xs sm:text-sm text-ndor-ink-secondary leading-relaxed","data-testid":"admin-setting-summary-".concat(a.key),children:a.summary}),c&&r.description&&r.description!==a.summary?(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed border-t border-ndor-edge pt-3",children:[(0,Xt.jsx)("span",{className:"uppercase tracking-[0.18em] font-mono-ui mr-1.5",children:"DB note:"}),r.description]}):null,(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 pt-1 text-[11px] text-ndor-ink-muted font-mono-ui",children:[(0,Xt.jsxs)("span",{"data-testid":"admin-setting-updated-".concat(a.key),children:["Updated: ",c?wR(r.updated_at):"never (default)"]}),c&&r.updated_by?(0,Xt.jsxs)("span",{className:"truncate max-w-[260px]",title:r.updated_by,children:["By: ",r.updated_by.slice(0,8),"\u2026"]}):null]})]}),(0,Xt.jsx)(rg,{open:y,onOpenChange:e=>!f&&b(e),children:(0,Xt.jsxs)(lg,{className:"sm:max-w-[440px]","data-testid":"admin-setting-confirm-".concat(a.key),children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 text-amber-500"}),"Confirm change"]}),(0,Xt.jsxs)(mg,{className:"text-sm text-ndor-ink-secondary leading-relaxed pt-2 space-y-2",children:[(0,Xt.jsxs)("span",{className:"block",children:["You're about to change ",(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:a.label}),"."]}),(0,Xt.jsxs)("span",{className:"block",children:[(0,Xt.jsx)("code",{className:"text-[11px] px-1.5 py-0.5 rounded bg-ndor-surface-alt",children:a.key}),": ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:d.value})," \u2192 ",(0,Xt.jsx)("span",{className:"font-mono-ui font-semibold text-ndor-ink",children:p})]}),a.spendBounded?(0,Xt.jsxs)("span",{className:"block text-[12px] text-amber-200 bg-amber-500/10 border border-amber-500/40 rounded p-2 mt-2",children:["This is a spend-bounded automation cap. Settings can lower spend but the in-code ceiling (",a.max,") still applies as the final guard."]}):null]})]}),(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:()=>b(!1),disabled:f,"data-testid":"admin-setting-confirm-cancel-".concat(a.key),children:"Cancel"}),(0,Xt.jsxs)(Rr,{variant:"default",onClick:k,disabled:f,className:"bg-ndor-ink text-ndor-canvas hover:bg-ndor-ink/90","data-testid":"admin-setting-confirm-save-".concat(a.key),children:[f?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin mr-2"}):null,"Confirm save"]})]})]})})]})}function NR(e){let{row:t}=e;const n=jR(t);return(0,Xt.jsxs)("div",{className:"border border-ndor-edge bg-ndor-surface rounded-lg p-4 space-y-2","data-testid":"admin-other-setting-".concat(t.key),children:[(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui break-all",children:t.key}),(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge text-[10px] uppercase tracking-wide w-fit",children:n.kind})]}),(0,Xt.jsx)("pre",{className:"text-sm text-ndor-ink whitespace-pre-wrap break-words tabular-nums font-mono-ui m-0",children:n.value}),t.description?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:t.description}):null,(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted font-mono-ui pt-1 border-t border-ndor-edge",children:["Updated: ",wR(t.updated_at)]})]})}function _R(){const[e,t]=(0,s.useState)([]),[n,a]=(0,s.useState)(!0),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(!1),[c,d]=(0,s.useState)(null),u=(0,s.useCallback)(async()=>{a(!0),i(null),l(!1);try{const e=await(0,zt.n)("/api/admin/settings"),n=Array.isArray(e)?e:(null===e||void 0===e?void 0:e.settings)||[];t(n),d(new Date)}catch(mK){403===(null===mK||void 0===mK?void 0:mK.status)?l(!0):i((null===mK||void 0===mK?void 0:mK.message)||"Failed to load settings.")}finally{a(!1)}},[]);(0,s.useEffect)(()=>{u()},[u]);const m=(0,s.useMemo)(()=>{const t=new Map;for(const n of e)t.set(n.key,n);return t},[e]),p=(0,s.useMemo)(()=>e.filter(e=>!bR.has(e.key)),[e]);return o?(0,Xt.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center space-y-3","data-testid":"admin-settings-forbidden",children:[(0,Xt.jsx)(mb,{className:"h-10 w-10 text-ndor-warning"}),(0,Xt.jsx)("h2",{className:"text-xl font-serif-display font-semibold text-ndor-ink",children:"Admin only"}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-secondary max-w-md",children:["You don't have permission to view this page. If you believe this is wrong, ask another admin to grant your account",(0,Xt.jsx)("code",{className:"mx-1 px-1 py-0.5 rounded bg-ndor-surface-alt text-xs",children:"profiles.is_admin = true"}),"via the database."]})]}):(0,Xt.jsxs)("div",{"data-testid":"admin-settings-page",className:"space-y-6 sm:space-y-8",children:[(0,Xt.jsxs)("header",{className:"flex flex-col sm:flex-row sm:items-end sm:justify-between gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui",children:"Admin \xb7 Operations"}),(0,Xt.jsx)("h1",{className:"mt-1 text-2xl sm:text-3xl font-serif-display font-semibold tracking-tight text-ndor-ink",children:"Runtime Settings"}),(0,Xt.jsxs)("p",{className:"mt-1.5 text-sm text-ndor-ink-secondary max-w-2xl",children:["Read-only view of ",(0,Xt.jsx)("code",{className:"px-1 py-0.5 rounded bg-ndor-surface-alt text-xs",children:"app_settings"}),". The 5 RC 1.38.A operational keys are pinned at the top. Edits are still made via"," ",(0,Xt.jsxs)("code",{className:"px-1 py-0.5 rounded bg-ndor-surface-alt text-xs",children:["PUT /api/admin/settings/","{key}"]})," ","(admin auth required)."]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-3",children:[c?(0,Xt.jsxs)("span",{className:"text-[11px] text-ndor-ink-muted font-mono-ui hidden sm:inline",children:["Fetched: ",c.toLocaleTimeString()]}):null,(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:u,disabled:n,className:"border-ndor-edge","data-testid":"admin-settings-refresh",children:[n?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-2"}):(0,Xt.jsx)(Kg,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})]}
2),r?(0,Xt.jsx)("div",{className:"rounded-lg border border-ndor-error-border bg-ndor-error-light text-ndor-error p-4 text-sm","data-testid":"admin-settings-error",children:r}):null,(0,Xt.jsxs)("section",{className:"space-y-3 sm:space-y-4","data-testid":"admin-settings-pinned",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)("h2",{className:"text-sm sm:text-base font-serif-display font-semibold text-ndor-ink",children:"RC 1.38.A operational levers"}),(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge text-[10px] uppercase tracking-wide",children:"5 keys"})]}),n&&0===e.length?(0,Xt.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:yR.map(e=>(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface animate-pulse h-44","aria-hidden":!0},e.key))}):(0,Xt.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:yR.map(e=>(0,Xt.jsx)(kR,{meta:e,row:m.get(e.key),onSaved:()=>{u()}},e.key))})]}),p.length>0?(0,Xt.jsxs)("section",{className:"space-y-3 sm:space-y-4","data-testid":"admin-settings-other",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)("h2",{className:"text-sm sm:text-base font-serif-display font-semibold text-ndor-ink",children:"Other settings"}),(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-ndor-edge text-[10px] uppercase tracking-wide",children:[p.length," key",1===p.length?"":"s"]})]}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:p.map(e=>(0,Xt.jsx)(NR,{row:e},e.key))})]}):null,(0,Xt.jsxs)("section",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt/50 p-4 sm:p-5 flex items-start gap-3","data-testid":"admin-settings-help",children:[(0,Xt.jsx)(zf,{className:"h-4 w-4 text-ndor-info shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{className:"text-xs sm:text-sm text-ndor-ink-secondary space-y-1.5",children:[(0,Xt.jsxs)("p",{children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Inline editing for the 6 operational levers"})," ","is enabled. Changes go through"," ",(0,Xt.jsx)("code",{className:"px-1 py-0.5 rounded bg-ndor-surface-alt text-xs",children:"PUT /api/admin/settings/{key}"})," ","(admin-only, server-side validated). Spend-bounded automation caps require an explicit confirmation step. The 60-second per-process settings cache is invalidated automatically on each save."]}),(0,Xt.jsxs)("p",{children:["Any other ",(0,Xt.jsx)("code",{className:"px-1 py-0.5 rounded bg-ndor-surface-alt text-xs",children:"app_settings"})," ","row remains read-only here; use curl for those:"]}),(0,Xt.jsx)("pre",{className:"rounded bg-ndor-surface border border-ndor-edge p-2.5 text-[11px] text-ndor-ink overflow-x-auto font-mono-ui m-0",children:'curl -X PUT "$API_URL/api/admin/settings/<key>" \\\n -H "Authorization: Bearer $ADMIN_JWT" \\\n -H "Content-Type: application/json" \\\n -d \'{"value_int": 7}\''})]})]})]})}const DR=wn("user-check",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]),CR=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function AR(){var e,t,n;const[a,r]=(0,s.useState)(""),[i,o]=(0,s.useState)(!1),[l,d]=(0,s.use
2State)(null),[u,m]=(0,s.useState)(null),[p,h]=(0,s.useState)(100),[f,x]=(0,s.useState)(""),[v,g]=(0,s.useState)(!1),[y,b]=(0,s.useState)(null),w=(0,s.useCallback)(async()=>{const e=a.trim();if(e){o(!0),b(null);try{let a=null,i=null,l=null;if("string"===typeof(n=e)&&CR.test(n.trim())){a=e;try{const{data:t}=await Mt.supabase.from("profiles").select("id, full_name").eq("id",e).maybeSingle();t&&(l=t.full_name||null)}catch(r){}}else{if(!function(e){return"string"===typeof e&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim())}(e))return fy.error("Input must be a valid email or a UUID user_id."),void o(!1);try{const n=await(0,zt.n)("/api/admin/users/lookup-rich",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});var t;if(a=n.user_id,i=n.email||null,l=n.full_name||null,n.plan||n.credits,d({user_id:a,email:i,full_name:l,plan:n.plan||null,credits:n.credits||null}),n.credits)return m({included_usage_remaining:n.credits.included_remaining,extra_usage_remaining:n.credits.extra_remaining,plan_code:(null===(t=n.plan)||void 0===t?void 0:t.plan_code)||null,cycle_ends_at:n.credits.cycle_ends_at||null}),void o(!1)}catch(mK){const t=404===(null===mK||void 0===mK?void 0:mK.status)?"No user found with that email. Double-check spelling, or try the user_id directly.":"Lookup failed: ".concat((null===mK||void 0===mK?void 0:mK.message)||"unknown");return fy.error(t),void o(!1)}}let c=null;try{const{data:e}=await Mt.supabase.from("user_usage").select("included_usage_remaining, extra_usage_remaining, plan_code, cycle_ends_at").eq("user_id",a).maybeSingle();c=e||null}catch(s){}d({user_id:a,email:i,full_name:l}),m(c)}catch(mK){fy.error("Lookup failed: "+((null===mK||void 0===mK?void 0:mK.message)||"unknown"))}finally{o(!1)}var n}else fy.error("Enter an email or user_id (UUID).")},[a]),j=(0,s.useCallback)(async()=>{if(null===l||void 0===l||!l.user_id)return;const e=Number.parseInt(p,10);if(!Number.isFinite(e)||e<=0)return void fy.error("Amount must be a positive integer.");const t=(f||"").trim();if(t.length<3)fy.error("Reason must be at least 3 characters.");else{g(!0);try{const n=await(0,zt.n)("/api/admin/users/".concat(l.user_id,"/usage-grant"),{method:"POST",body:JSON.stringify({amount:e,reason:t})}),a={included_usage_remaining:n.included_usage_remaining,extra_usage_remaining:n.extra_usage_remaining},r={included_usage_remaining:n.included_usage_remaining,extra_usage_remaining:n.extra_usage_remaining-n.granted};b({before:r,after:a,granted:n.granted,reason:n.reason}),m(e=>(0,c.A)((0,c.A)({},e||{}),a)),fy.success("Granted ".concat(n.granted," extra usage."))}catch(mK){var n;const t=(null===mK||void 0===mK||null===(n=mK.data)||void 0===n?void 0:n.detail)||(null===mK||void 0===mK?void 0:mK.message)||"Grant failed";fy.error("string"===typeof t?t:JSON.stringify(t))}finally{g(!1)}}},[l,p,f]);return(0,Xt.jsxs)("div",{className:"space-y-6 p-6 max-w-3xl","data-testid":"admin-users-page",children:[(0,Xt.jsxs)("header",{className:"space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Tn,{className:"h-5 w-5 text-ndor-ink-muted"}),(0,Xt.jsx)("h1",{className:"text-xl sm:text-2xl font-serif-display text-ndor-ink leading-tight",children:"User management"})]}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-secondary",children:["Look up a user by email or ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"user_id"}),", view their entitlement, and grant extra usage. Backed by ",(0,Xt.jsx)("span",{className:"font-mono-ui text-xs",children:"POST /api/admin/users/{user_id}/usage-grant"}),"."]})]}),(0,Xt.jsxs)(Fy,{children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Find user"}),(0,Xt.jsx)(Ty,{children:"Email or user_id (UUID)."})]}),(0,Xt.jsx)(Py,{className:"space-y-3",children:(0,Xt.jsxs)("div",{className:"flex gap-2",children:[(0,Xt.jsx)(Ag,{"data-testid":"admin-users-query-input",placeholder:"[email protected] or 552c3e57-50a5-427f-9c6b-8419d7d78cb0",value:a,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"===e.key&&w()},className:"font-mono-ui text-sm"}),(0,Xt.jsxs)(Rr,{"data-testid":"admin-users-lookup-btn",onClick:w,disabled:i||!a.trim(),children:[i?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}):(0,Xt.jsx)(wC,{className:"h-4 w-4"}),(0,Xt.jsx)("span",{className:"ml-2 hidden sm:inline",children:"Look up"})]}),l&&(0,Xt.jsx)(Rr,{variant:"ghost",onClick:()=>{d(null),m(null),b(null),x(""),h(100)},"data-testid":"admin-users-reset-btn",children:"Reset"})]})})]}),l&&(0,Xt.jsxs)(Fy,{"data-testid":"admin-users-target-card",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base",children:[(0,Xt.jsx)(DR,{className:"h-4 w-4 text-ndor-ink-muted"}),"Selected user"]})}),(0,Xt.jsxs)(Py,{className:"space-y-3 text-sm",children:[(0,Xt.jsxs)("dl",{className:"grid grid-cols-[8rem_1fr] gap-y-1",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted",children:"user_id"}),(0,Xt.jsx)("dd",{className:"font-mono-ui text-xs break-all","data-testid":"admin-users-target-id",children:l.user_id}),l.email&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted",children:"email"}),(0,Xt.jsx)("dd",{children:l.email})]}),l.full_name&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted",children:"name"}),(0,Xt.jsx)("dd",{children:l.full_name})]})]}),(0,Xt.jsxs)("div",{className:"border-t border-ndor-edge pt-3",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-[0.14em] text-ndor-ink-muted mb-2",children:"Current state"}),l.plan?(0,Xt.jsxs)("dl",{className:"grid grid-cols-[12rem_1fr] gap-y-1 text-sm mb-3","data-testid":"admin-users-plan",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted",children:"plan"}),(0,Xt.jsxs)("dd",{className:"font-mono-ui",children:[(l.plan.plan_code||"base").toUpperCase(),l.plan.billing_period?" \xb7 ".concat(l.plan.billing_period):""]}),(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted",children:"status"}),(0,Xt.jsx)("dd",{className:"font-mono-ui",children:l.plan.status||"none"}),l.plan.access_expires_at&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted",children:"expires"}),(0,Xt.jsx)("dd",{className:"font-mono-ui text-xs",children:new Date(l.plan.access_expires_at).toLocaleStr
2ing()})]})]}):null,u?(0,Xt.jsxs)("dl",{className:"grid grid-cols-[12rem_1fr] gap-y-1 text-sm","data-testid":"admin-users-usage",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted",children:"included_usage_remaining"}),(0,Xt.jsx)("dd",{className:"font-mono-ui tabular-nums",children:null!==(e=u.included_usage_remaining)&&void 0!==e?e:0}),(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted",children:"extra_usage_remaining"}),(0,Xt.jsx)("dd",{className:"font-mono-ui tabular-nums",children:null!==(t=u.extra_usage_remaining)&&void 0!==t?t:0}),u.plan_code&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted",children:"plan_code"}),(0,Xt.jsx)("dd",{className:"font-mono-ui",children:u.plan_code})]})]}):(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted italic flex items-center gap-1.5",children:[(0,Xt.jsx)(Oy,{className:"h-3 w-3"}),"Cross-user usage read not permitted by RLS, or no row yet. The grant response will return authoritative figures."]})]})]})]}),l&&(0,Xt.jsx)(SR,{userId:l.user_id,currentPlan:(null===l||void 0===l||null===(n=l.plan)||void 0===n?void 0:n.plan_code)||"base",onChanged:()=>w()}),l&&(0,Xt.jsxs)(Fy,{"data-testid":"admin-users-grant-card",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Grant extra usage"}),(0,Xt.jsxs)(Ty,{children:["Increments ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"extra_usage_remaining"})," only. Plan, included usage, and billing period are unchanged."]})]}),(0,Xt.jsxs)(Py,{className:"space-y-3",children:[(0,Xt.jsxs)("div",{className:"grid sm:grid-cols-[8rem_1fr] gap-3",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"amount",className:"text-xs uppercase tracking-[0.14em] text-ndor-ink-muted",children:"Amount"}),(0,Xt.jsx)(Ag,{id:"amount","data-testid":"admin-users-amount-input",type:"number",min:1,value:p,onChange:e=>h(e.target.value),className:"font-mono-ui tabular-nums"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"reason",className:"text-xs uppercase tracking-[0.14em] text-ndor-ink-muted",children:"Reason (audit)"}),(0,Xt.jsx)(Hw,{id:"reason","data-testid":"admin-users-reason-input",placeholder:"e.g. RC 1.41 e2e smoke regression \u2014 temporary top-up for items 7\u201311",value:f,onChange:e=>x(e.target.value),rows:2,maxLength:500})]})]}),(0,Xt.jsxs)(Rr,{"data-testid":"admin-users-grant-btn",onClick:j,disabled:v||!(null!==l&&void 0!==l&&l.user_id)||(f||"").trim().length<3,children:[v?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}):(0,Xt.jsx)(zy,{className:"h-4 w-4"}),(0,Xt.jsxs)("span",{className:"ml-2",children:["Grant ",Number.parseInt(p,10)||0," extra usage"]})]})]})]}),y&&(0,Xt.jsxs)(Fy,{className:"border-ndor-edge","data-testid":"admin-users-result-card",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base",children:[(0,Xt.jsx)(Kg,{className:"h-4 w-4 text-emerald-500"}),"Grant complete"]}),(0,Xt.jsxs)(Ty,{children:["Granted ",(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums",children:y.granted}),". Reason: ",(0,Xt.jsx)("span",{className:"italic",children:y.reason}),"."]})]}),(0,Xt.jsx)(Py,{children:(0,Xt.jsxs)("table",{className:"text-sm w-full",children:[(0,Xt.jsx)("thead",{className:"text-xs uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{children:[(0,Xt.jsx)("th",{className:"text-left py-1",children:"Field"}),(0,Xt.jsx)("th",{className:"text-right py-1",children:"Before"}),(0,Xt.jsx)("th",{className:"text-right py-1",children:"After"}),(0,Xt.jsx)("th",{className:"text-right py-1",children:"\u0394"})]})}),(0,Xt.jsxs)("tbody",{className:"font-mono-ui tabular-nums",children:[(0,Xt.jsxs)("tr",{className:"border-t border-ndor-edge",children:[(0,Xt.jsx)("td",{className:"py-1 text-ndor-ink-muted",children:"included_usage_remaining"}),(0,Xt.jsx)("td",{className:"py-1 text-right","data-testid":"admin-users-result-included-before",children:y.before.included_usage_remaining}),(0,Xt.jsx)("td",{className:"py-1 text-right","data-testid":"admin-users-result-included-after",children:y.after.included_usage_remaining}),(0,Xt.jsx)("td",{className:"py-1 text-right text-ndor-ink-muted",children:"0"})]}),(0,Xt.jsxs)("tr",{className:"border-t border-ndor-edge",children:[(0,Xt.jsx)("td",{className:"py-1 text-ndor-ink-muted",children:"extra_usage_remaining"}),(0,Xt.jsx)("td",{className:"py-1 text-right","data-testid":"admin-users-result-extra-before",children:y.before.extra_usage_remaining}),(0,Xt.jsx)("td",{className:"py-1 text-right text-emerald-500","data-testid":"admin-users-result-extra-after",children:y.after.extra_usage_remaining}),(0,Xt.jsxs)("td",{className:"py-1 text-right text-emerald-500",children:["+",y.granted]})]})]})]})})]}),(0,Xt.jsxs)("footer",{className:"text-xs text-ndor-ink-muted italic flex items-start gap-1.5 pt-2 border-t border-ndor-edge",children:[(0,Xt.jsx)(mb,{className:"h-3 w-3 mt-0.5"}),"Plan overrides bypass Stripe by design \u2014 they set ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"user_entitlements"})," directly. Every change writes a ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"credit_ledger"})," row with"," ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"action=admin_plan_override"}),". Server-side"," ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"require_admin"})," is the authoritative gate."]})]})}function SR(e){let{userId:t,currentPlan:n,onChanged:a}=e;
2const[r,i]=(0,s.useState)("base"===n?"flow":n),[o,l]=(0,s.useState)("monthly"),[c,d]=(0,s.useState)("30"),[u,m]=(0,s.useState)(""),[p,h]=(0,s.useState)(!1),f=(0,s.useCallback)(async()=>{const e=(u||"").trim();if(e.length<3)fy.error("Reason is required (\u2265 3 characters) \u2014 written to the audit ledger.");else if("focus"!==r&&"flow"!==r||o){h(!0);try{var n,s;const i=await(0,zt.n)("/api/admin/users/".concat(t,"/plan-override"),{method:"POST",body:JSON.stringify({plan_code:r,billing_period:"base"===r?null:o,duration_days:c&&String(c).trim()?Number.parseInt(c,10):null,reason:e})}),l=null!==i&&void 0!==i&&null!==(n=i.new)&&void 0!==n&&n.access_expires_at?" \xb7 expires ".concat(new Date(i.new.access_expires_at).toLocaleDateString()):"";fy.success("Plan set to ".concat(((null===i||void 0===i||null===(s=i.new)||void 0===s?void 0:s.plan_code)||r).toUpperCase()).concat(l)),m(""),null===a||void 0===a||a()}catch(mK){var i;const t=(null===mK||void 0===mK||null===(i=mK.data)||void 0===i?void 0:i.detail)||(null===mK||void 0===mK?void 0:mK.message)||"Override failed";fy.error("string"===typeof t?t:JSON.stringify(t))}finally{h(!1)}}else fy.error("Billing period is required for Focus/Flow.")},[t,r,o,c,u,a]),x=(0,s.useCallback)(async()=>{if(window.confirm("Revoke admin plan override for this user? They will revert to base.")){h(!0);try{await(0,zt.n)("/api/admin/users/".concat(t,"/plan-override"),{method:"DELETE"}),fy.success("Plan override revoked \u2014 user reverted to base."),null===a||void 0===a||a()}catch(mK){var e;const n=(null===mK||void 0===mK||null===(e=mK.data)||void 0===e?void 0:e.detail)||(null===mK||void 0===mK?void 0:mK.message)||"Revoke failed";fy.error("string"===typeof n?n:JSON.stringify(n))}finally{h(!1)}}},[t,a]);return(0,Xt.jsxs)(Fy,{"data-testid":"admin-users-plan-override-card",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base",children:[(0,Xt.jsx)(mb,{className:"h-4 w-4 text-ndor-gold"}),"Plan override"]}),(0,Xt.jsxs)(Ty,{children:["Sets ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"user_entitlements"})," directly \u2014 Stripe is never touched. Every change is audited to ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"credit_ledger"}),"."]})]}),(0,Xt.jsxs)(Py,{className:"space-y-3",children:[(0,Xt.jsxs)("div",{className:"grid sm:grid-cols-3 gap-3",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"po-plan",className:"text-xs uppercase tracking-[0.14em] text-ndor-ink-muted",children:"Plan"}),(0,Xt.jsxs)("select",{id:"po-plan",value:r,onChange:e=>i(e.target.value),disabled:p,className:"w-full h-9 px-2 rounded-md border border-ndor-edge bg-ndor-canvas text-sm font-mono-ui","data-testid":"admin-users-plan-override-plan",children:[(0,Xt.jsx)("option",{value:"base",children:"base"}),(0,Xt.jsx)("option",{value:"focus",children:"focus"}),(0,Xt.jsx)("option",{value:"flow",children:"flow"})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"po-period",className:"text-xs uppercase tracking-[0.14em] text-ndor-ink-muted",children:"Period"}),(0,Xt.jsxs)("select",{id:"po-period",value:o,onChange:e=>l(e.target.value),disabled:p||"base"===r,className:"w-full h-9 px-2 rounded-md border border-ndor-edge bg-ndor-canvas text-sm font-mono-ui disabled:opacity-50","data-testid":"admin-users-plan-override-period",children:[(0,Xt.jsx)("option",{value:"weekly",children:"weekly"}),(0,Xt.jsx)("option",{value:"monthly",children:"monthly"}),(0,Xt.jsx)("option",{value:"annual",children:"annual"})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"po-days",className:"text-xs uppercase tracking-[0.14em] text-ndor-ink-muted",children:"Days (blank = forever)"}),(0,Xt.jsx)(Ag,{id:"po-days",type:"number",min:1,max:3650,placeholder:"30",value:c,onChange:e=>d(e.target.value),disabled:p,"data-testid":"admin-users-plan-override-days",className:"font-mono-ui tabular-nums"})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{htmlFor:"po-reason",className:"text-xs uppercase tracking-[0.14em] text-ndor-ink-muted",children:"Reason (audit)"}),(0,Xt.jsx)(Ag,{id:"po-reason",type:"text",placeholder:"Reviewer comp \xb7 TAAFT 2026-05",value:u,onChange:e=>m(e.target.value),disabled:p,maxLength:240,"data-testid":"admin-users-plan-override-reason"})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,Xt.jsxs)(Rr,{"data-testid":"admin-users-plan-override-apply",onClick:f,disabled:p||(u||"").trim().length<3,children:[p?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}):(0,Xt.jsx)(zy,{className:"h-4 w-4"}),(0,Xt.jsx)("span",{className:"ml-2",children:"Apply override"})]}),n&&"base"!==n?(0,Xt.jsx)(Rr,{variant:"outline","data-testid":"admin-users-plan-override-revoke",onClick:x,disabled:p,children:"Revoke override"}):null]})]})]})}const ER=["__scopeTabs","value","onValueChange","defaultValue","orientation","dir","activationMode"],FR=["__scopeTabs","loop"],RR=["__scopeTabs","value","disabled"],IR=["__scopeTabs","value","forceMount","children"];var TR="Tabs",[PR,OR]=js(TR,[oc]),BR=oc(),[LR,MR]=PR(TR),zR=s.forwardRef((e,t)=>
2{const{__scopeTabs:n,value:a,onValueChange:r,defaultValue:s,orientation:i="horizontal",dir:o,activationMode:d="automatic"}=e,u=l(e,ER),m=Qs(o),[p,h]=_s({prop:a,onChange:r,defaultProp:null!==s&&void 0!==s?s:"",caller:TR});return(0,Xt.jsx)(LR,{scope:n,baseId:_i(),value:p,onValueChange:h,orientation:i,dir:m,activationMode:d,children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({dir:m,"data-orientation":i},u),{},{ref:t}))})});zR.displayName=TR;var UR="TabsList",VR=s.forwardRef((e,t)=>{const{__scopeTabs:n,loop:a=!0}=e,r=l(e,FR),s=MR(UR,n),i=BR(n);return(0,Xt.jsx)(xc,(0,c.A)((0,c.A)({asChild:!0},i),{},{orientation:s.orientation,dir:s.dir,loop:a,children:(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({role:"tablist","aria-orientation":s.orientation},r),{},{ref:t}))}))});VR.displayName=UR;var qR="TabsTrigger",WR=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:a,disabled:r=!1}=e,s=l(e,RR),i=MR(qR,n),o=BR(n),d=KR(i.baseId,a),u=YR(i.baseId,a),m=a===i.value;return(0,Xt.jsx)(vc,(0,c.A)((0,c.A)({asChild:!0},o),{},{focusable:!r,active:m,children:(0,Xt.jsx)(Is.button,(0,c.A)((0,c.A)({type:"button",role:"tab","aria-selected":m,"aria-controls":u,"data-state":m?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:d},s),{},{ref:t,onMouseDown:ys(e.onMouseDown,e=>{r||0!==e.button||!1!==e.ctrlKey?e.preventDefault():i.onValueChange(a)}),onKeyDown:ys(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&i.onValueChange(a)}),onFocus:ys(e.onFocus,()=>{const e="manual"!==i.activationMode;m||r||!e||i.onValueChange(a)})}))}))});WR.displayName=qR;var HR="TabsContent",GR=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:a,forceMount:r,children:i}=e,o=l(e,IR),d=MR(HR,n),u=KR(d.baseId,a),m=YR(d.baseId,a),p=a===d.value,h=s.useRef(p);return s.useEffect(()=>{const e=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,Xt.jsx)($l,{present:r||p,children:n=>{let{present:a}=n;return(0,Xt.jsx)(Is.div,(0,c.A)((0,c.A)({"data-state":p?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":u,hidden:!a,id:m,tabIndex:0},o),{},{ref:t,style:(0,c.A)((0,c.A)({},e.style),{},{animationDuration:h.current?"0s":void 0}),children:a&&i}))}})});function KR(e,t){return"".concat(e,"-trigger-").concat(t)}function YR(e,t){return"".concat(e,"-content-").concat(t)}GR.displayName=HR;var JR=VR,$R=WR,XR=GR;const QR=["className"],ZR=["className"],eI=["className"],tI=zR,nI=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,QR);return(0,Xt.jsx)(JR,(0,c.A)({ref:t,className:Sr("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",n)},a))});nI.displayName=JR.displayName;const aI=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,ZR);return(0,Xt.jsx)($R,(0,c.A)({ref:t,className:Sr("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",n)},a))});aI.displayName=$R.displayName;const rI=s.forwardRef((e,t)=>{let{className:n}=e,a=l(e,eI);return(0,Xt.jsx)(XR,(0,c.A)({ref:t,className:Sr("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",n)},a))});rI.displayName=XR.displayName;const sI=wn("file-warning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),iI=wn("credit-card",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]),oI=wn("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);function lI(e){return null===e||void 0===e||Number.isNaN(Number(e))?"\u2014":new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP",maximumFractionDigits:2}).format(Number(e)/100)}function cI(e){return null===e||void 0===e?"\u2014":new Intl.NumberFormat("en-GB").format(Number(e))}function dI(e){if(!e)return"\u2014";const t=new Date(e);
2return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function uI(e){let{status:t}=e;const n=(t||"").toLowerCase();return"paid"===n||"finalised"===n||"processed"===n||"active"===n?(0,Xt.jsx)(Vw,{className:"bg-emerald-500/10 text-emerald-200 border-emerald-500/40",variant:"outline",children:t}):"failed"===n||"tampered"===n||"rejected"===n||"expired"===n?(0,Xt.jsx)(Vw,{className:"bg-rose-500/10 text-rose-200 border-rose-500/40",variant:"outline",children:t}):"pending"===n||"received"===n||"trialing"===n?(0,Xt.jsx)(Vw,{className:"bg-amber-500/10 text-amber-200 border-amber-500/40",variant:"outline",children:t}):(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge text-ndor-ink-secondary",children:t||"\u2014"})}function mI(e){let{icon:t,label:n,value:a,sublabel:r,hint:s,testid:i,tone:o="neutral"}=e;const l="gold"===o?"text-ndor-gold":"good"===o?"text-emerald-600":"warn"===o?"text-amber-600":"text-ndor-ink";return(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":i,children:(0,Xt.jsxs)(Py,{className:"p-5 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:[(0,Xt.jsx)(t,{className:"h-3.5 w-3.5"}),n]}),(0,Xt.jsx)("p",{className:"text-3xl sm:text-4xl font-serif-display font-semibold tabular-nums leading-none ".concat(l),children:a}),r?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary",children:r}):null,s?(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted font-mono-ui",children:s}):null]})})}function pI(){var e,t,n,a,r,i,o,l,c,d,u,m,p,h,f,x,v,g,y,b,w,j,k,N,_,D,C,A,S,E,F,R,I;
2const[T,P]=(0,s.useState)(null),[O,B]=(0,s.useState)(null),[L,M]=(0,s.useState)([]),[z,U]=(0,s.useState)([]),[V,q]=(0,s.useState)(null),[W,H]=(0,s.useState)(null),[G,K]=(0,s.useState)(!0),[Y,J]=(0,s.useState)(!1),[$,X]=(0,s.useState)(!1),[Q,Z]=(0,s.useState)(null),[ee,te]=(0,s.useState)(null),ne=(0,s.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e?J(!0):K(!0),Z(null),X(!1);try{const[e,t,n,a,r,s]=await Promise.all([(0,zt.n)("/api/admin/billing/overview"),(0,zt.n)("/api/admin/billing/pricing-snapshot"),(0,zt.n)("/api/admin/billing/transactions?limit=50"),(0,zt.n)("/api/admin/billing/webhook-events?limit=50"),(0,zt.n)("/api/admin/billing/anomalies"),(0,zt.n)("/api/admin/billing/marketing-drift")]);P(e),B(t),M((null===n||void 0===n?void 0:n.transactions)||[]),U((null===a||void 0===a?void 0:a.events)||[]),q(r),H(s),te(new Date)}catch(mK){if(403===(null===mK||void 0===mK?void 0:mK.status))X(!0);else{const n=(null===mK||void 0===mK?void 0:mK.message)||"Failed to load billing data.";Z(n),e&&fy.error("Refresh failed",{description:n})}}finally{K(!1),J(!1)}},[]);(0,s.useEffect)(()=>{ne(!1)},[ne]);const ae=(0,s.useMemo)(()=>{const e=(null===V||void 0===V?void 0:V.summary)||{};return(e.stale_pending_count||0)+(e.paid_no_finalise_count||0)+(e.paid_no_event_count||0)+(e.rejected_webhook_count||0)+(e.missing_stripe_map_count||0)},[V]);return $?(0,Xt.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center space-y-3","data-testid":"admin-billing-forbidden",children:[(0,Xt.jsx)(mb,{className:"h-10 w-10 text-ndor-warning"}),(0,Xt.jsx)("h2",{className:"text-xl font-serif-display font-semibold text-ndor-ink",children:"Admin only"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary max-w-md",children:"You don't have permission to view this page."})]}):G?(0,Xt.jsx)("div",{className:"flex items-center justify-center py-16","data-testid":"admin-billing-loading",children:(0,Xt.jsx)(Lg,{className:"h-6 w-6 animate-spin text-ndor-ink-muted"})}):(0,Xt.jsxs)("div",{"data-testid":"admin-billing-page",className:"space-y-6 sm:space-y-8",children:[(0,Xt.jsxs)("header",{className:"flex flex-col sm:flex-row sm:items-end sm:justify-between gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui",children:"Admin \xb7 Operations"}),(0,Xt.jsx)("h1",{className:"mt-1 text-2xl sm:text-3xl font-serif-display font-semibold tracking-tight text-ndor-ink",children:"Billing & Pricing Governance"}),(0,Xt.jsxs)("p",{className:"mt-1.5 text-sm text-ndor-ink-secondary max-w-2xl",children:["Read-only launch-watch view. Source of truth:"," ",(0,Xt.jsx)("code",{className:"px-1 py-0.5 rounded bg-ndor-surface-alt text-xs",children:"core/pricing.py"})," ","and Stripe Live. No mutations from this surface."]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-3",children:[ee?(0,Xt.jsxs)("span",{className:"text-[11px] text-ndor-ink-muted font-mono-ui hidden sm:inline",children:["Fetched: ",ee.toLocaleTimeString()]}):null,(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:()=>ne(!0),disabled:Y,className:"border-ndor-edge","data-testid":"admin-billing-refresh",children:[Y?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-2"}):(0,Xt.jsx)(Kg,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})]}),Q?(0,Xt.jsx)("div",{className:"rounded-lg border border-ndor-error-border bg-ndor-error-light text-ndor-error p-4 text-sm","data-testid":"admin-billing-error",children:Q}):null,(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-[11px] font-mono-ui","data-testid":"admin-billing-mode-banner",children:[(0,Xt.jsxs)(Vw,{variant:"outline",className:null!==T&&void 0!==T&&T.stripe_test_mode?"border-amber-500/40 bg-amber-500/10 text-amber-200":"border-emerald-500/40 bg-emerald-500/10 text-emerald-200","data-testid":"admin-billing-stripe-mode",children:[(0,Xt.jsx)(b_,{className:"h-3 w-3 mr-1.5"}),"Stripe: ",null!==T&&void 0!==T&&T.stripe_test_mode?"TEST mode":"LIVE mode"]}),(0,Xt.jsxs)(Vw,{variant:"outline",className:(null===T||void 0===T?void 0:T.stripe_price_map_size)>0?"border-emerald-500/40 bg-emerald-500/10 text-emerald-200":"border-rose-500/40 bg-rose-500/10 text-rose-200","data-testid":"admin-billing-pricemap-status",children:[(0,Xt.jsx)(NE,{className:"h-3 w-3 mr-1.5"}),"Stripe price map: ",null!==(e=null===T||void 0===T?void 0:T.stripe_price_map_size)&&void 0!==e?e:0," entries"]}),ae>0?(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 text-amber-200","data-testid":"admin-billing-anomaly-banner",children:[(0,Xt.jsx)(Oy,{className:"h-3 w-3 mr-1.5"}),ae," anomal",1===ae?"y":"ies"," surfaced"]}
2):(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200","data-testid":"admin-billing-anomaly-banner",children:[(0,Xt.jsx)(Og,{className:"h-3 w-3 mr-1.5"}),"No anomalies"]}),null!==W&&void 0!==W&&W.available&&(null===W||void 0===W?void 0:W.drift_count)>0?(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-rose-500/40 bg-rose-500/10 text-rose-200","data-testid":"admin-billing-drift-banner",children:[(0,Xt.jsx)(sI,{className:"h-3 w-3 mr-1.5"}),"Marketing drift: ",W.drift_count]}):null,null!==W&&void 0!==W&&W.available&&0===(null===W||void 0===W?void 0:W.drift_count)?(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200","data-testid":"admin-billing-drift-banner",children:[(0,Xt.jsx)(Og,{className:"h-3 w-3 mr-1.5"}),"Marketing pricing in sync"]}):null]}),(0,Xt.jsxs)("section",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4","data-testid":"admin-billing-kpis",children:[(0,Xt.jsx)(mI,{icon:e_,label:"Revenue \xb7 24h",value:lI(null===T||void 0===T||null===(t=T.revenue)||void 0===t||null===(n=t.last_24h)||void 0===n?void 0:n.pence),sublabel:"".concat(cI(null===T||void 0===T||null===(a=T.revenue)||void 0===a||null===(r=a.last_24h)||void 0===r?void 0:r.count)," paid txns"),tone:"gold",testid:"admin-billing-kpi-rev24h"}),(0,Xt.jsx)(mI,{icon:e_,label:"Revenue \xb7 7d",value:lI(null===T||void 0===T||null===(i=T.revenue)||void 0===i||null===(o=i.last_7d)||void 0===o?void 0:o.pence),sublabel:"".concat(cI(null===T||void 0===T||null===(l=T.revenue)||void 0===l||null===(c=l.last_7d)||void 0===c?void 0:c.count)," paid txns"),testid:"admin-billing-kpi-rev7d"}),(0,Xt.jsx)(mI,{icon:e_,label:"Revenue \xb7 30d",value:lI(null===T||void 0===T||null===(d=T.revenue)||void 0===d||null===(u=d.last_30d)||void 0===u?void 0:u.pence),sublabel:"".concat(cI(null===T||void 0===T||null===(m=T.revenue)||void 0===m||null===(p=m.last_30d)||void 0===p?void 0:p.count)," paid txns"),testid:"admin-billing-kpi-rev30d"}),(0,Xt.jsx)(mI,{icon:Un,label:"MRR (estimate)",value:lI(null===T||void 0===T||null===(h=T.subscriptions)||void 0===h?void 0:h.mrr_pence),sublabel:"".concat(cI(null===T||void 0===T||null===(f=T.subscriptions)||void 0===f?void 0:f.active_total)," active subs"),hint:"".concat(cI(null===T||void 0===T||null===(x=T.subscriptions)||void 0===x?void 0:x.cancel_at_period_end)," pending cancel"),tone:"good",testid:"admin-billing-kpi-mrr"}),(0,Xt.jsx)(mI,{icon:iI,label:"Top-ups \xb7 30d",value:lI(null===T||void 0===T||null===(v=T.revenue)||void 0===v||null===(g=v.topups_30d)||void 0===g?void 0:g.pence),sublabel:"".concat(cI(null===T||void 0===T||null===(y=T.revenue)||void 0===y||null===(b=y.topups_30d)||void 0===b?void 0:b.count)," packs sold"),testid:"admin-billing-kpi-topups"}),(0,Xt.jsx)(mI,{icon:Aw,label:"Subscriptions \xb7 30d",value:lI(null===T||void 0===T||null===(w=T.revenue)||void 0===w||null===(j=w.plans_30d)||void 0===j?void 0:j.pence),sublabel:"".concat(cI(null===T||void 0===T||null===(k=T.revenue)||void 0===k||null===(N=k.plans_30d)||void 0===N?void 0:N.count)," sessions"),hint:"Subscription revenue is also recognised on invoice events; this is checkout-recorded only.",testid:"admin-billing-kpi-subs"}),(0,Xt.jsx)(mI,{icon:Tn,label:"Paying customers \xb7 30d",value:cI(null===T||void 0===T||null===(_=T.customers)||void 0===_?void 0:_.paying_last_30d),sublabel:"distinct user_ids",testid:"admin-billing-kpi-paying"}),(0,Xt.jsx)(mI,{icon:Oy,label:"Failed payments \xb7 30d",value:cI(null===T||void 0===T||null===(D=T.failed_payments)||void 0===D?void 0:D.last_30d_count),sublabel:(null!==(C=null===T||void 0===T||null===(A=T.failed_payments)||void 0===A?void 0:A.last_30d_count)&&void 0!==C?C:0)>0?"Triage in Anomalies tab":"Healthy",tone:(null!==(S=null===T||void 0===T||null===(E=T.failed_payments)||void 0===E?void 0:E.last_30d_count)&&void 0!==S?S:0)>0?"warn":"good",testid:"admin-billing-kpi-failed"})]}),(0,Xt.jsxs)(tI,{defaultValue:"pricing",className:"space-y-4","data-testid":"admin-billing-tabs",children:[(0,Xt.jsxs)(nI,{children:[(0,Xt.jsx)(aI,{value:"pricing","data-testid":"admin-billing-tab-pricing",children:"Pricing matrix"}),(0,Xt.jsx)(aI,{value:"subscriptions","data-testid":"admin-billing-tab-subs",children:"Subscriptions"}),(0,Xt.jsx)(aI,{value:"transactions","data-testid":"admin-billing-tab-transactions",children:"Transactions"}),(0,Xt.jsx)(aI,{value:"webhooks","data-testid":"admin-billing-tab-webhooks",children:"Webhooks"}),(0,Xt.jsxs)(aI,{value:"anomalies","data-testid":"admin-billing-tab-anomalies",children:["Anomalies",ae>0?(0,Xt.jsxs)("span",{className:"ml-1.5 text-amber-600",children:["\xb7",ae]}):null]}),(0,Xt.jsxs)(aI,{value:"drift","data-testid":"admin-billing-tab-drift",children:["Marketing drift",(null!==(F=null===W||void 0===W?void 0:W.drift_count)&&void 0!==F?F:0)>0?(0,Xt.jsxs)("span",{className:"ml-1.5 text-rose-600",children:["\xb7",W.drift_count]}):null]}),(0,Xt.jsx)(aI,{value:"refunds","data-testid":"admin-billing-tab-refunds",children:"Refunds"})]}),(0,Xt.jsxs)(rI,{value:"pricing",className:"space-y-4","data-testid":"admin-billing-pricing-tab",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsxs)(Iy,{className:"text-base flex items-center gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-gold"}),"Plan catalogue"]}),(0,Xt.jsxs)(Ty,{children:["Source of truth \u2014 ",(0,Xt.jsx)("code",{className:"text-xs",children:"core/pricing.py"})]})]}),(0,Xt.jsx)(Py,{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm",children:[(0,Xt.jsx)("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Plan"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Period"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Price (GBP)"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Founding Member"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Included usage"}),(0,Xt.jsx)("th",{className:"text-left py-2",children:"Account modes"})]})}),(0,Xt.jsx)("tbody",{className:"font-mono-ui",children:((null===O||void 0===O?void 0:O.plans)||[]).flatMap(e=>Object.entries(e.tiers||{}).map(t=>{let[n,a]=t;return(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge","data-testid":"admin-billing-plan-".concat(e.plan_code,"-").concat(n),children:[(0,Xt.jsxs)("td",{className:"py-2 pr-3 font-semibold capitalize",children:[e.label," ",(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted text-xs",children:["(",e.plan_code,")"]})]}),(0,Xt.jsx)("td",{className:"py-2 pr-3 capitalize",children:n}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-right tabular-nums",children:a.display_price||"\xa3".concat(a.price_gbp)}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-right tabular-nums",children:a.early_access_display||(a.early_access_price_gbp?"\xa3".concat(a.early_access_price_gbp):"\u2014")}
2),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-right tabular-nums",children:cI(a.included_usage)}),(0,Xt.jsx)("td",{className:"py-2 text-xs",children:(e.allowed_account_modes||[]).join(", ")})]},"".concat(e.plan_code,"-").concat(n))}))})]})})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Top-up Credit packages"}),(0,Xt.jsx)(Ty,{children:"RC 1.61 \u2014 Top-up Credits never expire (catalogue metadata)"})]}),(0,Xt.jsx)(Py,{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm",children:[(0,Xt.jsx)("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Code"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Label"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Usage"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Price"}),(0,Xt.jsx)("th",{className:"text-right py-2",children:"Validity"})]})}),(0,Xt.jsx)("tbody",{className:"font-mono-ui",children:((null===O||void 0===O?void 0:O.extra_packages)||[]).map(e=>(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge","data-testid":"admin-billing-topup-".concat(e.code),children:[(0,Xt.jsx)("td",{className:"py-2 pr-3 font-semibold",children:e.code}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-xs",children:e.label}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-right tabular-nums",children:cI(e.usage_amount)}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-right tabular-nums",children:e.display_price||"\xa3".concat(e.price_gbp)}),(0,Xt.jsx)("td",{className:"py-2 text-right tabular-nums",children:e.expires_in_days?"".concat(e.expires_in_days,"d"):"No expiry"})]},e.code))})]})})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Action credit costs"}),(0,Xt.jsxs)(Ty,{children:["Source of truth \u2014 admin-editable, persisted in"," ",(0,Xt.jsx)("code",{className:"text-xs",children:"credit_action_prices"}),". Changes take effect on the next paid action (60-second cache)."]})]}),(0,Xt.jsx)(Py,{className:"overflow-x-auto",children:(0,Xt.jsx)(hI,{meta:(null===O||void 0===O?void 0:O.action_costs_meta)||{},onChanged:()=>ne(!0)})})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsxs)(Iy,{className:"text-base flex items-center gap-2",children:[(0,Xt.jsx)(NE,{className:"h-4 w-4 text-ndor-ink-muted"}),"Stripe price map (env-bound)"]}),(0,Xt.jsxs)(Ty,{children:["Built at backend startup from ",(0,Xt.jsx)("code",{className:"text-xs",children:"STRIPE_PRICE_*"})," env vars. Empty entries indicate boot-validator drift \u2014 backend will refuse paid endpoints with 503."]})]}),(0,Xt.jsx)(Py,{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm","data-testid":"admin-billing-stripe-map",children:[(0,Xt.jsx)("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Price ID"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Kind"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Plan / Pack"}),(0,Xt.jsx)("th",{className:"text-left py-2",children:"Period / Flags"})]})}),(0,Xt.jsx)("tbody",{className:"font-mono-ui text-xs",children:0===((null===O||void 0===O?void 0:O.stripe_price_map)||[]).length?(0,Xt.jsx)("tr",{children:(0,Xt.jsx)("td",{colSpan:4,className:"py-3 text-ndor-ink-muted italic",children:"No price IDs resolved."})}):((null===O||void 0===O?void 0:O.stripe_price_map)||[]).map(e=>(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("td",{className:"py-1.5 pr-3 break-all",children:e.price_id}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:e.kind}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:e.plan_code||e.package_code||"\u2014"}),(0,Xt.jsxs)("td",{className:"py-1.5",children:[e.billing_period||""," ",e.early_access?(0,Xt.jsx)(Vw,{variant:"outline",className:"ml-1.5 border-ndor-gold/30 text-ndor-gold text-[10px]",children:"FOUNDING"}):null]})]},e.price_id))})]})})]})]}),(0,Xt.jsx)(rI,{value:"subscriptions",className:"space-y-4","data-testid":"admin-billing-subs-tab",children:(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Active-subscription mix"}),(0,Xt.jsxs)(Ty,{children:["From ",(0,Xt.jsx)("code",{className:"text-xs",children:"user_billing_link"})," (active / trialing / past_due)"]})]}),(0,Xt.jsxs)(Py,{className:"overflow-x-auto",children:[(0,Xt.jsxs)("table",{className:"w-full text-sm","data-testid":"admin-billing-subs-mix",children:[(0,Xt.jsx)("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Plan"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Monthly"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Annual"}),(0,Xt.jsx)("th",{className:"text-right py-2",children:"Unmapped"})]})}),(0,Xt.jsxs)("tbody",{className:"font-mono-ui",children:[Object.entries((null===T||void 0===T||null===(R=T.subscriptions)||void 0===R?void 0:R.mix)||{}).map(e=>{let[t,n]=e;return(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge","data-testid":"admin-billing-mix-".concat(t),children:[(0,Xt.jsx)("td",{className:"py-2 pr-3 font-semibold capitalize",children:t}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-right tabular-nums",children:cI(n.monthly)}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-right tabular-nums",children:cI(n.annual)}),(0,Xt.jsx)("td",{className:"py-2 text-right tabular-nums",children:cI(n.unknown)})]},t)}),(0,Xt.jsxs)("tr",{className:"font-semibold",children:[(0,Xt.jsx)("td",{className:"py-2 pr-3",children:"Total active"}),(0,Xt.jsx)("td",{colSpan:3,className:"py-2 text-right tabular-nums",children:cI(null===T||void 0===T||null===(I=T.subscriptions)||void 0===I?void 0:I.active_total)})]})]})]}),(0,Xt.jsxs)("p",{className:"mt-3 text-xs text-ndor-ink-muted",children:["Rows in the ",(0,Xt.jsx)("em",{children:"Unmapped"})," column carry a ",(0,Xt.jsx)("code",{className:"text-[11px]",children:"stripe_price_id"})," ","that doesn't resolve in the boot-time Stripe price map. Usually historical / test customers."]})]})]})}),(0,Xt.jsx)(rI,{value:"transactions",className:"space-y-3","data-testid":"admin-billing-transactions-tab",children:(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsxs)(Iy,{className:"text-base flex items-center gap-2",children:[(0,Xt.jsx)(VC,{className:"h-4 w-4 text-ndor-ink-muted"}),"Recent transactions"]}),(0,Xt.jsxs)(Ty,{children:[L.length," most recent rows from ",(0,Xt.jsx)("code",{className:"text-xs",children:"payment_transactions"})]})]}),(0,Xt.jsx)(Py,{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-xs","data-testid":"admin-billing-transactions-table",children:[(0,Xt.jsx)("thead",{className:"text-[10px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Created"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Kind"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Plan / Pack"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Amount"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Status"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"User"}),(0,Xt.jsx)("th",{className:"text-left py-2",children:"Session"})]})}),(0,Xt.jsx)("tbody",{className:"font-mono-ui",children:0===L.length?(0,Xt.jsx)("tr",{children:(0,Xt.jsx)("td",{colSpan:7,className:"py-3 text-ndor-ink-muted italic",children:"No transactions yet."})}):L.map(e=>(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge","data-testid":"admin-billing-tx-".concat(e.session_id),children:[(0,Xt.jsx)("td",{className:"py-1.5 pr-3 whitespace-nowrap",children:dI(e.created_at)}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:e.kind}),(0,Xt.jsxs)("td",{className:"py-1.5 pr-3",children:[e.plan_code||e.package_code||"\u2014",e.billing_period?" \xb7 ".concat(e.billing_period):""]}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3 text-right tabular-nums",children:lI(e.amount_pence)}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:(0,Xt.jsx)(uI,{status:e.status})}),(0,Xt.jsxs)("td",{className:"py-1.5 pr-3 text-[10px]",children:[(e.user_id||"").slice(0,8),"\u2026"]}),(0,Xt.jsxs)("td",{className:"py-1.5 text-[10px] break-all max-w-[160px]",children:[(e.session_id||"").slice(0,24),"\u2026"]})]},e.id))})]})})]})}),(0,Xt.jsx)(rI,{value:"webhooks",className:"space-y-3","data-testid":"admin-billing-webhooks-tab",children:(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Recent Stripe webhook events"}),(0,Xt.jsxs)(Ty,{children:[z.length," most recent rows from ",(0,Xt.jsx)("code",{className:"text-xs",children:"stripe_webhook_events"})]})]}),(0,Xt.jsx)(Py,{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-xs","data-testid":"admin-billing-webhooks-table",children:[(0,Xt.jsx)("thead",{className:"text-[10px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Received"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Type"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Status"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Session"}),(0,Xt.jsx)("th",{className:"text-left py-2",children:"Event"})]})}),(0,Xt.jsx)("tbody",{className:"font-mono-ui",children:0===z.length?(0,Xt.jsx)("tr",{children:(0,Xt.jsx)("td",{colSpan:5,className:"py-3 text-ndor-ink-muted italic",children:"No webhook events recorded."})}):z.map(e=>(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge","data-testid":"admin-billing-event-".concat(e.event_id),children:[(0,Xt.jsx)("td",{className:"py-1.5 pr-3 whitespace-nowrap",children:dI(e.received_at)}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:e.event_type}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:(0,Xt.jsx)(uI,{status:e.processing_status})}),(0,Xt.jsxs)("td",{className:"py-1.5 pr-3 text-[10px]",children:[(e.related_session_id||"").slice(0,20),"\u2026"]}),(0,Xt.jsx)("td",{className:"py-1.5 text-[10px] break-all max-w-[180px]",children:e.event_id})]},e.event_id))})]})})]})}),(0,Xt.jsxs)(rI,{value:"anomalies",className:"space-y-4","data-testid":"admin-billing-anomalies-tab",children:[0===ae?(0,Xt.jsx)(Fy,{className:"border-emerald-500/40 bg-emerald-500/10",children:(0,Xt.jsxs)(Py,{className:"p-6 flex items-center gap-3",children:[(0,Xt.jsx)(Og,{className:"h-5 w-5 text-emerald-600"}),(0,Xt.jsx)("p",{className:"text-sm text-emerald-200",children:"All clear \u2014 no Stripe-mismatch or stale-state anomalies detected."})]})}):null,(0,Xt.jsx)(xI,{title:"Stale pending checkouts",help:"Pending sessions older than 30 minutes. Usually buyers who abandoned the Stripe-hosted checkout. Safe to ignore at scale; monitor for spikes.",rows:(null===V||void 0===V?void 0:V.stale_pending)||[],testid:"admin-billing-anomaly-stale"}),(0,Xt.jsx)(xI,{title:"Paid without finalisation timestamp",help:"Status=paid/finalised but finalised_at is null. Indicates a missing finalisation write.",rows:(null===V||void 0===V?void 0:V.paid_no_finalise)||[],testid:"admin-billing-anomaly-no-finalise"}),(0,Xt.jsx)(xI,{title:"Paid without webhook event",help:"Money captured but no Stripe webhook event_id recorded. Usually means the polling-credit safety net fired before the webhook delivered. Investigate if recurring.",rows:(null===V||void 0===V?void 0:V.paid_no_event)||[],testid:"admin-billing-anomaly-no-event"}),((null===V||void 0===V?void 0:V.webhooks_rejected)||[]).length>0?(0,Xt.jsxs)(Fy,{className:"border-rose-500/40","data-testid":"admin-billing-anomaly-rejected",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base text-rose-200",children:"Rejected / tampered webhooks"}
2),(0,Xt.jsx)(Ty,{children:"Signature failed or replayed past the 3-day retry window."})]}),(0,Xt.jsx)(Py,{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-xs",children:[(0,Xt.jsx)("thead",{className:"text-[10px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Received"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Type"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Status"}),(0,Xt.jsx)("th",{className:"text-left py-2",children:"Event ID"})]})}),(0,Xt.jsx)("tbody",{className:"font-mono-ui",children:((null===V||void 0===V?void 0:V.webhooks_rejected)||[]).map(e=>(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("td",{className:"py-1.5 pr-3 whitespace-nowrap",children:dI(e.received_at)}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:e.event_type}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:(0,Xt.jsx)(uI,{status:e.processing_status})}),(0,Xt.jsx)("td",{className:"py-1.5 text-[10px] break-all",children:e.event_id})]},e.event_id))})]})})]}):null,((null===V||void 0===V?void 0:V.plans_missing_in_stripe_map)||[]).length>0?(0,Xt.jsxs)(Fy,{className:"border-amber-500/40","data-testid":"admin-billing-anomaly-missing-map",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base text-amber-200",children:"Plan tiers missing in Stripe price map"}),(0,Xt.jsxs)(Ty,{children:["These plan/period pairs exist in ",(0,Xt.jsx)("code",{className:"text-xs",children:"core/pricing.py"})," but no Stripe Price ID resolves to them. Check the boot-time validator output."]})]}),(0,Xt.jsx)(Py,{children:(0,Xt.jsx)("ul",{className:"text-sm font-mono-ui list-disc pl-5 space-y-0.5",children:((null===V||void 0===V?void 0:V.plans_missing_in_stripe_map)||[]).map(e=>(0,Xt.jsxs)("li",{children:[e.plan_code," \xb7 ",e.billing_period]},"".concat(e.plan_code,"-").concat(e.billing_period)))})})]}):null]}),(0,Xt.jsx)(rI,{value:"drift",className:"space-y-3","data-testid":"admin-billing-drift-tab",children:(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsxs)(Iy,{className:"text-base flex items-center gap-2",children:[(0,Xt.jsx)(oI,{className:"h-4 w-4 text-ndor-ink-muted"}),"Marketing site pricing drift"]}),(0,Xt.jsxs)(Ty,{children:["Compares ",(0,Xt.jsx)("code",{className:"text-xs",children:"/app/marketing/src/pages/pricing.astro"})," ","against ",(0,Xt.jsx)("code",{className:"text-xs",children:"core/pricing.py"}),"."]})]}),(0,Xt.jsx)(Py,{className:"space-y-4",children:null!==W&&void 0!==W&&W.available?0===W.drift_count?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-emerald-200 text-sm",children:[(0,Xt.jsx)(Og,{className:"h-4 w-4"}),"Marketing pricing matches the canonical backend catalogue."]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-rose-200 text-sm",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4"}),W.drift_count," drifted field",1===W.drift_count?"":"s","."]}),(0,Xt.jsxs)("table",{className:"w-full text-sm","data-testid":"admin-billing-drift-table",children:[(0,Xt.jsx)("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Scope"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Backend (expected)"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Marketing (actual)"}),(0,Xt.jsx)("th",{className:"text-left py-2",children:"Kind"})]})}),(0,Xt.jsx)("tbody",{className:"font-mono-ui",children:(W.drift||[]).map(e=>{var t,n;return(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:e.scope}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3 text-right",children:null!==(t=e.expected)&&void 0!==t?t:"\u2014"}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3 text-right text-rose-600",children:null!==(n=e.actual)&&void 0!==n?n:"\u2014"}),(0,Xt.jsx)("td",{className:"py-1.5",children:e.kind})]},e.scope)})})]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted",children:["Action: edit ",(0,Xt.jsx)("code",{className:"text-xs",children:"/app/marketing/src/pages/pricing.astro"})," ","to match, or update ",(0,Xt.jsx)("code",{className:"text-xs",children:"core/pricing.py"})," AND propagate to Stripe Live."]})]}):(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary italic",children:(null===W||void 0===W?void 0:W.reason)||"Mar
2keting site not bundled with this deployment."})})]})}),(0,Xt.jsx)(rI,{value:"refunds",className:"space-y-3","data-testid":"admin-billing-refunds-tab",children:(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Refunds & disputes"}),(0,Xt.jsx)(Ty,{children:"Tracked under roadmap item P1.9 \u2014 full integration deferred."})]}),(0,Xt.jsxs)(Py,{className:"space-y-3 text-sm text-ndor-ink-secondary",children:[(0,Xt.jsxs)("p",{children:["Stripe currently emits ",(0,Xt.jsx)("code",{className:"text-xs",children:"charge.refunded"})," and"," ",(0,Xt.jsx)("code",{className:"text-xs",children:"charge.dispute.created"})," events, both subscribed to the live webhook endpoint. The handler audits the event into"," ",(0,Xt.jsx)("code",{className:"text-xs",children:"stripe_webhook_events"})," but does not yet reverse"," ","the corresponding ",(0,Xt.jsx)("code",{className:"text-xs",children:"payment_transactions"})," row or"," ","debit the ",(0,Xt.jsx)("code",{className:"text-xs",children:"user_usage"})," bucket."]}),(0,Xt.jsxs)("p",{children:["Until P1.9 ships, refunds are processed manually inside the Stripe Dashboard and"," ","reconciled here from the Webhooks tab. Operators should:"]}),(0,Xt.jsxs)("ol",{className:"list-decimal pl-5 space-y-1",children:[(0,Xt.jsx)("li",{children:"Issue the refund in Stripe Dashboard."}),(0,Xt.jsx)("li",{children:"Look the original session up in the Transactions tab."}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Granted credits are NOT auto-clawed-back today."})," ","Look up the user under"," ",(0,Xt.jsx)("code",{className:"text-xs",children:"/admin/users"})," to inspect their current"," ",(0,Xt.jsx)("code",{className:"text-xs",children:"extra_usage_remaining"}),". The admin usage-grant endpoint accepts ",(0,Xt.jsx)("em",{children:"positive"})," integers only; there is"," ",(0,Xt.jsx)("strong",{children:"no UI clawback"})," until P1.9 ships. If credits must be reversed, coordinate with engineering for a service-role"," ",(0,Xt.jsx)("code",{className:"text-xs",children:"user_usage"})," adjustment and a paired"," ",(0,Xt.jsx)("code",{className:"text-xs",children:"credit_ledger"})," audit row."]})]}),(0,Xt.jsxs)("p",{className:"text-[11px] text-amber-200 bg-amber-500/10 border border-amber-500/40 rounded p-2 leading-relaxed",children:[(0,Xt.jsx)("strong",{children:"RC 1.48.9 correction."})," Earlier copy on this tab suggested a negative-amount usage-grant \u2014 that path does not exist (the API rejects"," ",(0,Xt.jsx)("code",{className:"text-[11px] bg-ndor-surface-alt px-1 py-0.5 rounded",children:"amount <= 0"})," ","with HTTP 422). Until automated refund reversal lands, manual SQL is the only path and must be paired with an audit-ledger row."]}),(0,Xt.jsx)(Vw,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 text-amber-200",children:"Read-only placeholder \xb7 P1.9 follow-up"})]})]})})]})]})}function hI(e){let{meta:t,onChanged:n}=e;return(0,Xt.jsxs)("table",{className:"w-full text-sm","data-testid":"admin-billing-action-costs-table",children:[(0,Xt.jsx)("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Action"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Credits per call"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Source"}),(0,Xt.jsx)("th",{className:"text-right py-2",title:"Typical wholesale OpenAI cost per call (RC 1.47 \xb7 calibrated 2026-05-01 against the currently configured NDOR primary model)",children:"Internal cost"})]})}),(0,Xt.jsx)("tbody",{className:"font-mono-ui",children:Object.entries(t||{}).map(e=>{let[t,a]=e;return(0,Xt.jsx)(fI,{action:t,info:a,onChanged:n},t)})})]})}function fI(e){var t,n;let{action:a,info:r,onChanged:i}=e;const[o,l]=(0,s.useState)(!1),[c,d]=(0,s.useState)(String(null!==(t=null===r||void 0===r?void 0:r.cost)&&void 0!==t?t:0)),[u,m]=(0,s.useState)(!1),[p,h]=(0,s.use
2State)(null),[f,x]=(0,s.useState)(!1);(0,s.useEffect)(()=>{var e;o||d(String(null!==(e=null===r||void 0===r?void 0:r.cost)&&void 0!==e?e:0))},[null===r||void 0===r?void 0:r.cost,o]);const v=()=>{var e;h(null),l(!1),d(String(null!==(e=null===r||void 0===r?void 0:r.cost)&&void 0!==e?e:0))},g=()=>{if(""===c||null===c||void 0===c)return"Value required.";const e=Number(c);return Number.isFinite(e)?Number.isInteger(e)?e<0?"Must be \u2265 0.":e>1e4?"Must be \u2264 10000.":null:"Must be an integer.":"Must be a number."},y=()=>{const e=g();e?h(e):x(!0)},b="db"===(null===r||void 0===r?void 0:r.source)?(0,Xt.jsx)(Vw,{variant:"outline",className:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200 text-[10px] uppercase tracking-wide",children:"DB"}):(0,Xt.jsx)(Vw,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 text-amber-200 text-[10px] uppercase tracking-wide",children:"Default"});return(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge","data-testid":"admin-billing-action-".concat(a),children:[(0,Xt.jsx)("td",{className:"py-2 pr-3 align-middle",children:a}),(0,Xt.jsxs)("td",{className:"py-2 pr-3 text-right tabular-nums align-middle",children:[o?(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-1.5","data-testid":"admin-billing-action-editor-".concat(a),children:[(0,Xt.jsx)(Ag,{type:"number",step:1,min:0,max:1e4,value:c,onChange:e=>{d(e.target.value),h(null)},onKeyDown:e=>{"Enter"===e.key&&y(),"Escape"===e.key&&v()},disabled:u,autoFocus:!0,className:"h-8 w-20 text-right tabular-nums","data-testid":"admin-billing-action-input-".concat(a)}),(0,Xt.jsx)(Rr,{size:"sm",onClick:y,disabled:u,className:"h-8 bg-ndor-ink text-ndor-canvas hover:bg-ndor-ink/90","data-testid":"admin-billing-action-save-".concat(a),children:u?(0,Xt.jsx)(Lg,{className:"h-3 w-3 animate-spin"}):(0,Xt.jsx)(Zm,{className:"h-3 w-3"})}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",onClick:v,disabled:u,className:"h-8","data-testid":"admin-billing-action-cancel-".concat(a),children:(0,Xt.jsx)(xh,{className:"h-3 w-3"})})]}):(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,Xt.jsx)("span",{"data-testid":"admin-billing-action-cost-".concat(a),children:null===r||void 0===r?void 0:r.cost}),(0,Xt.jsx)(Rr,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>{h(null),l(!0)},"aria-label":"Edit ".concat(a," cost"),"data-testid":"admin-billing-action-edit-".concat(a),children:(0,Xt.jsx)(JN,{className:"h-3.5 w-3.5"})})]}),p?(0,Xt.jsx)("p",{className:"text-[11px] text-rose-600 mt-1 text-right","data-testid":"admin-billing-action-error-".concat(a),children:p}):null]}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-right",children:b}),(0,Xt.jsx)("td",{className:"py-2 text-right tabular-nums text-ndor-ink-muted",title:"Typical wholesale OpenAI cost per call \xb7 admin visibility only","data-testid":"admin-billing-action-internal-cost-".concat(a),children:"number"===typeof(null===r||void 0===r?void 0:r.internal_cost_usd)?"$".concat(r.internal_cost_usd.toFixed(4)):"\u2014"})]}),(0,Xt.jsx)(rg,{open:f,onOpenChange:e=>!u&&x(e),children:(0,Xt.jsxs)(lg,{className:"sm:max-w-[440px]","data-testid":"admin-billing-action-confirm-".concat(a),children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 text-amber-500"}),"Confirm price change"]}),(0,Xt.jsxs)(mg,{className:"text-sm text-ndor-ink-secondary leading-relaxed pt-2 space-y-2",children:[(0,Xt.jsxs)("span",{className:"block",children:["You're about to change the platform-wide Credit cost for"," ",(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:a}),"."]}),(0,Xt.jsxs)("span",{className:"block",children:[(0,Xt.jsx)("code",{className:"text-[11px] px-1.5 py-0.5 rounded bg-ndor-surface-alt",children:a}),": ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:null!==(n=null===r||void 0===r?void 0:r.cost)&&void 0!==n?n:"\u2014"})," ","\u2192 ",(0,Xt.jsx)("span",{className:"font-mono-ui font-semibold text-ndor-ink",children:c})," ","Credits per call"]}),(0,Xt.jsx)("span",{className:"block text-[12px] text-amber-200 bg-amber-500/10 border border-amber-500/40 rounded p-2 mt-2",children:"This change takes effect on every paid call within 60 seconds. Affects every user on the platform."})]})]}),(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:()=>x(!1),disabled:u,"data-testid":"admin-billing-action-confirm-cancel-".concat(a),children:"Cancel"}),(0,Xt.jsxs)(Rr,{variant:"default",onClick:async()=>{const e=g();if(e)return void h(e);const t=Number(c);m(!0),h(null),x(!1);try{await(0,zt.n)("/api/admin/credit-prices/".concat(encodeURIComponent(a)),{method:"PUT",body:{cost:t}}),fy.success("Updated \xb7 ".concat(a," \u2192 ").concat(t," credits")),l(!1),i&&i()}catch(n){const e=(null===n||void 0===n?void 0:n.message)||"Save failed.";h(e),fy.error("Save failed",{description:e})}finally{m(!1)}},disabled:u,className:"bg-ndor-ink text-ndor-canvas hover:bg-ndor-ink/90","data-testid":"admin-billing-action-confirm-save-".concat(a),children:[u?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin mr-2"}):null,"Confirm save"]})]})]})})]})}function xI(e){let{title:t,help:n,rows:a,testid:r}=e;return a&&0!==a.length?(0,Xt.jsxs)(Fy,{className:"border-amber-500/40","data-testid":r,children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsxs)(Iy,{className:"text-base text-amber-200 flex items-center gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4"}),t,(0,Xt.jsx)(Vw,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 text-amber-200 ml-1.5",children:a.length})]}
2),(0,Xt.jsx)(Ty,{children:n})]}),(0,Xt.jsx)(Py,{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-xs",children:[(0,Xt.jsx)("thead",{className:"text-[10px] uppercase tracking-[0.14em] text-ndor-ink-muted",children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Created"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Kind"}),(0,Xt.jsx)("th",{className:"text-right py-2 pr-3",children:"Amount"}),(0,Xt.jsx)("th",{className:"text-left py-2 pr-3",children:"Status"}),(0,Xt.jsx)("th",{className:"text-left py-2",children:"Session"})]})}),(0,Xt.jsxs)("tbody",{className:"font-mono-ui",children:[a.slice(0,20).map(e=>(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge",children:[(0,Xt.jsx)("td",{className:"py-1.5 pr-3 whitespace-nowrap",children:dI(e.created_at)}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:e.kind}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3 text-right tabular-nums",children:lI(e.amount_pence)}),(0,Xt.jsx)("td",{className:"py-1.5 pr-3",children:(0,Xt.jsx)(uI,{status:e.status})}),(0,Xt.jsxs)("td",{className:"py-1.5 text-[10px] break-all max-w-[180px]",children:[(e.session_id||"").slice(0,24),"\u2026"]})]},e.id)),a.length>20?(0,Xt.jsx)("tr",{children:(0,Xt.jsxs)("td",{colSpan:5,className:"py-2 text-ndor-ink-muted italic text-center",children:["+",a.length-20," more not shown"]})}):null]})]})})]}):null}function vI(e){return null===e||void 0===e?"\u2014":new Intl.NumberFormat("en-GB").format(Number(e))}function gI(e){if(null===e||void 0===e)return"\u2014";const t=Number(e);return Number.isFinite(t)?"".concat(t.toFixed(1),"%"):"\u2014"}function yI(e){if(null===e||void 0===e)return"\u2014";const t=Number(e);return Number.isFinite(t)?t<1?t.toFixed(3):t.toFixed(1):"\u2014"}function bI(e){let{icon:t,label:n,value:a,sub:r,testId:s}=e;return(0,Xt.jsx)(Fy,{className:"border-ndor-edge","data-testid":s,children:(0,Xt.jsxs)(Ry,{className:"pb-2",children:[(0,Xt.jsxs)(Ty,{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-[0.18em]",children:[t?(0,Xt.jsx)(t,{className:"h-3 w-3"}):null,n]}),(0,Xt.jsx)(Iy,{className:"text-2xl font-mono-ui tabular-nums",children:a}),r?(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed",children:r}):null]})})}const wI={shortlist:"Shortlist",apply_with_repositioning:"Tailor",hold:"Hold",reject:"Reject",unanalysed:"Unanalysed"},jI={shortlist:"bg-emerald-500",apply_with_repositioning:"bg-amber-500",hold:"bg-slate-400",reject:"bg-rose-500",unanalysed:"bg-ndor-edge"};function kI(){var e,t,n,a,r,i,o;const[l,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(!0),[m,p]=(0,s.useState)(!1),h=(0,s.useCallback)(async()=>{p(!0);try{const e=await(0,zt.n)("/api/admin/analytics/overview");c(e)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to load analytics overview.")}finally{p(!1),u(!1)}},[]);(0,s.useEffect)(()=>{h()},[h]);const f=(0,s.useMemo)(()=>{var e;const t=null===l||void 0===l||null===(e=l.scoring)||void 0===e?void 0:e.decision_histogram;return t?Object.values(t).reduce((e,t)=>e+t,0):0},[l]);if(d)return(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-ndor-ink-secondary py-12 justify-center",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," Loading analytics overview\u2026"]});const x=(null===l||void 0===l?void 0:l.headlines)||{},v=(null===l||void 0===l?void 0:l.scoring)||{},g=(null===l||void 0===l?void 0:l.tailoring)||{},y=(null===l||void 0===l?void 0:l.packs)||{},b=(null===l||void 0===l?void 0:l.ndor)||{},w=(null===l||void 0===l?void 0:l.rubric)||{},j=(null===l||void 0===l?void 0:l.value_guard)||{window_days:30,total_attempts:0,reason_histogram:{},reason_pct:{},estimated_credits_saved:null,cv_improve_price:null};return(0,Xt.jsxs)("div",{className:"space-y-6","data-testid":"admin-analytics-page",children:[(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end sm:justify-between gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold text-ndor-ink leading-tight",children:"Operator Analytics"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed max-w-2xl",children:"Read-only product telemetry: candidate funnel, scoring posture, tailoring uplift, NDOR call cost, rubric rollout. Numbers update on Refresh."})]}),(0,Xt.jsxs)("div",{className:"flex gap-2",children:[(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",size:"sm","data-testid":"admin-analytics-link-scoring",children:(0,Xt.jsxs)(Et,{to:"/admin/scoring",children:[(0,Xt.jsx)(Bn,{className:"h-3.5 w-3.5 mr-1.5"})," Scoring Governance"]})}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:h,disabled:m,"data-testid":"admin-analytics-refresh",children:[m?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):(0,Xt.jsx)(Kg,{className:"h-3.5 w-3.5 mr-1.5"}),"Refresh"]})]})]}),(0,Xt.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[(0,Xt.jsx)(bI,{icon:XN,label:"Jobs tracked",value:vI(x.total_jobs),sub:"Across all source kinds, hidden rows excluded.",testId:"admin-analytics-tile-jobs"}),(0,Xt.jsx)(bI,{icon:On,label:"Analyse-Fit runs",value:vI(x.total_analyses),sub:"Avg holistic fit ".concat(yI(x.avg_holistic_fit)," \xb7 avg strict ").concat(yI(x.avg_source_strict)),testId:"admin-analytics-tile-analyses"}),(0,Xt.jsx)(bI,{icon:Kn,label:"CV variants",value:vI(x.total_variants),sub:"Avg uplift ".concat(null!==x.avg_variant_uplift?"+".concat(x.avg_variant_uplift):"\u2014"," pts"),testId:"admin-analytics-tile-variants"}),(0,Xt.jsx)(bI,{icon:Nn,label:"Application packs",value:vI(x.total_packs),sub:"Reject rate ".concat(gI(x.reject_rate_pct)),testId:"admin-analytics-tile-packs"})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{className:"pb-3",children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Analyse-Fit decision mix"}),(0,Xt.jsxs)(Ty,{className:"text-xs",children:["Across ",vI(f)," canonical Source-CV analyses. Variant rows excluded \u2014 they're separate str
2ict-grade runs."]})]}),(0,Xt.jsx)(Py,{className:"space-y-2",children:Object.entries(wI).map(e=>{var t,n;let[a,r]=e;const s=null!==(t=null===v||void 0===v||null===(n=v.decision_histogram)||void 0===n?void 0:n[a])&&void 0!==t?t:0,i=f>0?100*s/f:0;return(0,Xt.jsxs)("div",{className:"space-y-1","data-testid":"admin-analytics-decision-".concat(a),children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between text-xs font-medium text-ndor-ink",children:[(0,Xt.jsx)("span",{children:r}),(0,Xt.jsxs)("span",{className:"font-mono-ui tabular-nums text-ndor-ink-secondary",children:[vI(s)," \xb7 ",i.toFixed(1),"%"]})]}),(0,Xt.jsx)("div",{className:"h-2 rounded-full bg-ndor-edge overflow-hidden",children:(0,Xt.jsx)("div",{className:"h-2 ".concat(jI[a]," transition-all"),style:{width:"".concat(i,"%")}})})]},a)})})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{className:"pb-3",children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Tailoring funnel"}),(0,Xt.jsx)(Ty,{className:"text-xs",children:"How candidates move from analyse-fit \u2192 variant \u2192 packed application."})]}),(0,Xt.jsxs)(Py,{children:[(0,Xt.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,Xt.jsx)(NI,{label:"Analyses run",value:null===g||void 0===g||null===(e=g.funnel)||void 0===e?void 0:e.analyses_run,testId:"admin-analytics-funnel-analyses"}),(0,Xt.jsx)(NI,{label:"Variants generated",value:null===g||void 0===g||null===(t=g.funnel)||void 0===t?void 0:t.variants_generated,parent:null===g||void 0===g||null===(n=g.funnel)||void 0===n?void 0:n.analyses_run,testId:"admin-analytics-funnel-variants"}),(0,Xt.jsx)(NI,{label:"Packs created",value:null===g||void 0===g||null===(a=g.funnel)||void 0===a?void 0:a.packs_created,parent:null===g||void 0===g||null===(r=g.funnel)||void 0===r?void 0:r.analyses_run,testId:"admin-analytics-funnel-packs"})]}),null!==g&&void 0!==g&&g.top_template?(0,Xt.jsxs)("div",{className:"mt-4 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2.5 text-xs leading-relaxed text-emerald-900","data-testid":"admin-analytics-top-template",children:[(0,Xt.jsx)("strong",{children:"Top-performing template:"})," ",g.top_template.template_type," \xb7 ","avg strict score ",(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums",children:g.top_template.avg_strict_score})," over ",g.top_template.sample_count," samples."]}):null]})]}),(0,Xt.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{className:"pb-3",children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Application-pack status"}),(0,Xt.jsxs)(Ty,{className:"text-xs",children:["Across ",vI(null===y||void 0===y?void 0:y.total)," packs."]})]}),(0,Xt.jsxs)(Py,{className:"space-y-1",children:[0===Object.entries((null===y||void 0===y?void 0:y.status_histogram)||{}).length?(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted","data-testid":"admin-analytics-packs-empty",children:"No packs yet."}):Object.entries(y.status_histogram).map(e=>{let[t,n]=e;return(0,Xt.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,Xt.jsx)("span",{className:"capitalize",children:t.replace(/_/g," ")}),(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums","data-testid":"admin-analytics-pack-status-".concat(t),children:vI(n)})]},t)}),(0,Xt.jsxs)("div",{className:"pt-2 border-t border-ndor-edge mt-2 grid grid-cols-2 gap-2 text-xs",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted",children:"With variant CV"}),(0,Xt.jsx)("p",{className:"font-mono-ui tabular-nums","data-testid":"admin-analytics-pack-with-variant",children:vI(null===y||void 0===y?void 0:y.with_variant)})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted",children:"With cover letter"}),(0,Xt.jsx)("p",{className:"font-mono-ui tabular-nums","data-testid":"admin-analytics-pack-with-cover",children:vI(null===y||void 0===y?void 0:y.with_cover_letter)})]})]})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{className:"pb-3",children:[(0,Xt.jsxs)(Iy,{className:"text-base flex items-center gap-2",children:["NDOR cost",(0,Xt.jsx)(Vw,{className:"bg-ndor-surface-alt text-slate-200 border-slate-200",variant:"outline",children:"USD"})]}),(0,Xt.jsxs)(Ty,{className:"text-xs",children:["NDOR-reported cost across ",vI(null===b||void 0===b?void 0:b.total_calls)," calls. NDORFlow does not branch on this \u2014 operator visibility only."]})]}),(0,Xt.jsxs)(Py,{className:"space-y-2",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted",children:"Total cost"}),(0,Xt.jsx)("p",{className:"text-2xl font-mono-ui tabular-nums","data-testid":"admin-analytics-ndor-total-cost",children:(k=null===b||void 0===b?void 0:b.total_cost_usd,null===k||void 0===k?"\u2014":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:4}).format(Number(k)))})]}),Object.entries((null===b||void 0===b?void 0:b.by_task)||{}).length>0?(0,Xt.jsx)("div",{className:"pt-2 border-t border-ndor-edge mt-2 space-y-1 text-xs",children:Object.entries(b.by_task).map(e=>{let[t,n]=e;return(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsx)("span",{className:"capitalize",children:t.replace(/_/g," ")}),(0,Xt.jsx)("span",{className:"font-mono-ui tabular-nums","data-testid":"admin-analytics-ndor-task-".concat(t),children:vI(n)})]},t)})}):null]})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge","data-testid":"admin-analytics-value-guard-card",children:[(0,Xt.jsx)(Ry,{className:"pb-2",children:(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)(Iy,{className:"text-base",children:["Value-Guard audit \xb7 last ",j.window_days," days"]}
2),(0,Xt.jsx)(Ty,{className:"text-xs",children:"Charge-gate branches fired across all CV generations. Surfaces whether the RC 1.48.6 high-CV 50% presentation branch is absorbing the right volume."})]}),(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] font-mono-ui uppercase tracking-[0.14em] shrink-0",children:[(0,Xt.jsx)("span",{"data-testid":"admin-analytics-value-guard-total",children:vI(j.total_attempts)}),(0,Xt.jsx)("span",{className:"ml-1 text-ndor-ink-muted",children:"attempts"})]})]})}),(0,Xt.jsxs)(Py,{children:[0===j.total_attempts?(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted","data-testid":"admin-analytics-value-guard-empty",children:"No charge events in this window yet. Counters will populate as candidates generate variants."}):(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-2",children:[{key:"cv_quality_improved",label:"Material uplift",sub:"100% charged",tone:"bg-emerald-500/10 border-emerald-500/40"},{key:"presentation_optimisation_high_cv",label:"Presentation only",sub:"50% charged",tone:"bg-amber-500/10 border-amber-500/40"},{key:"within_tolerance_band",label:"Within tolerance",sub:"Waived",tone:"bg-sky-500/10 border-sky-500/40"},{key:"cv_quality_no_improvement",label:"No uplift",sub:"Waived",tone:"bg-sky-500/10 border-sky-500/40"},{key:"no_baseline_protection",label:"No baseline",sub:"100% charged",tone:"bg-ndor-surface-alt border-slate-200"}].map(e=>{var t,n;return(0,Xt.jsxs)("div",{className:"rounded-md border px-2.5 py-2 ".concat(e.tone),"data-testid":"admin-analytics-value-guard-row-".concat(e.key),children:[(0,Xt.jsx)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.14em] text-ndor-ink-muted leading-tight",children:e.label}),(0,Xt.jsx)("p",{className:"text-[9px] text-ndor-ink-muted mt-0.5",children:e.sub}),(0,Xt.jsxs)("p",{className:"mt-1.5 text-lg font-mono-ui tabular-nums text-ndor-ink",children:[(0,Xt.jsx)("span",{"data-testid":"admin-analytics-value-guard-count-".concat(e.key),children:vI((null===(t=j.reason_histogram)||void 0===t?void 0:t[e.key])||0)}),(0,Xt.jsxs)("span",{className:"text-[10px] text-ndor-ink-muted ml-1.5 font-normal",children:["(",(0,Xt.jsx)("span",{"data-testid":"admin-analytics-value-guard-pct-".concat(e.key),children:gI(null===(n=j.reason_pct)||void 0===n?void 0:n[e.key])}),")"]})]})]},e.key)})}),(0,Xt.jsxs)("div",{className:"mt-4 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2",children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:["Estimated Credits protected by waives + 50% presentation discounts",j.cv_improve_price?(0,Xt.jsxs)(Xt.Fragment,{children:[" (using current ",(0,Xt.jsx)("code",{children:"cv_improve"})," price = ",vI(j.cv_improve_price)," Credits)"]}
2):(0,Xt.jsx)(Xt.Fragment,{children:" (price not configured \u2014 saved value unavailable)"}),"."]}),(0,Xt.jsx)("p",{className:"text-2xl font-mono-ui tabular-nums text-ndor-ink shrink-0","data-testid":"admin-analytics-value-guard-credits-saved",children:null===j.estimated_credits_saved||void 0===j.estimated_credits_saved?"\u2014":"".concat(vI(j.estimated_credits_saved)," Cr")})]})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge","data-testid":"admin-analytics-rubric-card",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 flex flex-row items-start justify-between",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Iy,{className:"text-base",children:"Rubric rollout"}),(0,Xt.jsxs)(Ty,{className:"text-xs",children:[(0,Xt.jsx)("code",{children:null===w||void 0===w?void 0:w.rubric_version})," \xb7 ",(0,Xt.jsx)("code",{children:null===w||void 0===w?void 0:w.scoring_model_version})," \xb7 ",vI(null===w||void 0===w?void 0:w.current_row_count)," of ",vI(null===w||void 0===w?void 0:w.total_row_count)," rows on current"]})]}),(0,Xt.jsx)(Rr,{asChild:!0,variant:"ghost",size:"sm",children:(0,Xt.jsxs)(Et,{to:"/admin/scoring","data-testid":"admin-analytics-rubric-link",children:["Open Scoring panel ",(0,Xt.jsx)(Aw,{className:"h-3.5 w-3.5 ml-1"})]})})]}),(0,Xt.jsxs)(Py,{children:[(0,Xt.jsx)("div",{className:"h-2 rounded-full bg-ndor-edge overflow-hidden",children:(0,Xt.jsx)("div",{className:"h-2 bg-emerald-500",style:{width:"".concat(100-(null!==(i=null===w||void 0===w?void 0:w.stale_pct)&&void 0!==i?i:0),"%")},"data-testid":"admin-analytics-rubric-bar"})}),(0,Xt.jsxs)("p",{className:"mt-1 text-[10px] font-mono-ui uppercase tracking-[0.14em] text-ndor-ink-muted",children:[null!==(o=null===w||void 0===w?void 0:w.stale_pct)&&void 0!==o?o:0,"% stale \xb7 auto-refresh on next analyse-fit"]})]})]}),(0,Xt.jsxs)("p",{className:"text-[10px] text-ndor-ink-muted font-mono-ui leading-relaxed",children:["Source: ",(0,Xt.jsx)("code",{children:"GET /api/admin/analytics/overview"})," \xb7 RC 1.47.ADMIN-ANALYTICS \xb7 read-only"]})]});var k}function NI(e){let{label:t,value:n,parent:a,testId:r}=e;const s=a&&Number(a)>0?100*Number(n)/Number(a):null;return(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30 px-3 py-3","data-testid":r,children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:t}),(0,Xt.jsx)("p",{className:"text-2xl font-mono-ui tabular-nums text-ndor-ink mt-0.5",children:vI(n)}),null!==s?(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted mt-0.5",children:[s.toFixed(1),"% of analyses"]}):null]})}const _I=wn("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),DI=wn("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);function CI(e){return null===e||void 0===e?"\u2014":new Intl.NumberFormat("en-GB").format(Number(e))}function AI(e){let{stalePct:t}=e;return null===t||void 0===t?(0,Xt.jsx)(Vw,{variant:"outline","data-testid":"scoring-health-unknown",children:"Unknown"}):0===t?(0,Xt.jsx)(Vw,{className:"bg-emerald-500/10 text-emerald-200 border-emerald-500/40",variant:"outline","data-testid":"scoring-health-fully-rolled",children:"Fully rolled out"}):t<25?(0,Xt.jsxs)(Vw,{className:"bg-emerald-500/10 text-emerald-200 border-emerald-500/40",variant:"outline","data-testid":"scoring-health-healthy",children:["Healthy rollout \xb7 ",t,"% legacy"]}):t<75?(0,Xt.jsxs)(Vw,{className:"bg-amber-500/10 text-amber-200 border-amber-500/40",variant:"outline","data-testid":"scoring-health-rolling",children:["Rolling out \xb7 ",t,"% legacy"]}
2):(0,Xt.jsxs)(Vw,{className:"bg-rose-500/10 text-rose-200 border-rose-500/40",variant:"outline","data-testid":"scoring-health-fresh-bump",children:["Recent bump \xb7 ",t,"% legacy"]})}function SI(){var e,t;const[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(!0),[o,l]=(0,s.useState)(!1),c=(0,s.useCallback)(async()=>{l(!0);try{const e=await(0,zt.n)("/api/admin/scoring/rubric");a(e)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to load scoring snapshot.")}finally{l(!1),i(!1)}},[]);return(0,s.useEffect)(()=>{c()},[c]),r?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-ndor-ink-secondary py-12 justify-center",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," Loading scoring snapshot\u2026"]}):(0,Xt.jsxs)("div",{className:"space-y-5","data-testid":"admin-scoring-page",children:[(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end sm:justify-between gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold text-ndor-ink leading-tight",children:"Scoring Governance"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed max-w-2xl",children:"Live rubric, scoring-model, and rollout posture. After a rubric bump, cached rows auto-invalidate on the next analyse-fit per RC 1.46.REANALYSE-INTEGRITY \u2014 no manual sweep needed. Watch the stale % trend toward 0 as users open their jobs."})]}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:c,disabled:o,"data-testid":"admin-scoring-refresh",children:[o?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):(0,Xt.jsx)(Kg,{className:"h-3.5 w-3.5 mr-1.5"}),"Refresh"]})]}),(0,Xt.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,Xt.jsx)(Fy,{className:"border-ndor-edge",children:(0,Xt.jsxs)(Ry,{className:"pb-2",children:[(0,Xt.jsxs)(Ty,{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-[0.18em]",children:[(0,Xt.jsx)(_I,{className:"h-3 w-3"})," Rubric version"]}),(0,Xt.jsx)(Iy,{className:"text-2xl font-mono-ui tabular-nums","data-testid":"admin-scoring-rubric-version",children:(null===n||void 0===n?void 0:n.rubric_version)||"\u2014"})]})}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge",children:(0,Xt.jsxs)(Ry,{className:"pb-2",children:[(0,Xt.jsxs)(Ty,{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-[0.18em]",children:[(0,Xt.jsx)(Bn,{className:"h-3 w-3"})," Scoring model"]}),(0,Xt.jsx)(Iy,{className:"text-2xl font-mono-ui tabular-nums","data-testid":"admin-scoring-model-version",children:(null===n||void 0===n?void 0:n.scoring_model_version)||"\u2014"})]})}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge",children:(0,Xt.jsxs)(Ry,{className:"pb-2",children:[(0,Xt.jsxs)(Ty,{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-[0.18em]",children:[(0,Xt.jsx)(DI,{className:"h-3 w-3"})," Model used for fit"]}),(0,Xt.jsx)(Iy,{className:"text-base font-mono-ui truncate","data-testid":"admin-scoring-model-used",children:(null===n||void 0===n?void 0:n.model_used_for_fit)||"\u2014"})]})})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge",children:[(0,Xt.jsxs)(Ry,{className:"pb-3",children:[(0,Xt.jsxs)(Iy,{className:"text-base flex items-center gap-2",children:["Rollout posture ",(0,Xt.jsx)(AI,{stalePct:null===n||void 0===n?void 0:n.stale_pct})]}),(0,Xt.jsx)(Ty,{className:"text-xs leading-relaxed",children:"Stale rows carry a previous rubric / model stamp and will auto-refresh on the next analyse-fit (cache miss \u2192 fresh LLM run \u2192 new stamp). No manual action required."})]}),(0,Xt.jsxs)(Py,{className:"space-y-3",children:[(0,Xt.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,Xt.jsx)(EI,{label:"Current",value:CI(null===n||void 0===n?void 0:n.current_row_count),testId:"admin-scoring-current",tone:"ok"}),(0,Xt.jsx)(EI,{label:"Stale",value:CI(null===n||void 0===n?void 0:n.stale_row_count),testId:"admin-scoring-stale",tone:(null===n||void 0===n?void 0:n.stale_row_count)>0?"warn":"ok"}),(0,Xt.jsx)(EI,{label:"Total",value:CI(null===n||void 0===n?void 0:n.total_row_count),testId:"admin-scoring-total"})]}),(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between text-[10px] font-mono-ui uppercase tracking-[0.14em] text-ndor-ink-muted",children:[(0,Xt.jsx)("span",{children:"Stamped on current"}),(0,Xt.jsxs)("span",{"data-testid":"admin-scoring-stale-pct",children:[null!==(e=null===n||void 0===n?void 0:n.stale_pct)&&void 0!==e?e:0,"% stale"]})]}),(0,Xt.jsx)("div",{className:"h-2 rounded-full bg-ndor-edge overflow-hidden",children:(0,Xt.jsx)("div",{className:"h-2 bg-emerald-500 transition-all",style:{width:"".concat(100-(null!==(t=null===n||void 0===n?void 0:n.stale_pct)&&void 0!==t?t:0),"%")},"data-testid":"admin-scoring-rollout-bar"})})]}),(null===n||void 0===n?void 0:n.stale_row_count)>0?(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-200 leading-relaxed",children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsxs)("strong",{children:[CI(n.stale_row_count)," rows"]})," are still stamped with a previous rubric/model. They will auto-refresh organically as users anal
2yse-fit on those jobs. To force a sweep, use the existing per-job ",(0,Xt.jsx)("em",{children:"Re-analyse Fit"})," button (no admin tool yet, by design \u2014 preserves credit/cache integrity)."]})]}):(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-200 leading-relaxed",children:[(0,Xt.jsx)(Bn,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),(0,Xt.jsxs)("span",{children:["Every ",(0,Xt.jsx)("strong",{children:"job_scores"})," row carries the live rubric and scoring-model stamps. Rollout integrity: 100%."]})]})]})]}),(0,Xt.jsxs)("p",{className:"text-[10px] text-ndor-ink-muted font-mono-ui leading-relaxed",children:["Source: ",(0,Xt.jsx)("code",{children:"GET /api/admin/scoring/rubric"})," \xb7 RC 1.46.RUBRIC-OBSERVABILITY \xb7 read-only"]})]})}function EI(e){let{label:t,value:n,testId:a,tone:r}=e,s="text-ndor-ink";return"ok"===r&&(s="text-emerald-200"),"warn"===r&&(s="text-amber-200"),(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30 px-3 py-2.5",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:t}),(0,Xt.jsx)("p",{className:"text-xl font-mono-ui tabular-nums ".concat(s),"data-testid":a,children:n})]})}const FI=wn("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);function RI(e){if(!e)return"\u2014";try{const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch(t){return e}}function II(e,t){if(!e||!t)return null;try{const n=new Date(e).getTime(),a=new Date(t).getTime();return Number.isNaN(n)||Number.isNaN(a)?null:Math.max(0,a-n)}catch(n){return null}}function TI(e){return null===e||void 0===e?"\u2014":e<1e3?"".concat(e," ms"):e<6e4?"".concat((e/1e3).toFixed(2)," s"):"".concat((e/6e4).toFixed(2)," min")}const PI={green:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200",yellow:"border-amber-500/40 bg-amber-500/10 text-amber-200",red:"border-rose-500/40 bg-rose-500/10 text-rose-200"},OI={green:"bg-emerald-500",yellow:"bg-amber-500",red:"bg-rose-500"};function BI(e){if(!e)return"\u2014";const t=String(e);return t.length<=13?t:"".concat(t.slice(0,8),"\u2026").concat(t.slice(-4))}const LI={green:Og,yellow:FI,red:Oy};function MI(e){const t=function(e){var t;const n=Number(null!==(t=null===e||void 0===e?void 0:e.errors)&&void 0!==t?t:0);return Number.isFinite(n)&&n>0?{tone:"red",label:"Error"}:null!==e&&void 0!==e&&e.dry_run?{tone:"yellow",label:"Dry-run"}:{tone:"green",label:"Success"}}(e);return(0,c.A)((0,c.A)({},t),{},{Icon:LI[t.tone]||Og})}function zI(e){var t,n,a,r,s;let{run:i}=e;const{tone:o,label:l,Icon:c}=MI(i),d=Number(null!==(t=null===i||void 0===i||null===(n=i.rows_tombstoned)||void 0===n?void 0:n.cv_variants)&&void 0!==t?t:0),u=Number(null!==(a=null===i||void 0===i||null===(r=i.rows_tombstoned)||void 0===r?void 0:r.application_documents)&&void 0!==a?a:0),m=II(null===i||void 0===i?void 0:i.run_started_at,null===i||void 0===i?void 0:i.completed_at);return(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge last:border-b-0 align-top","data-testid":"retention-run-row-".concat(i.id),"data-tone":o,children:[(0,Xt.jsx)("td",{className:"py-3 pr-3 whitespace-nowrap",children:(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)("span",{className:"inline-block h-1.5 w-1.5 rounded-full ".concat(OI[o])}),(0,Xt.jsxs)(Vw,{variant:"outline",className:"".concat(PI[o]," text-[10px] uppercase tracking-wide"),"data-testid":"retention-run-status-".concat(i.id),children:[(0,Xt.jsx)(c,{className:"h-3 w-3 mr-1"}),l]})]})}),(0,Xt.jsx)("td",{className:"py-3 pr-3 font-mono-ui text-[11px] text-ndor-ink-muted whitespace-nowrap",children:(0,Xt.jsx)("span",{title:i.id,children:BI(i.id)})}),(0,Xt.jsx)("td",{className:"py-3 pr-3 text-xs text-ndor-ink whitespace-nowrap",children:RI(i.run_started_at)}),(0,Xt.jsx)("td",{className:"py-3 pr-3 text-xs text-ndor-ink whitespace-nowrap",children:RI(i.completed_at)}),(0,Xt.jsx)("td",{className:"py-3 pr-3 text-xs text-ndor-ink-muted whitespace-nowrap",children:TI(m)}),(0,Xt.jsx)("td",{className:"py-3 pr-3 text-xs text-ndor-ink whitespace-nowrap",children:Number.isFinite(Number(i.window_days))?"".concat(i.window_days,"d"):"\u2014"}),(0,Xt.jsx)("td",{className:"py-3 pr-3 text-xs text-ndor-ink whitespace-nowrap",children:i.exempt_user?(0,Xt.jsx)("span",{className:"font-mono-ui text-[11px]",title:i.exempt_user,children:BI(i.exempt_user)}
2):(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"none"})}),(0,Xt.jsx)("td",{className:"py-3 pr-3 text-xs text-ndor-ink whitespace-nowrap",children:(0,Xt.jsx)("span",{className:"font-mono-ui",children:d})}),(0,Xt.jsx)("td",{className:"py-3 pr-3 text-xs text-ndor-ink whitespace-nowrap",children:(0,Xt.jsx)("span",{className:"font-mono-ui",children:u})}),(0,Xt.jsx)("td",{className:"py-3 pr-0 text-xs text-ndor-ink",children:Number(null!==(s=i.errors)&&void 0!==s?s:0)>0?(0,Xt.jsxs)("div",{className:"flex items-start gap-1.5 max-w-md",children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 text-rose-600 shrink-0 mt-0.5"}),(0,Xt.jsx)("span",{className:"text-rose-200 break-words","data-testid":"retention-run-error-".concat(i.id),children:i.error_message||"".concat(i.errors," error(s)")})]}):(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"\u2014"})})]})}function UI(e){var t,n,a,r,s;let{run:i}=e;const{tone:o,label:l,Icon:c}=MI(i),d=Number(null!==(t=null===i||void 0===i||null===(n=i.rows_tombstoned)||void 0===n?void 0:n.cv_variants)&&void 0!==t?t:0),u=Number(null!==(a=null===i||void 0===i||null===(r=i.rows_tombstoned)||void 0===r?void 0:r.application_documents)&&void 0!==a?a:0),m=II(null===i||void 0===i?void 0:i.run_started_at,null===i||void 0===i?void 0:i.completed_at);return(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"retention-run-card-".concat(i.id),"data-tone":o,children:(0,Xt.jsxs)(Py,{className:"p-4 space-y-3",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,Xt.jsx)("span",{className:"inline-block h-1.5 w-1.5 rounded-full ".concat(OI[o])}),(0,Xt.jsxs)(Vw,{variant:"outline",className:"".concat(PI[o]," text-[10px] uppercase tracking-wide"),children:[(0,Xt.jsx)(c,{className:"h-3 w-3 mr-1"}),l]})]}),(0,Xt.jsx)("p",{className:"text-[11px] font-mono-ui text-ndor-ink-muted break-all",title:i.id,children:i.id})]}),(0,Xt.jsxs)("div",{className:"text-right shrink-0",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Window"}),(0,Xt.jsx)("p",{className:"text-sm font-semibold text-ndor-ink",children:Number.isFinite(Number(i.window_days))?"".concat(i.window_days,"d"):"\u2014"})]})]}),(0,Xt.jsxs)("dl",{className:"grid grid-cols-2 gap-x-3 gap-y-2 text-xs",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Started"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:RI(i.run_started_at)})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Completed"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:RI(i.completed_at)})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Duration"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink-muted",children:TI(m)})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Exempt user"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink font-mono-ui text-[11px] break-all",children:i.exempt_user?BI(i.exempt_user):"none"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"CV variants"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink font-mono-ui",children:d})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Cover letters"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink font-mono-ui",children:u})]})]}),Number(null!==(s=i.errors)&&void 0!==s?s:0)>0?(0,Xt.jsxs)("div",{className:"rounded-md border border-rose-500/40 bg-rose-500/10 p-2.5 text-xs text-rose-200 flex items-start gap-2","data-testid":"retention-run-card-error-".concat(i.id),children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),(0,Xt.jsx)("span",{className:"break-words",children:i.error_message||"".concat(i.errors," error(s)")})]}):null]})})}function VI(e){let{runs:t}=e;const n=(0,s.useMemo)(()=>{var e;const n=t.length,a=t.filter(e=>{var t;return Number(null!==(t=null===e||void 0===e?void 0:e.errors)&&void 0!==t?t:0)>0}).length,r=t.filter(e=>{var t;return(null===e||void 0===e?void 0:e.dry_run)&&0===Number(null!==(t=null===e||void 0===e?void 0:e.errors)&&void 0!==t?t:0)}).length,s=t.filter(e=>{var t;return!(null!==e&&void 0!==e&&e.dry_run)&&0===Number(null!==(t=null===e||void 0===e?void 0:e.errors)&&void 0!==t?t:0)}).length,i=t.reduce((e,t)=>
2{var n,a;return e+Number(null!==(n=null===t||void 0===t||null===(a=t.rows_tombstoned)||void 0===a?void 0:a.cv_variants)&&void 0!==n?n:0)},0),o=t.reduce((e,t)=>{var n,a;return e+Number(null!==(n=null===t||void 0===t||null===(a=t.rows_tombstoned)||void 0===a?void 0:a.application_documents)&&void 0!==n?n:0)},0);return{total:n,errors:a,dryRuns:r,successes:s,cvSum:i,adSum:o,lastRun:(null===(e=t[0])||void 0===e?void 0:e.run_started_at)||null}},[t]);return(0,Xt.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3","data-testid":"retention-summary-tiles",children:[(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface",children:(0,Xt.jsxs)(Py,{className:"p-3 sm:p-4",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Last run"}),(0,Xt.jsx)("p",{className:"text-xs font-medium text-ndor-ink mt-1 truncate",title:n.lastRun||"\u2014",children:n.lastRun?RI(n.lastRun):"\u2014"})]})}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface",children:(0,Xt.jsxs)(Py,{className:"p-3 sm:p-4",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Total runs"}),(0,Xt.jsx)("p",{className:"text-lg font-semibold text-ndor-ink font-mono-ui",children:n.total})]})}),(0,Xt.jsx)(Fy,{className:"border-emerald-500/40 bg-emerald-500/10/40",children:(0,Xt.jsxs)(Py,{className:"p-3 sm:p-4",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wide text-emerald-200",children:"Successes"}),(0,Xt.jsx)("p",{className:"text-lg font-semibold text-emerald-200 font-mono-ui",children:n.successes})]})}),(0,Xt.jsx)(Fy,{className:"border-amber-500/40 bg-amber-500/10/40",children:(0,Xt.jsxs)(Py,{className:"p-3 sm:p-4",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wide text-amber-200",children:"Dry-runs"}),(0,Xt.jsx)("p",{className:"text-lg font-semibold text-amber-200 font-mono-ui",children:n.dryRuns})]})}),(0,Xt.jsx)(Fy,{className:n.errors>0?"border-rose-500/40 bg-rose-500/10/40":"border-ndor-edge bg-ndor-surface",children:(0,Xt.jsxs)(Py,{className:"p-3 sm:p-4",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wide ".concat(n.errors>0?"text-rose-200":"text-ndor-ink-muted"),children:"Errors"}),(0,Xt.jsx)("p",{className:"text-lg font-semibold font-mono-ui ".concat(n.errors>0?"text-rose-200":"text-ndor-ink"),children:n.errors})]})}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface",children:(0,Xt.jsxs)(Py,{className:"p-3 sm:p-4",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Tombstoned (\u03a3)"}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink mt-1",children:[(0,Xt.jsx)("span",{className:"font-mono-ui font-medium",children:n.cvSum})," CV \xb7"," ",(0,Xt.jsx)("span",{className:"font-mono-ui font-medium",children:n.adSum})," letters"]})]})})]})}function qI(){const[e,t]=(0,s.useState)([]),[n,a]=(0,s.useState)(!1),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(30),u=(0,s.useCallback)(async()=>{a(!0),i(null);try{const e=await(0,zt.n)("/api/admin/cron/artefact-retention-runs?limit=".concat(encodeURIComponent(c))),n=Array.isArray(null===e||void 0===e?void 0:e.runs)?e.runs:[];n.sort((e,t)=>{const n=null!==e&&void 0!==e&&e.run_started_at?new Date(e.run_started_at).getTime():0;return(null!==t&&void 0!==t&&t.run_started_at?new Date(t.run_started_at).getTime():0)-n}),t(n),l(new Date)}catch(mK){i((null===mK||void 0===mK?void 0:mK.message)||"Failed to load retention runs.")}finally{a(!1)}},[c]);(0,s.useEffect)(()=>{u()},[u]);const m=n&&0===e.length,p=!n&&0===e.length&&!r;return(0,Xt.jsxs)("div",{className:"space-y-6 sm:space-y-8","data-testid":"admin-retention-page",children:[(0,Xt.jsxs)("header",{className:"flex flex-col sm:flex-row sm:items-end sm:justify-between gap-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h1",{className:"text-xl sm:text-2xl font-serif-display font-semibold text-ndor-ink",children:"Artefact Retention"}),(0,Xt.jsxs)("p",{className:"mt-1.5 text-sm text-ndor-ink-secondary max-w-2xl",children:["Daily audit trail for"," ",(0,Xt.jsx)("code",{className:"px-1 py-0.5 rounded bg-ndor-surface-alt text-xs",children:"ndorflow_artefact_retention"})," ","cron \u2014 read from"," ",(0,Xt.jsx)("code",{className:"px-1 py-0.5 rounded bg-ndor-surface-alt text-xs",children:"GET /api/admin/cron/artefact-retention-runs"}),". Schedule: ",(0,Xt.jsx)("code",{className:"text-xs",children:"0 3 * * *"})," UTC. Operator account is exempt for the 60-day soak (review on / after"," ",(0,Xt.jsx)("strong",{children:"2026-07-01"}),")."]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-3",children:[o?(0,Xt.jsxs)("span",{className:"text-[11px] text-ndor-ink-muted font-mono-ui hidden sm:inline","data-testid":"retention-fetched-at",children:["Fetched: ",o.toLocaleTimeString()]}):null,(0,Xt.jsxs)("label",{className:"hidden sm:flex items-center gap-2 text-xs text-ndor-ink-muted",children:[(0,Xt.jsx)("span",{children:"Limit"}),(0,Xt.jsx)("select",{value:c,onChange:e=>d(Number(e.target.value)||30),className:"rounded border border-ndor-edge bg-ndor-surface px-2 py-1 text-xs","data-testid":"retention-limit-select",disabled:n,children:[10,30,50,100].map(e=>(0,Xt.jsx)("option",{value:e,children:e},e))})]}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:u,disabled:n,className:"border-ndor-edge","data-testid":"admin-retention-refresh",children:[n?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-2"}):(0,Xt.jsx)(Kg,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})]}
2),r?(0,Xt.jsxs)("div",{className:"rounded-lg border border-rose-500/40 bg-rose-500/10 text-rose-200 p-4 text-sm flex items-start gap-2","data-testid":"admin-retention-error",children:[(0,Xt.jsx)(mb,{className:"h-4 w-4 shrink-0 mt-0.5"}),(0,Xt.jsx)("span",{className:"break-words",children:r})]}):null,e.length>0?(0,Xt.jsx)(VI,{runs:e}):null,m?(0,Xt.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3","data-testid":"admin-retention-skeleton",children:Array.from({length:4}).map((e,t)=>(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface animate-pulse h-32","aria-hidden":!0},t))}):null,p?(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"admin-retention-empty",children:(0,Xt.jsxs)(Py,{className:"p-6 text-center space-y-2",children:[(0,Xt.jsx)(pg,{className:"h-8 w-8 text-ndor-ink-muted mx-auto"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No retention runs recorded yet."}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted max-w-md mx-auto",children:["The first scheduled run will fire at the next 03:00 UTC tick. Until then, this page will stay empty unless an operator triggers a manual run via"," ",(0,Xt.jsx)("code",{className:"text-[11px] bg-ndor-surface-alt px-1 py-0.5 rounded",children:"POST /api/admin/cron/run-artefact-retention"}),"."]})]})}):null,e.length>0?(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface hidden lg:block","data-testid":"admin-retention-table-card",children:[(0,Xt.jsxs)(Ry,{children:[(0,Xt.jsx)(Iy,{className:"text-base font-serif-display font-semibold",children:"Run history"}),(0,Xt.jsxs)(Ty,{className:"text-xs",children:["Newest first \xb7 ",e.length," run",1===e.length?"":"s"," loaded \xb7 capped at"," ",c,"."]})]}),(0,Xt.jsx)(Py,{className:"p-0 sm:p-0",children:(0,Xt.jsx)("div",{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-left","data-testid":"admin-retention-table",children:[(0,Xt.jsx)("thead",{children:(0,Xt.jsxs)("tr",{className:"border-b border-ndor-edge bg-ndor-surface-alt/40",children:[(0,Xt.jsx)("th",{className:"py-2 pl-4 pr-3 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Status"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Run id"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Started"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Completed"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Duration"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Window"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Exempt"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"CV variants"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Cover letters"}),(0,Xt.jsx)("th",{className:"py-2 pr-4 text-[10px] uppercase tracking-wide text-ndor-ink-muted",children:"Errors"})]})}),(0,Xt.jsx)("tbody",{className:"[&>tr>td:first-child]:pl-4 [&>tr>td:last-child]:pr-4",children:e.map(e=>(0,Xt.jsx)(zI,{run:e},e.id))})]})})})]}):null,e.length>0?(0,Xt.jsx)("div",{className:"lg:hidden space-y-3","data-testid":"admin-retention-card-list",children:e.map(e=>(0,Xt.jsx)(UI,{run:e},e.id))}):null,(0,Xt.jsxs)("section",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt/50 p-4 sm:p-5 flex items-start gap-3","data-testid":"admin-retention-help",children:[(0,Xt.jsx)(zf,{className:"h-4 w-4 text-ndor-info shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{className:"text-xs sm:text-sm text-ndor-ink-secondary space-y-1.5",children:[(0,Xt.jsxs)("p",{children:["Status colouring: ",(0,Xt.jsx)("span",{className:"text-emerald-200 font-medium",children:"Success"})," ","(errors=0, non-dry) \xb7 ",(0,Xt.jsx)("span",{className:"text-amber-200 font-medium",children:"Dry-run"})," ","(preview, no writes) \xb7 ",(0,Xt.jsx)("span",{className:"text-rose-200 font-medium",children:"Error"})," ","(errors ",">"," 0). Manual runs use the same audit table \u2014 distinguished by the ",(0,Xt.jsx)("code",{className:"text-[11px] bg-ndor-surface-alt px-1 py-0.5 rounded",children:"dry_run"})," ","and ",(0,Xt.jsx)("code",{className:"text-[11px] bg-ndor-surface-alt px-1 py-0.5 rounded",children:"exempt_user"})," ","columns."]}),(0,Xt.jsxs)("p",{children:["Manual trigger (curl-only during the soak). RC 1.48.9 P0-5 \u2014"," ",(0,Xt.jsx)("code",{className:"text-[11px] bg-ndor-surface-alt px-1 py-0.5 rounded",children:"dry_run"})," ","now defaults to ",(0,Xt.jsx)("strong",{children:"true"}),"; an empty body previews safely. Pass ",(0,Xt.jsx)("code",{className:"text-[11px] bg-ndor-surface-alt px-1 py-0.5 rounded",children:'"dry_run": false'})," ","explicitly to actually tombstone:"]}),(0,Xt.jsx)("pre",{className:"rounded bg-ndor-surface border border-ndor-edge p-2.5 text-[11px] text-ndor-ink overflow-x-auto font-mono-ui m-0",children:'curl -X POST "$API_URL/api/admin/cron/run-artefact-retention" \\\n -H "Authorization: Bearer $ADMIN_JWT" \\\n -H "Content-Type: application/json" \\\n -d \'{"window_days": 30, "dry_run": true,\n "exempt_user": "552c3e57-50a5-427f-9c6b-8419d7d78cb0"}\''})]})]})]})}const WI=wn("mail-plus",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]]),HI=wn("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]),GI=Object.freeze(new Set(["active","live"]));function KI(e){return null!=e&&GI.has(String(e).trim().toLowerCase())}const YI=["all","account.created","member.invited","member.invitation_accepted","member.invitation_revoked","member.invitation_expired","member.revoked","member.role_modified","member.suspended","member.suspended_emergency","member.unsuspended","member.suspension_expired","member.bulk_invited","member.bulk_revoked","member.bulk_role_modified"];function JI(e){if(!e)return"\u2014";
2try{return new Date(e).toLocaleString()}catch(t){return e}}function $I(e){if(!e)return 1/0;return(Date.now()-new Date(e).getTime())/864e5}function XI(e,t){var n,a;const r=null!==(n=null===t||void 0===t?void 0:t.stale_threshold_days)&&void 0!==n?n:14,s=null!==(a=null===t||void 0===t?void 0:t.no_active_role_threshold_days)&&void 0!==a?a:30,i=[];return null!=e.active_role_count&&0===e.active_role_count&&$I(e.created_at)>s&&i.push({key:"no_active_roles_30d",label:"No active roles (".concat(s,"d+)")}),null!=e.member_count&&e.member_count<=1&&i.push({key:"owner_only",label:"Owner only"}),(e.active_role_count||0)>0&&null!=e.active_reviewer_count&&0===e.active_reviewer_count&&i.push({key:"no_reviewer",label:"Roles without reviewers"}),e.last_activity_at&&$I(e.last_activity_at)>r&&i.push({key:"stale",label:"Stale (".concat(r,"d+)")}),i}function QI(){var e,t;const[n,a]=(0,s.useState)([]),[r,i]=(0,s.useState)(!0),[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(""),[p,h]=(0,s.useState)("all"),[f,x]=(0,s.use
2State)("all"),[v,g]=(0,s.useState)(null),[y,b]=(0,s.useState)(null),w=(0,s.useCallback)(async()=>{i(!0),l(null),d(null);try{const e=await(0,zt.n)("/api/admin/employers");a((null===e||void 0===e?void 0:e.employers)||[]),d((null===e||void 0===e?void 0:e.partial_failures)||null)}catch(mK){l((null===mK||void 0===mK?void 0:mK.message)||"Failed to load employers.")}finally{i(!1)}},[]);(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{const t=await(0,zt.n)("/api/admin/v1/admin-limits");e||b(t)}catch(t){e||b(null)}})(),()=>{e=!0}},[]),(0,s.useEffect)(()=>{w()},[w]);const j=(0,s.useMemo)(()=>{let e=n;if(u.trim()){const t=u.trim().toLowerCase();e=e.filter(e=>(e.name||"").toLowerCase().includes(t)||(e.sector||"").toLowerCase().includes(t)||(e.account_id||"").toLowerCase().includes(t))}if("all"!==f){const t="activated"===f;e=e.filter(e=>Boolean(e.activated)===t)}return"all"!==p&&(e=e.filter(e=>XI(e,y).some(e=>e.key===p))),e},[n,u,f,p,y]),k=(0,s.useMemo)(()=>{const e={};for(const t of n)for(const n of XI(t,y))e[n.key]=(e[n.key]||0)+1;return e},[n,y]),N=null!==(e=null===y||void 0===y?void 0:y.stale_threshold_days)&&void 0!==e?e:14,_=null!==(t=null===y||void 0===y?void 0:y.no_active_role_threshold_days)&&void 0!==t?t:30;return(0,Xt.jsxs)("div",{className:"space-y-6 p-4 sm:p-6","data-testid":"admin-employers-page",children:[(0,Xt.jsxs)("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold tracking-tight text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Pn,{className:"h-5 w-5 text-ndor-ink-muted"}),"Founder console \u2014 Employers"]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted mt-1",children:"Operational visibility across employer tenants. Read-only. No write paths. No tenant impersonation."})]}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:w,disabled:r,"data-testid":"admin-employers-refresh",children:[r?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(Kg,{className:"h-4 w-4 mr-1.5"}),"Refresh"]})]}),c&&c.length>0&&(0,Xt.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-amber-200 flex items-start gap-2","data-testid":"admin-employers-partial-failures",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("strong",{children:"Partial read failure:"})," ",c.join(", "),". Affected counters render as \u2014 for every row. Other
2counters are accurate."]})]}),(0,Xt.jsxs)(Fy,{"data-testid":"admin-employers-health-overview",children:[(0,Xt.jsx)(Ry,{className:"pb-3",children:(0,Xt.jsxs)(Iy,{className:"text-sm font-medium flex items-center gap-2",children:[(0,Xt.jsx)(In,{className:"h-4 w-4 text-ndor-ink-muted"}),"Operational health"]})}),(0,Xt.jsxs)(Py,{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,Xt.jsx)(ZI,{label:"No active roles (".concat(_,"d+)"),k:"no_active_roles_30d",count:k.no_active_roles_30d||0,active:"no_active_roles_30d"===p,onClick:()=>h("no_active_roles_30d"===p?"all":"no_active_roles_30d")}),(0,Xt.jsx)(ZI,{label:"Owner only",k:"owner_only",count:k.owner_only||0,active:"owner_only"===p,onClick:()=>h("owner_only"===p?"all":"owner_only")}),(0,Xt.jsx)(ZI,{label:"Roles without reviewers",k:"no_reviewer",count:k.no_reviewer||0,active:"no_reviewer"===p,onClick:()=>h("no_reviewer"===p?"all":"no_reviewer")}),(0,Xt.jsx)(ZI,{label:"Stale (".concat(N,"d+)"),k:"stale",count:k.stale||0,active:"stale"===p,onClick:()=>h("stale"===p?"all":"stale")}),"all"!==p&&(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",className:"ml-auto",onClick:()=>h("all"),"data-testid":"admin-employers-health-clear",children:"Clear filter"})]})]}),(0,Xt.jsx)(Fy,{children:(0,Xt.jsxs)(Py,{className:"flex flex-wrap items-end gap-3 py-4",children:[(0,Xt.jsxs)("div",{className:"grow min-w-[200px]",children:[(0,Xt.jsx)(Pg,{className:"text-xs",children:"Search"}),(0,Xt.jsxs)("div",{className:"relative",children:[(0,Xt.jsx)(wC,{className:"h-3.5 w-3.5 absolute left-2.5 top-2.5 text-ndor-ink-muted"}),(0,Xt.jsx)(Ag,{value:u,onChange:e=>m(e.target.value),placeholder:"org name, sector, account_id",className:"h-9 pl-8","data-testid":"admin-employers-search"})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs",children:"Activation"}),(0,Xt.jsxs)(Vv,{value:f,onValueChange:x,children:[(0,Xt.jsx)(Wv,{className:"h-9 w-[160px]","data-testid":"admin-employers-activation-filter",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsxs)(Kv,{children:[(0,Xt.jsx)(Yv,{value:"all",children:"All"}),(0,Xt.jsx)(Yv,{value:"activated",children:"Activated only"}),(0,Xt.jsx)(Yv,{value:"not_activated",children:"Not activated"})]})]})]})]})}),(0,Xt.jsxs)(Fy,{children:[(0,Xt.jsx)(Ry,{className:"pb-3 flex flex-row items-center justify-between",children:(0,Xt.jsxs)(Iy,{className:"text-sm font-medium",children:["Employers (",j.length,j.length!==n.length?" of ".concat(n.length):"",")"]})}),(0,Xt.jsx)(Py,{children:r&&0===n.length?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 py-10 justify-center text-sm text-ndor-ink-muted","data-testid":"admin-employers-loading",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," Loading employers\u2026"]}):o?(0,Xt.jsxs)("div",{className:"py-10 text-center space-y-3","data-testid":"admin-employers-error",children:[(0,Xt.jsx)(Oy,{className:"mx-auto h-8 w-8 text-rose-500"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-rose-200",children:o}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:w,children:[(0,Xt.jsx)(Kg,{className:"h-3.5 w-3.5 mr-1.5"})," Retry"]})]}):0===j.length?(0,Xt.jsx)("div",{className:"py-10 text-center text-sm text-ndor-ink-muted","data-testid":"admin-employers-empty",children:"No employers match the current filters."}):(0,Xt.jsx)("div",{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm","data-testid":"admin-employers-table",children:[(0,Xt.jsx)("thead",{children:(0,Xt.jsxs)("tr",{className:"border-b text-left text-xs uppercase text-ndor-ink-muted",children:[(0,Xt.jsx)("th",{className:"py-2 pr-3",children:"Organisation"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 hidden md:table-cell",children:"Created"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-right",children:"Members"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-right",children:"Active roles"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-right hidden sm:table-cell",children:"Reviewers"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-right hidden sm:table-cell",children:"Open reviews"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 text-right hidden md:table-cell",children:"Pending invites"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 hidden lg:table-cell",children:"Activation"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 hidden lg:table-cell",children:"Last activity"})]})}),(0,Xt.jsx)("tbody",{children:j.map(e=>{const t=XI(e);return(0,Xt.jsxs)("tr",{className:"border-b last:border-0 cursor-pointer hover:bg-ndor-surface-alt/40",onClick:()=>g(e.account_id),"data-testid":"admin-employers-row-".concat(e.account_id),children:[(0,Xt.jsxs)("td",{className:"py-2 pr-3",children:[(0,Xt.jsx)("div",{className:"font-medium text-ndor-ink",children:e.name||(0,Xt.jsx)("em",{className:"text-ndor-ink-muted",children:"(no name)"})}),(0,Xt.jsxs)("div",{className:"text-[10px] text-ndor-ink-muted font-mono",children:[e.account_id.slice(0,8),"\u2026"]}),t.length>0&&(0,Xt.jsx)("div",{className:"mt-1 flex flex-wrap gap-1",children:t.map(t=>(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] border-amber-300 text-amber-200 bg-amber-500/10","data-testid":"admin-employers-health-".concat(e.account_id,"-").concat(t.key),children:t.label},t.key))})]}),(0,Xt.jsx)("td",{className:"py-2 pr-3 hidden md:table-cell text-xs text-ndor-ink-muted",children:JI(e.created_at)}),(0,Xt.jsx)(eT,{value:e.member_count}),(0,Xt.jsx)(eT,{value:e.active_role_count}),(0,Xt.jsx)(eT,{value:e.active_reviewer_count,hideOn:"sm"}),(0,Xt.jsx)(eT,{value:e.open_review_count,hideOn:"sm"}),(0,Xt.jsx)(eT,{value:e.pending_invite_count,hideOn:"md"}),(0,Xt.jsx)("td",{className:"py-2 pr-3 hidden lg:table-cell",children:(0,Xt.jsx)(Vw,{variant:e.activated?"default":"outline","data-testid":"admin-employers-activation-".concat(e.account_id),children:null===e.activated?"\u2014":e.activated?"Activated":"Placeholder"})}),(0,Xt.jsx)("td",{className:"py-2 pr-3 hidden lg:table-cell text-xs text-ndor-ink-muted",children:JI(e.last_activity_at)})]},e.account_id)})})]})})})]}),(0,Xt.jsx)(tT,{accountId:v,onClose:()=>g(null)})]})}function ZI(e){let{label:t,count:n,active:a,onClick:r}=e;return(0,Xt.jsxs)("button",{type:"button",onClick:r,className:"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors ".concat(a?"border-ndor-ink bg-ndor-ink text-ndor-surface":"border-ndor-edge bg-ndor-surface text-ndor-ink hover:bg-ndor-surface-alt/60"),"data-testid":"admin-employers-health-chip-".concat(t.replace(/\W+/g,"-").toLowerCase()),children:[(0,Xt.jsx)("span",{className:"font-mono tabular-nums",children:n}),(0,Xt.jsx)("span",{children:t})]})}function eT(e){let{value:t,hideOn:n}=e;const a="sm"===n?"hidden sm:table-cell":"md"===n?"hidden md:table-cell":"";return(0,Xt.jsx)("td",{className:"py-2 pr-3 text-right font-mono tabular-nums ".concat(a),children:null===t||void 0===t?"\u2014":t})}function tT(e){var t,n;let{accountId:a,onClose:r}=e;
2const[i,o]=(0,s.useState)(null),[l,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(null),[p,h]=(0,s.useState)("all"),[f,x]=(0,s.useState)(""),[v,g]=(0,s.useState)(50),[y,b]=(0,s.useState)(null),[w,j]=(0,s.useState)(!1),[k,N]=(0,s.useState)(null),_=(0,s.useCallback)(async()=>{if(a){d(!0),m(null);try{const e=await(0,zt.n)("/api/admin/employers/".concat(a));o(e)}catch(mK){m((null===mK||void 0===mK?void 0:mK.message)||"Failed to load detail.")}finally{d(!1)}}},[a]),D=(0,s.useCallback)(async()=>{if(a){j(!0),N(null);try{const e=new URLSearchParams;e.set("limit",String(v)),p&&"all"!==p&&e.set("action",p),f&&e.set("since",f);const t=await(0,zt.n)("/api/admin/employers/".concat(a,"/audit?").concat(e.toString()));b((null===t||void 0===t?void 0:t.rows)||[])}catch(mK){N((null===mK||void 0===mK?void 0:mK.message)||"Failed to load audit.")}finally{j(!1)}}},[a,p,f,v]);if((0,s.useEffect)(()=>{a&&(o(null),b(null),h("all"),x(""),g(50),_())},[a,_]),!a)return null;const C=(null===i||void 0===i?void 0:i.organisation)||{},A=(null===i||void 0===i?void 0:i.members)||[],S=(null===i||void 0===i?void 0:i.invitations)||[],E=(null===i||void 0===i?void 0:i.reviewer_assignments)||[],F=(null===i||void 0===i?void 0:i.roles)||[],R=(null===i||void 0===i?void 0:i.recent_audit)||[];return(0,Xt.jsx)(rg,{open:Boolean(a),onOpenChange:e=>!e&&r(),children:(0,Xt.jsxs)(lg,{className:"max-w-4xl max-h-[90vh] overflow-y-auto","data-testid":"admin-employer-detail-dialog",children:[(0,Xt.jsx)(cg,{children:(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Pn,{className:"h-4 w-4"}),C.name||(0,Xt.jsxs)("span",{className:"font-mono text-xs",children:[a.slice(0,8),"\u2026"]})]})}),l&&(0,Xt.jsxs)("div",{className:"flex items-center gap-2 py-6 justify-center text-sm text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," Loading detail\u2026"]}),u&&(0,Xt.jsx)("div",{className:"py-4 text-sm text-rose-200","data-testid":"admin-employer-detail-error",children:u}),i&&!l&&(0,Xt.jsxs)("div",{className:"space-y-5 text-sm",children:[(0,Xt.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,Xt.jsx)(nT,{icon:(0,Xt.jsx)(Tn,{className:"h-3.5 w-3.5"}),label:"Members",value:A.length}),(0,Xt.jsx)(nT,{icon:(0,Xt.jsx)(kn,{className:"h-3.5 w-3.5"}),label:"Active roles",value:F.filter(e=>KI(null===e||void 0===e?void 0:e.status)).length}),(0,Xt.jsx)(nT,{icon:(0,Xt.jsx)(DR,{className:"h-3.5 w-3.5"}),label:"Reviewers",value:new Set(E.filter(e=>"active"===e.assignment_status).map(e=>e.reviewer_user_id)).size}),(0,Xt.jsx)(nT,{icon:(0,Xt.jsx)(In,{className:"h-3.5 w-3.5"}),label:"Open reviews",value:null!==(t=i.open_reviews_total)&&void 0!==t?t:"\u2014"})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,Xt.jsx)(Vw,{variant:i.activated?"default":"outline",children:i.activated?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Og,{className:"h-3 w-3 mr-1"})," Activated"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(pg,{className:"h-3 w-3 mr-1"})," Placeholder"]})}),(null===(n=i.entitlement)||void 0===n?void 0:n.plan_tier)&&(0,Xt.jsxs)(Vw,{variant:"outline",children:["Plan: ",Bf(i.entitlement.plan_tier)]}),(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-muted",children:["Created ",JI(C.created_at)]})]}),(0,Xt.jsx)(sT,{accountId:a,entitlement:i.entitlement,onUpdated:e=>{e&&o(t=>t?(0,c.A)((0,c.A)({},t),{},{entitlement:(0,c.A)((0,c.A)({},t.entitlement||{}),{},{channel_2_enabled:e.channel_2.enabled})}):t)}}),(0,Xt.jsx)(aT,{title:"Members",icon:(0,Xt.jsx)(Tn,{className:"h-3.5 w-3.5"}),children:0===A.length?(0,Xt.jsx)(rT,{text:"No members."}):(0,Xt.jsxs)("table",{className:"w-full text-xs",children:[(0,Xt.jsx)("thead",{children:(0,Xt.jsxs)("tr",{className:"text-left text-[10px] uppercase text-ndor-ink-muted border-b",children:[(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"User"}),(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"Role"}),(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"Joined"})]})}),(0,Xt.jsx)("tbody",{children:A.map(e=>(0,Xt.jsxs)("tr",{className:"border-b last:border-0",children:[(0,Xt.jsxs)("td",{className:"py-1.5 pr-2 font-mono",children:[e.user_id.slice(0,8),"\u2026"]}),(0,Xt.jsx)("td",{className:"py-1.5 pr-2",children:(0,Xt.jsx)(Vw,{variant:"outline",children:e.role})}),(0,Xt.jsx)("td",{className:"py-1.5 pr-2 text-ndor-ink-muted",children:JI(e.joined_at)})]},e.user_id))})]})}),(0,Xt.jsx)(aT,{title:"Invitations (".concat(S.length,")"),icon:(0,Xt.jsx)(WI,{className:"h-3.5 w-3.5"}),children:0===S.length?(0,Xt.jsx)(rT,{text:"No invitations on this account."}):(0,Xt.jsxs)("table",{className:"w-full text-xs",children:[(0,Xt.jsx)("thead",{children:(0,Xt.jsxs)("tr",{className:"text-left text-[10px] uppercase text-ndor-ink-muted border-b",children:[(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"Email"}),(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"Role"}),(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"Status"}),(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"Issued"})]})}),(0,Xt.jsx)("tbody",{children:S.slice(0,20).map(e=>(0,Xt.jsxs)("tr",{className:"border-b last:border-0",children:[(0,Xt.jsx)("td",{className:"py-1.5 pr-2 break-all",children:e.target_email}),(0,Xt.jsx)("td",{className:"py-1.5 pr-2",children:(0,Xt.jsx)(Vw,{variant:"outline",children:e.target_role})}),(0,Xt.jsx)("td",{className:"py-1.5 pr-2",children:(0,Xt.jsx)(Vw,{variant:"pending"===e.status?"default":"outline",children:e.status})}),(0,Xt.jsx)("td",{className:"py-1.5 pr-2 text-ndor-ink-muted",children:JI(e.created_at)})]},e.id))})]})}),(0,Xt.jsx)(aT,{title:"Reviewer coverage (".concat(E.length,")"),icon:(0,Xt.jsx)(DR,{className:"h-3.5 w-3.5"}),children:0===E.length?(0,Xt.jsx)(rT,{text:"No reviewer assignments."}):(0,Xt.jsxs)("table",{className:"w-full text-xs",children:[(0,Xt.jsx)("thead",{children:(0,Xt.jsxs)("tr",{className:"text-left text-[10px] uppercase text-ndor-ink-muted border-b",children:[(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"Reviewer"}),(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"Role"}),(0,Xt.jsx)("th",{className:"py-1.5 pr-2",children:"Status"})]})}),(0,Xt.jsx)("tbody",{children:E.slice(0,50).map(e=>(0,Xt.jsxs)("tr",{className:"border-b last:border-0",children:[(0,Xt.jsxs)("td",{className:"py-1.5 pr-2 font-mono",children:[e.reviewer_user_id.slice(0,8),"\u2026"]}),(0,Xt.jsxs)("td",{className:"py-1.5 pr-2 font-mono",children:[e.role_id.slice(0,8),"\u2026"]}),(0,Xt.jsx)("td",{className:"py-1.5 pr-2",children:(0,Xt.jsx)(Vw,{variant:"active"===e.assignment_status?"default":"outline",children:e.assignment_status})})]},e.assignment_id))})]})}),(0,Xt.jsx)(aT,{title:"Recent activity (last 20)",icon:(0,Xt.jsx)(pg,{className:"h-3.5 w-3.5"}),children:0===R.length?(0,Xt.jsx)(rT,{text:"No audit rows yet."}):(0,Xt.jsx)("ul",{className:"space-y-1",children:R.map(e=>(0,Xt.jsxs)("li",{className:"flex items-center justify-between rounded border px-2 py-1.5 text-xs",children:[(0,Xt.jsx)("span",{className:"font-mono",children:e.action_class}),(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:JI(e.timestamp_utc)})]},e.id))})}),(0,Xt.jsxs)(aT,{title:"Audit search",icon:(0,Xt.jsx)(HI,{className:"h-3.5 w-3.5"}),children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-end gap-2",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-[10px] uppercase tracking-wide",children:"Action"}),(0,Xt.jsxs)(Vv,{value:p,onValueChange:h,children:[(0,Xt.jsx)(Wv,{className:"h-8 w-[220px]","data-testid":"admin-employer-audit-action",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:YI.map(e=>(0,Xt.jsx)(Yv,{value:e,children:e},e))})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-[10px] uppercase tracking-wide",children:"Since (ISO 8601)"}),(0,Xt.jsx)(Ag,{value:f,onChange:e=>x(e.target.value),placeholder:"2026-01-01T00:00:00Z",className:"h-8 w-[220px] font-mono text-xs","data-testid":"admin-employer-audit-since"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-[10px] uppercase tracking-wide",children:"Limit"}),(0,Xt.jsx)(Ag,{type:"number",value:v,min:1,max:200,onChange:e=>g(Math.max(1,Math.min(200,Number(e.target.value)||50))),className:"h-8 w-[100px]","data-testid":"admin-employer-audit-limit"})]}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:D,disabled:w,"data-testid":"admin-employer-audit-run",children:[w?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):(0,Xt.jsx)(wC,{className:"h-3.5 w-3.5 mr-1.5"}),"Run query"]})]}
2),k&&(0,Xt.jsx)("p",{className:"text-xs text-rose-200 mt-2",children:k}),null!==y&&(0,Xt.jsx)("div",{className:"mt-3","data-testid":"admin-employer-audit-results",children:0===y.length?(0,Xt.jsx)(rT,{text:"No rows match the filter."}):(0,Xt.jsx)("ul",{className:"space-y-1",children:y.map(e=>(0,Xt.jsxs)("li",{className:"rounded border px-2 py-1.5 text-xs","data-testid":"admin-employer-audit-row-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsx)("span",{className:"font-mono",children:e.action_class}),(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:JI(e.timestamp_utc)})]}),e.actor_identity&&(0,Xt.jsxs)("div",{className:"text-[10px] text-ndor-ink-muted font-mono mt-0.5",children:["actor ",String(e.actor_identity).slice(0,8),"\u2026"]})]},e.id))})})]})]})]})})}function nT(e){let{icon:t,label:n,value:a}=e;return(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2.5",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:[t,(0,Xt.jsx)("span",{children:n})]}),(0,Xt.jsx)("div",{className:"mt-1.5 text-xl font-mono tabular-nums text-ndor-ink",children:null===a||void 0===a?"\u2014":a})]})}function aT(e){let{title:t,icon:n,children:a}=e;return(0,Xt.jsxs)("section",{children:[(0,Xt.jsxs)("h3",{className:"text-xs font-medium uppercase tracking-wide text-ndor-ink-muted mb-2 flex items-center gap-1.5",children:[n,t]}),a]})}function rT(e){let{text:t}=e;return(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted italic",children:t})}function sT(e){let{accountId:t,entitlement:n,onUpdated:a}=e;const r=Boolean(null===n||void 0===n?void 0:n.channel_2_enabled),[i,o]=(0,s.useState)(!1),[l,c]=(0,s.useState)(!1),d=!r,u=r?"Active":"Dormant \xb7 Admin Controlled",m=r?"enabled":"dormant",p=r?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/40":"bg-blue-500/10 text-blue-200 border border-blue-500/30";return(0,Xt.jsxs)("section",{"data-testid":"admin-channel-2-control",className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30 px-4 py-4 space-y-3",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-ndor-ink-muted",children:"Channel-2"}),(0,Xt.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-medium ".concat(p),"data-testid":"admin-channel-2-status-".concat(m),children:u})]}),!i&&(0,Xt.jsx)("button",{type:"button",disabled:l,onClick:()=>o(!0),className:r?"text-xs font-medium px-3 py-1.5 rounded border border-ndor-edge bg-ndor-bg hover:bg-ndor-surface text-ndor-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 focus-visible:ring-offset-2 focus-visible:ring-offset-ndor-bg transition":"text-xs font-semibold px-3 py-1.5 rounded bg-blue-600 hover:bg-blue-500 text-white shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 focus-visible:ring-offset-2 focus-visible:ring-offset-ndor-bg transition disabled:opacity-50","data-testid":"admin-channel-2-toggle","aria-label":r?"Disable Channel-2 for this workspace":"Enable Channel-2 for this workspace",children:r?"Disable Channel-2":"Enable Channel-2"})]}),(0,Xt.jsx)("p",{className:"text-[12px] text-ndor-ink-muted leading-relaxed max-w-prose",children:"Enabling Channel-2 allows this workspace to access governed Surfaced Candidates and Signals workflows, subject to entitlement and usage controls. Default is dormant; only admins can change this. Every change is audit-logged."}),i&&(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1 border-t border-ndor-edge/60 mt-2","data-testid":"admin-channel-2-confirm",children:[(0,Xt.jsx)("span",{className:"text-xs text-ndor-ink py-2",children:d?"Confirm: enable Channel-2 for this workspace?":"Confirm: disable Channel-2 for this workspace?"}),(0,Xt.jsx)("button",{type:"button",disabled:l,onClick:async()=>{c(!0);try{const e=await(0,zt.n)("/api/admin/employers/".concat(t,"/channel-2"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel_2_enabled:d})});toast.success(d?"Channel-2 enabled.":"Channel-2 disabled."),"function"===typeof a&&a(e),o(!1)}catch(pK){var e,n,r,s,i;const a=(null===pK||void 0===pK||null===(e=pK.data)||void 0===e||null===(n=e.detail)||void 0===n?void 0:n.code)||(null===pK||void 0===pK?void 0:pK.code)||"TOGGLE_FAILED",o=(null===pK||void 0===pK||null===(r=pK.data)||void 0===r||null===(s=r.detail)||void 0===s?void 0:s.message)||(null===pK||void 0===pK||null===(i=pK.data)||void 0===i?void 0:i.message)||(null===pK||void 0===pK?void 0:pK.message)||"Toggle failed.";toast.error("".concat(a,": ").concat(o))}finally{c(!1)}},className:d?"text-xs font-semibold px-3 py-1.5 rounded bg-blue-600 hover:bg-blue-500 text-white disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 focus-visible:ring-offset-2 focus-visible:ring-offset-ndor-bg":"text-xs font-semibold px-3 py-1.5 rounded bg-rose-600 hover:bg-rose-500 text-white disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-400 focus-visible:ring-offset-2 focus-visible:ring-offset-ndor-bg","data-testid":"admin-channel-2-confirm-yes",children:l?"Applying\u2026":d?"Yes, enable":"Yes, disable"}),(0,Xt.jsx)("button",{type:"button",disabled:l,onClick:()=>o(!1),className:"text-xs px-3 py-1.5 rounded border border-ndor-edge bg-ndor-bg hover:bg-ndor-surface text-ndor-ink disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 focus-visible:ring-offset-2 focus-visible:ring-offset-ndor-bg","data-testid":"admin-channel-2-confirm-no",children:"Cancel"})]})]})}const iT=e=>"owner"===e||"admin"===e,oT=iT,lT={owner:"Owner",admin:"Admin",recruiter:"Recruiter",reviewer:"Reviewer"}
2,cT={owner:"Created the organisation. Highest authority. Can do everything an admin can do, and is the only role auto-assigned at organisation creation.",admin:"Account governance. Invites members, modifies roles, suspends, revokes, and shares full reviewer-lifecycle controls with recruiters.",recruiter:"Operational hiring authority. Creates and publishes roles, runs matching, sends interest signals, assigns reviewers, and routes candidates. Cannot manage members.",reviewer:"Reviews candidates routed to them. Can start, decide (advance / reject / on-hold), and add append-only notes on their own reviews only. No org or member management."},dT=[{area:"Organisation",action:"Edit organisation profile",owner:"yes",admin:"yes",recruiter:"no",reviewer:"no"},{area:"Organisation",action:"View plan & usage",owner:"yes",admin:"yes",recruiter:"yes",reviewer:"yes"},{area:"Members",action:"Invite a new member",owner:"yes",admin:"yes",recruiter:"no",reviewer:"no"},{area:"Members",action:"Reissue / revoke pending invitation",owner:"yes",admin:"yes",recruiter:"no",reviewer:"no"},{area:"Members",action:"Change a member\u2019s role",owner:"yes",admin:"yes",recruiter:"no",reviewer:"no"},{area:"Members",action:"Suspend / unsuspend a member",owner:"yes",admin:"yes",recruiter:"no",reviewer:"no"},{area:"Members",action:"Revoke a member",owner:"yes",admin:"yes",recruiter:"no",reviewer:"no"},{area:"Roles",action:"Create / edit a role draft",owner:"yes",admin:"yes",recruiter:"yes",reviewer:"no"},{area:"Roles",action:"Publish / close / archive a role",owner:"yes",admin:"yes",recruiter:"yes",reviewer:"no"},{area:"Roles",action:"Send an interest signal",owner:"yes",admin:"yes",recruiter:"yes",reviewer:"no"},{area:"Reviewers",action:"Assign / pause / resume / unassign a reviewer",owner:"yes",admin:"yes",recruiter:"yes",reviewer:"no"},{area:"Reviewers",action:"Route a revealed candidate to reviewers",owner:"yes",admin:"yes",recruiter:"yes",reviewer:"no"},{area:"Reviews",action:"Start a review",owner:"no",admin:"no",recruiter:"no",reviewer:"self"},{area:"Reviews",action:"Decide (advance / reject / on-hold)",owner:"no",admin:"no",recruiter:"no",reviewer:"self"},{area:"Reviews",action:"Add a review note",owner:"no",admin:"no",recruiter:"no",reviewer:"self"},{area:"Audit",action:"View account-wide activity log",owner:"yes",admin:"yes",recruiter:"yes",reviewer:"self"}];function uT(e){let{value:t}=e;return"yes"===t?(0,Xt.jsx)("span",{className:"inline-flex items-center justify-center w-6 h-6 rounded-full bg-emerald-500/10 text-emerald-200 border border-emerald-500/40",children:(0,Xt.jsx)(Zm,{className:"h-3.5 w-3.5"})}):"self"===t?(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] border-amber-300 text-amber-200 bg-amber-500/10",title:"Reviewer can take this action only on their own review rows.",children:"Own only"}):(0,Xt.jsx)("span",{className:"inline-flex items-center justify-center w-6 h-6 rounded-full bg-ndor-surface-alt text-slate-300 border border-slate-200",children:(0,Xt.jsx)(xh,{className:"h-3.5 w-3.5"})})}function mT(){const e=dT.reduce((e,t)=>((e[t.area]=e[t.area]||[]).push(t),e),{});return(0,Xt.jsxs)("div",{className:"p-4 sm:p-6 max-w-5xl mx-auto space-y-6","data-testid":"employer-permissions-page",children:[(0,Xt.jsxs)("header",{className:"space-y-2",children:[(0,Xt.jsxs)(Et,{to:"/employer",className:"inline-flex items-center text-xs text-ndor-ink-muted hover:text-ndor-ink","data-testid":"employer-permissions-back",children:[(0,Xt.jsx)(Zg,{className:"h-3 w-3 mr-1"})," Back to Organisation"]}),(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold tracking-tight text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-5 w-5 text-ndor-ink-muted"}),"Roles & permissions"]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary max-w-2xl",children:"Reference of who can do what inside an organisation. Owners are admin-equivalent for every employer write. Recruiters run the day-to-day hiring and reviewer lifecycle. Reviewers decide on their own assigned reviews only. Every cell below mirrors the actual backend enforcement \u2014 if a button is missing for your role, it is governance, not a bug."})]}),(0,Xt.jsx)("section",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Object.entries(cT).map(e=>{let[t,n]=e;return(0,Xt.jsxs)(Fy,{"data-testid":"employer-permissions-role-".concat(t),children:[(0,Xt.jsx)(Ry,{className:"pb-2",children:(0,Xt.jsxs)(Iy,{className:"text-sm font-medium flex items-center gap-2",children:[(0,Xt.jsx)(En,{className:"h-3.5 w-3.5 text-ndor-ink-muted"}),lT[t]]})}),(0,Xt.jsx)(Py,{children:(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:n})})]},t)})}),(0,Xt.jsxs)(Fy,{"data-testid":"employer-permissions-matrix",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsx)(Iy,{className:"text-sm font-medium",children:"Permissions matrix"})}),(0,Xt.jsx)(Py,{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm",children:[(0,Xt.jsx)("thead",{children:(0,Xt.jsxs)("tr",{className:"border-b text-left text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:[(0,Xt.jsx)("th",{className:"py-2 pr-3",children:"Action"}),["owner","admin","recruiter","reviewer"].map(e=>(0,Xt.jsx)("th",{className:"py-2 px-2 text-center",children:lT[e]},e))]})}),(0,Xt.jsx)("tbody",{children:Object.entries(e).map(e=>{let[t,n]=e;return(0,Xt.jsxs)(s.Fragment,{children:[(0,Xt.jsx)("tr",{className:"bg-ndor-surface-alt/40",children:(0,Xt.jsx)("td",{colSpan:5,className:"py-1.5 px-3 text-[10px] font-semibold uppercase tracking-wider text-ndor-ink-muted",children:t})}),n.map((e,n)=>(0,Xt.jsxs)("tr",{className:"border-b last:border-0","data-testid":"employer-permissions-row-".concat(e.action.replace(/\W+/g,"-").toLowerCase()),children:[(0,Xt.jsx)("td",{className:"py-2 pr-3 text-xs",children:e.action}),(0,Xt.jsx)("td",{className:"py-2 px-2 text-center",children:(0,Xt.jsx)(uT,{value:e.owner})}),(0,Xt.jsx)("td",{className:"py-2 px-2 text-center",children:(0,Xt.jsx)(uT,{value:e.admin})}),(0,Xt.jsx)("td",{className:"py-2 px-2 text-center",children:(0,Xt.jsx)(uT,{value:e.recruiter})}),(0,Xt.jsx)("td",{className:"py-2 px-2 text-center",children:(0,Xt.jsx)(uT,{value:e.reviewer})})]},"".concat(t,"-").concat(n)))]},t)})})]})})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Append-only audit trail: every action above is recorded with actor, authority class, and timestamp in the account's governance ledger. Audit rows cannot be altered or deleted."})]})}
2const pT=wn("clipboard-check",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]),hT=wn("file-check-2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]),fT=wn("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),xT=[{n:1,icon:kn,title:"Create a role",body:(0,Xt.jsxs)(Xt.Fragment,{children:["Define requirements, expectations, and dealbreakers. NDORFlow converts them into a structured evaluation framework that travels with the role.",(0,Xt.jsxs)("span",{className:"block mt-2 text-xs text-ndor-ink-muted",children:["Surface \xb7 ",(0,Xt.jsx)(Et,{to:"/employer/roles",className:"underline",children:"Roles"})]})]})},{n:2,icon:_I,title:"Define the evaluation framework",body:(0,Xt.jsxs)(Xt.Fragment,{children:["Calibrate the criteria each candidate will be assessed against for this specific role \u2014 not a generic taxonomy. The framework is preserved alongside every assessment.",(0,Xt.jsx)("span",{className:"block mt-2 text-xs text-ndor-ink-muted",children:"Surface \xb7 Role wizard (inside Roles)"})]})},{n:3,icon:Tn,title:"Upload Candidate Dossiers",body:(0,Xt.jsxs)(Xt.Fragment,{children:["Direct applicants, uploaded CVs and imported candidates are normalised into Candidate Dossiers \u2014 one structured artefact per identity, normalised regardless of how they arrived.",(0,Xt.jsxs)("span",{className:"block mt-2 text-xs text-ndor-ink-muted",children:["Surface \xb7 ",(0,Xt.jsx)(Et,{to:"/employer/candidates",className:"underline",children:"Candidates"})]})]})},{n:4,icon:pT,title:"Review the dossier assessment",body:(0,Xt.jsxs)(Xt.Fragment,{children:["Each Candidate Dossier carries a reviewable assessment against the role\u2019s framework \u2014 strengths, gaps, evidence quality, reasoning consistency. You see the working, not just a verdict.",(0,Xt.jsxs)("span",{className:"block mt-2 text-xs text-ndor-ink-muted",children:["Surface \xb7 ",(0,Xt.jsx)(Et,{to:"/employer/reviews",className:"underline",children:"Reviews"})]})]})},{n:5,icon:QC,title:"Shortlist dossiers",body:(0,Xt.jsx)(Xt.Fragment,{children:"Compare Candidate Dossiers side-by-side against the same framework. Reduce inconsistency between reviewers. Preserve the reasoning trail behind every advance and rejection."})},{n:6,icon:hT,title:"Export the Governance Pack",body:(0,Xt.jsx)(Xt.Fragment,{children:"The Dossier\u2019s assessment, the reasoning trail, the verdict chain, and the operator identity are frozen into an immutable Governance Pack \u2014 PDF + DOCX, SHA-anchored. The decision record outlives the role."})}],vT=[{icon:pT,title:"Dossier evaluations",body:(0,Xt.jsx)(Xt.Fragment,{children:"A structured assessment of one Candidate Dossier against one role\u2019s evaluation framework. Includes evidence, reasoning and a recommendation \u2014 never a hidden score."})},{icon:hT,title:"Governance Packs",body:(0,Xt.jsx)(Xt.Fragment,{children:"An immutable, SHA-anchored decision record exported as PDF + DOCX. Cover, governance summary, interpretation, evidence chain, verdict, operator identity. The pack is the decision record."})},{icon:kn,title:"Role activations",body:(0,Xt.jsx)(Xt.Fragment,{children:"Each open role you\u2019re actively hiring against consumes one active-role slot from your plan. Closing or archiving a role returns its slot for reuse."})},{icon:Fn,title:"Reasoning support",body:(0,Xt.jsx)(Xt.Fragment,{children:"NDORFlow surfaces evidence and reasoning. Reviewers and hiring managers still make the call \u2014 the platform makes the call defensible."})},{icon:Dn,title:"Signals",body:(0,Xt.jsx)(Xt.Fragment,{children:"Anonymous candidate matches and consent-based profile reveal \u2014 built and live, available for enabled workspaces. Evidence-led decisions today happen in Roles via imported candidates and evaluations."})}];function gT(){return(0,Xt.jsxs)("div",{className:"p-4 sm:p-6 max-w-5xl mx-auto
2space-y-8","data-testid":"employer-workflow-page",children:[(0,Xt.jsxs)("header",{className:"space-y-2",children:[(0,Xt.jsxs)(Et,{to:"/employer",className:"inline-flex items-center text-xs text-ndor-ink-muted hover:text-ndor-ink","data-testid":"employer-workflow-back",children:[(0,Xt.jsx)(Zg,{className:"h-3 w-3 mr-1"})," Back to Dashboard"]}),(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold tracking-tight text-ndor-ink flex items-center gap-2","data-testid":"employer-workflow-heading",children:[(0,Xt.jsx)(fT,{className:"h-5 w-5 text-ndor-ink-muted"}),"How NDORFlow works"]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary max-w-3xl",children:"NDORFlow is a structured hiring decision-support layer \u2014 not an ATS, not auto-apply, not keyword ranking. This page orients you to the workflow each role moves through and the concepts behind it."})]}),(0,Xt.jsxs)("section",{className:"space-y-4","data-testid":"employer-workflow-section-pipeline",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h2",{className:"text-lg font-semibold text-ndor-ink",children:"Your hiring workflow"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:"Six stages. Each one builds the evidence trail behind the next. Decisions stay with your people; the platform makes them consistent."})]}),(0,Xt.jsx)("ol",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:xT.map(e=>{let{n:t,icon:n,title:a,body:r}=e;return(0,Xt.jsx)("li",{children:(0,Xt.jsxs)(Fy,{className:"h-full border-ndor-edge bg-ndor-surface-alt/40",children:[(0,Xt.jsxs)(Ry,{className:"pb-2",children:[(0,Xt.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,Xt.jsx)("span",{className:"font-mono text-[11px] tracking-wider text-ndor-ink-muted",children:String(t).padStart(2,"0")}),(0,Xt.jsx)(n,{className:"h-3.5 w-3.5 text-ndor-ink-muted"})]}),(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:a})]}),(0,Xt.jsx)(Py,{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:r})]})},t)})})]}),(0,Xt.jsxs)("section",{className:"space-y-4","data-testid":"employer-workflow-section-concepts",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h2",{className:"text-lg font-semibold text-ndor-ink",children:"Understanding NDORFlow"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:"A short glossary of the concepts you will see in the workspace."})]}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:vT.map(e=>{let{icon:t,title:n,body:a}=e;return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface-alt/40",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 flex flex-row items-center gap-2 space-y-0",children:[(0,Xt.jsx)(t,{className:"h-4 w-4 text-ndor-ink-muted"}),(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:n})]}),(0,Xt.jsx)(Py,{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:a})]},n)})})]}),(0,Xt.jsxs)("section",{className:"space-y-4","data-testid":"employer-workflow-section-governance",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h2",{className:"text-lg font-semibold text-ndor-ink",children:"Governance & consistency"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:"What stays preserved when you hire through NDORFlow."})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface-alt/40",children:[(0,Xt.jsxs)(Ry,{className:"pb-2 flex flex-row items-center gap-2 space-y-0",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-ink-muted"}),(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"A defensible record of every hire"})]}),(0,Xt.jsxs)(Py,{className:"text-xs text-ndor-ink-secondary leading-relaxed space-y-3",children:[(0,Xt.jsxs)("ul",{className:"space-y-1.5 list-disc list-inside marker:text-ndor-ink-muted",children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("span",{className:"text-ndor-ink",children:"Structured review."})," ","Every candidate is assessed against the same framework for the role they applied to."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("span",{className:"text-ndor-ink",children:"Decision consistency."}
2)," ","The framework reduces reviewer variance without removing reviewer judgement."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("span",{className:"text-ndor-ink",children:"Rationale preservation."})," ","Reasoning trails are attached to advances and rejections \u2014 not just the outcome."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("span",{className:"text-ndor-ink",children:"Defensibility."})," ","When someone asks how a hire was made, the evidence trail is intact."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("span",{className:"text-ndor-ink",children:"Auditability."})," ","Decision packs can be exported and reviewed by anyone with appropriate access."]})]}),(0,Xt.jsxs)("p",{className:"text-[11px] italic text-ndor-ink-muted pt-2 border-t border-ndor-edge/50",children:["Roles & permissions inside your organisation are managed on the"," ",(0,Xt.jsx)(Et,{to:"/employer/help/permissions",className:"underline",children:"Permissions"})," ","page."]})]})]})]})]})}const yT=wn("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);function bT(e,t){const n=null===e||void 0===e?"\u2014":e;return null===t?"".concat(n," / \u221e"):void 0===t?"".concat(n," / \u2014"):"".concat(n," / ").concat(t)}function wT(e){var t,n,a,r,i,o,l,c,d,u,m,p,h;let{accountId:f,memberRole:x}=e;const[v,g]=(0,s.useState)(!0),[y,b]=(0,s.useState)({activeRoles:null,accountOpenReviews:null,activeReviewers:null,pendingInvites:null}),[w,j]=(0,s.useState)(null),k=(0,s.useCallback)(async()=>{var e,t,n;if(!f)return;g(!0);const a=await Promise.allSettled([(0,zt.n)("/api/employer/roles"),(0,zt.n)("/api/employer/v1/plan"),Mt.supabase.from("emp_candidate_reviews").select("review_id, status").eq("account_id",f).in("status",["pending","in_review"]),Mt.supabase.from("emp_reviewer_assignments").select("assignment_id, reviewer_user_id, assignment_status").eq("account_id",f).eq("assignment_status","active"),Mt.supabase.from("emp_member_invitations").select("id, status").eq("account_id",f).eq("status","pending")]),r={activeRoles:null,accountOpenReviews:null,activeReviewers:null,pendingInvites:null};if("fulfilled"===a[0].status){var s,i;const e=(null===(s=a[0].value)||void 0===s?void 0:s.items)||(null===(i=a[0].value)||void 0===i?void 0:i.roles)||a[0].value||[];r.activeRoles=(Array.isArray(e)?e:[]).filter(e=>KI(null===e||void 0===e?void 0:e.status)).length}var o,l;("fulfilled"===a[1].status&&j(a[1].value||null),"fulfilled"!==a[2].status||null!==(e=a[2].value)&&void 0!==e&&e.error)||(r.accountOpenReviews=((null===(o=a[2].value)||void 0===o?void 0:o.data)||[]).length);if("fulfilled"===a[3].status&&(null===(t=a[3].value)||void 0===t||!t.error)){var c;const e=(null===(c=a[3].value)||void 0===c?void 0:c.data)||[];r.activeReviewers=new Set(e.map(e=>e.reviewer_user_id)).size}"fulfilled"!==a[4].status||null!==(n=a[4].value)&&void 0!==n&&n.error||(r.pendingInvites=((null===(l=a[4].value)||void 0===l?void 0:l.data)||[]).length);b(r),g(!1)},[f]);if((0,s.useEffect)(()=>{k()},[k]),!f)return null;if(x&&!["owner","admin","recruiter"].includes(x))return null;const N=(null===w||void 0===w?void 0:w.entitlement)||null,_=(null===w||void 0===w?void 0:w.active_plan)||null,D=(null===N||void 0===N?void 0:N.plan_tier)||(null===_||void 0===_?void 0:_.plan_tier)||null,C=Bf(D),A=(Lf(D),null===N||void 0===N||!N.plan_tier||Boolean(null===(t=null===_||void 0===_?void 0:_.placeholder)||void 0===t||t)),S=A?"Activation pending founder review.":"Activation in effect.",E=A?"outline":"default",F=null!==(n=null!==(a=null===N||void 0===N?void 0:N.active_roles_cap)&&void 0!==a?a:null===_||void 0===_?void 0:_.active_roles_cap)&&void 0!==n?n:null,R=null!==(r=null!==(i=null===N||void 0===N?void 0:N.signals_allowance_monthly)&&void 0!==i?i:null===_||void 0===_?void 0:_.signals_allowance_monthly)&&void 0!==r?r:null,I=null!==(o=null===N||void 0===N?void 0:N.active_roles_current)&&void 0!==o?o:null,T=null!==(l=null===N||void 0===N?void 0:N.signals_used_this_period)&&void 0!==l?l:null,P=null!==(c=null===N||void 0===N?void 0:N.governance_packs_used_this_period)&&void 0!==c?c:null,O=null!==(d=null!==(u=null===N||void 0===N?void 0:N.governance_pack_allowance_monthly)&&void 0!==u?u:null===_||void 0===_?void 0:_.governance_pack_allowance_monthly)&&void 0!==d?d:null,B=null!==(m=null!==(p=null===N||void 0===N?void 0:N.eval_cap_monthly)&&void 0!==p?p:null===_||void 0===_?void 0:_.eval_cap_monthly)&&void 0!==m?m:null,L=null!==(h=null===N||void 0===N?void 0:N.evaluations_used_this_period)&&void 0!==h?h:null,M=null===N||void 0===N?void 0:N.period_starts_at,z=null===N||void 0===N?void 0:N.period_ends_at,U=lT[x]||x||"\u2014",V=cT[x]||"",q=(e,t)=>
2{if(null===t||void 0===t)return null;const n=null===e||void 0===e?0:Number(e);return Math.max(0,Number(t)-n)},W=(e,t,n)=>1===Number(e)?t:n,H=q(I,F),G=q(L,B),K=q(P,O),Y=q(T,R),J=null===F?"Unlimited active roles":"".concat(H," ").concat(W(H,"active role","active roles")," available"),$=null===B?"Unlimited evaluations":"".concat(G," ").concat(W(G,"evaluation","evaluations")," remaining"),X=null===O?"Unlimited governance packs":"".concat(K," ").concat(W(K,"governance pack","governance packs")," remaining"),Q=null===R?"Unlimited signals":"".concat(Y," ").concat(W(Y,"signal","signals")," remaining this month");return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"employer-dashboard-panel",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-ink-muted"}),"Operational summary"]}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:k,disabled:v,className:"h-7 w-7 p-0","aria-label":"Refresh dashboard","data-testid":"employer-dashboard-refresh",children:v?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin"}):(0,Xt.jsx)(Kg,{className:"h-3.5 w-3.5"})})]}),(0,Xt.jsxs)(Py,{className:"space-y-5",children:[x&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2.5","data-testid":"employer-dashboard-identity",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,Xt.jsx)("span",{className:"text-ndor-ink-muted uppercase tracking-wider text-[10px]",children:"You are"}),(0,Xt.jsx)(Vw,{variant:"outline","data-testid":"employer-dashboard-my-role",children:U}),(0,Xt.jsx)(Et,{to:"/employer/help/permissions",className:"ml-auto text-[11px] text-ndor-ink-muted underline-offset-2 hover:underline","data-testid":"employer-dashboard-permissions-link",children:"Roles & permissions"})]}),V&&(0,Xt.jsx)("p",{className:"mt-1.5 text-[11px] text-ndor-ink-secondary leading-relaxed",children:V})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,Xt.jsx)(jT,{testId:"employer-dashboard-active-roles",icon:(0,Xt.jsx)(kn,{className:"h-3.5 w-3.5"}),label:"Active roles",value:y.activeRoles,href:"/employer/roles"}),(0,Xt.jsx)(jT,{testId:"employer-dashboard-open-reviews",icon:(0,Xt.jsx)(In,{className:"h-3.5 w-3.5"}),label:"Open reviews",value:y.accountOpenReviews,hint:"Across all reviewers on this account."}),(0,Xt.jsx)(jT,{testId:"employer-dashboard-active-reviewers",icon:(0,Xt.jsx)(DR,{className:"h-3.5 w-3.5"}),label:"Active reviewers",value:y.activeReviewers,href:"/employer/reviewers"}),(0,Xt.jsx)(jT,{testId:"employer-dashboard-pending-invites",icon:(0,Xt.jsx)(WI,{className:"h-3.5 w-3.5"}),label:"Pending invites",value:y.pendingInvites,href:"/employer/members"})]}),(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"employer-dashboard-plan-strip",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,Xt.jsxs)(Vw,{variant:"outline",className:"font-normal","data-testid":"employer-dashboard-plan-tier",children:[(0,Xt.jsx)(yT,{className:"h-3 w-3 mr-1"}),C," plan"]}),(0,Xt.jsx)(Vw,{variant:E,"data-testid":"employer-dashboard-activation-badge",children:S})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mb-2",children:"Remaining this period"}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-2",children:[(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2 text-xs text-ndor-ink","data-testid":"employer-dashboard-roles-left",children:J}),(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2 text-xs text-ndor-ink","data-testid":"employer-dashboard-evaluations-left",children:$}),(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2 text-xs text-ndor-ink","data-testid":"employer-dashboard-packs-left",children:X}),(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2 text-xs text-ndor-ink","data-testid":"employer-dashboard-signals-left",children:Q})]})]})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30 px-3 py-3 space-y-2","data-testid":"employer-dashboard-usage",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsx)("h4",{className:"text-xs font-medium text-ndor-ink uppercase tracking-wider",children:"Plan & usage"}),N?M&&z&&(0,Xt.jsxs)("span",{className:"text-[10px] text-ndor-ink-muted",children:["Period: ",new Date(M).toLocaleDateString()," \u2192 ",new Date(z).toLocaleDateString()]}):(0,Xt.jsx)("span",{className:"text-[10px] text-ndor-ink-muted",children:"Awaiting plan activation"})]}),(0,Xt.jsxs)("dl",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs",children:[(0,Xt.jsxs)("div",{"data-testid":"employer-dashboard-usage-active-roles",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase text-ndor-ink-muted",children:"Roles used"}),(0,Xt.jsx)("dd",{className:"font-mono tabular-nums text-ndor-ink",children:bT(I,F)})]}),(0,Xt.jsxs)("div",{"data-testid":"employer-dashboard-usage-evaluations",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase text-ndor-ink-muted",children:"Evaluations used"}),(0,Xt.jsx)("dd",{className:"font-mono tabular-nums text-ndor-ink",children:bT(L,B)})]}),(0,Xt.jsxs)("div",{"data-testid":"employer-dashboard-usage-packs",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase text-ndor-ink-muted",children:"Governance packs used"}),(0,Xt.jsx)("dd",{className:"font-mono tabular-nums text-ndor-ink",children:bT(P,O)})]}),(0,Xt.jsxs)("div",{"data-testid":"employer-dashboard-usage-signals",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase text-ndor-ink-muted",children:"Signals used this month"}),(0,Xt.jsx)("dd",{className:"font-mono tabular-nums text-ndor-ink",children:bT(T,R)})]})]})]}),A&&(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-ndor-edge bg-ndor-surface-alt px-3 py-2 text-xs text-ndor-ink-secondary","data-testid":"employer-dashboard-placeholder-note",children:[(0,Xt.jsx)(ty,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-ndor-ink-muted"}),(0,Xt.jsxs)("span",{children:["Placeholder pricing \u2014 billing not yet active."," Quotas above reflect the placeholder tier and may change before launch."]})]})]})]})}function jT(e){let{testId:t,icon:n,label:a,value:r,hint:s,href:i}=e;const o=(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2.5 h-full","data-testid":t,children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:[n,(0,Xt.jsx)("span",{children:a})]}),(0,Xt.jsx)("div",{className:"mt-1.5 text-xl font-mono tabular-nums text-ndor-ink",children:null===r||void 0===r?"\u2014":r}),s&&(0,Xt.jsx)("div",{className:"mt-1 text-[10px] leading-snug text-ndor-ink-muted",children:s}),i&&(0,Xt.jsxs)("div",{className:"mt-1 text-[10px] text-ndor-ink-muted flex items-center gap-0.5",children:[(0,Xt.jsx)("span",{children:"Open"}),(0,Xt.jsx)(zy,{className:"h-2.5 w-2.5"})]})]});return i?(0,Xt.jsx)(Et,{to:i,className:"block hover:bg-ndor-surface-alt/60 rounded-md transition-colors","data-testid":"".concat(t,"-link"),children:o}):o}const kT="NDORFlow does not auto-apply, auto-tailor, or auto-decide. Every paid action requires explicit user intent.";function NT(e){let{variant:t="inline",testId:n="doctrine-disclaimer",className:a=""}=e;return"block"===t?(0,Xt.jsxs)("aside",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-5 py-4 "+a,"data-testid":n,"data-doctrine":"institutional-disclaimer",children:[(0,Xt.jsx)("p",{className:"font-mono-ui text-[11px] uppercase tracking-[0.14em] text-ndor-gold",children:"Operating posture"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-ndor-ink-secondary",children:kT})]}):(0,Xt.jsx)("p",{className:"text-sm leading-relaxed text-ndor-ink-muted italic "+a,"data-testid":n,"data-doctrine":"institutional-disclaimer",children:kT})}const _T={starter:{label:"Starter",blurb:"Free baseline for small teams getting started."},professional:{label:"Professional",blurb:"For active recruiting teams.",highlight:!0},business:{label:"Business",blurb:"For scale-stage hiring teams."},enterprise:{label:"Enterprise",blurb:"Admin-provisioned. No self-serve activation."}};const DT={starter:"Starter",professional:"Professional",business:"Business",enterprise:"Enterprise"},CT={active:"Active",past_due:"Past due",downgraded_to_starter:"Downgraded to Starter",cancelled:"Cancelled",expired:"Expired"};function AT(e){if(!e)return null;try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch(t){return null}}function ST(e){let{lifecycle:t,ent:n,onManageBilling:a}=e;if(!t||"active"===t)return null;const r=AT(null===n||void 0===n?void 0:n.past_due_since),s=AT(null===n||void 0===n?void 0:n.downgraded_to_starter_at),i=AT(null===n||void 0===n?void 0:n.access_expires_at),o={past_due:{tone:"amber",title:"Your last payment failed.",body:r?"Please update your payment method to keep your plan active. Past due since ".concat(r,"."):"Please update your payment method to keep your plan active.",cta:"Update payment method"},downgraded_to_starter:{tone:"rose",title:"Your organisation has been downgraded to Starter.",body:s?"The previous plan was paused on ".concat(s," after a grace peri
2od. Higher-tier caps no longer apply."):"The previous plan was paused after a grace period. Higher-tier caps no longer apply.",cta:"Restore previous plan"},cancelled:{tone:"rose",title:"Your subscription has been cancelled.",body:i?"Access to higher-tier features ends ".concat(i,". Re-subscribe to restore caps."):"Re-subscribe to restore higher-tier caps.",cta:"Choose a plan"},expired:{tone:"rose",title:"Your subscription has expired.",body:"Re-subscribe to restore the previous plan tier.",cta:"Choose a plan"}}[t];if(!o)return null;const l="amber"===o.tone?"border-amber-500/30 bg-amber-500/10 text-amber-900":"border-rose-500/30 bg-rose-500/10 text-rose-900";return(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-3 rounded-md border ".concat(l," p-3 text-sm"),"data-testid":"emp-billing-lifecycle-".concat(t,"-banner"),role:"status","aria-live":"polite",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 shrink-0 mt-[2px]","aria-hidden":"true"}),(0,Xt.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,Xt.jsx)("p",{className:"font-medium",children:o.title}),(0,Xt.jsx)("p",{className:"text-xs opacity-90",children:o.body}),(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",onClick:a,className:"border-current bg-transparent hover:bg-current/10","data-testid":"emp-billing-lifecycle-".concat(t,"-cta"),children:o.cta})]})]})}function ET(e){let{label:t,used:n,cap:a,testId:r}=e;const s=Number.isFinite(n)?Math.max(0,n):0,i=Number.isFinite(a)&&a>0?a:null,o=i?Math.min(100,Math.round(s/i*100)):0,l=null!==i&&s>=i,c=l?"bg-rose-500":null!==i&&!l&&s/i>=.8?"bg-amber-500":"bg-ndor-ink",d=null===i?"unlimited":String(i);return(0,Xt.jsxs)("div",{"data-testid":r,className:"space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex justify-between items-baseline gap-2",children:[(0,Xt.jsx)("span",{className:"text-xs text-ndor-ink-muted",children:t}),(0,Xt.jsxs)("span",{className:"text-xs tabular-nums text-ndor-ink font-medium",children:[s," ",(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted font-normal",children:["/ ",d]})]})]}),(0,Xt.jsx)("div",{className:"h-2 rounded-full bg-ndor-edge overflow-hidden",role:"progressbar","aria-valuemin":0,"aria-valuemax":i||100,"aria-valuenow":s,"aria-label":"".concat(t,": ").concat(s," of ").concat(d," used"),children:(0,Xt.jsx)("div",{className:"h-full ".concat(c," transition-all"),style:{width:"".concat(i?o:0,"%")}})})]})}function FT(e){let{catalogue:t,currentTier:n,currentPeriod:a,period:r,onPeriodChange:s,canMutate:i,onChoosePlan:o,disabledReason:l}=e;return t&&0!==t.length?(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"emp-billing-plan-selector",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,Xt.jsx)("h3",{className:"text-sm font-medium text-ndor-ink",children:"Choose a plan"}),(0,Xt.jsx)("div",{className:"inline-flex rounded-md border border-ndor-edge bg-ndor-surface-alt overflow-hidden text-xs",role:"tablist","aria-label":"Billing period",children:["monthly","annual"].map(e=>(0,Xt.jsx)("button",{type:"button",role:"tab","aria-selected":r===e,onClick:()=>s(e),"data-testid":"emp-billing-period-".concat(e),className:r===e?"px-3 py-1.5 bg-ndor-ink text-ndor-surface":"px-3 py-1.5 text-ndor-ink-muted hover:text-ndor-ink",children:"monthly"===e?"Monthly":"Annual \xb7 save ~17%"},e))})]}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 items-stretch",children:t.map(e=>{const t=_T[e.plan_tier]||{label:e.plan_tier,blurb:""},s=!!e.is_contact_only,c=n===e.plan_tier&&("starter"===e.plan_tier||s||!a||a===r),d="annual"===r?e.price_annual_cents:e.price_monthly_cents,u=s||null===d||void 0===d?"Contact sales":function(e,t,n){if(null===e||void 0===e)return null;const a="GBP"===t?"\xa3":"USD"===t?"$":"EUR"===t?"\u20ac":"".concat(t," "),r=Math.round(e/100).toLocaleString();return"".concat(a).concat(r," / ").concat("annual"===n?"yr":"mo")}(d,e.currency,r),m=function(e){if(e.is_contact_only)return["Custom / unlimited active roles","Custom / unlimited evaluations","Custom / unlimited governance packs","Custom / unlimited signals","Dedicated reviewer pool & SLAs"];const t=[];if(null!==e.active_roles_cap&&void 0!==e.active_roles_cap&&t.push("".concat(e.active_roles_cap," active role").concat(1===e.active_roles_cap?"":"s")),null!==e.eval_cap_monthly&&void 0!==e.eval_cap_monthly&&t.pu
2sh("".concat(e.eval_cap_monthly," evaluation").concat(1===e.eval_cap_monthly?"":"s"," / month")),null!==e.governance_pack_allowance_monthly&&void 0!==e.governance_pack_allowance_monthly){const n=e.governance_pack_allowance_monthly;t.push("".concat(n," governance pack").concat(1===n?"":"s"," / month"))}if(null!==e.signals_allowance_monthly&&void 0!==e.signals_allowance_monthly){const n=e.signals_allowance_monthly;t.push("".concat(n," signal").concat(1===n?"":"s"," / month"))}if(null!==e.role_activation_cap_monthly&&void 0!==e.role_activation_cap_monthly){const n=e.role_activation_cap_monthly;t.push("".concat(n," role activation").concat(1===n?"":"s"," / month"))}return"starter"===e.plan_tier&&t.push("No overage (hard stop at cap)"),t}(e);return(0,Xt.jsxs)(Fy,{className:"flex flex-col h-full border ".concat(c?"border-ndor-ink ring-1 ring-ndor-ink/30":t.highlight?"border-ndor-edge ring-1 ring-amber-300/40":"border-ndor-edge"," shadow-sm"),"data-testid":"emp-billing-plan-card-".concat(e.plan_tier),children:[(0,Xt.jsxs)(Ry,{className:"pb-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:t.label}),c&&(0,Xt.jsx)(Vw,{variant:"outline","data-testid":"emp-billing-plan-current-badge-".concat(e.plan_tier),children:"Current"})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:t.blurb})]}),(0,Xt.jsxs)(Py,{className:"pt-0 flex flex-col flex-1 gap-3",children:[(0,Xt.jsx)("p",{className:"text-2xl font-serif-display font-semibold text-ndor-ink tabular-nums","data-testid":"emp-billing-plan-price-".concat(e.plan_tier),children:u}),(0,Xt.jsx)("ul",{className:"text-xs text-ndor-ink-secondary space-y-1.5 flex-1",children:m.map(e=>(0,Xt.jsxs)("li",{className:"flex items-start gap-1.5",children:[(0,Xt.jsx)(Og,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-ndor-ink-muted"}),(0,Xt.jsx)("span",{children:e})]},e))}),s?(0,Xt.jsx)("p",{className:"w-full mt-auto text-xs text-ndor-ink-muted italic px-1 py-2 border-t border-ndor-edge","data-testid":"emp-billing-plan-contact-note-".concat(e.plan_tier),children:"Admin-provisioned. Contact sales for activation."}):(0,Xt.jsx)(Rr,{variant:c?"outline":"default",size:"sm",disabled:!i||c||"starter"===e.plan_tier,onClick:()=>o(e.plan_tier,r),"data-testid":"emp-billing-plan-choose-".concat(e.plan_tier),className:"w-full mt-auto",title:i?void 0:l,children:c?"Current plan":"starter"===e.plan_tier?"Starter is default":"Choose plan"})]})]},e.plan_tier)})})]}):(0,Xt.jsx)("div",{className:"text-xs text-ndor-ink-muted","data-testid":"emp-billing-plan-selector-empty",children:"Plan catalogue is loading\u2026"})}function RT(e){var t,n,a,r,i,o,l,c,d,u,m,p,h,f,x;let{accountId:v}=e;const[g,y]=(0,s.useState)(null),[b,w]=(0,s.useState)(!0),[j,k]=(0,s.useState)(null),[N,_]=(0,s.useState)("monthly"),[D,C]=(0,s.useState)(!1),A=(null===g||void 0===g?void 0:g.entitlement)||null,S=(0,s.useCallback)(async()=>{w(!0),k(null);try{const e=await(0,zt.n)("/api/employer/v1/billing/subscription");y(e)}catch(pK){k((null===pK||void 0===pK?void 0:pK.message)||"Failed to load billing.")}finally{w(!1)}},[]);(0,s.useEffect)(()=>{S()},[S]);const E=(0,s.useCallback)(async(e,t)=>{if(null!==g&&void 0!==g&&g.is_owner)if("enabled"===(null===g||void 0===g?void 0:g.feature_flag)){C(!0);try{const n=await(0,zt.n)("/api/employer/v1/billing/checkout-session",{method:"POST",body:JSON.stringify({plan_tier:e,billing_period:t})});if(null===n||void 0===n||!n.checkout_url)throw new Error("No checkout URL returned.");window.location.assign(n.checkout_url)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Unable to start checkout."),C(!1)}}else fy.message("Employer billing is not active yet.");else fy.error("Only the organisation owner can manage billing.")},[g]),F=(0,s.useCallback)(async()=>{if(null!==g&&void 0!==g&&g.is_owner)if("enabled"===(null===g||void 0===g?void 0:g.feature_flag)){C(!0);try{const e=await(0,zt.n)("/api/employer/v1/billing/customer-portal",{method:"POST",body:JSON.stringify({})});if(null===e||void 0===e||!e.portal_url)throw new Error("No portal URL returned.");window.location.assign(e.portal_url)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Unable to open billing portal."),C(!1)}}else fy.message("Employer billing is not active yet.");else fy.error("Only the organisation owner can manage billing.")},[g]);if(b)return(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"emp-billing-loading",children:(0,Xt.jsxs)(Py,{className:"py-8 flex items-center justify-center gap-2 text-sm text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," Loading billing\u2026"]})});if(j)return(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"emp-billing-error",children:(0,Xt.jsx)(Py,{className:"py-6 text-sm text-ndor-ink-muted",children:j})});if(!g)return null;const R=g.feature_flag||"disabled",I=(null===(t=g.entitlement)||void 0===t?void 0:t.lifecycle_status)||"active",T=(null===(n=g.entitlement)||void 0===n?void 0:n.plan_tier)||"starter",P=(null===(a=g.entitlement)||void 0===a?void 0:a.billing_period)||null,O=g.is_owner&&"enabled"===R,B=g.is_owner?"enabled"!==R?"Employer billing is not active yet.":void 0:"Only the organisation owner can manage billing.",L=AT(null===(r=g.billing_link)||void 0===r?void 0:r.current_period_end),M=!(null===(i=g.billing_link)||void 0===i||!i.cancel_at_period_end);return(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"emp-billing-panel",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"emp-billing-state-card",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-ink-muted"}),"Subscription"]}),(0,Xt.jsx)(Vw,{variant:"outline","data-testid":"emp-billing-lifecycle-badge",className:"active"===I?"border-emerald-300/60 text-emerald-700":"past_due"===I?"border-amber-400/60 text-amber-700":"border-rose-400/60 text-rose-700",children:CT[I]||I})]}),(0,Xt.jsxs)(Py,{className:"pt-0 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-baseline gap-2",children:[(0,Xt.jsx)("span",{className:"text-2xl font-serif-display font-semibold text-ndor-ink","data-testid":"emp-billing-plan-tier",children:DT[T]||T}),P&&(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge text-ndor-ink-muted","data-testid":"emp-billing-plan-period",children:"annual"===P?"Annual":"Monthly"}),M&&(0,Xt.jsx)(Vw,{variant:"outline",className:"border-rose-400/40 text-rose-700","data-testid":"emp-billing-cancel-at-period-end",children:"Cancels at period end"})]}),L&&(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted","data-testid":"emp-billing-renews",children:[M?"Access ends ":"Renews ",L]}),"enabled"!==R&&(0,Xt.jsxs)("div",{className:"mt-2 flex items-start gap-2 rounded-md border border-ndor-edge bg-ndor-surface-alt/40 p-2 text-[11px] text-ndor-ink-muted","data-testid":"emp-billing-flag-disabled-note",children:[(0,Xt.jsx)(b_,{className:"h-3 w-3 mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"Employer billing is not active yet."})," ","You can preview plans and caps below; checkout activates after operator review."]})]})]})]}),(0,Xt.jsx)(ST,{lifecycle:I,ent:g.entitlement,onManageBilling:F}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"emp-billing-usage-card",children:[(0,Xt.jsxs)(Ry,{className:"pb-4",children:[(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"Current period usage"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Consumption against your plan caps for this billing period."})]}),(0,Xt.jsxs)(Py,{className:"pt-0 grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-5 pb-5",children:[(0,Xt.jsx)(ET,{label:"Roles used",used:null!==(o=null===A||void 0===A?void 0:A.active_roles_current)&&void 0!==o?o:0,cap:null!==(l=null===A||void 0===A?void 0:A.active_roles_cap)&&void 0!==l?l:null,testId:"emp-billing-usage-roles"}),(0,Xt.jsx)(ET,{label:"Evaluations used",used:null!==(c=null===A||void 0===A?void 0:A.evaluations_used_this_period)&&void 0!==c?c:0,cap:null!==(d=null===A||void 0===A?void 0:A.eval_cap_monthly)&&void 0!==d?d:null,testId:"emp-billing-usage-evaluations"}),(0,Xt.jsx)(ET,{label:"Governance packs used",used:null!==(u=null===A||void 0===A?void 0:A.governance_packs_used_this_period)&&void 0!==u?u:0,cap:null!==(m=null===A||void 0===A?void 0:A.governance_pack_allowance_monthly)&&void 0!==m?m:null,testId:"emp-billing-usage-packs"}),(0,Xt.jsx)(ET,{label:"Signals used this month",used:null!==(p=null===A||void 0===A?void 0:A.signals_used_this_period)&&void 0!==p?p:0,cap:null!==(h=null===A||void 0===A?void 0:A.signals_allowance_monthly)&&void 0!==h?h:null,testId:"emp-billing-usage-signals"})]})]}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm",children:(0,Xt.jsx)(Py,{className:"pt-5 space-y-4",children:(0,Xt.jsx)(FT,{catalogue:g.catalogue,currentTier:T,currentPeriod:P,period:N,onPeriodChange:_,canMutate:O&&!D,onChoosePlan:E,disabledReason:B})})}),(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-stretch sm:items-center",children:[(0,Xt.jsxs)(Rr,{variant:"outline",onClick:F,disabled:!O||D||!(null!==(f=g.billing_link)&&void 0!==f&&f.has_customer),"data-testid":"emp-billing-manage-cta",title:g.is_owner?"enabled"!==R?"Employer billing is not active yet.":null!==(x=g.billing_link)&&void 0!==x&&x.has_customer?void 0:"No active billing for this organisation yet.":"Only the organisation owner can manage billing.",children:[D?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(KN,{className:"h-4 w-4 mr-1.5"}),"Manage billing"]}),(0,Xt.jsxs)(Rr,{variant:"ghost",disabled:!0,"data-testid":"emp-billing-history-cta",className:"text-ndor-ink-muted",title:"Invoice history available after activation.",children:[(0,Xt.jsx)(hS,{className:"h-4 w-4 mr-1.5"}),"View invoice history"]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"emp-billing-invoices-placeholder",children:[(0,Xt.jsx)(Ry,{className:"pb-2",children:(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"Invoices"})}),(0,Xt.jsx)(Py,{className:"pt-0",children:(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Invoice history will appear here once your subscription is active. Charges are processed by Stripe; receipts are emailed to the billing owner."})})]}),(0,Xt.jsx)(NT,{variant:"block",testId:"employer-billing-disclaimer"})]})}const IT=["profile","usage","plans"],TT="profile";function PT(e){if(null===e||void 0===e)return"\u2014";const t=String(e).trim();return t.length?t:"\u2014"}
2function OT(){const[e,t]=(0,s.useState)(!0),[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(!1),[o,l]=(0,s.useState)(!1),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(null),[p,h]=(0,s.useState)(null),[f,x]=Pt(),v=(f.get("tab")||"").toLowerCase(),g=(0,s.useMemo)(()=>IT.includes(v)?v:TT,[v]),y=(0,s.useCallback)(e=>{const t=new URLSearchParams(f);e===TT?t.delete("tab"):t.set("tab",e),x(t,{replace:!0})},[f,x]),b=(0,s.useCallback)(async()=>{t(!0),a(null),i(!1),l(!1);try{var e;const t=await(0,zt.n)("/api/employer/v1/me"),n=(null===t||void 0===t?void 0:t.organisation)||null;d(n),m((null===n||void 0===n?void 0:n.id)||(null===t||void 0===t?void 0:t.account_id)||null),h((null===t||void 0===t||null===(e=t.member)||void 0===e?void 0:e.role)||null)}catch(pK){404===(null===pK||void 0===pK?void 0:pK.status)?d(null):403===(null===pK||void 0===pK?void 0:pK.status)?l(!0):503===(null===pK||void 0===pK?void 0:pK.status)?i(!0):a((null===pK||void 0===pK?void 0:pK.message)||"Failed to load employer account.")}finally{t(!1)}},[]);if((0,s.useEffect)(()=>{b()},[b]),e)return(0,Xt.jsx)("div",{className:"flex items-center justify-center py-24","data-testid":"employer-account-loading",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})});if(o)return(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"employer-account-forbidden",children:[(0,Xt.jsx)(mb,{className:"mx-auto mb-4 h-10 w-10 text-slate-300"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Employer access only"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:"Your account doesn't have employer workspace access. Ask an admin to grant it."})]});if(r)return(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"employer-account-unmigrated",children:[(0,Xt.jsx)(Oy,{className:"mx-auto mb-4 h-10 w-10 text-amber-500"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Setup pending"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:"The employer organisations table hasn't been set up yet."})]});if(n)return(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"employer-account-error",children:[(0,Xt.jsx)(Oy,{className:"mx-auto mb-4 h-10 w-10 text-rose-500"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Couldn't load account"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:n}),(0,Xt.jsx)(Rr,{variant:"outline",className:"mt-6",onClick:b,children:"Retry"})]});if(!c)return(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"employer-account-empty",children:[(0,Xt.jsx)(Pn,{className:"mx-auto mb-4 h-10 w-10 text-ndor-ink-muted"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"No organisation yet"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:"Create your organisation to see your account & usage."}),(0,Xt.jsx)(Et,{to:"/employer","data-testid":"employer-account-create-cta",children:(0,Xt.jsx)(Rr,{className:"mt-6 bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:"Set up organisation"})})]});const w=(null===c||void 0===c?void 0:c.culture_json)||{};return(0,Xt.jsxs)("div",{className:"mx-auto max-w-3xl py-8 px-4 space-y-6","data-testid":"employer-account-page",children:[(0,Xt.jsxs)("header",{className:"space-y-1",children:[(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Pn,{className:"h-5 w-5 text-ndor-ink-muted"}),"Account"]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"Your organisation, current-period usage, and plan posture."})]}),(0,Xt.jsxs)(tI,{value:g,onValueChange:y,className:"w-full","data-testid":"employer-account-tabs",children:[(0,Xt.jsxs)(nI,{className:"grid grid-cols-3 w-full bg-ndor-surface-alt/60 border border-ndor-edge","data-testid":"employer-account-tabs-list",children:[(0,Xt.jsx)(aI,{value:"profile","data-testid":"employer-account-tab-profile",children:"Profile"}),(0,Xt.jsx)(aI,{value:"usage","data-testid":"employer-account-tab-usage",children:"Usage"}),(0,Xt.jsx)(aI,{value:"plans","data-testid":"employer-account-tab-plans",children:"Plans"})]}),(0,Xt.jsx)(rI,{value:"profile",className:"mt-6","data-testid":"employer-account-tab-content-profile",children:(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"employer-account-identity",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 flex flex-row items-center justify-between",children:[(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"Organisation"}),oT(p)?(0,Xt.jsxs)(Et,{to:"/employer",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink inline-flex items-center gap-1","data-testid":"employer-account-edit-link",children:[(0,Xt.jsx)(JN,{className:"h-3 w-3"}),"Edit profile"]}):null]}),(0,Xt.jsxs)(Py,{children:[(0,Xt.jsxs)("dl",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-sm",children:[(0,Xt.jsxs)("div",{"data-testid":"employer-account-field-name",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Name"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:PT(c.name)})]}),(0,Xt.jsxs)("div",{"data-testid":"employer-account-field-sector",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Sector"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:PT(c.sector)})]}),(0,Xt.jsxs)("div",{"data-testid":"employer-account-field-size",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Stage"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:PT(c.size_band)})]}),(0,Xt.jsxs)("div",{"data-testid":"employer-account-field-website",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Website"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:c.website?(0,Xt.jsxs)("a",{href:c.website,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 underline-offset-2 hover:underline",children:[c.website,(0,Xt.jsx)(KN,{className:"h-3 w-3"})]}):"\u2014"})]}),(0,Xt.jsxs)("div",{className:"sm:col-span-2","data-testid":"employer-account-field-working-model",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Working model"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:PT(w.working_model)})]}),(0,Xt.jsxs)("div",{className:"sm:col-span-2","data-testid":"employer-account-field-location-mode",children:[(0,Xt.jsx)("dt",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Location mode"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:PT(w.location_mode)})]})]}),(0,Xt.jsxs)("div",{className:"mt-4 pt-3 border-t border-ndor-edge flex items-center gap-2 text-xs",children:[(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Your role"}),(0,Xt.jsx)(Vw,{variant:"outline","data-testid":"employer-account-my-role",children:p||"\u2014"}),(0,Xt.jsx)(Et,{to:"/employer/help/permissions",className:"ml-auto text-[11px] text-ndor-ink-muted hover:text-ndor-ink underline-offset-2 hover:underline","data-testid":"employer-account-permissions-link",children:"Roles & permissions"})]})]})]})}),(0,Xt.jsx)(rI,{value:"usage",className:"mt-6","data-testid":"employer-account-tab-content-usage",children:(0,Xt.jsx)(wT,{accountId:u,memberRole:p})}),(0,Xt.jsx)(rI,{value:"plans",className:"mt-6","data-testid":"employer-account-tab-content-plans",children:(0,Xt.jsx)(RT,{accountId:u})})]})]})}function BT(e){let{orgName:t=null}=e;const{signOut:n}=tn();return(0,Xt.jsx)("div",{className:"mx-auto max-w-2xl px-4 py-12 sm:py-16","data-testid":"employer-no-membership-stub",children:(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface p-8",children:(0,Xt.jsxs)("div",{className:"flex items-start gap-4",children:[(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt p-3",children:(0,Xt.jsx)(kn,{className:"h-6 w-6 text-ndor-ink-secondary"})}),(0,Xt.jsxs)("div",{className:"flex-1",children:[(0,Xt.jsx)("h1",{className:"text-xl font-serif-display font-semibold tracking-tight text-ndor-ink","data-testid":"employer-no-membership-stub-title",children:"You are not connected to an employer workspace yet"}),(0,Xt.jsx)("p",{className:"mt-3 text-sm text-ndor-ink-secondary leading-relaxed",children:"If you were invited to join an organisation, open the invitation link from the original message. If you believe this is an error, contact the person who invited you or your platform administrator."}),(0,Xt.jsx)("div",{className:"mt-6 rounded border border-ndor-edge bg-ndor-surface-alt/60 p-4 text-xs text-ndor-ink-muted leading-relaxed",children:(0,Xt.jsxs)("p",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-ndor-gold"}),(0,Xt.jsx)("span",{children:"NDORFlow employer organisations are admin-
2provisioned. Account creation never creates an organisation automatically \u2014 workspaces are granted only through a valid invitation."})]})}),(0,Xt.jsx)("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-end",children:(0,Xt.jsx)(Rr,{variant:"outline",onClick:n,"data-testid":"employer-no-membership-stub-signout",children:"Sign out"})}),t&&(0,Xt.jsx)("p",{className:"mt-6 text-[11px] text-ndor-ink-muted/70 font-mono",children:t})]})]})})})}function LT(e){return null===e||void 0===e?"\u2014":String(e)}function MT(e){if(!e)return null;const t=new Date(e).getTime();if(Number.isNaN(t))return null;const n=Math.max(0,Math.round((Date.now()-t)/1e3));return n<60?"just now":n<3600?"".concat(Math.floor(n/60),"m ago"):n<86400?"".concat(Math.floor(n/3600),"h ago"):"".concat(Math.floor(n/86400),"d ago")}function zT(e){let{label:t,value:n,hint:a,icon:r,tone:s="default",testid:i,to:o}=e;const l={default:"text-ndor-ink",warn:"text-amber-400",alert:"text-rose-400"}[s],c=(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface hover:border-ndor-gold/30 transition-colors h-full","data-testid":i,children:(0,Xt.jsxs)(Py,{className:"p-5",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-muted font-medium",children:t}),r&&(0,Xt.jsx)(r,{className:"h-4 w-4 text-ndor-ink-muted shrink-0"})]}),(0,Xt.jsx)("div",{className:"text-3xl font-semibold font-mono-ui ".concat(l," mb-1"),children:n}),a&&(0,Xt.jsx)("div",{className:"text-[11px] text-ndor-ink-muted leading-relaxed",children:a})]})});return o?(0,Xt.jsx)(Et,{to:o,className:"block h-full",children:c}):c}function UT(){var e,t,n,a,r,i,o,l;const{profile:c}
2=tn(),d=ke(),[u,m]=(0,s.useState)(!0),[p,h]=(0,s.useState)(null),[f,x]=(0,s.useState)(!1),[v,g]=(0,s.useState)(null),[y,b]=(0,s.useState)(null),[w,j]=(0,s.useState)(null),[k,N]=(0,s.useState)(null),[_,D]=(0,s.useState)(null),[C,A]=(0,s.useState)(null),S=(0,s.useCallback)(async()=>{m(!0),h(null);try{var e,t,n,a,r;const l=await(0,zt.n)("/api/employer/v1/me");g(l);if("reviewer"===(null===l||void 0===l||null===(e=l.member)||void 0===e?void 0:e.role))return void d("/employer/reviews",{replace:!0});const c=(null===l||void 0===l||null===(t=l.organisation)||void 0===t?void 0:t.id)||(null===l||void 0===l?void 0:l.account_id),u=await Promise.allSettled([(0,zt.n)("/api/employer/roles"),(0,zt.n)("/api/employer/v1/plan"),c?Mt.supabase.from("emp_candidate_reviews").select("review_id, status, role_id, reviewer_user_id, candidate_user_id, created_at").eq("account_id",c).in("status",["pending","in_review"]).order("created_at",{ascending:!1}).limit(20):Promise.resolve({data:null}),c?Mt.supabase.from("emp_reviewer_assignments").select("assignment_id, reviewer_user_id, assignment_status, updated_at, role_id").eq("account_id",c).eq("assignment_status","active").order("updated_at",{ascending:!1}):Promise.resolve({data:null}),c?Mt.supabase.from("emp_member_invitations").select("id, status, invited_email, invited_role, created_at").eq("account_id",c).eq("status","pending").order("created_at",{ascending:!1}):Promise.resolve({data:null})]);if("fulfilled"===u[0].status){const e=u[0].value,t=(null===e||void 0===e?void 0:e.items)||(null===e||void 0===e?void 0:e.roles)||(Array.isArray(e)?e:[])||[];b(Array.isArray(t)?t:[])}else b(null);var s,i,o;if("fulfilled"===u[1].status&&A(u[1].value||null),"fulfilled"!==u[2].status||null!==(n=u[2].value)&&void 0!==n&&n.error)j(null);else j((null===(s=u[2].value)||void 0===s?void 0:s.data)||[]);if("fulfilled"!==u[3].status||null!==(a=u[3].value)&&void 0!==a&&a.error)N(null);else N((null===(i=u[3].value)||void 0===i?void 0:i.data)||[]);if("fulfilled"!==u[4].status||null!==(r=u[4].value)&&void 0!==r&&r.error)D(null);else D((null===(o=u[4].value)||void 0===o?void 0:o.data)||[])}catch(pK){if(403===(null===pK||void 0===pK?void 0:pK.status))h("Your account does not have employer workspace access.");else{if(404===(null===pK||void 0===pK?void 0:pK.status))return void x(!0);h((null===pK||void 0===pK?void 0:pK.message)||"Failed to load command centre.")}}finally{m(!1)}},[d]);(0,s.useEffect)(()=>{S()},[S]);const E=(null===c||void 0===c?void 0:c.first_name)||(null===v||void 0===v||null===(e=v.member)||void 0===e?void 0:e.first_name)||"",F=(null===v||void 0===v||null===(t=v.member)||void 0===t?void 0:t.role)||null,R=(null===v||void 0===v||null===(n=v.organisation)||void 0===n?void 0:n.name)||null,I=Array.isArray(y)?y.filter(e=>KI(null===e||void 0===e?void 0:e.status)).length:null,T=Array.isArray(w)?w.length:null,P=Array.isArray(k)?new Set(k.map(e=>e.reviewer_user_id)).size:null,O=Array.isArray(_)?_.length:null,B=(0,s.useMemo)(()=>{if(!Array.isArray(w))return null;const e=Date.now()-6048e5;return w.filter(t=>"in_review"===t.status&&new Date(t.created_at).getTime()<e)},[w]),L=(0,s.useMemo)(()=>{var e;return null===O&&null===B?null:(null!==O&&void 0!==O?O:0)+(null!==(e=null===B||void 0===B?void 0:B.length)&&void 0!==e?e:0)},[O,B]),M=(0,s.useMemo)(()=>Array.isArray(y)?y.slice(0,5):[],[y]),z=(0,s.useMemo)(()=>Array.isArray(w)?w.slice(0,6):[],[w]),U=(0,s.useMemo)(()=>{if(!Array.isArray(k))return[];const e=new Map;for(const t of k){const n=t.reviewer_user_id,a=e.get(n)||{reviewer_user_id:n,assigned:0,last_updated:null};a.assigned+=1,(!a.last_updated||t.updated_at&&t.updated_at>a.last_updated)&&(a.last_updated=t.updated_at),e.set(n,a)}return Array.from(e.values()).slice(0,5)},[k]);return u?(0,Xt.jsx)("div",{className:"flex items-center justify-center py-24","data-testid":"employer-command-centre-loading",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})}):f?(0,Xt.jsx)(BT,{}):p?(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"employer-command-centre-error",children:[(0,Xt.jsx)(ty,{className:"mx-auto mb-4 h-10 w-10 text-rose-500"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Can't load command centre"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:p}),(0,Xt.jsx)(Rr,{variant:"outline",className:"mt-6",onClick:S,children:"Retry"})]}):(0,Xt.jsxs)("div",{className:"mx-auto max-w-7xl py-6 md:py-10 px-3 md:px-6 space-y-8 md:space-y-10","data-testid":"employer-command-centre",children:[(0,Xt.jsxs)("section",{className:"space-y-5",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-6 flex-wrap",children:[(0,Xt.jsxs)("div",{className:"space-y-2 max-w-2xl",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.24em] text-ndor-gold font-medium",children:"Employer Command Centre"}),(0,Xt.jsx)("h1",{className:"text-3xl md:text-4xl font-semibold text-ndor-ink leading-tight",children:E?(0,Xt.jsxs)(Xt.Fragment,{children:["Hello, ",(0,Xt.jsx)("span",{className:"text-ndor-gold",children:E}),"."]}):"Welcome."}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-muted leading-relaxed",children:["Manage your organisation, roles, reviewers and hiring decisions.",R&&(0,Xt.jsxs)(Xt.Fragment,{children:[" Operating as ",(0,Xt.jsx)("span",{className:"text-ndor-ink",children:R}),"."]})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:S,"data-testid":"employer-command-centre-refresh","aria-label":"Refresh",children:(0,Xt.jsx)(Kg,{className:"h-4 w-4"})}),(0,Xt.jsx)(Et,{to:"/employer/roles/new","data-testid":"employer-command-centre-create-role",children:(0,Xt.jsxs)(Rr,{size:"sm",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:[(0,Xt.jsx)(Ow,{className:"mr-2 h-4 w-4"}),"Create role"]})})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-3 text-[11px] flex-wrap",children:[(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-ndor-edge text-ndor-ink-secondary","data-testid":"cc-role-chip",children:[(0,Xt.jsx)(Bn,{className:"h-3 w-3 mr-1"}),"You are: ",lT[F]||F||"\u2014"]}),C&&(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-ndor-edge text-ndor-ink-secondary","data-testid":"cc-plan-chip",children:["Plan: ",Bf((null===C||void 0===C||null===(a=C.entitlement)||void 0===a?void 0:a.plan_tier)||(null===C||void 0===C||null===(r=C.active_plan)||void 0===r?void 0:r.plan_tier))]})]})]}),(0,Xt.jsxs)("section",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 md:gap-4","data-testid":"cc-metric-row",children:[(0,Xt.jsx)(zT,{label:"Active Roles",value:LT(I),hint:0===I?"No active roles yet.":"Currently published.",icon:kn,testid:"cc-metric-active-roles",to:"/employer/roles"}),(0,Xt.jsx)(zT,{label:"Pending Decisions",value:LT(T),hint:0===T?"No reviews awaiting decision.":"Across all reviewers.",icon:In,tone:T>0?"warn":"default",testid:"cc-metric-pending-decisions"}),(0,Xt.jsx)(zT,{label:"Active Reviewers",value:LT(P),hint:0===P?"No reviewers assigned yet.":"With active assignments.",icon:DR,testid:"cc-metric-active-reviewers",to:"/employer/reviewers"}),(0,Xt.jsx)(zT,{label:"Governance Alerts",value:LT(L),hint:0===L?"Nothing needs attention.":"".concat(null!==O&&void 0!==O?O:0," pending invite").concat(1===(null!==O&&void 0!==O?O:0)?"":"s"," \xb7 ").concat(null!==(i=null===B||void 0===B?void 0:B.length)&&void 0!==i?i:0," stalled review").concat(1===(null!==(o=null===B||void 0===B?void 0:B.length)&&void 0!==o?o:0)?"":"s"),icon:Oy,tone:L>0?"alert":"default",testid:"cc-metric-governance-alerts"})]}),(0,Xt.jsxs)("section",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 md:gap-6",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface lg:col-span-2","data-testid":"cc-section-recent-roles",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(kn,{className:"h-4 w-4 text-ndor-ink-muted"}),"Recent roles"]}),(0,Xt.jsxs)(Et,{to:"/employer/roles",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink inline-flex items-center gap-1","data-testid":"cc-recent-roles-viewall",children:["View all ",(0,Xt.jsx)(zy,{className:"h-3 w-3"})]})]}),(0,Xt.jsxs)(Py,{children:[null===y&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Roles list unavailable \u2014 retry."}),Array.isArray(y)&&0===y.length&&(0,Xt.jsxs)("div",{className:"py-8 text-center","data-testid":"cc-recent-roles-empty",children:[(0,Xt.jsx)(kn,{className:"mx-auto mb-3 h-8 w-8 text-ndor-ink-muted opacity-50"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"No roles yet."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:"Create your first role to begin matching candidates."}),(0,Xt.jsx)(Et,{to:"/employer/roles/new",children:(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"mt-4",children:[(0,Xt.jsx)(Ow,{className:"mr-2 h-3 w-3"})," Create role"]})})]}),Array.isArray(y)&&y.length>0&&(0,Xt.jsx)("ul",{className:"divide-y divide-ndor-edge -mx-2","data-testid":"cc-recent-roles-list",children:M.map(e=>(0,Xt.jsx)("li",{className:"px-2 py-3",children:(0,Xt.jsxs)(Et,{to:"/employer/roles/".concat(e.role_id||e.id),className:"flex items-start justify-between gap-3 hover:bg-ndor-surface-alt/40 -mx-2 px-2 py-1 rounded transition-colors",children:[(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink truncate",children:e.title||"Untitled role"}),(0,Xt.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-[11px] text-ndor-ink-muted flex-wrap",children:[(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge text-[10px] uppercase tracking-wider",children:e.status||"draft"}),e.updated_at&&(0,Xt.jsxs)("span",{children:["Updated ",MT(e.updated_at)]})]})]}),(0,Xt.jsx)(zy,{className:"h-4 w-4 text-ndor-ink-muted mt-1 shrink-0"})]})},e.role_id||e.id))})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"cc-section-reviews-attention",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(In,{className:"h-4 w-4 text-ndor-ink-muted"}),"Reviews needing attention"]}),(0,Xt.jsxs)(Et,{to:"/employer/reviewers",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink inline-flex items-center gap-1","data-testid":"cc-reviews-attention-manage",children:["Manage ",(0,Xt.jsx)(zy,{className:"h-3 w-3"})]})]}),(0,Xt.jsxs)(Py,{children:[null===w&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Reviews unavailable \u2014 retry."}),Array.isArray(w)&&0===z.length&&(0,Xt.jsxs)("div",{className:"py-6 text-center","data-testid":"cc-reviews-attention-empty",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"All clear."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:"No reviews awaiting decision."})]}),z.length>0&&(0,Xt.jsx)("ul",{className:"space-y-2.5","data-testid":"cc-reviews-attention-list",children:z.map(e=>{const t=(B||[]).some(t=>t.review_id===e.review_id);return(0,Xt.jsxs)("li",{className:"flex items-start justify-between gap-2 py-2 border-b border-ndor-edge last:border-b-0",children:[(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsxs)("p",{className:"text-[11px] font-mono-ui text-ndor-ink-muted",children:["REV-",String(e.review_id||"").slice(0,8)]}),(0,Xt.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)(Vw,{variant:"outline",className:"in_review"===e.status?"border-amber-500/40 text-amber-400 text-[10px] uppercase tracking-wider":"border-ndor-edge text-[10px] uppercase tracking-wider",children:e.status}),t&&(0,Xt.jsx)(Vw,{className:"bg-rose-500/15 text-rose-300 text-[10px] uppercase tracking-wider border-0",children:"Stalled > 7d"})]})]}),e.created_at&&(0,Xt.jsx)("span",{className:"text-[10px] text-ndor-ink-muted shrink-0",children:MT(e.created_at)})]},e.review_id)})})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface lg:col-span-2","data-testid":"cc-section-reviewer-activity",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(wF,{
2className:"h-4 w-4 text-ndor-ink-muted"}),"Reviewer activity"]}),(0,Xt.jsxs)(Et,{to:"/employer/reviewers",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink inline-flex items-center gap-1","data-testid":"cc-reviewer-activity-manage",children:["Manage reviewers ",(0,Xt.jsx)(zy,{className:"h-3 w-3"})]})]}),(0,Xt.jsxs)(Py,{children:[null===k&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Reviewer data unavailable \u2014 retry."}),Array.isArray(k)&&0===U.length&&(0,Xt.jsxs)("div",{className:"py-6 text-center","data-testid":"cc-reviewer-activity-empty",children:[(0,Xt.jsx)(Tn,{className:"mx-auto mb-3 h-8 w-8 text-ndor-ink-muted opacity-50"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"No reviewers assigned yet."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:"Invite reviewers from the Organisation hub."}),(0,Xt.jsx)(Et,{to:"/employer/reviewers",children:(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",className:"mt-4",children:"Manage reviewers"})})]}),U.length>0&&(0,Xt.jsx)("ul",{className:"divide-y divide-ndor-edge -mx-2","data-testid":"cc-reviewer-activity-list",children:U.map(e=>(0,Xt.jsxs)("li",{className:"px-2 py-2.5 flex items-center justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsxs)("p",{className:"text-[11px] font-mono-ui text-ndor-ink-muted truncate",children:["REVIEWER-",String(e.reviewer_user_id||"").slice(0,8)]}),(0,Xt.jsxs)("p",{className:"text-[10px] text-ndor-ink-muted mt-0.5",children:[e.assigned," assignment",1===e.assigned?"":"s",e.last_updated&&" \xb7 last activity ".concat(MT(e.last_updated))]})]}),(0,Xt.jsx)(Vw,{variant:"outline",className:"border-emerald-500/30 text-emerald-300 text-[10px] uppercase tracking-wider",children:"Active"})]},e.reviewer_user_id))})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"cc-section-governance",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 flex flex-row items-center justify-between",children:[(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-ink-muted"}),"Governance"]}),(0,Xt.jsxs)(Et,{to:"/employer/members",className:"text-xs text-ndor-ink-muted hover:text-ndor-ink inline-flex items-center gap-1","data-testid":"cc-governance-manage",children:["Members ",(0,Xt.jsx)(zy,{className:"h-3 w-3"})]})]}),(0,Xt.jsx)(Py,{children:(0,Xt.jsxs)("ul",{className:"space-y-3 text-sm",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2 py-2 border-b border-ndor-edge",children:[(0,Xt.jsx)(WI,{className:"h-4 w-4 text-ndor-ink-muted mt-0.5"}),(0,Xt.jsxs)("div",{className:"flex-1",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"Pending invitations"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:null===O?"Unavailable":0===O?"No invitations awaiting acceptance.":"".concat(O," invitation").concat(1===O?"":"s"," awaiting acceptance.")})]}),(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge text-[11px]",children:LT(O)})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2 py-2 border-b border-ndor-edge",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 text-ndor-ink-muted mt-0.5"}),(0,Xt.jsxs)("div",{className:"flex-1",children:[(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink",children:["Stalled reviews (",">"," 7d)"]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:null===B?"Unavailable":0===B.length?"No reviewer is sitting on a review.":"".concat(B.length," review").concat(1===B.length?"":"s"," in-review for over a week.")})]}),(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge text-[11px]",children:LT(null!==(l=null===B||void 0===B?void 0:B.length)&&void 0!==l?l:null)})]})]})})]})]}),(0,Xt.jsx)(Fw,{workspace:"employer",memberRole:F}),(0,Xt.jsxs)("footer",{className:"text-[11px] text-ndor-ink-muted pt-4 border-t border-ndor-edge flex items-center justify-between flex-wrap gap-2","data-testid":"cc-footer-honesty",children:[(0,Xt.jsx)("span",{children:"Every counter is read from live records. Employer billing is not active yet."}),(0,Xt.jsxs)(Et,{to:"/employer/organisation",className:"hover:text-ndor-ink inline-flex items-center gap-1",children:[(0,Xt.jsx)(Pn,{className:"h-3 w-3"})," Configure organisation"]})]})]})}const VT=[{value:"seed",label:"Seed (1\u201310)"},{value:"growth",label:"Growth (11\u201350)"},{value:"scale",label:"Scale (51\u2013250)"},{value:"enterprise",label:"Enterprise (250+)"}],qT=[{value:"__none__",label:"\u2014 not set \u2014"},{value:"remote_global",label:"Remote \u2014 global"},{value:"remote_region",label:"Remote \u2014 specific region"},{value:"hub",label:"Hub-based"},{value:"office",label:"In-office"}],WT=[{value:"__none__",label:"\u2014 not set \u2014"},{value:"async",label:"Async-first"},{value:"deep_work",label:"Deep-work focused"},{value:"collab",label:"High collaboration"},{value:"flexible",label:"Flexible hours"}],HT={name:"",sector:"",size_band:"",website:"",description:"",culture_json:{working_model:"",location_mode:"",why_join_us:""}};function GT(e){if(!e)return(0,c.A)({},HT);const t=e.culture_json||{};return{name:e.name||"",sector:e.sector||"",size_band:e.size_band||"",website:e.website||"",description:e.description||"",culture_json:{working_model:t.working_model||"",location_mode:t.location_mode||"",why_join_us:t.why_join_us||""}}}
2function KT(){const[e,t]=(0,s.useState)(!0),[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(!1),[o,l]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[m,p]=(0,s.useState)((0,c.A)({},HT)),[h,f]=(0,s.useState)(!1),[x,v]=(0,s.useState)(null),g=(0,s.useCallback)(async()=>{t(!0),a(null),i(!1),l(!1);try{var e;const t=await(0,zt.n)("/api/employer/v1/me"),n=(null===t||void 0===t?void 0:t.organisation)||null;u(n),p(GT(n)),v((null===t||void 0===t||null===(e=t.member)||void 0===e?void 0:e.role)||(null===t||void 0===t?void 0:t.member_role)||null)}catch(pK){404===(null===pK||void 0===pK?void 0:pK.status)?(u(null),p((0,c.A)({},HT))):403===(null===pK||void 0===pK?void 0:pK.status)?l(!0):503===(null===pK||void 0===pK?void 0:pK.status)?i(!0):a((null===pK||void 0===pK?void 0:pK.message)||"Failed to load organisation.")}finally{t(!1)}},[]);(0,s.useEffect)(()=>{g()},[g]);const y=!d,b=(0,s.useMemo)(()=>y?null:function(e,t){const n={},a=["name","sector","size_band","website","description"];for(const o of a)((null===e||void 0===e?void 0:e[o])||"")!==((null===t||void 0===t?void 0:t[o])||"")&&(n[o]=(null===t||void 0===t?void 0:t[o])||"");const r=(null===e||void 0===e?void 0:e.culture_json)||{},s=(null===t||void 0===t?void 0:t.culture_json)||{},i={};for(const o of["working_model","location_mode","why_join_us"])(r[o]||"")!==(s[o]||"")&&(i[o]=s[o]||"");return Object.keys(i).length&&(n.culture_json=i),n}(GT(d),m),[d,m,y]),w=y?Boolean(m.name.trim()&&m.description.trim()):Object.keys(b||{}).length>0;return e?(0,Xt.jsx)("div",{className:"flex items-center justify-center py-24","data-testid":"employer-home-loading",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})}):o?(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"employer-home-forbidden",children:[(0,Xt.jsx)(mb,{className:"mx-auto mb-4 h-10 w-10 text-slate-300"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Employer access only"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:"Your account doesn't have employer workspace access. Ask an admin to grant it."})]}):r?(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"employer-home-unmigrated",children:[(0,Xt.jsx)(Oy,{className:"mx-auto mb-4 h-10 w-10 text-amber-500"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Setup pending"}),(0,Xt.jsxs)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:["The employer organisations table hasn't been set up yet. An admin needs to apply migration"," ",(0,Xt.jsx)("code",{className:"font-mono",children:"026_employer_organisations.sql"})," ","via the Supabase SQL editor."]})]}):n?(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"employer-home-error",children:[(0,Xt.jsx)(Oy,{className:"mx-auto mb-4 h-10 w-10 text-rose-500"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"Couldn't load organisation"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:n}),(0,Xt.jsx)(Rr,{variant:"outline",className:"mt-6",onClick:g,children:"Retry"})]}):(0,Xt.jsxs)("div",{className:"mx-auto max-w-3xl py-8 px-4 space-y-6","data-testid":y?"employer-home-create":"employer-home-editor",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Pn,{className:"h-5 w-5 text-ndor-ink-muted"}),y?"Create your organisation":"Your organisation profile"]}),(0,Xt.jsx)("p",{className:"mt-1 text-sm text-ndor-ink-muted",children:y?"This is the start of your employer workspace. Fill in a few basics \u2014 you can refine everything later.":"This information is shown to candidates when they receive a signal from your organisation."})]}),!y&&(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt px-4 py-3 text-xs text-ndor-ink-secondary leading-relaxed","data-testid":"employer-profile-callout",children:"Candidates see your organisation name, sector, stage, description, and website when reviewing a signal."}),x&&!oT(x)?(0,Xt.jsxs)("div",{className:"text-[12px] text-ndor-ink-muted bg-ndor-surface-alt/40 border border-ndor-edge rounded px-3 py-2","data-testid":"employer-org-readonly-banner",children:["View-only access \u2014 your role"," ",(0,Xt.jsx)("strong",{children:lT[x]||x})," ","cannot edit organisation details. Ask an owner or admin to make changes."]}):null,(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm",children:[(0,Xt.jsx)(Ry,{className:"pb-3",children:(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"The basics"})}),(0,Xt.jsxs)(Py,{className:"space-y-5",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{children:"Organisation name *"}),(0,Xt.jsx)(Ag,{value:m.name,onChange:e=>p(t=>(0,c.A)((0,c.A)({},t),{},{name:e.target.value})),placeholder:"Acme Robotics",className:"h-10","data-testid":"employer-field-name",autoComplete:"off"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"The name candidates will see."})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{children:"Sector"}),(0,Xt.jsx)(Ag,{value:m.sector,onChange:e=>p(t=>(0,c.A)((0,c.A)({},t),{},{sector:e.target.value})),placeholder:"e.g. Industrial automation, Fintech",className:"h-10","data-testid":"employer-field-sector",autoComplete:"off"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"e.g. Industrial automation, Fintech."})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{children:"Stage"}),(0,Xt.jsxs)(Vv,{value:m.size_band||"__none__",onValueChange:e=>p(t=>(0,c.A)((0,c.A)({},t),{},{size_band:"__none__"===e?"":e})),children:[(0,Xt.jsx)(Wv,{className:"h-10","data-testid":"employer-field-size-band",children:(0,Xt.jsx)(qv,{placeholder:"Select stage\u2026"})}),(0,Xt.jsxs)(Kv,{children:[(0,Xt.jsx)(Yv,{value:"__none__",children:"\u2014 not set \u2014"}),VT.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))]})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Helps candidates understand your context."})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{children:"Website"}),(0,Xt.jsx)(Ag,{value:m.website,onChange:e=>p(t=>(0,c.A)((0,c.A)({},t),{},{website:e.target.value})),placeholder:"https://acme.example",className:"h-10","data-testid":"employer-field-website",autoComplete:"off"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Shown as a link to candidates (optional). Include the full URL starting with https://."})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{children:"About your organisation *"}),(0,Xt.jsx)(Hw,{value:m.description,onChange:e=>p(t=>(0,c.A)((0,c.A)({},t),{},{description:e.target.value})),placeholder:"A short about \u2014 what you do and who you serve.",rows:4,"data-testid":"employer-field-description"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Your voice. Be direct and honest. 200 characters recommended."})]})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm",children:[(0,Xt.jsxs)(Ry,{className:"pb-3",children:[(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink",children:"Culture & working model"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted pt-1",children:"Lightweight signals candidates may use as context. Optional."})]}),(0,Xt.jsxs)(Py,{className:"space-y-5",children:[(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{children:"Working model"}),(0,Xt.jsxs)(Vv,{value:m.culture_json.working_model||"__none__",onValueChange:e=>p(t=>(0,c.A)((0,c.A)({},t),{},{culture_json:(0,c.A)((0,c.A)({},t.culture_json),{},{working_model:"__none__"===e?"":e})})),children:[(0,Xt.jsx)(Wv,{className:"h-10","data-testid":"employer-field-working-model",children:(0,Xt.jsx)(qv,{placeholder:"Select\u2026"})}),(0,Xt.jsx)(Kv,{children:WT.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{children:"Location mode"}),(0,Xt.jsxs)(Vv,{value:m.culture_json.location_mode||"__none__",onValueChange:e=>p(t=>(0,c.A)((0,c.A)({},t),{},{culture_json:(0,c.A)((0,c.A)({},t.culture_json),{},{location_mode:"__none__"===e?"":e})})),children:[(0,Xt.jsx)(Wv,{className:"h-10","data-testid":"employer-field-location-mode",children:(0,Xt.jsx)(qv,{placeholder:"Select\u2026"})}),(0,Xt.jsx)(Kv,{children:qT.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{children:"Why join you?"}),(0,Xt.jsx)(Hw,{value:m.culture_json.why_join_us,onChange:e=>p(t=>(0,c.A)((0,c.A)({},t),{},{culture_json:(0,c.A)((0,c.A)({},t.culture_json),{},{why_join_us:e.target.value})})),placeholder:"Two or three honest sentences.",rows:3,"data-testid":"employer-field-why-join"})]})]})]}),!x||oT(x)?(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-ndor-edge",children:[!y&&(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>{p(GT(d))},disabled:!w||h,"data-testid":"employer-revert",children:"Revert"}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:async()=>
2{if(!h&&w){f(!0);try{if(y){const e={name:m.name.trim(),description:m.description.trim()};m.sector.trim()&&(e.sector=m.sector.trim()),m.size_band&&(e.size_band=m.size_band),m.website.trim()&&(e.website=m.website.trim());const t={};m.culture_json.working_model&&(t.working_model=m.culture_json.working_model),m.culture_json.location_mode&&(t.location_mode=m.culture_json.location_mode),m.culture_json.why_join_us.trim()&&(t.why_join_us=m.culture_json.why_join_us.trim()),Object.keys(t).length&&(e.culture_json=t);const n=await(0,zt.n)("/api/employer/org",{method:"POST",body:e}),a=(null===n||void 0===n?void 0:n.organisation)||null;u(a),p(GT(a)),fy.success("Organisation created.")}else{const e=await(0,zt.n)("/api/employer/org",{method:"PATCH",body:b}),t=(null===e||void 0===e?void 0:e.organisation)||null;u(t),p(GT(t)),fy.success("Organisation saved.")}}catch(pK){var e;fy.error((null===pK||void 0===pK||null===(e=pK.data)||void 0===e?void 0:e.detail)||(null===pK||void 0===pK?void 0:pK.message)||"Save failed.")}finally{f(!1)}}},disabled:!w||h,"data-testid":"employer-save",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:[h?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)($N,{className:"h-4 w-4 mr-1.5"}),h?"Saving\u2026":y?"Create organisation":"Save profile"]})]}):null,!y&&(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"employer-home-members-cta",children:[(0,Xt.jsx)(Ry,{className:"pb-3",children:(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Tn,{className:"h-4 w-4 text-ndor-ink-muted"}),"Member management"]})}),(0,Xt.jsxs)(Py,{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"Invite teammates, modify roles, manage suspensions, and review the account audit trail."}),(0,Xt.jsx)(Et,{to:"/employer/members","data-testid":"employer-home-members-cta-link",children:(0,Xt.jsxs)(Rr,{size:"sm",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:["Open members ",(0,Xt.jsx)(zy,{className:"h-4 w-4 ml-1.5"})]})})]})]}),!y&&(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"employer-home-governance-hub",children:[(0,Xt.jsxs)(Ry,{className:"pb-3",children:[(0,Xt.jsxs)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-ink-muted"}),"Governance hub"]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted pt-1",children:"Workspace authority & access \u2014 direct links only."})]}),(0,Xt.jsx)(Py,{children:(0,Xt.jsxs)("ul",{className:"divide-y divide-ndor-edge",children:[(0,Xt.jsxs)("li",{className:"py-3 flex items-center justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2.5 min-w-0",children:[(0,Xt.jsx)(Tn,{className:"h-4 w-4 text-ndor-ink-muted mt-0.5 shrink-0"}),(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"Members"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Invitations, role changes, suspensions, audit."})]})]}),(0,Xt.jsx)(Et,{to:"/employer/members","data-testid":"employer-home-governance-members-link",className:"shrink-0",children:(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",children:["Open ",(0,Xt.jsx)(zy,{className:"h-3.5 w-3.5 ml-1"})]})})]}),(0,Xt.jsxs)("li",{className:"py-3 flex items-center justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2.5 min-w-0",children:[(0,Xt.jsx)(DR,{className:"h-4 w-4 text-ndor-ink-muted mt-0.5 shrink-0"}),(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"Reviewers"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Assignment scope & reviewer admin."})]})]}),(0,Xt.jsx)(Et,{to:"/employer/reviewers","data-testid":"employer-home-governance-reviewers-link",className:"shrink-0",children:(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",children:["Open ",(0,Xt.jsx)(zy,{className:"h-3.5 w-3.5 ml-1"})]})})]}),(0,Xt.jsxs)("li",{className:"py-3 flex items-center justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2.5 min-w-0",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-ink-muted mt-0.5 shrink-0"}),(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"Roles & permissions"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Reference matrix for the four-role authority model."})]})]}),(0,Xt.jsx)(Et,{to:"/employer/help/permissions","data-testid":"employer-home-governance-permissions-link",className:"shrink-0",children:(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",children:["Open ",(0,Xt.jsx)(zy,{className:"h-3.5 w-3.5 ml-1"})]})})]})]})})]})]})}
2function YT(){return(0,Xt.jsx)("div",{"data-testid":"employer-organisation-page",children:(0,Xt.jsx)(KT,{})})}function JT(){return(0,Xt.jsxs)("div",{className:"mx-auto max-w-3xl py-12 md:py-20 px-4 space-y-6","data-testid":"employer-candidates-page",children:[(0,Xt.jsxs)("header",{className:"space-y-2 text-center",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.24em] text-ndor-gold font-medium",children:"Candidates"}),(0,Xt.jsx)("h1",{className:"text-2xl md:text-3xl font-semibold text-ndor-ink",children:"Cross-role candidate view"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted leading-relaxed max-w-xl mx-auto",children:"A consolidated candidate roster across all of your roles is on the way. For now, candidates are surfaced per-role from the Roles page."})]}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"employer-candidates-empty",children:(0,Xt.jsxs)(Py,{className:"py-10 text-center space-y-4",children:[(0,Xt.jsx)(Tn,{className:"mx-auto h-10 w-10 text-ndor-ink-muted opacity-50"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink",children:"No cross-role view yet."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted max-w-md mx-auto",children:"Open a role to see its matches, signals, and reviewer assignments. Each role is its own decision channel."}),(0,Xt.jsx)("div",{className:"pt-2",children:(0,Xt.jsx)(Et,{to:"/employer/roles","data-testid":"employer-candidates-roles-cta",children:(0,Xt.jsxs)(Rr,{size:"sm",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:[(0,Xt.jsx)(kn,{className:"mr-2 h-4 w-4"}),"Open Roles",(0,Xt.jsx)(zy,{className:"ml-2 h-4 w-4"})]})})})]})})]})}const $T=[{icon:Kn,title:"Anonymous matches surface",body:"NDORFlow scores candidates against each live role and surfaces role-scoped matches in your workspace \u2014 without revealing identity."},{icon:Dn,title:"You send interest signals",body:"For candidates worth a closer look, you send a structured expression of interest. PII stays hidden in your view."},{icon:DR,title:"Candidates respond on their terms",body:"The candidate accepts, declines, or defers. Their identity is shared with you only when they accept, scoped to that role."},{icon:Bn,title:"Responses appear here",body:"This page becomes your signal inbox \u2014 acceptances unlock approved profile fields; declines and deferrals remain private. Auditable end-to-end."}];function XT(){return(0,Xt.jsxs)("div",{className:"mx-auto max-w-3xl py-10 md:py-16 px-4 space-y-8","data-testid":"employer-signals-page",children:[(0,Xt.jsxs)("header",{className:"space-y-3 text-center",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.24em] text-ndor-gold font-medium",children:"Signals"}),(0,Xt.jsx)("h1",{className:"text-2xl md:text-3xl font-semibold text-ndor-ink",children:"Signals inbox"}),(0,Xt.jsx)("div",{className:"flex items-center justify-center gap-2",children:(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge bg-ndor-surface-alt/60 text-[10px] uppercase tracking-[0.14em] text-ndor-ink-secondary","data-testid":"employer-signals-preview-pill",children:"Available for enabled workspaces"})}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted leading-relaxed max-w-xl mx-auto",children:"NDORFlow Signals is built and live for enabled workspaces. Once enabled here, this page collects candidate responses to the interest signals you send from a role's NDOR-surfaced matches."})]}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"employer-signals-roadmap-card",children:(0,Xt.jsxs)(Py,{className:"px-5 py-5 sm:px-6 sm:py-6 space-y-4",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-[0.18em] text-ndor-ink-secondary font-medium",children:"How the workflow will land"}),(0,Xt.jsx)("ol",{className:"space-y-3","data-testid":"employer-signals-roadmap-list",children:$T.map((e,t)=>{const n=e.icon;return(0,Xt.jsxs)("li",{className:"flex items-start gap-3 rounded-md border border-ndor-edge bg-ndor-bg/40 px-4 py-3","data-testid":"employer-signals-roadmap-stage-".concat(t+1),children:[(0,Xt.jsx)("div",{className:"shrink-0 w-8 h-8 rounded-md border border-ndor-edge bg-ndor-surface-alt/50 flex items-center justify-center","aria-hidden":!0,
2children:(0,Xt.jsx)(n,{className:"h-4 w-4 text-ndor-ink-secondary"})}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink",children:[t+1,". ",e.title]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:e.body})]})]},e.title)})})]})}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"employer-signals-mvp-card",children:(0,Xt.jsxs)(Py,{className:"px-5 py-5 sm:px-6 sm:py-6 space-y-3",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"Until then, evidence-led decisions happen in Roles."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:"Upload candidate dossiers against a live role, run NDOR evaluations, capture verdicts, and assemble a defensible governance pack. That surface is fully live for your workspace today."}),(0,Xt.jsx)("div",{children:(0,Xt.jsx)(Et,{to:"/employer/roles","data-testid":"employer-signals-roles-cta",children:(0,Xt.jsxs)(Rr,{size:"sm",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:[(0,Xt.jsx)(kn,{className:"mr-2 h-4 w-4"}),"Open Roles",(0,Xt.jsx)(zy,{className:"ml-2 h-4 w-4"})]})})})]})}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted text-center leading-relaxed","data-testid":"employer-signals-footnote",children:"Signal acceptance shares only an allow-listed projection of a candidate's profile \u2014 name, headline, location, current role, summary, top skills. No contact details. No CV download. Candidate consent is required for every reveal."})]})}async function QT(e){if(!e)return[];const{data:t,error:n}=await Mt.supabase.from("emp_account_members").select("user_id, role, joined_at").eq("account_id",e).order("joined_at",{ascending:!0});if(n)throw n;return t||[]}async function ZT(e){let{onlyPending:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[];let n=Mt.supabase.from("emp_member_invitations").select("id, target_email, target_role, status, invited_by, accepted_by, created_at, expires_at, accepted_at, revoked_at, token").eq("account_id",e).order("created_at",{ascending:!1});t&&(n=n.eq("status","pending"));const{data:a,error:r}=await n;if(r)throw r;return a||[]}async function eP(e){let{onlyActive:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[];let n=Mt.supabase.from("emp_member_suspensions").select("id, member_user_id, status, reason, is_emergency, suspended_by, suspended_at, expires_at, lifted_at, lifted_by").eq("account_id",e).order("suspended_at",{ascending:!1});t&&(n=n.eq("status","active"));const{data:a,error:r}=await n;if(r)throw r;return a||[]}async function tP(e){let{limit:t=50}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[];const{data:n,error:a}=await Mt.supabase.from("emp_member_audit_log").select("id, action_class, actor_identity, actor_authority_class, originating_context, timestamp_utc").filter("originating_context->>account_id","eq",e).order("id",{ascending:!1}).limit(t);if(a)throw a;return n||[]}const nP="/api/employer/v1";function aP(e){let{accountId:t,targetEmail:n,targetRole:a,expiresIn:r="7 days",idempotencyKey:s}=e;return(0,zt.n)("".concat(nP,"/members/invite"),{method:"POST",body:{account_id:t,target_email:n,target_role:a,expires_in:r},headers:s?{"Idempotency-Key":s}:void 0})}function rP(e){let{accountId:t,invitationId:n,idempotencyKey:a}=e;return(0,zt.n)("".concat(nP,"/invitations/").concat(n,"/revoke"),{method:"POST",body:{account_id:t},headers:a?{"Idempotency-Key":a}:void 0})}const sP=Object.freeze({inviteRevoke:100,revoke:50,roleModify:50,unsuspend:50});function iP(e){let{members:t,myUserId:n,isAdmin:a,selected:r,setSelected:s,onModifyRole:i,onSuspend:o,onRevoke:l,onBulkRevoke:c,onBulkRoleDemote:d,bulkLimits:u}=e;const m=Array.from(r);return t.length?(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"emp-members-list",children:[a&&m.length>0&&(0,Xt.jsxs)(Fy,{className:"flex flex-wrap items-center gap-3 border-amber-400/30 bg-amber-500/10/50 p-3 dark:bg-amber-950/20","data-testid":"emp-members-bul
2k-bar",children:[(0,Xt.jsxs)("span",{className:"text-sm font-medium","data-testid":"emp-members-bulk-count",children:[m.length," selected"]}),(0,Xt.jsxs)("span",{className:"text-xs text-slate-300",children:["(cap ",u.revoke," revoke / ",u.roleModify," role)"]}),(0,Xt.jsxs)("div",{className:"ml-auto flex flex-wrap gap-2",children:[(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",onClick:()=>d("reviewer"),"data-testid":"emp-members-bulk-demote-reviewer",children:"\u2192 reviewer"}),(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",onClick:()=>d("recruiter"),"data-testid":"emp-members-bulk-demote-recruiter",children:"\u2192 recruiter"}),(0,Xt.jsx)(Rr,{size:"sm",variant:"destructive",onClick:c,"data-testid":"emp-members-bulk-revoke",children:"Bulk revoke"})]})]}),(0,Xt.jsx)("div",{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm",children:[(0,Xt.jsx)("thead",{className:"text-left text-xs uppercase tracking-wider text-slate-300",children:(0,Xt.jsxs)("tr",{children:[a&&(0,Xt.jsx)("th",{className:"w-8 p-2"}),(0,Xt.jsx)("th",{className:"p-2",children:"User"}),(0,Xt.jsx)("th",{className:"p-2",children:"Role"}),(0,Xt.jsx)("th",{className:"p-2",children:"Joined"}),a&&(0,Xt.jsx)("th",{className:"p-2 text-right",children:"Actions"})]})}),(0,Xt.jsx)("tbody",{children:t.map(e=>{const t=e.user_id===n,c=a&&!t;return(0,Xt.jsxs)("tr",{className:"border-t border-zinc-200 dark:border-zinc-800","data-testid":"emp-members-row-".concat(e.user_id),children:[a&&(0,Xt.jsx)("td",{className:"p-2",children:(0,Xt.jsx)(Vb,{checked:r.has(e.user_id),onCheckedChange:()=>(e=>{const t=new Set(r);t.has(e)?t.delete(e):t.add(e),s(t)})(e.user_id),disabled:t,"aria-label":"select member ".concat(e.user_id),"data-testid":"emp-members-select-".concat(e.user_id)})}),(0,Xt.jsxs)("td",{className:"p-2 font-mono text-xs",children:[e.user_id.slice(0,8),"\u2026",t&&(0,Xt.jsx)(Vw,{variant:"secondary",className:"ml-2",children:"you"})]}),(0,Xt.jsx)("td",{className:"p-2",children:(0,Xt.jsx)(Vw,{variant:"admin"===e.role?"default":"outline","data-testid":"emp-members-role-".concat(e.user_id),children:e.role})}),(0,Xt.jsx)("td",{className:"p-2 text-xs text-slate-300",children:e.joined_at?new Date(e.joined_at).toLocaleDateString():"\u2014"}),a&&(0,Xt.jsx)("td",{className:"p-2",children:(0,Xt.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",disabled:!c,onClick:()=>i(e),"data-testid":"emp-members-modify-role-".concat(e.user_id),children:"Role"}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",disabled:!c,onClick:()=>o(e),"data-testid":"emp-members-suspend-".concat(e.user_id),children:"Suspend"}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",disabled:!c,onClick:()=>l(e.user_id),className:"text-rose-300 hover:text-rose-200","data-testid":"emp-members-revoke-".concat(e.user_id),children:"Revoke"})]})})]},e.user_id)})})]})})]}):(0,Xt.jsx)(Fy,{className:"p-8 text-center text-sm text-slate-300","data-testid":"emp-members-list-empty",children:"No members yet. Invite your first teammate."})}const oP={pending:"default",accepted:"secondary",revoked:"destructive",expired:"outline"};function lP(e){let{invitations:t,isAdmin:n,selected:a,setSelected:r,onRevoke:s,onReissue:i,onBulkRevoke:o,bulkLimit:l}=e;const c=Array.from(a);return t.length?(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"emp-invitations-list",children:[n&&c.length>0&&(0,Xt.jsxs)(Fy,{className:"flex flex-wrap items-center gap-3 border-amber-400/30 bg-amber-500/10/50 p-3 dark:bg-amber-950/20","data-testid":"emp-invitations-bulk-bar",children:[(0,Xt.jsxs)("span",{className:"text-sm font-medium","data-testid":"emp-invitations-bulk-count",children:[c.length," selected"]}),(0,Xt.jsxs)("span",{className:"text-xs text-slate-300",children:["(cap ",l,")"]}),(0,Xt.jsx)(Rr,{size:"sm",variant:"destructive",className:"ml-auto",onClick:o,"data-testid":"emp-invitations-bulk-revoke",children:"Bulk revoke"})]}),(0,Xt.jsx)("div",{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm",children:[(0,Xt.jsx)("thead",{className:"text-left text-xs uppercase tracking-wider text-slate-300",children:(0,Xt.jsxs)("tr",{children:[n&&(0,Xt.jsx)("th",{className:"w-8 p-2"}),(0,Xt.jsx)("th",{className:"p-2",children:"Email"}),(0,Xt.jsx)("th",{className:"p-2",children:"Role"}),(0,Xt.jsx)("th",{className:"p-2",children:"Status"}),(0,Xt.jsx)("th",{className:"p-2",children:"Issued"}),(0,Xt.jsx)("th",{className:"p-2",children:"Expires"}),n&&(0,Xt.jsx)("th",{className:"p-2 text-right",children:"Actions"})]})}),(0,Xt.jsx)("tbody",{children:t.map(e=>{const t="pending"===e.status;return(0,Xt.jsxs)("tr",{className:"border-t border-zinc-200 dark:border-zinc-800","data-testid":"emp-invitations-row-".concat(e.id),children:[n&&(0,Xt.jsx)("td",{className:"p-2",children:(0,Xt.jsx)(Vb,{checked:a.has(e.id),onCheckedChange:()=>(e=>
2{const t=new Set(a);t.has(e)?t.delete(e):t.add(e),r(t)})(e.id),disabled:!t,"data-testid":"emp-invitations-select-".concat(e.id)})}),(0,Xt.jsx)("td",{className:"p-2",children:e.target_email}),(0,Xt.jsx)("td",{className:"p-2",children:(0,Xt.jsx)(Vw,{variant:"outline",children:e.target_role})}),(0,Xt.jsx)("td",{className:"p-2",children:(0,Xt.jsx)(Vw,{variant:oP[e.status]||"outline","data-testid":"emp-invitations-status-".concat(e.id),children:e.status})}),(0,Xt.jsx)("td",{className:"p-2 text-xs text-slate-300",children:e.created_at?new Date(e.created_at).toLocaleDateString():"\u2014"}),(0,Xt.jsx)("td",{className:"p-2 text-xs text-slate-300",children:e.expires_at?new Date(e.expires_at).toLocaleDateString():"\u2014"}),n&&(0,Xt.jsx)("td",{className:"p-2 text-right",children:(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",disabled:!t,onClick:()=>async function(e){if(null===e||void 0===e||!e.token)return void fy.error("Token missing \u2014 refresh the page and try again.");const t="".concat(window.location.origin,"/invitations/accept?token=").concat(encodeURIComponent(e.token));try{await navigator.clipboard.writeText(t),fy.success("Invitation link copied \u2014 share it with ".concat(e.target_email))}catch(n){fy.error("Couldn't access the clipboard. Long-press to copy the URL manually.")}}(e),className:"text-slate-200 hover:text-ndor-ink dark:text-zinc-300 dark:hover:text-zinc-100","data-testid":"emp-invitations-copy-link-".concat(e.id),"aria-label":"Copy invitation link for ".concat(e.target_email),children:[(0,Xt.jsx)(Mn,{className:"h-3.5 w-3.5 sm:mr-1.5"}),(0,Xt.jsx)("span",{className:"hidden sm:inline",children:"Copy link"})]}),i&&(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",disabled:!t,onClick:()=>i(e),className:"text-slate-200 hover:text-ndor-ink dark:text-zinc-300 dark:hover:text-zinc-100","data-testid":"emp-invitations-reissue-".concat(e.id),"aria-label":"Reissue invitation for ".concat(e.target_email," (revokes the current invitation and issues a fresh one)"),title:"Revoke this invitation and issue a fresh one with a new link.",children:[(0,Xt.jsx)(Kg,{className:"h-3.5 w-3.5 sm:mr-1.5"}),(0,Xt.jsx)("span",{className:"hidden sm:inline",children:"Reissue"})]}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",disabled:!t,onClick:()=>s(e.id),className:"text-rose-300 hover:text-rose-200","data-testid":"emp-invitations-revoke-".concat(e.id),children:"Revoke"})]})})]},e.id)})})]})})]}):(0,Xt.jsx)(Fy,{className:"p-8 text-center text-sm text-slate-300","data-testid":"emp-invitations-list-empty",children:"No invitations on this account yet."})}function cP(e){let{suspensions:t,isAdmin:n,selected:a,setSelected:r,onUnsuspend:s,onBulkUnsuspend:i,bulkLimit:o}=e;const l=Array.from(a);return t.length?(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"emp-suspensions-list",children:[n&&l.length>0&&(0,Xt.jsxs)(Fy,{className:"flex flex-wrap items-center gap-3 border-amber-400/30 bg-amber-500/10/50 p-3 dark:bg-amber-950/20","data-testid":"emp-suspensions-bulk-bar",children:[(0,Xt.jsxs)("span",{className:"text-sm font-medium","data-testid":"emp-suspensions-bulk-count",children:[l.length," selected"]}),(0,Xt.jsxs)("span",{className:"text-xs text-slate-300",children:["(cap ",o,")"]}),(0,Xt.jsx)(Rr,{size:"sm",variant:"default",className:"ml-auto",onClick:i,"data-testid":"emp-suspensions-bulk-unsuspend",children:"Bulk lift"})]}),(0,Xt.jsx)("div",{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm",children:[(0,Xt.jsx)("thead",{className:"text-left text-xs uppercase tracking-wider text-slate-300",children:(0,Xt.jsxs)("tr",{children:[n&&(0,Xt.jsx)("th",{className:"w-8 p-2"}),(0,Xt.jsx)("th",{className:"p-2",children:"Member"}),(0,Xt.jsx)("th",{className:"p-2",children:"Status"}),(0,Xt.jsx)("th",{className:"p-2",children:"Reason"}),(0,Xt.jsx)("th",{className:"p-2",children:"Issued"}),(0,Xt.jsx)("th",{className:"p-2",children:"Expires"}),n&&(0,Xt.jsx)("th",{className:"p-2 text-right",children:"Actions"})]})}),(0,Xt.jsx)("tbody",{children:t.map(e=>{var t;const i="active"===e.status;return(0,Xt.jsxs)("tr",{className:"border-t border-zinc-200 dark:border-zinc-800","data-testid":"emp-suspensions-row-".concat(e.id),children:[n&&(0,Xt.jsx)("td",{className:"p-2",children:(0,Xt.jsx)(Vb,{checked:a.has(e.id),onCheckedChange:()=>(e=>
2{const t=new Set(a);t.has(e)?t.delete(e):t.add(e),r(t)})(e.id),disabled:!i,"data-testid":"emp-suspensions-select-".concat(e.id)})}),(0,Xt.jsxs)("td",{className:"p-2 font-mono text-xs",children:[null===(t=e.member_user_id)||void 0===t?void 0:t.slice(0,8),"\u2026"]}),(0,Xt.jsx)("td",{className:"p-2",children:(0,Xt.jsxs)(Vw,{variant:"active"===e.status?"destructive":"lifted"===e.status?"secondary":"outline","data-testid":"emp-suspensions-status-".concat(e.id),children:[e.status,e.is_emergency?" \xb7 emergency":""]})}),(0,Xt.jsx)("td",{className:"p-2 max-w-xs truncate text-slate-200 dark:text-zinc-300",children:e.reason||"\u2014"}),(0,Xt.jsx)("td",{className:"p-2 text-xs text-slate-300",children:e.suspended_at?new Date(e.suspended_at).toLocaleDateString():"\u2014"}),(0,Xt.jsx)("td",{className:"p-2 text-xs text-slate-300",children:e.expires_at?new Date(e.expires_at).toLocaleDateString():"never"}),n&&(0,Xt.jsx)("td",{className:"p-2 text-right",children:(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",disabled:!i,onClick:()=>{window.confirm("Lift this suspension?")&&s(e.id)},"data-testid":"emp-suspensions-unsuspend-".concat(e.id),children:"Lift"})})]},e.id)})})]})})]}):(0,Xt.jsx)(Fy,{className:"p-8 text-center text-sm text-slate-300","data-testid":"emp-suspensions-list-empty",children:"No suspensions recorded for this account."})}const dP={"account.created":"Account created","member.invited":"Member invited","member.invitation_accepted":"Invitation accepted","member.invitation_revoked":"Invitation revoked","member.invitation_expired":"Invitation expired","member.revoked":"Member revoked","member.role_modified":"Role modified","member.suspended":"Member suspended","member.suspended_emergency":"Emergency suspension","member.unsuspended":"Suspension lifted","member.suspension_expired":"Suspension expired","member.bulk_revoked":"Bulk member revoke","member.bulk_role_modified":"Bulk role modify","member.bulk_invited":"Bulk invitation"};function uP(e){let{audit:t}=e;return t.length?(0,Xt.jsx)("div",{className:"space-y-2","data-testid":"emp-audit-feed",children:t.map(e=>{var t;return(0,Xt.jsxs)(Fy,{className:"flex flex-col gap-1 p-3 sm:flex-row sm:items-center","data-testid":"emp-audit-row-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"flex flex-1 items-center gap-3",children:[(0,Xt.jsx)(Vw,{variant:"outline","data-testid":"emp-audit-class-".concat(e.id),children:e.actor_authority_class||"\u2014"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-sm font-medium",children:dP[e.action_class]||e.action_class}),(0,Xt.jsxs)("p",{className:"font-mono text-xs text-slate-300",children:["actor ",null===(t=e.actor_identity)||void 0===t?void 0:t.slice(0,8),"\u2026"]})]})]}),(0,Xt.jsx)("div",{className:"text-xs text-slate-300 sm:text-right",children:e.timestamp_utc?new Date(e.timestamp_utc).toLocaleString():""})]},e.id)})}):(0,Xt.jsx)(Fy,{className:"p-8 text-center text-sm text-slate-300","data-testid":"emp-audit-empty",children:"No audit events visible to you for this account."})}const mP=["admin","recruiter","reviewer"];function pP(e){let{onClose:t,onSubmit:n}=e;const[a,r]=(0,s.useState)(""),[i,o]=(0,s.useState)("recruiter"),[l,c]=(0,s.useState)(!1);return(0,Xt.jsx)(rg,{open:!0,onOpenChange:e=>{e||t()},children:(0,Xt.jsxs)(lg,{"data-testid":"emp-invite-dialog",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{children:"Invite a member"}),(0,Xt.jsx)(mg,{children:"They will receive a pending invitation that expires in 7 days."})]}),(0,Xt.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),a.trim()){c(!0);try{await n({targetEmail:a.trim(),targetRole:i})}finally{c(!1)}}},className:"space-y-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{htmlFor:"emp-invite-email",children:"Email address"}),(0,Xt.jsx)(Ag,{id:"emp-invite-email",type:"email",required:!0,value:a,onChange:e=>r(e.target.value),placeholder:"[email protected]","data-testid":"emp-invite-email-input"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{children:"Role"}),(0,Xt.jsx)(TD,{value:i,onValueChange:o,className:"mt-2 space-y-2","data-testid":"emp-invite-role-radio",children:mP.map(e=>(0,Xt.jsxs)(Pg,{htmlFor:"emp-invite-role-".concat(e),className:"flex cursor-pointer items-start gap-3 rounded-md border p-3 text-sm hover:bg-ndor-surface-alt dark:hover:bg-zinc-800 has-[[data-state=checked]]:bg-ndor-surface-alt dark:has-[[data-state=checked]]:bg-zinc-800 has-[[data-state=checked]]:border-zinc-300",children:[(0,Xt.jsx)(PD,{value:e,id:"emp-invite-role-".concat(e),"data-testid":"emp-invite-role-".concat(e),className:"mt-0.5"}),(0,Xt.jsxs)("div",{className:"space-y-0.5",children:[(0,Xt.jsx)("div",{className:"font-medium",children:lT[e]}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300 dark:text-slate-300 leading-relaxed",children:cT[e]})]})]},e))})]}),(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{type:"button",variant:"ghost",onClick:t,"data-testid":"emp-invite-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{type:"submit",disabled:l,"data-testid":"emp-invite-submit",children:l?"Sending\u2026":"Send invitation"})]})]})]})})}const hP=["admin","recruiter","reviewer"];function fP(e){let{member:t,onClose:n,onSubmit:a}=e;
2const[r,i]=(0,s.useState)("admin"===t.role?"recruiter":"admin"),[o,l]=(0,s.useState)(!1);return(0,Xt.jsx)(rg,{open:!0,onOpenChange:e=>{e||n()},children:(0,Xt.jsxs)(lg,{"data-testid":"emp-role-dialog",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{children:"Modify member role"}),(0,Xt.jsxs)(mg,{children:["current role: ",(0,Xt.jsx)("span",{className:"font-mono",children:t.role})]})]}),(0,Xt.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),l(!0);try{await a({targetUserId:t.user_id,newRole:r})}finally{l(!1)}},className:"space-y-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{children:"New role"}),(0,Xt.jsx)(TD,{value:r,onValueChange:i,className:"mt-2 grid grid-cols-3 gap-2","data-testid":"emp-role-radio",children:hP.map(e=>(0,Xt.jsxs)(Pg,{htmlFor:"emp-role-".concat(e),className:"flex cursor-pointer items-center gap-2 rounded border p-2 text-sm\n has-[[data-state=checked]]:bg-ndor-surface-alt dark:has-[[data-state=checked]]:bg-zinc-800\n ".concat(e===t.role?"opacity-40":""),children:[(0,Xt.jsx)(PD,{value:e,id:"emp-role-".concat(e),disabled:e===t.role}),e]},e))})]}),(0,Xt.jsx)("p",{className:"rounded bg-amber-500/10 p-2 text-xs text-amber-200 dark:bg-amber-950/30 dark:text-amber-200",children:"Founder accounts cannot be demoted. Last-admin protection enforced by backend."}),(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{type:"button",variant:"ghost",onClick:n,"data-testid":"emp-role-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{type:"submit",disabled:o||r===t.role,"data-testid":"emp-role-submit",children:o?"Updating\u2026":"Modify role"})]})]})]})})}function xP(e){let{member:t,onClose:n,onSubmit:a}=e;const[r,i]=(0,s.useState)(""),[o,l]=(0,s.useState)(function(){const e=new Date;return e.setDate(e.getDate()+7),e.toISOString().slice(0,16)}()),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(!1),p=r.trim(),h=p.length>0&&!!o;return(0,Xt.jsx)(rg,{open:!0,onOpenChange:e=>{e||n()},children:(0,Xt.jsxs)(lg,{"data-testid":"emp-suspend-dialog",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{children:"Suspend member"}),(0,Xt.jsx)(mg,{className:"font-mono text-xs",children:t.user_id})]}),(0,Xt.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),h){m(!0);try{const e=new Date(o).toISOString();await a({targetUserId:t.user_id,reason:p,expiresAt:e,isEmergency:c})}finally{m(!1)}}},className:"space-y-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{htmlFor:"emp-suspend-reason",children:"Reason (required)"}),(0,Xt.jsx)(Hw,{id:"emp-suspend-reason",required:!0,maxLength:1e3,value:r,onChange:e=>i(e.target.value),placeholder:"Governance reason for the suspension",rows:3,"data-testid":"emp-suspend-reason-input"}),(0,Xt.jsxs)("p",{className:"mt-1 text-xs text-slate-300",children:[r.length,"/1000"]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{htmlFor:"emp-suspend-expires",children:"Expires at (required)"}),(0,Xt.jsx)(Ag,{id:"emp-suspend-expires",type:"datetime-local",required:!0,value:o,onChange:e=>l(e.target.value),"data-testid":"emp-suspend-expires-input"}),(0,Xt.jsx)("p",{className:"mt-1 text-xs text-slate-300",children:"The shim refuses indefinite suspension via the UI."})]}),(0,Xt.jsxs)(Pg,{className:"flex cursor-pointer items-center gap-2 text-sm",children:[(0,Xt.jsx)(Vb,{checked:c,onCheckedChange:d,"data-testid":"emp-suspend-emergency-checkbox"}),"Emergency suspension (records as ",(0,Xt.jsx)("code",{children:"member.suspended_emergency"}),")"]}),(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{type:"button",variant:"ghost",onClick:n,"data-testid":"emp-suspend-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{type:"submit",disabled:!h||u,variant:"destructive","data-testid":"emp-suspend-submit",children:u?"Suspending\u2026":"Suspend"})]})]})]})})}function vP(e){let{title:t,summary:n,idField:a="id",onClose:r}=e;const{requested:s=0,succeeded:i=0,failed:o=0,errors:l=[]}=n||{};return(0,Xt.jsx)(rg,{open:!0,onOpenChange:e=>{e||r()},children:(0,Xt.jsxs)(lg,{className:"max-w-2xl","data-testid":"emp-bulk-result",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{children:t}),(0,Xt.jsx)(mg,{children:"Per-record outcome for the batch operation."})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-3 gap-2","data-testid":"emp-bulk-counters",children:[(0,Xt.jsxs)("div",{className:"rounded border bg-ndor-surface-alt p-3 text-center dark:bg-zinc-900",children:[(0,Xt.jsx)("p",{className:"text-xs text-slate-300",children:"requested"}),(0,Xt.jsx)("p",{className:"text-2xl font-semibold","data-testid":"emp-bulk-requested",children:s})]}),(0,Xt.jsxs)("div",{className:"rounded border border-green-500/40 bg-green-50 p-3 text-center dark:bg-green-950/20",children:[(0,Xt.jsx)("p",{className:"text-xs text-green-700 dark:text-green-300",children:"succeeded"}),(0,Xt.jsx)("p",{className:"text-2xl font-semibold text-green-700 dark:text-green-300","data-testid":"emp-bulk-succeeded",children:i})]}),(0,Xt.jsxs)("div",{className:"rounded border border-red-500/40 bg-red-50 p-3 text-center dark:bg-red-950/20",children:[(0,Xt.jsx)("p",{className:"text-xs text-rose-200 dark:text-red-300",children:"failed"}),(0,Xt.jsx)("p",{className:"text-2xl font-semibold text-rose-200 dark:text-red-300","data-testid":"emp-bulk-failed",children:o})]})]}),l.length>0&&(0,Xt.jsxs)("div",{className:"mt-4 max-h-72 overflow-y-auto","data-testid":"emp-bulk-errors",children:[(0,Xt.jsx)("p",{className:"mb-2 text-sm font-medium",children:"Per-record errors"}),(0,Xt.jsx)("ul",{className:"space-y-2",children:l.map((e,t)=>{var n;return(0,Xt.jsxs)("li",{className:"flex flex-col gap-1 rounded border bg-ndor-surface-alt p-2 text-xs dar
2k:bg-zinc-900","data-testid":"emp-bulk-error-".concat(t),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Vw,{variant:"destructive",children:e.sqlstate||"ERR"}),(0,Xt.jsx)("span",{className:"font-mono text-slate-300",children:null===(n=e[a]||JSON.stringify(e.item||""))||void 0===n?void 0:n.toString().slice(0,40)})]}),(0,Xt.jsx)("p",{className:"text-slate-200 dark:text-zinc-300",children:e.message||JSON.stringify(e)})]},t)})})]}),0===l.length&&(0,Xt.jsx)("p",{className:"mt-4 text-sm text-slate-300","data-testid":"emp-bulk-no-errors",children:"All requested items processed without error."}),(0,Xt.jsx)(dg,{children:(0,Xt.jsx)(Rr,{onClick:r,"data-testid":"emp-bulk-close",children:"Close"})})]})})}function gP(e){let{orgName:t,myUserId:n,members:a,invitations:r,suspensions:s,audit:i}=e;const o=a.find(e=>e.user_id===n),l=r.find(e=>e.accepted_by===n),c=s.filter(e=>e.member_user_id===n);return(0,Xt.jsxs)("div",{className:"mx-auto w-full max-w-4xl p-4 sm:p-6","data-testid":"emp-reviewer-view",children:[(0,Xt.jsxs)("header",{className:"mb-6",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-300","data-testid":"emp-reviewer-org-label",children:t}),(0,Xt.jsx)("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl","data-testid":"emp-reviewer-title",children:"My membership"}),(0,Xt.jsxs)("p",{className:"mt-1 text-sm text-slate-300",children:["You have ",(0,Xt.jsx)(Vw,{variant:"outline","data-testid":"emp-reviewer-my-role",children:"reviewer"})," access. You can see only records about your own membership."]})]}),(0,Xt.jsxs)("section",{className:"mb-6",children:[(0,Xt.jsx)("h2",{className:"mb-2 text-sm font-semibold uppercase tracking-wider text-slate-300",children:"Membership"}),o?(0,Xt.jsxs)(Fy,{className:"p-4","data-testid":"emp-reviewer-membership",children:[(0,Xt.jsx)("p",{className:"font-mono text-xs text-slate-300",children:o.user_id}),(0,Xt.jsxs)("p",{className:"mt-1",children:["role: ",(0,Xt.jsx)(Vw,{variant:"outline",children:o.role})]}),(0,Xt.jsxs)("p",{className:"mt-1 text-xs text-slate-300",children:["joined ",o.joined_at?new Date(o.joined_at).toLocaleDateString():"\u2014"]})]}):(0,Xt.jsx)(Fy,{className:"p-4 text-sm text-slate-300","data-testid":"emp-reviewer-no-membership",children:"No membership record visible."})]}),(0,Xt.jsxs)("section",{className:"mb-6",children:[(0,Xt.jsx)("h2",{className:"mb-2 text-sm font-semibold uppercase tracking-wider text-slate-300",children:"My invitation"}),l?(0,Xt.jsxs)(Fy,{className:"p-4","data-testid":"emp-reviewer-invitation",children:[(0,Xt.jsx)("p",{children:l.target_email}),(0,Xt.jsxs)("p",{className:"mt-1",children:[(0,Xt.jsx)(Vw,{variant:"secondary",children:l.status})," ","as ",(0,Xt.jsx)(Vw,{variant:"outline",children:l.target_role})]})]}):(0,Xt.jsx)(Fy,{className:"p-4 text-sm text-slate-300","data-testid":"emp-reviewer-no-invitation",children:"No accepted invitation record visible."})]}),(0,Xt.jsxs)("section",{className:"mb-6",children:[(0,Xt.jsx)("h2",{className:"mb-2 text-sm font-semibold uppercase tracking-wider text-slate-300",children:"My suspensions"}),c.length?(0,Xt.jsx)("div",{className:"space-y-2","data-testid":"emp-reviewer-suspensions",children:c.map(e=>(0,Xt.jsxs)(Fy,{className:"p-3","data-testid":"emp-reviewer-suspension-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,Xt.jsx)(Vw,{variant:"active"===e.status?"destructive":"outline",children:e.status}),e.is_emergency&&(0,Xt.jsx)(Vw,{variant:"destructive",children:"emergency"}),(0,Xt.jsxs)("span",{className:"text-xs text-slate-300",children:[e.suspended_at?new Date(e.suspended_at).toLocaleDateString():"",e.expires_at?" \u2192 ".concat(new Date(e.expires_at).toLocaleDateString()):""]})]}),(0,Xt.jsx)("p",{className:"mt-2 text-sm",children:e.reason||"\u2014"})]},e.id))}):(0,Xt.jsx)(Fy,{className:"p-4 text-sm text-slate-300","data-testid":"emp-reviewer-no-suspensions",children:"No suspension records visible."})]}),(0,Xt.jsxs)("section",{children:[(0,Xt.jsx)("h2",{className:"mb-2 text-sm font-semibold uppercase tracking-wider text-slate-300",children:"My audit trail"}),(0,Xt.jsx)(uP,{audit:i})]})]})}
2function yP(){const e=ke(),[t,n]=(0,s.useState)(null),[a,r]=(0,s.useState)(""),[i,o]=(0,s.useState)(null),[l,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(!0),[m,p]=(0,s.useState)(null),[h,f]=(0,s.useState)(!1),[x,v]=(0,s.useState)([]),[g,y]=(0,s.useState)([]),[b,w]=(0,s.useState)([]),[j,k]=(0,s.useState)([]),[N,_]=(0,s.useState)(new Set),[D,C]=(0,s.useState)(new Set),[A,S]=(0,s.useState)(new Set),[E,F]=(0,s.useState)(!1),[R,I]=(0,s.useState)(null),[T,P]=(0,s.useState)(null),[O,B]=(0,s.useState)(null),L=(0,s.useCallback)(async()=>{u(!0),p(null);try{var e,t;const a=await(0,zt.n)("/api/employer/v1/me"),s=null===a||void 0===a||null===(e=a.organisation)||void 0===e?void 0:e.id,i=null===a||void 0===a||null===(t=a.member)||void 0===t?void 0:t.role;if(!s||!i)return f(!0),void u(!1);n(s),r(a.organisation.name||"Organisation"),o(i),c(a.user_id)}catch(mK){404===(null===mK||void 0===mK?void 0:mK.status)?f(!0):p(String((null===mK||void 0===mK?void 0:mK.message)||mK||"failed to load workspace"))}finally{u(!1)}},[]);(0,s.useEffect)(()=>{L()},[L]);const M=(0,s.useCallback)(async()=>{if(!t)return;const[e,n,a,r]=await Promise.all([QT(t).catch(()=>[]),ZT(t).catch(()=>[]),eP(t).catch(()=>[]),tP(t,{limit:100}).catch(()=>[])]);v(e),y(n),w(a),k(r)},[t]);(0,s.useEffect)(()=>{t&&M()},[t,M]);const z=(0,s.useCallback)(async e=>{let{targetEmail:n,targetRole:a}=e;try{await aP({accountId:t,targetEmail:n,targetRole:a}),fy.success("invitation sent"),F(!1),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||(null===mK||void 0===mK?void 0:mK.message)||"invite failed"))}},[t,M]),U=(0,s.useCallback)(async e=>{try{await rP({accountId:t,invitationId:e}),fy.success("invitation revoked"),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||(null===mK||void 0===mK?void 0:mK.message)||"revoke failed"))}},[t,M]),V=(0,s.useCallback)(async e=>{if(null===e||void 0===e||!e.id||null===e||void 0===e||!e.target_email||null===e||void 0===e||!e.target_role)return void fy.error("Invitation missing fields \u2014 refresh and try again.");const n=t=>"reissue-".concat(t,"-").concat(e.id,"-").concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8));try{await rP({accountId:t,invitationId:e.id,idempotencyKey:n("revoke")})}catch(mK){return void fy.error("Reissue blocked at step 1 \u2014 couldn't revoke the existing invitation. ".concat((null===mK||void 0===mK?void 0:mK.detail)||(null===mK||void 0===mK?void 0:mK.message)||"").trim())}try{await aP({accountId:t,targetEmail:e.target_email,targetRole:e.target_role,idempotencyKey:n("issue")}),fy.success("Invitation reissued to ".concat(e.target_email,". A new link has been created \u2014 the previous link is no longer valid."))}catch(mK){fy.error("Step 1 succeeded (old invitation revoked) but step 2 failed (could not issue a fresh one): ".concat((null===mK||void 0===mK?void 0:mK.detail)||(null===mK||void 0===mK?void 0:mK.message)||"issue failed",'. Use "Invite" to retry.'))}finally{await M()}},[t,M]),q=(0,s.useCallback)(async e=>{try{await function(e){let{accountId:t,targetUserId:n}=e;return(0,zt.n)("".concat(nP,"/members/").concat(n,"/revoke"),{method:"POST",body:{account_id:t}})}({accountId:t,targetUserId:e}),fy.success("member revoked"),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||(null===mK||void 0===mK?void 0:mK.message)||"revoke failed"))}},[t,M]),W=(0,s.useCallback)(async e=>{let{targetUserId:n,newRole:a}=e;try{await function(e){let{accountId:t,targetUserId:n,newRole:a}=e;return(0,zt.n)("".concat(nP,"/members/").concat(n,"/role"),{method:"POST",body:{account_id:t,new_role:a}})}({accountId:t,targetUserId:n,newRole:a}),fy.success("role updated to ".concat(a)),I(null),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||(null===mK||void 0===mK?void 0:mK.message)||"role modify failed"))}},[t,M]),H=(0,s.useCallback)(async e=>{let{targetUserId:n,reason:a,expiresAt:r,isEmergency:s}=e;try{await function(e){let{accountId:t,targetUserId:n,reason:a,expiresAt:r,isEmergency:s=!1}=e;return(0,zt.n)("".concat(nP,"/members/").concat(n,"/suspend"),{method:"POST",body:{account_id:t,reason:a,expires_at:r,is_emergency:s}})}({accountId:t,targetUserId:n,reason:a,expiresAt:r,isEmergency:s}),fy.success("member suspended"),P(null),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||(null===mK||void 0===mK?void 0:mK.message)||"suspend failed"))}},[t,M]),G=(0,s.useCallback)(async e=>{try{await function(e){let{accountId:t,suspensionId:n}=e;return(0,zt.n)("".concat(nP,"/suspensions/").concat(n,"/unsuspend"),{method:"POST",body:{account_id:t}}
2)}({accountId:t,suspensionId:e}),fy.success("suspension lifted"),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||(null===mK||void 0===mK?void 0:mK.message)||"unsuspend failed"))}},[t,M]),K=(0,s.useCallback)(async()=>{const e=Array.from(N);if(e.length)if(e.length>sP.revoke)fy.error("bulk revoke cap is ".concat(sP.revoke));else try{const n=await function(e){let{accountId:t,targetUserIds:n}=e;return(0,zt.n)("".concat(nP,"/members/bulk/revoke"),{method:"POST",body:{account_id:t,target_user_ids:n}})}({accountId:t,targetUserIds:e});B({title:"Bulk Member Revoke",summary:n,idField:"target_user_id"}),_(new Set),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||"bulk revoke failed"))}},[t,N,M]),Y=(0,s.useCallback)(async()=>{const e=Array.from(D);if(e.length)if(e.length>sP.inviteRevoke)fy.error("bulk invite revoke cap is ".concat(sP.inviteRevoke));else try{const n=await function(e){let{accountId:t,invitationIds:n}=e;return(0,zt.n)("".concat(nP,"/members/bulk/invite-revoke"),{method:"POST",body:{account_id:t,invitation_ids:n}})}({accountId:t,invitationIds:e});B({title:"Bulk Invitation Revoke",summary:n,idField:"invitation_id"}),C(new Set),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||"bulk invite revoke failed"))}},[t,D,M]),J=(0,s.useCallback)(async()=>{const e=Array.from(A);
2if(e.length)if(e.length>sP.unsuspend)fy.error("bulk unsuspend cap is ".concat(sP.unsuspend));else try{const n=await function(e){let{accountId:t,suspensionIds:n}=e;return(0,zt.n)("".concat(nP,"/members/bulk/unsuspend"),{method:"POST",body:{account_id:t,suspension_ids:n}})}({accountId:t,suspensionIds:e});B({title:"Bulk Unsuspend",summary:n,idField:"suspension_id"}),S(new Set),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||"bulk unsuspend failed"))}},[t,A,M]),$=(0,s.useCallback)(async e=>{const n=Array.from(N);if(!n.length)return;if(n.length>sP.roleModify)return void fy.error("bulk role-modify cap is ".concat(sP.roleModify));const a=n.map(t=>({target_user_id:t,new_role:e}));try{const n=await function(e){let{accountId:t,items:n}=e;return(0,zt.n)("".concat(nP,"/members/bulk/role-modify"),{method:"POST",body:{account_id:t,items:n}})}({accountId:t,items:a});B({title:"Bulk Role \u2192 ".concat(e),summary:n,idField:"item"}),_(new Set),await M()}catch(mK){fy.error(String((null===mK||void 0===mK?void 0:mK.detail)||"bulk role-modify failed"))}},[t,N,M]);if(d)return(0,Xt.jsx)("div",{className:"flex h-[50vh] items-center justify-center","data-testid":"emp-members-loading",children:(0,Xt.jsx)("span",{className:"text-sm text-slate-300",children:"Loading member workspace\u2026"})});if(h)return(0,Xt.jsx)(BT,{});if(m)return(0,Xt.jsx)("div",{className:"mx-auto max-w-2xl p-6","data-testid":"emp-members-access-error",children:(0,Xt.jsxs)(Fy,{className:"border-red-500/20 bg-red-50 p-6 dark:bg-red-950/20",children:[(0,Xt.jsx)("h2",{className:"mb-2 text-lg font-semibold text-rose-200 dark:text-red-300",children:"Access denied"}),(0,Xt.jsx)("p",{className:"text-sm text-rose-200/80 dark:text-red-300/80",children:m}),(0,Xt.jsx)(Rr,{className:"mt-4",onClick:()=>e("/employer"),"data-testid":"emp-members-back-btn",children:"Back to employer home"})]})});const X="admin"===i||"owner"===i;return"reviewer"===i?(0,Xt.jsx)(gP,{orgName:a,myUserId:l,members:x,invitations:g,suspensions:b,audit:j}):(0,Xt.jsxs)("div",{className:"mx-auto w-full max-w-7xl p-4 sm:p-6","data-testid":"emp-members-workspace",children:[(0,Xt.jsxs)("header",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-300","data-testid":"emp-members-org-label",children:a}),(0,Xt.jsx)("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl","data-testid":"emp-members-title",children:"Member management"})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)(Vw,{variant:"outline","data-testid":"emp-members-my-role",children:["you \xb7 ",i]}),X&&(0,Xt.jsx)(Rr,{onClick:()=>F(!0),"data-testid":"emp-members-invite-btn",children:"Invite member"})]})]}),(0,Xt.jsxs)(tI,{defaultValue:"members",className:"w-full","data-testid":"emp-members-tabs",children:[(0,Xt.jsxs)(nI,{className:"mb-4 grid w-full grid-cols-2 sm:grid-cols-4",children:[(0,Xt.jsxs)(aI,{value:"members","data-testid":"emp-members-tab-members",children:["Members (",x.length,")"]}),(0,Xt.jsxs)(aI,{value:"invitations","data-testid":"emp-members-tab-invitations",children:["Invitations (",g.length,")"]}),(0,Xt.jsxs)(aI,{value:"suspensions","data-testid":"emp-members-tab-suspensions",children:["Suspensions (",b.filter(e=>"active"===e.status).length,")"]}),(0,Xt.jsxs)(aI,{value:"audit","data-testid":"emp-members-tab-audit",children:["Audit (",j.length,")"]})]}),(0,Xt.jsx)(Fy,{className:"mb-4 border-ndor-edge p-4","data-testid":"emp-members-permissions-explainer",children:(0,Xt.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-ndor-ink-muted shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{className:"space-y-2 text-xs",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Roles & permissions"}),(0,Xt.jsx)(Et,{to:"/employer/help/permissions",className:"text-ndor-ink-muted underline-offset-2 hover:underline","data-testid":"emp-members-permissions-link",children:"Full matrix \u2192"})]}),(0,Xt.jsx)("ul",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:["owner","admin","recruiter","reviewer"].map(e=>(0,Xt.jsxs)("li",{className:"border border-ndor-edge rounded-md px-2.5 py-1.5","data-testid":"emp-members-role-card-".concat(e),children:[(0,Xt.jsx)(Vw,{variant:"outline",className:"mr-1.5 text-[10px]",children:lT[e]}),(0,Xt.jsx)("span",{className:"text-ndor-ink-secondary leading-relaxed",children:cT[e]})]},e))})]})]})}),(0,Xt.jsx)(rI,{value:"members",children:(0,Xt.jsx)(iP,{members:x,myUserId:l,isAdmin:X,selected:N,setSelected:_,onModifyRole:e=>I({member:e}),onSuspend:e=>P({member:e}),onRevoke:e=>{window.confirm("Revoke this member? This cannot be undone.")&&q(e)},onBulkRevoke:K,onBulkRoleDemote:$,bulkLimits:sP})}),(0,Xt.jsx)(rI,{value:"invitations",children:(0,Xt.jsx)(lP,{invitations:g,isAdmin:X,selected:D,setSelected:C,onRevoke:e=>{window.confirm("Revoke this pending invitation?")&&U(e)},onReissue:e=>{window.confirm("Reissue invitation to ".concat(e.target_email,"?\n\n")+"This revokes the current invitation and issues a fresh one with a NEW link. The previous link will no longer work.")&&V(e)},onBulkRevoke:Y,bulkLimit:sP.inviteRevoke})}),(0,Xt.jsx)(rI,{value:"suspensions",children:(0,Xt.jsx)(cP,{suspensions:b,isAdmin:X,selected:A,setSelected:S,onUnsuspend:G,onBulkUnsuspend:J,bulkLimit:sP.unsu
2spend})}),(0,Xt.jsx)(rI,{value:"audit",children:(0,Xt.jsx)(uP,{audit:j})})]}),E&&(0,Xt.jsx)(pP,{onClose:()=>F(!1),onSubmit:z}),R&&(0,Xt.jsx)(fP,{member:R.member,onClose:()=>I(null),onSubmit:W}),T&&(0,Xt.jsx)(xP,{member:T.member,onClose:()=>P(null),onSubmit:H}),O&&(0,Xt.jsx)(vP,{title:O.title,summary:O.summary,idField:O.idField,onClose:()=>B(null)})]})}const bP=wn("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),wP=wn("message-square-plus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]),jP="/api/employer/v1/reviewer",kP=e=>e?{"Idempotency-Key":e}:{};function NP(e){let{reviewId:t,idempotencyKey:n}=e;return(0,zt.n)("".concat(jP,"/reviews/").concat(t,"/start"),{method:"POST",headers:kP(n),body:{}})}const _P={"reviewer.queue.title":"My reviews","reviewer.queue.subtitle":"Candidates routed to you for review. Start a pending review, then advance, reject, or place on hold. All decisions are append-only.","reviewer.queue.counter.pending":"Pending","reviewer.queue.counter.in_review":"In review","reviewer.queue.counter.decided":"Decided","reviewer.queue.section.title":"Queue","reviewer.queue.empty":"No reviews assigned yet.","reviewer.queue.empty.body":"When an admin or recruiter routes a candidate to you, the review will appear here as \u201cPending\u201d. Start it to lock the review-in-progress state, then decide (advance, reject, or place on hold). All decisions are append-only.","reviewer.queue.empty.cta":"Back to Organisation","reviewer.queue.loading":"Loading\u2026","reviewer.queue.col.review":"Review","reviewer.queue.col.status":"Status","reviewer.queue.col.decision":"Decision","reviewer.queue.col.routed":"Routed","reviewer.queue.col.actions":"Actions","reviewer.queue.action.start":"Start","reviewer.queue.action.decide":"Decide","reviewer.queue.action.note":"Note","reviewer.decide.title":"Record decision","reviewer.decide.field.decision":"Decision","reviewer.decide.option.advance":"Advance","reviewer.decide.option.reject":"Reject","reviewer.decide.option.on_hold":"On hold","reviewer.decide.field.rationale":"Rationale","reviewer.decide.rationale.required":"Required when rejecting","reviewer.decide.rationale.optional":"Optional context (max 2000 chars)","reviewer.decide.cancel":"Cancel","reviewer.decide.submit":"Submit decision","reviewer.decide.toast.success":"Decision recorded. Your recommendation will be considered by the authorised hiring team before the candidate\u2019s status is changed.","reviewer.decide.toast.fail":"Failed to record decision","reviewer.decide.rationale.warning":"A rationale is required for rejection","reviewer.note.title":"Add note","reviewer.note.placeholder":"Notes are append-only and visible to admins/recruiters.","reviewer.note.cancel":"Cancel","reviewer.note.submit":"Add note","reviewer.note.toast.success":"Note added","reviewer.note.toast.fail":"Failed to add note","reviewer.toast.start.success":"Review started","reviewer.toast.start.fail":"Failed to start review","reviewer.toast.queue.fail":"Failed to load reviewer queue","reviewer.status.pending":"Pending","reviewer.status.in_review":"In review","reviewer.status.decided":"Decided","reviewer.decision.advance":"Advance","reviewer.decision.reject":"Reject","reviewer.decision.on_hold":"On hold","admin.roster.title":"Reviewer roster","admin.roster.subtitle":"Assign reviewers to roles, pause or resume their access, and remove assignments. Reviewers see only their own queue.","admin.roster.access.denied":"You need an admin or recruiter role to manage reviewer assignments.","admin.roster.bootstrap.fail":"Failed to load reviewer roster","admin.roster.loading":"Loading reviewer roster\u2026","admin.roster.empty":"No reviewer assignments yet.","admin.roster.empty.body":"Reviewers are members with the \u201creviewer\u201d role on this account. Once you\u2019ve invited them and created a role, use \u201cAssign reviewer\u201d to bind them to that role. From then on, you can route candidates from the Matches surface to all active reviewers in one click.","admin.roster.empty.cta.members":"Invite reviewers","admin.roster.empty.cta.roles":"Manage roles","admin.roster.action.assign":"Assign reviewer","admin.roster.action.refresh":"Refresh","admin.roster.col.role":"Role","admin.roster.col.reviewer":"Reviewer","admin.roster.col.status":"Status","admin.roster.col.created":"Assigned","admin.roster.col.actions":"Actions","admin.roster.status.active":"Active","admin.roster.status.paused":"Paused","admin.roster.status.removed":"Removed","admin.roster.action.pause":"Pause","admin.roster.action.resume":"Resume","admin.roster.action.unassign":"Unassign","admin.roster.toast.pause.success":"Reviewer assignment paused","admin.roster.toast.pause.fail":"Failed to pause assignment","admin.roster.toast.resume.success":"Reviewer assignment resumed","admin.roster.toast.resume.fail":"Failed to resume assignment","admin.roster.toast.unassign.success":"Reviewer unassigned","admin.roster.toast.unassign.fail":"Failed to unassign reviewer","admin.roster.unassign.confirm":"Remove this reviewer\u2019s assignment? This cannot be undone but is auditable.","admin.assign.title":"Assign reviewer","admin.assign.field.role":"Role","admin.assign.field.reviewer":"Reviewer","admin.assign.placeholder.role":"Select a role\u2026","admin.assign.placeholder.reviewer":"Select a reviewer\u2026","admin.assign.help.reviewer":"Only employer members with the \u201creviewer\u201d role appear here. Invite reviewers from the Members page first.","admin.assign.cancel":"Cancel","admin.assign.submit":"Assign","admin.assign.toast.success":"Reviewer assigned","admin.assign.toast.fail":"Failed to assign reviewer","admin.assign.no_roles":"No roles available. Create a role first.","admin.assign.no_reviewers":"No members with the reviewer role yet.","coverage.title":"Reviewer coverage","coverage.loading":"Loading reviewer coverage\u2026","coverage.fail":"Failed to load reviewer coverage","coverage.active_assignments":"Active reviewers","coverage.o
2pen.pending":"Pending reviews","coverage.open.in_review":"In review","coverage.decided":"Decided","coverage.consensus.label":"Status:","coverage.empty":"No reviewers assigned to this role yet.","coverage.cta.assign":"Assign reviewers","coverage.cta.view_roster":"View reviewer roster","coverage.help":"Open reviews are counted across all reviewers assigned to this role.","route.action.default":"Route to reviewers","route.action.routed":"Routed to reviewers","route.action.already_routed":"Already routed","route.action.disabled.no_reviewers":"No active reviewers on this role","route.toast.success":"Fanned out to {{n}} reviewers","route.toast.cta.view_reviewers":"View reviewers","route.toast.fail":"Failed to route candidate","route.aria.routed_match":"Route this revealed candidate to all active reviewers","admin.roster.col.workload":"Workload","admin.roster.workload.none":"No open reviews","admin.roster.workload.pending":"{{n}} pending","admin.roster.workload.in_review":"{{n}} in review","admin.roster.workload.fail":"Failed to load workload counters"},DP=e=>{var t;return null!==(t=_P[e])&&void 0!==t?t:e},CP=function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=null!==(t=_P[e])&&void 0!==t?t:e;return String(a).replace(/\{\{(\w+)\}\}/g,(e,t)=>Object.prototype.hasOwnProperty.call(n,t)?String(n[t]):e)},AP={pending:{key:"reviewer.status.pending",variant:"secondary"},in_review:{key:"reviewer.status.in_review",variant:"default"},decided:{key:"reviewer.status.decided",variant:"outline"}},SP={advance:(0,Xt.jsx)(Og,{className:"h-4 w-4 text-emerald-600"}),reject:(0,Xt.jsx)(Gg,{className:"h-4 w-4 text-rose-600"}),on_hold:(0,Xt.jsx)(bP,{className:"h-4 w-4 text-amber-600"})};function EP(){return"rev-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,10))}function FP(){const[e,t]=(0,s.useState)([]),[n,a]=(0,s.useState)(!0),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),u=(0,s.useCallback)(async()=>{a(!0);try{const e=await function(){let{status:e,limit:t=50}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=new URLSearchParams;return e&&n.set("status",e),n.set("limit",String(t)),(0,zt.n)("".concat(jP,"/queue?").concat(n.toString()))}({limit:100});t((null===e||void 0===e?void 0:e.reviews)||[])}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||DP("reviewer.toast.queue.fail"))}finally{a(!1)}},[]);(0,s.useEffect)(()=>{u()},[u]);const m=(0,s.useCallback)(async e=>{i(e.review_id);
2try{await NP({reviewId:e.review_id,idempotencyKey:EP()}),fy.success(DP("reviewer.toast.start.success")),u()}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||DP("reviewer.toast.start.fail"))}finally{i(null)}},[u]),p=(0,s.useMemo)(()=>({pending:e.filter(e=>"pending"===e.status).length,inReview:e.filter(e=>"in_review"===e.status).length,decided:e.filter(e=>"decided"===e.status).length}),[e]);return(0,Xt.jsxs)("div",{className:"space-y-6 p-6","data-testid":"reviewer-queue-page",children:[(0,Xt.jsxs)("header",{className:"space-y-1",children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:DP("reviewer.queue.title")}),(0,Xt.jsx)("p",{className:"text-sm text-muted-foreground",children:DP("reviewer.queue.subtitle")})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-3 gap-3","data-testid":"reviewer-queue-counters",children:[(0,Xt.jsx)(Fy,{children:(0,Xt.jsxs)(Py,{className:"p-4",children:[(0,Xt.jsx)("div",{className:"text-xs uppercase text-muted-foreground",children:DP("reviewer.queue.counter.pending")}),(0,Xt.jsx)("div",{className:"text-2xl font-semibold",children:p.pending})]})}),(0,Xt.jsx)(Fy,{children:(0,Xt.jsxs)(Py,{className:"p-4",children:[(0,Xt.jsx)("div",{className:"text-xs uppercase text-muted-foreground",children:DP("reviewer.queue.counter.in_review")}),(0,Xt.jsx)("div",{className:"text-2xl font-semibold",children:p.inReview})]})}),(0,Xt.jsx)(Fy,{children:(0,Xt.jsxs)(Py,{className:"p-4",children:[(0,Xt.jsx)("div",{className:"text-xs uppercase text-muted-foreground",children:DP("reviewer.queue.counter.decided")}),(0,Xt.jsx)("div",{className:"text-2xl font-semibold",children:p.decided})]})})]}),(0,Xt.jsxs)(Fy,{children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base",children:[(0,Xt.jsx)(Dn,{className:"h-4 w-4"})," ",DP("reviewer.queue.section.title")]})}),(0,Xt.jsx)(Py,{children:n?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," ",DP("reviewer.queue.loading")]}):0===e.length?(0,Xt.jsxs)("div",{"data-testid":"reviewer-queue-empty",className:"py-10 text-center space-y-3 max-w-md mx-auto",children:[(0,Xt.jsx)(Dn,{className:"mx-auto h-8 w-8 text-muted-foreground/70"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-foreground",children:DP("reviewer.queue.empty")}),(0,Xt.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:DP("reviewer.queue.empty.body")}),(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",size:"sm","data-testid":"reviewer-queue-empty-cta",children:(0,Xt.jsx)("a",{href:"/employer",children:DP("reviewer.queue.empty.cta")})})]}):(0,Xt.jsx)("div",{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm","data-testid":"reviewer-queue-table",children:[(0,Xt.jsx)("thead",{children:(0,Xt.jsxs)("tr",{className:"border-b text-left text-xs uppercase text-muted-foreground",children:[(0,Xt.jsx)("th",{className:"py-2 pr-3",children:DP("reviewer.queue.col.review")}),(0,Xt.jsx)("th",{className:"py-2 pr-3",children:DP("reviewer.queue.col.status")}),(0,Xt.jsx)("th",{className:"py-2 pr-3",children:DP("reviewer.queue.col.decision")}),(0,Xt.jsx)("th",{className:"py-2 pr-3",children:DP("reviewer.queue.col.routed")}),(0,Xt.jsx)("th",{className:"py-2 pr-3",children:DP("reviewer.queue.col.actions")})]})}),(0,Xt.jsx)("tbody",{children:e.map(e=>{const t=AP[e.status]||{label:e.status,variant:"outline"};return(0,Xt.jsxs)("tr",{className:"border-b last:border-0","data-testid":"reviewer-row-".concat(e.review_id),children:[(0,Xt.jsxs)("td",{className:"py-2 pr-3 font-mono text-xs",children:[e.review_id.slice(0,8),"\u2026"]}),(0,Xt.jsx)("td",{className:"py-2 pr-3",children:(0,Xt.jsx)(Vw,{variant:t.variant,children:DP(t.key)})}),(0,Xt.jsx)("td",{className:"py-2 pr-3",children:e.decision?(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[SP[e.decision]||null,(0,Xt.jsx)("span",{className:"capitalize",children:e.decision.replace("_"," ")})]}):(0,Xt.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-xs text-muted-foreground",children:new Date(e.routed_at).toLocaleStr
2ing()}),(0,Xt.jsx)("td",{className:"py-2 pr-3",children:(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost","data-testid":"reviewer-open-".concat(e.review_id),asChild:!0,children:(0,Xt.jsx)("a",{href:"/employer/reviews/".concat(e.review_id),children:"Open"})}),"pending"===e.status&&(0,Xt.jsxs)(Rr,{size:"sm",variant:"secondary","data-testid":"reviewer-start-".concat(e.review_id),disabled:r===e.review_id,onClick:()=>m(e),children:[(0,Xt.jsx)(jF,{className:"mr-1 h-3 w-3"})," ",DP("reviewer.queue.action.start")]}),"in_review"===e.status&&(0,Xt.jsx)(Rr,{size:"sm","data-testid":"reviewer-decide-open-".concat(e.review_id),onClick:()=>l(e),children:DP("reviewer.queue.action.decide")}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline","data-testid":"reviewer-note-open-".concat(e.review_id),onClick:()=>d(e),children:[(0,Xt.jsx)(wP,{className:"mr-1 h-3 w-3"})," ",DP("reviewer.queue.action.note")]})]})})]},e.review_id)})})]})})})]}),(0,Xt.jsx)(RP,{row:o,onClose:()=>l(null),onDone:u}),(0,Xt.jsx)(IP,{row:c,onClose:()=>d(null),onDone:u}),(0,Xt.jsx)(Fw,{workspace:"employer",memberRole:null})]})}function RP(e){let{row:t,onClose:n,onDone:a}=e;const[r,i]=(0,s.useState)("advance"),[o,l]=(0,s.useState)(""),[c,d]=(0,s.useState)(!1),u=Boolean(t);(0,s.useEffect)(()=>{t&&(i("advance"),l(""))},[t]);const m="reject"===r;return(0,Xt.jsx)(rg,{open:u,onOpenChange:e=>!e&&n(),children:(0,Xt.jsxs)(lg,{"data-testid":"reviewer-decide-dialog",children:[(0,Xt.jsx)(cg,{children:(0,Xt.jsx)(ug,{children:DP("reviewer.decide.title")})}),(0,Xt.jsxs)("div",{className:"space-y-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-sm font-medium",children:DP("reviewer.decide.field.decision")}),(0,Xt.jsxs)(Vv,{value:r,onValueChange:i,children:[(0,Xt.jsx)(Wv,{"data-testid":"reviewer-decision-select",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsxs)(Kv,{children:[(0,Xt.jsx)(Yv,{value:"advance",children:DP("reviewer.decide.option.advance")}),(0,Xt.jsx)(Yv,{value:"reject",children:DP("reviewer.decide.option.reject")}),(0,Xt.jsx)(Yv,{value:"on_hold",children:DP("reviewer.decide.option.on_hold")})]})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("div",{className:"mb-1 text-sm font-medium",children:[DP("reviewer.decide.field.rationale")," ",m&&(0,Xt.jsx)("span",{className:"text-rose-600",children:"*"})]}),(0,Xt.jsx)(Hw,{"data-testid":"reviewer-rationale-textarea",maxLength:2e3,value:o,onChange:e=>l(e.target.value),placeholder:DP(m?"reviewer.decide.rationale.required":"reviewer.decide.rationale.optional")})]})]}),(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:n,disabled:c,children:DP("reviewer.decide.cancel")}),(0,Xt.jsxs)(Rr,{"data-testid":"reviewer-decide-submit",onClick:async()=>{if(t)if(!m||o.trim()){d(!0);try{await function(e){let{reviewId:t,decision:n,rationaleExcerpt:a,idempotencyKey:r}=e;return(0,zt.n)("".concat(jP,"/reviews/").concat(t,"/decide"),{method:"POST",headers:kP(r),body:{decision:n,rationale_excerpt:a||null}})}({reviewId:t.review_id,decision:r,rationaleExcerpt:o.trim()||null,idempotencyKey:EP()}),fy.success(DP("reviewer.decide.toast.success")),n(),a()}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||DP("reviewer.decide.toast.fail"))}finally{d(!1)}}else fy.error(DP("reviewer.decide.rationale.warning"))},disabled:c,children:[c&&(0,Xt.jsx)(Lg,{className:"mr-1 h-3 w-3 animate-spin"})," ",DP("reviewer.decide.submit")]})]})]})})}function IP(e){let{row:t,onClose:n,onDone:a}=e;const[r,i]=(0,s.useState)(""),[o,l]=(0,s.useState)(!1),c=Boolean(t);(0,s.useEffect)(()=>{t&&i("")},[t]);return(0,Xt.jsx)(rg,{open:c,onOpenChange:e=>!e&&n(),children:(0,Xt.jsxs)(lg,{"data-testid":"reviewer-note-dialog",children:[(0,Xt.jsx)(cg,{children:(0,Xt.jsx)(ug,{children:DP("reviewer.note.title")})}),(0,Xt.jsx)(Hw,{"data-testid":"reviewer-note-textarea",maxLength:4e3,rows:6,value:r,onChange:e=>i(e.target.value),placeholder:DP("reviewer.note.placeholder")}),(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:n,disabled:o,children:DP("reviewer.note.cancel")}),(0,Xt.jsxs)(Rr,{"data-testid":"reviewer-note-submit",onClick:async()=>
2{if(t&&r.trim()){l(!0);try{await function(e){let{reviewId:t,body:n,idempotencyKey:a}=e;return(0,zt.n)("".concat(jP,"/reviews/").concat(t,"/notes"),{method:"POST",headers:kP(a),body:{body:n}})}({reviewId:t.review_id,body:r.trim(),idempotencyKey:EP()}),fy.success(DP("reviewer.note.toast.success")),n(),a()}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||DP("reviewer.note.toast.fail"))}finally{l(!1)}}},disabled:o||!r.trim(),children:[o&&(0,Xt.jsx)(Lg,{className:"mr-1 h-3 w-3 animate-spin"})," ",DP("reviewer.note.submit")]})]})]})})}const TP={advance:"bg-emerald-500/15 text-emerald-700 border-emerald-500/30",reject:"bg-rose-500/15 text-rose-700 border-rose-500/30",on_hold:"bg-amber-500/15 text-amber-700 border-amber-500/30"};function PP(e){let{status:t}=e;const n="decided"===t?"bg-emerald-500/15 text-emerald-700 border-emerald-500/30":"in_review"===t?"bg-blue-500/15 text-blue-700 border-blue-500/30":"bg-ndor-surface-alt/60 border-ndor-edge text-ndor-ink-secondary";return(0,Xt.jsx)(Vw,{variant:"outline",className:"uppercase tracking-wider text-[10px] ".concat(n),children:(t||"pending").replace("_"," ")})}function OP(e){let{decision:t}=e;return t?(0,Xt.jsx)(Vw,{variant:"outline",className:"uppercase tracking-wider text-[10px] ".concat(TP[t]||""),children:t}):null}function BP(){var e,t;const{reviewId:n}=_e(),a=ke(),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(!0),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(null),[p,h]=(0,s.use
2State)(null),[f,x]=(0,s.useState)(!1),v=(0,s.useCallback)(async()=>{l(!0),d(null);try{const e=await(0,zt.n)("/api/employer/v1/reviewer/reviews/".concat(n,"/dossier"));i(e||null)}catch(mK){var e;d((null===mK||void 0===mK||null===(e=mK.data)||void 0===e?void 0:e.detail)||(null===mK||void 0===mK?void 0:mK.message)||"Could not load dossier.")}finally{l(!1)}},[n]);(0,s.useEffect)(()=>{v()},[v]);const g=(null===r||void 0===r?void 0:r.review)||{},y=(null===r||void 0===r?void 0:r.role)||{},b=(null===r||void 0===r?void 0:r.candidate)||{},w=(null===r||void 0===r?void 0:r.match)||null,j=(null===r||void 0===r?void 0:r.notes)||[],k=(0,s.useCallback)(()=>{m(null),v(),fy.success("Decision recorded. Your recommendation will be considered by the authorised hiring team before the candidate\u2019s status is changed.")},[v]),N=(0,s.useCallback)(()=>{h(null),v(),fy.success("Note saved.")},[v]),_=(0,s.useCallback)(async()=>{if(g.review_id){x(!0);try{await NP({reviewId:g.review_id,idempotencyKey:"reviewer-dossier-".concat(Date.now(),"-").concat(Math.random().toString(16).slice(2,8))}),fy.success("Review started."),v()}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||"Could not start review.")}finally{x(!1)}}},[g.review_id,v]),D="decided"===g.status,C=(0,s.useMemo)(()=>(b.parsed_cv_text||"").split(/\n+/).map(e=>e.trim()).filter(Boolean).slice(0,80),[b.parsed_cv_text]);return(0,Xt.jsxs)("div",{className:"mx-auto max-w-5xl px-4 py-6 sm:py-8 space-y-4","data-testid":"reviewer-dossier-page",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsxs)(Rr,{variant:"ghost",size:"sm",onClick:()=>a("/employer/reviews"),"data-testid":"reviewer-dossier-back",className:"text-ndor-ink-secondary",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1"})," Back to queue"]}),(0,Xt.jsxs)("div",{className:"text-[11px] text-ndor-ink-muted font-mono",children:["Review \xb7 V-",(g.review_id||"").slice(0,8)]})]}),o&&(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface p-6 text-sm text-ndor-ink-secondary","data-testid":"reviewer-dossier-loading",children:"Loading dossier\u2026"}),!!c&&(0,Xt.jsx)(Fy,{className:"border-rose-500/40 bg-rose-500/5 p-4 text-sm text-rose-700","data-testid":"reviewer-dossier-error",children:c}),!o&&!c&&r&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface p-5",children:(0,Xt.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(PP,{status:g.status}),(0,Xt.jsx)(OP,{decision:g.decision})]}),(0,Xt.jsxs)("h1",{className:"text-lg font-serif-display text-ndor-ink tracking-tight mt-1",children:["Reviewing candidate ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:b.token})," for"," ",(0,Xt.jsx)("span",{className:"text-ndor-ink-secondary",children:y.title||"Untitled role"})]}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted",children:["Routed ",g.routed_at?new Date(g.routed_at).toLocaleString():"\u2014"," \xb7"," ",g.decided_at?"Decided ".concat(new Date(g.decided_at).toLocaleString()):"Awaiting decision"]})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-2",children:["pending"===g.status&&(0,Xt.jsx)(Rr,{size:"sm",onClick:_,disabled:f,"data-testid":"reviewer-dossier-start-btn",children:f?"Starting\u2026":"Start review"}),!D&&(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",onClick:()=>h({review_id:g.review_id}),"data-testid":"reviewer-dossier-note-btn",children:"Add note"}),!D&&"in_review"===g.status&&(0,Xt.jsx)(Rr,{size:"sm",onClick:()=>m({review_id:g.review_id}),"data-testid":"reviewer-dossier-decide-btn",children:"Decide"})]})]})}),(0,Xt.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface p-5 space-y-3","data-testid":"reviewer-dossier-role",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-ndor-ink-muted uppercase tracking-wider",children:[(0,Xt.jsx)(kn,{className:"h-3.5 w-3.5"})," Role definition"]}),(0,Xt.jsx)("h2",{className:"text-base font-medium text-ndor-ink",children:y.title||"\u2014"}),(0,Xt.jsxs)("dl",{className:"text-xs space-y-1.5",children:[(0,Xt.jsxs)("div",{className:"flex gap-2",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted w-32 shrink-0",children:"Must-have domain"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:y.must_have_domain||"\u2014"})]}),(0,Xt.jsxs)("div",{className:"flex gap-2",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted w-32 shrink-0",children:"Working model"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:y.working_model||"\u2014"})]}),(0,Xt.jsxs)("div",{className:"flex gap-2",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted w-32 shrink-0",children:"Location"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:y.location_constraint||"\u2014"})]})]}),(y.must_have_skills||[]).length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted uppercase tracking-wider mb-1",children:"Must-have skills"}),(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5",children:y.must_have_skills.slice(0,24).map(e=>(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge bg-ndor-surface-alt/60 text-[10px]",children:e},e))})]}),(y.nice_to_have_skills||[]).length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted uppercase tracking-wider mb-1",children:"Nice-to-have"}),(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5",children:y.nice_to_have_skills.slice(0,18).map(e=>(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge bg-ndor-surface-alt/60 text-[10px] text-ndor-ink-secondary",children:e},e))})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface p-5 space-y-3","data-testid":"reviewer-dossier-candidate",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-ndor-ink-muted uppercase tracking-wider",children:[(0,Xt.jsx)(Bn,{className:"h-3.5 w-3.5 text-ndor-gold"})," Candidate (PII-free)"]}),(0,Xt.jsx)("h2",{className:"text-base font-mono-ui text-ndor-ink",children:b.token}),(0,Xt.jsxs)("dl",{className:"text-xs space-y-1.5",children:[(0,Xt.jsxs)("div",{className:"flex gap-2",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted w-32 shrink-0",children:"Primary domain"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:b.primary_domain||"\u2014"})]}),(0,Xt.jsxs)("div",{className:"flex gap-2",children:[(0,Xt.jsx)("dt",{className:"text-ndor-ink-muted w-32 shrink-0",children:"Years experience"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:null!==(e=b.years_experience)&&void 0!==e?e:"\u2014"})]})]}
2),(b.skills_json||[]).length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted uppercase tracking-wider mb-1",children:"Skills (declared)"}),(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5",children:b.skills_json.slice(0,30).map(e=>(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge bg-ndor-surface-alt/60 text-[10px]",children:e},e))})]}),w&&(0,Xt.jsxs)("div",{className:"mt-3 rounded border border-ndor-edge bg-ndor-surface-alt/40 p-3 text-[11px] space-y-1",children:[(0,Xt.jsx)("p",{className:"font-mono-ui text-ndor-ink-muted",children:"NDOR match metadata"}),(0,Xt.jsxs)("p",{className:"text-ndor-ink",children:["Fit score: ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:null!==(t=w.fit_score)&&void 0!==t?t:"\u2014"}),w.confidence&&(0,Xt.jsxs)(Xt.Fragment,{children:[" \xb7 Confidence: ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:w.confidence})]}),w.decision_signal&&(0,Xt.jsxs)(Xt.Fragment,{children:[" \xb7 Signal: ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:w.decision_signal})]})]})]})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface p-5 space-y-3","data-testid":"reviewer-dossier-cv",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-ndor-ink-muted uppercase tracking-wider",children:[(0,Xt.jsx)(Nn,{className:"h-3.5 w-3.5"})," Parsed CV evidence"]}),b.parsed_cv_truncated_at&&(0,Xt.jsxs)("span",{className:"text-[10px] text-ndor-ink-muted",children:["Truncated at ",b.parsed_cv_truncated_at.toLocaleString()," chars"]})]}),0===C.length?(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"No parsed CV text on record."}):(0,Xt.jsx)("div",{className:"text-sm text-ndor-ink-secondary leading-relaxed space-y-2 max-h-[420px] overflow-y-auto pr-2","data-testid":"reviewer-dossier-cv-body",children:C.map((e,t)=>(0,Xt.jsx)("p",{children:e},t))})]}),j.length>0&&(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface p-5 space-y-3","data-testid":"reviewer-dossier-notes",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-ndor-ink-muted uppercase tracking-wider",children:["Notes (",j.length,")"]}),(0,Xt.jsx)("div",{className:"space-y-3",children:j.map(e=>(0,Xt.jsxs)("div",{className:"text-xs leading-relaxed border-l-2 border-ndor-gold/40 pl-3",children:[(0,Xt.jsx)("p",{className:"text-ndor-ink-muted text-[10px] mb-0.5",children:e.created_at?new Date(e.created_at).toLocaleString():"\u2014"}),(0,Xt.jsx)("p",{className:"text-ndor-ink-secondary whitespace-pre-wrap",children:e.body})]},e.note_id))})]}),(0,Xt.jsx)(gs,{className:"bg-ndor-edge"}),g.rationale_excerpt&&(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface p-5","data-testid":"reviewer-dossier-rationale",children:[(0,Xt.jsx)("div",{className:"flex items-center gap-2 text-[11px] text-ndor-ink-muted uppercase tracking-wider mb-2",children:"Recorded rationale"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink whitespace-pre-wrap",children:g.rationale_excerpt})]})]}),(0,Xt.jsx)(RP,{row:u,onClose:()=>m(null),onDone:k}),(0,Xt.jsx)(IP,{row:p,onClose:()=>h(null),onDone:N})]})}const LP=wn("user-minus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);async function MP(e){if(!e)return[];const{data:t,error:n}=await Mt.supabase.from("emp_reviewer_assignments").select("assignment_id, account_id, role_id, reviewer_user_id, assignment_status, created_at, updated_at").eq("account_id",e).order("created_at",{ascending:!1});if(n)throw n;return t||[]}async function zP(e){if(!e)return[];const{data:t,error:n}=await Mt.supabase.from("emp_account_members").select("user_id, role, joined_at").eq("account_id",e).eq("role","reviewer").order("joined_at",{ascending:!1});if(n)throw n;return t||[]}async function UP(e,t){if(!e||!t)return[];const{data:n,error:a}=await Mt.supabase.from("emp_candidate_reviews").select("review_id, reviewer_user_id, status").eq("account_id",e).eq("role_id",t).in("status",["pen
2ding","in_review"]);if(a)throw a;return n||[]}async function VP(e,t){if(!e||!t)return[];const{data:n,error:a}=await Mt.supabase.from("emp_candidate_reviews").select("review_id, reviewer_user_id, status, decision").eq("account_id",e).eq("role_id",t).eq("status","decided");if(a)throw a;return n||[]}async function qP(e){if(!e)return[];const{data:t,error:n}=await Mt.supabase.from("emp_candidate_reviews").select("review_id, reviewer_user_id, status").eq("account_id",e).in("status",["pending","in_review"]);if(n)throw n;return t||[]}function WP(){return"rev-roster-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,10))}function HP(){ke();const[e,t]=(0,s.useState)(null),[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)([]),[c,d]=(0,s.useState)([]),[u,m]=(0,s.useState)([]),[p,h]=(0,s.useState)({}),[f,x]=(0,s.useState)(!0),[v,g]=(0,s.useState)(null),[y,b]=(0,s.useState)(!1),w="admin"===r||"recruiter"===r,j=(0,s.useCallback)(async()=>{x(!0),t(null);try{var e,n,r,s;const t=await(0,zt.n)("/api/employer/v1/me"),o=null!==(e=null===t||void 0===t?void 0:t.account_id)&&void 0!==e?e:null===t||void 0===t||null===(n=t.organisation)||void 0===n?void 0:n.id,c=null!==(r=null===t||void 0===t||null===(s=t.member)||void 0===s?void 0:s.role)&&void 0!==r?r:null===t||void 0===t?void 0:t.role;if(a(o),i(c),!o)throw new Error("No organisation found for current user");if("admin"!==c&&"recruiter"!==c)return void x(!1);const[u,p,f,v]=await Promise.all([MP(o),(0,zt.n)("/api/employer/roles"),zP(o),qP(o).catch(()=>[])]);l(u),d((null===p||void 0===p?void 0:p.items)||(null===p||void 0===p?void 0:p.roles)||p||[]),m(f);const g={};for(const e of v||[]){const t=e.reviewer_user_id;t&&(g[t]||(g[t]={pending:0,in_review:0}),"pending"===e.status&&(g[t].pending+=1),"in_review"===e.status&&(g[t].in_review+=1))}h(g)}catch(mK){t((null===mK||void 0===mK?void 0:mK.message)||DP("admin.roster.bootstrap.fail"))}finally{x(!1)}},[]);(0,s.useEffect)(()=>{j()},[j]);const k=(0,s.useMemo)(()=>{const e=new Map;for(const t of c)e.set(t.id,t);return e},[c]),N=e=>{const t=u.find(t=>t.user_id===e);return t?"".concat(e.slice(0,8),"\u2026"):(null===e||void 0===e?void 0:e.slice(0,8))+"\u2026"},_=async e=>{g(e.assignment_id);try{await function(e){let{accountId:t,assignmentId:n,idempotencyKey:a}=e;return(0,zt.n)("".concat(jP,"/assignments/").concat(n,"/pause"),{method:"POST",headers:kP(a),body:{account_id:t}})}({accountId:n,assignmentId:e.assignment_id,idempotencyKey:WP()}),fy.success(DP("admin.roster.toast.pause.success")),j()}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||DP("admin.roster.toast.pause.fail"))}finally{g(null)}},D=async e=>{g(e.assignment_id);try{await function(e){let{accountId:t,assignmentId:n,idempotencyKey:a}=e;return(0,zt.n)("".concat(jP,"/assignments/").concat(n,"/resume"),{method:"POST",headers:kP(a),body:{account_id:t}})}({accountId:n,assignmentId:e.assignment_id,idempotencyKey:WP()}),fy.success(DP("admin.roster.toast.resume.success")),j()}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||DP("admin.roster.toast.resume.fail"))}finally{g(null)}},C=async e=>{if(window.confirm(DP("admin.roster.unassign.confirm"))){g(e.assignment_id);try{await function(e){let{accountId:t,assignmentId:n,idempotencyKey:a}=e;return(0,zt.n)("".concat(jP,"/assignments/").concat(n,"/unassign"),{method:"POST",headers:kP(a),body:{account_id:t}})}({accountId:n,assignmentId:e.assignment_id,idempotencyKey:WP()}),fy.success(DP("admin.roster.toast.unassign.success")),j()}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||DP("admin.roster.toast.unassign.fail"))}finally{g(null)}}};return f?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 p-6 text-sm text-muted-foreground","data-testid":"reviewer-roster-loading",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," ",DP("admin.roster.loading")]}):e?(0,Xt.jsx)("div",{className:"p-6","data-testid":"reviewer-roster-boot-error",children:(0,Xt.jsx)(Fy,{children:(0,Xt.jsx)(Py,{className:"p-4 text-sm text-rose-600",children:e})})}):w?(0,Xt.jsxs)("div",{className:"space-y-6 p-4 sm:p-6","data-testid":"reviewer-roster-page",children:[(0,Xt.jsxs)("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:DP("admin.roster.title")}),(0,Xt.jsx)("p",{className:"text-sm text-muted-foreground",children:DP("admin.roster.subtitle")})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm","data-testid":"reviewer-roster-refresh",onClick:j,children:[(0,Xt.jsx)(Kg,{className:"mr-1 h-3 w-3"})," ",DP("admin.roster.action.refresh")]}),(0,Xt.jsxs)(Rr,{size:"sm","data-testid":"reviewer-roster-assign-open",onClick:()=>b(!0),disabled:0===c.length||0===u.length,children:[(0,Xt.jsx)(Ow,{className:"mr-1 h-3 w-3"})," ",DP("admin.roster.action.assign")]})]})]}),(0,Xt.jsxs)(Fy,{children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base",children:[(0,Xt.jsx)(Tn,{className:"h-4 w-4"}),DP("admin.roster.title")]})}),(0,Xt.jsx)(Py,{children:0===o.length?(0,Xt.jsxs)("div",{"data-testid":"reviewer-roster-empty",className:"py-10 text-center space-y-3 max-w-md mx-auto",children:[(0,Xt.jsx)(Tn,{className:"mx-auto h-8 w-8 text-muted-foreground
2/70"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-foreground",children:DP("admin.roster.empty")}),(0,Xt.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:DP("admin.roster.empty.body")}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2 pt-1",children:[(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",size:"sm","data-testid":"reviewer-roster-empty-cta-members",children:(0,Xt.jsx)("a",{href:"/employer/members",children:DP("admin.roster.empty.cta.members")})}),(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",size:"sm","data-testid":"reviewer-roster-empty-cta-roles",children:(0,Xt.jsx)("a",{href:"/employer/roles",children:DP("admin.roster.empty.cta.roles")})}),c.length>0&&u.length>0&&(0,Xt.jsxs)(Rr,{size:"sm","data-testid":"reviewer-roster-empty-cta-assign",onClick:()=>b(!0),children:[(0,Xt.jsx)(Ow,{className:"mr-1 h-3 w-3"})," ",DP("admin.roster.action.assign")]})]})]}):(0,Xt.jsx)("div",{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm","data-testid":"reviewer-roster-table",children:[(0,Xt.jsx)("thead",{children:(0,Xt.jsxs)("tr",{className:"border-b text-left text-xs uppercase text-muted-foreground",children:[(0,Xt.jsx)("th",{className:"py-2 pr-3",children:DP("admin.roster.col.role")}),(0,Xt.jsx)("th",{className:"py-2 pr-3",children:DP("admin.roster.col.reviewer")}),(0,Xt.jsx)("th",{className:"py-2 pr-3",children:DP("admin.roster.col.status")}),(0,Xt.jsx)("th",{className:"py-2 pr-3 hidden md:table-cell",children:DP("admin.roster.col.workload")}),(0,Xt.jsx)("th",{className:"py-2 pr-3 hidden sm:table-cell",children:DP("admin.roster.col.created")}),(0,Xt.jsx)("th",{className:"py-2 pr-3",children:DP("admin.roster.col.actions")})]})}),(0,Xt.jsx)("tbody",{children:o.map(e=>{var t;const n=k.get(e.role_id),a="active"===e.assignment_status?"admin.roster.status.active":"paused"===e.assignment_status?"admin.roster.status.paused":"admin.roster.status.removed",r="active"===e.assignment_status?"default":"paused"===e.assignment_status?"secondary":"outline",s="removed"===e.assignment_status,i=p[e.reviewer_user_id]||{pending:0,in_review:0},o=0===i.pending&&0===i.in_review;return(0,Xt.jsxs)("tr",{className:"border-b last:border-0","data-testid":"reviewer-roster-row-".concat(e.assignment_id),children:[(0,Xt.jsxs)("td",{className:"py-2 pr-3",children:[(0,Xt.jsx)("div",{className:"font-medium",children:null!==(t=null===n||void 0===n?void 0:n.title)&&void 0!==t?t:e.role_id.slice(0,8)+"\u2026"}),(0,Xt.jsxs)("div",{className:"text-xs text-muted-foreground hidden sm:block",children:[e.role_id.slice(0,8),"\u2026"]})]}),(0,Xt.jsx)("td",{className:"py-2 pr-3 font-mono text-xs",children:N(e.reviewer_user_id)}),(0,Xt.jsx)("td",{className:"py-2 pr-3",children:(0,Xt.jsx)(Vw,{variant:r,children:DP(a)})}),(0,Xt.jsx)("td",{className:"py-2 pr-3 hidden md:table-cell text-xs","data-testid":"reviewer-roster-workload-".concat(e.assignment_id),children:s?(0,Xt.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):o?(0,Xt.jsx)("span",{className:"text-muted-foreground",children:DP("admin.roster.workload.none")}):(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-1",children:[i.pending>0&&(0,Xt.jsx)(Vw,{variant:"secondary","data-testid":"reviewer-roster-workload-pending-".concat(e.assignment_id),children:CP("admin.roster.workload.pending",{n:i.pending})}),i.in_review>0&&(0,Xt.jsx)(Vw,{variant:"default","data-testid":"reviewer-roster-workload-in-review-".concat(e.assignment_id),children:CP("admin.roster.workload.in_review",{n:i.in_review})})]})}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-xs text-muted-foreground hidden sm:table-cell",children:e.created_at?new Date(e.created_at).toLocaleString():"\u2014"}),(0,Xt.jsx)("td",{className:"py-2 pr-3",children:(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-2",children:["active"===e.assignment_status&&(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline","data-testid":"reviewer-roster-pause-".concat(e.assignment_id),disabled:v===e.assignment_id,onClick:()=>_(e),children:[(0,Xt.jsx)(kF,{className:"mr-1 h-3 w-3"})," ",DP("admin.roster.action.pause")]}),"paused"===e.assignment_status&&(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline","data-testid":"reviewer-roster-resume-".concat(e.assignment_id),disabled:v===e.assignment_id,onClick:()=>D(e),children:[(0,Xt.jsx)(jF,{className:"mr-1 h-3 w-3"})," ",DP("admin.roster.action.resume")]}),!s&&(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost","data-testid":"reviewer-roster-unassign-".concat(e.assignment_id),disabled:v===e.assignment_id,onClick:()=>C(e),children:[(0,Xt.jsx)(LP,{className:"mr-1 h-3 w-3"})," ",DP("admin.roster.action.unassign")]})]})})]},e.assignment_id)})})]})})})]}),(0,Xt.jsx)(GP,{open:y,onClose:()=>b(!1),onDone:j,accountId:n,roles:c,reviewers:u})]}):(0,Xt.jsx)("div",{className:"p-6","data-testid":"reviewer-roster-denied",children:(0,Xt.jsx)(Fy,{children:(0,Xt.jsx)(Py,{className:"p-4 text-sm text-muted-foreground",children:DP("admin.roster.access.denied")})})})}function GP(e){let{open:t,onClose:n,onDone:a,accountId:r,roles:i,reviewers:o}=e;
2const[l,c]=(0,s.useState)(""),[d,u]=(0,s.useState)(""),[m,p]=(0,s.useState)(!1);(0,s.useEffect)(()=>{t&&(c(""),u(""))},[t]);const h=0===i.length,f=0===o.length;return(0,Xt.jsx)(rg,{open:t,onOpenChange:e=>!e&&n(),children:(0,Xt.jsxs)(lg,{"data-testid":"reviewer-roster-assign-dialog",children:[(0,Xt.jsx)(cg,{children:(0,Xt.jsx)(ug,{children:DP("admin.assign.title")})}),(0,Xt.jsxs)("div",{className:"space-y-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-sm font-medium",children:DP("admin.assign.field.role")}),h?(0,Xt.jsx)("div",{className:"text-sm text-rose-600","data-testid":"reviewer-roster-no-roles",children:DP("admin.assign.no_roles")}):(0,Xt.jsxs)(Vv,{value:l,onValueChange:c,children:[(0,Xt.jsx)(Wv,{"data-testid":"reviewer-roster-role-select",children:(0,Xt.jsx)(qv,{placeholder:DP("admin.assign.placeholder.role")})}),(0,Xt.jsx)(Kv,{children:i.map(e=>(0,Xt.jsx)(Yv,{value:e.id,children:e.title||e.id},e.id))})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-sm font-medium",children:DP("admin.assign.field.reviewer")}),f?(0,Xt.jsx)("div",{className:"text-sm text-rose-600","data-testid":"reviewer-roster-no-reviewers",children:DP("admin.assign.no_reviewers")}):(0,Xt.jsxs)(Vv,{value:d,onValueChange:u,children:[(0,Xt.jsx)(Wv,{"data-testid":"reviewer-roster-reviewer-select",children:(0,Xt.jsx)(qv,{placeholder:DP("admin.assign.placeholder.reviewer")})}),(0,Xt.jsx)(Kv,{children:o.map(e=>(0,Xt.jsxs)(Yv,{value:e.user_id,children:[e.user_id.slice(0,8),"\u2026"]},e.user_id))})]}),(0,Xt.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:DP("admin.assign.help.reviewer")})]})]}),(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:n,disabled:m,children:DP("admin.assign.cancel")}),(0,Xt.jsxs)(Rr,{"data-testid":"reviewer-roster-assign-submit",onClick:async()=>{if(l&&d&&r){p(!0);try{await function(e){let{accountId:t,roleId:n,reviewerUserId:a,idempotencyKey:r}=e;return(0,zt.n)("".concat(jP,"/assignments"),{method:"POST",headers:kP(r),body:{account_id:t,role_id:n,reviewer_user_id:a}})}({accountId:r,roleId:l,reviewerUserId:d,idempotencyKey:WP()}),fy.success(DP("admin.assign.toast.success")),n(),a()}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||DP("admin.assign.toast.fail"))}finally{p(!1)}}},disabled:m||!l||!d||h||f,children:[m&&(0,Xt.jsx)(Lg,{className:"mr-1 h-3 w-3 animate-spin"})," ",DP("admin.assign.submit")]})]})]})})}async function KP(e){if(!e)throw new Error("rolesApi.getRole: id is required");const t=await(0,zt.n)("/api/employer/roles"),n=Array.isArray(t)?t:t&&Array.isArray(t.roles)?t.roles:null;return n&&n.find(t=>t.id===e)||null}async function YP(e){if(!e)throw new Error("rolesApi.getRoleCriteria: id is required");return(0,zt.n)("/api/employer/roles/".concat(encodeURIComponent(e),"/criteria"))}const JP={draft:"bg-ndor-surface-alt text-slate-200 border-slate-300",live:"bg-emerald-500/10 text-emerald-200 border-emerald-500/40",active:"bg-emerald-500/10 text-emerald-200 border-emerald-500/40",closing:"bg-amber-500/10 text-amber-200 border-amber-500/40",closed:"bg-rose-500/10 text-rose-200 border-rose-500/40",archived:"bg-ndor-surface-alt text-slate-200 border-zinc-300"},$P={draft:"Draft",live:"Active",active:"Active",closing:"Closing",closed:"Closed",archived:"Archived"};function XP(e){let{status:t,dataTestid:n}=e;const a=(t||"").toLowerCase(),r=JP[a]||"bg-ndor-surface-alt text-slate-300 border-slate-200",s=$P[a]||t||"Unknown";return(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-2","data-testid":n||"role-status-".concat(a),children:[(0,Xt.jsx)(Vw,{className:"".concat(r," border"),children:s}),"live"===a?(0,Xt.jsx)("span",{className:"text-xs text-slate-300","data-testid":"role-status-live-legacy-hint",children:"legacy"}):null]})}const QP=[{key:"draft",title:"Draft",match:e=>"draft"===e},{key:"active",title:"Active",match:e=>"active"===e||"live"===e},{key:"closing",title:"Closing",match:e=>"closing"===e},{key:"closed",title:"Closed",match:e=>"closed"===e},{key:"archived",title:"Archived",match:e=>"archived"===e}];function ZP(e){if(!e)return"\u2014";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"2-digit"})}
2function eO(){const[e,t]=(0,s.useState)(!0),[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)([]),[o,l]=(0,s.useState)({}),d=(0,s.useCallback)(e=>{l(t=>(0,c.A)((0,c.A)({},t),{},{[e]:!t[e]}))},[]),u=ke(),m=(0,s.useCallback)(async()=>{t(!0),a(null);try{const e=await async function(){const e=await(0,zt.n)("/api/employer/roles");return Array.isArray(e)?e:e&&Array.isArray(e.roles)?e.roles:[]}();i(Array.isArray(e)?e:[])}catch(mK){a((null===mK||void 0===mK?void 0:mK.message)||"Failed to load roles")}finally{t(!1)}},[]);(0,s.useEffect)(()=>{m()},[m]);const p=(0,s.useMemo)(()=>{const e=Object.fromEntries(QP.map(e=>[e.key,[]]));for(const t of r){const n=(t.status||"").toLowerCase(),a=QP.find(e=>e.match(n));a&&e[a.key].push(t)}for(const t of Object.keys(e))e[t].sort((e,t)=>{const n=new Date(e.updated_at||e.created_at||0).getTime();return new Date(t.updated_at||t.created_at||0).getTime()-n});return e},[r]),h=r.length;return e?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 p-8 text-sm text-slate-300","data-testid":"roles-list-loading",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}),"Loading roles\u2026"]}):n?(0,Xt.jsx)("div",{className:"p-6","data-testid":"roles-list-error",children:(0,Xt.jsx)(Fy,{children:(0,Xt.jsxs)(Py,{className:"flex items-start gap-3 p-6",children:[(0,Xt.jsx)(Oy,{className:"mt-0.5 h-5 w-5 text-rose-200"}),(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)("div",{className:"font-medium text-slate-100",children:"Couldn't load roles"}),(0,Xt.jsx)("div",{className:"text-sm text-slate-300",children:n}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:m,children:[(0,Xt.jsx)(Kg,{className:"mr-2 h-4 w-4"}),"Retry"]})]})]})})}):0===h?(0,Xt.jsx)("div",{className:"p-6","data-testid":"roles-list-empty",children:(0,Xt.jsxs)(Fy,{children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2",children:[(0,Xt.jsx)(kn,{className:"h-5 w-5"}),"No roles yet"]})}),(0,Xt.jsxs)(Py,{className:"space-y-3 text-sm text-slate-300",children:[(0,Xt.jsxs)("p",{children:["Roles describe the positions you're hiring for. Each role moves through a structured lifecycle: ",(0,Xt.jsx)("em",{children:"draft"})," \u2192",(0,Xt.jsx)("em",{children:" active"})," \u2192 ",(0,Xt.jsx)("em",{children:"closing"})," \u2192 ",(0,Xt.jsx)("em",{children:"closed"})," \u2192",(0,Xt.jsx)("em",{children:" archived"}),". You can refine criteria at any point while a role is still in draft."]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted",children:["New to NDORFlow?"," ",(0,Xt.jsx)(Et,{to:"/employer/help/workflow",className:"underline hover:text-ndor-ink","data-testid":"roles-list-empty-workflow-link",children:"Read the workflow primer"})," ","first \u2014 it explains how each role's evaluation framework shapes everything downstream."]}),(0,Xt.jsxs)(Rr,{onClick:()=>u("/employer/roles/new"),"data-testid":"roles-list-create-cta",children:[(0,Xt.jsx)(Ow,{className:"mr-2 h-4 w-4"}),"Create role"]})]})]})}):(0,Xt.jsxs)("div",{className:"space-y-6 p-6","data-testid":"roles-list-page",children:[(0,Xt.jsxs)("header",{className:"flex flex-row items-center justify-between gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold text-ndor-ink",children:"Roles"}),(0,Xt.jsxs)("p",{className:"text-sm text-slate-300",children:[h," role",1===h?"":"s"," in your account"]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:m,"data-testid":"roles-list-refresh",children:[(0,Xt.jsx)(Kg,{className:"mr-2 h-4 w-4"}),"Refresh"]}),(0,Xt.jsxs)(Rr,{onClick:()=>u("/employer/roles/new"),"data-testid":"roles-list-new-role",children:[(0,Xt.jsx)(Ow,{className:"mr-2 h-4 w-4"}),"New role"]})]})]}),QP.map(e=>{const t=p[e.key];if(!t||0===t.length)return null;const n=!!o[e.key],a=t.length>5,r=a&&!n?t.slice(0,5):t,s=t.length-r.length;return(0,Xt.jsxs)("section",{className:"space-y-2","data-testid":"roles-list-pillar-".concat(e.key),children:[(0,Xt.jsxs)("h2",{className:"text-sm font-medium uppercase tracking-wide text-slate-300",children:[e.title," ",(0,Xt.jsxs)("span",{className:"text-slate-300",children:["(",t.length,")"]})]}),(0,Xt.jsx)(Fy,{children:(0,Xt.jsxs)(Py,{className:"p-0",children:[(0,Xt.jsxs)(zF,{children:[(0,Xt.jsx)(UF,{children:(0,Xt.jsxs)(qF,{children:[(0,Xt.jsx)(WF,{children:"Title"}),(0,Xt.jsx)(WF,{children:"Status"}),(0,Xt.jsx)(WF,{children:"Published"}),(0,Xt.jsx)(WF,{children:"Last updated"})]})}),(0,Xt.jsx)(VF,{children:r.map(e=>(0,Xt.jsxs)(qF,{className:"cursor-pointer hover:bg-ndor-surface-alt",onClick:()=>u("/employer/roles/".concat(e.id)),"data-testid":"roles-list-row-".concat(e.id),children:[(0,Xt.jsx)(HF,{className:"font-medium",children:(0,Xt.jsx)(Et,{to:"/employer/roles/".concat(e.id),className:"text-slate-100 hover:underline",children:e.title||"(untitled)"})}),(0,Xt.jsx)(HF,{children:(0,Xt.jsx)(XP,{status:e.status})}),(0,Xt.jsx)(HF,{className:"text-sm text-slate-300",children:ZP(e.published_at)}),(0,Xt.jsx)(HF,{className:"text-sm text-slate-300",children:ZP(e.updated_at)})]},e.id))})]}),a&&(0,Xt.jsxs)("div",{className:"border-t border-ndor-edge px-4 py-2 flex items-center justify-between","data-testid":"roles-list-pillar-".concat(e.key,"-overflow"),children:[(0,Xt.jsx)("span",{className:"text-xs text-ndor-ink-muted",children:n?"Showing all ".concat(t.length," roles in ").concat(e.title,"."):"Showing ".concat(5," of ").concat(t.length," \xb7 ").concat(s," more in ").concat(e.title,".")}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",onClick:()=>
2d(e.key),className:"text-xs","data-testid":"roles-list-pillar-".concat(e.key,"-toggle"),"aria-expanded":n,children:n?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Tv,{className:"mr-1 h-3.5 w-3.5"}),"Show less"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Gn,{className:"mr-1 h-3.5 w-3.5"}),"Show more"]})})]})]})})]},e.key)})]})}function tO(){return(0,Xt.jsx)(eO,{})}const nO=wn("pen-line",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);function aO(e){let{open:t,status:n,onCancel:a,onConfirm:r,pending:s,error:i}=e;const o="closing"===n,l=o?"Finalise close (hard-close)?":"Soft-close this role?",c=o?"Hard-close finalises the role to `closed` immediately. Active matches stop. You can archive it later, but a closed role cannot be re-opened.":"Soft-close pauses new matching but keeps the row visible while in-flight work completes. You can hard-close it later, or it will finalise to `closed` automatically.",d=o?"Close now":"Close role";return(0,Xt.jsx)(rg,{open:Boolean(t),onOpenChange:e=>{e||s||a()},children:(0,Xt.jsxs)(lg,{"data-testid":"close-confirm-modal","aria-busy":s?"true":"false",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"close-confirm-title",children:l}),(0,Xt.jsx)(mg,{"data-testid":"close-confirm-copy",children:c})]}),i?(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-200","data-testid":"close-confirm-error",children:[(0,Xt.jsx)(mb,{className:"mt-0.5 h-4 w-4"}),(0,Xt.jsx)("div",{children:i})]}):null,(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:a,disabled:s,"data-testid":"close-confirm-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{onClick:()=>r(o),disabled:s,"data-testid":"close-confirm-go",children:s?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}),"Closing\u2026"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Gg,{className:"mr-2 h-4 w-4"}),d]})})]})]})})}function rO(e){let{open:t,status:n,onCancel:a,onConfirm:r,pending:s,error:i}=e;const o="draft"===n,l=o?"Discard this draft?":"Archive this closed role?",c=o?"Archiving a draft permanently discards it. There is no un-archive.":"Archiving a closed role is permanent and removes it from the active list. There is no un-archive.",d=o?"Discard draft":"Archive role",u=o?pb:Vn;return(0,Xt.jsx)(rg,{open:Boolean(t),onOpenChange:e=>{e||s||a()},children:(0,Xt.jsxs)(lg,{"data-testid":"archive-confirm-modal","aria-busy":s?"true":"false",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"archive-confirm-title",children:l}),(0,Xt.jsx)(mg,{"data-testid":"archive-confirm-copy",children:c})]}),i?(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-200","data-testid":"archive-confirm-error",children:[(0,Xt.jsx)(mb,{className:"mt-0.5 h-4 w-4"}),(0,Xt.jsx)("div",{children:i})]}):null,(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:a,disabled:s,"data-testid":"archive-confirm-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{variant:o?"destructive":"default",onClick:r,disabled:s,"data-testid":"archive-confirm-go",children:s?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}),"Archiving\u2026"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(u,{className:"mr-2 h-4 w-4"}),d]})})]})]})})}const sO={seniority:25,domain_alignment:30,evidence_strength:25,location:10,risk:10},iO={seniority:"Seniority",domain_alignment:"Domain",evidence_strength:"Evidence",location:"Location",risk:"Risk"};function oO(e){const t={shortlist:{cls:"text-emerald-200 bg-emerald-500/15 border-emerald-500/40",label:"Shortlist",icon:Og},review:{cls:"text-amber-200 bg-amber-500/15 border-amber-500/40",label:"Review",icon:Oy},reject:{cls:"text-rose-200 bg-rose-500/15 border-rose-500/40",label:"Reject",icon:Gg}}[e]||{cls:"text-slate-200 bg-slate-500/15 border-slate-500/40",label:"\u2014",icon:Oy},n=t.icon;return(0,Xt.jsxs)("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-md border ".concat(t.cls),"data-testid":"candidate-verdict-header",children:[(0,Xt.jsx)(n,{className:"h-4 w-4"}),(0,Xt.jsx)("span",{className:"text-xs uppercase tracking-wider font-semibold",children:t.label})]})}function lO(e){const t=Math.max(0,Math.min(100,Number(e)||0)),n=t>=75?"bg-emerald-500":t>=45?"bg-amber-500":"bg-rose-500";return(0,Xt.jsxs)("div",{className:"flex items-center gap-3","data-testid":"candidate-verdict-fit-bar",children:[(0,Xt.jsx)("div",{className:"flex-1 h-2 rounded bg-ndor-bg/60 overflow-hidden",children:(0,Xt.jsx)("div",{className:"h-full ".concat(n),style:{width:"".concat(t,"%")}})}),(0,Xt.jsx)("span",{className:"text-sm font-semibold text-ndor-ink",children:t}),(0,Xt.jsx)("span",{className:"text-xs text-slate-300",children:"/ 100"})]})}function cO(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"emerald";if(!Array.isArray(e)||0===e.length)return(0,Xt.jsx)("p",{className:"text-xs text-slate-300",children:"\u2014"});const n="amber"===t?"text-amber-300":"text-emerald-300";return(0,Xt.jsx)("ul",{className:"space-y-1.5 text-sm text-slate-100",children:e.slice(0,6).map((e,t)=>(0,Xt.jsxs)("li",{className:"leading-relaxed flex gap-2",children:[(0,Xt.jsx)("span",{className:"".concat(n," shrink-0"),"aria-hidden":"true",children:"\u2022"}),(0,Xt.jsx)("span",{children:String(e).slice(0,240)})]},t))})}function dO(e){if(!e||"object"!==typeof e)return null;const t=Object.entries(e);if(0===t.length)return null;const n=t.some(e=>{let[,t]=e;return!0===t||t&&"object"===typeof t&&t.triggered});return(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":"candidate-verdict-dealbreakers","data-any-triggered":n?"true":"false",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-200 font-medium",children:"Dealbreakers"}),(0,Xt.jsx)("div",{className:"space-y-1.5",children:t.map(e=>{let[t,n]=e;const a=!0===n||n&&"object"===typeof n&&!0===n.triggered,r=n&&"object"===typeof n&&(n.basis||n.reason)||"";return(0,Xt.jsxs)("div",{className:"text-xs px-2.5 py-1.5 rounded border leading-relaxed ".concat(a?"border-rose-500/40 bg-rose-500/10 text-rose-200":"border-emerald-500/40 bg-emerald-500/10 text-emerald-200"),children:[(0,Xt.jsxs)("span",{className:"font-medium",children:[a?"\u2717":"\u2713"," ",t]}),r?(0,Xt.jsxs)("span",{className:"ml-1 opacity-90",children:[" \xb7 ",String(r).slice(0,200)]}):null]},t)})})]})}function uO(e,t,n){const a=(e||"").toLowerCase();if(!a)return"partial";const r=Array.from(new Set(a.split(/[^a-z0-9]+/i).filter(e=>e.length>=4)));if(0===r.length)return"partial";const s=e=>r.some(t=>e.toLowerCase().includes(t)),i=t.some(s),o=n.some(s);return i&&!o?"met":o&&!i?"missing":"partial"}function mO(e){let{text:t,status:n}=e;const a={met:{cls:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200",Icon:Og},partial:{cls:"border-amber-500/40 bg-amber-500/10 text-amber-200",Icon:ep},missing:{cls:"border-rose-500/40 bg-rose-500/10 text-rose-200",Icon:CC}},{cls:r,Icon:s}=a[n]||a.partial;return(0,Xt.jsxs)("div",{className:"flex items-start gap-2 text-xs px-2.5 py-2 rounded border ".concat(r),"data-testid":"candidate-verdict-criterion","data-match":n,children:[(0,Xt.jsx)(s,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),(0,Xt.jsx)("span",{className:"leading-relaxed",children:t})]})}function pO(e){let{name:t,score:n,weight:a}=e;const r=Math.max(0,Math.min(100,Number(n)||0)),s=r>=75?"bg-emerald-500":r>=45?"bg-amber-500":"bg-rose-500";return(0,Xt.jsxs)("div",{className:"grid grid-cols-[90px_1fr_44px_42px] gap-3 items-center text-xs",children:[(0,Xt.jsx)("span",{className:"text-slate-200",children:iO[t]||t}),(0,Xt.jsx)("div",{className:"h-2 rounded bg-ndor-bg/60 overflow-hidden",children:(0,Xt.jsx)("div",{className:"h-full ".concat(s),style:{width:"".concat(r,"%")}})}),(0,Xt.jsx)("span",{className:"text-right text-ndor-ink font-semibold",children:r}),(0,Xt.jsxs)("span",{className:"text-right text-xs text-slate-300",children:["\xb7",a,"%"]})]})}function hO(e,t){const n=Array.isArray(e)&&e.length>0||Array.isArray(t)&&t.length>0,a=(e,t)=>(0,Xt.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded border ".concat(t?"border-emerald-500/40 bg-emerald-500/10 text-emerald-200":"border-slate-500/40 bg-slate-500/10 text-slate-300"),children:[e," ",t?"\u2713":"\u2014"]},e);return(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":"candidate-verdict-dossier-evidence",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-200 font-medium",children:"Evidence used from dossier"}),(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[a("CV",n),a("Cover Letter",!1),a("Supporting Statement",!1),a("Notes",!1)]})]})}function fO(e){var t,n,a;let{candidateId:r,open:i,role:o=null}=e;
2const[l,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[p,h]=(0,s.useState)(null),f=(0,s.useCallback)(async()=>{m(!0),h(null);try{const e=await(0,zt.n)("/api/employer/v1/candidates/".concat(r,"/evaluation"));d((null===e||void 0===e?void 0:e.item)||null)}catch(pK){h((null===pK||void 0===pK?void 0:pK.message)||"Could not load evaluation details.")}finally{m(!1)}},[r]);(0,s.useEffect)(()=>{!i||l||u||p||f()},[i,l,u,p,f]);const x=(null===l||void 0===l?void 0:l.criteria_snapshot)||(null===l||void 0===l||null===(t=l.raw_runner_payload)||void 0===t?void 0:t.criteria_snapshot)||(null!==o&&void 0!==o&&o.structured_definition_json?{title:o.title,description:o.structured_definition_json.description,required_criteria:o.structured_definition_json.required_criteria||o.structured_definition_json.must_have||[],preferred_criteria:o.structured_definition_json.preferred_criteria||o.structured_definition_json.nice_to_have||[],weighted_dimensions:o.structured_definition_json.weighted_dimensions}:null),v=(null===l||void 0===l?void 0:l.dimension_scores)||(null===l||void 0===l||null===(n=l.raw_runner_payload)||void 0===n?void 0:n.dimension_scores)||{},g=(null===l||void 0===l?void 0:l.evidence_map)||(null===l||void 0===l||null===(a=l.raw_runner_payload)||void 0===a?void 0:a.evidence_map)||{},y=(0,s.useMemo)(()=>{const e=[];return Object.values(v).forEach(t=>{const n=null===t||void 0===t?void 0:t.positive_signals;Array.isArray(n)&&n.forEach(t=>e.push(String(t)))}),e},[v]),b=(0,s.useMemo)(()=>{const e=[];return Object.values(v).forEach(t=>{const n=null===t||void 0===t?void 0:t.weaknesses;Array.isArray(n)&&n.forEach(t=>e.push(String(t)))}),e},[v]),w=(0,s.useMemo)(()=>{const e=null===x||void 0===x?void 0:x.weighted_dimensions;if(!e||"object"!==typeof e)return{values:sO,isCustom:!1};const t=(0,c.A)({},sO);let n=!1;for(const a of Object.keys(sO)){const r=Number(e[a]);Number.isFinite(r)&&r>=0&&r<=100&&(t[a]=Math.round(r),Math.round(r)!==sO[a]&&(n=!0))}return{values:t,isCustom:n}},[x]);if(!i)return null;if(u)return(0,Xt.jsxs)("div",{className:"flex items-center gap-2 py-4 text-xs text-slate-200","data-testid":"candidate-verdict-loading",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin"}),"Loading evaluation details\u2026"]});if(p)return(0,Xt.jsxs)("div",{className:"space-y-2 py-3","data-testid":"candidate-verdict-error",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2 text-sm text-rose-300",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 mt-0.5"}),(0,Xt.jsx)("span",{children:p})]}),(0,Xt.jsx)("button",{type:"button",onClick:f,className:"text-xs text-slate-200 hover:text-ndor-ink underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded",children:"Retry"})]});if(!l)return(0,Xt.jsx)("p",{className:"text-xs text-slate-300 py-3","data-testid":"candidate-verdict-empty",children:"No evaluation details available."});const j=Array.isArray(null===x||void 0===x?void 0:x.required_criteria)?x.required_criteria.slice(0,8):[];return(0,Xt.jsxs)("div",{className:"mt-4 space-y-5 rounded-lg border border-ndor-edge bg-ndor-bg/50 p-5","data-testid":"candidate-verdict-explainer","data-candidate-id":r,children:[(0,Xt.jsxs)("header",{className:"space-y-1.5 pb-4 border-b border-ndor-edge","data-testid":"candidate-verdict-role-header",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-200 font-medium",children:"Evaluated against this role"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink font-medium",children:(null===x||void 0===x?void 0:x.title)||(null===o||void 0===o?void 0:o.title)||"\u2014"}),null!==x&&void 0!==x&&x.description?(0,Xt.jsx)("p",{className:"text-xs text-slate-200 leading-relaxed",children:String(x.description).slice(0,220)}):null]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[oO(l.governance_verdict),null!=l.confidence_low&&null!=l.confidence_high&&(0,Xt.jsxs)("span",{className:"text-xs text-slate-200",children:["Confidence ",l.confidence_low,"\u2013",l.confidence_high]})]}),null!=l.overall_fit&&lO(l.overall_fit),j.length>0&&(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":"candidate-verdict-criteria-gri
2d",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-200 font-medium",children:"Required criteria match"}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:j.map((e,t)=>(0,Xt.jsx)(mO,{text:String(e).slice(0,120),status:uO(String(e),y,b)},t))}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300 leading-relaxed",children:"Match status derived from positive signals and weaknesses recorded by the evaluator. Heuristic indicator only."})]}),Object.keys(v).length>0&&(0,Xt.jsxs)("div",{className:"space-y-2.5","data-testid":"candidate-verdict-dimensions",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-200 font-medium",children:"Dimension breakdown"}),(0,Xt.jsx)("div",{className:"space-y-2",children:Object.keys(sO).map(e=>{var t,n;const a=v[e];if(!a)return null;const r="object"===typeof a?null!==(t=null!==(n=a.score)&&void 0!==n?n:a.value)&&void 0!==t?t:0:Number(a);return(0,Xt.jsx)(pO,{name:e,score:r,weight:w.values[e]},e)})})]}),g&&"object"===typeof g&&Object.keys(g).length>0&&(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":"candidate-verdict-evidence-map",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-200 font-medium",children:"Evidence map"}),(0,Xt.jsx)("ul",{className:"space-y-1.5 text-sm text-slate-100",children:Object.entries(g).slice(0,6).map(e=>{let[t,n]=e;return(0,Xt.jsxs)("li",{className:"leading-relaxed",children:[(0,Xt.jsx)("span",{className:"text-xs uppercase tracking-wider text-slate-300 mr-2",children:iO[t]||t}),(0,Xt.jsx)("span",{className:"text-xs text-emerald-300 mr-1.5",children:"[CV]"}),(0,Xt.jsx)("span",{children:"string"===typeof n?n.slice(0,240):JSON.stringify(n).slice(0,240)})]},t)})})]}),l.verdict_reason&&(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-200 font-medium",children:"Verdict reason"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink leading-relaxed whitespace-pre-line",children:String(l.verdict_reason).slice(0,600)})]}),dO(l.dealbreaker_flags),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-5",children:[(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-emerald-300 font-medium",children:"Strengths"}),cO(l.strengths,"emerald")]}),(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-amber-300 font-medium",children:"Gaps"}),cO(l.gaps,"amber")]})]}),hO(l.strengths,l.gaps),(0,Xt.jsxs)("div",{className:"space-y-1.5 pt-4 border-t border-ndor-edge",children:[(0,Xt.jsxs)("p",{className:"text-xs text-slate-200 leading-relaxed","data-testid":"candidate-verdict-legend",children:["Verdict rule:\xa0",(0,Xt.jsx)("span",{className:"text-emerald-300 font-medium",children:"\u226575 Shortlist"})," \xb7\xa0",(0,Xt.jsx)("span",{className:"text-amber-300 font-medium",children:"45\u201374 Review"})," \xb7\xa0",(0,Xt.jsx)("span",{className:"text-rose-300 font-medium",children:"<45 Reject"})," \xb7\xa0 any dealbreaker triggered \u2192 Reject."]}),(0,Xt.jsxs)("p",{className:"text-xs text-slate-300 leading-relaxed","data-testid":"candidate-verdict-weighting-footnote",children:["Weighting applied:\xa0",Object.entries(w.values).map((e,t,n)=>{let[a,r]=e;return(0,Xt.jsxs)("span",{children:[iO[a]," ",r,t<n.length-1?" \xb7 ":""]},a)}),"\xa0(",w.isCustom?"custom for this role":"NDOR default",")."]}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300 leading-relaxed","data-testid":"candidate-verdict-doctrine-footnote",children:"Numeric scores are anchored in CV / resume evidence. Cover letters, supporting statements and notes inside the dossier strengthen interpretation but do not override CV facts."})]})]})}function xO(e){let{label:t,count:n,tone:a,testId:r}=e;const s={ink:"text-ndor-ink",emerald:"text-emerald-300",amber:"text-amber-300",rose:"text-rose-300",slate:"text-ndor-ink-secondary"},i=s[a]||s.slate;return(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-secondary","data-testid":r,children:[(0,Xt.jsx)("span",{className:"font-semibold ".concat(i),"data-testid":"".concat(r,"-count"),children:n})," ",t]})}function vO(e){let{title:t,testId:n,children:a,extra:r=null}=e;return(0,Xt.jsxs)("div",{className:"flex items-baseline flex-wrap gap-x-4 gap-y-1","data-testid":n,children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-secondary font-medium shrink-0 w-40",children:t}),(0,Xt.jsx)("div",{className:"flex items-baseline flex-wrap gap-x-4 gap-y-1",children:a}),r]})}function gO(e){var t,n,a;let{items:r,reconciliation:i=null,reviewerActive:o=null,reviewerPending:l=null,reviewerInReview:c=null}=e;const d=(0,s.useMemo)(()=>function(e){const t={shortlisted:0,review:0,rejected:0,awaiting:0};if(!Array.isArray(e))return t;for(const n of e){if(null!==n&&void 0!==n&&n.erased_at)continue;if("complete"!==(null===n||void 0===n?void 0:n.evaluation_status))continue;const e=n.governance_status;"shortlisted"===e?t.shortlisted+=1:"review"===e?t.review+=1:"rejected"===e?t.rejected+=1:t.awaiting+=1}return t}(r),[r]);if(!i||0===(null!==(t=i.n_all)&&void 0!==t?t:0))return null;const u=i;return(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-workflow-summary",children:(0,Xt.jsxs)(Py,{className:"px-5 py-4 sm:px-6 sm:py-5 space-y-3",children:[(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-secondary font-medium",children:"Workflow summary"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed",children:"Progressive workflow: Uploaded \u2192 Integrity \u2192 Eligible \u2192 Assessed \u2192 NDOR recommendation \u2192 Employer decision. Each strip below shows the authoritative count for its own dimension."})]}),(0,Xt.jsx)(vO,{title:"Corpus",testId:"role-workflow-summary-corpus",children:(0,Xt.jsx)(xO,{label:"candidate".concat(1===u.n_all?"":"s"," uploaded"),count:u.n_all,tone:"ink",testId:"role-workflow-corpus-uploaded"})}),(0,Xt.jsxs)(vO,{title:"Admissibility",testId:"role-workflow-summary-admissibility",children:[(0,Xt.jsx)(xO,{label:"awaiting integrity",count:u.n_awaiting_integrity,tone:"amber",testId:"role-workflow-admissibility-awaiting"}),(0,Xt.jsx)(xO,{label:"excluded",count:u.n_excluded,tone:"rose",testId:"role-workflow-admissibility-excluded"}),(0,Xt.jsx)(xO,{label:"eligible",count:u.n_eligible,tone:"emerald",testId:"role-workflow-admissibility-eligible"})]}),(0,Xt.jsxs)(vO,{title:"Evaluation",testId:"role-workflow-summary-evaluation",children:[(0,Xt.jsx)(xO,{label:"evaluated",count:u.n_completed_auth,tone:"ink",testId:"role-workflow-evaluation-completed"}),(0,Xt.jsx)(xO,{label:"eligible awaiting evaluation",count:Math.max(0,(null!==(n=u.n_eligible)&&void 0!==n?n:0)-(null!==(a=u.n_completed_auth)&&void 0!==a?a:0)),tone:"slate",testId:"role-workflow-evaluation-pending"})]}),(0,Xt.jsxs)(vO,{title:"NDOR recommendations",testId:"role-workflow-summary-ndor-recs",children:[(0,Xt.jsx)(xO,{label:"shortlist",count:u.n_shortlist,tone:"emerald",testId:"role-workflow-ndor-shortlist"}),(0,Xt.jsx)(xO,{label:"review",count:u.n_review,tone:"amber",testId:"role-workflow-ndor-review"}),(0,Xt.jsx)(xO,{label:"reject",count:u.n_reject,tone:"rose",testId:"role-workflow-ndor-reject"})]}),(0,Xt.jsxs)(vO,{title:"Employer decisions",testId:"role-workflow-summary-employer-decisions",children:[(0,Xt.jsx)(xO,{label:"shortlisted",count:d.shortlisted,tone:"emerald",testId:"role-workflow-decision-shortlisted"}),(0,Xt.jsx)(xO,{label:"under review",count:d.review,tone:"amber",testId:"role-workflow-decision-review"}),(0,Xt.jsx)(xO,{label:"rejected",count:d.rejected,tone:"rose",testId:"role-workflow-decision-rejected"}),(0,Xt.jsx)(xO,{label:"awaiting decision",count:d.awaiting,tone:"slate",testId:"role-workflow-decision-awaiting"})]}),!1===u.invariant_ok&&(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-100","data-testid":"role-workflow-invariant-warning",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsx)("p",{className:"font-medium",children:"Reconciliation invariant violation."}),(0,Xt.jsxs)("ul",{className:"list-disc list-inside space-y-0.5 text-amber-100/90",children:[!u.partition_admissibility_ok&&(0,Xt.jsxs)("li",{"data-testid":"role-workflow-invariant-admissibility",children:["Admissibility partition mismatch: ",u.n_awaiting_integrity," + ",u.n_excluded," + ",u.n_eligible," \u2260 ",u.n_all,"."]}),!u.partition_ndor_ok&&(0,Xt.jsxs)("li",{"data-testid":"role-workflow-invariant-ndor-partition",children:["NDOR partition mismatch: ",u.n_shortlist," + ",u.n_review," + ",u.n_reject," + ",u.n_unclassified_invali
2d," \u2260 ",u.n_completed_auth,"."]}),u.n_unclassified_invalid>0&&(0,Xt.jsxs)("li",{"data-testid":"role-workflow-invariant-unclassified",children:[u.n_unclassified_invalid," completed evaluation",1===u.n_unclassified_invalid?"":"s"," missing a valid recommendation \u2014 see backend operator log."]}),u.n_mirror_authority_mismatch>0&&(0,Xt.jsxs)("li",{"data-testid":"role-workflow-invariant-mirror",children:[u.n_mirror_authority_mismatch," candidate",1===u.n_mirror_authority_mismatch?"":"s"," where the",(0,Xt.jsx)("code",{className:"mx-1 px-1 rounded bg-amber-500/20 font-mono",children:"evaluation_status"}),"mirror disagrees with the authoritative",(0,Xt.jsx)("code",{className:"mx-1 px-1 rounded bg-amber-500/20 font-mono",children:"emp_evaluations"}),"record. This is a data-integrity signal, not a UI bug."]})]})]})]}),null!==o||null!==l||null!==c?(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 pt-1 text-xs text-ndor-ink-secondary border-t border-ndor-edge","data-testid":"role-workflow-reviewer-strip",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,Xt.jsx)(Tn,{className:"h-3.5 w-3.5 opacity-70"}),(0,Xt.jsxs)("span",{children:["Reviewer coverage \u2014"," ",(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-ndor-edge text-ndor-ink-secondary text-[10px] mr-1","data-testid":"role-workflow-reviewer-active",children:[null!==o&&void 0!==o?o:0," active"]}),(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-ndor-edge text-ndor-ink-secondary text-[10px] mr-1","data-testid":"role-workflow-reviewer-pending",children:[null!==l&&void 0!==l?l:0," pending"]}),(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-ndor-edge text-ndor-ink-secondary text-[10px]","data-testid":"role-workflow-reviewer-inreview",children:[null!==c&&void 0!==c?c:0," in review"]})]})]}),0===o&&d.review>0?(0,Xt.jsx)("span",{className:"text-amber-300/90 text-[11px]","data-testid":"role-workflow-reviewer-warning",children:"No reviewers assigned \u2014 review verdicts will not progress."}):null]}):null]})})}const yO=wn("file-down",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]),bO={draft:{label:"Draft",tone:"amber"},finalised:{label:"Finalised",tone:"emerald"},exported:{label:"Exported",tone:"emerald"},revoked:{label:"Revoked",tone:"rose"}};function wO(e){let{value:t}=e;return t?(0,Xt.jsxs)("code",{className:"font-mono text-[10px] text-ndor-ink-muted",children:[String(t).slice(0,8),"\u2026"]}):(0,Xt.jsx)("span",{children:"\u2014"})}function jO(e){let{status:t}=e;const n=bO[t]||{label:t,tone:"slate"},a={emerald:"border-emerald-500/40 bg-emerald-500/10 text-emerald-300",amber:"border-amber-500/40 bg-amber-500/10 text-amber-300",rose:"border-rose-500/40 bg-rose-500/10 text-rose-300",slate:"border-ndor-edge text-ndor-ink-secondary"}[n.tone];return(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] uppercase tracking-[0.14em] ".concat(a),"data-testid":"governance-pack-status-".concat(t),children:n.label})}function kO(e){let{roleId:t,items:n}=e;const a=(0,s.useMemo)(()=>Array.isArray(n)?n.filter(e=>"complete"===e.evaluation_status&&("shortlisted"===e.governance_status||"review"===e.governance_status)&&!e.erased_at):[],[n]),r=a.filter(e=>"shortlisted"===e.governance_status).length,i=a.filter(e=>"review"===e.governance_status).length,[o,l]=(0,s.useState)([]),[d,u]=(0,s.useState)(!0),[m,p]=(0,s.useState)(null),[h,f]=(0,s.useState)(!1),[x,v]=(0,s.useState)({}),[g,y]=(0,s.useState)(!1),[b,w]=(0,s.useState)({}),j=(0,s.useCallback)(async()=>{u(!0),p(null);try{const e=await(0,zt.n)("/api/employer/v1/roles/".concat(t,"/governance-packs"));l(Array.isArray(null===e||void 0===e?void 0:e.items)?e.items:[]),f(Boolean(null===e||void 0===e?void 0:e.migration_pending))}catch(pK){p((null===pK||void 0===pK?void 0:pK.message)||"Failed to load governance packs.")}finally{u(!1)}},[t]);(0,s.useEffect)(()=>{j()},[j]);const k=Object.values(x).filter(Boolean).length,N=(0,s.useCallback)(async()=>{const e=Object.entries(x).filter(e=>{let[,t]=e;return t}).map(e=>{let[t]=e;return t});if(0!==e.length){y(!0);try{await(0,zt.n)("/api/employer/v1/roles/".concat(t,"/governance-packs"),{method:"POST",body:JSON.stringify({candidate_ids:e,kind:"role_governance"})}),fy.success("Draft created with ".concat(e.length," candidate").
2concat(1===e.length?"":"s",".")),v({}),await j()}catch(pK){var n;const t=(null===pK||void 0===pK||null===(n=pK.data)||void 0===n?void 0:n.detail)||{},a=t.code||"DRAFT_FAILED";"GOVERNANCE_PACK_MIGRATION_PENDING"===a?(f(!0),fy.error("Governance pack storage migration pending \u2014 see admin hint below.")):fy.error("".concat(a,": ").concat(t.message||(null===pK||void 0===pK?void 0:pK.message)||"Draft failed."))}finally{y(!1)}}else fy.error("Select at least one candidate.")},[x,t,j]),_=(0,s.useCallback)(async e=>{w(t=>(0,c.A)((0,c.A)({},t),{},{[e]:"finalise"}));try{const t=await(0,zt.n)("/api/employer/v1/governance-packs/".concat(e,"/finalise"),{method:"POST"});!1===(null===t||void 0===t?void 0:t.changed)?fy.message("Pack was already finalised."):fy.success("Pack finalised \u2014 content is now immutable."),await j()}catch(pK){var t;const n=(null===pK||void 0===pK||null===(t=pK.data)||void 0===t?void 0:t.detail)||{},a=n.code||"FINALISE_FAILED";"PACK_BUDGET_EXHAUSTED"===a?fy.error("Governance pack allowance exhausted for this period. Review your plan in Billing."):fy.error("".concat(a,": ").concat(n.message||n.detail||(null===pK||void 0===pK?void 0:pK.message)||"Finalise failed."))}finally{w(t=>{const n=(0,c.A)({},t);return delete n[e],n})}},[j]),D=(0,s.useCallback)(async e=>{w(t=>(0,c.A)((0,c.A)({},t),{},{[e]:"export"}));try{const n="https://app.ndorflow.app",{data:{session:a}}=await Mt.supabase.auth.getSession(),r=(null===a||void 0===a?void 0:a.access_token)||"";if(!r)return void fy.error("Your session has expired. Please sign in again.");const s=await fetch("".concat(n,"/api/employer/v1/governance-packs/").concat(e,"/export"),{headers:{Authorization:"Bearer ".concat(r)}});if(!s.ok){const e=await s.text();throw new Error(e||"Export failed (".concat(s.status,")."))}const i=await s.blob(),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="governance-pack-".concat(e.slice(0,8),".pdf"),document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o);try{(0,kk.Di)()}catch(t){}fy.success("Governance pack downloaded."),await j()}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Export failed.")}finally{w(t=>{const n=(0,c.A)({},t);return delete n[e],n})}},[j]);return 0!==a.length||0!==o.length||d?(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"governance-pack-panel",children:(0,Xt.jsxs)(Py,{className:"px-5 py-4 sm:px-6 sm:py-5 space-y-5",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-3",children:[(0,Xt.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-md border border-ndor-edge bg-ndor-surface-alt/50 flex items-center justify-center","aria-hidden":!0,children:(0,Xt.jsx)(hT,{className:"h-4 w-4 text-ndor-ink-secondary"})}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,Xt.jsx)("h3",{className:"text-sm font-medium text-ndor-ink",children:"Governance pack"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:"The formal governance artefact operationalising the hiring decision. Finalised packs are immutable and count against your plan's monthly allowance."})]})]}),h?(0,Xt.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2.5 text-[11px] text-amber-200 flex items-start gap-2","data-testid":"governance-pack-migration-hint",children:[(0,Xt.jsx)(ty,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),(0,Xt.jsxs)("span",{children:["Governance pack storage migration pending. Apply"," ",(0,Xt.jsx)("code",{className:"font-mono",children:"backend/migrations/130_emp_governance_packs_payload.sql"})," ","via Supabase Studio to enable this surface."]})]}):null,a.length>0&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-bg/30 p-3 space-y-3","data-testid":"governance-pack-draft-builder",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.16em] text-ndor-ink-secondary font-medium",children:"Build a new pack"}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-ndor-ink-secondary",children:[(0,Xt.jsxs)("span",{"data-testid":"governance-pack-eligible-strip",children:["Eligible \xb7 ",r," shortlisted \xb7 ",i," review"]}),(0,Xt.jsx)("button",{type:"button",onClick:()=>{const e={};for(const t of a)e[t.id]=!0;v(e)},className:"text-ndor-ink-secondary hover:text-ndor-ink underline-offset-2 hover:underline","data-testid":"governance-pack-select-all",children:"Select all"}
2),(0,Xt.jsx)("span",{"aria-hidden":!0,children:"\xb7"}),(0,Xt.jsx)("button",{type:"button",onClick:()=>v({}),className:"text-ndor-ink-secondary hover:text-ndor-ink underline-offset-2 hover:underline","data-testid":"governance-pack-clear-all",children:"Clear"})]})]}),(0,Xt.jsx)("ul",{className:"space-y-1.5 max-h-[200px] overflow-y-auto pr-1","data-testid":"governance-pack-eligible-list",children:a.map(e=>{const t=Boolean(x[e.id]),n={emerald:"bg-emerald-500/10 text-emerald-300 border-emerald-500/40",amber:"bg-amber-500/10 text-amber-300 border-amber-500/40",slate:"bg-ndor-bg/40 text-ndor-ink-secondary border-ndor-edge"}["shortlisted"===e.governance_status?"emerald":"review"===e.governance_status?"amber":"slate"];return(0,Xt.jsxs)("li",{className:"flex items-center gap-3 px-2 py-1.5 rounded border border-transparent hover:border-ndor-edge","data-testid":"governance-pack-eligible-row-".concat(e.id),children:[(0,Xt.jsx)(Vb,{checked:t,onCheckedChange:()=>{return t=e.id,void v(e=>(0,c.A)((0,c.A)({},e),{},{[t]:!e[t]}));var t},"data-testid":"governance-pack-eligible-checkbox-".concat(e.id)}),(0,Xt.jsx)(wO,{value:e.id}),(0,Xt.jsx)("span",{className:"flex-1 text-xs text-ndor-ink-secondary truncate",children:e.original_filename||"\u2014"}),(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-[0.14em] px-1.5 py-0.5 rounded border ".concat(n),children:e.governance_status})]},e.id)})}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-secondary","data-testid":"governance-pack-selected-count",children:[k," selected"]}),(0,Xt.jsx)(Rr,{size:"sm",disabled:0===k||g,onClick:N,className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted","data-testid":"governance-pack-create-draft-btn",children:g?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Creating\u2026"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Ow,{className:"mr-1.5 h-3.5 w-3.5"}),"Create governance pack draft"]})})]})]}),(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":"governance-pack-list",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.16em] text-ndor-ink-secondary font-medium",children:"Packs for this role"}),d?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted","data-testid":"governance-pack-loading",children:"Loading\u2026"}):m?(0,Xt.jsx)("p",{className:"text-xs text-rose-300","data-testid":"governance-pack-load-error",children:m}):0===o.length?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted","data-testid":"governance-pack-list-empty",children:"No packs yet \u2014 assemble your first one above."}):(0,Xt.jsx)("ul",{className:"space-y-2",children:o.map(e=>{const t=b[e.id],n="draft"===e.pack_status,a="finalised"===e.pack_status||"exported"===e.pack_status;return(0,Xt.jsxs)("li",{className:"rounded-md border border-ndor-edge bg-ndor-bg/30 px-3 py-2.5 flex items-center gap-3 flex-wrap","data-testid":"governance-pack-row-".concat(e.id),children:[(0,Xt.jsx)(wO,{value:e.id}),(0,Xt.jsx)(jO,{status:e.pack_status}),(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-secondary",children:[e.included_count," candidate",1===e.included_count?"":"s"]}),(0,Xt.jsxs)("span",{className:"text-[10px] text-ndor-ink-muted",children:["created ",e.created_at?new Date(e.created_at).toLocaleString():"\u2014"]}),e.finalised_at?(0,Xt.jsxs)("span",{className:"text-[10px] text-emerald-300/80 flex items-center gap-1",children:[(0,Xt.jsx)(Bn,{className:"h-3 w-3"}),"finalised ",new Date(e.finalised_at).toLocaleString()]}):null,(0,Xt.jsx)("span",{className:"flex-1"}),n?(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",disabled:Boolean(t),onClick:()=>_(e.id),className:"border-ndor-edge text-ndor-ink hover:bg-ndor-surface-alt","data-testid":"governance-pack-finalise-".concat(e.id),children:"finalise"===t?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Finalising\u2026"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Bn,{className:"mr-1.5 h-3 w-3"}),"Finalise pack"]})}):null,a?(0,Xt.jsx)(Rr,{size:"sm",disabled:Boolean(t),onClick:()=>D(e.id),className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted disabled:opacity-60 disabled:cursor-not-allowed","data-testid":"governance-pack-export-".concat(e.id),children:"export"===t?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Exporting\u2026"]}
2):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(yO,{className:"mr-1.5 h-3 w-3"}),"Export PDF"]})}):null,n?(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",disabled:!0,className:"text-ndor-ink-muted/60 hover:text-ndor-ink-muted/60 cursor-not-allowed",title:"Draft delete ships in the next slice.","data-testid":"governance-pack-delete-disabled-".concat(e.id),children:(0,Xt.jsx)(pb,{className:"h-3 w-3"})}):null]},e.id)})})]}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted leading-relaxed pt-1 border-t border-ndor-edge","data-testid":"governance-pack-footer",children:"Allowance is consumed only when a pack is finalised. Re-exporting a finalised pack does not consume additional allowance. Pack content is frozen at finalisation."}),(0,Xt.jsx)(NT,{variant:"block",testId:"governance-pack-disclaimer",className:"mt-4"})]})}):(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"governance-pack-empty",children:(0,Xt.jsx)(Py,{className:"px-5 py-4 sm:px-6 sm:py-5",children:(0,Xt.jsxs)("div",{className:"flex items-start gap-3",children:[(0,Xt.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-md border border-ndor-edge bg-ndor-surface-alt/50 flex items-center justify-center","aria-hidden":!0,children:(0,Xt.jsx)(hT,{className:"h-4 w-4 text-ndor-ink-secondary"})}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1 space-y-1.5",children:[(0,Xt.jsx)("h3",{className:"text-sm font-medium text-ndor-ink",children:"Governance pack"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:"Governance packs become available once candidates are shortlisted or flagged for review. Run evaluations on the dossiers above to begin."})]})]})})})}const NO={clear:"No integrity indicators detected",review_required:"Review recommended",unable_to_verify:"Could not complete inspection"},_O={included_for_evaluation:"Included for evaluation",excluded_from_evaluation:"Excluded from evaluation"},DO={document_integrity_concern:"Document integrity concern",other:"Other (see note)"},CO={inspection_exception:"The integrity inspection raised an unexpected error.",parser_metadata_unavailable:"The parser produced text but per-glyph / per-run metadata was unavailable.",unsupported_document_structure:"The document structure is not recognised by the current inspector.",parse_failed_upstream:"The upstream parser could not extract text from this document."},AO={white_text:"White text",near_white_text:"Near-white text",vanish:"Hidden run (w:vanish)",web_hidden:"Web-hidden element",tiny_font:"Sub-visible font size",off_canvas:"Off-canvas positioning",matrix_scaled:"Matrix-scaled to invisible",low_contrast:"Low contrast against background",zero_width_stuffing:"Zero-width character stuffing"},SO={strong:"Strong",heuristic:"Heuristic"};function EO(e){return e&&"string"===typeof e?e.split("_").map(e=>e?e.charAt(0).toUpperCase()+e.slice(1):"").join(" "):"\u2014"}function FO(e){return _O[e]||EO(e)}function RO(e){return DO[e]||EO(e)}function IO(e){return CO[e]||EO(e)}const TO=[{value:"document_integrity_concern",label:"Document integrity concern"},{value:"other",label:"Other (please explain in the note)"}];const PO=new Set(["owner","admin","recruiter"]);function OO(e){let{f:t}=e;const n=(a=t.indicator_type,AO[a]||EO(a));var a;const r=function(e){return SO[e]||EO(e)}(t.confidence),s=[];return null!=t.page_number&&s.push("p.".concat(t.page_number)),null!=t.paragraph_index&&s.push("\xb6".concat(t.paragraph_index)),null!=t.font_size&&s.push("font ".concat(t.font_size,"pt")),t.font_color_hex&&s.push("text colour #".concat(t.font_color_hex)),t.bg_color_hex&&s.push("background #".concat(t.bg_color_hex)),null!=t.char_count&&s.push("".concat(t.char_count," chars")),(0,Xt.jsx)("li",{className:"py-2 first:pt-0 border-b border-ndor-edge/40 last:border-b-0","data-testid":"integrity-finding-row",children:(0,Xt.jsx)("div",{className:"flex items-start justify-between gap-4",children:(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink",children:[(0,Xt.jsx)("span",{className:"font-medium",children:n}),(0,Xt.jsx)("span",{className:"ml-2 text-xs uppercase tracking-wider text-slate-400","data-testid":"integrity-finding-confidence",children:r})]}),s.length>0&&(0,Xt.jsx)("p",{className:"text-xs text-slate-400 mt-0.5",children:s.join(" \xb7 ")}),t.text_fragment&&(0,Xt.jsxs)("p",{className:"text-xs italic text-slate-300 mt-1 line-clamp-2",title:t.text_fragment,children:["\u201c",t.text_fragment,"\u201d"]})]})})})}function BO(e){let{open:t,mode:n,currentDisposition:a,busy:r,onCancel:i,onSubmit:o}=e;
2const[l,c]=(0,s.useState)("document_integrity_concern"),[d,u]=(0,s.useState)("");if((0,s.useEffect)(()=>{t&&(c("document_integrity_concern"),u(""))},[t,n]),!t)return null;const m="include"===n?"included_for_evaluation":"excluded_from_evaluation",p="exclude"===n,h=p?l:l||null,f="other"===l,x=d.trim(),v=Boolean(!r&&("include"===n||l)&&(!f||x.length>0)),g="include"===n?"excluded_from_evaluation"===a?"Reverse: include for evaluation":"Include for evaluation":"included_for_evaluation"===a?"Reverse: exclude from evaluation":"Exclude from evaluation";return(0,Xt.jsxs)("div",{className:"mt-4 rounded-md border border-ndor-edge bg-ndor-surface/60 p-4 space-y-3","data-testid":"integrity-dispose-dialog","data-mode":n,children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:g}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300",children:"include"===n?"The candidate will become eligible for evaluation. Reason is optional; a note helps future reviewers understand the decision.":"The candidate will be excluded from evaluation. A reason is required."}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsxs)("label",{htmlFor:"integrity-dispose-reason",className:"text-[11px] uppercase tracking-wider text-slate-300",children:["Reason ",p?(0,Xt.jsx)("span",{className:"text-rose-300",children:"(required)"}):(0,Xt.jsx)("span",{className:"text-slate-500",children:"(optional)"})]}),(0,Xt.jsxs)("select",{id:"integrity-dispose-reason","data-testid":"integrity-dispose-reason-select",value:l,onChange:e=>c(e.target.value),className:"w-full rounded-md border border-ndor-edge bg-ndor-bg px-2.5 py-1.5 text-sm text-ndor-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400",children:[!p&&(0,Xt.jsx)("option",{value:"",children:"\u2014 select a reason \u2014"}),TO.map(e=>(0,Xt.jsx)("option",{value:e.value,children:e.label},e.value))]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsxs)("label",{htmlFor:"integrity-dispose-note",className:"text-[11px] uppercase tracking-wider text-slate-300",children:["Note"," ",f?(0,Xt.jsx)("span",{className:"text-rose-300",children:"(required when reason is \u201cother\u201d)"}):(0,Xt.jsx)("span",{className:"text-slate-500",children:"(optional, up to 2000 characters)"})]}),(0,Xt.jsx)(Hw,{id:"integrity-dispose-note","data-testid":"integrity-dispose-note",rows:3,maxLength:2e3,value:d,onChange:e=>u(e.target.value),placeholder:f?"Please describe the reason in your own words.":"Optional context to help future reviewers.",className:"w-full bg-ndor-bg border-ndor-edge text-sm text-ndor-ink"}),f&&0===x.length&&(0,Xt.jsx)("p",{className:"text-[11px] text-rose-300",children:"A written explanation is required when the reason is \u201cother\u201d."})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",className:"h-8 text-xs uppercase tracking-wider border-ndor-edge text-slate-200",onClick:i,disabled:r,"data-testid":"integrity-dispose-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",className:"h-8 text-xs uppercase tracking-wider ".concat("include"===n?"border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/10":"border-rose-500/40 text-rose-200 hover:bg-rose-500/10"),disabled:!v,onClick:()=>o({disposition:m,reason:h,disposition_note:x.length>0?x:null}),"data-testid":"integrity-dispose-confirm",children:r?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Working\u2026"]}):"include"===n?"Confirm include":"Confirm exclude"})]})]})}function LO(e){var t;let{candidate:n,memberRole:a,onDisposed:r}=e;const[i,o]=(0,s.useState)(!1),[l,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[m,p]=(0,s.useState)(!1),[h,f]=(0,s.useState)(null),x=function(e){const t=null===e||void 0===e?void 0:e.integrity_classification,n=null===e||void 0===e?void 0:e.integrity_status,a=null===e||void 0===e?void 0:e.integrity_disposition;return"clear"===t?{cls:"border-emerald-500/40 text-emerald-300 bg-emerald-500/5",Icon:Bn,label:"Integrity: clear",title:"Automated check found no hidden or adversarial text."}:"included"===t?{cls:"border-amber-500/40 text-amber-200 bg-amber-500/5",Icon:mb,label:"Integrity: reviewed \xb7 included",title:"Detector produced findings; a human included this dossier for evaluation."}:"excluded"===t?{cls:"border-rose-500/40 text-rose-200 bg-rose-500/5",Icon:mb,label:"Integrity: reviewed \xb7 excluded",title:"Detector produced findings; a human excluded this dossier from evaluation."}:"unresolved"===t?{cls:"border-amber-500/60 text-amber-100 bg-amber-500/10",Icon:mb,label:"unable_to_verify"===n?"Integrity: unverifiable \xb7 needs decision":"Integrity: needs decision",title:"A human decision (include or exclude) is required before evaluation."}:"grandfathered_legacy"===t?{cls:"border-slate-500/40 text-slate-200 bg-slate-500/5",Icon:DC,label:"Not checked (uploaded before this feature)",title:"This candidate predates the integrity control. Eligible for evaluation."}:"missing_check"===t?{cls:"border-orange-500/60 text-orange-200 bg-orange-500/10",Icon:mb,label:"Integrity check unavailable",title:"The required integrity check is missing. Evaluation is blocked until the check is repaired."}:"clear"===n?{cls:"border-emerald-500/40 text-emerald-300 bg-emerald-500/5",Icon:Bn,label:"Integrity: clear",title:"Automated check found no hidden or adversarial text."}:"review_required"===n||"unable_to_verify"===n?"included_for_evaluation"===a?{cls:"border-amber-500/40 text-amber-200 bg-amber-500/5",Icon:mb,label:"Integrity: reviewed \xb7 included",title:"Detector produced findings; a human included this dossier for evaluation."}:"excluded_from_evaluation"===a?{cls:"border-rose-500/40 text-rose-200 bg-rose-500/5",Icon:mb,label:"Integrity: reviewed \xb7 excluded",title:"Detector produced findings; a human excluded this dossier from evaluation."}:{cls:"border-amber-500/60 text-amber-100 bg-amber-500/10",Icon:mb,label:"unable_to_verify"===n?"Integrity: unverifiable":"Integrity: needs decision",title:"A human decision (include or exclude) is required before evaluation."}:{cls:"border-slate-500/40 text-slate-200 bg-slate-500/5",Icon:DC,label:"Integrity: not checked",title:"No integrity check on file for this candidate."}}(n),v=Boolean(a&&PO.has(a)),g=null===n||void 0===n?void 0:n.integrity_classification,y=(null===n||void 0===n?void 0:n.integrity_disposition)||(null===d||void 0===d||null===(t=d.check)||void 0===t?void 0:t.disposition)||null,b=v&&Boolean(null===n||void 0===n?void 0:n.integrity_check_i
2d)&&("unresolved"===g||"excluded"===g),w=v&&Boolean(null===n||void 0===n?void 0:n.integrity_check_id)&&("unresolved"===g||"included"===g||"clear"===g),j=(0,s.useCallback)(async()=>{if(null!==n&&void 0!==n&&n.id){c(!0);try{const e=await(0,zt.n)("/api/employer/v1/candidates/".concat(n.id,"/integrity"));u(e||null)}catch(pK){var e,t;u(null);const a=(null===pK||void 0===pK?void 0:pK.code)||(null===pK||void 0===pK||null===(e=pK.data)||void 0===e||null===(t=e.detail)||void 0===t?void 0:t.code)||"INTEGRITY_LOAD_FAILED";fy.error("".concat(a,": ").concat((null===pK||void 0===pK?void 0:pK.message)||"Failed to load integrity detail."))}finally{c(!1)}}},[null===n||void 0===n?void 0:n.id]);(0,s.useEffect)(()=>{i&&!d&&j()},[i,d,j]);const k=(0,s.useCallback)(async e=>{p(!0);try{await(0,zt.n)("/api/employer/v1/candidates/".concat(n.id,"/integrity/dispose"),{method:"POST",body:JSON.stringify(e)}),fy.success("included_for_evaluation"===e.disposition?"Included for evaluation.":"Excluded from evaluation."),f(null),u(null),"function"===typeof r&&r(n.id,e.disposition)}catch(pK){var t,a,s,i;const n=(null===pK||void 0===pK?void 0:pK.code)||(null===pK||void 0===pK||null===(t=pK.data)||void 0===t||null===(a=t.detail)||void 0===a?void 0:a.code)||"DISPOSE_FAILED",r=(null===pK||void 0===pK||null===(s=pK.data)||void 0===s||null===(i=s.detail)||void 0===i?void 0:i.message)||(null===pK||void 0===pK?void 0:pK.message)||"Disposition failed.";fy.error("".concat(n,": ").concat(r))}finally{p(!1)}},[n.id,r]),N=(0,s.useMemo)(()=>{if(null===d||void 0===d||!d.check)return[];const e=d.check,t=[{key:"machine",label:"Machine result",value:(n=e.aggregate_status,NO[n]||EO(n)),testid:"integrity-line-aggregate"}];var n;return e.integrity_failure_code&&t.push({key:"failure",label:"Inspection detail",value:IO(e.integrity_failure_code),testid:"integrity-line-failure"}),e.disposition&&t.push({key:"disposition",label:"Employer decision",value:FO(e.disposition),testid:"integrity-line-disposition"}),e.disposition_reason&&t.push({key:"reason",label:"Reason",value:RO(e.disposition_reason),testid:"integrity-line-reason"}),e.disposition_note&&t.push({key:"note",label:"Note",value:e.disposition_note,testid:"integrity-line-note"}),t},[d]),_=x.Icon;return(0,Xt.jsxs)("div",{className:"mt-2","data-testid":"integrity-row","data-candidate-id":n.id,children:[(0,Xt.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"inline-flex items-center gap-1.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded","data-testid":"integrity-badge-toggle","data-expanded":i?"true":"false",title:x.title,children:[(0,Xt.jsxs)(Vw,{variant:"outline",className:"".concat(x.cls," text-[10px] uppercase tracking-wider flex items-center gap-1"),"data-testid":"integrity-badge","data-status":n.integrity_status||"not_checked","data-disposition":n.integrity_disposition||"none","data-classification":g||"none",children:[(0,Xt.jsx)(_,{className:"h-3 w-3"}),x.label]}),i?(0,Xt.jsx)(Gn,{className:"h-3 w-3 text-slate-400"}):(0,Xt.jsx)(qn,{className:"h-3 w-3 text-slate-400"})]}),i&&(0,Xt.jsxs)("div",{className:"mt-3 rounded-md border border-ndor-edge bg-ndor-bg/40 p-4","data-testid":"integrity-detail-panel",children:[l&&(0,Xt.jsxs)("p",{className:"text-xs text-slate-400 flex items-center gap-2",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin"}),"Loading integrity detail\u2026"]}),!l&&d&&null===d.check&&(0,Xt.jsx)("p",{className:"text-xs text-slate-300","data-testid":"integrity-no-check",children:"missing_check"===g?"The required integrity check is missing for this candidate. This is not evidence against the candidate \u2014 it indicates the automated check did not persist. Evaluation is blocked until the integrity state is repaired (re-ingest or ops remediation).":"No integrity check on file for this candidate. Older uploads predate this control."}),!l&&d&&d.check&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("div",{className:"text-xs text-slate-300 space-y-1","data-testid":"integrity-check-summary",children:N.map(e=>(0,Xt.jsxs)("p",{"data-testid":e.testid,children:[e.label,":"," ",(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium",children:e.value})]},e.key))}),d.findings&&d.findings.length>0&&(0,Xt.jsxs)("div",{className:"mt-3",children:[(0,Xt.jsxs)("p",{className:"text-xs uppercase tracking-wider text-slate-400 mb-1",children:["Findings (",d.findings.length,")"]}),(0,Xt.jsx)("ul",{className:"max-h-64 overflow-y-auto","data-testid":"integrity-findings-list",children:d.findings.map(e=>(0,Xt.jsx)(OO,{f:e},e.id))}),(0,Xt.jsx)("p",{className:"mt-2 text-[11px] text-slate-500",children:"Findings describe observed document properties. They are evidence for a human decision \u2014 not a verdict on the candidate."})]}),v&&!h&&(b||w)&&(0,Xt.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2","data-testid":"integrity-actions",children:[b&&(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",className:"h-8 text-xs uppercase tracking-wider border-emerald-500/40 text-emerald-200 hover:bg-emerald-500/10",onClick:()=>f("include"),disabled:m,"data-testid":"integrity-include-btn","data-reversal":"excluded_from_evaluation"===y?"true":"false",children:"excluded_from_evaluation"===y?"Reverse to include":"Include for evaluation"}),w&&(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",className:"h-8 text-xs uppercase tracking-wider border-rose-500/40 text-rose-200 hover:bg-rose-500/10",onClick:()=>f("exclude"),disabled:m,"data-testid":"integrity-exclude-btn","data-reversal":"included_for_evaluation"===y?"true":"false",children:"included_for_evaluation"===y?"Reverse to exclude":"Exclude from evaluation"})]}),(0,Xt.jsx)(BO,{open:null!==h,mode:h,currentDisposition:y,busy:m,onCancel:()=>f(null),onSubmit:k})]})]})]})}function MO(e){let{matchId:t,candidateId:n,empCandidateId:a,accountId:r,roleId:i,activeReviewerCount:o,onRouted:l}=e;
2const[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(!1),[p,h]=(0,s.useState)(!1),f=a?"emp_candidate":"profile";(0,s.useEffect)(()=>{let e=!1;return(async()=>{if(i)try{const t="emp_candidate"===f?await async function(e,t){if(!e||!t)return[];const{data:n,error:a}=await Mt.supabase.from("emp_candidate_reviews").select("review_id, reviewer_user_id, status").eq("role_id",e).eq("emp_candidate_id",t);if(a)throw a;return n||[]}(i,a):await async function(e,t){if(!e||!t)return[];const{data:n,error:a}=await Mt.supabase.from("emp_candidate_reviews").select("review_id, reviewer_user_id, status").eq("role_id",e).eq("candidate_user_id",t);if(a)throw a;return n||[]}(i,n);!e&&t&&t.length>0&&h(!0)}catch(t){}})(),()=>{e=!0}},[i,n,a,f]);const x=!o||o<=0,v=c||x||!r||!n&&!a,g=DP(u?"route.action.routed":p?"route.action.already_routed":"route.action.default"),y=x?DP("route.action.disabled.no_reviewers"):void 0;return(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",disabled:v,onClick:async()=>{if(!v){d(!0);try{var e;const s=await function(e){let{accountId:t,roleId:n,candidateUserId:a=null,empCandidateId:r=null,idempotencyKey:s}=e;if(null==a===(null==r))return Promise.reject(new Error("routeCandidate: exactly one of candidateUserId, empCandidateId is required"));const i={account_id:t,role_id:n};return a&&(i.candidate_user_id=a),r&&(i.emp_candidate_id=r),(0,zt.n)("".concat(jP,"/reviews/route"),{method:"POST",headers:kP(s),body:i})}({accountId:r,roleId:i,candidateUserId:"profile"===f?n:null,empCandidateId:"emp_candidate"===f?a:null,idempotencyKey:"route-".concat(t||n||a,"-").concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8))}),o=Number(null!==(e=null===s||void 0===s?void 0:s.reviewers_routed)&&void 0!==e?e:0);fy.success(CP("route.toast.success",{n:o}),{action:{label:DP("route.toast.cta.view_reviewers"),onClick:()=>{window.location.href="/employer/reviewers"}}}),m(!0),h(!0),"function"===typeof l&&l()}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||DP("route.toast.fail"))}finally{d(!1)}}},title:y,"aria-label":DP("route.aria.routed_match"),"data-testid":"match-route-".concat(t||a||n),"data-target-kind":f,children:[c?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(DR,{className:"h-4 w-4 mr-1.5"}),g]})}const zO=[{key:"all",label:"All candidates",lane:"corpus"},{key:"awaiting",label:"Awaiting integrity",lane:"admissibility"},{key:"excluded",label:"Excluded",lane:"admissibility"},{key:"eligible",label:"Eligible for assessment",lane:"admissibility"}],UO=[{key:"shortlist",label:"Shortlist",lane:"ndor"},{key:"review",label:"Review",lane:"ndor"},{key:"reject",label:"Reject",lane:"ndor"}],VO=new Set(["shortlist","review","reject"]),qO=[{key:"shortlisted",label:"Move to shortlist"},{key:"review",label:"Move to review"},{key:"rejected",label:"Reject"},{key:"open",label:"Reset to open"}];function WO(e){if(!e)return null;const t={shortlist:{cls:"border-emerald-500/60 bg-emerald-500/20 text-emerald-100",label:"Shortlist"},review:{cls:"border-amber-500/60 bg-amber-500/20 text-amber-100",label:"Review"},reject:{cls:"border-rose-500/60 bg-rose-500/20 text-rose-100",label:"Reject"}}[e];return t?(0,Xt.jsxs)(Vw,{variant:"outline",className:"".concat(t.cls," text-[10px] uppercase tracking-wider"),"data-testid":"role-candidate-ndor-badge","data-verdict":e,children:["NDOR \xb7 ",t.label]}):null}function HO(e){const t={shortlisted:{cls:"border-emerald-500/40 text-emerald-300",label:"Shortlisted"},review:{cls:"border-amber-500/40 text-amber-300",label:"Under review"},rejected:{cls:"border-rose-500/40 text-rose-300",label:"Rejected"},open:{cls:"border-ndor-edge text-ndor-ink-muted",label:"Awaiting decision"}},n=t[e]||t.open;return(0,Xt.jsx)(Vw,{variant:"outline",className:"".concat(n.cls," text-[10px] uppercase tracking-wider"),"data-testid":"role-candidate-decision-badge","data-decision":e||"open",children:n.label})}function GO(e){const t={parsed:{cls:"border-emerald-500/40 text-emerald-300",label:"Parsed"},parsing:{cls:"border-amber-500/40 text-amber-300",label:"Parsing"},pending:{cls:"border-ndor-edge text-ndor-ink-muted",label:"Pending"},parse_failed:{cls:"border-rose-500/40 text-rose-300",label:"Parse failed"}},n=t[e]||t.pending;return(0,Xt.jsx)(Vw,{variant:"outline",className:"".concat(n.cls," text-[10px] uppercase tracking-wider"),children:n.label})}function KO(e){if(!e)return"";const t=Math.max(0,Math.round((Date.now()-new Date(e).getTime())/1e3));return t<60?"just now":t<3600?"".concat(Math.floor(t/60),"m ago"):t<86400?"".concat(Math.floor(t/3600),"h ago"):"".concat(Math.floor(t/86400),"d ago")}function YO(e){let{roleId:t,roleTitle:n,role:a=null,canUpload:r=!0,refreshToken:i=0,integrityFilterRequest:o=null,onIntegrityFilterApplied:l=null}=e;const d=(null===a||void 0===a?void 0:a.status)||"",u=!("active"===d||"live"===d),[m,p]=(0,s.use
2State)(null),[h,f]=(0,s.useState)(null),[x,v]=(0,s.useState)(null),[g,y]=(0,s.useState)({}),[b,w]=(0,s.useState)({}),[j,k]=(0,s.useState)("all");(0,s.useEffect)(()=>{if(!o)return;const e="awaiting_disposition"===o?"awaiting":"excluded"===o?"excluded":"eligible"===o?"eligible":null;e&&k(e),"function"===typeof l&&l()},[o,l]);const[N,_]=(0,s.useState)({}),[D,C]=(0,s.useState)(null),[A,S]=(0,s.useState)("ndor_recommendation_accepted"),[E,F]=(0,s.useState)(""),[R,I]=(0,s.useState)(!1),[T,P]=(0,s.useState)(null),[O,B]=(0,s.useState)(()=>new Set),[L,M]=(0,s.useState)(!1);(0,s.useEffect)(()=>{"eligible"!==j&&O.size>0&&B(new Set)},[j,O.size]);const[z,U]=(0,s.useState)(null),[V,q]=(0,s.useState)((null===a||void 0===a?void 0:a.org_id)||null),[W,H]=(0,s.useState)(0),[G,K]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{let u=(null===a||void 0===a?void 0:a.org_id)||null,m=null;if(u)try{var n,r;const e=await(0,zt.n)("/api/employer/v1/me");m=null!==(n=null===e||void 0===e||null===(r=e.member)||void 0===r?void 0:r.role)&&void 0!==n?n:null}catch(d){m=null}else{var s,i,o,l,c;const e=await(0,zt.n)("/api/employer/v1/me");u=null!==(s=null!==(i=null===e||void 0===e||null===(o=e.organisation)||void 0===o?void 0:o.id)&&void 0!==i?i:null===e||void 0===e?void 0:e.account_id)&&void 0!==s?s:null,m=null!==(l=null===e||void 0===e||null===(c=e.member)||void 0===c?void 0:c.role)&&void 0!==l?l:null}if(e)return;if(q(u),K(m),!u)return void H(0);const p=(await MP(u)||[]).filter(e=>e.role_id===t&&"active"===e.assignment_status).length;e||H(p)}catch(u){e||H(0)}})(),()=>{e=!0}},[t,null===a||void 0===a?void 0:a.org_id,i]);const Y=(0,s.useCallback)(async()=>{v(null);try{const e=await(0,zt.n)("/api/employer/v1/roles/".concat(t,"/candidates"));p((null===e||void 0===e?void 0:e.items)||[]),f((null===e||void 0===e?void 0:e.reconciliation)||null)}catch(pK){v((null===pK||void 0===pK?void 0:pK.message)||"Failed to load candidates."),p([]),f(null)}},[t]),J=(0,s.useCallback)(async()=>{try{const e=await(0,zt.n)("/api/employer/v1/roles/".concat(t,"/usage"));U(e||null)}catch(e){U(null)}},[t]);(0,s.useEffect)(()=>{t&&Y()},[t,Y]),(0,s.useEffect)(()=>{t&&J()},[t,J]),(0,s.useEffect)(()=>{t&&i>0&&(Y(),J())},[i,t,Y,J]);const $=(0,s.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];y(t=>(0,c.A)((0,c.A)({},t),{},{[e]:!0}));try{const n=await(0,zt.n)("/api/employer/v1/candidates/".concat(e,"/evaluate"),{method:"POST",body:JSON.stringify({force:t})});null!==n&&void 0!==n&&n.cached?fy.message("Returned cached evaluation. Use Re-evaluate to refresh."):null!==n&&void 0!==n&&n.governance_verdict?fy.success("Evaluated: ".concat(n.governance_verdict)):fy.message("Evaluation submitted."),await Y(),await J()}catch(pK){var n;const t=(null===pK||void 0===pK||null===(n=pK.data)||void 0===n?void 0:n.detail)||(null===pK||void 0===pK?void 0:pK.data)||{},a=t.code||(null===pK||void 0===pK?void 0:pK.code)||"EVALUATE_FAILED",r=t.message||t.error_code||(null===pK||void 0===pK?void 0:pK.message)||"Evaluation failed.";"EVAL_BUDGET_EXHAUSTED"===a?(fy.error(t.message||"Monthly evaluation allowance reached. Upgrade your workspace or wait until reset."),await J()):fy.error("".concat(a,": ").concat(r))}finally{y(t=>{const n=(0,c.A)({},t);return delete n[e],n})}},[Y,J]),X=(0,s.useCallback)((e,t)=>{var n,a;const r=(null===e||void 0===e||null===(n=e.latest_evaluation)||void 0===n?void 0:n.governance_verdict)||(null===e||void 0===e?void 0:e.governance_verdict)||null,s=(null===e||void 0===e||null===(a=e.latest_evaluation)||void 0===a?void 0:a.id)||(null===e||void 0===e?void 0:e.evaluation_id)||(null===e||void 0===e?void 0:e.latest_evaluation_id)||null;S("ndor_recommendation_accepted"),F(""),C({candidateId:e.id,candidateName:(null===e||void 0===e?void 0:e.anon_id)||(null===e||void 0===e?void 0:e.display_name)||e.id,target:t,latestEvaluationId:s,ndorVerdict:r})},[]),Q=(0,s.useCallback)((e,t)=>{if(!e||"open"===t)return!1;return!({shortlist:new Set(["shortlisted","review","open"]),review:new Set(["review","shortlisted","rejected","open"]),reject:new Set(["rejected","review","open"])}[e]||new Set).has(t)},[]),Z=(0,s.useCallback)(async()=>
2{if(!D)return;const{candidateId:e,target:t,latestEvaluationId:n,ndorVerdict:a}=D;if(Q(a,t)&&E.trim().length<100)fy.error("Divergent decisions require a rationale of at least 100 characters.");else{I(!0),_(t=>(0,c.A)((0,c.A)({},t),{},{[e]:!0}));try{const a=await(0,zt.n)("/api/employer/v1/candidates/".concat(e,"/governance"),{method:"PATCH",body:JSON.stringify({governance_status:t,decision_reason:A,decision_note:E,evaluation_id_at_decision:n})});!1===(null===a||void 0===a?void 0:a.changed)?fy.message("Already at that verdict."):null!==a&&void 0!==a&&a.is_material_divergence?fy.success("Divergent decision recorded with rationale."):fy.success("Decision recorded: ".concat(t,".")),C(null),F(""),await Y()}catch(pK){var r;const t=(null===pK||void 0===pK||null===(r=pK.data)||void 0===r?void 0:r.detail)||(null===pK||void 0===pK?void 0:pK.data)||{},n=t.code||(null===pK||void 0===pK?void 0:pK.code)||"DECISION_FAILED",a=t.message||(null===pK||void 0===pK?void 0:pK.message)||"Decision failed.";fy.error("".concat(n,": ").concat(a))}finally{I(!1),_(t=>{const n=(0,c.A)({},t);return delete n[e],n})}}},[D,A,E,Q,Y]),ee=(0,s.useCallback)(async(e,t)=>{if("open"!==t){const n=(m||[]).find(t=>t.id===e)||{id:e};return void X(n,t)}_(t=>(0,c.A)((0,c.A)({},t),{},{[e]:!0}));try{const t=await(0,zt.n)("/api/employer/v1/candidates/".concat(e,"/governance"),{method:"PATCH",body:JSON.stringify({governance_status:"open"})});!1===(null===t||void 0===t?void 0:t.changed)?fy.message("Already at that verdict."):fy.success("Decision reset to open."),await Y()}catch(pK){var n;const t=(null===pK||void 0===pK||null===(n=pK.data)||void 0===n?void 0:n.detail)||(null===pK||void 0===pK?void 0:pK.data)||{},a=t.code||(null===pK||void 0===pK?void 0:pK.code)||"OVERRIDE_FAILED",r=t.message||(null===pK||void 0===pK?void 0:pK.message)||"Override failed.";fy.error("".concat(a,": ").concat(r))}finally{_(t=>{const n=(0,c.A)({},t);return delete n[e],n})}},[m,Y,X]),te=(0,s.useCallback)(async()=>{if(0!==O.size){M(!0);try{var e,n;const a=Array.from(O),r="eligible-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,10)),s=await(0,zt.n)("/api/employer/v1/roles/".concat(t,"/evaluate-bulk/dispatch"),{method:"POST",headers:{"Idempotency-Key":r},body:JSON.stringify({candidate_ids:a})}),i=null!==(e=null!==(n=null===s||void 0===s?void 0:s.dispatched_count)&&void 0!==n?n:null===s||void 0===s?void 0:s.dispatched)&&void 0!==e?e:a.length;fy.success("Evaluation dispatched for ".concat(i," candidate").concat(1===i?"":"s",".")),B(new Set),await Y(),await J()}catch(pK){var a;const t=(null===pK||void 0===pK||null===(a=pK.data)||void 0===a?void 0:a.detail)||(null===pK||void 0===pK?void 0:pK.data)||{},n=t.code||(null===pK||void 0===pK?void 0:pK.code)||"BULK_DISPATCH_FAILED",r=t.message||(null===pK||void 0===pK?void 0:pK.message)||"Bulk evaluation failed.";if("EVAL_BUDGET_EXHAUSTED"===n)fy.error(r),await J();else if("INTEGRITY_DISPOSITION_REQUIRED"===n){const e=[];Array.isArray(t.unresolved)&&t.unresolved.length&&e.push("".concat(t.unresolved.length," awaiting decision")),Array.isArray(t.excluded)&&t.excluded.length&&e.push("".concat(t.excluded.length," excluded")),Array.isArray(t.missing_check)&&t.missing_check.length&&e.push("".concat(t.missing_check.length," missing integrity check")),fy.error("Cannot dispatch: ".concat(e.join(", "),". Refresh and re-select.")),await Y()}else fy.error("".concat(n,": ").concat(r))}finally{M(!1)}}},[O,t,Y,J]),ne=(0,s.useMemo)(()=>{if(!Array.isArray(m))return m;const e=m.filter(e=>!e.erased_at);return"all"===j?e:"awaiting"===j?e.filter(e=>"unresolved"===e.integrity_classification||"missing_check"===e.integrity_classification):"excluded"===j?e.filter(e=>"excluded"===e.integrity_classification):"eligible"===j?e.filter(e=>("clear"===e.integrity_classification||"included"===e.integrity_classification||"grandfathered_legacy"===e.integrity_classification)&&!e.evaluation_id):VO.has(j)?e.filter(e=>"complete"===e.evaluation_status&&e.governance_verdict===j&&!e.authoritative_evaluation_invalid):e},[m,j]),ae=(0,s.useMemo)(()=>{var e,t,n,a,r,s,i;return{all:null!==(e=null===h||void 0===h?void 0:h.n_all)&&void 0!==e?e:0,awaiting:null!==(t=null===h||void 0===h?void 0:h.n_awaiting_integrity)&&void 0!==t?t:0,excluded:null!==(n=null===h||void 0===h?void 0:h.n_excluded)&&void 0!==n?n:0,eligible:null!==(a=null===h||void 0===h?void 0:h.n_eligible_awaiting_first_assessment)&&void 0!==a?a:0,shortlist:null!==(r=null===h||void 0===h?void 0:h.n_shortlist)&&void 0!==r?r:0,review:null!==(s=null===h||void 0===h?void 0:h.n_review)&&void 0!==s?s:0,reject:null!==(i=null===h||void 0===h?void 0:h.n_reject)&&void 0!==i?i:0}},[h]);return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-candidates-panel",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 flex flex-row items-center justify-between px-6 pt-6",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-slate-300"}),"Candidates & Dossiers"]}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:Y,"aria-label":"Refresh candidates","data-testid":"role-candidates-refresh",className:"h-8 w-8 p-0",children:(0,Xt.jsx)(Kg,{className:"h-4 w-4"})})]}),(0,Xt.jsxs)(Py,{className:"space-y-5 px-6 pb-6",children:[u&&Array.isArray(m)&&m.length>0&&(0,Xt.jsxs)("div",{className:"text-xs rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-amber-200","data-testid":"role-candidates-lifecycle-banner",children:["New evaluations are disabled
2while this role is"," ",(0,Xt.jsx)("code",{className:"font-mono",children:d||"not active"}),". Existing verdicts, governance packs, and reviewer triage remain available."]}),x&&(0,Xt.jsxs)("div",{className:"text-xs text-rose-400 flex items-start gap-2","data-testid":"role-candidates-error",children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 mt-0.5"}),(0,Xt.jsx)("span",{children:x})]}),null===m&&(0,Xt.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin text-slate-300"})}),Array.isArray(m)&&0===m.length&&(0,Xt.jsxs)("div",{className:"text-center py-8 px-4 rounded-md border border-dashed border-ndor-edge bg-ndor-bg/40 space-y-2","data-testid":"role-candidates-empty",children:[(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink font-medium",children:"No candidates yet."}),(0,Xt.jsxs)("p",{className:"text-xs text-slate-200 leading-relaxed max-w-md mx-auto",children:["Use the ",(0,Xt.jsx)("strong",{children:"Upload Dossiers"})," tab to add your first Candidate Dossier. Each dossier is one PDF or DOCX file containing the candidate\u2019s CV (required), plus any cover letter, supporting statement or notes you have on file."]})]}),Array.isArray(m)&&m.length>0&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(gO,{items:m,reconciliation:h}),(0,Xt.jsxs)("div",{className:"space-y-1.5","data-testid":"role-candidates-filter-group-admissibility",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-secondary font-medium",children:"Dossiers & admissibility"}),(0,Xt.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",role:"tablist","aria-label":"Dossiers and admissibility views",children:zO.map(e=>{const t=j===e.key,n=ae[e.key];return(0,Xt.jsxs)("button",{type:"button",role:"tab","aria-selected":t,onClick:()=>k(e.key),className:"text-[11px] uppercase tracking-wider px-2.5 py-1 rounded-full border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 ".concat(t?"border-ndor-ink bg-ndor-ink text-ndor-surface font-semibold":"border-ndor-edge bg-ndor-bg/40 text-ndor-ink-secondary hover:text-ndor-ink hover:border-ndor-ink/40"),"data-testid":"role-candidates-filter-".concat(e.key),"data-active":t?"true":"false",children:[e.label," (",n,")"]},e.key)})})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5","data-testid":"role-candidates-filter-group-ndor-results",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-ndor-ink-secondary font-medium",children:"NDOR evaluation results"}),(0,Xt.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",role:"tablist","aria-label":"NDOR completed-evaluation result views",children:UO.map(e=>{const t=j===e.key,n=ae[e.key],a="shortlist"===e.key?"border-emerald-500/60 bg-emerald-500/20 text-emerald-100":"review"===e.key?"border-amber-500/60 bg-amber-500/20 text-amber-100":"border-rose-500/60 bg-rose-500/20 text-rose-100";return(0,Xt.jsxs)("button",{type:"button",role:"tab","aria-selected":t,onClick:()=>k(e.key),className:"text-[11px] uppercase tracking-wider px-2.5 py-1 rounded-full border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 ".concat(t?"".concat(a," font-semibold"):"border-ndor-edge bg-ndor-bg/40 text-ndor-ink-secondary hover:text-ndor-ink hover:border-ndor-ink/40"),"data-testid":"role-candidates-filter-".concat(e.key),"data-active":t?"true":"false",children:[e.label," (",n,")"]},e.key)})})]}),"eligible"===j&&((e,t)=>{const n=(ne||[]).filter(e=>"complete"!==e.evaluation_status),a=new Set(n.map(e=>e.id)),r=n.length,s=null!==(e=null===z||void 0===z?void 0:z.monthly_cap)&&void 0!==e?e:null,i=null!==(t=null===z||void 0===z?void 0:z.monthly_used)&&void 0!==t?t:0,o=null==s?Number.POSITIVE_INFINITY:Math.max(0,s-i),l=Math.min(r,o),c=o===Number.POSITIVE_INFINITY?"\u221e":String(o),d=l,m=O.size,p=m>0&&!L&&!u;return(0,Xt.jsxs)("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/10 px-4 py-3 space-y-3","data-testid":"eligible-view-panel",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1",children:[(0,Xt.jsx)("p",{className:"text-sm font-semibold text-emerald-100","data-testid":"eligible-view-headline",children:"Eligible for assessment"}),(0,Xt.jsxs)("p",{className:"text-xs text-emerald-200/90",children:[(0,Xt.jsx)("span",{className:"text-emerald-100 font-semibold","data-testid":"eligible-count",children:r})," ","dossier",1===r?"":"s"," awaiting first assessment"]}),(0,Xt.jsxs)("p",{className:"text-xs text-emerald-200/90",children:[(0,Xt.jsx)("span",{className:"text-emerald-100 font-semibold","data-testid":"eligible-available-count",children:c})," ","evaluation",1===o?"":"s"," available",null!=s&&(0,Xt.jsxs)(Xt.Fragment,{children:[" ","(",i," of ",s," used",null!==z&&void 0!==z&&z.period_ends_at?", resets ".concat(new Date(z.period_ends_at).toLocaleDateString("en-GB",{day:"2-digit",month:"short"})):"",")"]})]}),(0,Xt.jsxs)("p",{className:"text-xs text-emerald-200/90",children:[(0,Xt.jsx)("span",{className:"text-emerald-100 font-semibold","data-testid":"eligible-selected-count",children:m})," ","selected"]})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,Xt.jsx)(Rr,{size:"sm",className:"h-8 text-xs uppercase tracking-wider bg-emerald-500/20 border border-emerald-500/50 text-emerald-100 hover:bg-emerald-500/30 disabled:opacity-40",disabled:!p,onClick:te,"data-testid":"eligible-bulk-evaluate-btn",children:L?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Dispatching\u2026"]}):"Evaluate selected (".concat(m,")")}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",className:"h-8 text-xs uppercase tracking-wider border-emerald-500/40 text-emerald-100 hover:bg-emerald-500/10 disabled:opacity-40",disabled:0===d||L,onClick:()=>{const e=new Set;for(const t of n){if(e.size>=d)break;e.add(t.id)}B(e)},"data-testid":"eligible-select-up-to-cap-btn",title:"Selects up to the available evaluation capacity in visible order. No AI/scoring/ranking decides which dossiers consume scarce capacity.",children:["Select up to ",c]}),m>0&&(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",className:"h-8 text-xs uppercase tracking-wider text-emerald-200 hover:text-emerald-100",onClick:()=>B(new Set),disabled:L,"data-testid":"eligible-clear-selection-btn",children:"Clear selection"})]}),m>l&&(0,Xt.jsxs)("p",{className:"text-[11px] text-amber-200","data-testid":"eligible-selection-over-cap",children:["Your selection (",m,") exceeds the current evaluation capacity (",c,"). Reduce your selection or upgrade your workspace."]}),(0,Xt.jsx)("span",{className:"hidden","data-testid":"eligible-unevaluated-ids","data-ids":Array.from(a).join(",")})]})})()]}),z&&z.limit_reached&&(0,Xt.jsxs)("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm leading-relaxed text-amber-200",role:"status","data-testid":"role-candidates-limit-reached-banner",children:[(0,Xt.jsx)("p",{className:"font-medium text-amber-100",children:"Monthly evaluation allowance reached."}),(0,Xt.jsxs)("p",{className:"mt-1 text-amber-200/90",children:["Your ",z.plan_tier?"".concat(z.plan_tier.charAt(0).toUpperCase()).concat(z.plan_tier.slice(1)):"current"," workspace has used ",z.monthly_used," of ",z.monthly_cap," evaluations for the current billing period."]}),(0,Xt.jsxs)("p",{className:"mt-1 text-amber-200/90",children:[z.period_ends_at?(0,Xt.jsxs)(Xt.Fragment,{children:["Resets on ",new Date(z.period_ends_at).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}),"."]}):(0,Xt.jsx)(Xt.Fragment,{children:"Resets at the next billing period."})," ","Upgrade your workspace or wait until reset."]}),(0,Xt.jsx)(Et,{to:"/employer/account?tab=plans",className:"mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-amber-100 hover:text-amber-50 underline-offset-4 hover:underline","data-testid":"role-candidates-view-plans-link",children:"View plans"})]}),Array.isArray(ne)&&0===ne.length&&Array.isArray(m)&&m.length>
20&&(0,Xt.jsx)("div",{className:"text-center py-6 px-4 rounded-md border border-dashed border-ndor-edge bg-ndor-bg/30","data-testid":"role-candidates-filter-empty",children:(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary",children:"No dossiers match the current filter."})}),Array.isArray(ne)&&ne.length>0&&(0,Xt.jsx)("div",{className:"max-h-[560px] overflow-y-auto pr-1 -mr-1","data-testid":"role-candidates-scroll-region",children:(0,Xt.jsx)("ul",{className:"divide-y divide-ndor-edge","data-testid":"role-candidates-list",children:ne.map(e=>{return(0,Xt.jsxs)("li",{id:"candidate-".concat(e.id),className:"py-5 first:pt-2","data-testid":"role-candidate-row","data-candidate-id":e.id,children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,Xt.jsxs)("div",{className:"min-w-0 flex-1 flex items-start gap-3",children:["eligible"===j&&(0,Xt.jsx)(Vb,{className:"mt-1 h-4 w-4 border-emerald-500/50 data-[state=checked]:bg-emerald-500 data-[state=checked]:text-emerald-950 disabled:opacity-40",checked:O.has(e.id),onCheckedChange:t=>{B(n=>{const a=new Set(n);return t?a.add(e.id):a.delete(e.id),a})},disabled:L||u||"complete"===e.evaluation_status,"aria-label":"complete"===e.evaluation_status?"".concat(e.original_filename," \u2014 already evaluated"):"Select ".concat(e.original_filename," for evaluation"),title:"complete"===e.evaluation_status?"This dossier has already been evaluated. Re-evaluate is available via the per-row action.":void 0,"data-testid":"eligible-row-checkbox","data-candidate-id":e.id,"data-evaluated":"complete"===e.evaluation_status?"true":"false"}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate",title:e.original_filename,children:e.original_filename}),(0,Xt.jsxs)("div",{className:"mt-2 flex items-center gap-2 flex-wrap text-xs text-slate-300",children:[(0,Xt.jsx)("span",{children:KO(e.created_at)}),(0,Xt.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,Xt.jsx)("span",{children:(n=e.file_size_bytes,n?n<1024?"".concat(n," B"):n<1048576?"".concat((n/1024).toFixed(1)," KB"):"".concat((n/1048576).toFixed(1)," MB"):"\u2014")}),(0,Xt.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,Xt.jsx)("span",{className:"font-mono-ui",children:String(e.cv_sha256||"").slice(0,8)}),(0,Xt.jsx)("span",{className:"text-xs uppercase tracking-wider px-2 py-0.5 rounded border border-slate-500/40 bg-slate-500/10 text-slate-200",title:"Candidate Dossier \u2014 CV (required) plus optional cover letter, supporting statement, candidate notes","data-testid":"role-candidate-dossier-pill",children:"Dossier"})]}),"parse_failed"===e.parse_status&&e.parse_error_code&&(0,Xt.jsx)("p",{className:"mt-2 text-xs text-rose-300",children:e.parse_error_code}),(0,Xt.jsx)(LO,{candidate:e,memberRole:G,onDisposed:()=>Y()})]})]}),(0,Xt.jsxs)("div",{className:"shrink-0 flex flex-col items-end gap-1.5",children:[GO(e.parse_status),"complete"===e.evaluation_status&&!e.authoritative_evaluation_invalid&&WO(e.governance_verdict),"complete"===e.evaluation_status&&!e.authoritative_evaluation_invalid&&"number"===typeof e.overall_fit&&(0,Xt.jsxs)("span",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-secondary","data-testid":"role-candidate-fit-score",children:["Fit ",e.overall_fit,"/100","number"===typeof e.confidence_low&&"number"===typeof e.confidence_high?" \xb7 conf ".concat(e.confidence_low,"\u2013").concat(e.confidence_high):""]}),"complete"===e.evaluation_status&&e.authoritative_evaluation_invalid&&(0,Xt.jsx)(Vw,{variant:"outline",className:"border-amber-500/60 bg-amber-500/10 text-amber-200 text-[10px] uppercase tracking-wider","data-testid":"role-candidate-invariant-flag",children:"Recommendation invalid"}),"complete"===e.evaluation_status&&HO(e.governance_status)]})]}),(0,Xt.jsxs)("div",{className:"mt-3 flex items-center justify-end gap-4 flex-wrap",children:["eligible"===j&&"parsed"===e.parse_status&&"complete"!==e.evaluation_status&&(0,Xt.jsx)(Rr,{size:"sm",variant:"outline",className:"h-8 text-xs uppercase tracking-wider focus-visible:ring-2 focus-visible:ring-blue-400",onClick:()=>$(e.id,!1),disabled:Boolean(g[e.id])||Boolean(z&&z.limit_reached)||u,title:u?"Evaluations only run on active roles. Publish the role or wait until it leaves the closing/closed state.":z&&z.limit_reached?"Monthly allowance reached (".concat(z.monthly_used," of ").concat(z.monthly_cap,"). Resets ").concat(z.period_ends_at?new Date(z.period_ends_at).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"next period","."):void 0,"data-testid":"role-candidate-evaluate-btn","data-limit-reached":z&&z.limit_reached?"true":"false","data-lifecycle-blocked":u?"true":"false",children:g[e.id]?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Assessing\u2026"]}):"Assess"}),"complete"===e.evaluation_status&&(0,Xt.jsx)("button",{type:"button",onClick:()=>w(t=>(0,c.A)((0,c.A)({},t),{},{[e.id]:!t[e.id]})),className:"text-xs text-slate-200 hover:text-ndor-ink underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded font-medium","data-testid":"role-candidate-verdict-toggle","data-expanded":b[e.id]?"true":"false",children:b[e.id]?"Hide verdict details":"Why this verdict?"}),"complete"===e.evaluation_status&&(0,Xt.jsx)(MO,{empCandidateId:e.id,accountId:V,roleId:t,activeReviewerCount:W}),"complete"===e.evaluation_status&&VO.has(j)&&(0,Xt.jsx)("button",{type:"button",onClick:()=>P({id:e.id,filename:e.original_filename}),disabled:Boolean(g[e.id])||Boolean(z&&z.limit_reached)||u,title:u?"Re-evaluation only runs on active roles.":z&&z.limit_reached?"Monthly allowance reached (".concat(z.monthly_used," of ").concat(z.monthly_cap,"). Resets ").concat(z.period_ends_at?new Date(z.period_ends_at).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"next period","."):"Dispatch a new evaluation for this candidate. The current NDOR recommendation remains displayed until the new evaluation completes successfully.",className:"text-xs text-slate-300 hover:text-ndor-ink underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded disabled:opacity-50 disabled:cursor-not-allowed disabled:no-underline","data-testid":"role-candidate-reevaluate-btn","data-limit-reached":z&&z.limit_reached?"true":"false","data-lifecycle-blocked":u?"true":"false",children:g[e.id]?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"inline mr-1 h-3 w-3 animate-spin"}),"Re-evaluating\u2026"]}):"Re-evaluate"}),"complete"===e.evaluation_status&&(0,Xt.jsxs)(cp,{children:[(0,Xt.jsx)(dp,{asChild:!0,children:(0,Xt.jsx)("button",{type:"button",disabled:Boolean(N[e.id]),className:"text-xs text-slate-300 hover:text-ndor-ink underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded inline-flex items-center gap-1 disabled:opacity-50","data-testid":"role-candidate-override-trigger",children:N[e.id]?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"h-3 w-3 animate-spin"}),"Updating\u2026"]}
2):(0,Xt.jsxs)(Xt.Fragment,{children:["Override ",(0,Xt.jsx)(Gn,{className:"h-3 w-3"})]})})}),(0,Xt.jsxs)(up,{align:"end",className:"bg-ndor-surface border-ndor-edge","data-testid":"role-candidate-override-menu",children:[(0,Xt.jsx)(pp,{className:"text-[10px] uppercase tracking-wider text-ndor-ink-secondary",children:"Move verdict"}),(0,Xt.jsx)(hp,{}),qO.map(t=>(0,Xt.jsxs)(mp,{disabled:e.governance_status===t.key,onSelect:()=>ee(e.id,t.key),className:"text-xs text-ndor-ink hover:bg-ndor-surface-alt cursor-pointer","data-testid":"role-candidate-override-".concat(t.key),children:[t.label,e.governance_status===t.key?(0,Xt.jsx)("span",{className:"ml-2 text-[9px] uppercase text-ndor-ink-muted",children:"current"}):null]},t.key))]})]})]}),"complete"===e.evaluation_status&&(0,Xt.jsx)(fO,{candidateId:e.id,open:Boolean(b[e.id]),role:a})]},e.id);var n})})}),Array.isArray(m)&&m.length>0&&(0,Xt.jsx)(kO,{roleId:t,items:m}),Array.isArray(m)&&m.length>0&&(0,Xt.jsxs)("p",{className:"text-xs text-slate-300 text-center pt-3 border-t border-ndor-edge","data-testid":"role-candidates-next-action",children:["First assessment is available only from"," ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Eligible for assessment"}),". NDOR recommendations (Shortlist / Review / Reject) are shown in the corresponding result views. Use ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Override"})," on a row to record an employer decision."]})]}),(0,Xt.jsx)(aS,{open:null!==T,onOpenChange:e=>{e||P(null)},children:(0,Xt.jsxs)(oS,{className:"bg-ndor-surface border-ndor-edge","data-testid":"role-candidate-reevaluate-confirm",children:[(0,Xt.jsxs)(lS,{children:[(0,Xt.jsx)(dS,{className:"text-ndor-ink",children:"Re-evaluate this dossier?"}),(0,Xt.jsxs)(uS,{className:"text-ndor-ink-secondary space-y-2",children:[(0,Xt.jsxs)("span",{className:"block",children:["A new NDOR evaluation will be dispatched for",(0,Xt.jsxs)("span",{className:"font-medium text-ndor-ink",children:[" ",null===T||void 0===T?void 0:T.filename]}),". It will consume one evaluation from your monthly allowance."]}),(0,Xt.jsx)("span",{className:"block",children:"The current authoritative recommendation and result view remain in place until the new evaluation completes successfully. Historical evaluations are preserved and never overwritten."})]})]}),(0,Xt.jsxs)(cS,{children:[(0,Xt.jsx)(pS,{className:"border-ndor-edge text-ndor-ink-secondary hover:bg-ndor-surface-alt","data-testid":"role-candidate-reevaluate-cancel",children:"Cancel"}),(0,Xt.jsx)(mS,{className:"bg-slate-500/30 border border-slate-500/60 text-ndor-ink hover:bg-slate-500/40",onClick:()=>{const e=null===T||void 0===T?void 0:T.id;P(null),e&&$(e,!0)},"data-testid":"role-candidate-reevaluate-confirm-btn",children:"Re-evaluate"})]})]})}),(0,Xt.jsx)(aS,{open:null!==D,onOpenChange:e=>{e||(C(null),F(""))},children:(0,Xt.jsxs)(oS,{className:"bg-ndor-surface border-ndor-edge max-w-lg","data-testid":"governance-decision-surface",children:[(0,Xt.jsxs)(lS,{children:[(0,Xt.jsx)(dS,{className:"text-ndor-ink",children:"Record employer decision"}),(0,Xt.jsxs)(uS,{className:"text-ndor-ink-secondary space-y-2",children:[(0,Xt.jsxs)("span",{className:"block",children:["Recording ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:null===D||void 0===D?void 0:D.target})," for",(0,Xt.jsxs)("span",{className:"font-medium text-ndor-ink",children:[" ",null===D||void 0===D?void 0:D.candidateName]}),"."]}),(null===D||void 0===D?void 0:D.ndorVerdict)&&(0,Xt.jsxs)("span",{className:"block text-xs",children:["NDOR recommendation for this candidate:",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink ml-1",children:D.ndorVerdict}),"."]}),D&&Q(D.ndorVerdict,D.target)&&(0,Xt.jsx)("span",{className:"block text-xs text-amber-300","data-testid":"decision-divergence-hint",children:"This decision materially diverges from NDOR\u2019s recommendation. A rationale of at least 100 characters is required."})]})]}),(0,Xt.jsxs)("div",{className:"space-y-3 py-2",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"block text-xs uppercase tracking-wider text-ndor-ink-secondary mb-1",htmlFor:"decision-reason-select",children:"Decision reason"}),(0,Xt.jsxs)("select",{id:"decision-reason-select","data-testid":"decision-reason-select",className:"w-full bg-ndor-surface-alt border border-ndor-edge rounded px-2 py-1.5 text-sm text-ndor-ink",value:A,onChange:e=>S(e.target.value),children:[(0,Xt.jsx)("option",{value:"ndor_recommendation_accepted",children:"NDOR recommendation accepted"}),(0,Xt.jsx)("option",{value:"ndor_recommendation_overruled",children:"NDOR recommendation overruled"}),(0,Xt.jsx)("option",{value:"reviewer_evidence_accepted",children:"Reviewer evidence accepted"}),(0,Xt.jsx)("option",{value:"post_interview",children:"Post-interview"}),(0,Xt.jsx)("option",{value:"other",children:"Other"})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("label",{className:"block text-xs uppercase tracking-wider text-ndor-ink-secondary mb-1",htmlFor:"decision-note-textarea",children:"Rationale"}),(0,Xt.jsx)("textarea",{id:"decision-note-textarea","data-testid":"decision-note-textarea",className:"w-full h-28 bg-ndor-surface-alt border border-ndor-edge rounded px-2 py-1.5 text-sm text-ndor-ink resize-none",value:E,onChange:e=>F(e.target.value.slice(0,2e3)),placeholder:"Explain the decision. Required for divergent decisions (min 100 characters)."}),(0,Xt.jsx)("div",{className:"mt-1 flex items-center justify-between text-xs","data-testid":"decision-note-counter",children:(()=>{const e=E.trim().length,t=!!D&&Q(D.ndorVerdict,D.target),n=t?100:0,a=t&&e<n?"text-amber-300":"text-ndor-ink-secondary";return(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("span",{className:a,children:[e,"/",t?"\u2265100":"2000"," characters"]}),t&&(0,Xt.jsxs)("span",{className:a,children:[Math.max(0,n-e)," more required"]})]})})()})]})]}),(0,Xt.jsxs)(cS,{children:[(0,Xt.jsx)(pS,{className:"border-ndor-edge text-ndor-ink-secondary hover:bg-ndor-surface-alt","data-testid":"decision-surface-cancel",disabled:R,children:"Cancel"}),(0,Xt.jsx)(mS,{className:"bg-emerald-500/30 border border-emerald-500/60 text-ndor-ink hover:bg-emerald-500/40",onClick:e=>{e.preventDefault(),Z()},"data-testid":"decision-surface-submit",disabled:R||D&&Q(D.ndorVerdict,D.target)&&E.trim().length<100,children:"Record decision"})]})]})})]})}const JO={no_reviewers:"Awaiting reviewer routing",incomplete:"Awaiting additional review",all_agree:"Consensus reached",majority_advance:"Majority advance",majority_reject:"Majority reject",split:"Split review"},$O={no_reviewers:"border-ndor-edge bg-ndor-surface-alt/60 text-ndor-ink-muted",incomplete:"border-amber-500/40 bg-amber-500/10 text-amber-200",all_agree:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200",majority_advance:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200",majority_reject:"border-rose-500/40 bg-rose-500/10 text-rose-200",split:"border-sky-500/40 bg-sky-500/10 text-sky-200"};function XO(e){let{roleId:t}=e;
2const[n,a]=(0,s.useState)(!0),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(0),[u,m]=(0,s.useState)(0),[p,h]=(0,s.useState)(0),[f,x]=(0,s.useState)(0),[v,g]=(0,s.useState)("no_reviewers"),y=(0,s.useCallback)(async()=>{if(t){a(!0),i(null);try{var e,n,r;const a=await(0,zt.n)("/api/employer/v1/me"),s=null!==(e=null!==(n=null===a||void 0===a||null===(r=a.organisation)||void 0===r?void 0:r.id)&&void 0!==n?n:null===a||void 0===a?void 0:a.account_id)&&void 0!==e?e:null;if(l(s),!s)return d(0),m(0),h(0),x(0),void g("no_reviewers");const[i,o,c]=await Promise.all([MP(s),UP(s,t),VP(s,t)]),u=(i||[]).filter(e=>e.role_id===t&&"active"===e.assignment_status).length,p=(o||[]).filter(e=>"pending"===e.status).length,f=(o||[]).filter(e=>"in_review"===e.status).length,v=(c||[]).length,y=(c||[]).filter(e=>"advance"===e.decision).length,b=(c||[]).filter(e=>"reject"===e.decision).length,w=p+f+v;d(u),m(p),h(f),x(v),g(function(e){let{routed:t,decided:n,advance:a,reject:r}=e;return t?n<t?"incomplete":n===a||n===r?"all_agree":a>n/2?"majority_advance":r>n/2?"majority_reject":"split":"no_reviewers"}({routed:w,decided:v,advance:y,reject:b}))}catch(mK){i((null===mK||void 0===mK?void 0:mK.message)||DP("coverage.fail"))}finally{a(!1)}}},[t]);(0,s.useEffect)(()=>{y()},[y]);const b=c>0,w=u+p+f>0;return(0,Xt.jsxs)(Fy,{"data-testid":"reviewer-coverage-panel",children:[(0,Xt.jsxs)(Ry,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base",children:[(0,Xt.jsx)(Tn,{className:"h-4 w-4"}),DP("coverage.title")]}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",onClick:y,disabled:n,"data-testid":"reviewer-coverage-refresh","aria-label":"Refresh reviewer coverage",children:n?(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin"}):(0,Xt.jsx)(Kg,{className:"h-3.5 w-3.5"})})]}),(0,Xt.jsxs)(Py,{className:"space-y-4 text-sm",children:[r&&(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-rose-500/40 bg-rose-500/10 p-2 text-xs text-rose-200","data-testid":"reviewer-coverage-error",children:[(0,Xt.jsx)(ty,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,Xt.jsx)("span",{children:r})]}),n&&!r?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-xs text-slate-300","data-testid":"reviewer-coverage-loading",children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin"}),DP("coverage.loading")]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("dl",{className:"grid grid-cols-4 gap-2 text-center",children:[(0,Xt.jsx)(QO,{testId:"reviewer-coverage-active",label:DP("coverage.active_assignments"),value:c}),(0,Xt.jsx)(QO,{testId:"reviewer-coverage-pending",label:DP("coverage.open.pending"),value:u}),(0,Xt.jsx)(QO,{testId:"reviewer-coverage-in-review",label:DP("coverage.open.in_review"),value:p}),(0,Xt.jsx)(QO,{testId:"reviewer-coverage-decided",label:DP("coverage.decided"),value:f})]}),w&&(0,Xt.jsxs)("div",{className:"rounded-md border px-3 py-2 text-xs ".concat($O[v]||$O.no_reviewers),"data-testid":"reviewer-coverage-consensus","data-consensus":v,children:[(0,Xt.jsx)("span",{className:"uppercase tracking-wide text-[10px] opacity-80",children:DP("coverage.consensus.label")}),(0,Xt.jsx)("span",{className:"ml-1.5",children:JO[v]||v})]}),b?(0,Xt.jsx)("p",{className:"text-xs text-slate-300","data-testid":"reviewer-coverage-help",children:DP("coverage.help")}):(0,Xt.jsx)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-amber-200","data-testid":"reviewer-coverage-empty",children:DP("coverage.empty")}),(0,Xt.jsx)(Rr,{size:"sm",variant:b?"outline":"default",asChild:!0,className:"w-full","data-testid":"reviewer-coverage-cta",disabled:!o,children:(0,Xt.jsxs)(Et,{to:"/employer/reviewers","aria-label":DP(b?"coverage.cta.view_roster":"coverage.cta.assign"),children:[DP(b?"coverage.cta.view_roster":"coverage.cta.assign"),(0,Xt.jsx)(zy,{className:"ml-1.5 h-3.5 w-3.5"})]})})]})]})]})}function QO(e){let{testId:t,label:n,value:a}=e;return(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-bg/40 px-2 py-2","data-testid":t,children:[(0,Xt.jsx)("div",{className:"text-xl font-semibold tabular-nums text-ndor-ink",children:a}),(0,Xt.jsx)("div",{className:"mt-0.5 text-[10px] uppercase tracking-wide text-slate-300",children:n})]})}const ZO=new Set(["role.created","role.updated","role.published","role.closed","role.archived","signal.sent","signal.accepted","signal.declined","signal.deferred"]),eB={"role.created":"Created","role.published":"Published","role.closed":"Closed","role.archived":"Archived","role.updated":"Updated","signal.sent":"Signal sent","signal.accepted":"Signal accepted","signal.declined":"Signal declined","signal.deferred":"Signal deferred"},tB={"role.created":"bg-slate-500/10 text-slate-200 border-slate-500/40","role.published":"bg-emerald-500/10 text-emerald-200 border-emerald-500/40","role.closed":"bg-rose-500/10 text-rose-200 border-rose-500/40","role.archived":"bg-slate-500/10 text-slate-200 border-slate-500/40","role.updated":"bg-amber-500/10 text-amber-200 border-amber-500/40","signal.sent":"bg-blue-500/10 text-blue-200 border-blue-500/40","signal.accepted":"bg-emerald-500/10 text-emerald-200 border-emerald-500/40","signal.declined":"bg-rose-500/10 text-rose-200 border-rose-500/40","signal.deferred":"bg-slate-500/10 text-slate-200 border-slate-500/40"};function nB(e){if(!e)return"\u2014";const t=new Date(e);
2return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function aB(e){let{roleId:t}=e;const[n,a]=(0,s.useState)(!0),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)([]),c=(0,s.useCallback)(async()=>{if(!t)return l([]),void a(!1);a(!0),i(null);try{const e=await async function(){let{roleId:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=await(0,zt.n)("/api/employer/v1/audit?limit=100"),n=Array.isArray(t)?t:t&&Array.isArray(t.rows)?t.rows:[];return e?n.filter(t=>t&&t.role_id===e):n}({roleId:t}),n=(Array.isArray(e)?e:[]).filter(e=>ZO.has(e.action)).sort((e,t)=>{const n=new Date(e.created_at).getTime();return new Date(t.created_at).getTime()-n});l(n)}catch(mK){i((null===mK||void 0===mK?void 0:mK.message)||"Failed to load lifecycle")}finally{a(!1)}},[t]);(0,s.useEffect)(()=>{c()},[c]);const d=function(e){const t=[];let n=null;for(const a of e)"role.updated"===a.action&&"criteria_patch"===(a.payload||{}).surface?n?(n.count+=1,n.last_iso=a.created_at):n={kind:"collapsed",count:1,first_iso:a.created_at,last_iso:a.created_at}:(n&&(t.push(n),n=null),t.push({kind:"event",row:a}));return n&&t.push(n),t}(o);return(0,Xt.jsxs)(Fy,{"data-testid":"lifecycle-timeline-panel",children:[(0,Xt.jsxs)(Ry,{className:"flex flex-row items-center justify-between gap-2",children:[(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base",children:[(0,Xt.jsx)(qb,{className:"h-4 w-4"}),"Lifecycle Timeline"]}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",onClick:c,disabled:n,"data-testid":"lifecycle-timeline-refresh",children:(0,Xt.jsx)(Kg,{className:"h-4 w-4 ".concat(n?"animate-spin":"")})})]}),(0,Xt.jsx)(Py,{children:n?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-sm text-slate-300",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}),"Loading lifecycle\u2026"]}):r?(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-200","data-testid":"lifecycle-timeline-error",children:[(0,Xt.jsx)(Oy,{className:"mt-0.5 h-4 w-4"}),(0,Xt.jsx)("div",{children:r})]}):0===d.length?(0,Xt.jsx)("div",{className:"text-sm text-slate-300","data-testid":"lifecycle-timeline-empty",children:"No lifecycle events yet."}):(0,Xt.jsx)("ol",{className:"space-y-3","data-testid":"lifecycle-timeline-list",children:d.map((e,t)=>{if("collapsed"===e.kind)return(0,Xt.jsxs)("li",{className:"flex items-start gap-3 text-sm","data-testid":"lifecycle-timeline-collapsed-criteria",children:[(0,Xt.jsx)(pg,{className:"mt-0.5 h-4 w-4 text-amber-300"}),(0,Xt.jsxs)("div",{className:"space-y-0.5",children:[(0,Xt.jsxs)("div",{className:"font-medium text-slate-100",children:["Criteria refined ",e.count,"\xd7 since publish"]}),(0,Xt.jsxs)("div",{className:"text-xs text-slate-300",children:["Last: ",nB(e.last_iso)]})]})]},"collapsed-".concat(t));const n=e.row,a=eB[n.action]||n.action,r=tB[n.action]||"bg-slate-500/10 text-slate-200 border-slate-500/40",s=n.payload||{},i=!0===s.plan_unactivated,o=!0===s.counter_incremented?"counter +1":!0===s.counter_decremented?"counter -1":null,l=s.from&&s.to?"".concat(s.from," \u2192 ").concat(s.to):null;return(0,Xt.jsxs)("li",{className:"flex items-start gap-3 text-sm","data-testid":"lifecycle-timeline-row-".concat(n.action),children:[(0,Xt.jsx)(Vw,{className:"".concat(r," border"),children:a}),(0,Xt.jsxs)("div",{className:"space-y-0.5",children:[l?(0,Xt.jsx)("div",{className:"font-medium text-slate-100",children:l}):(0,Xt.jsx)("div",{className:"font-medium text-slate-100",children:a}),(0,Xt.jsx)("div",{className:"text-xs text-slate-300",children:nB(n.created_at)}),i||o?(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-1 pt-1",children:[i?(0,Xt.jsx)(Vw,{className:"bg-amber-500/10 text-amber-200 border border-amber-500/40","data-testid":"lifecycle-chip-plan-unactivated",children:"plan unactivated"}):null,o?(0,Xt.jsx)(Vw,{className:"bg-slate-500/10 text-slate-200 border border-slate-500/40",children:o}):null]}):null]})]},n.id)})})})]})}const rB=[{icon:Kn,title:"NDORFlow surfaces candidates",body:"Anonymous, role-scoped matches are produced from your role definition and the wider set of eligible candidates. Identity is not revealed at this stage."},{icon:Dn,title:"You express interest",body:"For candidates worth a closer look, you send a structured interest signal \u2014 visible to the candidate, but PII-free in y
2our view."},{icon:DR,title:"The candidate decides",body:"The candidate accepts, declines, or defers. Their identity is shared with you only on explicit acceptance, scoped to this role."},{icon:Bn,title:"You review revealed profiles",body:"Approved profile fields appear inline \u2014 name, headline, location, current role, summary, skills. No contact details. No CV download. Auditable by design."}];function sB(e){let{roleId:t}=e;const{isOperator:n}=pn(),a=n;return(0,Xt.jsxs)("div",{className:"space-y-5","data-testid":"surfaced-candidates-placeholder",children:[(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"surfaced-candidates-preview-card",children:(0,Xt.jsx)(Py,{className:"px-5 py-5 sm:px-6 sm:py-6",children:(0,Xt.jsxs)("div",{className:"flex items-start gap-4",children:[(0,Xt.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-lg border border-ndor-edge bg-ndor-surface-alt/60 flex items-center justify-center","aria-hidden":!0,children:(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-ndor-ink-secondary"})}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,Xt.jsx)("h2",{className:"text-base font-semibold text-ndor-ink tracking-tight",children:"NDOR-Surfaced Candidates"}),(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge bg-ndor-surface-alt/60 text-[10px] uppercase tracking-[0.14em] text-ndor-ink-secondary","data-testid":"surfaced-candidates-preview-pill",children:"Available for enabled workspaces"})]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed",children:"NDORFlow can surface anonymous, role-scoped candidate matches at publish time and let you express interest before any identity is shared. This capability is built and live \u2014 it activates per workspace via an entitlement gate."})]})]})})}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3","data-testid":"surfaced-candidates-roadmap",children:rB.map((e,t)=>{const n=e.icon;return(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-bg/40 px-4 py-4 space-y-2","data-testid":"surfaced-candidates-roadmap-stage-".concat(t+1),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(n,{className:"h-4 w-4 text-ndor-ink-secondary","aria-hidden":!0}),(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink",children:[t+1,". ",e.title]})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:e.body})]},e.title)})}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed text-center pt-2","data-testid":"surfaced-candidates-disclaimer",children:"Until this is enabled for your workspace, evidence-led decisions are made through Imported Candidates \u2014 the surface live for your workspace today."}),a?(0,Xt.jsxs)("div",{className:"rounded-md border border-dashed border-ndor-edge bg-ndor-surface-alt/40 px-4 py-3 text-[11px] text-ndor-ink-muted","data-testid":"surfaced-candidates-operator-note",children:[(0,Xt.jsx)("span",{className:"font-mono uppercase tracking-[0.18em] text-[10px] text-ndor-ink-secondary mr-2",children:"Operator"}),"Operator preview access is enabled internally. The anonymous matches surface lives at"," ",(0,Xt.jsxs)("code",{className:"font-mono text-ndor-ink",children:["/employer/roles/",t||":id","/matches"]})," ","and is not exposed to other employer accounts."]}):null]})}function iB(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}const oB={accepted:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200",pending:"border-amber-500/40 bg-
2amber-500/10 text-amber-200",declined:"border-rose-500/40 bg-rose-500/10 text-rose-200",deferred:"border-blue-500/40 bg-blue-500/10 text-blue-200"};function lB(e){let{signal:t}=e;if(!t)return null;const n=t.status||"pending";return(0,Xt.jsxs)(Vw,{variant:"outline",className:"uppercase tracking-wider text-[10px] ".concat(oB[n]||"border-ndor-edge bg-ndor-surface-alt/60 text-ndor-ink-secondary"),"data-testid":"surfaced-match-signal-".concat(n),children:["Signal ",n]})}function cB(e){let{poolSummary:t}=e;if(!t||!t.diagnostics)return null;const n=t.diagnostics,a=n.no_primary_cv,r=n.empty_parsed_text||0,s=n.has_usable_profile||0,i=n.domain_match||0,o=n.working_model_compatible||0,l=n.location_compatible||0,c=n.eligible_total||0,d=n.pool_size||0;let u=null;return 0===d?u="No discoverable candidate profiles in the pool yet.":null!==a&&void 0!==a&&a>=d?u="None of the ".concat(d," discoverable candidates have uploaded a Source CV. Matching can begin once at least one candidate marks a Source CV as primary."):null!==a&&void 0!==a&&a>0&&0===c?u="".concat(a," of ").concat(d," candidates have no primary Source CV. Without parsed CV text, eligibility cannot be scored."):r>0&&0===c?u="".concat(r," candidate(s) have a primary CV but no parsed text yet. Re-parsing or re-upload would unblock matching."):0===s&&d>0?u="No candidates in the pool have a usable profile (skills or primary domain).":0===i&&d>0?u="No candidates match the role's primary domain. Broadening the must-have domain may surface more.":0===o&&d>0?u="No candidates are compatible with the role's working model.":0===l&&d>0&&(u="No candidates are within the role's location constraint."),(0,Xt.jsxs)("div",{className:"rounded border border-amber-500/20 bg-amber-500/5 px-3 py-3 space-y-2","data-testid":"role-surfaced-pool-diagnostic",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 mt-0.5 text-amber-300 shrink-0"}),(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsx)("p",{className:"font-medium text-ndor-ink",children:"Why no matches yet?"}),u&&(0,Xt.jsx)("p",{className:"mt-1","data-testid":"role-surfaced-pool-diagnostic-summary",children:u})]})]}),(0,Xt.jsxs)("dl",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-4 gap-y-1 text-[11px] text-ndor-ink-muted pl-5",children:[(0,Xt.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,Xt.jsx)("dt",{children:"Pool size"}),(0,Xt.jsx)("dd",{"data-testid":"diag-pool-size",className:"text-ndor-ink",children:d})]}),null!==a&&void 0!==a&&(0,Xt.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,Xt.jsx)("dt",{children:"No primary CV"}),(0,Xt.jsx)("dd",{"data-testid":"diag-no-primary-cv",className:"text-ndor-ink",children:a})]}),(0,Xt.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,Xt.jsx)("dt",{children:"Empty parsed text"}),(0,Xt.jsx)("dd",{"data-testid":"diag-empty-parsed-text",className:"text-ndor-ink",children:r})]}),(0,Xt.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,Xt.jsx)("dt",{children:"Domain match"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:i})]}),(0,Xt.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,Xt.jsx)("dt",{children:"Working model OK"}),(0,Xt.jsx)("dd",{className:"text-ndor-ink",children:o})]}),(0,Xt.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,Xt.jsx)("dt",{children:"Eligible total"}),(0,Xt.jsx)("dd",{"data-testid":"diag-eligible-total",className:"text-ndor-ink",children:c})]})]})]})}function dB(e){let{revealed:t,matchId:n}=e;if(!t)return null;const a=Array.isArray(t.skills)?t.skills.slice(0,12):[],r=[t.current_job_title,t.current_company].filter(Boolean).join(" \xb7 "),s=[t.location,t.years_experience?"".concat(t.years_experience," yrs experience"):null,t.primary_domain].filter(Boolean).join(" \xb7 ");return(0,Xt.jsxs)("div",{className:"mt-3 rounded border border-emerald-500/20 bg-emerald-500/[0.04] px-4 py-3 space-y-2","data-testid":"surfaced-reveal-panel-".concat(n),children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-[0.14em] text-emerald-200/80",children:"Revealed profile"}),t.full_name&&(0,Xt.jsx)("div",{className:"text-sm font-semibold text-ndor-ink","data-testid":"surfaced-reveal-name-".concat(n),children:t.full_name}),t.headline&&(0,Xt.jsx)("div",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:t.headline}),r&&(0,Xt.jsx)("div",{className:"text-xs text-ndor-ink-secondary",children:r}),s&&(0,Xt.jsx)("div",{className:"text-[11px] text-ndor-ink-muted",children:s}),t.summary&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed pt-1 border-t border-emerald-500/10",children:t.summary}),a.length>0&&(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5 pt-1",children:a.map(e=>(0,Xt.jsx)(Vw,{variant:"outline",className:"border-ndor-edge bg-ndor-surface-alt/40 text-[10px] text-ndor-ink-secondary",children:e},e))}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted italic pt-1",children:"Candidate identity and profile context become visible only after acceptance. Contact details are never exposed by this
2surface."})]})}function uB(e){let{roleId:t,accountId:n,signalsRemaining:a,signalsAllowance:r,onSignalSent:i}=e;const[o,l]=(0,s.useState)(null),[d,u]=(0,s.useState)({}),[m,p]=(0,s.useState)(null),[h,f]=(0,s.useState)(null),[x,v]=(0,s.useState)(0),[g,y]=(0,s.useState)({}),[b,w]=(0,s.useState)(n||null),[j,k]=(0,s.useState)(0),[N,_]=(0,s.useState)(null),D=(0,s.useCallback)(async()=>{try{let s=n||null;if(!s){var e,a,r;const t=await(0,zt.n)("/api/employer/v1/me");s=null!==(e=null!==(a=null===t||void 0===t||null===(r=t.organisation)||void 0===r?void 0:r.id)&&void 0!==a?a:null===t||void 0===t?void 0:t.account_id)&&void 0!==e?e:null}if(w(s),!s)return void k(0);const i=(await MP(s)||[]).filter(e=>e.role_id===t&&"active"===e.assignment_status).length;k(i)}catch(s){k(0)}},[t,n]),C=(0,s.useCallback)(async()=>{p(null);try{const[e,n]=await Promise.all([(0,zt.n)("/api/employer/roles/".concat(t,"/matches?limit=200")).catch(e=>{throw e}),(0,zt.n)("/api/employer/roles/".concat(t,"/signals")).catch(()=>({signals_by_match:{}}))]);l(Array.isArray(null===e||void 0===e?void 0:e.matches)?e.matches:[]),u((null===n||void 0===n?void 0:n.signals_by_match)||{}),_((null===e||void 0===e?void 0:e.pool_summary)||null)}catch(pK){var e,n,a;const r=(null===pK||void 0===pK||null===(e=pK.data)||void 0===e||null===(n=e.detail)||void 0===n?void 0:n.message)||(null===pK||void 0===pK||null===(a=pK.data)||void 0===a?void 0:a.message)||(null===pK||void 0===pK?void 0:pK.message)||"Unable to load Surfaced Candidates.";p(r),l([])}},[t]);(0,s.useEffect)(()=>{C()},[C,x]),(0,s.useEffect)(()=>{D()},[D,x]);const A=(0,s.useMemo)(()=>null===a||void 0===a?null:Number(a),[a]);return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-surfaced-candidates-panel",children:[(0,Xt.jsxs)(Ry,{className:"px-6 pt-6 pb-3 flex flex-row items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)(Iy,{className:"text-base font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4 text-slate-300"}),"Surfaced Candidates"]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1 leading-relaxed max-w-prose",children:"Anonymous matches against your role. Sending a signal expresses governed interest; identity is revealed only after the candidate accepts."})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[null!==A&&(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-ndor-edge bg-ndor-surface-alt/60 text-[10px] uppercase tracking-[0.14em] text-ndor-ink-secondary","data-testid":"surfaced-signals-remaining",children:["Signals remaining ",A,null!==r&&void 0!==r?" / ".concat(r):""]}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>v(e=>e+1),"aria-label":"Refresh","data-testid":"role-surfaced-refresh",className:"h-8 w-8 p-0",children:(0,Xt.jsx)(Kg,{className:"h-4 w-4"})})]})]}),(0,Xt.jsxs)(Py,{className:"px-6 pb-6 space-y-3",children:[m&&(0,Xt.jsxs)("div",{className:"text-xs text-rose-400 flex items-start gap-2 bg-rose-500/5 border border-rose-500/20 rounded px-3 py-2","data-testid":"role-surfaced-error",children:[(0,Xt.jsx)(ty,{className:"h-3.5 w-3.5 mt-0.5"}),(0,Xt.jsx)("span",{children:m})]}),null===o&&(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-xs text-slate-300 py-6 justify-center",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}),"Loading\u2026"]}),Array.isArray(o)&&0===o.length&&!m&&(0,Xt.jsxs)("div",{className:"text-center py-8 space-y-3","data-testid":"role-surfaced-empty",children:[(0,Xt.jsx)(Dn,{className:"h-6 w-6 text-slate-400 mx-auto"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink font-medium",children:"No matches surfaced yet."}),(0,Xt.jsx)("p",{className:"text-xs text-slate-200 leading-relaxed max-w-md mx-auto",children:"Surfaced Candidates are produced by the institutional matching workflow. Once your role has been published and the discoverable pool has been evaluated, anonymous matches will appear here."}),(0,Xt.jsx)("div",{className:"text-left max-w-md mx-auto",children:(0,Xt.jsx)(cB,{poolSummary:N})})]}),Array.isArray(o)&&o.length>0&&(0,Xt.jsx)("ul",{className:"space-y-2","data-testid":"role-surfaced-list",children:o.map((e,n)=>{const a=d[e.id]||null,r=e.revealed_profile||null,s=null!==e.fit_score&&void 0!==e.fit_score?Math.round(100*e.fit_score):null,i=!!g[e.id];return(0,Xt.jsxs)("li",{className:"rounded border border-ndor-edge bg-ndor-surface-alt/30 px-4 py-3","data-testid":"role-surfaced-row-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsxs)("span",{className:"text-sm font-medium text-ndor-ink tabular-nums",children:["Match ",String(n+1).padStart(3,"0")]}),r?(0,Xt.jsxs)(Vw,{variant:"outline",className:"border-emerald-500/40 bg-emerald-500/10 text-emerald-200 uppercase tracking-wider text-[10px]","data-testid":"surfaced-revealed-".concat(e.id),children:[(0,Xt.jsx)(DR,{className:"h-3 w-3 mr-1"}),r.full_name||"Identity revealed"]}):null,(0,Xt.jsx)(lB,{signal:a})]}),(0,Xt.jsxs)("div",{className:"mt-1 flex items-center gap-3 flex-wrap text-[11px] text-ndor-ink-secondary",children:[null!==s&&(0,Xt.jsxs)("span",{"data-testid":"surfaced-fit-".concat(e.id),children:["Fit ",s,"%"]}),e.surfaced_at&&(0,Xt.jsxs)("span",{children:["Surfaced ",iB(e.surfaced_at)]}),(null===a||void 0===a?void 0:a.sent_at)&&(0,Xt.jsxs)("span",{"data-testid":"surfaced-sent-at-".concat(e.id),children:["Sent ",iB(a.sent_at)]}),(null===a||void 0===a?void 0:a.responded_at)&&(0,Xt.jsxs)("span",{"data-testid":"surfaced-responded-at-".concat(e.id),children:["accepted"===a.status?"Accepted":"declined"===a.status?"Declined":"deferred"===a.status?"Deferred":"Responded"," ",iB(a.responded_at)]})]})]}),(0,Xt.jsxs)("div",{className:"flex-shrink-0 flex items-center gap-1",children:[r&&e.candidate_id&&"accepted"===(null===a||void 0===a?void 0:a.status)&&(0,Xt.jsx)(MO,{matchId:e.id,candidateId:e.candidate_id,accountId:b,roleId:t,activeReviewerCount:j,onRouted:()=>v(e=>e+1)}),r&&(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:()=>y(t=>(0,c.A)((0,c.A)({},t),{},{[e.id]:!t[e.id]})),className:"text-xs h-8","data-testid":"surfaced-reveal-toggle-".concat(e.id),"aria-expanded":i,"aria-label":i?"Collapse profile":"View profile context",children:[(0,Xt.jsx)(Gn,{className:"h-3.5 w-3.5 mr-1.5 transition-transform duration-150 ".concat(i?"rotate-180":"")}),i?"Hide profile":"View profile"]}),!a&&(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:()=>((e,t)=>{const n=String((null!==t&&void 0!==t?t:0)+1).padStart(3,"0");f({matchId:e.id,label:n,body:"",busy:!1})})(e,n),disabled:null!==A&&A<=0,className:"text-xs h-8","data-testid":"role-surfaced-send-".concat(e.id),children:[(0,Xt.jsx)(_
2n,{className:"h-3.5 w-3.5 mr-1.5"}),"Send signal"]})]})]}),i&&r&&(0,Xt.jsx)(dB,{revealed:r,matchId:e.id})]},e.id)})}),h&&(0,Xt.jsxs)("div",{className:"rounded border border-ndor-edge bg-ndor-bg/60 px-4 py-3 space-y-2","data-testid":"role-surfaced-composer",children:[(0,Xt.jsx)("div",{className:"text-xs text-ndor-ink-secondary uppercase tracking-wider",children:"Compose signal \xb7 governed expression of interest"}),(0,Xt.jsx)(Hw,{value:h.body,onChange:e=>f(t=>(0,c.A)((0,c.A)({},t),{},{body:e.target.value})),maxLength:800,rows:3,placeholder:"A short, institutional note about why this role would suit them. The candidate sees only this text \u2014 no recruiter identity, no contact details.",className:"text-sm bg-ndor-bg text-ndor-ink placeholder:text-ndor-ink-muted border-ndor-edge focus-visible:ring-1 focus-visible:ring-ndor-glow","data-testid":"role-surfaced-composer-input",disabled:h.busy}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between text-[11px] text-ndor-ink-muted",children:[(0,Xt.jsxs)("span",{children:[h.body.length,"/800"]}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)(Oy,{className:"h-3 w-3 inline mr-1"}),"Sending consumes one of your monthly signals."]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",onClick:()=>f(null),disabled:h.busy,"data-testid":"role-surfaced-composer-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{size:"sm",onClick:async()=>{if(h&&h.body.trim()){f(e=>(0,c.A)((0,c.A)({},e),{},{busy:!0}));try{const e=await(0,zt.n)("/api/employer/roles/".concat(t,"/matches/").concat(h.matchId,"/signal"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({signal_body:h.body})}),n=h.label?" \xb7 Match ".concat(h.label):"";if(null!==e&&void 0!==e&&e.already_sent?fy.warning("A signal for this match is already pending".concat(n,".")):fy.success("Signal sent".concat(n)),f(null),v(e=>e+1),"function"===typeof i)try{i(e)}catch(d){}}catch(pK){var e,n,a,r,s,o,l;const i=(null===pK||void 0===pK?void 0:pK.status)||(null===pK||void 0===pK||null===(e=pK.data)||void 0===e?void 0:e.status),d=(null===pK||void 0===pK||null===(n=pK.data)||void 0===n||null===(a=n.detail)||void 0===a?void 0:a.code)||(null===pK||void 0===pK?void 0:pK.code)||"SIGNAL_FAILED",u=(null===pK||void 0===pK||null===(r=pK.data)||void 0===r||null===(s=r.detail)||void 0===s?void 0:s.message)||(null===pK||void 0===pK||null===(o=pK.data)||void 0===o?void 0:o.detail)||(null===pK||void 0===pK||null===(l=pK.data)||void 0===l?void 0:l.message)||(null===pK||void 0===pK?void 0:pK.message)||"Signal failed.";if(409===i||/already granted|already accepted/i.test(String(u)))return fy.info("This match already has an accepted signal. No new signal was sent."),f(null),void v(e=>e+1);fy.error("".concat(d,": ").concat("string"===typeof u?u:"Signal failed.")),f(e=>e?(0,c.A)((0,c.A)({},e),{},{busy:!1}):e)}}},disabled:h.busy||!h.body.trim(),"data-testid":"role-surfaced-composer-send",children:h.busy?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Sending\u2026"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(_n,{className:"h-3.5 w-3.5 mr-1.5"}),"Send signal"]})})]})]})]})]})}const mB=Object.freeze({enabled:!1,signals_allowance:null,signals_used:null,signals_remaining:null});function pB(){const[e,t]=(0,s.useState)((0,c.A)((0,c.A)({},mB),{},{loading:!0})),n=(0,s.useCallback)(async()=>{try{var e,n,a;const r=await(0,zt.n)("/api/employer/v1/me"),s=(null===r||void 0===r?void 0:r.channel_2)||mB;t({enabled:Boolean(s.enabled),signals_allowance:null!==(e=s.signals_allowance)&&void 0!==e?e:null,signals_used:null!==(n=s.signals_used)&&void 0!==n?n:null,signals_remaining:null!==(a=s.signals_remaining)&&void 0!==a?a:null,loading:!1})}catch(r){t((0,c.A)((0,c.A)({},mB),{},{loading:!1}))}},[]);return(0,s.useEffect)(()=>{n()},[n]),(0,c.A)((0,c.A)({},e),{},{refresh:n})}function hB(e){let{role:t,refreshToken:n=0,integrityFilterRequest:a=null,onIntegrityFilterApplied:r=null}=e;const[i,o]=(0,s.useState)("uploaded"),[l,c]=(0,s.useState)(null),d=pB();(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{var t;const n=await(0,zt.n)("/api/employer/v1/me"),a=(null===n||void 0===n||null===(t=n.organisation)||void 0===t?void 0:t.name)||null;e||c(a)}catch(n){e||c(null)}})(),()=>{e=!0}},[]);const u=function(e){if(!e||"string"!==typeof e)return null;const t=e.trim();return t?t.split(/\s+/)[0]:null}(l),m=u?"".concat(u," Imported Candidates"):"Imported Candidates",p=l?"".concat(l," Imported Candidates"):"Imported Candidates";return(0,Xt.jsx)("div",{"data-testid":"role-candidates-workspace",children:(0,Xt.jsxs)(tI,{value:i,onValueChange:o,className:"w-full",children:[(0,Xt.jsxs)(nI,{className:"bg-ndor-bg/40 border border-ndor-edge p-1 gap-1 h-auto","data-testid":"candidates-subtabs",children:[(0,Xt.jsx)(aI,{value:"uploaded","data-testid":"candidates-subtab-uploaded","aria-label":p,title:p,className:"text-[11px] sm:text-xs font-medium uppercase tracking-wider text-ndor-ink-secondary data-[state=active]:bg-ndor-surface data-[state=active]:text-ndor-ink data-[state=active]:font-semibold data-[state=active]:shadow-[inset_0_-2px_0_0_#C9A45C] hover:text-ndor-ink transition-colors",children:m}),(0,Xt.jsx)(aI,{value:"surfaced","data-testid":"candidates-subtab-surfaced","aria-label":"NDOR-Surfaced Candidates",title:"NDOR-Surfaced Candidates",className:"text-[11px] sm:text-xs font-medium uppercase tracking-wider text-ndor-ink-secondary data-[state=active]:bg-ndor-surface data-[state=active]:text-ndor-ink data-[state=active]:font-semibold data-[state=active]:shadow-[inset_0_-2px_0_0_#C9A45C] hover:text-ndor-ink transition-colors",children:"NDOR-Surfaced Candidates"})]}),(0,Xt.jsx)(rI,{value:"uploaded",className:"mt-4 focus-visible:outline-none","data-testid":"uploaded-dossiers-panel",children:(0,Xt.jsxs)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3 lg:gap-8",children:[(0,Xt.jsx)("div",{className:"space-y-6 lg:col-span-2 lg:space-y-8",children:(0,Xt.jsx)(YO,{roleId:t.id,roleTitle:t.title,role:t,refreshToken:n,integrityFilterRequest:a,onIntegrityFilterApplied:r})}),(0,Xt.jsxs)("aside",{className:"space-y-6",children:[(0,Xt.jsx)(XO,{roleId:t.id}),(0,Xt.jsx)(aB,{roleId:t.id})]})]})}),(0,Xt.jsx)(rI,{value:"surfaced",className:"mt-4 focus-visible:outline-none","data-testid":"surfaced-candidates-preview",children:d.loading?(0,Xt.jsx)("div",{className:"rounded border border-ndor-edge bg-ndor-surface-alt/30 px-5 py-6 text-sm text-ndor-ink-muted","data-testid":"surfaced-candidates-loading",children:"Loading\u2026"}):d.enabled?(0,Xt.jsx)(uB,{roleId:t.id,accountId:t.org_id||t.account_id||null,signalsRemaining:d.signals_remaining,signalsAllowance:d.signals_allowance,onSignalSent:d.refresh}):(0,Xt.jsx)(sB,{roleId:t.id})})]})})}const fB=Object.freeze({limits:null,loading:!0,error:null});
2function xB(){const[e,t]=(0,s.useState)(fB),n=(0,s.useCallback)(async()=>{t(e=>(0,c.A)((0,c.A)({},e),{},{loading:!0,error:null}));try{const e=await(0,zt.n)("/api/employer/v1/limits");t({limits:e,loading:!1,error:null})}catch(pK){t({limits:null,loading:!1,error:(null===pK||void 0===pK?void 0:pK.message)||"Limits unavailable"})}},[]);return(0,s.useEffect)(()=>{n()},[n]),(0,c.A)((0,c.A)({},e),{},{refresh:n})}function vB(e){return"".concat("emp_bulk_eval:").concat(e,":in_flight")}function gB(){if("undefined"===typeof window||!window.sessionStorage)return null;try{const e="__emp_bulk_marker_probe__";return window.sessionStorage.setItem(e,"1"),window.sessionStorage.removeItem(e),window.sessionStorage}catch(e){return null}}function yB(e){var t,n;let{open:a,onOpenChange:r,roleId:i,candidateIds:o,onDispatched:l,onReviewFlagged:c}=e;const[d,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)(null),[h,f]=(0,s.useState)(null),[x,v]=(0,s.useState)(!1),[g,y]=(0,s.useState)(null),[b,w]=(0,s.useState)(!1),[j,k]=(0,s.useState)(null),N=Array.isArray(o)&&o.length>0;(0,s.useEffect)(()=>{if(!a)return p(null),f(null),y(null),void k(null);let e=!1;return(async()=>{u(!0),f(null);try{const t=await(0,zt.n)("/api/employer/v1/roles/".concat(i,"/evaluate-bulk/preview"),{method:"POST",body:JSON.stringify({candidate_ids:o})});e||p(t)}catch(pK){e||f((null===pK||void 0===pK?void 0:pK.message)||"Preview failed.")}finally{e||u(!1)}})(),(async()=>{w(!0);try{const t=await(0,zt.n)("/api/employer/v1/roles/".concat(i,"/candidates"));if(e)return;const n=Array.isArray(null===t||void 0===t?void 0:t.items)?t.items:[],a={};n.forEach(e=>{e&&e.id&&(a[e.id]={classification:e.integrity_classification||null,disposition:e.integrity_disposition||null,status:e.integrity_status||null})}),y(a)}catch(t){e||y({})}finally{e||w(!1)}})(),()=>{e=!0}},[a,i,o]);const _=Number((null===m||void 0===m?void 0:m.over_bundle)||0),D=Boolean(null===m||void 0===m?void 0:m.would_exceed_cap)||_>0,C=(0,s.useMemo)(()=>{if(!g)return{ready:!1,blocking:!1,unresolved:[],excluded:[],missingCheck:[]};const e=N?o:Object.keys(g),t=[],n=[],a=[];e.forEach(e=>{const r=g[e];r&&("unresolved"===r.classification?t.push(e):"excluded"===r.classification?n.push(e):"missing_check"===r.classification&&a.push(e))});return{ready:!0,blocking:N?t.length+n.length+a.length>0:t.length+a.length>0,unresolved:t,excluded:n,missingCheck:a}},[g,o,N]),A=Boolean(m)&&!d&&!D&&!C.blocking&&!j,S=function(e){if(!e)return null;try{const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}catch(t){return null}}(null===m||void 0===m?void 0:m.period_ends_at),E=(0,s.useMemo)(()=>j||(C.blocking?{unresolved:C.unresolved,excluded:C.excluded,missingCheck:C.missingCheck,mode:N?"explicit_ids":"all_parsed"}:null),[j,C,N]);return(0,Xt.jsx)(rg,{open:a,onOpenChange:r,children:(0,Xt.jsxs)(lg,{className:"sm:max-w-lg bg-ndor-surface border-ndor-edge text-ndor-ink","data-testid":"bulk-eval-confirm-dialog",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"text-base font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(NE,{className:"h-4 w-4 text-ndor-ink-muted"}),"Run bulk evaluation"]}),(0,Xt.jsx)(mg,{className:"text-sm text-ndor-ink-muted leading-relaxed",children:"Evaluations are drawn from your monthly allowance. Beyond-cap dispatches are blocked."})]}),d&&(0,Xt.jsx)("div",{className:"flex items-center justify-center py-6","data-testid":"bulk-eval-preview-loading",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})}),!d&&m&&!1===m.plan_active&&(0,Xt.jsx)("div",{className:"rounded-lg border border-slate-500/40 bg-slate-500/10 p-4 text-sm text-ndor-ink-muted","data-testid":"bulk-eval-plan-inactive",children:"Plan not activated \u2014 contact your administrator to enable evaluation."}),!d&&m&&m.plan_active&&(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"bulk-eval-preview-cards",children:[(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[(0,Xt.jsxs)("div",{className:"rounded-lg border border-emerald-500/40 bg-emerald-500/10 p-4","data-testid":"bulk-eval-within-card",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-emerald-300/80",children:"Within allowance"}),(0,Xt.jsx)("p",{className:"text-2xl font-semibold mt-0.5 text-emerald-300",children:m.within_bundle||0}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted",children:"drawn from monthly cap"})]}),(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge bg-ndor-bg/40 p-4","data-testid":"bulk-eval-used-card",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Used this period"}),(0,Xt.jsx)("p",{className:"text-2xl font-semibold mt-0.5 text-ndor-ink",children:null!==(t=m.monthly_used)&&void 0!==t?t:"\u2014"}),(0,Xt.jsxs)("p",{className:"text-[10px] text-ndor-ink-muted",children:["of ",null!==(n=m.monthly_cap)&&void 0!==n?n:"\u2014"," this period"]})]}),(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge bg-ndor-bg/40 p-4","data-testid":"bulk-eval-reset-card",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Resets"}),(0,Xt.jsx)("p",{className:"text-base font-semibold mt-1 text-ndor-ink",children:S||"\u2014"}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted",children:"next billing period"})]})]}),Number(m.skip_already_complete||0)>0&&(0,Xt.jsxs)("p",{className:"text-[10px] text-ndor-ink-muted","data-testid":"bulk-eval-skip-note",children:[m.skip_already_complete," candidate(s) already evaluated will be skipped."]}),D&&(0,Xt.jsxs)("div",{className:"rounded-lg border border-amber-500/40 bg-amber-500/10 p-4 space-y-2","data-testid":"bulk-eval-blocked-banner",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-amber-100",children:"Monthly evaluation allowance reached."}),(0,Xt.jsxs)("p",{className:"text-xs text-amber-200/90 leading-relaxed",children:["This dispatch would consume ",_," evaluation(s) beyond your current monthly allowance.",S?(0,Xt.jsxs)(Xt.Fragment,{children:[" Your allowance resets on ",(0,Xt.jsx)("span",{className:"font-medium",children:S}),"."]}):null," ","Upgrade your workspace or wait until reset."]}),(0,Xt.jsxs)(Et,{to:"/employer/account?tab=plans",className:"inline-flex items-center gap-1.5 text-xs font-medium text-amber-100 hover:text-amber-50 underline-offset-4 hover:underline","data-testid":"bulk-eval-view-plans-link",onClick:()=>null===r||void 0===r?void 0:r(!1),children:["View plans ",(0,Xt.jsx)(KN,{className:"h-3 w-3"})]})]})]}),b&&!g&&(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted","data-testid":"bulk-eval-integrity-precheck-loading",children:"Checking dossier integrity dispositions\u2026"}),E&&(0,Xt.jsxs)("div",{className:"rounded-lg border border-rose-500/40 bg-rose-500/10 p-4 space-y-3","data-testid":"bulk-eval-integrity-blocker","data-block-source":j?"server"
2:"client","data-block-mode":E.mode,children:[(0,Xt.jsxs)("p",{className:"text-sm font-medium text-rose-100 flex items-center gap-2",children:[(0,Xt.jsx)(mb,{className:"h-4 w-4"}),"all_parsed"===E.mode?"Evaluate All cannot proceed yet.":"The following selected dossiers cannot be evaluated:"]}),"all_parsed"===E.mode?(0,Xt.jsxs)("div",{className:"text-xs text-rose-100/90 leading-relaxed space-y-1",children:[E.unresolved.length>0&&(0,Xt.jsxs)("p",{"data-testid":"bulk-eval-integrity-unresolved-line",children:[(0,Xt.jsx)("span",{className:"font-medium",children:E.unresolved.length})," ","dossier",1===E.unresolved.length?"":"s"," require an Include or Exclude decision before evaluation."]}),E.missingCheck.length>0&&(0,Xt.jsxs)("p",{"data-testid":"bulk-eval-integrity-missing-line",children:[(0,Xt.jsx)("span",{className:"font-medium",children:E.missingCheck.length})," ","dossier",1===E.missingCheck.length?"":"s"," are missing the required integrity check and cannot be evaluated until the check is repaired."]}),E.excluded.length>0&&(0,Xt.jsxs)("p",{className:"text-rose-200/80","data-testid":"bulk-eval-integrity-excluded-context-line",children:[E.excluded.length," ","dossier",1===E.excluded.length?"":"s"," have already been excluded from evaluation."]}),(0,Xt.jsx)("p",{className:"pt-1",children:"Resolve the outstanding decisions below."})]}):(0,Xt.jsxs)("div",{className:"text-xs text-rose-100/90 leading-relaxed space-y-1.5",children:[E.unresolved.length>0&&(0,Xt.jsxs)("p",{"data-testid":"bulk-eval-integrity-unresolved-line",children:[(0,Xt.jsxs)("span",{className:"font-medium",children:["Requires a decision (",E.unresolved.length,"):"]})," ",(0,Xt.jsx)("span",{className:"font-mono text-[11px] break-all","data-testid":"bulk-eval-integrity-unresolved-ids",children:E.unresolved.join(", ")})]}),E.excluded.length>0&&(0,Xt.jsxs)("p",{"data-testid":"bulk-eval-integrity-excluded-line",children:[(0,Xt.jsxs)("span",{className:"font-medium",children:["Already excluded (",E.excluded.length,"):"]})," ",(0,Xt.jsx)("span",{className:"font-mono text-[11px] break-all","data-testid":"bulk-eval-integrity-excluded-ids",children:E.excluded.join(", ")})]}),E.missingCheck.length>0&&(0,Xt.jsxs)("p",{"data-testid":"bulk-eval-integrity-missing-line",children:[(0,Xt.jsxs)("span",{className:"font-medium",children:["Missing integrity check (",E.missingCheck.length,"):"]})," ",(0,Xt.jsx)("span",{className:"font-mono text-[11px] break-all","data-testid":"bulk-eval-integrity-missing-ids",children:E.missingCheck.join(", ")})]}),(0,Xt.jsx)("p",{className:"pt-1 text-rose-100/80",children:"Resolve the decisions or remove the affected dossiers from the selection, then try again."})]}),"function"===typeof c&&(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:()=>{c(),null===r||void 0===r||r(!1)},className:"h-8 text-[11px] border-rose-500/40 text-rose-100 hover:bg-rose-500/10","data-testid":"bulk-eval-integrity-review-cta",children:"Review dossiers awaiting decision"})]}),h&&(0,Xt.jsxs)("div",{className:"text-xs text-rose-400 flex items-start gap-2","data-testid":"bulk-eval-error",children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 mt-0.5"}),(0,Xt.jsx)("span",{children:h})]}),(0,Xt.jsxs)(dg,{className:"gap-2",children:[(0,Xt.jsx)(Rr,{variant:"outline",onClick:()=>null===r||void 0===r?void 0:r(!1),disabled:x,className:"border-ndor-edge text-ndor-ink min-h-9 px-4","data-testid":"bulk-eval-cancel-btn",children:"Cancel"}),(0,Xt.jsx)(Rr,{onClick:async()=>{v(!0),f(null),k(null);try{const e="bulk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,10)),t=await(0,zt.n)("/api/employer/v1/roles/".concat(i,"/evaluate-bulk/dispatch"),{method:"POST",headers:{"Idempotency-Key":e},body:JSON.stringify({candidate_ids:o})});fy.success("Bulk evaluation queued \xb7 ".concat((null===t||void 0===t?void 0:t.count)||o.length," candidate(s)")),null!==t&&void 0!==t&&t.job_id&&function(e,t){if(!e||null===t||void 0===t||!t.jobId)return!1;const n=gB();if(!n)return!1;try{return n.setItem(vB(e),JSON.stringify({schema:1,jobId:t.jobId,accountId:t.accountId||null,dispatchedAt:t.dispatchedAt||Date.now()})),!0}catch(a){return!1}}(i,{jobId:t.job_id,dispatchedAt:Date.now()}),null===l||void 0===l||l(t),null===r||void 0===r||r(!1)}catch(pK){var e;const n=(null===pK||void 0===pK||null===(e=pK.data)||void 0===e?void 0:e.detail)||(null===pK||void 0===pK?void 0:pK.data)||{},a=n.code||(null===pK||void 0===pK?void 0:pK.code)||"DISPATCH_FAILED",r=n.message||(null===pK||void 0===pK?void 0:pK.message)||"Dispatch failed.";"INTEGRITY_DISPOSITION_REQUIRED"===a?(k({unresolved:Array.isArray(n.unresolved)?n.unresolved:[],excluded:Array.isArray(n.excluded)?n.excluded:[],missingCheck:Array.isArray(n.missing_check)?n.missing_check:[],mode:n.mode||(N?"explicit_ids":"all_parsed")}),fy.error("Integrity disposition required for one or more dossiers.")):(f("".concat(a,": ").concat(r)),fy.error("".concat(a,": ").concat(r)))}finally{v(!1)}},disabled:!A||x,className:"bg-blue-500 hover:bg-blue-500/90 text-white min-h-9 px-4","data-testid":"bulk-eval-confirm-btn",title:E?"Integrity disposition required \u2014 resolve the flagged dossiers first.":D?"Monthly allowance reached. Upgrade workspace or wait until ".concat(S||"reset","."):void 0,children:x?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}),"Dispatching\u2026"]}):"Continue"})]})]})})}const bB=[".pdf",".docx",".zip"],wB={parsed:{cls:"bg-emerald-500/10 border-emerald-500/40 text-emerald-300",label:"Parsed"},duplicate:{cls:"bg-amber-500/10 border-amber-500/40 text-amber-300",label:"Duplicate"},parse_failed:{cls:"bg-rose-500/10 border-rose-500/40 text-rose-300",label:"Parse failed"},rejected:{cls:"bg-rose-500/10 border-rose-400/30 text-rose-300/90",label:"Rejected"},budget_exceeded:{cls:"bg-rose-500/10 border-rose-400/30 text-rose-300/90",label:"Budget exceeded"},queued:{cls:"bg-ndor-surface border-ndor-edge text-ndor-ink-muted",label:"Queued"},parsing:{cls:"bg-blue-500/10 border-blue-500/40 text-blue-300",label:"Parsing"},evaluating:{cls:"bg-blue-500/10 border-blue-500/40 text-blue-300",label:"Evaluating"},evaluated:{cls:"bg-emerald-500/10 border-emerald-500/40 text-emerald-300",label:"Evaluated"}};function jB(e){let{status:t}=e;const n=wB[t]||wB.queued;return(0,Xt.jsx)(Vw,{variant:"outline",className:"".concat(n.cls," text-[10px] uppercase tracking-wider"),"data-testid":"bulk-status-pill-".concat(t),children:n.label})}function kB(e){switch(e.item_status){case"parsed":return"Candidate created";case"duplicate":return"Existing candidate returned";
2case"parse_failed":return"Parser failure";case"rejected":return"Rejected at intake";case"budget_exceeded":return"Not processed within batch budget";case"parsing":return"Parsing\u2026";case"queued":return"Queued";default:return"\u2014"}}function NB(e){let{rule:t,label:n,count:a,descriptor:r,testId:s}=e;return(0,Xt.jsxs)("div",{className:"flex items-stretch rounded-lg border border-ndor-edge bg-ndor-surface overflow-hidden","data-testid":s,children:[(0,Xt.jsx)("div",{className:"w-1 ".concat(t)}),(0,Xt.jsxs)("div",{className:"flex-1 p-3",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:n}),(0,Xt.jsx)("p",{className:"mt-1 text-2xl font-semibold text-ndor-ink",children:a}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted",children:r})]})]})}function _B(e){let{files:t,onClear:n,onRemove:a}=e;return t.length?(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":"bulk-pre-upload-list",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted",children:[t.length," file",1===t.length?"":"s"," ready to upload"]}),(0,Xt.jsx)("button",{type:"button",onClick:n,className:"text-[10px] text-ndor-ink-muted hover:text-ndor-ink underline-offset-2 hover:underline","data-testid":"bulk-pre-upload-clear",children:"Clear"})]}),(0,Xt.jsx)("ul",{className:"rounded-md border border-ndor-edge divide-y divide-ndor-edge max-h-48 overflow-y-auto",children:t.map((e,t)=>(0,Xt.jsxs)("li",{className:"px-3 py-2 flex items-center justify-between gap-3",children:[(0,Xt.jsx)("span",{className:"text-xs text-ndor-ink truncate",title:e.name,children:e.name}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,Xt.jsxs)("span",{className:"text-[10px] text-ndor-ink-muted",children:[(e.size/1024).toFixed(1)," KB"]}),(0,Xt.jsx)("button",{type:"button",onClick:()=>a(t),className:"text-[10px] text-ndor-ink-muted hover:text-rose-300","data-testid":"bulk-pre-upload-remove",children:"Remove"})]})]},"".concat(e.name,"-").concat(t)))})]}):null}function DB(e){var t,n,a;let{roleId:r,roleTitle:i,onTerminalSuccess:o,onReviewFlaggedIntegrity:l}=e;const{limits:c,loading:d,error:u,refresh:m}=xB(),p=null!==(t=null===c||void 0===c?void 0:c.upload_per_file_max_bytes)&&void 0!==t?t:null,h=null!==(n=null===c||void 0===c?void 0:c.upload_bulk_max_files)&&void 0!==n?n:null,f=null!==(a=null===c||void 0===c?void 0:c.upload_bulk_max_batch_bytes)&&void 0!==a?a:null,x=null!=p&&null!=h&&null!=f,[v,g]=(0,s.useState)([]),[y,b]=(0,s.useState)(!1),[w,j]=(0,s.useState)(null),[k,N]=(0,s.useState)([]),[_,D]=(0,s.use
2State)(null),C=(0,s.useRef)(null),[A,S]=(0,s.useState)(!1),E=(0,s.useRef)(null),F=(0,s.useRef)(!1),[R,I]=(0,s.useState)(null),[T,P]=(0,s.useState)(!1),O=null!=w,B=w?{parsed:w.parsed_count||0,parse_failed:w.parse_failed_count||0,duplicate:w.duplicate_count||0,rejected:w.rejected_count||0,budget_exceeded:w.budget_exceeded_count||0,pending:(w.total_files||0)-(w.parsed_count||0)-(w.parse_failed_count||0)-(w.duplicate_count||0)-(w.rejected_count||0)-(w.budget_exceeded_count||0)}:{parsed:0,parse_failed:0,duplicate:0,rejected:0,budget_exceeded:0,pending:0},L=(0,s.useCallback)(async e=>{try{const n=await(0,zt.n)("/api/employer/v1/ingestion/batches/".concat(e));if(j((null===n||void 0===n?void 0:n.batch)||null),N((null===n||void 0===n?void 0:n.items)||[]),null!==n&&void 0!==n&&n.batch&&!["queued","running"].includes(n.batch.status)){E.current&&(clearInterval(E.current),E.current=null);if((n.batch.parsed_count||0)>0&&!F.current&&(F.current=!0,"function"===typeof o))try{o(n.batch)}catch(t){}}}catch(pK){D((null===pK||void 0===pK?void 0:pK.message)||"Failed to refresh batch.")}},[o]);(0,s.useEffect)(()=>()=>{E.current&&clearInterval(E.current)},[]),(0,s.useEffect)(()=>{if(!w||"complete"!==w.status||(w.parsed_count||0)<=0)return void I(null);let e=!1;return P(!0),(async()=>{try{const t=new Set((k||[]).filter(e=>"parsed"===e.item_status&&e.candidate_id).map(e=>e.candidate_id)),n=await(0,zt.n)("/api/employer/v1/roles/".concat(r,"/candidates"));if(e)return;const a=Array.isArray(null===n||void 0===n?void 0:n.items)?n.items:[],s=t.size>0?a.filter(e=>t.has(e.id)):a;let i=0,o=0,l=0,c=0;s.forEach(e=>{const t=e.integrity_classification;"clear"===t||"included"===t||"grandfathered_legacy"===t?i+=1:"unresolved"===t?o+=1:"missing_check"===t?l+=1:"excluded"===t&&(c+=1)}),I({total_processed:s.length,ready:i,unresolved:o,missing_check:l,excluded:c})}catch(t){e||I(null)}finally{e||P(!1)}})(),()=>{e=!0}},[w,k,r]);const M=(0,s.useCallback)(e=>{E.current&&clearInterval(E.current),L(e),E.current=setInterval(()=>L(e),1500)},[L]),z=e=>{const t=(e.name||"").toLowerCase();return bB.some(e=>t.endsWith(e))?x?e.size>p&&!t.endsWith(".zip")?"".concat(e.name,": max ").concat(Math.floor(p/1048576)," MB per file."):t.endsWith(".zip")&&e.size>f?"".concat(e.name,": zip exceeds ").concat(Math.floor(f/1048576)," MB."):null:"Server limits unavailable. Refresh and retry.":"Only PDF, DOCX, or ZIP files are supported."};return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-bulk-upload-panel",children:[(0,Xt.jsxs)(Py,{className:"space-y-5 p-5",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h3",{className:"text-base font-semibold text-ndor-ink","data-testid":"bulk-header-title",children:"Batch Intake Session"}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted mt-0.5","data-testid":"bulk-header-subtitle",children:[i?"".concat(i," \xb7 "):"",O?"".concat(w.total_files," CV").concat(1===w.total_files?"":"s"," uploaded"):"Drop CVs to begin"]})]}),(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",disabled:!w||"complete"!==w.status||0===B.parsed,onClick:()=>S(!0),className:"text-[11px] uppercase tracking-wider border-blue-500/40 bg-blue-500/10 text-blue-300 hover:bg-blue-500/20 min-h-9 px-4 disabled:opacity-40 disabled:bg-ndor-surface disabled:text-ndor-ink-muted disabled:border-ndor-edge","data-testid":"bulk-start-evaluation-btn",title:"complete"===(null===w||void 0===w?void 0:w.status)?"Run bulk evaluation on parsed candidates":"Available once a batch completes",children:"Start evaluation"})]}),w?(0,Xt.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2.5","data-testid":"bulk-summary-cards",children:[(0,Xt.jsx)(NB,{rule:"bg-emerald-500",label:"Parsed",count:B.parsed,descriptor:"ready for evaluation",testId:"bulk-summary-parsed"}),(0,Xt.jsx)(NB,{rule:"bg-rose-500",label:"Parse Failed",count:B.parse_failed,descriptor:"need re-upload",testId:"bulk-summary-parse-failed"}),(0,Xt.jsx)(NB,{rule:"bg-amber-500",label:"Duplicates",count:B.duplicate,descriptor:"not recreated",testId:"bulk-summary-duplicate"}),(0,Xt.jsx)(NB,{rule:"bg-blue-500",label:"Pending",count:B.pending+B.budget_exceeded+B.rejected,descriptor:"budget_exceeded"===(null===w||void 0===w?void 0:w.status)?"".concat(B.budget_exceeded," budget-exceeded"):"complete"===(null===w||void 0===w?void 0:w.status)?"intake complete":"in flight",testId:"bulk-summary-pending"})]}):(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted text-center py-2","data-testid":"bulk-summary-cards-placeholder",children:"Bulk intake telemetry appears during active upload sessions."}),w&&"complete"===w.status&&R&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-bg/40 p-3 space-y-1.5","data-testid":"bulk-completion-integrity-summary","data-integrity-ready":R.ready,"data-integrity-unresolved":R.unresolved,"data-integrity-missing-check":R.missing_check,"data-integrity-excluded":R.excluded,children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink font-medium","data-testid":"bulk-completion-
2headline",children:[R.total_processed," candidate",1===R.total_processed?" dossier":" dossiers"," processed"]}),0===R.unresolved&&0===R.missing_check&&0===R.excluded?(0,Xt.jsxs)("p",{className:"text-xs text-emerald-300","data-testid":"bulk-completion-clean-line",children:[R.ready," ready \u2014 no document-integrity indicators detected"]}):(0,Xt.jsxs)("div",{className:"text-xs text-ndor-ink-muted space-y-1","data-testid":"bulk-completion-flagged-block",children:[(0,Xt.jsxs)("p",{"data-testid":"bulk-completion-ready-line",children:[(0,Xt.jsx)("span",{className:"text-emerald-300 font-medium",children:R.ready})," ","ready for evaluation"]}),R.unresolved>0&&(0,Xt.jsxs)("p",{"data-testid":"bulk-completion-review-line",children:[(0,Xt.jsx)("span",{className:"text-amber-300 font-medium",children:R.unresolved})," ","require document review"]}),R.missing_check>0&&(0,Xt.jsxs)("p",{"data-testid":"bulk-completion-missing-line",children:[(0,Xt.jsx)("span",{className:"text-orange-300 font-medium",children:R.missing_check})," ","missing the required integrity check (ops remediation)"]}),R.excluded>0&&(0,Xt.jsxs)("p",{"data-testid":"bulk-completion-excluded-line",children:[(0,Xt.jsx)("span",{className:"text-rose-300 font-medium",children:R.excluded})," ","already excluded from evaluation"]}),(R.unresolved>0||R.missing_check>0)&&"function"===typeof l&&(0,Xt.jsx)("button",{type:"button",onClick:()=>l(),className:"mt-1 inline-flex items-center gap-1 text-[11px] font-medium text-amber-200 hover:text-amber-100 underline-offset-2 hover:underline","data-testid":"bulk-completion-review-cta",children:"\u2192 Review flagged dossiers"}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted pt-1 leading-relaxed",children:"Document review recommended: dossiers with formatting indicators may contain text not normally visible in the submitted documents. Review these dossiers before evaluation."})]})]}),w&&"complete"===w.status&&!R&&T&&(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"bulk-completion-integrity-summary-loading",children:"Checking document-integrity indicators\u2026"}),!w&&(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"bulk-pre-upload-zone",children:[(0,Xt.jsx)("input",{ref:C,type:"file",accept:".pdf,.docx,.zip",multiple:!0,className:"hidden",onChange:e=>{var t;const n=Array.from((null===(t=e.target)||void 0===t?void 0:t.files)||[]);if(e.target.value="",!n.length)return;const a=[];for(const r of n){const e=z(r);e?fy.error(e):a.push(r)}if(!a.length)return;a.some(e=>e.name.toLowerCase().endsWith(".zip"))&&a.length>1?fy.error("Submit either a single ZIP OR multiple files, not both."):g(e=>{const t=[...e,...a];if(x&&t.length>h)return fy.error("Max ".concat(h," files per batch. Extras dropped.")),t.slice(0,h);const n=t.reduce((e,t)=>e+t.size,0);return x&&n>f&&fy.error("Batch exceeds ".concat(Math.floor(f/1048576)," MB total.")),t})},"data-testid":"bulk-file-input"}),(0,Xt.jsxs)("div",{className:"rounded-lg border border-dashed border-ndor-edge p-4 text-center",children:[(0,Xt.jsx)(NE,{className:"mx-auto h-5 w-5 text-ndor-ink-muted"}),(0,Xt.jsx)("p",{className:"mt-2 text-xs text-ndor-ink",children:"Drop PDF, DOCX, or a single ZIP archive."}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted mt-0.5",children:x?(0,Xt.jsxs)(Xt.Fragment,{children:["Up to ",h," files \xb7 max ",Math.floor(p/1048576)," MB/file \xb7 ",Math.floor(f/1048576)," MB total batch."]}):d?(0,Xt.jsx)(Xt.Fragment,{children:"Loading server limits\u2026"}):(0,Xt.jsx)(Xt.Fragment,{children:"Server limits unavailable."})}),u?(0,Xt.jsxs)("p",{className:"text-[10px] text-rose-300 mt-1","data-testid":"bulk-limits-error",children:[u," \xb7"," ",(0,Xt.jsx)("button",{type:"button",className:"underline hover:text-rose-200",onClick:m,children:"Retry"})]}):null,(0,Xt.jsx)(Rr,{onClick:()=>{var e;return null===(e=C.current)||void 0===e?void 0:e.click()},size:"sm",variant:"outline",disabled:!x,className:"mt-3 border-ndor-edge text-ndor-ink disabled:opacity-50","data-testid":"bulk-file-pick-btn",children:"Choose files"})]}),(0,Xt.jsx)(_B,{files:v,onClear:()=>g([]),onRemove:e=>g(t=>
2t.filter((t,n)=>n!==e))}),v.length>0&&(0,Xt.jsx)(Rr,{onClick:async()=>{if(v.length){b(!0),D(null),j(null),N([]),F.current=!1;try{var e;const n=new FormData;for(const e of v)n.append("files",e,e.name);let a;try{a=await(0,zt.n)("/api/employer/v1/roles/".concat(r,"/candidates/upload-bulk"),{method:"POST",body:n})}catch(pK){var t;const n=(null===pK||void 0===pK||null===(t=pK.data)||void 0===t?void 0:t.detail)||(null===pK||void 0===pK?void 0:pK.data)||{},a=n.code||(null===pK||void 0===pK?void 0:pK.code)||"UPLOAD_FAILED",r=n.message||(null===pK||void 0===pK?void 0:pK.message)||"Bulk upload failed.";return fy.error("".concat(a,": ").concat(r)),void D("".concat(a,": ").concat(r))}fy.success("Batch queued \xb7 ".concat((null===(e=a)||void 0===e?void 0:e.total_files)||0," files")),g([]),M(a.batch_id)}finally{b(!1)}}},disabled:y,size:"sm",className:"w-full bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted","data-testid":"bulk-submit-btn",children:y?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}),"Submitting\u2026"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(hb,{className:"mr-2 h-4 w-4"}),"Upload ",v.length," file",1===v.length?"":"s"]})})]}),w&&(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"bulk-upload-results",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h4",{className:"text-sm font-medium text-ndor-ink",children:"Upload Results"}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted mt-0.5",children:"Every file becomes an auditable candidate intake record. No scoring is invented during intake."})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Vw,{variant:"outline",className:"text-[10px] uppercase tracking-wider border-ndor-edge text-ndor-ink-muted","data-testid":"bulk-batch-status",children:w.status}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>{null!==w&&void 0!==w&&w.id&&L(w.id)},"aria-label":"Refresh batch","data-testid":"bulk-refresh",className:"h-7 w-7 p-0",children:(0,Xt.jsx)(Kg,{className:"h-3.5 w-3.5"})})]})]}),(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge overflow-hidden",children:[(0,Xt.jsxs)("div",{className:"grid grid-cols-12 gap-2 px-3 py-2 bg-ndor-bg border-b border-ndor-edge text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:[(0,Xt.jsx)("div",{className:"col-span-5",children:"File"}),(0,Xt.jsx)("div",{className:"col-span-2 text-center",children:"Status"}),(0,Xt.jsx)("div",{className:"col-span-3",children:"Outcome"}),(0,Xt.jsx)("div",{className:"col-span-2 text-right",children:"Detail"})]}),(0,Xt.jsx)("ul",{className:"divide-y divide-ndor-edge max-h-96 overflow-y-auto","data-testid":"bulk-items-list",children:k.map(e=>{return(0,Xt.jsxs)("li",{className:"grid grid-cols-12 gap-2 items-center px-3 py-2.5","data-testid":"bulk-item-row","data-item-status":e.item_status,children:[(0,Xt.jsx)("div",{className:"col-span-5 min-w-0",children:(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink truncate flex items-center gap-1.5",title:e.original_filename,children:[(0,Xt.jsx)(Nn,{className:"h-3.5 w-3.5 text-ndor-ink-muted shrink-0"}),e.original_filename]})}),(0,Xt.jsx)("div",{className:"col-span-2 flex justify-center",children:(0,Xt.jsx)(jB,{status:e.item_status})}),(0,Xt.jsx)("div",{className:"col-span-3 text-[11px] text-ndor-ink-muted truncate",children:kB(e)}),(0,Xt.jsx)("div",{className:"col-span-2 text-[10px] text-ndor-ink-muted text-right truncate",title:e.error_detail||"",children:(t=e,t.parser_used?t.parser_used:t.error_code?t.error_code:"\u2014")})]},e.id);var t})})]}),_&&(0,Xt.jsxs)("div",{className:"text-xs text-rose-400 flex items-start gap-2","data-testid":"bulk-error",children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 mt-0.5"}),(0,Xt.jsx)("span",{children:_})]}),(0,Xt.jsx)("button",{type:"button",onClick:()=>{j(null),N([]),D(null)},className:"text-[11px] text-ndor-ink-muted hover:text-ndor-ink underline-offset-2 hover:underline","data-testid":"bulk-reset",children:"Start a new intake session"})]}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted pt-3 border-t border-ndor-edge leading-relaxed","data-testid":"bulk-footer-rule",children:"Design rule: intake reports operational truth only \u2014 parsed, failed, duplicate, rejected. Evaluation happens later."})]}),(0,Xt.jsx)(yB,{open:A,onOpenChange:S,roleId:r,candidateIds:(k||[]).filter(e=>"parsed"===e.item_status&&e.candidate_id).map(e=>e.candidate_id),onDispatched:()=>{},onReviewFlagged:l})]})}const CB=10485760,AB=[".pdf",".docx"];function SB(e){let{roleId:t,roleTitle:n,onUploadComplete:a,onReviewFlaggedIntegrity:r}=e;
2const[i,o]=(0,s.useState)("single"),[l,c]=(0,s.useState)(!1),d=(0,s.useRef)(null),u=(0,s.useCallback)(async e=>{var n,r;const s=null===(n=e.target)||void 0===n||null===(r=n.files)||void 0===r?void 0:r[0];if(!s)return;e.target.value="";const i=s.name.toLowerCase();if(!AB.some(e=>i.endsWith(e)))return void fy.error("Only PDF and DOCX files are supported.");if(s.size>CB)return void fy.error("Max ".concat(10," MB."));let o;c(!0);try{var l,d;const e=new FormData;e.append("file",s,s.name);try{o=await(0,zt.n)("/api/employer/v1/roles/".concat(t,"/candidates/upload"),{method:"POST",body:e})}catch(pK){var u,m,p,h,f,x;const t=(null===pK||void 0===pK||null===(u=pK.data)||void 0===u||null===(m=u.detail)||void 0===m?void 0:m.code)||(null===pK||void 0===pK||null===(p=pK.data)||void 0===p?void 0:p.code)||(null===pK||void 0===pK?void 0:pK.code)||"UPLOAD_FAILED",n=(null===pK||void 0===pK||null===(h=pK.data)||void 0===h||null===(f=h.detail)||void 0===f?void 0:f.message)||(null===pK||void 0===pK||null===(x=pK.data)||void 0===x?void 0:x.message)||(null===pK||void 0===pK?void 0:pK.message)||"Upload failed.";return void fy.error("".concat(t,": ").concat(n))}if(null!==(l=o)&&void 0!==l&&l.duplicate)fy.warning("This Candidate Dossier is already uploaded to this role.");else if("parsed"===(null===(d=o)||void 0===d?void 0:d.parse_status)){if(fy.success("Uploaded \xb7 parsed ".concat(o.original_filename)),"function"===typeof a)try{a("single")}catch(g){}}else{var v;fy.error("Parse failed: ".concat((null===(v=o)||void 0===v?void 0:v.parse_status)||"unknown"))}}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Upload failed.")}finally{c(!1)}},[t,a]),m=(0,s.useCallback)(()=>{if("function"===typeof a)try{a("bulk")}catch(e){}},[a]);return(0,Xt.jsxs)("div",{className:"space-y-5","data-testid":"role-upload-panel",children:[(0,Xt.jsxs)("div",{className:"inline-flex rounded-md border border-ndor-edge p-0.5 bg-ndor-bg w-full",role:"tablist","aria-label":"Upload mode","data-testid":"role-candidates-upload-mode",children:[(0,Xt.jsx)("button",{type:"button",role:"tab","aria-selected":"single"===i,onClick:()=>o("single"),className:"flex-1 text-[11px] uppercase tracking-wider px-2 py-1.5 rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 ".concat("single"===i?"bg-ndor-ink text-ndor-surface":"text-slate-200 hover:text-ndor-ink"),"data-testid":"role-candidates-mode-single",children:"Single dossier"}),(0,Xt.jsxs)("button",{type:"button",role:"tab","aria-selected":"bulk"===i,onClick:()=>o("bulk"),className:"flex-1 text-[11px] uppercase tracking-wider px-2 py-1.5 rounded flex items-center justify-center gap-1.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 ".concat("bulk"===i?"bg-ndor-ink text-ndor-surface":"text-slate-200 hover:text-ndor-ink"),"data-testid":"role-candidates-mode-bulk",children:[(0,Xt.jsx)(NE,{className:"h-3.5 w-3.5"}),"Bulk dossiers"]})]}),"single"===i&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("input",{ref:d,type:"file",accept:".pdf,.docx",className:"hidden",onChange:u,"data-testid":"role-candidate-upload-input"}),(0,Xt.jsx)(Rr,{onClick:()=>{var e;return null===(e=d.current)||void 0===e?void 0:e.click()},disabled:l,size:"sm",className:"w-full bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted focus-visible:ring-2 focus-visible:ring-blue-400","data-testid":"role-candidate-upload-trigger",children:l?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}),"Uploading\u2026"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(hb,{className:"mr-2 h-4 w-4"}),"Upload Candidate Dossier"]})}),(0,Xt.jsx)("p",{className:"text-xs text-slate-200 mt-2 leading-relaxed",children:"PDF or DOCX \xb7 max 10 MB \xb7 one Candidate Dossier per candidate. Combine CV (required) plus optional cover letter, supporting statement or notes in a single file. Certificates, portfolios and reference letters are not part of an NDORFlow dossier."})]}),"bulk"===i&&(0,Xt.jsx)(DB,{roleId:t,roleTitle:n,onTerminalSuccess:m,onReviewFlaggedIntegrity:r})]})}function EB(e){if(!e)return null;const t=new Date(e);
2return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function FB(e){let{label:t,value:n,fallback:a="Unavailable",testId:r}=e;const s=null===n||void 0===n?a:n;return(0,Xt.jsxs)("div",{className:"flex items-baseline justify-between gap-3 py-1.5",children:[(0,Xt.jsx)("span",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-secondary",children:t}),(0,Xt.jsx)("span",{className:"text-sm font-semibold text-ndor-ink tabular-nums text-right","data-testid":r,children:s})]})}function RB(e){let{role:t}=e;const n=null===t||void 0===t?void 0:t.id,a=pB(),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(0),p=(0,s.useCallback)(async()=>{if(n){d(null);try{const[e,t]=await Promise.all([(0,zt.n)("/api/employer/v1/roles/".concat(n,"/candidates")).catch(()=>null),(0,zt.n)("/api/employer/v1/roles/".concat(n,"/governance-packs")).catch(()=>null)]);i(Array.isArray(null===e||void 0===e?void 0:e.items)?e.items:e?[]:null),l(Array.isArray(null===t||void 0===t?void 0:t.items)?t.items:t?[]:null)}catch(pK){d((null===pK||void 0===pK?void 0:pK.message)||"Unable to load role status.")}}},[n]);(0,s.useEffect)(()=>{p()},[p,u]);const h=(0,s.useMemo)(()=>{if(!Array.isArray(r))return null;let e=0,t=0,n=null;for(const a of r){"parsed"===a.parse_status?e+=1:a.parse_status&&"parsed"!==a.parse_status&&(t+=1);const r=a.created_at||a.uploaded_at||null;r&&(!n||r>n)&&(n=r)}return{total:r.length,parsed:e,failed:t,latest:n}},[r]),f=(0,s.useMemo)(()=>{if(!Array.isArray(r))return null;let e=0;for(const t of r)"complete"===t.evaluation_status&&(e+=1);return{complete:e}},[r]),x=Array.isArray(o)?o.length:null,v=Array.isArray(o)?o.filter(e=>"finalised"===e.status||"exported"===e.status).length:null;if(!t)return(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-status-tab-loading",children:(0,Xt.jsx)(Py,{className:"px-6 py-6",children:(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin text-slate-300"})})});const g=KI(t.status),y=Boolean(t.published_at);return(0,Xt.jsxs)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3 lg:gap-8","data-testid":"role-status-tab",children:[(0,Xt.jsxs)("div",{className:"space-y-6 lg:col-span-2 lg:space-y-6",children:[(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-status-card-overview",children:[(0,Xt.jsxs)(Ry,{className:"pb-3 flex flex-row items-center justify-between px-6 pt-6",children:[(0,Xt.jsxs)(Iy,{className:"text-base font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(kn,{className:"h-4 w-4 text-slate-300"}),"Role Status"]}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>m(e=>e+1),"aria-label":"Refresh status","data-testid":"role-status-refresh",className:"h-8 w-8 p-0",children:(0,Xt.jsx)(Kg,{className:"h-4 w-4"})})]}),(0,Xt.jsxs)(Py,{className:"px-6 pb-6 space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,Xt.jsx)("span",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-secondary",children:"Lifecycle"}),(0,Xt.jsx)("div",{"data-testid":"role-status-lifecycle",children:(0,Xt.jsx)(XP,{status:t.status})})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,Xt.jsx)("span",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-secondary",children:"Active for matching"}),(0,Xt.jsx)(Vw,{variant:"outline",className:g?"border-emerald-500/40 bg-emerald-500/10 text-emerald-200":"border-ndor-edge bg-ndor-surface-alt/60 text-ndor-ink-secondary","data-testid":"role-status-active",children:g?"Active":"Inactive"})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,Xt.jsx)("span",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-secondary",children:"Publish state"}),(0,Xt.jsx)(Vw,{variant:"outline",className:y?"border-blue-500/40 bg-blue-500/10 text-blue-200":"border-ndor-edge bg-ndor-surface-alt/60 text-ndor-ink-secondary","data-testid":"role-status-publish",children:y?"Published":"Unpublished"})]}),(0,Xt.jsx)(FB,{label:"Published at",value:EB(t.published_at),fallback:"Not published",testId:"role-status-published-at"}),(0,Xt.jsx)(FB,{label:"Created",value:EB(t.created_at),testId:"role-status-created-at"}),(0,Xt.jsx)(FB,{label:"Last updated",value:EB(t.updated_at),testId:"role-status-updated-at"})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-status-card-intake",children:[(0,Xt.jsx)(Ry,{className:"pb-3 px-6 pt-6",children:(0,Xt.jsxs)(Iy,{className:"text-base font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Dn,{className:"h-4 w-4 text-slate-300"}),"Intake Status"]})}),(0,Xt.jsxs)(Py,{className:"px-6 pb-6 space-y-1",children:[c&&(0,Xt.jsxs)("div",{className:"text-xs text-rose-400 flex items-start gap-2 mb-3","data-testid":"role-status-error",children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 mt-0.5"}),(0,Xt.jsx)("span",{children:c})]}),(0,Xt.jsx)(FB,{label:"Dossiers uploaded",value:h?h.total:null,testId:"role-status-dossiers-total"}),(0,Xt.jsx)(FB,{label:"Parsed",value:h?h.parsed:null,testId:"role-status-dossiers-parsed"}),(0,Xt.jsx)(FB,{label:"Parse failed",value:h?h.failed:null,testId:"role-status-dossiers-failed"}),(0,Xt.jsx)(FB,{label:"Latest upload",value:h?EB(h.latest):null,fallback:h&&0===h.total?"No uploads yet":"Unavailable",testId:"role-status-latest-upload"})]})]}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-status-card-evaluation",children:[(0,Xt.jsx)(Ry,{className:"pb-3 px-6 pt-6",children:(0,Xt.jsxs)(Iy,{className:"text-base font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(pT,{className:"h-4 w-4 text-slate-300"}),"Evaluation Status"]})}),(0,Xt.jsxs)(Py,{className:"px-6 pb-6 space-y-1",children:[(0,Xt.jsx)(FB,{label:"Evaluations completed",value:f?f.complete:null,testId:"role-status-evals-complete"}),(0,Xt.jsx)(FB,{label:"Governance packs",value:x,testId:"role-status-packs-total"}),(0,Xt.jsx)(FB,{label:"Finalised / exported",value:v,testId:"role-status-packs-finalised"}),(0,Xt.jsx)("div",{className:"pt-2 mt-1 border-t border-ndor-edge/50",children:(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted leading-relaxed",children:"Reviewer coverage detail appears in the sidebar \u2014 assigned, pending and in-review reviewers for this role."})})]})]})]}),(0,Xt.jsxs)("aside",{className:"space-y-6",children:[(0,Xt.jsx)("div",{"data-testid":"role-status-reviewer-coverage-mount",children:(0,Xt.jsx)(XO,{roleId:n})}),(0,Xt.jsx)("div",{"data-testid":"role-status-timeline-mount",children:(0,Xt.jsx)(aB,{roleId:n})}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-status-card-channel-2",children:[(0,Xt.jsx)(Ry,{className:"pb-2 px-5 pt-5",children:(0,Xt.jsxs)(Iy,{className:"text-sm font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 text-slate-300"}),"Surfaced Candidates"]})}),(0,Xt.jsxs)(Py,{className:"px-5 pb-5 space-y-2",children:[(0,Xt.jsx)(Vw,{variant:"outline",className:a.enabled?"border-emerald-500/40 bg-emerald-500/10 text-emerald-200 text-[10px] uppercase tracking-[0.14em]":"border-ndor-edge bg-ndor-surface-alt/60 text-[10px] uppercase tracking-[0.14em] text-ndor-ink-secondary","data-testid":"role-status-channel-2-pill",children:a.enabled?"Active \xb7 Channel-2":"Not yet active"}),a.enabled?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink leading-relaxed",children:"Anonymous role-scoped matching is active on this workspace. Open the Candidates tab \u2192 Surfaced Candidates sub-tab to review matches and send governed signals."}),null!==a.signals_remaining&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-secondary tabular-nums","data-testid":"role-status-channel-2-quota",children:["Signals remaining: ",a.signals_remaining,null!==a.signals_allowance?" / ".concat(a.signals_allowance):""]})]}):(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted leading-relaxed",children:"Anonymous role-scoped matching is preview-only on this workspace. When it rolls out broadly, candidate-side acceptance flows will be auditable from the Lifecycle Timeline."})]})]})]})]})}function IB(e,t){if(null==e)return"\u2014";const n=(Number(e)||0)/100,a="GBP"===t?"\xa3":"USD"===t?"$":"EUR"===t?"\u20ac":"".concat(t||""," ");return"".concat(a).concat(n.toFixed(2))}function TB(e){let{rule:t,label:n,value:a,descriptor:r,valueClass:s,testId:i}=e;return(0,Xt.jsxs)("div",{className:"flex items-stretch rounded-lg border border-ndor-edge bg-ndor-surface overflow-hidden","data-testid":i,children:[(0,Xt.jsx)("div",{className:"w-1 ".concat(t)}),(0,Xt.jsxs)("div",{className:"flex-1 p-4",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-300 font-medium",children:n}),(0,Xt.jsx)("p",{className:"mt-1.5 text-2xl font-semibold ".concat(s||"text-ndor-ink"),children:a}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300 mt-1 leading-snug",children:r})]})]})}function PB(e){let{roleId:t,refreshKey:n}=e;
2const[a,r]=(0,s.useState)(null),[i,o]=(0,s.useState)(null);if((0,s.useEffect)(()=>{let e=!1;return(async()=>{try{const n=await(0,zt.n)("/api/employer/v1/roles/".concat(t,"/usage"));e||r(n)}catch(pK){e||o((null===pK||void 0===pK?void 0:pK.message)||"Usage read failed.")}})(),()=>{e=!0}},[t,n]),i)return(0,Xt.jsx)("div",{className:"rounded-lg border border-rose-500/40 bg-rose-500/10 p-3 text-xs text-rose-300","data-testid":"role-usage-strip-error",children:"Usage unavailable \xb7 \u2014"});if(!a)return(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3","data-testid":"role-usage-strip-loading",children:[0,1,2].map(e=>(0,Xt.jsxs)("div",{className:"flex items-stretch rounded-lg border border-ndor-edge bg-ndor-surface overflow-hidden",children:[(0,Xt.jsx)("div",{className:"w-1 bg-slate-500"}),(0,Xt.jsxs)("div",{className:"flex-1 p-4",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-300 font-medium",children:"\u2014"}),(0,Xt.jsx)("p",{className:"mt-1.5 text-2xl font-semibold text-slate-300",children:"\u2014"}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300 mt-1",children:"loading"})]})]},e))});if(!1===a.plan_active)return(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge bg-ndor-surface overflow-hidden flex items-stretch","data-testid":"role-usage-strip-inactive",children:[(0,Xt.jsx)("div",{className:"w-1 bg-slate-500"}),(0,Xt.jsxs)("div",{className:"flex-1 p-4",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-300 font-medium",children:"Evaluation allowance"}),(0,Xt.jsx)("p",{className:"mt-1.5 text-sm text-ndor-ink",children:"Plan not activated"}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300 mt-1 leading-snug",children:"Contact your administrator to enable evaluation for this account."})]})]});const l=null!=a.monthly_cap?a.monthly_cap:a.bundle_total,c=null!=a.monthly_used?a.monthly_used:a.bundle_used,d=null==c?null:Number(c),u=null==l||null==d?null:Math.max(0,Number(l)-d),m=null==l||0===l||null==d?0:d/Number(l),p=function(e){if(!e)return null;try{const t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}catch(t){return null}}(a.period_ends_at),h=null==l?"bg-emerald-500":0===u?"bg-rose-500":m>=.8?"bg-amber-500":"bg-emerald-500",f=null==l?"text-emerald-300":0===u?"text-rose-300":m>=.8?"text-amber-300":"text-emerald-300",x=null==l?"".concat(a.plan_tier," \xb7 unlimited"):0===u?p?"allowance exhausted \xb7 resets ".concat(p):"allowance exhausted \xb7 overage rate applies":m>=.8?p?"approaching monthly limit \xb7 resets ".concat(p):"approaching monthly limit":p?"".concat(a.plan_tier," \xb7 resets ").concat(p):"".concat(a.plan_tier," \xb7 monthly allowance"),v=null==l?"all evaluations included":null==d?"usage data unavailable":"".concat(d," of ").concat(l," evaluations used this period");return(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3","data-testid":"role-usage-strip",children:[(0,Xt.jsx)(TB,{rule:h,label:"Evaluations remaining this period",value:null==l?"\u221e":null==u?"\u2014":u,descriptor:x,valueClass:f,testId:"role-usage-remaining-card"}),(0,Xt.jsx)(TB,{rule:"bg-blue-500",label:"Used this period",value:null==d?"\u2014":d,descriptor:v,testId:"role-usage-used-card"}),(0,Xt.jsx)(TB,{rule:"bg-slate-500",label:"Overage rate",value:null==a.overage_rate_cents?"\u2014":IB(a.overage_rate_cents,a.currency),descriptor:"per evaluation beyond monthly allowance",testId:"role-usage-overage-card"})]})}RB.displayName="RoleStatusTab";const OB=wn("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),BB=[2e3,3e3,4e3,6e3,8e3],LB=new Set(["complete","partial","failed"]);function MB(e,t){return new Promise((n,a)=>{var r;if(null!==t&&void 0!==t&&t.aborted)return void a(zB());const s=setTimeout(()=>{var e;null===t||void 0===t||null===(e=t.removeEventListener)||void 0===e||e.call(t,"abort",i),n()},e);function i(){clearTimeout(s),a(zB())}null===t||void 0===t||null===(r=t.addEventListener)||void 0===r||r.call(t,"abort",i,{once:!0})})}function zB(){if("function"===typeof DOMException)return new DOMException("Polling aborted","AbortError");const e=new Error("Polling aborted");return e.name="AbortError",e}async function UB(e){let{signal:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!==t&&void 0!==t&&t.aborted)throw zB();return(0,zt.n)("/api/employer/v1/bulk-eval/jobs/".concat(e))}async function VB(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{signal:n,onTick:a}=t;if(!e)throw new Error("pollBulkEvalJob requires a jobId");let r=!1;const s=()=>{"undefined"!==typeof document&&"visible"===document.visibilityState&&(r=!0)};"undefined"!==typeof document&&"function"===typeof document.addEventListener&&document.addEventListener("visibilitychange",s);try{var i,o;let t=await UB(e,{signal:n});if(null===a||void 0===a||a(t),LB.has(null===(i=t)||void 0===i||null===(o=i.job)||void 0===o?void 0:o.status))return t;for(let i=0;i<60;i+=1){var l,c;if(null!==n&&void 0!==n&&n.aborted)throw zB();const s=BB[Math.min(i,BB.length-1)],o=r?0:s;if(r=!1,o>0&&await MB(o,n),null!==n&&void 0!==n&&n.aborted)throw zB();if(t=await UB(e,{signal:n}),null===a||void 0===a||a(t),LB.has(null===(l=t)||void 0===l||null===(c=l.job)||void 0===c?void 0:c.status))return t}const s=new Error("Bulk evaluation is still running after the maximum wait.");throw s.code="POLL_TIMEOUT",s}finally{"undefined"!==typeof document&&"function"===typeof document.removeEventListener&&document.removeEventListener("visibilitychange",s)}}function qB(e){const t={queued:{cls:"border-blue-500/40 text-blue-300 bg-blue-500/10",label:"Queued",icon:wF},running:{cls:"border-blue-500/40 text-blue-300 bg-blue-500/10",label:"Running",icon:wF},complete:{cls:"border-emerald-500/40 text-emerald-300 bg-emerald-500/10",label:"Complete",icon:Og},partial:{cls:"border-amber-500/40 text-amber-300 bg-amber-500/10",label:"Partial",icon:Oy},failed:{cls:"border-rose-500/40 text-rose-300 bg-rose-500/10",label:"Failed",icon:Oy}},n=t[e]||t.queued,a=n.icon;return(0,Xt.jsxs)(Vw,{variant:"outline",className:"".concat(n.cls," text-[10px] uppercase tracking-wider flex items-center gap-1"),"data-testid":"role-bulk-eval-job-status-pill","data-job-status":e,children:[(0,Xt.jsx)(a,{className:"h-3 w-3"}),n.label]})}function WB(e,t){if(null==e)return"\u2014";const n=(Number(e)||0)/100,a="GBP"===t?"\xa3":"USD"===t?"$":"EUR"===t?"\u20ac":"".concat(t||""," ");return"".concat(a).concat(n.toFixed(2))}function HB(e){var t,n,a;let{roleId:r,activeJobId:i,onTerminal:o}=e;
2const[l,c]=(0,s.useState)(i||null),[d,u]=(0,s.useState)(null),[m,p]=(0,s.useState)(!1),[h,f]=(0,s.useState)(!1),[x,v]=(0,s.useState)(null),g=(0,s.useRef)(null),y=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(i)return void c(i);const e=function(e){if(!e)return null;const t=gB();if(!t)return null;try{const n=t.getItem(vB(e));if(!n)return null;const a=JSON.parse(n);return a&&1===a.schema&&"string"===typeof a.jobId?a:(t.removeItem(vB(e)),null)}catch(n){try{t.removeItem(vB(e))}catch(a){}return null}}(r);null!==e&&void 0!==e&&e.jobId&&c(e.jobId)},[i,r]),(0,s.useEffect)(()=>{if(!l)return;y.current=!1;const e=new AbortController;return g.current=e,p(!0),v(null),VB(l,{signal:e.signal,onTick:e=>{u(e)}}).then(e=>{if(u(e),!y.current){var t;if(y.current=!0,"complete"===(null===e||void 0===e||null===(t=e.job)||void 0===t?void 0:t.status))try{(0,kk.Di)()}catch(n){}null===o||void 0===o||o(e)}}).catch(e=>{"AbortError"!==(null===e||void 0===e?void 0:e.name)&&v((null===e||void 0===e?void 0:e.message)||"Polling failed.")}).finally(()=>p(!1)),()=>e.abort()},[l]);const b=null===d||void 0===d?void 0:d.job,w=null===d||void 0===d?void 0:d.items,j=null===b||void 0===b?void 0:b.status,k=(0,s.useMemo)(()=>"complete"===j||"partial"===j||"failed"===j,[j]),N=(0,s.useMemo)(()=>function(e){if(!Array.isArray(e))return{running:0,terminal:0,total:0};let t=0,n=0;return e.forEach(e=>{"queued"===e.item_status||"running"===e.item_status?t+=1:n+=1}),{running:t,terminal:n,total:e.length}}(w),[w]),_=k&&Number((null===b||void 0===b?void 0:b.failed_count)||0)+N.total>0&&(Number((null===b||void 0===b?void 0:b.failed_count)||0)>0||Array.isArray(w)&&w.some(e=>"failed"===e.item_status||"timeout"===e.item_status)),D=(0,s.useCallback)(async()=>{if(l){f(!0),v(null);try{var e;await(0,zt.n)("/api/employer/v1/bulk-eval/jobs/".concat(l,"/resume"),{method:"POST"}),fy.success("Bulk evaluation resumed."),y.current=!1,u(null),c(e=>e);const t=new AbortController;null===(e=g.current)||void 0===e||e.abort(),g.current=t,p(!0),VB(l,{signal:t.signal,onTick:u}).then(e=>{u(e),y.current||(y.current=!0,null===o||void 0===o||o(e))}).catch(e=>{"AbortError"!==(null===e||void 0===e?void 0:e.name)&&v((null===e||void 0===e?void 0:e.message)||"Polling failed.")}).finally(()=>p(!1))}catch(pK){var t;const n=(null===pK||void 0===pK||null===(t=pK.data)||void 0===t?void 0:t.detail)||(null===pK||void 0===pK?void 0:pK.data)||{},a=n.code||(null===pK||void 0===pK?void 0:pK.code)||"RESUME_FAILED",r=n.message||(null===pK||void 0===pK?void 0:pK.message)||"Resume failed.";fy.error("".concat(a,": ").concat(r)),v("".concat(a,": ").concat(r))}finally{f(!1)}}},[l,o]),C=(0,s.useCallback)(()=>{var e;null===(e=g.current)||void 0===e||e.abort(),function(e){if(!e)return!1;const t=gB();if(!t)return!1;try{return t.removeItem(vB(e)),!0}catch(n){return!1}}(r),c(null),u(null),v(null)},[r]);return l?(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-bulk-eval-job-card","data-job-id":l,children:(0,Xt.jsxs)(Py,{className:"p-4 space-y-3",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-wider text-slate-300 font-medium",children:"Bulk evaluation"}),j?qB(j):(0,Xt.jsx)(Vw,{variant:"outline",className:"border-slate-500/40 text-slate-300 bg-slate-500/10 text-xs uppercase tracking-wider",children:"Loading\u2026"}),m&&!k&&(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 animate-spin text-slate-300"})]}),k&&(0,Xt.jsx)("button",{type:"button",onClick:C,className:"text-slate-300 hover:text-ndor-ink","aria-label":"Dismiss","data-testid":"role-bulk-eval-job-dismiss",children:(0,Xt.jsx)(xh,{className:"h-4 w-4"})})]}),b&&(0,Xt.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-[10px]","data-testid":"role-bulk-eval-job-counters",children:[(0,Xt.jsxs)("div",{className:"rounded-md border border-emerald-500/40 bg-emerald-500/10 px-2 py-1.5",children:[(0,Xt.jsx)("p",{className:"uppercase tracking-wider text-emerald-300/80",children:"Complete"}),(0,Xt.jsx)("p",{className:"text-base font-semibold text-emerald-300",children:null!==(t=b.complete_count)&&void 0!==t?t:0})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-rose-500/40 bg-rose-500/10 px-2 py-1.5",children:[(0,Xt.jsx)("p",{className:"uppercase tracking-wider text-rose-300/80",children:"Failed"}),(0,Xt.jsx)("p",{className:"text-base font-semibold text-rose-300",children:null!==(n=b.failed_count)&&void 0!==n?n:0})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-slate-500/40 bg-slate-500/10 px-2 py-1.5",children:[(0,Xt.jsx)("p",{className:"uppercase tracking-wider text-slate-300/80",children:"Skipped"}),(0,Xt.jsx)("p",{className:"text-base font-semibold text-slate-300",children:null!==(a=b.skipped_count)&&void 0!==a?a:0})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 px-2 py-1.5",children:[(0,Xt.jsx)("p",{className:"uppercase tracking-wider text-amber-300/80",children:"Timeout"}),(0,Xt.jsx)("p",{className:"text-base font-semibold text-amber-300",children:Array.isArray(w)?w.filter(e=>"timeout"===e.item_status).length:0})]})]}),Array.isArray(w)&&w.length>0&&(0,Xt.jsxs)("div",{className:"text-xs text-slate-300","data-testid":"role-bulk-eval-job-items-summary",children:[N.terminal," of ",N.total," candidates processed",!k&&N.running>0&&" \xb7 ".concat(N.running," in flight")]}),k&&Number((null===b||void 0===b?void 0:b.charged_total_cents)||0)>0&&(0,Xt.jsxs)("div",{className:"text-xs text-slate-300","data-testid":"role-bulk-eval-job-charged",children:["Charged total: ",WB(b.charged_total_cents,b.currency_snapshot)," \xb7 recorded for later invoicing or billing reconciliation"]}),x&&(0,Xt.jsxs)("div",{className:"text-xs text-rose-400 flex items-start gap-2","data-testid":"role-bulk-eval-job-error",children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5 mt-0.5"}),(0,Xt.jsx)("span",{children:x})]}
2),k&&(0,Xt.jsx)("div",{className:"flex items-center justify-end gap-2 pt-1",children:_&&(0,Xt.jsx)(Rr,{onClick:D,disabled:h,size:"sm",className:"h-7 text-[11px] bg-blue-500 hover:bg-blue-500/90 text-white","data-testid":"role-bulk-eval-job-resume-btn",children:h?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-1 h-3 w-3 animate-spin"}),"Resuming\u2026"]}):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(OB,{className:"mr-1 h-3 w-3"}),"Retry failed"]})})})]})}):(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-bulk-eval-job-card-empty",children:(0,Xt.jsxs)(Py,{className:"p-4 flex items-start gap-3",children:[(0,Xt.jsx)("div",{className:"rounded-md border border-slate-500/40 bg-slate-500/10 p-2 shrink-0",children:(0,Xt.jsx)(wF,{className:"h-4 w-4 text-slate-300"})}),(0,Xt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No bulk evaluation in flight"}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300 mt-1 leading-relaxed",children:"Launch a bulk run from the Candidates & Dossiers panel to score every parsed dossier against this role at once. Live progress, per-candidate verdicts and the charged total will appear here."})]})]})})}const GB={seniority:25,domain_alignment:30,evidence_strength:25,location:10,risk:10},KB={seniority:"Seniority",domain_alignment:"Domain",evidence_strength:"Evidence",location:"Location",risk:"Risk"};function YB(e,t,n){var a;const r=null!==(a=null===e||void 0===e?void 0:e[t])&&void 0!==a?a:null===e||void 0===e?void 0:e[n];return Array.isArray(r)?r.filter(e=>"string"===typeof e&&e.trim()).slice(0,25):[]}function JB(e){let{role:t}=e;if(!t)return null;const n=t.structured_definition_json||{},a=YB(n,"required_criteria","must_have"),r=YB(n,"preferred_criteria","nice_to_have"),s=function(e){const t=null===e||void 0===e?void 0:e.dealbreakers;return t?Array.isArray(t)?t.filter(e=>"string"===typeof e&&e.trim()).map(e=>({key:e,value:""})):"object"===typeof t?Object.entries(t).filter(e=>{let[t]=e;return"string"===typeof t&&t.trim()}).map(e=>{let[t,n]=e;return{key:t,value:"string"===typeof n?n:""}}):[]:[]}(n),{weights:i,isCustom:o}=function(e){const t=null===e||void 0===e?void 0:e.weighted_dimensions;if(!t||"object"!==typeof t)return{weights:GB,isCustom:!1};const n=(0,c.A)({},GB);let a=!1;for(const r of Object.keys(GB)){const e=Number(t[r]);Number.isFinite(e)&&e>=0&&e<=100&&(n[r]=Math.round(e),Math.round(e)!==GB[r]&&(a=!0))}return{weights:n,isCustom:a}}(n),l=0===a.length&&0===r.length&&0===s.length;return(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-criteria-summary",children:(0,Xt.jsxs)(Py,{className:"p-5 space-y-5",children:[(0,Xt.jsxs)("header",{className:"space-y-1",children:[(0,Xt.jsx)("h3",{className:"text-sm font-semibold text-ndor-ink tracking-wide",children:"What we evaluate against"}),(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-wider text-slate-300",children:"Read-only \xb7 role definition"})]}),(0,Xt.jsxs)("section",{className:"space-y-2.5","data-testid":"role-criteria-required",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wider text-emerald-300 font-medium",children:[(0,Xt.jsx)(Og,{className:"h-4 w-4"}),"Required (",a.length,")"]}),0===a.length?(0,Xt.jsx)("p",{className:"text-sm text-slate-300 leading-relaxed",children:"No required criteria defined. Add them in the role editor so evaluations have firm anchors."}):(0,Xt.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map((e,t)=>(0,Xt.jsx)("span",{className:"text-xs px-2.5 py-1 rounded-md border border-emerald-500/40 bg-emerald-500/10 text-emerald-200",children:e},"req-".concat(t)))})]}),(0,Xt.jsxs)("section",{className:"space-y-2.5","data-testid":"role-criteria-preferred",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wider text-slate-200 font-medium",children:[(0,Xt.jsx)(Kn,{className:"h-4 w-4"}),"Preferred (",r.length,")"]}),0===r.length?(0,Xt.jsx)("p",{className:"text-sm text-slate-300",children:"No preferred criteria."}):(0,Xt.jsx)("div",{className:"flex flex-wrap gap-2",children:r.map((e,t)=>(0,Xt.jsx)("span",{className:"text-xs px-2.5 py-1 rounded-md border border-slate-500/40 bg-slate-500/10 text-slate-200",children:e},"pref-".concat(t)))})]}),(0,Xt.jsxs)("section",{className:"space-y-2.5","data-testid":"role-criteria-dealbreakers",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wider text-rose-300 font-medium",children:[(0,Xt.jsx)(mb,{className:"h-4 w-4"}),"Dealbreakers (",s.length,")"]}),0===s.length?(0,Xt.jsx)("p",{className:"text-sm text-slate-300 leading-relaxed",children:"No dealbreakers configured. The four supported keys are timezone, clearance, work_authorization, language."}):(0,Xt.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>{let{key:t,value:n}=e;return(0,Xt.jsxs)("span",{className:"text-xs px-2.5 py-1 rounded-md border border-rose-500/40 bg-rose-500/10 text-rose-200",children:[t,n?(0,Xt.jsxs)("span",{className:"text-rose-300/90",children:[" \xb7 ",n]}):null]},"db-".concat(t))})})]}),(0,Xt.jsxs)("section",{className:"space-y-3","data-testid":"role-criteria-weighting",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wider text-blue-300 font-medium",children:[(0,Xt.jsx)(QC,{className:"h-4 w-4"}),"Dimension weighting"]}),(0,Xt.jsx)("span",{className:"text-xs uppercase tracking-wider px-2 py-0.5 rounded border ".concat(o?"border-blue-500/40 bg-blue-500/10 text-blue-200":"border-slate-500/40 bg-slate-500/10 text-slate-200"),"data-testid":"role-criteria-weighting-source","data-custom":o?"true":"false",children:o?"Custom for this role":"NDOR default"})]}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 gap-2.5",children:Object.entries(i).map(e=>{let[t,n]=e;return(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,Xt.jsx)("span",{className:"text-xs text-slate-200",children:KB[t]}),(0,Xt.jsx)("span",{className:"text-xs font-semibold text-blue-200",children:n})]}),(0,Xt.jsx)("div",{className:"h-1.5 rounded bg-ndor-bg/60 overflow-hidden",children:(0,Xt.jsx)("div",{className:"h-full bg-blue-500/70",style:{width:"".concat(n,"%")}})})]},t)})}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300 leading-relaxed pt-1",children:"Weights sum to 100 and govern the relative influence of each dimension on overall fit. Editing weights is gated behind a future P2 slice \u2014 this view is read-only."})]}),l&&(0,Xt.jsx)("p",{className:"text-sm text-slate-300 leading-relaxed border-t border-ndor-edge pt-4","data-testid":"role-criteria-empty-hint",children:"This role has minimal criteria defined. Evaluations will still run, but verdicts are most defensible when required criteria, preferred criteria, and dealbreakers are explicit."})]})})}function $B(e){if(!e)return"\u2014";const t=new Date(e);
2return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function XB(e){return Array.isArray(e)&&e.length>0}function QB(e){return e&&"object"===typeof e&&!Array.isArray(e)}function ZB(){var e,t;const{id:n}=_e(),a=ke(),[r,i]=(0,s.useState)(!0),[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(null),[p,h]=(0,s.useState)(0),[f,x]=(0,s.useState)("definition"),v=(0,s.useCallback)(e=>{h(e=>e+1),"single"===e&&x("candidates")},[]),[g,y]=(0,s.useState)(null),b=(0,s.useCallback)(()=>{y("awaiting_disposition"),x("candidates")},[]),w=(0,s.useCallback)(()=>{y(null)},[]),j=(0,s.useCallback)(async()=>{if(n){i(!0),l(null);try{const t=await KP(n);if(!t)return l("Role not found"),d(null),void m(null);d(t);try{const e=await YP(n);m(e)}catch(e){m(null)}}catch(mK){l((null===mK||void 0===mK?void 0:mK.message)||"Failed to load role")}finally{i(!1)}}},[n]);(0,s.useEffect)(()=>{j()},[j]);const[k,N]=(0,s.useState)(!1),[_,D]=(0,s.useState)(!1),[C,A]=(0,s.useState)(!1),[S,E]=(0,s.useState)(null),F=(0,s.useCallback)(()=>{E(null),N(!0)},[]),R=(0,s.useCallback)(()=>{E(null),D(!0)},[]),I=(0,s.useCallback)(()=>{C||(N(!1),D(!1),E(null))},[C]),T=e=>{var t,n;const a=null!==(t=null!==(n=null===e||void 0===e?void 0:e.detail)&&void 0!==n?n:null===e||void 0===e?void 0:e.message)&&void 0!==t?t:"Action failed";return"string"===typeof a?a:a&&"object"===typeof a&&(a.detail||a.message||a.code)||"Action failed"},P=(0,s.useCallback)(async e=>{if(null!==c&&void 0!==c&&c.id){A(!0),E(null);try{const t=await async function(e){let{immediate:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)throw new Error("rolesApi.closeRole: id is required");return(0,zt.n)("/api/employer/roles/".concat(encodeURIComponent(e),"/close"),{method:"POST",body:JSON.stringify({immediate:Boolean(t)})})}(c.id,{immediate:Boolean(e)});null!==t&&void 0!==t&&t.already_terminal?fy.message("Role was already closed."):fy.success(e?"Role closed.":"Role is closing."),N(!1),await j()}catch(mK){E(T(mK))}finally{A(!1)}}},[null===c||void 0===c?void 0:c.id,j]),O=(0,s.useCallback)(async()=>{if(null!==c&&void 0!==c&&c.id){A(!0),E(null);try{const e=await async function(e){if(!e)throw new Error("rolesApi.archiveRole: id is required");return(0,zt.n)("/api/employer/roles/".concat(encodeURIComponent(e),"/archive"),{method:"POST",body:JSON.stringify({})})}(c.id);null!==e&&void 0!==e&&e.already_terminal?fy.message("Role was already archived."):"draft"===c.status?fy.success("Draft discarded."):fy.success("Role archived."),D(!1),await j()}catch(mK){E(T(mK))}finally{A(!1)}}},[null===c||void 0===c?void 0:c.id,null===c||void 0===c?void 0:c.status,j]),[B,L]=(0,s.useState)(!1),M=(0,s.useCallback)(async()=>{if(null!==c&&void 0!==c&&c.id&&!B){L(!0);try{var e;const t=await async function(e){let{title_override:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)throw new Error("rolesApi.cloneRole: id is required");const n={};return"string"===typeof t&&t.trim()&&(n.title_override=t.trim()),(0,zt.n)("/api/employer/roles/".concat(encodeURIComponent(e),"/clone"),{method:"POST",body:JSON.stringify(n)})}(c.id),n=null===t||void 0===t||null===(e=t.role)||void 0===e?void 0:e.id;if(!n)return void fy.error("Clone did not return a new role id.");fy.success("Cloned to draft. Edit and publish when ready."),a("/employer/roles/".concat(n))}catch(mK){const t=null===mK||void 0===mK?void 0:mK.detail;t&&"object"===typeof t&&"POTENTIAL_DUPLICATE_ROLE"===t.code?fy.error("A role with this title already exists. Open the existing role or rename the source before cloning."):fy.error(T(mK)||"Failed to clone role.")}finally{L(!1)}}},[null===c||void 0===c?void 0:c.id,B,a]);if(r)return(0,Xt.jsxs)("div",{className:"flex items-center gap-2 p-8 text-sm text-slate-300","data-testid":"role-detail-loading",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}),"Loading role\u2026"]});if(o||!c)return(0,Xt.jsx)("div",{className:"p-6","data-testid":"role-detail-error",children:(0,Xt.jsx)(Fy,{children:(0,Xt.jsxs)(Py,{className:"flex items-start gap-3 p-6",children:[(0,Xt.jsx)(Oy,{className:"mt-0.5 h-5 w-5 text-rose-400"}),(0,Xt.jsxs)("div",{className:"space-y-2",children:[(0,Xt.jsx)("div",{className:"font-medium text-ndor-ink",children:o||"Role not found"}),(0,Xt.jsxs)("div",{className:"flex gap-2",children:[(0,Xt.jsxs)(Rr,{size:"sm",onClick:j,children:[(0,Xt.jsx)(Kg,{className:"mr-2 h-4 w-4"}),"Retry"]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:()=>a("/employer/roles"),children:[(0,Xt.jsx)(Zg,{className:"mr-2 h-4 w-4"}),"Back to roles"]})]})]})]})})});const z=c.structured_definition_json||{},U=QB(z.comp_band)?z.comp_band:null,V=XB(z.responsibilities)?z.responsibilities:[],q=XB(z.must_have_skills)?z.must_have_skills:[],W=XB(z.nice_to_have_skills)?z.nice_to_have_skills:[],H=u&&!1!==u.criteria_exists?u.criteria||u:null,G=H&&QB(H.dimension_weights)?H.dimension_weights:null,K="draft"===c.status,Y="closing"===c.status,J="active"===c.status||"live"===c.status,$="closed"===c.status,X="ar
2chived"===c.status,Q=!K;return(0,Xt.jsxs)("div",{className:"space-y-6 p-6 lg:p-8 max-w-screen-2xl mx-auto w-full","data-testid":"role-detail-".concat(c.id),children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:()=>a("/employer/roles"),"data-testid":"role-detail-back",children:[(0,Xt.jsx)(Zg,{className:"mr-2 h-4 w-4"}),"Back to roles"]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:j,"data-testid":"role-detail-refresh",children:[(0,Xt.jsx)(Kg,{className:"mr-2 h-4 w-4"}),"Refresh"]}),K?(0,Xt.jsx)(Rr,{size:"sm",asChild:!0,"data-testid":"role-detail-edit-draft",title:"Edit this draft",children:(0,Xt.jsxs)(Et,{to:"/employer/roles/".concat(c.id,"/edit"),children:[(0,Xt.jsx)(nO,{className:"mr-2 h-4 w-4"}),"Edit draft"]})}):null,K?(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:R,"data-testid":"role-detail-archive-cta",children:[(0,Xt.jsx)(pb,{className:"mr-2 h-4 w-4"}),"Discard draft"]}):null,J?(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:F,"data-testid":"role-detail-close-cta",children:[(0,Xt.jsx)(Gg,{className:"mr-2 h-4 w-4"}),"Close role"]}):null,Y?(0,Xt.jsxs)(Rr,{size:"sm",onClick:F,"data-testid":"role-detail-close-cta",children:[(0,Xt.jsx)(Gg,{className:"mr-2 h-4 w-4"}),"Close now"]}):null,$?(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:R,"data-testid":"role-detail-archive-cta",children:[(0,Xt.jsx)(Vn,{className:"mr-2 h-4 w-4"}),"Archive"]}):null,$||X?(0,Xt.jsxs)(Rr,{size:"sm",onClick:M,disabled:B,"data-testid":"role-detail-clone-cta",title:"Create a new draft role from this role's structured definition. The source role is not modified.",children:[B?(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}):(0,Xt.jsx)(Mn,{className:"mr-2 h-4 w-4"}),"Clone to Draft"]}):null]})]}),(0,Xt.jsxs)("header",{className:"space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold text-ndor-ink",children:c.title||"(untitled)"}),(0,Xt.jsx)(XP,{status:c.status})]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-4 text-xs text-slate-300",children:[(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,Xt.jsx)(kn,{className:"h-3 w-3"}),"Created: ",$B(c.created_at)]}),(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,Xt.jsx)(pg,{className:"h-3 w-3"}),"Published: ",$B(c.published_at)]}),(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,Xt.jsx)(pg,{className:"h-3 w-3"}),"Updated: ",$B(c.updated_at)]})]}),Q?(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-amber-200","data-testid":"role-detail-readonly-banner",children:[(0,Xt.jsx)(mb,{className:"mt-0.5 h-4 w-4"}),(0,Xt.jsx)("div",{children:"This role is no longer editable from the wizard. Use the lifecycle controls above to close or archive it."})]}):null,Y?(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-amber-200","data-testid":"role-detail-closing-banner",children:[(0,Xt.jsx)(pg,{className:"mt-0.5 h-4 w-4"}),(0,Xt.jsxs)("div",{children:["This role is closing. Active matches are paused; downstream automation will finalise it to ",(0,Xt.jsx)("code",{className:"font-mono",children:"closed"}),". You can ",(0,Xt.jsx)("strong",{children:"Close now"})," to finalise immediately."]})]}):null,X?(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-slate-500/40 bg-slate-500/10 p-3 text-xs text-slate-200","data-testid":"role-detail-archived-banner",children:[(0,Xt.jsx)(Vn,{className:"mt-0.5 h-4 w-4"}),(0,Xt.jsx)("div",{children:"This role is archived. It is no longer visible in the active roles list and cannot be re-opened."})]}):null]}),(0,Xt.jsxs)("section",{className:"space-y-3","aria-label":"Operational status","data-testid":"role-detail-operational-band",children:[(0,Xt.jsx)(PB,{roleId:c.id}),(0,Xt.jsx)(HB,{roleId:c.id,onTerminal:()=>h(e=>e+1)})]}),(0,Xt.jsx)("div",{"data-testid":"role-detail-tabs-wrapper",children:(0,Xt.jsxs)(tI,{value:f,onValueChange:x,className:"w-full",children:[(0,Xt.jsxs)(nI,{className:"bg-ndor-bg/40 border border-ndor-edge p-1 gap-1 h-auto","data-testid":"role-detail-tabs",children:[(0,Xt.jsx)(aI,{value:"definition","data-testid":"role-detail-tab-definition",className:"text-xs sm:text-sm font-medium text-ndor-ink-secondary data-[state=active]:bg-ndor-surface data-[state=active]:text-ndor-ink data-[state=active]:font-semibold data-[state=active]:shadow-[inset_0_-2px_0_0_#C9A45C] data-[state=active]:border-ndor-ink/30 hover:text-ndor-ink transition-colors",children:"Definition"}),(0,Xt.jsx)(aI,{value:"upload","data-testid":"role-detail-tab-upload",className:"text-xs sm:text-sm font-medium text-ndor-ink-secondary data-[state=active]:bg-ndor-surface data-[state=active]:text-ndor-ink data-[state=active]:font-semibold data-[state=active]:shadow-[inset_0_-2px_0_0_#C9A45C] data-[state=active]:border-ndor-ink/30 hover:text-ndor-ink transition-colors",children:"Upload Dossiers"}),(0,Xt.jsx)(aI,{value:"candidates","data-testid":"role-detail-tab-candidates",className:"text-xs sm:text-sm font-medium text-ndor-ink-secondary data-[state=active]:bg-ndor-surface data-[state=active]:text-ndor-ink data-[state=active]:font-semibold data-[state=active]:shadow-[inset_0_-2px_0_0_#C9A45C] data-[state=active]:border-ndor-ink/30 hover:text-ndor-ink transition-colors",children:"Candidates"}),(0,Xt.jsx)(aI,{value:"status","data-testid":"role-detail-tab-status",className:"text-xs sm:text-sm font-medium text-ndor-ink-secondary data-[state=active]:bg-ndor-surface data-[state=active]:text-ndor-ink data-[state=active]:font-semibold data-[state=active]:shadow-[inset_0_-2px_0_0_#C9A45C] data-[state=active]:border-ndor-ink/30 hover:text-ndor-ink transition-colors",children:"Status"})]}),(0,Xt.jsx)(rI,{value:"definition",className:"mt-4 focus-visible:outline-none","data-testid":"role-detail-tab-content-definition",children:(0,Xt.jsxs)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3 lg:gap-8",children:[(0,Xt.jsxs)("div",{className:"space-y-6 lg:col-span-2 lg:space-y-8 max-h-[720px] overflow-y-auto pr-1",children:[(0,Xt.jsxs)(Fy,{"data-testid":"role-detail-definition",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsx)(Iy,{className:"text-base",children:"Role definition"})}),(0,Xt.jsxs)(Py,{className:"space-y-4 text-sm",children:[(0,Xt.jsxs)("dl",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Must-have domain"}),(0,Xt.jsx)("dd",{className:"text-slate-100",children:z.must_have_domain||(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Working model"}),(0,Xt.jsx)("dd",{className:"text-slate-100",children:z.working_model||(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Location"}),(0,Xt.jsx)("dd",{className:"text-slate-100",children:z.location||(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Compensation band"}),(0,Xt.jsx)("dd",{className:"text-slate-100",children:U?"".concat(U.currency||""," ").concat(null!==(e=U.min)&&void 0!==e?e:"?","\u2013").concat(null!==(t=U.max)&&void 0!==t?t:"?").trim():(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Responsibilities"}),V.length>0?(0,Xt.jsx)("ul",{className:"list-disc pl-5 text-slate-100",children:V.map((e,t)=>(0,Xt.jsx)("li",{children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none yet"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Must-have skills"}),q.length>0?(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5",children:q.map((e,t)=>(0,Xt.jsx)(Vw,{className:"bg-slate-500/10 text-slate-200 border border-slate-500/40",children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none yet"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Nice-to-have skills"}),W.length>0?(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5",children:W.map((e,t)=>(0,Xt.jsx)(Vw,{className:"bg-slate-500/10 text-slate-200 border border-slate-500/40",children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none yet"})]})]})]}),(0,Xt.jsxs)(Fy,{"data-testid":"role-detail-criteria",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsx)(Iy,{className:"text-base",children:"Evaluation criteria (raw)"})}),(0,Xt.jsx)(Py,{className:"space-y-4 text-sm",children:H?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Dimension weights"}),G?(0,Xt.jsx)("div",{className:"grid grid-cols-2 gap-2",children:["seniority","domain_alignment","evidence_strength","location","risk"].map(e=>{var t;return(0,Xt.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-ndor-edge bg-ndor-bg/50 px-3 py-2","data-testid":"role-detail-weight-".concat(e),children:[(0,Xt.jsx)("span",{className:"text-slate-200",children:e}),(0,Xt.jsx)("span",{className:"font-mono text-slate-100",children:null!==(t=G[e])&&void 0!==t?t:0})]},e)})}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 defaults will be applied"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Required criteria"}),XB(H.required_criteria)?(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5",children:H.required_criteria.map((e,t)=>(0,Xt.jsx)(Vw,{className:"bg-emerald-500/10 text-emerald-200 border border-emerald-500/40",children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Preferred criteria"}),XB(H.preferred_criteria)?(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5",children:H.preferred_criteria.map((e,t)=>(0,Xt.jsx)(Vw,{className:"bg-sky-500/10 text-sky-200 border border-sky-500/40",children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Dealbreakers"}),QB(H.dealbreakers)&&Object.keys(H.dealbreakers).length>0?(0,Xt.jsx)("div",{className:"grid grid-cols-2 gap-1.5 text-xs",children:Object.entries(H.dealbreakers).map(e=>{let[t,n]=e;return(0,Xt.jsxs)("div",{className:"rounded-md border border-rose-500/40 bg-rose-500/10 px-2 py-1 text-rose-200",children:[(0,Xt.jsxs)("span",{className:"font-medium",children:[t,":"]})," ",String(n)]},t)})}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none"})]})]}):(0,Xt.jsx)("div",{className:"text-slate-300","data-testid":"role-detail-criteria-empty",children:"Criteria will appear here after this role is published. Until then, evaluation defaults will be derived from the role definition above."})})]})]}),(0,Xt.jsx)("aside",{className:"space-y-6",children:(0,Xt.jsx)(JB,{role:c})})]})}),(0,Xt.jsx)(rI,{value:"upload",className:"mt-4 focus-visible:outline-none","data-testid":"role-detail-tab-content-upload",children:J?(0,Xt.jsxs)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-detail-upload-card",children:[(0,Xt.jsx)(Ry,{className:"px-6 pt-6 pb-3",children:(0,Xt.jsx)(Iy,{className:"text-base font-semibold text-ndor-ink",children:"Upload Dossiers"})}),(0,Xt.jsxs)(Py,{className:"px-6 pb-6 space-y-3",children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted leading-relaxed",children:["Add candidate dossiers one at a time, or upload a ZIP of PDFs/DOCXs as a bulk batch. On a successful upload, the view automatically switches to ",(0,Xt.jsx)("strong",{children:"Candidates"}),"so the newly-parsed rows surface immediately. Duplicates stay on this tab so you can decide what to do next."]}),(0,Xt.jsx)(SB,{roleId:c.id,roleTitle:c.title,onUploadComplete:v,onReviewFlaggedIntegrity:b})]})]}):(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-detail-upload-blocked",children:(0,Xt.jsxs)(Py,{className:"px-6 py-6 space-y-2",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:K?"Upload becomes available after publish.":"Upload is closed for this role."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:K?"Publish this role to begin candidate intake and generate N
2DOR-Surfaced Candidates. NDOR matching runs once at publish and produces an immutable historical snapshot \u2014 no continuous rescoring.":Y?"New dossier intake is paused while this role is closing. Reviewer triage and governance pack assembly remain available below.":$?"New dossier intake is closed. Historical evidence and governance packs remain available.":"This role is archived and is read-only."})]})})}),(0,Xt.jsx)(rI,{value:"candidates",className:"mt-4 focus-visible:outline-none","data-testid":"role-detail-tab-content-candidates",children:K?(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface","data-testid":"role-detail-candidates-draft-blocked",children:(0,Xt.jsxs)(Py,{className:"px-6 py-6 space-y-2",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No candidates yet \u2014 this role is still a draft."}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:"Publish this role to begin candidate intake and NDOR-Surfaced Candidates. NDOR matching runs once at publish \u2014 the surfaced set is a historical evidence snapshot, not a continuous feed."})]})}):(0,Xt.jsx)(hB,{role:c,refreshToken:p,integrityFilterRequest:g,onIntegrityFilterApplied:w})}),(0,Xt.jsx)(rI,{value:"status",className:"mt-4 focus-visible:outline-none","data-testid":"role-detail-tab-content-status",children:(0,Xt.jsx)(RB,{role:c})})]})}),(0,Xt.jsx)(aO,{open:k,status:c.status,onCancel:I,onConfirm:P,pending:C,error:S}),(0,Xt.jsx)(rO,{open:_,status:c.status,onCancel:I,onConfirm:O,pending:C,error:S})]})}function eL(){return(0,Xt.jsx)(ZB,{})}const tL=1500;function nL(e){let{delayMs:t=tL}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const[n,a]=(0,s.useState)("idle"),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(null),c=(0,s.useRef)(null),d=(0,s.useRef)(null),u=(0,s.useRef)(!1),m=(0,s.useRef)(e);(0,s.useEffect)(()=>{m.current=e},[e]);const p=(0,s.useCallback)(async()=>{if(u.current)return;const e=d.current;if(null!==e&&void 0!==e){d.current=null,u.current=!0,a("saving"),i(null);try{await m.current(e),l(new Date),a("saved")}catch(mK){i((null===mK||void 0===mK?void 0:mK.message)||"Save failed"),a("error")}finally{u.current=!1,null!==d.current&&(a("pending"),c.current=setTimeout(p,t))}}},[t]),h=(0,s.useCallback)(e=>{d.current=e,a("pending"),c.current&&clearTimeout(c.current),c.current=setTimeout(p,t)},[p,t]),f=(0,s.useCallback)(async()=>{c.current&&(clearTimeout(c.current),c.current=null),await p()},[p]);return(0,s.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]),{trigger:h,flush:f,status:n,error:r,lastSavedAt:o}}const aL={responsibilities:[],must_have_domain:null,must_have_skills:[],nice_to_have_skills:[],dealbreakers:{},comp_band:null,working_model:null,location_constraint:null,notes:null},rL={required_criteria:[],preferred_criteria:[],dealbreakers:{},dimension_weights:{},evaluation_metadata:{}},sL=new Set(["responsibilities","must_have_domain","must_have_skills","nice_to_have_skills","dealbreakers","comp_band","working_model","location_constraint","notes","weighted_dimensions"]);function iL(e){if(!e||"object"!==typeof e)return e;const t=(0,c.A)({},e);return"skills_required"in t&&(null==t.must_have_skills&&Array.isArray(t.skills_required)&&(t.must_have_skills=t.skills_required),delete t.skills_required),"skills_preferred"in t&&(null==t.nice_to_have_skills&&Array.isArray(t.skills_preferred)&&(t.nice_to_have_skills=t.skills_preferred),delete t.skills_preferred),"seniority"in t&&delete t.seniority,t}function oL(e){const t=iL(e);return t&&"object"===typeof t?(0,c.A)((0,c.A)({},aL),t):(0,c.A)({},aL)}function lL(e){if(!e||"object"!==typeof e)return{};const t={};for(const n of Object.keys(e))sL.has(n)&&(t[n]=e[n]);return Array.isArray(t.responsibilities)&&(t.responsibilities=t.responsibilities.map(e=>"string"===typeof e?e.trim():e).filter(e=>"string"===typeof e&&e.length>0)),Array.isArray(t.must_have_skills)&&(t.must_have_skills=t.must_have_skills.map(e=>"string"===typeof e?e.trim():e).filter(e=>"string"===typeof e&&e.length>0)),Array.isArray(t.nice_to_have_skills)&&(t.nice_to_have_skills=t.nice_to_have_skills.map(e=>"string"===typeof e?e.trim():e).filter(e=>"string"===typeof e&&e.length>0)),t}function cL(e){if(!e||"object"!==typeof e)return(0,c.A)({},rL);const t=!1===e.criteria_exists?null:e.criteria||e;return t&&"object"===typeof t?{required_criteria:Array.isArray(t.required_criteria)?t.required_criteria:[],preferred_criteria:Array.isArray(t.preferred_criteria)?t.preferred_criteria:[],dealbreakers:t.dealbreakers&&"object"===typeof t.dealbreakers?t.dealbreakers:{},dimension_weights:t.dimension_weights&&"object"===typeof t.dimension_weights?t.dimension_weights:{},evaluation_metadata:t.evaluation_metadata&&"object"===typeof t.evaluation_metadata?t.evaluation_metadata:{}}:(0,c.A)({},rL)}function dL(e){let{roleId:t}=e;
2const[n,a]=(0,s.useState)(t||null),[r,i]=(0,s.useState)(Boolean(t)),[o,l]=(0,s.useState)(null),[d,u]=(0,s.useState)(""),[m,p]=(0,s.useState)((0,c.A)({},aL)),[h,f]=(0,s.useState)((0,c.A)({},rL)),x=(0,s.useRef)({title:"",definition:(0,c.A)({},aL),criteria:(0,c.A)({},rL),updated_at:null,status:"draft"}),[v,g]=(0,s.useState)("draft"),[y,b]=(0,s.useState)(!1),w=(0,s.useCallback)(async()=>{if(t){i(!0),l(null);try{const n=await KP(t);if(!n)return void l("Role not found");const r=oL(n.structured_definition_json);let s=(0,c.A)({},rL);try{s=cL(await YP(t))}catch(e){s=(0,c.A)({},rL)}a(n.id),u(n.title||""),p(r),f(s),g(n.status||"draft"),x.current={title:n.title||"",definition:r,criteria:s,updated_at:n.updated_at||null,status:n.status||"draft"}}catch(mK){l((null===mK||void 0===mK?void 0:mK.message)||"Failed to load role")}finally{i(!1)}}},[t]);(0,s.useEffect)(()=>{w()},[w]);const j=(0,s.useCallback)(async e=>{if(n)return n;const t=(e||"").trim();if(!t)throw new Error("Title is required to save a new draft");const r=await async function(e){let{title:t,structured_definition_json:n}=e;return(0,zt.n)("/api/employer/roles",{method:"POST",body:JSON.stringify({title:t,structured_definition_json:n||{}})})}({title:t,structured_definition_json:{}}),s=(null===r||void 0===r?void 0:r.role)||r;if(!s||!s.id)throw new Error("Server did not return the created role");return a(s.id),g(s.status||"draft"),x.current={title:s.title||t,definition:oL(s.structured_definition_json),criteria:(0,c.A)({},rL),updated_at:s.updated_at||null,status:s.status||"draft"},s.id},[n]),k=(0,s.useCallback)(async e=>{var t,n;let{title:a,definition:r}=e;const s=await j(a),i={};let o;(a||"")!==(x.current.title||"")&&(i.title=(a||"").trim()),i.structured_definition_json=lL(r);try{o=await async function(e,t){if(!e)throw new Error("rolesApi.patchRole: id is required");return(0,zt.n)("/api/employer/roles/".concat(encodeURIComponent(e)),{method:"PATCH",body:JSON.stringify(t)})}(s,i)}catch(mK){throw mK}const l=(null===(t=o)||void 0===t?void 0:t.role)||o;return x.current=(0,c.A)((0,c.A)({},x.current),{},{title:null!==(n=null===l||void 0===l?void 0:l.title)&&void 0!==n?n:a,definition:oL(null===l||void 0===l?void 0:l.structured_definition_json)||r,updated_at:(null===l||void 0===l?void 0:l.updated_at)||x.current.updated_at,status:(null===l||void 0===l?void 0:l.status)||x.current.status}),null!==l&&void 0!==l&&l.status&&g(l.status),l},[j]),N=(0,s.useCallback)(async e=>{if(!n)throw new Error("Cannot save criteria before the role draft exists");let t;try{t=await async function(e,t){if(!e)throw new Error("rolesApi.patchCriteria: id is required");return(0,zt.n)("/api/employer/roles/".concat(encodeURIComponent(e),"/criteria"),{method:"PATCH",body:JSON.stringify(t)})}(n,e)}
2catch(mK){throw f(x.current.criteria),mK}return x.current=(0,c.A)((0,c.A)({},x.current),{},{criteria:cL(t)}),t},[n]);const _=(0,s.useCallback)(async()=>{b(!1),await w()},[w]);return{id:n,status:v,loading:r,loadError:o,title:d,setTitle:u,definition:m,setDefinition:p,criteria:h,setCriteria:f,savedTitle:x.current.title,savedDefinition:x.current.definition,savedCriteria:x.current.criteria,dirtyDefinition:function(){return(d||"")!==(x.current.title||"")||JSON.stringify(m)!==JSON.stringify(x.current.definition)},dirtyCriteria:function(){return JSON.stringify(h)!==JSON.stringify(x.current.criteria)},saveBasicsResponsibilities:k,saveCriteria:N,ensureCreated:j,staleTab:y,reloadFromServer:_}}const uL=[{n:1,key:"basics",title:"Basics",enabled:!0},{n:2,key:"responsibilities",title:"Responsibilities & skills",enabled:!0},{n:3,key:"criteria",title:"Criteria & dealbreakers",enabled:!0},{n:4,key:"review",title:"Review & publish",enabled:!0}];function mL(e){if(!e)return"";const t=Date.now(),n=new Date(e).getTime();if(Number.isNaN(n))return"";const a=Math.max(0,Math.round((t-n)/1e3));return a<5?"just now":a<60?"".concat(a,"s ago"):a<3600?"".concat(Math.floor(a/60),"m ago"):"".concat(Math.floor(a/3600),"h ago")}function pL(e){let{status:t,lastSavedAt:n,error:a}=e;const[,r]=(0,s.useState)(0);return(0,s.useEffect)(()=>{const e=setInterval(()=>r(e=>e+1),3e4);return()=>clearInterval(e)},[]),"saving"===t?(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-slate-300","data-testid":"wizard-save-indicator-saving",children:[(0,Xt.jsx)(Lg,{className:"h-3 w-3 animate-spin"}),"Saving\u2026"]}):"pending"===t?(0,Xt.jsx)("span",{className:"inline-flex items-center gap-1 text-xs text-amber-200","data-testid":"wizard-save-indicator-pending",children:"Unsaved changes"}):"error"===t?(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-rose-200",title:a||"","data-testid":"wizard-save-indicator-error",children:[(0,Xt.jsx)(Oy,{className:"h-3 w-3"}),"Save failed \u2014 retry"]}):"saved"===t&&n?(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-emerald-200",title:new Date(n).toISOString(),"data-testid":"wizard-save-indicator-saved",children:[(0,Xt.jsx)(Zm,{className:"h-3 w-3"}),"Saved \xb7 ",mL(n)]}):(0,Xt.jsx)("span",{className:"text-xs text-slate-300","data-testid":"wizard-save-indicator-idle",children:"No changes yet"})}function hL(e){let{step:t,onStepChange:n,roleId:a,roleTitle:r,status:s,saveStatus:i,saveError:o,lastSavedAt:l,dirty:c,onSaveDraft:d,staleTab:u,onReloadStale:m,children:p}=e;const h=ke(),f=Math.max(0,Math.min(uL.length-1,(t||1)-1)),x=uL[f],v=f>0?uL[f-1]:null,g=f<uL.length-1?uL[f+1]:null;return(0,Xt.jsxs)("div",{className:"space-y-6 p-6","data-testid":"role-wizard-layout",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:()=>h("/employer/roles"),"data-testid":"wizard-back-to-roles",children:[(0,Xt.jsx)(Zg,{className:"mr-2 h-4 w-4"}),"Back to roles"]}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,Xt.jsx)(pL,{status:i,error:o,lastSavedAt:l}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:d,disabled:!c||"saving"===i,"data-testid":"wizard-save-draft",children:[(0,Xt.jsx)($N,{className:"mr-2 h-4 w-4"}),"Save draft"]})]})]}),(0,Xt.jsxs)("header",{className:"space-y-1",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold text-ndor-ink",children:a?r||"(untitled)":"Create role"}),s?(0,Xt.jsx)(XP,{status:s}):null]}),(0,Xt.jsx)("p",{className:"text-sm text-slate-300",children:"Draft authoring \xb7 Steps 1\u20133. Publishing arrives in the next slice."})]}),(0,Xt.jsx)("ol",{className:"flex flex-wrap items-center gap-2","data-testid":"wizard-stepper",children:uL.map((e,t)=>{const r=t===f,s=t<f,i=e.enabled&&!("review"===e.key&&!a);return(0,Xt.jsxs)("li",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)("button",{type:"button",disabled:!i,onClick:()=>i&&n(e.n),className:"rounded-full border px-3 py-1.5 text-sm transition-colors "+(r?"border-slate-900 bg-slate-900 text-white":s?"border-emerald-500/40 bg-emerald-500/10 text-emerald-200":"border-slate-200 bg-ndor-surface text-slate-300 hover:bg-ndor-surface-alt")+(i?"":" opacity-50 cursor-not-allowed"),"data-testid":"wizard-step-tab-".concat(e.key),title:i||"review"!==e.key?void 0:"Save the draft first to enable Review & publish",children:[(0,Xt.jsx)("span",{className:"font-mono mr-2",children:e.n}),e.title,i?null:(0,Xt.jsx)(b_,{className:"inline ml-2 h-3 w-3"})]}
2),t<uL.length-1?(0,Xt.jsx)("span",{"aria-hidden":!0,className:"text-slate-300",children:"\xb7"}):null]},e.key)})}),(0,Xt.jsx)("div",{className:"rounded-md border border-slate-200 bg-ndor-surface","data-testid":"wizard-step-body-".concat(x.key),children:p}),(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",disabled:!v||!v.enabled,onClick:()=>v&&n(v.n),"data-testid":"wizard-prev-step",children:[(0,Xt.jsx)(Wn,{className:"mr-2 h-4 w-4"}),v?v.title:"Previous"]}),(0,Xt.jsxs)(Rr,{size:"sm",disabled:!g||"review"===g.key&&!a||!a&&1===x.n&&!c,onClick:()=>{g&&("review"!==g.key||a)&&n(g.n)},title:g&&"review"===g.key&&!a?"Save the draft first to enable Review & publish":void 0,"data-testid":"wizard-next-step",children:[g?g.title:"Finish",(0,Xt.jsx)(qn,{className:"ml-2 h-4 w-4"})]})]}),(0,Xt.jsx)(rg,{open:Boolean(u),onOpenChange:e=>{e||m()},children:(0,Xt.jsxs)(lg,{"data-testid":"wizard-stale-tab-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{children:"This role was edited elsewhere"}),(0,Xt.jsx)(mg,{children:"We detected a newer version of this role on the server. Reload to pick up the latest changes before continuing. Your unsaved edits in this tab will be discarded."})]}),(0,Xt.jsx)(dg,{children:(0,Xt.jsx)(Rr,{onClick:m,"data-testid":"wizard-stale-tab-reload",children:"Reload role"})})]})})]})}const fL=["remote","hybrid","onsite"],xL=["GBP","USD","EUR","AED","QAR","SAR","CAD","AUD"];function vL(e){let{value:t,onChange:n}=e;const a=t&&"object"===typeof t?t:{},r=(e,t)=>{const r=(0,c.A)({},a);""===t||null===t||void 0===t?delete r[e]:r[e]=t,n(0===Object.keys(r).length?null:r)};return(0,Xt.jsxs)("div",{className:"grid grid-cols-3 gap-3","data-testid":"basics-comp-band",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-slate-300",children:"Currency"}),(0,Xt.jsxs)(Vv,{value:a.currency||"",onValueChange:e=>r("currency",e),children:[(0,Xt.jsx)(Wv,{"data-testid":"basics-comp-currency",children:(0,Xt.jsx)(qv,{placeholder:"\u2014"})}),(0,Xt.jsx)(Kv,{children:xL.map(e=>(0,Xt.jsx)(Yv,{value:e,children:e},e))})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-slate-300",children:"Min"}),(0,Xt.jsx)(Ag,{type:"number",inputMode:"numeric",min:0,value:Number.isFinite(a.min)?String(a.min):"",onChange:e=>{const t=e.target.value;r("min",""===t?"":Math.max(0,parseInt(t,10)||0))},"data-testid":"basics-comp-min"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-xs text-slate-300",children:"Max"}),(0,Xt.jsx)(Ag,{type:"number",inputMode:"numeric",min:0,value:Number.isFinite(a.max)?String(a.max):"",onChange:e=>{const t=e.target.value;r("max",""===t?"":Math.max(0,parseInt(t,10)||0))},"data-testid":"basics-comp-max"})]})]})}function gL(e){let{title:t,definition:n,onTitleChange:a,onDefinitionChange:r}=e;const s=n||{},i=e=>r((0,c.A)((0,c.A)({},s),e));return(0,Xt.jsxs)("div",{className:"space-y-6 p-6","data-testid":"wizard-step-basics",children:[(0,Xt.jsxs)("header",{children:[(0,Xt.jsx)("h2",{className:"text-base font-semibold text-ndor-ink",children:"Basics"}),(0,Xt.jsx)("p",{className:"text-sm text-slate-300",children:"A title is required to save the draft. Everything else can stay empty until you're ready to publish."})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,Xt.jsxs)("div",{className:"md:col-span-2",children:[(0,Xt.jsxs)(Pg,{htmlFor:"basics-title",className:"text-sm",children:["Role title ",(0,Xt.jsx)("span",{className:"text-rose-200",children:"*"})]}),(0,Xt.jsx)(Ag,{id:"basics-title",value:t||"",onChange:e=>a(e.target.value),maxLength:200,placeholder:"e.g. Senior Reservoir Engineer","data-testid":"basics-title-input"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{htmlFor:"basics-domain",className:"text-sm",children:"Must-have domain"}),(0,Xt.jsx)(Ag,{id:"basics-domain",value:s.must_have_domain||"",onChange:e=>i({must_have_domain:e.target.value||null}),maxLength:120,placeholder:"e.g. upstream oil & gas","data-testid":"basics-domain-input"}),(0,Xt.jsx)("p",{className:"mt-1 text-xs text-slate-300",children:"Required to publish. Drives the must-have filter at evaluation time."})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)(Pg,{className:"text-sm",children:"Working model"}),(0,Xt.jsxs)(Vv,{value:s.working_model||"",onValueChange:e=>i({working_model:e||null}),children:[(0,Xt.jsx)(Wv,{"data-testid":"basics-working-model",children:(0,Xt.jsx)(qv,{placeholder:"\u2014"})}),(0,Xt.jsx)(Kv,{children:fL.map(e=>(0,Xt.jsx)(Yv,{value:e,"data-testid":"basics-working-model-".concat(e),children:e},e))})]})]}),(0,Xt.jsxs)("div",{className:"md:col-span-2",children:[(0,Xt.jsx)(Pg,{htmlFor:"basics-location",className:"text-sm",children:"Location constraint"}),(0,Xt.jsx)(Ag,{id:"basics-location",value:s.location_constraint||"",onChange:e=>i({location_constraint:e.target.value||null}),maxLength:120,placeholder:"e.g. Doha-based or UK-remote","data-testid":"basics-location-input"})]}),(0,Xt.jsxs)("div",{className:"md:col-span-2",children:[(0,Xt.jsx)(Pg,{className:"text-sm",children:"Compensation band"}),(0,Xt.jsx)(vL,{value:s.comp_band,onChange:e=>i({comp_band:e})}),(0,Xt.jsx)("p",{className:"mt-1 text-xs text-slate-300",children:"All three fields are required when any one is provided."})]})]})]})}const yL=200;function bL(e){let{value:t,onChange:n,placeholder:a,tone:r="emerald",dataTestid:i}=e;
2const o=Array.isArray(t)?t:[],[l,c]=(0,s.useState)(""),[d,u]=(0,s.useState)(null);function m(e){const{next:t,error:a}=function(e,t){const n=String(t||"").trim();if(!n)return{next:e,error:null};if(n.length>yL)return{next:e,error:"Max ".concat(yL," characters per entry")};const a=new Set(e.map(e=>e.toLowerCase()));return a.has(n.toLowerCase())?{next:e,error:null}:e.length>=60?{next:e,error:"Maximum of ".concat(60," entries reached")}:{next:[...e,n.slice(0,yL)],error:null}}(o,e);u(a),t!==o&&n(t),c("")}function p(e){const t=o.filter((t,n)=>n!==e);n(t),u(null)}const h="sky"===r?"bg-sky-500/10 text-sky-200":"bg-emerald-500/10 text-emerald-200";return(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":i||"criteria-chip-input",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5",children:[o.map((e,t)=>(0,Xt.jsxs)(Vw,{className:"".concat(h," border-transparent"),"data-testid":"".concat(i||"criteria","-chip-").concat(t),children:[(0,Xt.jsx)("span",{className:"truncate max-w-[200px]",children:e}),(0,Xt.jsx)("button",{type:"button","aria-label":"Remove ".concat(e),className:"ml-1 rounded hover:bg-black/10",onClick:()=>p(t),"data-testid":"".concat(i||"criteria","-chip-remove-").concat(t),children:(0,Xt.jsx)(xh,{className:"h-3 w-3"})})]},"".concat(e,"-").concat(t))),(0,Xt.jsx)(Ag,{type:"text",className:"border-0 h-7 flex-1 min-w-[120px] shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",value:l,onChange:e=>{c(e.target.value),u(null)},onKeyDown:function(e){"Enter"===e.key||","===e.key?(e.preventDefault(),m(l)):"Backspace"===e.key&&""===l&&o.length>0&&(e.preventDefault(),p(o.length-1))},onBlur:()=>l&&m(l),placeholder:a||"Type and press Enter\u2026",maxLength:201,"data-testid":"".concat(i||"criteria","-input")})]}),(0,Xt.jsx)("div",{className:"flex items-center justify-between text-xs",children:(0,Xt.jsx)("span",{className:d?"text-rose-200":"text-slate-300",children:d||"".concat(o.length," / ").concat(60," entries \xb7 ").concat(yL," char max each")})})]})}function wL(e){let{value:t,onChange:n}=e;const a=Array.isArray(t)?t:[];return(0,Xt.jsxs)("div",{className:"space-y-2","data-testid":"responsibilities-editor",children:[0===a.length?(0,Xt.jsx)("p",{className:"text-xs text-slate-300",children:"Add at least one responsibility before publishing."}):null,a.map((e,t)=>(0,Xt.jsxs)("div",{className:"flex items-start gap-2","data-testid":"responsibility-row-".concat(t),children:[(0,Xt.jsx)(Hw,{value:e,onChange:e=>((e,t)=>{const r=[...a];r[e]=t,n(r)})(t,e.target.value.slice(0,400)),rows:2,maxLength:401,placeholder:"e.g. Lead reservoir simulation studies for ...","data-testid":"responsibility-input-".concat(t)}),(0,Xt.jsx)(Rr,{type:"button",size:"sm",variant:"ghost",onClick:()=>(e=>{const t=a.filter((t,n)=>n!==e);n(t)})(t),"data-testid":"responsibility-remove-".concat(t),"aria-label":"Remove responsibility",children:(0,Xt.jsx)(pb,{className:"h-4 w-4"})})]},"r-".concat(t))),(0,Xt.jsxs)(Rr,{type:"button",size:"sm",variant:"outline",onClick:()=>{a.length>=30||n([...a,""])},disabled:a.length>=30,"data-testid":"responsibility-add",children:[(0,Xt.jsx)(Ow,{className:"mr-1 h-4 w-4"}),"Add responsibility"]}),(0,Xt.jsxs)("p",{className:"text-xs text-slate-300",children:[a.length," / ",30," entries \xb7 ",400," char max each"]})]})}function jL(e){let{definition:t,onDefinitionChange:n}=e;const a=t||{},r=e=>n((0,c.A)((0,c.A)({},a),e));return(0,Xt.jsxs)("div",{className:"space-y-6 p-6","data-testid":"wizard-step-responsibilities",children:[(0,Xt.jsxs)("header",{children:[(0,Xt.jsx)("h2",{className:"text-base font-semibold text-ndor-ink",children:"Responsibilities & skills"}),(0,Xt.jsx)("p",{className:"text-sm text-slate-300",children:"What the person will do and what they MUST bring. Nice-to-haves are tie-breakers \u2014 not gates."})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{className:"text-sm",children:"Responsibilities"}),(0,Xt.jsx)(wL,{value:a.responsibilities,onChange:e=>r({responsibilities:e})})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{className:"text-sm",children:"Must-have skills"}),(0,Xt.jsx)(bL,{value:a.must_have_skills||[],onChange:e=>r({must_have_skills:e}),placeholder:"Add a must-have skill and press Enter\u2026",tone:"emerald",dataTestid:"must-have-skills"}),(0,Xt.jsxs)("p",{className:"text-xs text-slate-300",children:["Each up to ",yL," chars. Required for publish."]})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{className:"text-sm",children:"Nice-to-have skills"}),(0,Xt.jsx)(bL,{value:a.nice_to_have_skills||[],onChange:e=>r({nice_to_have_skills:e}),placeholder:"Add a nice-to-have and press Enter\u2026",tone:"sky",dataTestid:"nice-to-have-skills"}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300",children:"Already-listed must-haves are removed automatically by the backend on save."})]})]})}const kL=["timezone","clearance","work_authorization","language"],NL={timezone:"e.g. UTC\xb12",clearance:"e.g. SC required",work_authorization:"e.g. UK right-to-work",language:"e.g. English C1"};function _L(e){let{value:t,onChange:n}=e;const a=t&&"object"===typeof t?t:{};function r(e,t){if(void 0===t||null===t||""===t){const t=(0,c.A)({},a);delete t[e],n(t)}else n((0,c.A)((0,c.A)({},a),{},{[e]:t}))}return(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"dealbreakers-editor",children:[kL.map(e=>{const t=a[e]||"";return(0,Xt.jsxs)("div",{className:"grid grid-cols-3 items-center gap-3","data-testid":"dealbreaker-row-".concat(e),children:[(0,Xt.jsx)(Pg,{className:"text-sm capitalize text-slate-200",children:e.replace(/_/g," ")}),(0,Xt.jsx)(Ag,{type:"text",value:t,maxLength:200,placeholder:NL[e],onChange:t=>r(e,t.target.value),className:"col-span-2","data-testid":"dealbreaker-input-".concat(e)}),t?(0,Xt.jsxs)(Rr,{type:"button",size:"sm",variant:"ghost",onClick:()=>r(e,""),className:"col-start-3 justify-self-end -mt-3","data-testid":"dealbreaker-clear-".concat(e),children:[(0,Xt.jsx)(pb,{className:"mr-1 h-3 w-3"}),"Clear"]}):null]},e)}),(0,Xt.jsx)("p",{className:"text-xs text-slate-300",children:"Dealbreakers are evaluated in Phase 2.E. Unknown keys are not accepted by the backend."})]})}const DL=wn("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),CL=["seniority","domain_alignment","evidence_strength","location","risk"],AL={seniority:25,domain_alignment:30,evidence_strength:25,location:10,risk:10};function SL(e){let{value:t,onChange:n}=e;const a=(0,s.useMemo)(()=>{const e=(0,c.A)({},AL);if(t&&"object"===typeof t)for(const n of CL)"number"===typeof t[n]&&(e[n]=t[n]);return e},[t]),r=CL.reduce((e,t)=>
2e+(a[t]||0),0),i=100===r;return(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"dimension-weight-sliders",children:[(0,Xt.jsx)("div",{className:"grid grid-cols-1 gap-4",children:CL.map(e=>(0,Xt.jsxs)("div",{className:"space-y-1","data-testid":"weight-row-".concat(e),children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsx)(Pg,{className:"text-sm capitalize text-slate-200",children:e.replace(/_/g," ")}),(0,Xt.jsx)("span",{className:"font-mono text-sm text-slate-100","data-testid":"weight-value-".concat(e),children:a[e]})]}),(0,Xt.jsx)(gF,{min:0,max:100,step:1,value:[a[e]],onValueChange:t=>function(e,t){const r=Math.max(0,Math.min(100,Math.round(t)));n((0,c.A)((0,c.A)({},a),{},{[e]:r}))}(e,t[0]),"data-testid":"weight-slider-".concat(e)})]},e))}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Xt.jsxs)("span",{className:"text-sm font-medium ".concat(i?"text-emerald-200":"text-amber-200"),"data-testid":"weight-total",children:["Total = ",r,i?" \u2713":" \xb7 must equal 100"]}),(0,Xt.jsxs)(Rr,{type:"button",size:"sm",variant:"ghost",onClick:function(){n((0,c.A)({},AL))},"data-testid":"weight-restore-defaults",children:[(0,Xt.jsx)(DL,{className:"mr-2 h-3 w-3"}),"Restore defaults"]})]})]})}const EL=1e3;function FL(e){let{roleId:t,criteria:n,onCriteriaChange:a}=e;if(!t)return(0,Xt.jsx)("div",{className:"p-6 text-sm text-slate-300","data-testid":"wizard-step-criteria-locked",children:"Save the draft on Step 1 (a title is enough) before refining criteria \u2014 these settings live in a companion table that needs the role row to exist first."});const r=n||{},s=e=>a((0,c.A)((0,c.A)({},r),e)),i=r.evaluation_metadata&&r.evaluation_metadata.notes||"";return(0,Xt.jsxs)("div",{className:"space-y-6 p-6","data-testid":"wizard-step-criteria",children:[(0,Xt.jsxs)("header",{children:[(0,Xt.jsx)("h2",{className:"text-base font-semibold text-ndor-ink",children:"Criteria & dealbreakers"}),(0,Xt.jsx)("p",{className:"text-sm text-slate-300",children:"Criteria refinements take effect at evaluation time. They do not change publish requirements \u2014 the publish gate only reads the role definition from Steps 1 & 2."})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{className:"text-sm",children:"Required criteria"}),(0,Xt.jsx)(bL,{value:r.required_criteria||[],onChange:e=>s({required_criteria:e}),placeholder:"Add a required criterion and press Enter\u2026",tone:"emerald",dataTestid:"required-criteria"})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{className:"text-sm",children:"Preferred criteria"}),(0,Xt.jsx)(bL,{value:r.preferred_criteria||[],onChange:e=>s({preferred_criteria:e}),placeholder:"Add a preferred criterion and press Enter\u2026",tone:"sky",dataTestid:"preferred-criteria"})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{className:"text-sm",children:"Dealbreakers"}),(0,Xt.jsx)(_L,{value:r.dealbreakers||{},onChange:e=>s({dealbreakers:e})})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{className:"text-sm",children:"Dimension weights"}),(0,Xt.jsx)(SL,{value:r.dimension_weights||{},onChange:e=>s({dimension_weights:e})})]}),(0,Xt.jsxs)("section",{className:"space-y-2",children:[(0,Xt.jsx)(Pg,{htmlFor:"criteria-notes",className:"text-sm",children:"Evaluation notes"}),(0,Xt.jsx)(Hw,{id:"criteria-notes",value:i,onChange:e=>{const t=e.target.value.slice(0,EL),n=(0,c.A)({},r.evaluation_metadata||{});t?n.notes=t:delete n.notes,s({evaluation_metadata:n})},rows:4,maxLength:1001,placeholder:"Free-text notes for reviewers \u2014 kept on the role; never shown to candidates.","data-testid":"criteria-notes-input"}),(0,Xt.jsxs)("p",{className:"text-xs text-slate-300",children:[i.length," / ",EL," chars"]})]})]})}const RL=wn("rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]),IL=Object.freeze({NO_TITLE:"NO_TITLE",MISSING_DOMAIN:"MISSING_DOMAIN",MISSING_COMP_BAND:"MISSING_COMP_BAND",NO_RESPONSIBILITIES:"NO_RESPONSIBILITIES",NO_MUST_HAVE_SKILLS:"NO_MUST_HAVE_SKILLS"});function TL(e){let{title:t,definition:n}=e;const a=[],r=n&&"object"===typeof n?n:{};(t||"").trim()||a.push({code:IL.NO_TITLE,step:1,message:"Add a role title.",fixHint:"A title is required to identify the role."}),r.must_have_domain&&""!==String(r.must_have_domain).trim()||a.push({code:IL.MISSING_DOMAIN,step:1,message:"Choose a primary domain.",fixHint:"Drives the must-have filter at evaluation time."});const s=r.comp_band;s&&"object"===typeof s&&"string"===typeof s.currency&&""!==s.currency.trim()&&null!==s.min&&void 0!==s.min&&Number.isFinite(Number(s.min))||a.push({code:IL.MISSING_COMP_BAND,step:1,message:"Specify a compensation band (currency + minimum required).",fixHint:"Min is required; Max is optional but recommended."});(Array.isArray(r.responsibilities)?r.responsibilities:[]).filter(e=>""!==(e||"").trim()).length<1&&a.push({code:IL.NO_RESPONSIBILITIES,step:2,message:"Add at least one responsibility.",fixHint:"Even one bullet makes downstream evaluation possible."});return(Array.isArray(r.must_have_skills)?r.must_have_skills:[]).filter(e=>""!==(e||"").trim()).length<1&&a.push({code:IL.NO_MUST_HAVE_SKILLS,step:2,message:"Add at least one must-have skill.",fixHint:"Must-have skills are the hard gates at evaluation time."}),a}function PL(e){return Array.isArray(e)&&e.length>0}function OL(e){return e&&"object"===typeof e&&!Array.isArray(e)}function BL(e){var t;let{roleId:n,title:a,definition:r,criteria:i,onJumpToStep:o,onPublish:l}=e;const c=(0,s.useMemo)(()=>TL({title:a,definition:r}),[a,r]);if(!n)return(0,Xt.jsx)("div",{className:"p-6 text-sm text-slate-300","data-testid":"wizard-step-review-locked",children:"Save the draft on Step 1 before reviewing \u2014 Publish dispatches against the saved row."});const d=r||{},u=i||{},m=OL(d.comp_band)?d.comp_band:null,p=PL(d.responsibilities)?d.responsibilities:[],h=PL(d.must_have_skills)?d.must_have_skills:[],f=PL(d.nice_to_have_skills)?d.nice_to_have_skills:[],x=PL(u.required_criteria)?u.required_criteria:[],v=PL(u.preferred_criteria)?u.preferred_criteria:[],g=OL(u.dealbreakers)?u.dealbreakers:{},y=OL(u.dimension_weights)?u.dimension_weights:{},b=0===c.length;return(0,Xt.jsxs)("div",{className:"space-y-6 p-6","data-testid":"wizard-step-review",children:[(0,Xt.jsxs)("header",{children:[(0,Xt.jsx)("h2",{className:"text-base font-semibold text-ndor-ink",children:"Review & publish"}),(0,Xt.jsx)("p",{className:"text-sm text-slate-300",children:"Confirm the role definition. Publishing is one-way for the draft \u2192 active transition; close + archive remain available afterwards."})]}),(0,Xt.jsxs)(Fy,{"data-testid":"publish-blocker-checklist",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsxs)(Iy,{className:"text-base flex items-center gap-2",children:[b?(0,Xt.jsx)(Og,{className:"h-5 w-5 text-emerald-600"}):(0,Xt.jsx)(Oy,{className:"h-5 w-5 text-amber-600"}),b?"Ready to publish":"Publish blockers"]})}),(0,Xt.jsx)(Py,{className:"space-y-2",children:b?(0,Xt.jsx)("p",{className:"text-sm text-emerald-200","data-testid":"publish-blockers-empty",children:"All required fields are filled. You can publish this role now."}):(0,Xt.jsx)("ul",{className:"space-y-2","data-testid":"publish-blockers-list",children:c.map(e=>(0,Xt.jsxs)("li",{className:"flex items-start gap-3 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm","data-testid":"publish-blocker-".concat(e.code),children:[(0,Xt.jsx)(Oy,{className:"mt-0.5 h-4 w-4 text-amber-200"}),(0,Xt.jsxs)("div",{className:"flex-1",children:[(0,Xt.jsx)("div",{className:"font-medium text-ndor-ink",children:e.message}),(0,Xt.jsx)("div",{className:"text-xs text-slate-300",children:e.fixHint})]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:()=>o(e.step),"data-testid":"publish-blocker-fix-".concat(e.code),children:["Fix this",(0,Xt.jsx)(zy,{className:"ml-1 h-3 w-3"})]})]},e.code))})})]}),(0,Xt.jsxs)(Fy,{"data-testid":"review-definition-summary",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsx)(Iy,{className:"text-base",children:"Role definition"})}),(0,Xt.jsxs)(Py,{className:"space-y-4 text-sm",children:[(0,Xt.jsxs)("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Title"}),(0,Xt.jsx)("dd",{className:"text-slate-100","data-testid":"review-title",children:(a||"").trim()||(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Must-have domain"}),(0,Xt.jsx)("dd",{className:"text-slate-100","data-testid":"review-domain",children:d.must_have_domain||(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Working model"}),(0,Xt.jsx)("dd",{className:"text-slate-100",children:d.working_model||(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("dt",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Location"}),(0,Xt.jsx)("dd",{className:"text-slate-100",children:d.location_constraint||(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})})]}),(0,Xt.jsxs)("div",{className:"col-span-2",children:[(0,Xt.jsx)("dt",{className:"text-xs uppercase tracking-wide text-slate-300",children:"Compensation band"}),(0,Xt.jsx)("dd",{className:"text-slate-100","data-testid":"review-comp-band",children:m?"".concat(m.currency||""," ").concat(null!==(t=m.min)&&void 0!==t?t:"?").concat(null!=m.max?"\u2013".concat(m.max):"").trim():(0,Xt.jsx)("span",{className:"text-slate-300",children:"\u2014"})})]})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Responsibilities"}),p.length>0?(0,Xt.jsx)("ul",{className:"list-disc pl-5 text-slate-100","data-testid":"review-responsibilities",children:p.map((e,t)=>(0,Xt.jsx)("li",{children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none yet"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Must-have skills"}),h.length>0?(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1","data-testid":"review-must-skills",children:h.map((e,t)=>(0,Xt.jsx)(Vw,{className:"bg-emerald-500/10 text-emerald-200 border-transparent",children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none yet"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Nice-to-have skills"}),f.length>0?(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1",children:f.map((e,t)=>(0,Xt.jsx)(Vw,{className:"bg-sky-500/10 text-sky-200 border-transparent",children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none yet"})]})]})]}),(0,Xt.jsxs)(Fy,{"data-testid":"review-criteria-summary",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsx)(Iy,{className:"text-base",children:"Evaluation criteria"})}),(0,Xt.jsxs)(Py,{className:"space-y-4 text-sm",children:[(0,Xt.jsxs)("p",{className:"flex items-start gap-2 rounded-md bg-ndor-surface-alt p-3 text-xs text-slate-300","data-testid":"review-criteria-disclaimer",children:[(0,Xt.jsx)(zf,{className:"mt-0.5 h-3 w-3"}),"Criteria refinements take effect at evaluation time. They do not change publish requirements."]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Dimension weights"}),(0,Xt.jsx)("div",{className:"grid grid-cols-2 gap-2",children:["seniority","domain_alignment","evidence_strength","location","risk"].map(e=>{var t;return(0,Xt.jsxs)("div",{className:"flex items-center justify-between rounded-md bg-ndor-surface-alt px-3 py-2","data-testid":"review-weight-".concat(e),children:[(0,Xt.jsx)("span",{className:"text-slate-300",children:e}),(0,Xt.jsx)("span",{className:"font-mono text-slate-100",children:null!==(t=y[e])&&void 0!==t?t:0})]},e)})})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Required criteria"}),x.length>0?(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1",children:x.map((e,t)=>(0,Xt.jsx)(Vw,{className:"bg-emerald-500/10 text-emerald-200 border-transparent",children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Preferred criteria"}),v.length>0?(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1",children:v.map((e,t)=>(0,Xt.jsx)(Vw,{className:"bg-sky-500/10 text-sky-200 border-transparent",children:e},t))}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none"})]}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-slate-300",children:"Dealbreakers"}
2),Object.keys(g).length>0?(0,Xt.jsx)("div",{className:"grid grid-cols-2 gap-1 text-xs",children:Object.entries(g).map(e=>{let[t,n]=e;return(0,Xt.jsxs)("div",{className:"rounded-md bg-rose-500/10 px-2 py-1 text-rose-200",children:[(0,Xt.jsxs)("span",{className:"font-medium",children:[t,":"]})," ",String(n)]},t)})}):(0,Xt.jsx)("div",{className:"text-slate-300",children:"\u2014 none"})]})]})]}),(0,Xt.jsxs)(Fy,{"data-testid":"review-publish-sideeffects",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsxs)(Iy,{className:"text-base flex items-center gap-2",children:[(0,Xt.jsx)(RL,{className:"h-4 w-4 text-slate-200"}),"What happens when you publish"]})}),(0,Xt.jsx)(Py,{children:(0,Xt.jsxs)("ol",{className:"list-decimal pl-5 text-sm text-slate-200 space-y-1",children:[(0,Xt.jsxs)("li",{"data-testid":"publish-effect-status",children:["Status flips ",(0,Xt.jsx)("code",{className:"font-mono",children:"draft \u2192 active"}),"."]}),(0,Xt.jsx)("li",{"data-testid":"publish-effect-criteria",children:"Criteria mirror is regenerated from your role definition. Your Step 3 weights & evaluation notes are preserved."}),(0,Xt.jsxs)("li",{"data-testid":"publish-effect-audit",children:["A ",(0,Xt.jsx)("code",{className:"font-mono",children:"role.published"})," governance audit row is recorded."]}),(0,Xt.jsxs)("li",{"data-testid":"publish-effect-counter",children:["Active-role counter increments if your plan is activated; otherwise the publish is audited with"," ",(0,Xt.jsx)("code",{className:"font-mono",children:"plan_unactivated=true"}),"."]})]})})]}),(0,Xt.jsx)("div",{className:"flex items-center justify-end",children:(0,Xt.jsxs)(Rr,{size:"lg",disabled:!b,onClick:l,"data-testid":"publish-cta",children:[(0,Xt.jsx)(Zm,{className:"mr-2 h-4 w-4"}),"Publish role"]})})]})}function LL(e){let{open:t,onCancel:n,onConfirm:a,pending:r,error:s}=e;return(0,Xt.jsx)(rg,{open:Boolean(t),onOpenChange:e=>{e||r||n()},children:(0,Xt.jsxs)(lg,{"data-testid":"publish-confirm-modal","aria-busy":r?"true":"false",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{"data-testid":"publish-confirm-title",children:"Publish this role?"}),(0,Xt.jsx)(mg,{"data-testid":"publish-confirm-copy",children:"Publishing makes the role visible to your account. You can soft-close (closing) or hard-close (closed) later, but draft \u2192 active is one-way."})]}),s?(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-200","data-testid":"publish-confirm-error",children:[(0,Xt.jsx)(mb,{className:"mt-0.5 h-4 w-4"}),(0,Xt.jsx)("div",{children:s})]}):null,(0,Xt.jsxs)(dg,{children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:n,disabled:r,"data-testid":"publish-confirm-cancel",children:"Cancel"}),(0,Xt.jsx)(Rr,{onClick:a,disabled:r,"data-testid":"publish-confirm-go",children:r?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"mr-2 h-4 w-4 animate-spin"}),"Publishing\u2026"]}):"Publish role"})]})]})})}function ML(){const{id:e}=_e(),t=ke(),[n,a]=Pt(),r=function(e){const t=parseInt(e,10);return Number.isFinite(t)?Math.max(1,Math.min(4,t)):1}(n.get("step")),i=dL({roleId:e||null}),{id:o,status:l,loading:c,loadError:d,title:u,setTitle:m,definition:p,setDefinition:h,criteria:f,setCriteria:x,dirtyDefinition:v,dirtyCriteria:g,saveBasicsResponsibilities:y,saveCriteria:b,staleTab:w,reloadFromServer:j}=i,k=(0,s.useRef)(o||null);(0,s.useEffect)(()=>{o&&(k.current=o)},[o]);const N=(0,s.useCallback)(async()=>{const n=!e,a=await y({title:u,definition:p});if(n){const e=a&&a.id||k.current;e&&t("/employer/roles/".concat(e,"/edit?step=").concat(r),{replace:!0})}return a},[y,u,p,e,t,r]),_=(0,s.useCallback)(async()=>b(f),[b,f]),D=nL(N),C=nL(_),A=3===r,S=v(),E=g();(0,s.useEffect)(()=>{A||S&&D.trigger({at:Date.now()})},[u,p,A]),(0,s.useEffect)(()=>{A&&o&&E&&C.trigger({at:Date.now()})},[f,A,o]);const F=(0,s.useCallback)(async e=>{try{3!==r&&S&&await D.flush(),3===r&&E&&await C.flush()}catch(mK){return void fy.error((null===mK||void 0===mK?void 0:mK.message)||"Could not save before navigating")}a({step:String(e)},{replace:!1})},[r,S,E,D,C,a]),R=(0,s.useCallback)(async()=>
2{try{3!==r&&S&&await D.flush(),3===r&&E&&await C.flush(),fy.success("Draft saved")}catch(mK){fy.error((null===mK||void 0===mK?void 0:mK.message)||"Save failed")}},[r,S,E,D,C]),I=A?C:D,T=A?E:S||1===r&&!o&&Boolean((u||"").trim()),P=(0,s.useMemo)(()=>{const e=uL.find(e=>e.n===r);return e?e.key:"basics"},[r]),[O,B]=(0,s.useState)(!1),[L,M]=(0,s.useState)(!1),[z,U]=(0,s.useState)(null),V=(0,s.useCallback)(async()=>{try{S&&await D.flush(),E&&await C.flush()}catch(mK){return void fy.error((null===mK||void 0===mK?void 0:mK.message)||"Save your draft before publishing")}U(null),B(!0)},[S,E,D,C]),q=(0,s.useCallback)(async()=>{if(o){M(!0),U(null);try{const e=await async function(e){if(!e)throw new Error("rolesApi.publishRole: id is required");return(0,zt.n)("/api/employer/roles/".concat(encodeURIComponent(e),"/publish"),{method:"POST",body:JSON.stringify({})})}(o),n=(null===e||void 0===e?void 0:e.role)||null;null!==e&&void 0!==e&&e.plan_unactivated?fy.success("Role published. Heads up: your plan isn\u2019t fully activated yet \u2014 counter not incremented."):null!==e&&void 0!==e&&e.already_active?fy.message("Role was already active."):fy.success("Role published."),B(!1),t("/employer/roles/".concat(n&&n.id||o),{replace:!0})}catch(mK){var e,n;const a=null!==(e=null!==(n=null===mK||void 0===mK?void 0:mK.detail)&&void 0!==n?n:null===mK||void 0===mK?void 0:mK.message)&&void 0!==e?e:"Publish failed";let r;r="string"===typeof a?a:a&&"object"===typeof a&&(a.detail||a.message||a.code)||"Publish failed",U(r)}finally{M(!1)}}},[o,t]),W=(0,s.useCallback)(()=>{L||(B(!1),U(null))},[L]);return c?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 p-8 text-sm text-slate-300","data-testid":"wizard-loading",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}),"Loading wizard\u2026"]}):d?(0,Xt.jsx)("div",{className:"p-6 text-sm text-rose-200","data-testid":"wizard-load-error",children:d}):(0,Xt.jsxs)(hL,{step:r,onStepChange:F,roleId:o,roleTitle:u,status:l,saveStatus:I.status,saveError:I.error,lastSavedAt:I.lastSavedAt,dirty:T,onSaveDraft:R,staleTab:w,onReloadStale:j,children:[(0,Xt.jsxs)("div",{"data-testid":"wizard-active-step-".concat(P),children:[1===r?(0,Xt.jsx)(gL,{title:u,definition:p,onTitleChange:m,onDefinitionChange:h}):null,2===r?(0,Xt.jsx)(jL,{definition:p,onDefinitionChange:h}):null,3===r?(0,Xt.jsx)(FL,{roleId:o,criteria:f,onCriteriaChange:x}):null,4===r?(0,Xt.jsx)(BL,{roleId:o,title:u,definition:p,criteria:f,onJumpToStep:e=>a({step:String(e)},{replace:!1}),onPublish:V}):null]}),(0,Xt.jsx)(LL,{open:O,onCancel:W,onConfirm:q,pending:L,error:z})]})}function zL(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();if(!e)return"\u2014";const n=new Date(e);if(Number.isNaN(n.getTime()))return"\u2014";const a=Math.floor((t-n.getTime())/1e3);if(a<0)return UL(n);if(a<60)return"just now";const r=Math.floor(a/60);if(r<60)return"".concat(r," minute").concat(1===r?"":"s"," ago");const s=Math.floor(r/60);return s<24?"".concat(s," hour").concat(1===s?"":"s"," ago"):UL(n)}function UL(e){return e.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}Object.freeze(["id","fit_score","confidence","decision_signal","match_rationale_json","surfaced_at"]);function VL(e){let{roleId:t,match:n,matchLabel:a,open:r,onOpenChange:i,onSent:o}=e;const[l,c]=(0,s.useState)(""),[d,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!r||!t||null===n||void 0===n||!n.id)return;let e=!1;return u(!0),c(""),(async()=>{try{const a=await(0,zt.n)("/api/employer/roles/".concat(t,"/matches/").concat(n.id,"/signal/prefill"));e||c((null===a||void 0===a?void 0:a.prefill)||"")}catch(a){e||c("")}finally{e||u(!1)}})(),()=>{e=!0}},[r,t,null===n||void 0===n?void 0:n.id]);const h=l.trim().length,f=h>600,x=!m&&h>0&&!f;return(0,Xt.jsx)(rg,{open:r,onOpenChange:i,children:(0,Xt.jsxs)(lg,{className:"max-w-xl bg-ndor-surface text-ndor-ink border border-ndor-edge","data-testid":"interest-signal-composer",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsx)(ug,{children:"Express interest"}),(0,Xt.jsx)(mg,{children:"The candidate will see this signal and your role details. Their identity remains private until they choose to accept."})]}),(0,Xt.jsxs)("div",{className:"space-y-3",children:[a&&(0,Xt.jsxs)("div",{className:"text-[11px] uppercase tracking-wider text-ndor-ink-muted",children:["Signalling for: ",a]}),d?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ndor-ink-muted py-6",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}),"Preparing suggested text\u2026"]}
2):(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted italic",children:"Pre-filled from match analysis. Edit freely."}),(0,Xt.jsx)(Hw,{value:l,onChange:e=>c(e.target.value),rows:9,className:"resize-none text-sm bg-ndor-bg text-ndor-ink placeholder:text-ndor-ink-muted border-ndor-edge focus-visible:ring-1 focus-visible:ring-ndor-glow",placeholder:"Introduce your interest in a few sentences\u2026","data-testid":"signal-body-input"})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between text-[11px]",children:[(0,Xt.jsxs)("span",{className:f?"text-rose-500":"text-ndor-ink-muted","data-testid":"signal-body-counter",children:[h,"/",600,f&&" \u2014 over limit"]}),(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"No contact details are exchanged until the candidate accepts this signal."})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-3 border-t border-ndor-edge",children:[(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>i(!1),disabled:m,"data-testid":"signal-cancel",children:"Cancel"}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:async()=>{if(x&&null!==n&&void 0!==n&&n.id){p(!0);try{const e=await(0,zt.n)("/api/employer/roles/".concat(t,"/matches/").concat(n.id,"/signal"),{method:"POST",body:JSON.stringify({signal_body:l.trim()})});null!==e&&void 0!==e&&e.already_sent?fy.info(a?"A pending signal already exists \xb7 ".concat(a,"."):"A pending signal already exists for this match."):fy.success(a?"Signal sent \xb7 ".concat(a):"Signal sent. Their identity remains private."),o&&o((null===e||void 0===e?void 0:e.signal)||null),i(!1)}catch(pK){var e;fy.error((null===pK||void 0===pK||null===(e=pK.data)||void 0===e?void 0:e.detail)||(null===pK||void 0===pK?void 0:pK.message)||"Could not send signal.")}finally{p(!1)}}},disabled:!x,"data-testid":"signal-send",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:[m?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(_n,{className:"h-4 w-4 mr-1.5"}),m?"Sending\u2026":"Send signal"]})]})]})})}const qL={surface:"state-pill state-pill--accepted",hold:"state-pill state-pill--pending",pass:"state-pill state-pill--muted"};function WL(e){return function(e){return"number"!==typeof e||Number.isNaN(e)?"\u2014":"".concat(Math.round(100*e),"%")}(e)}function HL(e){return function(e){return"Match ".concat(String(e+1).padStart(3,"0"))}(e)}function GL(e){var t;let{match:n,index:a,signal:r,onSendInterest:i,accountId:o,roleId:l,activeReviewerCount:c,onRouted:d}=e;const[u,m]=(0,s.useState)(!1),p=n.match_rationale_json||{},h=p.strengths||[],f=p.gaps||[],x=p.reasoning||"",v=Boolean(p.error),g=HL(a),y=qL[n.decision_signal]||qL.pass,b="pending"===(null===r||void 0===r?void 0:r.status)||"accepted"===(null===r||void 0===r?void 0:r.status)||"declined"===(null===r||void 0===r?void 0:r.status)||"deferred"===(null===r||void 0===r?void 0:r.status),w="revealed"===n.reveal_state&&n.revealed_profile,j=w?n.revealed_profile.full_name:g;return(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm transition hover:border-ndor-ink-muted ".concat(w?"state-rail--accepted":""),"data-testid":"match-card-".concat(n.id),children:(0,Xt.jsxs)(Py,{className:"p-5",children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-5",children:[(0,Xt.jsxs)("div",{className:"flex flex-col items-center shrink-0 min-w-[72px]",children:[(0,Xt.jsx)("div",{className:"text-2xl font-mono tabular-nums text-ndor-ink","data-testid":"match-fit-".concat(n.id),children:WL(n.fit_score)}),(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mt-0.5",children:"Fit"})]}),(0,Xt.jsxs)("div",{className:"flex-1 min-w-0 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,Xt.jsx)("span",{className:"text-sm font-semibold text-ndor-ink ".concat(w?"":"font-mono-ui tracking-wide"),"data-testid":"match-label-".concat(n.id),children:j}),w&&(0,Xt.jsx)("span",{className:"state-pill state-pill--accepted shrink-0","data-testid":"match-access-granted-".concat(n.id),children:"Access granted"}),(0,Xt.jsx)("span",{className:"".concat(y," capitalize shrink-0"),"data-testid":"match-signal-".concat(n.id),children:n.decision_signal}),(0,Xt.jsxs)("span",{className:"".concat("state-pill state-pill--muted"," capitalize shrink-0"),"data-testid":"match-confidence-".concat(n.id),children:[n.confidence," confidence"]}),v&&(0,Xt.jsx)("span",{className:"state-pill state-pill--declined
2shrink-0",children:"Requires retry"}),b&&!w&&(0,Xt.jsx)("span",{className:"state-pill state-pill--pending shrink-0","data-testid":"match-signal-sent-".concat(n.id),children:"Signal sent"})]}),!u&&x&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted line-clamp-2",children:x}),(0,Xt.jsx)("div",{className:"flex items-center gap-3 text-[11px] text-ndor-ink-muted",children:(0,Xt.jsxs)("span",{children:["Surfaced ",(k=n.surfaced_at,zL(k))]})})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[!v&&!b&&(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:()=>i&&i(n,g),"data-testid":"match-send-interest-".concat(n.id),children:[(0,Xt.jsx)(_n,{className:"h-4 w-4 mr-1.5"})," Send interest"]}),w&&n.candidate_id&&(0,Xt.jsx)(MO,{matchId:n.id,candidateId:n.candidate_id,accountId:o,roleId:l,activeReviewerCount:c,onRouted:d}),(0,Xt.jsx)(Rr,{size:"sm",variant:"ghost",onClick:()=>m(e=>!e),"data-testid":"match-toggle-".concat(n.id),"aria-label":u?"Collapse match details":"Expand match details","aria-expanded":u,children:(0,Xt.jsx)(Gn,{className:"h-4 w-4 transition-transform duration-150 ".concat(u?"rotate-180":"")})})]})]}),u&&(0,Xt.jsxs)("div",{className:"mt-5 pt-5 border-t border-ndor-edge space-y-4","data-testid":"match-detail-".concat(n.id),children:[w&&(0,Xt.jsxs)("div",{className:"rounded-md border px-4 py-3 space-y-2",style:{backgroundColor:"hsl(var(--ndor-state-accepted-bg))",borderColor:"hsl(var(--ndor-state-accepted-border))"},"data-testid":"match-revealed-profile-".concat(n.id),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-wider",style:{color:"hsl(var(--ndor-state-accepted-text))"},children:[(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5"})," Candidate profile \u2014 this role only"]}),(0,Xt.jsx)("div",{className:"text-sm font-semibold text-ndor-ink",children:n.revealed_profile.full_name}),n.revealed_profile.headline&&(0,Xt.jsx)("div",{className:"text-xs text-ndor-ink-secondary",children:n.revealed_profile.headline}),(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-3 text-[11px] text-ndor-ink-secondary",children:[n.revealed_profile.current_job_title&&(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"Current:"})," ",n.revealed_profile.current_job_title,n.revealed_profile.current_company?" \xb7 ".concat(n.revealed_profile.current_company):""]}),n.revealed_profile.location&&(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"Location:"})," ",n.revealed_profile.location]}),"number"===typeof n.revealed_profile.years_experience&&(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"Experience:"})," ",n.revealed_profile.years_experience," years of experience"]})]}),n.revealed_profile.primary_domain&&(0,Xt.jsxs)("div",{className:"text-[11px] text-ndor-ink-secondary",children:[(0,Xt.jsx)("strong",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"Primary domain"})," ",(0,Xt.jsx)("span",{className:"ml-1",children:n.revealed_profile.primary_domain})]}),n.revealed_profile.summary&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink leading-relaxed whitespace-pre-wrap pt-1",children:n.revealed_profile.summary}),(null===(t=n.revealed_profile.skills)||void 0===t?void 0:t.length)>0&&(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5 pt-1",children:n.revealed_profile.skills.slice(0,20).map((e,t)=>(0,Xt.jsx)("span",{className:"state-pill state-pill--muted",children:e},t))}),(0,Xt.jsx)("p",{className:"text-[10px] text-ndor-ink-muted pt-1",children:"This profile is scoped to this role and this match only. No contact details, phone number, or CV file have been shared."})]}),x&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-ndor-ink-muted mb-1.5",children:[(0,Xt.jsx)(zf,{className:"h-3.5 w-3.5"})," Reasoning"]}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink leading-relaxed","data-testid":"match-reasoning-".concat(n.id),children:x})]}),h.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-ndor-ink-muted mb-1.5",children:[(0,Xt.jsx)(Kn,{className:"h-3.5 w-3.5"})," Strengths"]}),(0,Xt.jsx)("ul",{className:"space-y-1.5 list-disc list-inside text-sm text-ndor-ink","data-testid":"match-strengths-".concat(n.id),children:h.map((e,t)=>(0,Xt.jsx)("li",{children:e},t))})]}),f.length>0&&(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-ndor-ink-muted mb-1.5",children:[(0,Xt.jsx)(Oy,{className:"h-3.5 w-3.5"})," Gaps"]}),(0,Xt.jsx)("ul",{className:"space-y-1.5 list-disc list-inside text-sm text-ndor-ink","data-testid":"match-gaps-".concat(n.id),children:f.map((e,t)=>(0,Xt.jsx)("li",{children:e},t))})]}),v&&(0,Xt.jsxs)("div",{className:"rounded-md border border-rose-500/40 bg-rose-500/10 px-3 py-2 text-xs text-rose-200","data-testid":"match-error-".concat(n.id),children:["This match failed scoring (",p.error,"). Re-run matching to attempt again."]})]})]})});var k}const KL=[{value:"all",label:"All signals"},{value:"surface",label:"Surface only"},{value:"hold",label:"Hold only"},{value:"pass",label:"Pass only"}],YL=[{value:"fit_desc",label:"Fit score \u2014 high \u2192 low"},{value:"fit_asc",label:"Fit score \u2014 low \u2192 high"},{value:"recent",label:"Most recent"}];function JL(){const{id:e}
2=_e(),t=ke(),[n,a]=(0,s.useState)(!0),[r,i]=(0,s.useState)(!1),[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)("all"),[p,h]=(0,s.useState)("fit_desc"),[f,x]=(0,s.useState)({}),[v,g]=(0,s.useState)(null),[y,b]=(0,s.useState)(""),[w,j]=(0,s.useState)(!1),[k,N]=(0,s.useState)(null),[_,D]=(0,s.useState)(0),C=(0,s.useCallback)(async()=>{try{var t,n,a;const r=await(0,zt.n)("/api/employer/v1/me"),s=null!==(t=null!==(n=null===r||void 0===r||null===(a=r.organisation)||void 0===a?void 0:a.id)&&void 0!==n?n:null===r||void 0===r?void 0:r.account_id)&&void 0!==t?t:null;if(N(s),!s)return void D(0);const i=(await MP(s)||[]).filter(t=>t.role_id===e&&"active"===t.assignment_status).length;D(i)}catch(r){N(null),D(0)}},[e]),A=(0,s.useCallback)(async()=>{a(!0),l(null);try{const t=await(0,zt.n)("/api/employer/roles/".concat(e,"/matches?limit=200"));d(t||null)}catch(pK){var t;l((null===pK||void 0===pK||null===(t=pK.data)||void 0===t?void 0:t.detail)||(null===pK||void 0===pK?void 0:pK.message)||"Failed to load matches.")}finally{a(!1)}},[e]),S=(0,s.useCallback)(async()=>{try{const t=await(0,zt.n)("/api/employer/roles/".concat(e,"/signals"));x((null===t||void 0===t?void 0:t.signals_by_match)||{})}catch(t){x({})}},[e]);(0,s.useEffect)(()=>{A()},[A]),(0,s.useEffect)(()=>{S()},[S]),(0,s.useEffect)(()=>{C()},[C]);const E=(e,t)=>{g(e),b(t),j(!0)},F=(null===c||void 0===c?void 0:c.role)||null,R=(null===c||void 0===c?void 0:c.matches)||[],I=(null===c||void 0===c?void 0:c.counts)||{surface:0,hold:0,pass:0,total:0},T=(0,s.useMemo)(()=>function(e,t,n){let a=Array.isArray(e)?e:[];return t&&"all"!==t&&(a=a.filter(e=>e.decision_signal===t)),a="fit_asc"===n?[...a].sort((e,t)=>{var n,a;return(null!==(n=e.fit_score)&&void 0!==n?n:0)-(null!==(a=t.fit_score)&&void 0!==a?a:0)}):"recent"===n?[...a].sort((e,t)=>new Date(t.surfaced_at)-new Date(e.surfaced_at)):[...a].sort((e,t)=>{var n,a;return(null!==(n=t.fit_score)&&void 0!==n?n:0)-(null!==(a=e.fit_score)&&void 0!==a?a:0)}),a}(R,u,p),[R,u,p]);if(n)return(0,Xt.jsx)("div",{className:"flex items-center justify-center py-24","data-testid":"employer-matches-loading",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})});if(o)return(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"employer-matches-error",children:[(0,Xt.jsx)(ty,{className:"mx-auto mb-4 h-10 w-10 text-rose-500"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:o}),(0,Xt.jsx)(Rr,{variant:"outline",className:"mt-6",onClick:()=>t("/employer/roles"),children:"Back to roles"})]});const P="draft"===(null===F||void 0===F?void 0:F.status),O=0===R.length;return(0,Xt.jsxs)("div",{className:"mx-auto max-w-4xl py-8 px-4 space-y-6","data-testid":"employer-matches-page",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)(Rr,{variant:"ghost",size:"sm",onClick:()=>t("/employer/roles/".concat(e)),className:"mb-2","data-testid":"employer-matches-back",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"})," Role editor"]}),(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Bw,{className:"h-5 w-5 text-ndor-ink-muted"}),(null===F||void 0===F?void 0:F.title)||"Role matches"]}),(0,Xt.jsx)("p",{className:"mt-1 text-sm text-ndor-ink-muted",children:"Anonymous match intelligence for discoverable candidates. No candidate identity is surfaced."})]}),(0,Xt.jsx)("span",{className:"state-pill ".concat("live"===(null===F||void 0===F?void 0:F.status)?"state-pill--accepted":"draft"===(null===F||void 0===F?void 0:F.status)?"state-pill--draft":"state-pill--muted"),"data-testid":"employer-matches-role-status",children:(null===F||void 0===F?void 0:F.status)||"draft"})]}),P&&(0,Xt.jsx)(Fy,{className:"border-amber-500/40 bg-amber-500/10 shadow-none","data-testid":"employer-matches-draft-banner",children:(0,Xt.jsx)(Py,{className:"py-4",children:(0,Xt.jsx)("p",{className:"text-sm text-amber-200",children:"This role is still a draft. Matching runs automatically once the role is published."})})}),!P&&(0,Xt.jsxs)("div",{className:"grid grid-cols-4 gap-3","data-testid":"employer-matches-counts",children:[(0,Xt.jsx)($L,{label:"Total",value:I.total,testId:"count-total"}),(0,Xt.jsx)($L,{label:"Surface",value:I.surface,testId:"count-surface",tone
2:"emerald"}),(0,Xt.jsx)($L,{label:"Hold",value:I.hold,testId:"count-hold",tone:"amber"}),(0,Xt.jsx)($L,{label:"Pass",value:I.pass,testId:"count-pass",tone:"slate"})]}),!P&&(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)(Vv,{value:u,onValueChange:m,children:[(0,Xt.jsx)(Wv,{className:"h-9 w-[180px]","data-testid":"matches-filter",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:KL.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]}),(0,Xt.jsxs)(Vv,{value:p,onValueChange:h,children:[(0,Xt.jsx)(Wv,{className:"h-9 w-[220px]","data-testid":"matches-sort",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:YL.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:A,"data-testid":"matches-refresh",children:[(0,Xt.jsx)(Kg,{className:"h-4 w-4 mr-1.5"})," Refresh"]}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:async()=>{if(!r){i(!0);try{await(0,zt.n)("/api/employer/roles/".concat(e,"/run-matching"),{method:"POST"}),fy.success("Matching scheduled. Refreshing in a moment\u2026"),setTimeout(()=>{A()},12e3)}catch(pK){var t;fy.error((null===pK||void 0===pK||null===(t=pK.data)||void 0===t?void 0:t.detail)||(null===pK||void 0===pK?void 0:pK.message)||"Could not schedule matching.")}finally{i(!1)}}},disabled:r||"live"!==(null===F||void 0===F?void 0:F.status),"data-testid":"matches-run",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:[r?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(jF,{className:"h-4 w-4 mr-1.5"}),r?"Running\u2026":"Run matching"]})]})]}),!P&&O&&(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"employer-matches-empty",children:(0,Xt.jsxs)(Py,{className:"py-12 text-center max-w-md mx-auto",children:[(0,Xt.jsx)(Bw,{className:"mx-auto mb-3 h-8 w-8 text-ndor-ink-muted"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No matches yet for this role."}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted mt-2 leading-relaxed",children:["If matching has just run, results may take a moment to surface. Otherwise, click ",(0,Xt.jsx)("strong",{children:"Run matching"})," ","above to score the eligible candidates against this role's criteria. If no eligible candidates are surfaced under the current constraints, this list will stay empty until either the role is re-scoped or new candidates onboard."]}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted mt-3 leading-relaxed",children:[(0,Xt.jsx)("strong",{children:"What happens next:"})," matches appear here anonymously. Send an interest signal to a candidate; if they accept, their identity reveals and you can route them to your reviewers from this same surface."]}),(0,Xt.jsx)("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:(0,Xt.jsx)(Rr,{asChild:!0,size:"sm",variant:"outline","data-testid":"employer-matches-empty-cta-detail",children:(0,Xt.jsx)(Et,{to:"/employer/roles/".concat(e),children:"Open role detail"})})})]})}),!P&&!O&&(0,Xt.jsxs)("div",{className:"space-y-3","data-testid":"employer-matches-list",children:["hold"===u&&(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt px-3 py-2","data-testid":"employer-matches-hold-note",children:(0,Xt.jsxs)("div",{className:"flex items-start gap-2 text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsx)(zf,{className:"h-3.5 w-3.5 mt-0.5 text-ndor-ink-muted shrink-0"}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)("strong",{className:"text-ndor-ink",children:"On hold:"}
2)," ","matches you're not ready to action yet. These remain in the queue."]})]})}),0===T.length?(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"employer-matches-filter-empty",children:(0,Xt.jsx)(Py,{className:"py-10 text-center",children:(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"No matches under the current filter."})})}):T.map((t,n)=>(0,Xt.jsx)(GL,{match:t,index:n,signal:f[t.id],onSendInterest:E,accountId:k,roleId:e,activeReviewerCount:_,onRouted:C},t.id))]}),!P&&(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted text-center pt-4","data-testid":"employer-matches-review-only-note",children:"Candidate identity remains private until they accept an interest signal. Reveal is scoped to that specific role and that specific match."}),(0,Xt.jsx)(VL,{roleId:e,match:v,matchLabel:y,open:w,onOpenChange:j,onSent:()=>S()})]})}function $L(e){let{label:t,value:n,testId:a,tone:r}=e;const s={emerald:"text-emerald-200",amber:"text-amber-200",slate:"text-slate-200"}[r]||"text-ndor-ink";return(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt px-4 py-3","data-testid":a,children:[(0,Xt.jsx)("div",{className:"text-xl font-mono tabular-nums ".concat(s),children:null!==n&&void 0!==n?n:0}),(0,Xt.jsx)("div",{className:"text-[11px] uppercase tracking-wider text-ndor-ink-muted mt-0.5",children:t})]})}const XL={pending:"state-pill state-pill--pending",accepted:"state-pill state-pill--accepted",declined:"state-pill state-pill--declined",deferred:"state-pill state-pill--deferred"},QL={pending:"Your decision pending",accepted:"Accepted",declined:"Declined",deferred:"Deferred"},ZL={pending:"state-rail--pending",accepted:"state-rail--accepted",declined:"state-rail--declined",deferred:"state-rail--deferred"};function eM(e){var t,n,a,r,i;let{signal:o,onRespond:l,pending:c,pendingAction:d}=e;const u="pending"===o.status,m="declined"===o.status||"deferred"===o.status,p=o.role||{},h=o.organisation||{},f=XL[o.status]||XL.pending,x=ZL[o.status]||"",v=Boolean(h.sector||h.size_band||h.description||h.website),[g,y]=(0,s.useState)("pending"===o.status);return(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm transition hover:border-ndor-ink-muted ".concat(x," ").concat(m?"opacity-80":""),"data-testid":"signal-card-".concat(o.id),children:(0,Xt.jsxs)(Py,{className:"p-5 space-y-4",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-ndor-ink-muted",children:[(0,Xt.jsx)(Pn,{className:"h-3.5 w-3.5"}),(0,Xt.jsx)("span",{"data-testid":"signal-org-".concat(o.id),className:"font-medium text-ndor-ink",children:p.organisation_name||"An organisation"}),(0,Xt.jsx)("span",{children:"has expressed interest"})]}),(0,Xt.jsx)("h3",{className:"mt-1 text-base font-semibold text-ndor-ink","data-testid":"signal-role-".concat(o.id),children:p.title||"Role"}),(0,Xt.jsxs)("div",{className:"mt-1 flex items-center gap-3 text-[11px] text-ndor-ink-muted",children:[p.location&&(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,Xt.jsx)(qw,{className:"h-3 w-3"})," ",p.location]}),(0,Xt.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,Xt.jsx)(pg,{className:"h-3 w-3"})," ",zL(o.sent_at)]})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,Xt.jsx)("span",{className:f,"data-testid":"signal-status-".concat(o.id),children:QL[o.status]||o.status}),(0,Xt.jsx)("button",{type:"button",onClick:()=>y(e=>!e),className:"rounded-md p-1.5 text-ndor-ink-muted hover:bg-ndor-surface-alt hover:text-ndor-ink transition-colors","data-testid":"signal-toggle-".concat(o.id),"aria-expanded":g,"aria-label":g?"Collapse signal details":"Expand signal details",children:(0,Xt.jsx)(Gn,{className:"h-4 w-4 transition-transform duration-150 ".concat(g?"rotate-180":"")})})]})]}),g&&v&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt px-3 py-2 space-y-1.5","data-testid":"signal-org-meta-".concat(o.id),children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted",children:"About this organisation"}),(h.sector||h.size_band)&&(0,Xt.jsx)("div",{className:"text-xs text-ndor-ink","data-testid":"signal-org-meta-sector-".concat(o.id),children:[h.sector,h.size_band].filter(
2Boolean).join(" \xb7 ")}),h.description&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted leading-relaxed","data-testid":"signal-org-meta-description-".concat(o.id),children:h.description.length>280?"".concat(h.description.slice(0,279).trimEnd(),"\u2026"):h.description}),h.website&&(0,Xt.jsxs)("a",{href:h.website,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] font-medium text-ndor-ink underline decoration-dotted underline-offset-2 hover:decoration-solid","data-testid":"signal-org-meta-website-".concat(o.id),children:["Website ",(0,Xt.jsx)(KN,{className:"h-3 w-3"})]})]}),g&&"accepted"===o.status&&o.access_status&&(0,Xt.jsxs)("div",{className:"rounded-md border px-3 py-2.5 space-y-2.5",style:{backgroundColor:"hsl(var(--ndor-state-accepted-bg))",borderColor:"hsl(var(--ndor-state-accepted-border))"},"data-testid":"signal-access-".concat(o.id),children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-semibold",style:{color:"hsl(var(--ndor-state-accepted-text))"},children:[(0,Xt.jsx)(Zm,{className:"h-3.5 w-3.5"})," Access granted"]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink leading-relaxed",children:"Your profile is accessible to this organisation for this role only. This access was granted when you accepted and is scoped to this match."}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-secondary leading-relaxed","data-testid":"signal-access-permanence-".concat(o.id),children:"To close this access, contact support."}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed italic",children:"Access does not extend to other roles or signals from this organisation."}),(null===(t=o.reciprocity)||void 0===t?void 0:t.reciprocity_summary)&&(0,Xt.jsxs)("div",{className:"pt-2 border-t",style:{borderColor:"hsl(var(--ndor-state-accepted-border))"},children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mb-1",children:"What this organisation knows about you"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink leading-relaxed","data-testid":"signal-reciprocity-summary-".concat(o.id),children:o.reciprocity.reciprocity_summary})]}),(null===(n=o.reciprocity)||void 0===n||null===(a=n.candidate_benefit_points)||void 0===a?void 0:a.length)>0&&g&&(0,Xt.jsxs)("div",{"data-testid":"signal-reciprocity-benefits-".concat(o.id),children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mb-1",children:"Why this may suit you"}),(0,Xt.jsx)("ul",{className:"list-disc list-inside text-[11px] text-ndor-ink-secondary space-y-0.5",children:o.reciprocity.candidate_benefit_points.map((e,t)=>(0,Xt.jsx)("li",{children:e},t))})]}),(null===(r=o.reciprocity)||void 0===r||null===(i=r.fit_cautions)||void 0===i?void 0:i.length)>0&&g&&(0,Xt.jsxs)("div",{"data-testid":"signal-reciprocity-cautions-".concat(o.id),children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mb-1",children:"Points to consider"}),(0,Xt.jsx)("ul",{className:"list-disc list-inside text-[11px] text-ndor-ink-secondary space-y-0.5",children:o.reciprocity.fit_cautions.map((e,t)=>(0,Xt.jsx)("li",{children:e},t))})]})]}),o.ndor_reasoning_summary&&g&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt px-3 py-2","data-testid":"signal-reasoning-".concat(o.id),children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mb-1",children:"How your profile matched"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink leading-relaxed",children:o.ndor_reasoning_summary})]}),o.body&&g&&(0,Xt.jsxs)("div",{"data-testid":"signal-body-".concat(o.id),children:[(0,Xt.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-ndor-ink-muted mb-1",children:"Their note"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink leading-relaxed whitespace-pre-wrap",children:o.body})]}),(0,Xt.jsx)("div",{className:"pt-2 border-t border-ndor-edge flex items-center justify-end gap-2",children:u?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"ghost",onClick:()=>l(o.id,"defer"),disabled:c,"data-testid":"signal-defer-".concat(o.id),title:"Come back to this later.",children:[(0,Xt.jsx)(bP,{className:"h-4 w-4 mr-1.5"}),"defer"===d?"Deferring\u2026":"Defer"]}),(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:()=>l(o.id,"decline"),disabled:c,"data-testid":"signal-decline-".concat(o.id),style:{borderColor:"hsl(var(--ndor-state-declined-border))",color:"hsl(var(--ndor-state-declined-text))"},children:[(0,Xt.jsx)(xh,{className:"h-4 w-4 mr-1.5"}),"decline"===d?"Declining\u2026":"Decline"]}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:()=>l(o.id,"accept"),disabled:c,"data-testid":"signal-accept-".concat(o.id),className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:[c&&"accept"===d?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(Zm,{className:"h-4 w-4 mr-1.5"}),"accept"===d?"Accepting\u2026":"Accept"]})]}):(0,Xt.jsxs)("span",{className:"text-xs text-ndor-ink-muted","data-testid":"signal-responded-".concat(o.id),children:["Responded ",zL(o.responded_at)]})})]})})}function tM(e){let{label:t,value:n,tone:a,testId:r}=e;const s={emerald:"text-emerald-200",amber:"text-amber-200",rose:"text-rose-200",sky:"text-sky-900"}[a]||"text-ndor-ink";return(0,Xt.jsxs)("div",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt px-4 py-3","data-testid":r,children:[(0,Xt.jsx)("div",{className:"text-xl font-mono tabular-nums ".concat(s),children:null!==n&&void 0!==n?n:0}),(0,Xt.jsx)("div",{className:"text-[11px] uppercase tracking-wider text-ndor-ink-muted mt-0.5",children:t})]})}
2function nM(){const[e,t]=(0,s.useState)(!0),[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(null),d=(0,s.useCallback)(async()=>{t(!0),a(null);try{const e=await(0,zt.n)("/api/candidate/signals");i(e||null)}catch(pK){var e;a((null===pK||void 0===pK||null===(e=pK.data)||void 0===e?void 0:e.detail)||(null===pK||void 0===pK?void 0:pK.message)||"Failed to load signals.")}finally{t(!1)}},[]);(0,s.useEffect)(()=>{d()},[d]);const u=async(e,t)=>{if(o)return;const n=r;l({id:e,action:t});try{const n=await(0,zt.n)("/api/candidate/signals/".concat(e,"/respond"),{method:"POST",body:JSON.stringify({action:t})});i(t=>{if(!t)return t;const a=(0,c.A)((0,c.A)({},t),{},{signals:t.signals.map(t=>t.id===e?n.signal:t)}),r={pending:0,accepted:0,declined:0,deferred:0};for(const e of a.signals)e.status in r&&(r[e.status]+=1);return r.total=a.signals.length,a.counts=r,a}),n.already_responded?fy.info("You had already responded to this signal."):"accept"===t?fy.success("Accepted. Your profile is now accessible for this role only."):"decline"===t?fy.success("Declined."):fy.success("Deferred \u2014 you can respond later.")}catch(pK){var a;i(n),fy.error((null===pK||void 0===pK||null===(a=pK.data)||void 0===a?void 0:a.detail)||(null===pK||void 0===pK?void 0:pK.message)||"Could not respond.")}finally{l(null)}},m=(null===r||void 0===r?void 0:r.signals)||[],p=(null===r||void 0===r?void 0:r.counts)||{pending:0,accepted:0,declined:0,deferred:0,total:0},h=(0,s.useMemo)(()=>[...m].sort((e,t)=>"pending"===e.status&&"pending"!==t.status?-1:"pending"!==e.status&&"pending"===t.status?1:new Date(t.sent_at)-new Date(e.sent_at)),[m]);return e?(0,Xt.jsx)("div",{className:"flex items-center justify-center py-24","data-testid":"candidate-signals-loading",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})}):n?(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"candidate-signals-error",children:[(0,Xt.jsx)(ty,{className:"mx-auto mb-4 h-10 w-10 text-rose-500"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:n})]}):(0,Xt.jsxs)("div",{className:"mx-auto max-w-3xl py-8 px-4 space-y-6","data-testid":"candidate-signals-page",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsxs)("h1",{className:"text-2xl font-semibold text-ndor-ink flex items-center gap-2",children:[(0,Xt.jsx)(Dn,{className:"h-5 w-5 text-ndor-ink-muted"}),"Interest signals"]}),(0,Xt.jsx)("p",{className:"mt-1 text-sm text-ndor-ink-muted",children:"You decide how to respond to every signal. Your identity remains private until you choose otherwise."})]}),p.total>0&&(0,Xt.jsxs)("div",{className:"grid grid-cols-4 gap-3","data-testid":"candidate-signals-counts",children:[(0,Xt.jsx)(tM,{label:"Pending",value:p.pending,tone:"amber",testId:"count-pending"}),(0,Xt.jsx)(tM,{label:"Accepted",value:p.accepted,tone:"emerald",testId:"count-accepted"}),(0,Xt.jsx)(tM,{label:"Declined",value:p.declined,tone:"rose",testId:"count-declined"}),(0,Xt.jsx)(tM,{label:"Deferred",value:p.deferred,tone:"sky",testId:"count-deferred"})]}),0===h.length?(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"candidate-signals-empty",children:(0,Xt.jsxs)(Py,{className:"py-14 text-center",children:[(0,Xt.jsx)(Dn,{className:"mx-auto mb-3 h-8 w-8 text-ndor-ink-muted"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No signals yet"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1 max-w-md mx-auto",children:"When an organisation expresses interest in your profile, their signal will appear here. You stay anonymous until you decide to accept."})]})}):(0,Xt.jsx)("div",{className:"space-y-3","data-testid":"candidate-signals-list",children:h.map(e=>(0,Xt.jsx)(eM,{signal:e,pending:(null===o||void 0===o?void 0:o.id)===e.id,pendingAction:(null===o||void 0===o?void 0:o.id)===e.id?o.action:null,onRespond:u},e.id))}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted text-center pt-4","data-testid":"candidate-signals-privacy-note",children:"When you accept a signal, your approved profile fields are shared with the organisation for this role only. No contact details are included."})]})}function aM(e){let{children:t,redirectTo:n="/dashboard"}=e;const{loading:a}=tn(),{isOperator:r,loading:s}=pn();return a||s?null:r?t:(0,Xt.jsx)(We,{to:n,replace:!0})}const rM={candidate:{label:"Candidate",description:"Jobs, applications, documents, workflow.",Icon:kn},employer:{label:"Employer",description:"Roles and matches (coming in RC 1.30.B).",Icon:Pn},admin:{label:"Admin",description:"Jobs inventory, sources, catalogue.",Icon:Ln}};function sM(){const{allowedWorkspaces:e,effectiveDefault:t,switchWorkspace:n,loading:a}=on(),r=ke();return(0,s.useEffect)(()=>{a||1===e.length&&r(an(e[0]),{replace:!0})},[a,e,r]),a?null:(0,Xt.jsxs)("div",{className:"mx-auto max-w-3xl py-16 px-4","data-testid":"choose-workspace-page",children:[(0,Xt.jsxs)("div",{className:"text-center mb-8",children:[(0,Xt.jsx)("h1",{className:"text-2xl font-semibold text-ndor-ink",children:"Choose your workspace"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:"You have access to more than one. Pick where you'd like to start \u2014 we'll remember it for next time."})]}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:e.map(e=>{const a=rM[e];if(!a)return null;const{Icon:r}=a,s=t===e;return(0,Xt.jsx)("button",{type:"button",onClick:()=>n(e),className:"text-left","data-testid":"choose-workspace-tile-".concat(e),children:(0,Xt.jsx)(Fy,{className:"border-ndor-edge hover:border-ndor-gold transition-colors",children:(0,Xt.jsxs)(Py,{className:"py-6 flex items-start gap-4",children:[(0,Xt.jsx)(r,{className:"h-6 w-6 text-ndor-ink-muted shrink-0 mt-0.5"}),(0,Xt.jsxs)("div",{className:"flex-1",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:a.label}),s&&(0,Xt.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-ndor-gold font-mono-ui",children:"current default"})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:a.description})]})]})})},e)})})]})}function iM(){const{signOut:e}=tn();return(0,Xt.jsxs)("div",{className:"mx-auto max-w-xl py-24 px-4 text-center","data-testid":"no-access-page",children:[(0,Xt.jsx)(mb,{className:"mx-auto mb-4 h-10 w-10 text-ndor-ink-muted"}),(0,Xt.jsx)("h1",{className:"text-xl font-semibold text-ndor-ink",children:"No workspace access"}),(0,Xt.jsx)("p",{className:"mt-2 text-sm text-ndor-ink-muted",children:"Your account doesn't have any workspace enabled yet. An admin needs to grant you candidate or employer access before you can continue."}),(0,Xt.jsx)(Rr,{variant:"outline",className:"mt-6",onClick:e,"data-testid":"no-access-signout",children:"Sign out"})]})}const oM=wn("badge-check",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);function lM(){const e="false".trim().toLowerCase();
2return"false"!==e&&"0"!==e&&"no"!==e}const cM={usage_topup:"Top-up Credits",plan_subscription:"Subscription"},dM={usage_20:"20 Credits",usage_50:"50 Credits",usage_120:"120 Credits"},uM={finalised:"bg-emerald-500/10 text-emerald-200 border-emerald-500/40",pending:"bg-amber-500/10 text-amber-200 border-amber-500/40",failed:"bg-rose-500/10 text-rose-200 border-rose-500/40"};function mM(e){if(!e)return"\u2014";try{return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}catch(t){return e}}function pM(e){if("usage_topup"===e.kind){const t=dM[e.package_code]||e.package_code||"Top-up";return"Top-up Credits \xb7 ".concat(t)}if("plan_subscription"===e.kind){const t=(e.plan_code||"plan").toString(),n=e.billing_period?" (".concat(e.billing_period,")"):"";return"".concat(t.charAt(0).toUpperCase()+t.slice(1)," subscription").concat(n)}return cM[e.kind]||e.kind||"Payment"}function hM(){const e=ke(),{refresh:t}=If(),[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)([]),[o,l]=(0,s.useState)(!0),[c,d]=(0,s.useState)(!0),[u,m]=(0,s.useState)(!1),[p,h]=(0,s.use
2State)(null),f=(0,s.useCallback)(async()=>{l(!0);try{const e=await(0,zt.n)("/api/account/plan");a(e)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Unable to load your Credits balance."),a(null)}finally{l(!1)}},[]),x=(0,s.useCallback)(async()=>{d(!0),h(null);try{const e=await(0,zt.n)("/api/payments/billing-history?limit=10");i(Array.isArray(null===e||void 0===e?void 0:e.history)?e.history:[])}catch(pK){h((null===pK||void 0===pK?void 0:pK.message)||"Unable to load billing history."),i([])}finally{d(!1)}},[]);(0,s.useEffect)(()=>{f(),x()},[f,x]);const v=(0,s.useCallback)(()=>{e("/account?tab=plan&addUsage=1")},[e]),g=(0,s.useCallback)(async()=>{m(!0);try{const e=await(0,zt.n)("/api/payments/customer-portal",{method:"POST",body:JSON.stringify({})});if(null===e||void 0===e||!e.url)throw new Error("Stripe did not return a portal URL.");window.location.assign(e.url)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Unable to open the Stripe billing portal."),m(!1)}},[]),y=(null===n||void 0===n?void 0:n.included_usage_remaining)||0,b=(null===n||void 0===n?void 0:n.extra_usage_remaining)||0,w=y+b,j=(null===n||void 0===n?void 0:n.plan_code)||"base",k=r.length>0,N=(0,s.useMemo)(()=>[{icon:Bn,label:"Secure payments by Stripe"},{icon:oM,label:"Cancel anytime"},{icon:VC,label:"Transparent billing"},{icon:b_,label:"Card details never touch NDORFlow"}],[]);return(0,Xt.jsxs)("div",{className:"space-y-6 max-w-5xl","data-testid":"credits-page",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h1",{className:"text-3xl font-serif-display font-semibold text-ndor-ink tracking-tight",children:"Credits & Billing"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-1",children:"Your Credits balance, recent payments, and self-service billing tools \u2014 all in one place."})]}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm",children:(0,Xt.jsxs)(Py,{className:"p-6","data-testid":"credits-summary",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Available Credits"}),(0,Xt.jsx)("p",{className:"text-4xl font-serif-display font-semibold text-ndor-ink mt-1 tabular-nums","data-testid":"credits-summary-total",children:o?"\u2014":w.toLocaleString()}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted mt-2",children:["Plan:"," ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink capitalize",children:j}),(null===n||void 0===n?void 0:n.billing_period)&&(0,Xt.jsxs)(Xt.Fragment,{children:[" \xb7 ",(0,Xt.jsx)("span",{className:"text-ndor-ink-secondary",children:n.billing_period})]})]})]}),(0,Xt.jsx)("div",{className:"w-12 h-12 rounded-lg flex items-center justify-center bg-amber-500/10 text-amber-200",children:(0,Xt.jsx)(Sn,{className:"h-6 w-6"})})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mt-5",children:[(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30 p-4",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Included Credits"}),(0,Xt.jsx)("p",{className:"text-2xl font-serif-display font-semibold text-ndor-ink tabular-nums mt-1","data-testid":"credits-summary-included",children:o?"\u2014":y.toLocaleString()}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:"Refresh each cycle on Focus / Flow"})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30 p-4",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Top-up Credits"}),(0,Xt.jsx)("p",{className:"text-2xl font-serif-display font-semibold text-ndor-ink tabular-nums mt-1","data-testid":"credits-summary-extra",children:o?"\u2014":b.toLocaleString()}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted mt-1",children:"Top-ups \xb7 No expiry"})]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 mt-5",children:[(0,Xt.jsxs)(Rr,{onClick:v,"data-testid":"plan-add-credits-button",className:"bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground",children:[(0,Xt.jsx)(Ow,{className:"h-4 w-4 mr-1.5"}),"Add Credits"]}),(0,Xt.jsxs)(Rr,{variant:"outline",onClick:g,disabled:u,"data-testid":"customer-portal-button",className:"border-ndor-edge text-ndor-ink hover:bg-ndor-surface",children:[u?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(KN,{className:"h-4 w-4 mr-1.5"}),"Manage billing & invoices"]}),(0,Xt.jsxs)(Rr,{variant:"ghost",onClick:()=>{f(),x(),null===t||void 0===t||t()},"data-testid":"credits-refresh-button",className:"text-ndor-ink-muted hover:text-ndor-ink",children:[(0,Xt.jsx)(Kg,{className:"h-4 w-4 mr-1.5"}),"Refresh"]})]}
2),!k&&!o&&(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted mt-3","data-testid":"customer-portal-hint",children:"The Stripe billing portal unlocks once you've made your first top-up or subscription. Your invoice history will appear here after that."})]})}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm",children:(0,Xt.jsxs)(Py,{className:"p-4",children:[(0,Xt.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3","data-testid":"credits-trust-strip",children:N.map(e=>{let{icon:t,label:n}=e;return(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-xs text-ndor-ink-secondary",children:[(0,Xt.jsx)(t,{className:"h-4 w-4 text-emerald-600 shrink-0"}),(0,Xt.jsx)("span",{children:n})]},n)})}),lM()&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted mt-3","data-testid":"credits-test-mode-hint",children:["Stripe is currently in ",(0,Xt.jsx)("strong",{children:"TEST MODE"})," \u2014 no real card is charged. Use Stripe's ",(0,Xt.jsx)("code",{children:"4242 4242 4242 4242"})," test card with any future expiry and CVC."]})]})}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm",children:[(0,Xt.jsx)(Ry,{children:(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base font-medium text-ndor-ink",children:[(0,Xt.jsx)(hS,{className:"h-5 w-5 text-ndor-ink-muted"}),"Recent payments"]})}),(0,Xt.jsxs)(Py,{"data-testid":"billing-history-card",children:[c?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ndor-ink-muted py-4",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," Loading payments\u2026"]}):p?(0,Xt.jsx)("p",{className:"text-sm text-rose-200 py-2","data-testid":"billing-history-error",children:p}):0===r.length?(0,Xt.jsx)("div",{className:"text-sm text-ndor-ink-muted py-2","data-testid":"billing-history-empty",children:"No payments yet. Add Credits to see your invoice history here."}):(0,Xt.jsx)("div",{className:"overflow-x-auto",children:(0,Xt.jsxs)("table",{className:"w-full text-sm","data-testid":"billing-history-table",children:[(0,Xt.jsx)("thead",{children:(0,Xt.jsxs)("tr",{className:"text-left text-xs uppercase tracking-wide text-ndor-ink-muted border-b border-ndor-edge",children:[(0,Xt.jsx)("th",{className:"py-2 pr-3 font-medium",children:"Date"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 font-medium",children:"Item"}),(0,Xt.jsx)("th",{className:"py-2 pr-3 font-medium text-right",children:"Amount"}),(0,Xt.jsx)("th",{className:"py-2 font-medium",children:"Status"})]})}),(0,Xt.jsx)("tbody",{children:r.map(e=>(0,Xt.jsxs)("tr",{"data-testid":"billing-history-row-".concat(e.session_id||e.created_at),className:"border-b border-ndor-edge/40 last:border-b-0",children:[(0,Xt.jsx)("td",{className:"py-2 pr-3 text-ndor-ink-secondary whitespace-nowrap",children:mM(e.finalised_at||e.created_at)}),(0,Xt.jsx)("td",{className:"py-2 pr-3 text-ndor-ink",children:pM(e)}),(0,Xt.jsxs)("td",{className:"py-2 pr-3 text-right font-medium text-ndor-ink tabular-nums",children:["\xa3",e.amount_gbp.toFixed(2)]}),(0,Xt.jsx)("td",{className:"py-2",children:(0,Xt.jsx)(Vw,{variant:"outline",className:"text-xs font-medium border ".concat(uM[e.status]||"bg-ndor-surface-alt text-slate-200 border-slate-200"),children:e.status||e.payment_status||"pending"})})]},e.session_id||"".concat(e.created_at,"-").concat(e.kind)))})]})}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted mt-4",children:"Need a VAT invoice or refund? Open the Stripe billing portal above \u2014 every paid transaction has a downloadable receipt."})]})]})]})}const fM=[{key:"full_name",label:"Full name"},{key:"headline",label:"Headline"},{key:"current_job_title",label:"Current job title"},{key:"current_company",label:"Current company"},{key:"years_experience",label:"Years of experience"},{key:"location",label:"Location"},{key:"visa_status",label:"Visa / work authorisation"},{key:"summary",label:"Experience summary"},{key:"primary_domain",label:"Primary domain"},{key:"skills_json",label:"Skills (at least one)"},{key:"primary_cv",label:"Primary Source CV"}],xM=[{key:"preferred_regions",label:"Preferred regions (at least one)"},{key:"open_to_relocation",label:"Open to relocation"},{key:"relocation_regions",label:"Relocation regions"},{key:"location_strictness",label:"Location strictness"},{key:"include_cover_letter",label:"Include cover letter choice"}],vM={skills_json:"Improves job match scoring",primary_domain:"Helps role relevance detection",headline:"Improves profile clarity in applications",summary:"Strengthens repositioning advice",preferred_regions:"Improves location match accuracy",location_strictness:"Controls how strict job filtering feels"};function gM(e,t,n){switch(e.key){case"years_experience":return"number"===typeof(null===t||void 0===t?void 0:t.years_experience)&&t.years_experience>=0;case"skills_json":return Array.isArray(null===t||void 0===t?void 0:t.skills_json)&&t.skills_json.length>0;case"primary_cv":return Boolean(null===n||void 0===n?void 0:n.id);default:{const n=null===t||void 0===t?void 0:t[e.key];return"string"===typeof n?n.trim().length>0:Boolean(n)}}}function yM(e,t){switch(e.key){case"preferred_regions":return Array.isArray(null===t||void 0===t?void 0:t.preferred_regions)&&t.preferred_regions.length>0;case"relocation_regions":return"no"===(null===t||void 0===t?void 0:t.open_to_relocation)||Array.isArray(null===t||void 0===t?void 0:t.relocation_regions)&&t.relocation_regions.length>0;case"open_to_relocation":return["yes","conditional","no"].includes(null===t||void 0===t?void 0:t.open_to_relocation);case"location_strictness":return["strict","balanced","open"].includes(null===t||void 0===t?void 0:t.location_strictness);case"include_cover_letter":return"boolean"===typeof(null===t||void 0===t?void 0:t.include_cover_letter);default:return!1}}function bM(e){let{pct:t,testId:n}=e;const a=t>=100?"bg-ndor-success":t>=60?"bg-ndor-gold":"bg-ndor-warning";return(0,Xt.jsx)("div",{className:"h-1.5 w-full rounded-full bg-ndor-surface-alt overflow-hidden","data-testid":n,children:(0,Xt.jsx)("div",{className:"h-full ".concat(a," transition-all"),style:{width:"".concat(Math.max(3,Math.min(100,t)),"%")}})})}function wM(e){let{title:t,pct:n,missing:a,barTestId:r,missingTestId:s,targetId:i}=e;const o=function(e){const t=["skills_json","primary_domain","headline","summary","preferred_regions","location_strictness"],n=new Set(e.map(e=>e.key));for(const a of t)if(n.has(a))return vM[a];return null}(a);return(0,Xt.jsxs)("div",{className:"flex-1 min-w-0 space-y-1.5",children:[(0,Xt.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,Xt.jsx)("span",{className:"text-xs uppercase tracking-[0.18em] text-ndor-ink-muted font-mono-ui",children:t}),(0,Xt.jsxs)("span",{className:"text-sm font-medium text-ndor-ink font-mono-ui","data-testid":"".concat(r,"-pct"),children:[n,"%"]})]}),(0,Xt.jsx)("button",{type:"button",onClick:()=>{var e;i&&(null===(e=document.getElementById(i))||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"}))},"aria-label":"Scroll to ".concat(t),className:"block w-full text-left","data-testid":"".concat(r,"-click"),children:(0,Xt.jsx)(bM,{pct:n,testId:r})}),a.length>0?(0,Xt.jsxs)("div",{className:"pt-0.5 space-y-0.5",children:[(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":s,children:[(0,Xt.jsx)(ty,{className:"h-3 w-3 inline mr-1 -mt-0.5 text-ndor-warning"}),"Missing:"," ",(0,Xt.jsx)("span",{className:"text-ndor-ink-secondary",children:a.slice(0,3).map(e=>e.label).join(" \xb7 ")}),a.length>3&&(0,Xt.jsxs)("span",{className:"text-ndor-ink-muted",children:[" ","+",a.length-3," more"]})]}),o&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-gold pl-[18px]","data-testid":"".concat(s,"-hint"),children:["\u2192 ",o]})]}):(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-success pt-0.5 flex items-center gap-1",children:[(0,Xt.jsx)(Og,{className:"h-3 w-3"}),"Complete"]})]})}
2function jM(){const[e,t]=(0,s.useState)(null),[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(!0),d=(0,s.useCallback)(async()=>{try{const[e,n]=await Promise.all([(0,zt.n)("/api/profile/me").catch(()=>null),(0,zt.n)("/api/profile/preferences").catch(()=>null)]);t((null===e||void 0===e?void 0:e.profile)||null),a((null===e||void 0===e?void 0:e.primary_cv)||null),i((null===n||void 0===n?void 0:n.preferences)||null)}finally{l(!1)}},[]);(0,s.useEffect)(()=>{d()},[d]),(0,s.useEffect)(()=>{const e=()=>d();return window.addEventListener("ndor:profile-refresh",e),()=>window.removeEventListener("ndor:profile-refresh",e)},[d]);const u=(0,s.useMemo)(()=>!o&&e&&r?function(e,t,n){const a=fM.map(n=>(0,c.A)((0,c.A)({},n),{},{filled:gM(n,e,t)})),r=xM.map(e=>(0,c.A)((0,c.A)({},e),{},{filled:yM(e,n)})),s=a.filter(e=>e.filled).length,i=r.filter(e=>e.filled).length;return{profile_pct:Math.round(s/fM.length*100),preference_pct:Math.round(i/xM.length*100),missing_profile:a.filter(e=>!e.filled),missing_preference:r.filter(e=>!e.filled)}}(e,n,r):null,[o,e,n,r]);return(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"completeness-meter-card",children:[(0,Xt.jsx)(Ry,{className:"pb-2",children:(0,Xt.jsx)(Iy,{className:"text-sm font-medium text-ndor-ink flex items-center gap-2",children:"Profile completeness"})}),(0,Xt.jsx)(Py,{children:o||!u?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Loading\u2026"}):(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row gap-5",children:[(0,Xt.jsx)(wM,{title:"Profile",pct:u.profile_pct,missing:u.missing_profile,barTestId:"completeness-profile-bar",missingTestId:"completeness-profile-missing",targetId:"profile-section"}),(0,Xt.jsx)(wM,{title:"Preferences",pct:u.preference_pct,missing:u.missing_preference,barTestId:"completeness-preferences-bar",missingTestId:"completeness-preferences-missing",targetId:"preferences-section"})]})})]})}const kM="DELETE";function NM(){const[e,t]=(0,s.useState)(!1),[n,a]=(0,s.useState)(""),[r,i]=(0,s.useState)(!1),[o,l]=(0,s.useState)(!1),c=(0,s.useMemo)(()=>n.trim().toUpperCase()===kM&&r&&!o,[n,r,o]);return(0,Xt.jsxs)(Fy,{className:"border-red-200 bg-red-50/30 shadow-sm","data-testid":"delete-account-section",children:[(0,Xt.jsx)(Ry,{className:"pb-2",children:(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base font-medium text-rose-200",children:[(0,Xt.jsx)(Oy,{className:"h-5 w-5"}),"Danger zone"]})}),(0,Xt.jsxs)(Py,{className:"space-y-3",children:[(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:["Deleting your account permanently removes your CVs, generated variants, application packs, cover letters, preferences, credit balance, plan history, and all consents.",(0,Xt.jsx)("strong",{className:"text-rose-200",children:" This cannot be undone."})," ","Your Stripe billing history is retained by Stripe under their independent retention policy; consult our Privacy Policy for the full data list."]}),(0,Xt.jsxs)(aS,{open:e,onOpenChange:e=>{t(e),e||(a(""),i(!1),l(!1))},children:[(0,Xt.jsx)(rS,{asChild:!0,children:(0,Xt.jsxs)(Rr,{variant:"destructive",className:"bg-red-600 hover:bg-red-700","data-testid":"delete-account-open-btn",children:[(0,Xt.jsx)(pb,{className:"h-4 w-4 mr-1.5"}),"Delete my account"]})}),(0,Xt.jsxs)(oS,{className:"sm:max-w-md","data-testid":"delete-account-confirm-dialog",children:[(0,Xt.jsxs)(lS,{children:[(0,Xt.jsxs)(dS,{className:"text-rose-200 inline-flex items-center gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-5 w-5"}),"Permanently delete your account?"]}),(0,Xt.jsx)(uS,{className:"text-sm leading-relaxed",children:"Every CV, variant, pack, cover letter, preference, credit balance and consent record tied to this account will be removed from NDORFlow. You will be signed out immediately and will not be able to recover your data."})]}),(0,Xt.jsxs)("div",{className:"space-y-3 py-2",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsxs)(Pg,{htmlFor:"delete-account-confirm-input",className:"text-xs text-ndor-ink",children:["Type ",(0,Xt.jsx)("code",{className:"font-mono text-rose-200",children:kM})," to enable the delete button:"]}),(0,Xt.jsx)(Ag,{id:"delete-account-confirm-input",value:n,onChange:e=>a(e.target.value),placeholder:kM,autoComplete:"off",className:"font-mono","data-testid":"delete-account-confirm-input"})]}),(0,Xt.jsxs)("label",{className:"flex items-start gap-2 text-xs text-ndor-ink-secondary leading-relaxed cursor-pointer","data-testid":"delete-account-ack-row",children:[(0,Xt.jsx)(Vb,{checked:r,onCheckedChange:e=>i(Boolean(e)),"data-testid":"delete-account-ack-checkbox"}),(0,Xt.jsx)("span",{children:"I understand this is permanent and irreversible, and that NDORFlow cannot recover my data once deleted."})]})]}),(0,Xt.jsxs)(cS,{className:"gap-2",children:[(0,Xt.jsx)(pS,{"data-testid":"delete-account-cancel-btn",children:"Cancel"}),(0,Xt.jsxs)(mS,{onClick:async()=>
2{if(c){l(!0);try{await(0,zt.n)("/api/account",{method:"DELETE"});try{await Mt.supabase.auth.signOut()}catch(s){}try{Object.keys(localStorage).filter(e=>e.startsWith("ndor:")||e.startsWith("sb-")).forEach(e=>localStorage.removeItem(e))}catch(i){}fy.success("Your account has been deleted. Goodbye."),setTimeout(()=>{window.location.assign("/")},600)}catch(pK){var e,t,n,a,r;const i=null===pK||void 0===pK||null===(e=pK.data)||void 0===e||null===(t=e.detail)||void 0===t?void 0:t.code,o=(null===pK||void 0===pK||null===(n=pK.data)||void 0===n||null===(a=n.detail)||void 0===a?void 0:a.message)||(null===pK||void 0===pK||null===(r=pK.data)||void 0===r?void 0:r.detail)||(null===pK||void 0===pK?void 0:pK.message);"OPERATOR_PROTECTED"===i?fy.error("string"===typeof o?o:"This account is protected and cannot be deleted."):fy.error("string"===typeof o?o:"Account deletion failed. Please try again."),l(!1)}}},disabled:!c,className:"bg-red-600 text-white hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"delete-account-confirm-btn",children:[o&&(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Permanently delete my account"]})]})]})]})]})]})}const _M=["No visa required","Work visa required","Sponsorship needed","Permanent resident","Citizen","Other"],DM=["full_name","headline","current_job_title","current_company","years_experience","location","visa_status","summary","primary_domain","skills_json"],CM=e=>null==e?"":String(e);function AM(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function SM(e){let{value:t,onChange:n}=e;const[a,r]=(0,s.useState)(""),i=Array.isArray(t)?t:[],o=()=>{const e=a.trim();if(!e)return void r("");const t=function(e){const t=new Set,n=[];for(const a of e||[]){if("string"!==typeof a)continue;const e=a.trim();if(!e)continue;const r=e.toLowerCase();t.has(r)||(t.add(r),n.push(e))}return n}([...i,e]);t.length!==i.length&&n(t),r("")},l=e=>
2{const t=i.filter((t,n)=>n!==e);n(t)};return(0,Xt.jsxs)("div",{className:"space-y-1.5","data-testid":"profile-field-skills_json",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Skills"}),(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-1.5 min-h-[2.5rem] rounded-md border border-ndor-edge bg-ndor-surface-alt px-2 py-1.5 focus-within:border-ndor-ink",onClick:e=>{const t=e.currentTarget.querySelector("input");null===t||void 0===t||t.focus()},children:[i.map((e,t)=>(0,Xt.jsxs)(Vw,{variant:"outline",className:"bg-ndor-surface border-ndor-edge text-xs flex items-center gap-1 pr-1","data-testid":"profile-skill-chip-".concat(t),children:[(0,Xt.jsx)("span",{className:"truncate max-w-[12rem]",children:e}),(0,Xt.jsx)("button",{type:"button","aria-label":"Remove ".concat(e),onClick:e=>{e.stopPropagation(),l(t)},className:"text-ndor-ink-muted hover:text-ndor-error ml-0.5","data-testid":"profile-skill-remove-".concat(t),children:(0,Xt.jsx)(xh,{className:"h-3 w-3"})})]},"".concat(e,"-").concat(t))),(0,Xt.jsx)("input",{type:"text",value:a,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"===e.key||","===e.key?(e.preventDefault(),o()):"Backspace"===e.key&&""===a&&i.length>0&&l(i.length-1)},onBlur:o,placeholder:0===i.length?"Add a skill and press Enter\u2026":"",className:"flex-1 min-w-[8rem] bg-transparent outline-none text-sm text-ndor-ink placeholder:text-ndor-ink-muted","data-testid":"profile-skill-input"})]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted",children:["Press ",(0,Xt.jsx)("span",{className:"font-mono",children:"Enter"})," or ",(0,Xt.jsx)("span",{className:"font-mono",children:","})," to add a skill. Click ",(0,Xt.jsx)("span",{className:"font-mono",children:"\xd7"})," to remove. ",i.length," ","skill",1===i.length?"":"s","."]})]})}function EM(e){let{value:t,onChange:n}=e;const[a,r]=(0,s.useState)(""),i="string"===typeof t&&t.trim().length>0,o=()=>{const e=a.trim();e?(n(e),r("")):r("")},l=()=>{n("")};return(0,Xt.jsxs)("div",{className:"space-y-1.5","data-testid":"profile-field-primary_domain",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Primary domain"}),(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-1.5 min-h-[2.5rem] rounded-md border border-ndor-edge bg-ndor-surface-alt px-2 py-1.5 focus-within:border-ndor-ink",onClick:e=>{const t=e.currentTarget.querySelector("input");null===t||void 0===t||t.focus()},children:[i&&(0,Xt.jsxs)(Vw,{variant:"outline",className:"bg-ndor-surface border-ndor-edge text-xs flex items-center gap-1 pr-1","data-testid":"profile-primary-domain-chip",children:[(0,Xt.jsx)("span",{className:"truncate max-w-[16rem]",children:t}),(0,Xt.jsx)("button",{type:"button","aria-label":"Remove primary domain",onClick:e=>{e.stopPropagation(),l()},className:"text-ndor-ink-muted hover:text-ndor-error ml-0.5","data-testid":"profile-primary-domain-remove",children:(0,Xt.jsx)(xh,{className:"h-3 w-3"})})]}),!i&&(0,Xt.jsx)("input",{type:"text",value:a,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"===e.key||","===e.key?(e.preventDefault(),o()):"Backspace"===e.key&&""===a&&i&&l()},onBlur:o,placeholder:"Type your domain and press Enter\u2026",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,className:"flex-1 min-w-[8rem] bg-transparent outline-none text-sm text-ndor-ink placeholder:text-ndor-ink-muted","data-testid":"profile-primary-domain-in
2put"})]}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted",children:["One short label for the space you work in \u2014 e.g. ",(0,Xt.jsx)("span",{className:"font-mono",children:"Energy"}),","," ",(0,Xt.jsx)("span",{className:"font-mono",children:"Product Design"}),", ",(0,Xt.jsx)("span",{className:"font-mono",children:"Data Platform"}),"."," ","Press ",(0,Xt.jsx)("span",{className:"font-mono",children:"Enter"})," or ",(0,Xt.jsx)("span",{className:"font-mono",children:","})," to set. Click ",(0,Xt.jsx)("span",{className:"font-mono",children:"\xd7"})," to clear and replace."]})]})}const FM=[{to:"/terms",label:"Terms of Service",icon:QC,testid:"legal-nav-terms"},{to:"/privacy",label:"Privacy Policy",icon:Bn,testid:"legal-nav-privacy"},{to:"/refund",label:"Refund Policy",icon:Nn,testid:"legal-nav-refund"}];function RM(e){let{title:t,updatedAt:n,activePath:a,children:r,embedded:s=!1,testid:i}=e;const o=(0,Xt.jsxs)("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 py-10 sm:py-14","data-testid":i,children:[!s&&(0,Xt.jsx)("div",{className:"mb-6",children:(0,Xt.jsx)(Rr,{asChild:!0,variant:"ghost",size:"sm",className:"text-ndor-ink-muted hover:text-ndor-ink -ml-2",children:(0,Xt.jsxs)(Et,{to:"/","data-testid":"legal-back-home",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"}),"Back to NDORFlow"]})})}),(0,Xt.jsxs)("header",{className:"space-y-2 mb-8 pb-6 border-b border-ndor-edge",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui",children:"NDORFlow Legal"}),(0,Xt.jsx)("h1",{className:"text-3xl sm:text-4xl font-serif-display font-semibold tracking-tight text-ndor-ink",children:t}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted font-mono-ui","data-testid":"legal-updated-at",children:["Last updated ",n]})]}),(0,Xt.jsx)("nav",{className:"flex flex-wrap gap-2 mb-10","data-testid":"legal-page-nav",children:FM.map(e=>{let{to:t,label:n,icon:r,testid:s}=e;const i=a===t;return(0,Xt.jsxs)(Et,{to:t,"data-testid":s,className:"inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md border transition-colors ".concat(i?"bg-ndor-ink text-ndor-canvas border-ndor-ink":"bg-transparent text-ndor-ink-muted border-ndor-edge hover:bg-ndor-surface-alt/50"),children:[(0,Xt.jsx)(r,{className:"h-3.5 w-3.5"}),n]},t)})}),(0,Xt.jsx)("article",{className:"prose prose-sm max-w-none text-ndor-ink-secondary font-manrope space-y-6 prose-headings:font-serif-display prose-headings:text-ndor-ink prose-headings:font-semibold prose-headings:tracking-tight prose-h2:text-xl prose-h2:mt-10 prose-h2:mb-3 prose-h3:text-base prose-h3:mt-6 prose-h3:mb-2 prose-p:text-sm prose-p:leading-relaxed prose-li:text-sm prose-li:leading-relaxed prose-strong:text-ndor-ink prose-strong:font-semibold prose-a:text-ndor-ink prose-a:underline hover:prose-a:text-ndor-ink/80","data-testid":"legal-page-body",children:r}),(0,Xt.jsxs)("footer",{className:"mt-12 pt-6 border-t border-ndor-edge text-xs text-ndor-ink-muted space-y-1",children:[(0,Xt.jsxs)("p",{children:["Questions about this document? Contact"," ",(0,Xt.jsx)("a",{href:"mailto:[email protected]","data-testid":"legal-contact-email",children:"[email protected]"}),"."]}),(0,Xt.jsxs)("p",{"data-testid":"legal-shell-copyright",children:["\xa9 ",(new Date).getFullYear()," NDOR Labs Limited. All rights reserved."]}),(0,Xt.jsx)("p",{className:"leading-relaxed",children:"NDORFlow is developed and owned by NDOR Labs Limited. Commercial services, subscriptions and customer support are provided by IAA Energy Resources Limited."})]})]});return s?o:(0,Xt.jsx)("div",{className:"min-h-screen bg-ndor-canvas",children:o})}function IM(){let{embedded:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,Xt.jsxs)(RM,{title:"Privacy Policy",updatedAt:"28 April 2026",activePath:"/privacy",embedded:e,testid:"privacy-page",children:[(0,Xt.jsxs)("p",{children:["The NDORFlow software platform (",(0,Xt.jsx)("strong",{children:'"NDORFlow"'}),") is owned, developed and licensed by ",(0,Xt.jsx)("strong",{children:"NDOR Labs Limited"}),' (the "',(0,Xt.jsx)("strong",{children:"Software Owner"}),'"). ',(0,Xt.jsx)("strong",{children:"IAA Energy Resources Limited"}),' (Company No. 11583381), a company registered in England and Wales, is the Authorised Commercial Operator for NDORFlow (the "',(0,Xt.jsx)("strong",{children:"Commercial Operator"}),'") and is responsible for marketing, sales, subscriptions, billing, payment collection, customer onboarding and customer support. References to'," ",(0,Xt.jsx)("strong",{children:'"we"'}),", ",(0,Xt.jsx)("strong",{children:'"us"'})," or"," ",(0,Xt.jsx)("strong",{children:'"our"'})," in this Policy refer to the two companies acting in their respective capacities set out above and in Section\xa01 below. This Privacy Policy explains what personal data we collect when you use NDORFlow, how we use and share it, how long we keep it, and the rights you have over it. It applies to all visitors and registered users of the Service."]}),(0,Xt.jsx)("h2",{children:"1. Who is responsible for your personal data?"}),(0,Xt.jsx)("p",{children:"NDORFlow is operated as a partnership between two companies. Each handles a distinct part of your relationship with the Service, and each is responsible for its own processing activities:"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"NDOR Labs Limited"})," \u2014 the Software Owner \u2014 is responsible for the operation, maintenance, security and development of the NDORFlow software platform and its technical infrastru
2cture (for example: how the application is built, hosted, encrypted, monitored and updated)."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"IAA Energy Resources Limited"})," \u2014 the Authorised Commercial Operator \u2014 is responsible for your commercial relationship with NDORFlow (for example: sign-up, subscriptions, billing, payment collection, invoices, customer accounts, customer communications and commercial support)."]})]}),(0,Xt.jsxs)("p",{children:["Where UK / EU data-protection law requires a designated data controller, IAA Energy Resources Limited acts as the controller of your personal data for the commercial-operation activities listed above, and NDOR Labs Limited acts as the party responsible for platform-operation activities on our behalf. For any privacy question or to exercise your rights, contact us via a single address:"," ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),"."]}),(0,Xt.jsx)("h2",{children:"2. What data we collect"}),(0,Xt.jsx)("h3",{children:"2.1 Account data"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsx)("li",{children:"Email address, display name, password hash, workspace membership."}),(0,Xt.jsx)("li",{children:"Plan, Credits balance, billing history metadata."}),(0,Xt.jsx)("li",{children:"IP address, device, browser, and log data captured automatically."})]}),(0,Xt.jsx)("h3",{children:"2.2 Uploaded CVs and documents"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsx)("li",{children:"CV files (PDF, DOCX) you upload."}),(0,Xt.jsx)("li",{children:"Parsed structured representations of those files (sections, experience entries, skills)."}),(0,Xt.jsx)("li",{children:"Cover letters, application packs, and notes you create inside the Service."})]}),(0,Xt.jsx)("h3",{children:"2.3 Job application materials"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsx)("li",{children:"Jobs you mark as recommended, applied, or ignored."}),(0,Xt.jsx)("li",{children:"Fit scores, NDOR analyses, and interview-preparation outputs generated for you."}),(0,Xt.jsx)("li",{children:"Exported bundles (PDF, Word) you have produced."})]}),(0,Xt.jsx)("h3",{children:"2.4 Billing data"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:["We do ",(0,Xt.jsx)("strong",{children:"not"})," store your full card or bank details. Payments are processed by Stripe."]}),(0,Xt.jsx)("li",{children:"We store Stripe customer IDs, transaction metadata, subscription status, and receipts linked to your account."})]}),(0,Xt.jsx)("h3",{children:"2.5 Cookies & analytics"}),(0,Xt.jsx)("p",{children:"We use strictly necessary cookies for authentication and session management. We may use first-party analytics to measure feature usage and product performance. Where required by local law (UK/EU), a consent banner is presented for non-essential analytics cookies."}),(0,Xt.jsx)("h2",{children:"3. How we use your data"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"To provide the Service"})," \u2014 parse your CVs, generate tailored outputs, score fit, produce packs, deliver exports."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"To bill you"})," \u2014 process subscriptions and top-ups via Stripe, issue receipts, enforce Credits."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"To secure the Service"})," \u2014 detect abuse, enforce rate-limits, investigate security incidents."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"To improve the Service"})," \u2014 aggregate and anonymised analytics; never to train third-party public AI models with your Content."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"To communicate with you"})," \u2014 transactional email (receipts, security notices, material product changes). Marketing email only with explicit opt-in."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"To comply with law"})," \u2014 respond to lawful requests, meet tax and accounting obligations."]})]}),(0,Xt.jsx)("h2",{children:"4. Legal bases (UK GDPR / EU GDPR)"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Contract"})," \u2014 to provide the Service you signed up for."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Legitimate interests"})," \u2014 to secure, debug, and improve the Service; balanced against your rights."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Consent"}
2)," \u2014 for non-essential analytics cookies and marketing email."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Legal obligation"})," \u2014 tax, accounting, responding to lawful authority requests."]})]}),(0,Xt.jsx)("h2",{children:"5. Third-party processors"}),(0,Xt.jsx)("p",{children:"We rely on the following processors to deliver the Service. Each is bound by a Data Processing Agreement."}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Supabase"})," \u2014 authentication, Postgres database, object storage. Primary region: EU (Frankfurt)."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Stripe"})," \u2014 payment processing, subscription management, Stripe Customer Portal."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"OpenAI, Anthropic, Google Gemini"})," \u2014 large-language-model inference for CV tailoring, cover-letter generation, fit scoring, and interview-preparation outputs. We send the minimum context required for each inference; we do not allow the provider to use your data to train their models (enterprise-grade settings are enabled where available)."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Gmail OAuth (Google)"})," \u2014 optional; only enabled if you connect your Gmail account to send application emails. Scope is limited to drafting and sending from your own account."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Email delivery (Resend / SendGrid)"})," \u2014 transactional email."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Hosting & CDN"})," \u2014 application hosting and content-delivery network."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"PostHog"})," \u2014 first-party product analytics. We capture page views and discrete product events (e.g. paid action attempted, paid action completed) to understand how the Service is used and to debug failures. Session-recording is currently disabled. We do not use PostHog for advertising or cross-site tracking. PostHog acts as a processor under our instructions; see the"," ",(0,Xt.jsx)("a",{href:"https://posthog.com/privacy",rel:"noreferrer",target:"_blank",children:"PostHog Privacy Policy"})," and"," ",(0,Xt.jsx)("a",{href:"https://posthog.com/dpa",rel:"noreferrer",target:"_blank",children:"Data Processing Agreement"}),"."]})]}),(0,Xt.jsx)("h2",{children:"6. International transfers"}),(0,Xt.jsx)("p",{children:"Some processors are located outside the UK / EEA. When we transfer personal data internationally we rely on UK IDTA or EU Standard Contractual Clauses, supplemented by technical safeguards (encryption in transit and at rest) to ensure an adequate level of protection."}),(0,Xt.jsx)("h2",{children:"7. Security"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsx)("li",{children:"TLS 1.2+ for all traffic."}),(0,Xt.jsx)("li",{children:"Encryption at rest for the database and object storage."}),(0,Xt.jsx)("li",{children:"Least-privilege access controls, MFA on administrative accounts."}),(0,Xt.jsx)("li",{children:"Row-level-security policies gating all user-owned tables."}),(0,Xt.jsx)("li",{children:"Regular backups; Supabase operates point-in-time recovery."}),(0,Xt.jsx)("li",{children:"Independent security reviews on major releases."})]}),(0,Xt.jsx)("h2",{children:"8. Retention"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Active accounts."})," We retain your account data and Content for as long as your account is active."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Closed accounts."})," On account closure, we delete your Content within 90 days, except where we must retain billing records for legal / tax reasons (typically 6 years in the UK)."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Anonymised metrics."})," We may retain aggregated, non-identifying usage statistics indefinitely."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Backups."})," Deleted Content may persist in encrypted backups for up to 35 days before rotation."]})]}),(0,Xt.jsx)("h2",{children:"9. Your rights"}),(0,Xt.jsx)("p",{children:"Subject to local law, you have the right to:"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsx)("li",{children:"Access the personal data we hold about you."}),(0,Xt.jsx)("li",{children:"Rectify inaccurate data."}),(0,Xt.jsx)("li",{children:'Erase data ("right to be forgotten") \u2014 subject to retention obligations above.'}),(0,Xt.jsx)("li",{children:"Port your data to another service in a machine-readable format."}),(0,Xt.jsx)("li",{children:"Restrict or object to processing."}),(0,Xt.jsx)("li",{children:"Withdraw consent (for consent-based processing)."}),(0,Xt.jsxs)("li",{children:["Lodge a complaint with a supervisory authority (in the UK, the Information Commissioner's Office \u2014 ",(0,Xt.jsx)("a",{href:"https://ico.org.uk/",rel:"noreferrer",target:"_blank",children:"ico.org.uk"}),")."]})]}),(0,Xt.jsxs)("p",{children:["To exercise any of these rights, email"," ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),". We respond within 30 days."]}),(0,Xt.jsx)("h2",{children:"10. Children"}),(0,Xt.jsx)("p",{children:"The Service is not intended for and may not be used by anyone under 16. We do not knowingly collect data from children. If you believe a child has created an account, contact us and we will delete the account."}),(0,Xt.jsx)("h2",{children:"11. Automated decision-making"}),(0,Xt.jsx)("p",{children:"NDORFlow does not make automated decisions that produce legal or similarly significant effects about you. AI-generated CVs, cover letters, and fit scores are decision-support outputs \u2014 you review and edit them before acting on them."}),(0,Xt.jsx)("h2",{children:"12. Changes to this Policy"}),(0,Xt.jsx)("p",{children:'We may update this Privacy Policy from time to time. Material changes will be notified by email and/or in-product banner at least 14 days before they take effect. The "Last updated" date at the top of this page reflects the current version.'}),(0,Xt.jsx)("h2",{children:"13. Contact"}),(0,Xt.jsxs)("p",{children:["For privacy questions or to exercise your rights, email"," ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),". For billing privacy questions, email ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),". For our Terms of Service and Refund Policy, see ",(0,Xt.jsx)("a",{href:"/terms",children:"/terms"})," and ",(0,Xt.jsx)("a",{href:"/refund",children:"/refund"}),"."]})]})}function TM(){return(0,Xt.jsxs)(RM,{title:"Terms of Service",updatedAt:"28 April 2026",activePath:"/terms",testid:"terms-page",children:[(0,Xt.jsxs)("p",{children:["These Terms of Service (the ",(0,Xt.jsx)("strong",{children:'"Terms"'}),") govern your access to and use of NDORFlow (",(0,Xt.jsx)("strong",{children:'"NDORFlow"'}),", the ",(0,Xt.jsx)("strong",{children:'"Service"'}),"). NDORFlow is a software-as-a-service product that helps candidates tailor CVs, generate cover letters, analyse job fit, and assemble application packs."]}),(0,Xt.jsx)("h2",{children:"1. The parties to these Terms"}),(0,Xt.jsx)("p",{children:"NDORFlow is operated as a partnership between two companies. These Terms are entered into between you and:"}),(0,Xt.jsx)("ul",{children:(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"IAA Energy Resources Limited"})," (Company No. 11583381), a company registered in England and Wales, whose registered office is 71-75 Shelton Street, Covent Garden, London, England, WC2H 9JQ (",(0,Xt.jsx)("strong",{children:'"we"'}),","," ",(0,Xt.jsx)("strong",{children:'"us"'}),", or ",(0,Xt.jsx)("strong",{children:'"our"'}),"). IAA Energy Resources Limited is the Authorised Commercial Operator for NDORFlow and is responsible for marketing, sales, subscriptions, billing, payment collection, commercial onboarding and customer support. IAA Energy Resources Limited is the contracting party for your subscription and the counterparty on invoices and payment statements."]})}),(0,Xt.jsxs)("p",{children:["The NDORFlow software platform and its associated intellectual property are owned, developed and licensed by ",(0,Xt.jsx)("strong",{children:"NDOR Labs Limited"}),' (the "',(0,Xt.jsx)("strong",{children:"Software Owner"}),'"), which licenses the platform to IAA Energy Resources Limited for commercial distribution and customer access. Section\xa010 (',(0,Xt.jsx)("em",{children:"Software ownership & licensing"}),") sets out the ownership and licensing arrangement in more detail. Customers purchase access to NDORFlow through IAA Energy Resources Limited."]}),(0,Xt.jsx)("p",{children:"By creating an account, subscribing to a paid plan, or using any part of the Service, you agree to these Terms. If you do not agree, do not use the Service."}),(0,Xt.jsx)("h2",{children:"2. The Service"}),(0,Xt.jsxs)("p",{children:["NDORFlow provides tools that assist you in preparing job applications. The Service includes a jobs catalogue, CV tailoring, cover letter generation, fit-scoring, interview preparation, and export utilities. The Service uses artificial-intelligence models and third-party processors (see our ",(0,Xt.jsx)("a",{href:"/privacy",children:"Privacy Policy"}),") to produce its outputs."]}),(0,Xt.jsx)("h2",{children:"3. Eligibility & Account"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsx)("li",{children:"You must be at least 16 years old and able to form a binding contract."}),(0,Xt.jsx)("li",{children:"You must provide accurate registration information and keep it current."}),(0,Xt.jsx)("li",{children:"You are responsible for all activity under your account and for keeping credentials secure."}),(0,Xt.jsx)("li",{children:"One account per person unless we explicitly permit team accounts."})]}),(0,Xt.jsx)("h2",{children:"4. Credits Model"}),(0,Xt.jsxs)("p",{children:["Paid actions in NDORFlow (Analyse Fit, CV generation, cover-letter generation, and any other action we label as paid) consume ",(0,Xt.jsx)("strong",{children:"Credits"}),". Credits come from two sources:"]}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Included Credits"})," \u2014 allocated monthly by your subscription plan; they reset each billing month and do not carry over."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Top-up Credits"})," \u2014 purchased as a top-up package. Top-up Credits do not expire and remain on your account until consumed, independent of your subscription state. Top-up Credits are consumed only after your Included Credits for the current month are exhausted."]})]}),(0,Xt.jsx)("p",{children:"Credits are consumed strictly for the paid action they are charged for; pricing for each action is displayed before you commit. Where an action produces no improvement over your existing materials, NDORFlow may waive the charge \u2014 the decision and reason are surfaced in the success toast at the point of action."}),(0,Xt.jsx)("p",{children:"Credits are a licence to use the Service. They have no cash value, are not redeemable for money, and are non-transferable between accounts."}),(0,Xt.jsx)("h2",{children:"5. Subscriptions & Billing"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsx)("li",{children:"Paid plans (Focus, Flow) are billed monthly or annually in advance via Stripe."}),(0,Xt.jsx)("li",{children:'IAA Energy Resources Limited is the seller and merchant of record for your subscription and any top-up purchase. Card processing is performed by Stripe on behalf of IAA Energy Resources Limited; invoices, receipts and payment statements will show "IAA Energy Resources Limited" as the counterparty.'}),(0,Xt.jsx)("li",{children:"Your subscription renews automatically at the end of each billing period unless cancelled."}),(0,Xt.jsx)("li",{children:"Prices, Included-Credit allowances, and any Founding Member offers are listed on the plan-selection page at the time of purchase and in your Account > Plan."}),(0,Xt.jsx)("li",{children:"We may change pricing or plan features with at least 30 days' notice for existing subscribers; changes take effect at the next renewal."}),(0,Xt.jsx)("li",{children:"Failed payments may result in Service suspension; you remain liable for amounts owed."})]}),(0,Xt.jsx)("h2",{children:"6. Cancellation & Refunds"}),(0,Xt.jsxs)("p",{children:["You may cancel your subscription at any time from Account > Plan or via the Stripe Customer Portal. Cancellation takes effect at the end of your current billing period and you retain access until that date. Refund eligibility is governed by our ",(0,Xt.jsx)("a",{href:"/refund",children:"Refund Policy"}),", which is incorporated into these Terms by reference. Refunds are issued by IAA Energy Resources Limited to the original payment method."]}),(0,Xt.jsx)("h2",{children:"7. AI-Generated Content & Disclaimers"}),(0,Xt.jsx)("p",{children:"CVs, cover letters, fit scores, interview preparation, and other outputs are generated
2with the assistance of artificial-intelligence models (OpenAI, Anthropic, and Google accessed via NDORFlow's managed integrations). These outputs are probabilistic and may contain errors, omissions, or fabricated content. You must review, edit, and verify every output before using it in a real job application. NDORFlow is not liable for any consequence arising from unreviewed output."}),(0,Xt.jsxs)("p",{children:[(0,Xt.jsx)("strong",{children:"No employment guarantee."})," NDORFlow is a tool that helps you prepare applications. We do not promise interviews, job offers, salary outcomes, or any specific employment result. Success depends on many factors outside our control."]}),(0,Xt.jsx)("h2",{children:"8. Your Content"}),(0,Xt.jsxs)("p",{children:["You retain all ownership of the CVs, cover letters, application packs, and other materials you upload or generate using the Service (your ",(0,Xt.jsx)("strong",{children:'"Content"'}),"). You grant NDORFlow a limited, non-exclusive, worldwide licence to host, process, and display your Content solely to provide the Service to you. We do not use your Content to train public AI models and we do not sell your Content."]}),(0,Xt.jsx)("h2",{children:"9. Acceptable Use"}),(0,Xt.jsx)("p",{children:"You agree not to:"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsx)("li",{children:"Use the Service to generate or submit falsified credentials or fraudulent applications."}),(0,Xt.jsx)("li",{children:"Reverse-engineer, scrape at scale, or copy substantial parts of the Service."}),(0,Xt.jsx)("li",{children:"Use the Service to harass, defame, or discriminate against any person."}),(0,Xt.jsx)("li",{children:"Upload malware, illegal content, or content you do not have rights to."}),(0,Xt.jsx)("li",{children:"Circumvent our Credits, rate-limit, or billing controls."}),(0,Xt.jsx)("li",{children:"Use the Service to build a competing product."})]}),(0,Xt.jsx)("h2",{children:"10. Software ownership & licensing"}),(0,Xt.jsxs)("p",{children:["The NDORFlow software platform, its underlying source code, models, prompts, evaluation frameworks, algorithms, databases, templates, documentation, branding and all other associated intellectual property (together, the"," ",(0,Xt.jsx)("strong",{children:'"Platform IP"'}),") are owned exclusively by"," ",(0,Xt.jsx)("strong",{children:"NDOR Labs Limited"}),". Nothing in these Terms, in your subscription, or in any commercial dealing with IAA Energy Resources Limited transfers any ownership of the Platform IP to you."]}),(0,Xt.jsx)("p",{children:"NDOR Labs Limited licenses the Platform IP to IAA Energy Resources Limited on commercial terms that authorise IAA Energy Resources Limited to distribute the Service, sell subscriptions, invoice customers and provide customer support. Your subscription grants you a limited, personal, non-exclusive, non-transferable, revocable licence to use the Service subject to these Terms; it does not grant you any right in the Platform IP itself. Our third-party processors retain all rights to their underlying models and platforms."}),(0,Xt.jsx)("h2",{children:"11. Suspension & Termination"}),(0,Xt.jsxs)("p",{children:["We may suspend or terminate your account, with or without notice, if you materially breach these Terms, if required by law, or if continued provision creates material risk to NDORFlow or other users. You may close your account at any time from Account > Plan. On termination, your right to use the Service ends and we may delete your data subject to the retention rules in our ",(0,Xt.jsx)("a",{href:"/privacy",children:"Privacy Policy"}),"."]}),(0,Xt.jsx)("h2",{children:"12. Limitation of Liability"}),(0,Xt.jsx)("p",{children:"To the maximum extent permitted by law, NDORFlow, IAA Energy Resources Limited, NDOR Labs Limited and their respective licensors are not liable for any indirect, incidental, special, consequential, or punitive damages, including loss of employment opportunity, loss of income, loss of data, or reputational harm. The aggregate liability of IAA Energy Resources Limited for any claim arising from or related to the Service shall not exceed the greater of (a) the amount you paid IAA Energy Resources Limited in the twelve (12) months preceding the event giving rise to the claim, or (b) one hundred pounds sterling (\xa3100). Nothing in these Terms limits liability for fraud, gross negligence, or any liability that cannot be limited by law (including liability for death or personal injury caused by negligence)."}),(0,Xt.jsx)("h2",{children:"13. Warranty Disclaimer"}),(0,Xt.jsx)("p",{children:'The Service is provided "as is" and "as available" without warranties of any kind, express or implied, including fitness for a particular purpose, non-infringement, and accuracy. We do not warrant uninterrupted or error-free operation.'}),(0,Xt.jsx)("h2",{children:"14. Changes to these Terms"}),(0,Xt.jsx)("p",{children:"We may update these Terms from time to time. Material changes will be notified by email and/or in-product banner at least 14 days before they take effect. Continued use of the Service after changes take effect constitutes acceptance of the updated Terms."}),(0,Xt.jsx)("h2",{children:"15. Governing Law & Disputes"}),(0,Xt.jsx)("p",{children:"These Terms are governed by the laws of England and Wales. Any dispute arising under these Terms is subject to the exclusive jurisdiction of the courts of England and Wales, except where mandatory consumer-protection law grants you a right to bring proceedings in your country of residence."}),(0,Xt.jsx)("h2",{children:"16. Contact"}),(0,Xt.jsxs)("p",{children:["For questions about these Terms, email ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),". For billing issues, email ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),"."]})]})}function PM(){return(0,Xt.jsxs)(RM,{title:"Refund Policy",updatedAt:"28 April 2026",activePath:"/refund",testid:"refund-page",children:[(0,Xt.jsxs)("p",{children:["This Refund Policy describes when and how refunds may be available for NDORFlow purchases. It forms part of our ",(0,Xt.jsx)("a",{href:"/terms",children:"Terms of Service"}),"."," ",(0,Xt.jsx)("strong",{children:"IAA Energy Resources Limited"})," (Company No. 11583381) is the seller and merchant of record for your NDORFlow subscription and any top-up purchase, and issues any refund to the original payment method. Our goal is to be fair, transparent, and to comply with applicable consumer-protection law in your country of residence."]}),(0,Xt.jsx)("h2",{children:"1. Credit Purchases (Top-ups)"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Unused Credits."}
2)," If you have not consumed any Credits from a top-up package, you may request a full refund within ",(0,Xt.jsx)("strong",{children:"14 days"})," of purchase. This right mirrors the statutory right of withdrawal for digital services in the UK and EU, which you may waive by using the Credits. Once you consume any Credits from the package, the package is treated as partly delivered and is non-refundable except as set out below."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Used Credits."}),' Credits that have been consumed (Analyse Fit, CV generation, cover-letter generation, or any other paid action that was attempted and delivered) are not refundable. Where NDORFlow waives a charge automatically because an action did not produce an improvement (e.g. "Tailoring complete \u2014 no charge (no improvement)"), you are not billed and there is nothing to refund.']})]}),(0,Xt.jsx)("h2",{children:"2. Subscriptions (Focus, Flow)"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Cancellation."})," You may cancel at any time from Account > Plan or via the Stripe Customer Portal. Cancellation stops future renewals. You retain access to the paid plan until the end of your current billing period."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Monthly plans."})," Monthly fees are not pro-rated on cancellation. You keep access through the end of the month you have paid for."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Annual plans."})," If you cancel within 14 days of first subscribing and have consumed fewer than 50% of the Included Credits allocated for that period, you may request a full refund. Beyond that window, annual plans are non-refundable but continue to the end of the paid year."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Material Service failure."})," If a Service defect we are responsible for prevents you from using the plan substantially as described, and we cannot remedy the defect within 14 days of you reporting it, you may request a pro-rated refund for the affected period."]})]}),(0,Xt.jsx)("h2",{children:"3. Billing Cycles & Renewals"}),(0,Xt.jsx)("p",{children:"Paid plans renew automatically at the end of each billing period unless cancelled before the renewal date. You will receive a renewal email receipt from Stripe. If a renewal charge appears on your statement after you intended to cancel, contact us within 30 days of the charge and we will consider a refund of the renewal subject to the rules above."}),(0,Xt.jsx)("h2",{children:"4. Payment Disputes & Chargebacks"}),(0,Xt.jsxs)("p",{children:["If you believe a charge is incorrect, please contact us first at"," ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),". We aim to acknowledge within 2 business days and resolve within 10 business days. Filing a chargeback with your bank or card issuer without contacting us first may result in account suspension pending the dispute outcome. We will respond to all bank chargebacks with the relevant billing records."]}),(0,Xt.jsx)("h2",{children:"5. Exceptional Scenarios"}),(0,Xt.jsxs)("ul",{children:[(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Duplicate charges."})," If you are charged twice for the same purchase due to a payment-processor error, we will refund the duplicate in full on confirmation."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Unauthorised charges."})," If you report a charge you did not authorise within 60 days, we will investigate and, where appropriate, refund and lock the account pending identity re-verification."]}),(0,Xt.jsxs)("li",{children:[(0,Xt.jsx)("strong",{children:"Service outages."})," We may issue Credits or partial refunds at our discretion for extended outages that materially affect your ability to use the Service."]})]}),(0,Xt.jsx)("h2",{children:"6. Consumer Protections"}),(0,Xt.jsx)("p",{children:"This policy does not affect your statutory consumer rights. In the UK, your rights under the Consumer Rights Act 2015 and the Consumer Contracts Regulations 2013 continue to apply. In the EU, your rights under the Consumer Rights Directive (2011/83/EU) continue to apply. In the US, applicable state consumer-protection law continues to apply. Where local law requires a more generous refund than this policy provides, the local law prevails for that purchase."}),(0,Xt.jsx)("h2",{children:"7. How to Request a Refund"}),(0,Xt.jsxs)("ol",{children:[(0,Xt.jsxs)("li",{children:["Email ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),' with the subject line "Refund request \u2014 [your email]".']}),(0,Xt.jsx)("li",{children:"Include the Stripe transaction ID or the date and amount of the charge."}),(0,Xt.jsx)("li",{children:"Describe the reason and any relevant screenshots."}),(0,Xt.jsx)("li",{children:"We will acknowledge within 2 business days and decide within 10 business days."}),(0,Xt.jsx)("li",{children:"Approved refunds are returned to the original payment method and usually clear within 5\u201310 business days depending on your bank."})]}),(0,Xt.jsx)("h2",{children:"8. Changes to this Policy"}),(0,Xt.jsx)("p",{children:'We may update this Refund Policy from time to time. The "Last updated" date at the top of this page reflects the latest version. Purchases made before a change are governed by the policy in force at time of purchase.'}),(0,Xt.jsx)("h2",{children:"9. Contact"}),(0,Xt.jsxs)("p",{children:["For refund requests, email"," ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),". For general questions, see our"," ",(0,Xt.jsx)("a",{href:"/terms",children:"Terms of Service"})," or email"," ",(0,Xt.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"}),"."]})]})}const OM={job_description:"Job description",source_cv:"Synthetic Source CV",tailored_cv:"NDOR-tailored CV",cover_letter:"NDOR-tailored cover letter"},BM={job_description:"Paraphrased Senior Manager \u2014 Digital Product Management (Integrated Risk Management) JD. No employer name; no verbatim copy.",source_cv:"Synthetic candidate CV in the same domain (strategy / risk / decision-support). Fake name, fake employers, altered timelines.",tailored_cv:"CV produced by the live NDOR pipeline. Same prompt path your users hit in production.",cover_letter:"Cover letter produced by the live NDOR pipeline. Same prompt path your users hit."};function LM(){var e,t,n;
2const[a,r]=(0,s.useState)(null),[i,o]=(0,s.useState)(null);if((0,s.useEffect)(()=>{fetch("/proof/manifest.json",{cache:"no-store"}).then(e=>e.ok?e.json():Promise.reject(new Error(e.statusText))).then(r).catch(e=>o(e.message))},[]),i)return(0,Xt.jsx)("div",{className:"min-h-screen bg-ndor-surface text-ndor-ink p-8",children:(0,Xt.jsxs)("p",{className:"text-sm text-ndor-warning","data-testid":"proof-error",children:["Could not load /proof/manifest.json \u2014 ",i]})});if(!a)return(0,Xt.jsx)("div",{className:"min-h-screen bg-ndor-surface text-ndor-ink p-8",children:(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted",children:"Loading proof artifacts\u2026"})});const l=a.verdict_delta,c=l>0?"+":"";return(0,Xt.jsx)("div",{className:"min-h-screen bg-ndor-surface text-ndor-ink py-12 px-6",children:(0,Xt.jsxs)("div",{className:"max-w-4xl mx-auto space-y-8","data-testid":"proof-preview-page",children:[(0,Xt.jsxs)("header",{className:"space-y-2",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.24em] text-ndor-ink-muted",children:"Internal \xb7 operator preview"}),(0,Xt.jsx)("h1",{className:"text-3xl sm:text-4xl font-serif-display text-ndor-ink",children:"NDOR proof \u2014 one example outcome"}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-secondary leading-relaxed",children:["Synthetic candidate \xb7 paraphrased financial-services Integrated Risk Management role \xb7 same NDOR pipeline your users hit in production."," ",(0,Xt.jsx)("span",{className:"italic text-ndor-ink-muted",children:"Results vary."})]})]}),(0,Xt.jsxs)("section",{className:"rounded-xl border border-ndor-edge bg-ndor-surface-alt/30 p-6 grid grid-cols-1 sm:grid-cols-3 gap-4","data-testid":"proof-headline-numbers",children:[(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-ndor-ink-muted",children:"Source CV verdict"}),(0,Xt.jsxs)("p",{className:"text-4xl font-serif-display text-ndor-ink",children:[a.source_verdict,(0,Xt.jsx)("span",{className:"text-base text-ndor-ink-muted",children:"/100"})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"LLM-graded NDOR CV verdict before tailoring."})]}),(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-ndor-ink-muted",children:"Tailored CV verdict"}),(0,Xt.jsxs)("p",{className:"text-4xl font-serif-display text-ndor-ink",children:[a.tailored_verdict,(0,Xt.jsx)("span",{className:"text-base text-ndor-ink-muted",children:"/100"})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"Same JD; same grader; CV tailored by NDOR."})]}),(0,Xt.jsxs)("div",{className:"space-y-1",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-ndor-ink-muted",children:"Lift"}),(0,Xt.jsxs)("p",{className:"text-4xl font-serif-display "+(l>0?"text-ndor-success":"text-ndor-ink"),children:[c,l]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted",children:"NDOR CV verdict points, JD held constant."})]})]}),(0,Xt.jsxs)("section",{className:"space-y-3","data-testid":"proof-downloads",children:[(0,Xt.jsx)("h2",{className:"text-base text-ndor-ink",children:"Download artifacts"}),(0,Xt.jsx)("ul",{className:"space-y-2",children:Object.entries(a.files).map(e=>{let[t,n]=e;return(0,Xt.jsxs)("li",{className:"rounded-lg border border-ndor-edge bg-ndor-surface-alt/20 p-4 flex items-start justify-between gap-4","data-testid":"proof-row-".concat(t),children:[(0,Xt.jsxs)("div",{className:"min-w-0",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:OM[t]||t}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed mt-0.5",children:BM[t]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col gap-1.5 shrink-0",children:[(0,Xt.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-ndor-gold underline whitespace-nowrap","data-testid":"proof-view-".concat(t),children:"View"}),(0,Xt.jsx)("a",{href:n,download:!0,className:"text-xs text-ndor-gold underline whitespace-nowrap","data-testid":"proof-d
2ownload-".concat(t),children:"Download"})]})]},t)})})]}),(0,Xt.jsxs)("section",{className:"space-y-2","data-testid":"proof-pipeline-meta",children:[(0,Xt.jsx)("h2",{className:"text-base text-ndor-ink",children:"Pipeline trace"}),(0,Xt.jsxs)("ul",{className:"text-[11px] text-ndor-ink-muted leading-relaxed",children:[(0,Xt.jsxs)("li",{children:["Grader model: ",(null===(e=a.models)||void 0===e?void 0:e.grader)||"\u2014"]}),(0,Xt.jsxs)("li",{children:["CV variant model: ",(null===(t=a.models)||void 0===t?void 0:t.cv_variant)||"\u2014"]}),(0,Xt.jsxs)("li",{children:["Cover letter model: ",(null===(n=a.models)||void 0===n?void 0:n.cover_letter)||"\u2014"]})]}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed",children:["Fabrication checks (CV / cover letter) ran inside `ndor.router.generate_cv` and `generate_cover_letter`. Manifest with full meta:"," ",(0,Xt.jsx)("a",{href:"/proof/manifest.json",target:"_blank",rel:"noopener noreferrer",className:"text-ndor-gold underline",children:"/proof/manifest.json"}),"."]})]})]})})}const MM=wn("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),zM={cv_variant:{singular:"Tailored CV",endpoint:"/api/cv-variants",pronoun:"it"},cover_letter:{singular:"Cover Letter",endpoint:"/api/cover-letters",pronoun:"it"},interview_prep:{singular:"Interview Prep",endpoint:"/api/interview-prep",pronoun:"it"}};function UM(e){let{open:t,onOpenChange:n,kind:a,doc:r,onDeleted:i}=e;const o=zM[a]||zM.cv_variant,[l,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),m=()=>{u(null),c(!1),null===n||void 0===n||n(!1)};async function p(){let{force:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(null!==r&&void 0!==r&&r.id){c(!0);try{var t;const n="".concat(o.endpoint,"/").concat(r.id).concat(e?"?force=true":""),a=await(0,zt.n)(n,{method:"DELETE"});fy.success(e&&null!==a&&void 0!==a&&null!==(t=a.unlinked_pack_ids)&&void 0!==t&&t.length?"".concat(o.singular," deleted and unlinked from ")+"".concat(a.unlinked_pack_ids.length," pack")+"".concat(1===a.unlinked_pack_ids.length?"":"s","."):"".concat(o.singular," deleted.")),null===i||void 0===i||i(r.id),m()}catch(pK){var n,a;409===(null===pK||void 0===pK?void 0:pK.status)&&"linked_to_packs"===(null===(n=pK.data)||void 0===n||null===(a=n.detail)||void 0===a?void 0:a.error)?u(pK.data.detail):fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to delete ".concat(o.singular.toLowerCase(),"."))}finally{c(!1)}}}const h=(null===r||void 0===r?void 0:r.variant_name)||(null===r||void 0===r?void 0:r.title)||(null===r||void 0===r?void 0:r.target_role)||"Untitled";if(d){var f;const e="cv_variant"===a,r=(d.pack_count_active||0)+(d.pack_count_archived||0);return(0,Xt.jsx)(rg,{open:t,onOpenChange:n,children:(0,Xt.jsxs)(lg,{"data-testid":"delete-doc-conflict",children:[(0,Xt.jsx)(cg,{children:(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[(0,Xt.jsx)(MM,{className:"h-4 w-4 text-ndor-warning"}),e?"Cannot delete \u2014 still selected on a pack":"This cover letter is in use"]})}),(0,Xt.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,Xt.jsxs)("p",{className:"text-ndor-ink",children:[(0,Xt.jsx)("span",{className:"font-medium",children:h})," is still linked to"," ",(0,Xt.jsx)("span",{className:"font-medium",children:r})," application pack",1===r?"":"s",d.pack_count_active>0&&" (".concat(d.pack_count_active," active)"),d.pack_count_archived>0&&", ".concat(d.pack_count_archived," archived"),"."]}),e?(0,Xt.jsx)("p",{className:"text-ndor-ink-secondary text-xs",children:"Because every application pack must have a Selected CV, this Tailored CV can only be removed after you change the Selected CV on each linked pack (or delete the pack itself). Open the pack from the list below \u2014 reassign, then come back here."}):(0,Xt.jsxs)("p",{className:"text-ndor-ink-secondary text-xs",children:["Deleting it now will ",(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium",children:"unlink it from those packs"})," \u2014 their Selected Cover Letter will become unset but the packs themselves will stay. You can always link a different letter afterwards."]}),(null===(f=d.pack_ids)||void 0===f?void 0:f.length)>0&&(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 px-3 py-2 space-y-1",children:[(0,Xt.jsx)("p",{className:"text-[10px] uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Affected packs"}),(0,Xt.jsxs)("ul",{className:"space-y-1","data-testid":"delete-doc-conflict-pack-list",children:[d.pack_ids.slice(0,5).map(e=>(0,Xt.jsx)("li",{className:"text-xs",children:(0,Xt.jsxs)("a",{href:"/applications/".concat(e),className:"text-ndor-info hover:underline","data-testid":"delete-doc-conflict-pack-link-".concat(e),children:["Open pack ",e.slice(0,8)," \u2192"]})},e)),d.pack_ids.length>5&&(0,Xt.jsxs)("li",{className:"text-[11px] text-ndor-ink-muted",children:["\u2026 and ",d.pack_ids.length-5," more."]})]})]})]}),(0,Xt.jsxs)(dg,{className:"gap-2",children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:m,disabled:l,"data-testid":"delete-doc-conflict-cancel",children:"Close"}),!e&&(0,Xt.jsxs)(Rr,{variant:"destructive",onClick:()=>p({force:!0}),disabled:l,"data-testid":"delete-doc-conflict-force",children:[l?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}):(0,Xt.jsx)(pb,{className:"h-4 w-4 mr-1.5"}),"Delete anyway & unlink from ",r," pack",1===r?"":"s"]})]})]})})}const x=(null===r||void 0===r?void 0:r.usage)||{},v=(x.pack_count_active||0)+(x.pack_count_archived||0)>0;return(0,Xt.jsx)(rg,{open:t,onOpenChange:n,children:(0,Xt.jsxs)(lg,{"data-testid":"delete-doc-confirm",children:[(0,Xt.jsx)(cg,{children:(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 text-ndor-warning"}),"Delete this ",o.singular.toLowerCase(),"?"]})}),(0,Xt.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,Xt.jsxs)("p",{className:"text-ndor-ink",children:[(0,Xt.jsx)("span",{className:"font-medium",children:h})," will be removed from your library."]}),!v&&(0,Xt.jsxs)("p",{className:"text-ndor-ink-secondary text-xs","data-testid":"delete-doc-confirm-unused-note",children:["No application pack is currently using ",o.pronoun," \u2014 this is a clean delete."]}),x.pack_count_active>0&&(0,Xt.jsxs)("p",{className:"text-ndor-warning text-xs","data-testid":"delete-doc-confirm-active-note",children:[x.pack_count_active," active pack",1===x.pack_count_active?"":"s"," currently reference",1===x.pack_count_active?"s":""," ",o.pronoun,".","cv_variant"===a?" The delete will be blocked and you'll be asked to reassign first.":" Deleting will unset the Selected Cover Letter on those packs."]}),!x.pack_count_active&&x.pack_count_archived>0&&(0,Xt.jsxs)("p",{className:"text-ndor-ink-muted text-xs","data-testid":"delete-doc-confirm-archived-note",children:["Only archived packs reference ",o.pronoun,". ","cv_variant"===a?"Archived packs still count \u2014 the delete may be blocked.":"Delete will unlink those archived packs from the letter."]})]}),(0,Xt.jsxs)(dg,{className:"gap-2",children:[(0,Xt.jsx)(Rr,{variant:"ghost",onClick:m,disabled:l,"data-testid":"delete-doc-confirm-cancel",children:"Cancel"}),(0,Xt.jsxs)(Rr,{variant:"destructive",onClick:()=>p({force:!1}),disabled:l,"data-testid":"delete-doc-confirm-delete",children:[l?(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin mr-1.5"}):(0,Xt.jsx)(pb,{className:"h-4 w-4 mr-1.5"}),"Delete"]})]})]})})}
2function VM(e){let{variantId:t,letterId:n,title:a,disabled:r}=e;const[i,o]=(0,s.useState)(!1),l=async e=>{if(t||n){o(!0);try{const r=t?"/api/cv-variants/".concat(t,"/export"):"/api/cover-letters/".concat(n,"/export"),s="docx"===e?"docx":"pdf";await async function(e,t){const{data:{session:n}}=await Mt.supabase.auth.getSession();if(null===n||void 0===n||!n.access_token)throw new Error("Not authenticated.");const a=await fetch("".concat("https://app.ndorflow.app").concat(e),{headers:{Authorization:"Bearer ".concat(n.access_token)}});if(!a.ok){let e="Export failed (".concat(a.status,")");try{e=(await a.json()).detail||e}catch(c){}throw new Error(e)}const r=(a.headers.get("Content-Disposition")||"").match(/filename="([^"]+)"/),s=r?r[1]:t,i=await a.blob(),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download=s,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(o)}("".concat(r,"?format=").concat(e),"".concat((a||"document").slice(0,60),".").concat(s)),fy.success("Downloaded ".concat(e.toUpperCase(),"."))}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Export failed.")}finally{o(!1)}}};return(0,Xt.jsxs)(cp,{children:[(0,Xt.jsx)(dp,{asChild:!0,children:(0,Xt.jsxs)(Rr,{variant:"ghost",size:"sm",className:"h-7 text-xs text-ndor-ink-muted",disabled:r||i,"data-testid":"export-button",children:[i?(0,Xt.jsx)(Lg,{className:"h-3 w-3 animate-spin mr-1"}):(0,Xt.jsx)(AC,{className:"h-3 w-3 mr-1"}),"Export"]})}),(0,Xt.jsxs)(up,{align:"end",children:[(0,Xt.jsxs)(mp,{onClick:()=>l("pdf"),"data-testid":"export-pdf",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4 mr-2"})," PDF"]}),(0,Xt.jsxs)(mp,{onClick:()=>l("docx"),"data-testid":"export-docx",children:[(0,Xt.jsx)(yO,{className:"h-4 w-4 mr-2"})," Word (.docx)"]})]})]})}function qM(e){if(!e)return"";try{return new Date(e).toLocaleDateString()}catch(t){return""}}function WM(e){let{open:t,onOpenChange:n,id:a,title:r,subtitle:i}=e;const[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)("");return(0,s.useEffect)(()=>{if(!t||!a)return;let e=!0;return d(!0),m(""),l(null),(0,zt.n)("/api/cv-variants/".concat(a)).then(t=>e&&l(t)).catch(t=>e&&m((null===t||void 0===t?void 0:t.message)||"Failed to load.")).finally(()=>e&&d(!1)),()=>{e=!1}},[t,a]),(0,Xt.jsx)(rg,{open:t,onOpenChange:n,children:(0,Xt.jsxs)(lg,{className:"max-w-3xl max-h-[80vh] overflow-y-auto","data-testid":"variant-preview-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[r,(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] tracking-[0.16em] uppercase border-ndor-edge text-ndor-ink-muted",children:[(0,Xt.jsx)(b_,{className:"h-2.5 w-2.5 mr-1"}),"Read-only"]})]}),i&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:i})]}),c&&(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted mx-auto my-6"}),u&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-error",children:u}),!c&&!u&&(0,Xt.jsx)("div",{"data-testid":"variant-preview-body",children:o?(0,Xt.jsx)(Y_,{mode:"variant",data:o}):(0,Xt.jsx)("span",{className:"text-ndor-ink-muted italic text-sm",children:"No content available."})})]})})}const HM=3e5;function GM(e){if(!e)return"";try{return new Date(e).toLocaleDateString()}catch(t){return""}}function KM(e){let{open:t,onOpenChange:n,id:a,title:r,subtitle:i}=e;const[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)("");return(0,s.useEffect)(()=>{if(!t||!a)return;let e=!0;return d(!0),m(""),l(null),(0,zt.n)("/api/cover-letters/".concat(a)).then(t=>e&&l(t)).catch(t=>e&&m((null===t||void 0===t?void 0:t.message)||"Failed to load.")).finally(()=>e&&d(!1)),()=>{e=!1}},[t,a]),(0,Xt.jsx)(rg,{open:t,onOpenChange:n,children:(0,Xt.jsxs)(lg,{className:"max-w-3xl max-h-[80vh] overflow-y-auto","data-testid":"letter-preview-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[r,(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] tracking-[0.16em] uppercase border-ndor-edge text-ndor-ink-muted",children:[(0,Xt.jsx)(b_,{className:"h-2.5 w-2.5 mr-1"}),"Read-only"]})]}),i&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:i})]}),c&&(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted mx-auto my-6"}),u&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-error",children:u}),!c&&!u&&(0,Xt.jsx)("div",{"data-testid":"letter-preview-body",children:o?(0,Xt.jsx)(Y_,{mode:"letter",data:o}):(0,Xt.jsx)("span",{className:"text-ndor-ink-muted italic text-sm",children:"No content available."})})]})})}const YM=3e5;function JM(e){if(!e)return"";try{return new Date(e).toLocaleDateString()}catch(t){return""}}function $M(e){let{open:t,onOpenChange:n,id:a,title:r,subtitle:i}=e;
2const[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)("");return(0,s.useEffect)(()=>{if(!t||!a)return;let e=!0;return d(!0),m(""),l(null),(0,zt.n)("/api/interview-prep/".concat(a),{headers:{"X-Envelope":"rc_1_52_canonical"}}).then(t=>{var n,a,r,s;if(!e)return;const i=null!==(n=null!==(a=null===t||void 0===t||null===(r=t.result)||void 0===r?void 0:r.interview_prep)&&void 0!==a?a:null===t||void 0===t||null===(s=t.content_json)||void 0===s?void 0:s.interview_prep)&&void 0!==n?n:null;l(i)}).catch(t=>e&&m((null===t||void 0===t?void 0:t.message)||"Failed to load.")).finally(()=>e&&d(!1)),()=>{e=!1}},[t,a]),(0,Xt.jsx)(rg,{open:t,onOpenChange:n,children:(0,Xt.jsxs)(lg,{className:"max-w-3xl max-h-[80vh] overflow-y-auto","data-testid":"interview-prep-preview-modal",children:[(0,Xt.jsxs)(cg,{children:[(0,Xt.jsxs)(ug,{className:"flex items-center gap-2",children:[r,(0,Xt.jsxs)(Vw,{variant:"outline",className:"text-[10px] tracking-[0.16em] uppercase border-ndor-edge text-ndor-ink-muted",children:[(0,Xt.jsx)(b_,{className:"h-2.5 w-2.5 mr-1"}),"Read-only"]})]}),i&&(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:i})]}),c&&(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted mx-auto my-6"}),u&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-error",children:u}),!c&&!u&&(0,Xt.jsx)("div",{"data-testid":"interview-prep-preview-body",children:(0,Xt.jsx)(gE,{interviewPrep:o})})]})})}const XM=3e5;const QM=[{key:"source",label:"Source CV",Component:bC},{key:"variants",label:"CV Variants",Component:function(){const[e,t]=(0,s.useState)(()=>{const e=ew(sw(),HM);return e.hit&&Array.isArray(e.data)?e.data:[]}),[n,a]=(0,s.useState)(()=>!ew(sw(),HM).hit),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(""),[c,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(null),p=(0,s.useCallback)(async()=>{try{const e=await tw(sw(),()=>(0,zt.n)("/api/cv-variants"),{ttlMs:HM});t(Array.isArray(e)?e:[])}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to load CV variants.")}finally{a(!1)}},[]);return(0,s.useEffect)(()=>{p()},[p]),n?(0,Xt.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})}):(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"variants-history",children:[0===e.length?(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm",children:(0,Xt.jsxs)(Py,{className:"p-8 text-center space-y-3",children:[(0,Xt.jsx)("div",{className:"mx-auto w-12 h-12 rounded-full bg-ndor-surface-alt flex items-center justify-center",children:(0,Xt.jsx)(Kn,{className:"h-5 w-5 text-ndor-ink-muted"})}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No CV variants yet"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted leading-relaxed max-w-sm mx-auto",children:"Tailored CVs are generated when you apply to a job. Open a job to start."}),(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",size:"sm","data-testid":"variants-history-jobs-link",children:(0,Xt.jsxs)(Et,{to:"/jobs",children:[(0,Xt.jsx)(KN,{className:"h-3.5 w-3.5 mr-1.5"}),"Browse jobs"]})}),(0,Xt.jsxs)("div",{className:"mt-5 mx-auto max-w-md rounded-md border border-ndor-edge bg-ndor-surface-alt/40 p-3 text-left","data-testid":"variants-empty-reviewer-hint",children:[(0,Xt.jsx)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Recommended next step"}),(0,Xt.jsxs)("ol",{className:"mt-2 space-y-1.5 text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"1."}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)(Et,{to:"/jobs",className:"text-ndor-info hover:underline",children:"Import or choose a job"})," from the Jobs page."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"2."}),(0,Xt.jsxs)("span",{children:["Run ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Analyse Fit"})," on the role using your Source CV."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"3."}),(0,Xt.jsxs)("span",{children:["Inside the application flow, generate a ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"tailored CV variant"})," \u2014 it lands here in your library."]})]})]})]})]})}):(0,Xt.jsx)("ul",{className:"space-y-2",children:e.map(e=>(0,Xt.jsxs)("li",{className:"rounded-lg border border-ndor-edge bg-ndor-surface px-4 py-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-3","data-testid":"variant-row-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-3 sm:contents min-w-0
2w-full",children:[(0,Xt.jsx)("div",{className:"w-9 h-9 rounded-lg bg-ndor-surface-alt flex items-center justify-center shrink-0",children:(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-ndor-ink-muted"})}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate","data-testid":"variant-row-title",children:e.variant_name||"Untitled variant"}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted line-clamp-2 sm:line-clamp-none break-words",children:[e.role_family||"No role family"," \xb7 Generated ",qM(e.created_at)]})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 sm:shrink-0 self-end sm:self-auto",children:[(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:()=>{i(e.id),l(e.variant_name||"CV variant"),d("Generated ".concat(qM(e.created_at)))},"data-testid":"variant-row-preview",children:"Preview"}),(0,Xt.jsx)(VM,{variantId:e.id,title:e.variant_name||"cv-variant"}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"icon",className:"h-8 w-8 text-ndor-ink-muted hover:text-ndor-error",onClick:()=>m(e),"data-testid":"variant-row-delete",children:(0,Xt.jsx)(pb,{className:"h-4 w-4"})})]})]},e.id))}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed pt-1",children:["To create a new tailored CV, open a job from"," ",(0,Xt.jsx)(Et,{to:"/jobs",className:"underline hover:text-ndor-ink",children:"/jobs"})," and use the application flow."]}),(0,Xt.jsx)(WM,{open:!!r,onOpenChange:e=>!e&&i(null),id:r,title:o,subtitle:c}),(0,Xt.jsx)(UM,{open:!!u,onOpenChange:e=>!e&&m(null),kind:"cv_variant",doc:u,onDeleted:()=>{nw(sw()),m(null),p()}})]})}},{key:"letters",label:"Cover Letters",Component:function(){const[e,t]=(0,s.useState)(()=>{const e=ew(iw(),YM);return e.hit&&Array.isArray(e.data)?e.data:[]}),[n,a]=(0,s.useState)(()=>!ew(iw(),YM).hit),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(""),[c,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(null),p=(0,s.useCallback)(async()=>{try{const e=await tw(iw(),()=>(0,zt.n)("/api/cover-letters"),{ttlMs:YM});t(Array.isArray(e)?e:[])}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to load cover letters.")}finally{a(!1)}},[]);return(0,s.useEffect)(()=>{p()},[p]),n?(0,Xt.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})}):(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"cover-letters-history",children:[0===e.length?(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm",children:(0,Xt.jsxs)(Py,{className:"p-8 text-center space-y-3",children:[(0,Xt.jsx)("div",{className:"mx-auto w-12 h-12 rounded-full bg-ndor-surface-alt flex items-center justify-center",children:(0,Xt.jsx)(Kn,{className:"h-5 w-5 text-ndor-ink-muted"})}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No cover letters yet"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted leading-relaxed max-w-sm mx-auto",children:"Cover letters are generated when you apply to a job. Open a job to start."}),(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",size:"sm","data-testid":"letters-history-jobs-link",children:(0,Xt.jsxs)(Et,{to:"/jobs",children:[(0,Xt.jsx)(KN,{className:"h-3.5 w-3.5 mr-1.5"}),"Browse jobs"]})}),(0,Xt.jsxs)("div",{className:"mt-5 mx-auto max-w-md rounded-md border border-ndor-edge bg-ndor-surface-alt/40 p-3 text-left","data-testid":"letters-empty-reviewer-hint",children:[(0,Xt.jsx)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Recommended next step"}),(0,Xt.jsxs)("ol",{className:"mt-2 space-y-1.5 text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"1."}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)(Et,{to:"/jobs",className:"text-ndor-info hover:underline",children:"Import or choose a job"})," from the Jobs page."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"2."}),(0,Xt.jsxs)("span",{children:["Run ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Analyse Fit"})," and generate a tailored CV for the role."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"3."}),(0,Xt.jsxs)("span",{children:["Inside the application flow, generate a ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"cover letter"})," \u2014 it lands here in your library."]})]})]})]})]})}):(0,Xt.jsx)("ul",{className:"space-y-2",children:e.map(e=>(0,Xt.jsxs)("li",{className:"rounded-lg border border-ndor-edge bg-ndor-surface px-4 py-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-3","data-testid":"letter-row-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-3 sm:contents min-w-0
2w-full",children:[(0,Xt.jsx)("div",{className:"w-9 h-9 rounded-lg bg-ndor-surface-alt flex items-center justify-center shrink-0",children:(0,Xt.jsx)(Bg,{className:"h-4 w-4 text-ndor-ink-muted"})}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate","data-testid":"letter-row-title",children:e.title||"Untitled cover letter"}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted line-clamp-2 sm:line-clamp-none break-words",children:[e.target_role||"No target role"," \xb7 Generated ",GM(e.created_at)]})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 sm:shrink-0 self-end sm:self-auto",children:[(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:()=>{i(e.id),l(e.title||"Cover letter"),d("Generated ".concat(GM(e.created_at)))},"data-testid":"letter-row-preview",children:"Preview"}),(0,Xt.jsx)(VM,{letterId:e.id,title:e.title||"cover-letter"}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"icon",className:"h-8 w-8 text-ndor-ink-muted hover:text-ndor-error",onClick:()=>m(e),"data-testid":"letter-row-delete",children:(0,Xt.jsx)(pb,{className:"h-4 w-4"})})]})]},e.id))}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed pt-1",children:["To create a new cover letter, open a job from"," ",(0,Xt.jsx)(Et,{to:"/jobs",className:"underline hover:text-ndor-ink",children:"/jobs"})," and use the application flow."]}),(0,Xt.jsx)(KM,{open:!!r,onOpenChange:e=>!e&&i(null),id:r,title:o,subtitle:c}),(0,Xt.jsx)(UM,{open:!!u,onOpenChange:e=>!e&&m(null),kind:"cover_letter",doc:u,onDeleted:()=>{nw(iw()),m(null),p()}})]})}},{key:"prep",label:"Interview Prep",Component:function(){const[e,t]=(0,s.useState)(()=>{const e=ew(mw(),XM);return e.hit&&Array.isArray(e.data)?e.data:[]}),[n,a]=(0,s.useState)(()=>!ew(mw(),XM).hit),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(""),[c,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(null),p=(0,s.useCallback)(async()=>{try{const e=await tw(mw(),()=>(0,zt.n)("/api/interview-prep"),{ttlMs:XM});t(Array.isArray(e)?e:[])}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to load interview prep.")}finally{a(!1)}},[]);return(0,s.useEffect)(()=>{p()},[p]),n?(0,Xt.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})}):(0,Xt.jsxs)("div",{className:"space-y-4","data-testid":"interview-prep-history",children:[0===e.length?(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm",children:(0,Xt.jsxs)(Py,{className:"p-8 text-center space-y-3",children:[(0,Xt.jsx)("div",{className:"mx-auto w-12 h-12 rounded-full bg-ndor-surface-alt flex items-center justify-center",children:(0,Xt.jsx)(Kn,{className:"h-5 w-5 text-ndor-ink-muted"})}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:"No interview prep yet"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted leading-relaxed max-w-sm mx-auto",children:"Interview prep is generated
2when you apply to a job. Open a job and use the Interview Prep step in the application flow."}),(0,Xt.jsx)(Rr,{asChild:!0,variant:"outline",size:"sm","data-testid":"interview-prep-history-jobs-link",children:(0,Xt.jsxs)(Et,{to:"/jobs",children:[(0,Xt.jsx)(KN,{className:"h-3.5 w-3.5 mr-1.5"}),"Browse jobs"]})}),(0,Xt.jsxs)("div",{className:"mt-5 mx-auto max-w-md rounded-md border border-ndor-edge bg-ndor-surface-alt/40 p-3 text-left","data-testid":"interview-prep-empty-reviewer-hint",children:[(0,Xt.jsx)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.16em] text-ndor-ink-muted",children:"Recommended next step"}),(0,Xt.jsxs)("ol",{className:"mt-2 space-y-1.5 text-xs text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"1."}),(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)(Et,{to:"/jobs",className:"text-ndor-info hover:underline",children:"Import or choose a job"})," from the Jobs page."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"2."}),(0,Xt.jsxs)("span",{children:["Run ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Analyse Fit"})," and generate a tailored CV for the role."]})]}),(0,Xt.jsxs)("li",{className:"flex items-start gap-2",children:[(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"3."}),(0,Xt.jsxs)("span",{children:["Inside the application flow, generate ",(0,Xt.jsx)("span",{className:"font-medium text-ndor-ink",children:"Interview Prep"})," \u2014 it lands here in your library."]})]})]})]})]})}):(0,Xt.jsx)("ul",{className:"space-y-2",children:e.map(e=>(0,Xt.jsxs)("li",{className:"rounded-lg border border-ndor-edge bg-ndor-surface px-4 py-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-3","data-testid":"interview-prep-row-".concat(e.id),children:[(0,Xt.jsxs)("div",{className:"flex items-start gap-3 sm:contents min-w-0 w-full",children:[(0,Xt.jsx)("div",{className:"w-9 h-9 rounded-lg bg-ndor-surface-alt flex items-center justify-center shrink-0",children:(0,Xt.jsx)(ZN,{className:"h-4 w-4 text-ndor-ink-muted"})}),(0,Xt.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink truncate","data-testid":"interview-prep-row-title",children:e.title||"Untitled interview prep"}),(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted line-clamp-2 sm:line-clamp-none break-words",children:[e.target_role||e.source_filename||"No target role"," \xb7 Generated ",JM(e.created_at)]})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center gap-1.5 sm:shrink-0 self-end sm:self-auto",children:[(0,Xt.jsx)(Rr,{variant:"outline",size:"sm",onClick:()=>{i(e.id),l(e.title||"Interview prep"),d("Generated ".concat(JM(e.created_at)))},"data-testid":"interview-prep-row-preview",children:"Preview"}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"icon",className:"h-8 w-8 text-ndor-ink-muted hover:text-ndor-error",onClick:()=>m(e),"data-testid":"interview-prep-row-delete",children:(0,Xt.jsx)(pb,{className:"h-4 w-4"})})]})]},e.id))}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed pt-1",children:["To generate new interview prep, open a job from"," ",(0,Xt.jsx)(Et,{to:"/jobs",className:"underline hover:text-ndor-ink",children:"/jobs"})," and use the application flow."]}),(0,Xt.jsx)($M,{open:!!r,onOpenChange:e=>!e&&i(null),id:r,title:o,subtitle:c}),(0,Xt.jsx)(UM,{open:!!u,onOpenChange:e=>!e&&m(null),kind:"interview_prep",doc:u,onDeleted:()=>{nw(mw()),m(null),p()}})]})}}];function ZM(){const[e,t]=Pt(),n=e.get("tab")||"source",a="uploaded"===n?"source":n,r=(0,s.useMemo)(()=>{var e;return(null===(e=QM.find(e=>e.key===a))||void 0===e?void 0:e.Component)||bC},[a]);return(0,Xt.jsxs)("div",{className:"space-y-6","data-testid":"documents-workspace",children:[(0,Xt.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui",children:"Library"}),(0,Xt.jsx)("h1",{className:"text-3xl sm:text-4xl font-serif-display font-semibold text-ndor-ink tracking-tight",children:"Documents"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary",children:"Browse your Source CV, generated variants, cover letters, and interview prep."})]}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface",children:(0,Xt.jsxs)(Py,{className:"p-0",children:[(0,Xt.jsx)("nav",{className:"flex border-b border-ndor-edge","data-testid":"documents-tabs",role:"tablist",children:QM.map(n=>{const r=n.key===a;return(0,Xt.jsxs)(Et,{to:"/documents?tab=".concat(n.key),role:"tab","aria-selected":r,"data-testid":"documents-tab-".concat(n.key),onClick:a=>{a.preventDefault();
2const r=new URLSearchParams(e);r.set("tab",n.key),t(r)},className:"relative flex-1 text-center px-4 py-4 text-sm transition-colors\n ".concat(r?"text-ndor-ink font-semibold bg-ndor-surface-alt/50":"text-ndor-ink-secondary hover:text-ndor-ink hover:bg-ndor-surface-alt/30"),children:[(0,Xt.jsx)("span",{className:"tracking-tight",children:n.label}),r&&(0,Xt.jsx)("span",{"aria-hidden":!0,className:"absolute left-6 right-6 bottom-0 h-[2px] bg-ndor-gold rounded-full"})]},n.key)})}),(0,Xt.jsx)("div",{className:"p-4 sm:p-6","data-testid":"documents-panel-".concat(a),children:(0,Xt.jsx)(r,{})})]})})]})}const ez={base:"Base",focus:"Focus",flow:"Flow"},tz={focus:120,flow:250},nz={monthly:"Monthly",annual:"Annual"},az={active:"Active",pending:"Pending",expired:"Expired"};function rz(){const[e,t]=(0,s.useState)(null),[n,a]=(0,s.useState)(!0),{usageCosts:r}=If(),i=Sf(r),[o,l]=(0,s.useState)("idle"),[c,d]=(0,s.useState)([]),[u,m]=(0,s.useState)(!1),[p,h]=(0,s.useState)(null),[f,x]=(0,s.useState)(!1),v=(0,s.useCallback)(async()=>{x(!0);try{const e=await(0,zt.n)("/api/payments/customer-portal",{method:"POST",body:JSON.stringify({})});if(null===e||void 0===e||!e.url)throw new Error("Stripe did not return a portal URL.");window.location.assign(e.url)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Unable to open the Stripe billing portal."),x(!1)}},[]),g=(0,s.useCallback)(async()=>{a(!0);try{const e=await(0,zt.n)("/api/account/plan");t(e)}catch(e){t(null)}finally{a(!1)}},[]);(0,s.useEffect)(()=>{g()},[g]);const y=(0,s.useCallback)(async()=>{if(l("select"),0===c.length){m(!0);try{const e=await(0,zt.n)("/api/account/usage-packages");d(Array.isArray(null===e||void 0===e?void 0:e.packages)?e.packages:[])}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Unable to load credit packages."),l("idle")}finally{m(!1)}}},[c.length]),b=be(),w=ke(),j=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(j.current)return;if(n)return;const e=new URLSearchParams(b.search);if("1"!==e.get("addUsage"))return;j.current=!0,y(),e.delete("addUsage");const t=e.toString();w({pathname:b.pathname,search:t?"?".concat(t):""},{replace:!0})},[n,b.pathname,b.search,w,y]);const k=()=>
2{l("idle"),h(null)},N=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(N.current)return;if(n)return;const e=new URLSearchParams(b.search),t=e.get("session_id");if("1"===e.get("cancelled")){N.current=!0,fy.error("Top-up cancelled."),e.delete("cancelled");const t=e.toString();return void w({pathname:b.pathname,search:t?"?".concat(t):""},{replace:!0})}t&&(N.current=!0,(async()=>{let n=!1;for(let e=0;e<30;e++){try{const e=await(0,zt.n)("/api/payments/checkout/status/".concat(t));if(null!==e&&void 0!==e&&e.finalised||"finalised"===(null===e||void 0===e?void 0:e.status)){n=!0;break}}catch(r){break}await new Promise(e=>setTimeout(e,2e3))}await g(),n?fy.success("Top-up Credits added to your account."):fy.message("Stripe is still confirming your payment. Refresh in a moment."),e.delete("session_id"),e.delete("topup");const a=e.toString();w({pathname:b.pathname,search:a?"?".concat(a):""},{replace:!0})})())},[n,b.pathname,b.search,w,g]);const[_,D]=(0,s.useState)(!1),C=6e5,A=(0,s.useCallback)(async()=>{D(!0);try{await(0,zt.n)("/api/account/plan/pending/cancel",{method:"POST",body:JSON.stringify({})}),await g()}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Could not cancel the pending plan.")}finally{D(!1)}},[g]),S=(0,s.useRef)(!1);if((0,s.useEffect)(()=>{if(n)return;if(!e)return;if("pending"!==e.status)return;if(S.current)return;const t=e.pending_since;if(!t)return;const a=new Date(t).getTime();if(Number.isNaN(a))return;Date.now()-a<C||(S.current=!0,(async()=>{try{const e=await(0,zt.n)("/api/account/plan/pending/cancel",{method:"POST",body:JSON.stringify({})});null!==e&&void 0!==e&&e.cancelled&&fy.message("Cleared an abandoned plan selection \u2014 you're back on Base."),await g()}catch(e){}})())},[n,e,C,g]),n)return(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ndor-ink-muted py-6",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," Loading plan\u2026"]});if(!e)return(0,Xt.jsx)("div",{className:"text-sm text-ndor-ink-muted py-6",children:"Plan information is unavailable right now. Please try again shortly."});const E="expired"===e.status,F="pending"===e.status,R=e.lifecycle_status||"active",I="past_due"===R,T="delinquent"===R,P="usage_blocked"===R,O=I||T||P,B=F&&e.pending_since?new Date(e.pending_since).getTime():null,L=F&&null!==B&&!Number.isNaN(B)&&Date.now()-B<C,M="active"===e.status?"bg-emerald-500/15 text-emerald-200 border-emerald-500/30":"pending"===e.status?"bg-amber-500/15 text-amber-200 border-amber-500/30":"bg-rose-500/15 text-rose-200 border-rose-500/30",z=e.access_expires_at,U=z?new Date(z).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"\u2014",V=e.cycle_ends_at,q="annual"===e.billing_period&&"active"===e.status&&V&&V!==z,W=V?new Date(V).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return(0,Xt.jsxs)("div",{className:"space-y-6","data-testid":"account-plan-section",children:[O&&(0,Xt.jsxs)("div",{className:I?"flex flex-col sm:flex-row sm:items-start gap-3 rounded-md border border-amber-500/30 bg-amber-500/10 p-3 text-sm text-amber-200":"flex flex-col sm:flex-row sm:items-start gap-3 rounded-md border border-rose-500/30 bg-rose-500/10 p-3 text-sm text-rose-200","data-testid":"account-plan-lifecycle-".concat(R,"-banner"),children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 shrink-0 mt-[2px]"}),(0,Xt.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,Xt.jsxs)("p",{className:"font-medium",children:[I&&"Your last payment failed \u2014 please update your card to keep your plan active.",T&&"Your payment is overdue \u2014 service will be paused if not resolved.",P&&"New usage is blocked because your subscription is overdue. Update your card to restore access."]}),(0,Xt.jsx)("button",{type:"button",onClick:v,"data-testid":"account-plan-lifecycle-".concat(R,"-portal-btn"),className:"inline-flex items-center gap-2 rounded-md border border-current px-3 py-1.5 text-xs font-medium hover:bg-current/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400",children:"Update payment method"})]})]}),E&&(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-rose-500/30 bg-rose-500/10 p-3 text-sm text-rose-200","data-testid":"account-plan-expired-banner",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 shrink-0 mt-[2px]"}),(0,Xt.jsx)("span",{children:"Your plan has expired \u2014 renew to restore access."})]}),L&&(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-3 rounded-md border border-amber-500/30 bg-amber-500/10 p-3 text-sm text-amber-200","data-testid":"account-plan-pending-recovery-banner",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 shrink-0 mt-[2px]"}),(0,Xt.jsxs)("div",{className:"flex-1",children:[(0,Xt.jsxs)("p",{className:"font-medium",children:["Your ",ez[e.plan_code]||e.plan_code," plan is pending payment."]}),(0,Xt.jsx)("p",{className:"mt-0.5 text-amber-200/80",children:"Resume Stripe Checkout to activate it, or cancel the pending selection and stay on Base. We'll automatically clear it after 10 minutes if you don't return."})]}),(0,Xt.jsxs)("div",{className:"flex gap-2 shrink-0",children:[(0,Xt.jsxs)(Rr,{size:"sm",variant:"outline",onClick:A,disabled:_,"data-testid":"account-plan-pending-cancel-btn",className:"border-amber-500/40 text-amber-200 hover:bg-amber-500/20",children:[_&&(0,Xt.jsx)(Lg,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Cancel pending plan"]}),(0,Xt.jsx)(Rr,{size:"sm",onClick:()=>w("/onboarding/payment"),"data-testid":"account-plan-pending-resume-btn",className:"bg-amber-600 hover:bg-amber-700 text-white",children:"Resume payment"})]})]}),(0,Xt.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Your current plan"}),(0,Xt.jsxs)("div",{className:"flex items-center flex-wrap gap-3",children:[(0,Xt.jsx)("h2",{className:"text-3xl font-serif-display font-semibold text-ndor-ink tracking-tight","data-testid":"account-plan-name",children:ez[e.plan_code]||e.plan_code||"Base"}),(0,Xt.jsx)(Vw,{variant:"outline",className:"uppercase tracking-[0.12em] ".concat(M),"data-testid":"account-plan-status",children:az[e.status]||e.status}),e.billing_period&&(0,Xt.jsx)(Vw,{variant:"outline",className:"text-ndor-ink-muted border-ndor-edge","data-testid":"account-plan-billing-period",children:nz[e.billing_period]})]}),e.access_expires_at&&(0,Xt.jsxs)("p",{className:"text-xs text-ndor-ink-muted","data-testid":"account-plan-expires",children:[E?"Expired on "
2:"Renews ",U]}),e.plan_code&&"base"!==e.plan_code&&"expired"!==e.status&&(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-ndor-gold font-mono-ui mt-1","data-testid":"account-plan-founding-member",children:"Founding Member Pricing \u2014 locked in for life"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-snug mt-0.5","data-testid":"account-plan-founding-member-context",children:"Your Founding Member rate is locked in below future pricing."}),tz[e.plan_code]&&i?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-snug mt-1","data-testid":"account-plan-app-count",children:"Supports multiple fully tailored applications per month."}):null]})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30 p-4",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Included Credits"}),(0,Xt.jsx)("p",{className:"text-2xl font-serif-display font-semibold text-ndor-ink tabular-nums","data-testid":"account-plan-included-remaining",children:(e.included_usage_remaining||0).toLocaleString()}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Credits remaining this cycle"}),q&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted mt-2","data-testid":"account-plan-cycle-ends",children:["Cycle resets ",W]})]}),(0,Xt.jsxs)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/30 p-4",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Top-up Credits"}),(0,Xt.jsx)("p",{className:"text-2xl font-serif-display font-semibold text-ndor-ink tabular-nums","data-testid":"account-plan-extra-remaining",children:(e.extra_usage_remaining||0).toLocaleString()}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:0===(e.extra_usage_remaining||0)?"No top-up Credits on this account":"top-up Credits remaining"}),(0,Xt.jsxs)(Rr,{variant:"outline",size:"sm",onClick:y,"data-testid":"account-plan-add-usage",className:"mt-3 border-ndor-edge text-ndor-ink hover:bg-ndor-surface",children:[(0,Xt.jsx)(Ow,{className:"h-3.5 w-3.5 mr-1.5"}),(0,Xt.jsx)("span",{"data-testid":"plan-add-credits-button",children:"Add Credits"})]})]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[(0,Xt.jsx)(Et,{to:"/onboarding/plan",state:{from:"/account?tab=plan"},children:(0,Xt.jsx)(Rr,{variant:"outline",className:"w-full sm:w-auto","data-testid":"account-plan-change",children:"Change plan"})}),E&&(0,Xt.jsx)(Et,{to:"/onboarding/plan",state:{from:"/account?tab=plan"},children:(0,Xt.jsxs)(Rr,{className:"w-full sm:w-auto bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground","data-testid":"account-plan-renew",children:[(0,Xt.jsx)(Og,{className:"h-4 w-4 mr-1.5"}),"Renew plan"]})}),(0,Xt.jsxs)(Rr,{variant:"outline",className:"w-full sm:w-auto border-ndor-edge text-ndor-ink hover:bg-ndor-surface",onClick:v,disabled:f,"data-testid":"customer-portal-button",children:[f?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)(KN,{className:"h-4 w-4 mr-1.5"}),"Manage billing & invoices"]}),(0,Xt.jsx)(Et,{to:"/credits",className:"w-full sm:w-auto",children:(0,Xt.jsxs)(Rr,{variant:"ghost",className:"w-full sm:w-auto text-ndor-ink-muted hover:text-ndor-ink","data-testid":"billing-history-button",children:[(0,Xt.jsx)(hS,{className:"h-4 w-4 mr-1.5"}),"View billing history"]})})]}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted","data-testid":"account-plan-trust-copy",children:"Secure payments by Stripe \xb7 Cancel anytime \xb7 Transparent billing \xb7 Card details never touch NDORFlow"}),"select"===o&&(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-edge bg-ndor-surface-alt/30 p-5 space-y-4","data-testid":"usage-package-selector",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Add extra Credits"}),(0,Xt.jsx)("h3",{className:"text-lg font-serif-display font-semibold text-ndor-ink",children:"Choose a to
2p-up"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary mt-1",children:"Top up extra Credits to use anywhere \u2014 base, Focus, or Flow."})]}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:k,"data-testid":"usage-package-selector-close",className:"text-ndor-ink-muted hover:text-ndor-ink",children:(0,Xt.jsx)(xh,{className:"h-4 w-4"})})]}),u?(0,Xt.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"})," Loading packages\u2026"]}):(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:c.map(e=>(0,Xt.jsxs)("button",{type:"button",onClick:()=>(async e=>{h(e),l("confirm")})(e),"data-testid":"usage-package-".concat(e.code),className:"text-left rounded-lg border border-ndor-edge bg-ndor-surface p-4 hover:border-ndor-gold/50 transition-colors",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:e.label}),(0,Xt.jsx)("p",{className:"mt-1 text-2xl font-serif-display font-semibold text-ndor-ink tabular-nums",children:e.display_price}),(0,Xt.jsxs)("p",{className:"mt-1 text-xs text-ndor-ink-secondary",children:[e.usage_amount," top-up Credits \xb7 No expiry"]})]},e.code))})]}),("confirm"===o||"activating"===o)&&p&&(0,Xt.jsxs)("div",{className:"rounded-xl border border-ndor-edge bg-ndor-surface-alt/30 p-5 space-y-4","data-testid":"usage-package-confirm",children:[(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Review & confirm"}),(0,Xt.jsxs)("h3",{className:"text-lg font-serif-display font-semibold text-ndor-ink","data-testid":"usage-package-confirm-title",children:[p.label," \xb7 ",p.display_price]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary mt-1","data-testid":"usage-package-stub-notice",children:lM()?"You'll complete payment securely on Stripe (TEST MODE). When your top-up is confirmed, ".concat(p.usage_amount," extra Credits are added to your account."):"You'll complete payment securely on Stripe. When your top-up is confirmed, ".concat(p.usage_amount," extra Credits are added to your account.")})]}),(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:k,disabled:"activating"===o,"data-testid":"usage-package-confirm-close",className:"text-ndor-ink-muted hover:text-ndor-ink",children:(0,Xt.jsx)(xh,{className:"h-4 w-4"})})]}),(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 sm:justify-end",children:[(0,Xt.jsxs)(Rr,{variant:"outline",onClick:()=>l("select"),disabled:"activating"===o,"data-testid":"usage-package-confirm-back",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"}),"Back to packages"]}),(0,Xt.jsx)(Rr,{onClick:async()=>{if(p){l("activating");try{const e=await(0,zt.n)("/api/payments/checkout/topup",{method:"POST",body:JSON.stringify({package_code:p.code})});if(null===e||void 0===e||!e.checkout_url)throw new Error("Stripe did not return a checkout URL.");window.location.assign(e.checkout_url)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Unable to start Stripe Checkout."),l("confirm")}}},disabled:"activating"===o,"data-testid":"usage-package-confirm-activate",className:"bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground",children:"activating"===o?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"})," Redirecting to Stripe\u2026"]}):(0,Xt.jsx)(Xt.Fragment,{children:"Pay with Stripe"})})]})]}),(0,Xt.jsx)("div",{className:"mt-8",children:(0,Xt.jsx)(NT,{variant:"block",testId:"account-plan-disclaimer"})})]})}const sz=[{value:"strict",label:"Strict \u2014 only show matching locations"},{value:"balanced",label:"Balanced \u2014 flex with relocation openness"},{value:"open",label:"Open \u2014 barely penalise non-matches"}],iz=[{value:"yes",label:"Yes \u2014 I would relocate"},{value:"conditional",label:"Conditional \u2014 depends on role/package"},{value:"no",label:"No \u2014 location is fixed"}];function oz(e){let{value:t,onChange:n,placeholder:a,testId:r,cap:i}=e;
2const[o,l]=(0,s.useState)(""),c=i>0&&(t||[]).length>=i,d=()=>{if(c)return;const e=o.trim();e&&(t.some(t=>t.toLowerCase()===e.toLowerCase())||n([...t,e]),l(""))};return(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsxs)("div",{className:"flex flex-wrap gap-1.5","data-testid":"".concat(r,"-chips"),children:[t.map((e,a)=>(0,Xt.jsxs)(Vw,{variant:"outline",className:"bg-ndor-surface border-ndor-edge text-xs gap-1 pl-2.5",children:[e,(0,Xt.jsx)("button",{type:"button",onClick:()=>n(t.filter((e,t)=>t!==a)),className:"text-ndor-ink-muted hover:text-ndor-error ml-0.5","aria-label":"Remove ".concat(e),"data-testid":"".concat(r,"-chip-remove-").concat(a),children:(0,Xt.jsx)(xh,{className:"h-3 w-3"})})]},"".concat(e,"-").concat(a))),0===t.length&&(0,Xt.jsx)("span",{className:"text-xs text-ndor-ink-muted italic",children:"None set"})]}),(0,Xt.jsxs)("div",{className:"flex gap-2",children:[(0,Xt.jsx)(Ag,{value:o,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"!==e.key&&","!==e.key||(e.preventDefault(),d())},placeholder:a,className:"h-9 text-sm",disabled:c,"data-testid":"".concat(r,"-input")}),(0,Xt.jsx)(Rr,{type:"button",variant:"outline",size:"sm",onClick:d,disabled:!o.trim()||c,"data-testid":"".concat(r,"-add"),children:"Add"})]}),i>0&&(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted",children:[(t||[]).length," / ",i,c?" \u2014 limit reached":""]})]})}function lz(e){let{value:t,onChange:n,options:a,testId:r}=e;const s=new Set(t||[]);return(0,Xt.jsx)("div",{className:"flex flex-wrap gap-1.5","data-testid":"".concat(r,"-group"),children:a.map(e=>{const t=s.has(e.value);return(0,Xt.jsx)("button",{type:"button",onClick:()=>(e=>{const t=new Set(s);t.has(e)?t.delete(e):t.add(e),n([...t])})(e.value),className:["text-xs px-2.5 py-1 rounded-full border transition-colors",t?"bg-ndor-ink text-ndor-surface border-ndor-ink":"bg-ndor-surface text-ndor-ink border-ndor-edge hover:bg-ndor-surface-alt"].join(" "),"data-testid":"".concat(r,"-").concat(e.value),"aria-pressed":t,children:e.label},e.value)})})}function cz(e){let{icon:t,title:n,hint:a}=e;return(0,Xt.jsxs)("div",{className:"flex items-start gap-2 pt-1",children:[(0,Xt.jsx)(t,{className:"h-4 w-4 text-ndor-ink-muted mt-0.5 shrink-0"}),(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h3",{className:"text-sm font-medium text-ndor-ink leading-tight",children:n}),a&&(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted mt-0.5",children:a})]})]})}function dz(){var e,t;const[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(!0),[d,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)(!1),h=(0,s.useCallback)(async()=>{l(!0);try{const e=await(0,zt.n)("/api/profile/preferences"),t=(0,c.A)((0,c.A)({},xw),e.preferences||{});a(t),i((0,c.A)({},t)),p(Boolean(e.unmigrated))}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to load preferences.")}finally{l(!1)}},[]);(0,s.useEffect)(()=>{h()},[h]);const f=(0,s.useMemo)(()=>n&&r?function(e,t){const n={};if(!e||!t)return n;for(const a of Object.keys(xw)){const r=e[a],s=t[a];vw.includes(a)?kw(null!==r&&void 0!==r?r:[],null!==s&&void 0!==s?s:[])||(n[a]=null!==s&&void 0!==s?s:[]):r!==s&&(n[a]=s)}return n}(n,r):{},[n,r]),x=Object.keys(f).length>0,v=(e,t)=>i(n=>(0,c.A)((0,c.A)({},n),{},{[e]:t}));return o||!r?(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"preferences-card",children:[(0,Xt.jsx)(Ry,{className:"pb-3",children:(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base font-medium text-ndor-ink",children:[(0,Xt.jsx)(qw,{className:"h-5 w-5 text-ndor-ink-muted"}),"Preferences"]})}),(0,Xt.jsx)(Py,{className:"py-8 flex items-center justify-center",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})})]}):(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"preferences-card",id:"preferences-section",children:[(0,Xt.jsxs)(Ry,{className:"pb-3",children:[(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base font-medium text-ndor-ink",children:[(0,Xt.jsx)(qw,{className:"h-5 w-5 text-ndor-ink-muted"}),"Preferences"]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted pt-1",children:"These guide scoring and document generation \u2014 they never hide jobs. The Jobs page and NDOR Analyse Fit read the same preferences."})]}),(0,Xt.jsxs)(Py,{className:"space-y-6",children:[m&&(0,Xt.jsxs)("div",{className:"flex items-start gap-2 p-2.5 rounded border border-amber-500/40 bg-amber-500/10 text-amber-200 text-xs","data-testid":"preferences-unmigrated-warning",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4 shrink-0 mt-0.5"}),(0,Xt.jsxs)("span",{children:["Preferences storage column is missing. Changes won't persist until an admin applies migration"," ",(0,Xt.jsx)("code",{className:"font-mono",children:"023_profile_preferences_json.sql"}),"."]})]}),(0,Xt.jsx)(cz,{icon:kn,title:"Roles & industries",hint:"Helps NDOR weigh strategic alignment when scoring jobs."}),(0,Xt.jsxs)("div",{className:"space-y-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Preferred titles"}),(0,Xt.jsx)(oz,{value:r.preferred_titles||[],onChange:e=>v("preferred_titles",e),placeholder:"e.g. Director of Engineering",testId:"preferences-card-preferred-titles",cap:10})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Industries"}
2),(0,Xt.jsx)(oz,{value:r.industries||[],onChange:e=>v("industries",e),placeholder:"e.g. Energy, Fintech, Healthtech",testId:"preferences-card-industries",cap:10}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted italic",children:"Free text for now \u2014 a curated industry taxonomy is on the roadmap."})]})]}),(0,Xt.jsx)(cz,{icon:yT,title:"Employment & seniority",hint:"Tap chips to toggle. Multiple selections allowed."}),(0,Xt.jsxs)("div",{className:"space-y-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Employment types"}),(0,Xt.jsx)(lz,{value:r.employment_types||[],onChange:e=>v("employment_types",e),options:gw,testId:"preferences-card-employment-types"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Seniority targets"}),(0,Xt.jsx)(lz,{value:r.seniority_targets||[],onChange:e=>v("seniority_targets",e),options:yw,testId:"preferences-card-seniority-targets"})]})]}),(0,Xt.jsx)(cz,{icon:oI,title:"Location & remote",hint:"Used for the Jobs filter and the location sub-score."}),(0,Xt.jsxs)("div",{className:"space-y-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Preferred regions"}),(0,Xt.jsx)(oz,{value:r.preferred_regions||[],onChange:e=>v("preferred_regions",e),placeholder:"e.g. London, Kuala Lumpur",testId:"preferences-card-preferred-regions",cap:10})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Remote preference"}),(0,Xt.jsxs)(Vv,{value:r.remote_preferences,onValueChange:e=>v("remote_preferences",e),children:[(0,Xt.jsx)(Wv,{className:"h-10","data-testid":"preferences-card-remote-pref",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:bw.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Location strictness"}),(0,Xt.jsxs)(Vv,{value:r.location_strictness,onValueChange:e=>v("location_strictness",e),children:[(0,Xt.jsx)(Wv,{className:"h-10","data-testid":"preferences-card-strictness",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:sz.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Open to relocation"}),(0,Xt.jsxs)(Vv,{value:r.open_to_relocation,onValueChange:e=>v("open_to_relocation",e),children:[(0,Xt.jsx)(Wv,{className:"h-10","data-testid":"preferences-card-relocation",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:iz.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]})]}),"no"!==r.open_to_relocation&&(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Relocation regions (optional)"}),(0,Xt.jsx)(oz,{value:r.relocation_regions||[],onChange:e=>v("relocation_regions",e),placeholder:"e.g. Dublin, Singapore",testId:"preferences-card-relocation-regions",cap:10})]})]}),(0,Xt.jsx)(cz,{icon:QN,title:"Salary expectations",hint:"Used by NDOR to score the salary fit. Leave blank to skip."}),(0,Xt.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Minimum"}),(0,Xt.jsx)(Ag,{type:"number",min:0,inputMode:"numeric",value:null!==(e=r.salary_floor)&&void 0!==e?e:"",onChange:e=>{const t=e.target.value;v("salary_floor",""===t?null:Number(t))},placeholder:"80000","data-testid":"preferences-card-salary-floor"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Maximum"}),(0,Xt.jsx)(Ag,{type:"number",min:0,inputMode:"numeric",value:null!==(t=r.salary_ceiling)&&void 0!==t?t:"",onChange:e=>{const t=e.target.value;v("salary_ceiling",""===t?null:Number(t))},placeholder:"140000","data-testid":"preferences-card-salary-ceiling"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Currency"}),(0,Xt.jsxs)(Vv,{value:r.salary_currency,onValueChange:e=>v("salary_currency",e),children:[(0,Xt.jsx)(Wv,{className:"h-10","data-testid":"preferences-card-salary-currency",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:ww.map(e=>(0,Xt.jsx)(Yv,{value:e,children:e},e))})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Period"}),(0,Xt.jsxs)(Vv,{value:r.salary_period,onValueChange:e=>v("salary_period",e),children:[(0,Xt.jsx)(Wv,{className:"h-10","data-testid":"preferences-card-salary-period",children:(0,Xt.jsx)(qv,{})}),(0,Xt.jsx)(Kv,{children:jw.map(e=>(0,Xt.jsx)(Yv,{value:e.value,children:e.label},e.value))})]})]})]}),(0,Xt.jsx)(cz,{icon:xh,title:"Excluded keywords",hint:"NDOR flags roles whose description matches these as a risk in key_risks."}),(0,Xt.jsx)(oz,{value:r.excluded_keywords||[],onChange:e=>v("excluded_keywords",e),placeholder:"e.g. recruiter spam, blockchain",testId:"preferences-card-excluded-keywords",cap:20}),(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-4 p-3 rounded-md border border-ndor-edge bg-ndor-surface-alt",children:[(0,Xt.jsxs)("div",{className:"space-y-0.5 pr-2",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Include cover letter when generating a pack"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Mirrors the Workflow page toggle. Same preference, same source of truth."})]}),(0,Xt.jsx)(vk,{checked:Boolean(r.include_cover_letter),onCheckedChange:e=>v("include_cover_letter",Boolean(e)),"data-testid":"preferences-card-include-cover-toggle"})]}),(0,Xt.jsxs)("div",{className:"flex items-start justify-between gap-4 p-3 rounded-md border border-ndor-edge bg-ndor-surface-alt","data-testid":"preferences-card-discoverability-row",children:[(0,Xt.jsxs)("div",{className:"space-y-0.5 pr-2",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Discoverable by employers"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"Employers can discover your profile for relevant opportunities. This is off unless you turn it on."})]}),(0,Xt.jsx)(vk,{checked:Boolean(r.discoverable_to_employers),onCheckedChange:e=>v("discoverable_to_employers",Boolean(e)),"data-testid":"preferences-card-discoverability-toggle"})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1 border-t border-ndor-edge",children:[(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>{n&&i((0,c.A)({},n))},disabled:!x||d,"data-testid":"preferences-card-revert",children:"Revert"}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:async()=>
2{if(!x||d)return;const e=(0,c.A)({},f);if("salary_floor"in e&&(e.salary_floor=_w(e.salary_floor)),"salary_ceiling"in e&&(e.salary_ceiling=_w(e.salary_ceiling)),"number"===typeof e.salary_floor&&"number"===typeof e.salary_ceiling&&e.salary_floor>e.salary_ceiling)fy.error("Salary minimum cannot exceed maximum.");else{u(!0);try{const t=await(0,zt.n)("/api/profile/preferences",{method:"POST",body:e}),n=(0,c.A)((0,c.A)({},xw),t.preferences||{});a(n),i((0,c.A)({},n)),p(Boolean(t.unmigrated)),fy.success(t.unmigrated?"Saved in session \u2014 apply migration 023 to persist.":"Preferences saved."),Ht("preferences_updated",{unmigrated:!!t.unmigrated}),window.dispatchEvent(new Event("ndor:profile-refresh")),window.dispatchEvent(new Event("ndor:preferences-changed"))}catch(pK){var t;fy.error((null===pK||void 0===pK||null===(t=pK.data)||void 0===t?void 0:t.detail)||(null===pK||void 0===pK?void 0:pK.message)||"Failed to save preferences.")}finally{u(!1)}}},disabled:!x||d,"data-testid":"preferences-card-save",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:[d?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)($N,{className:"h-4 w-4 mr-1.5"}),d?"Saving\u2026":"Save preferences"]})]})]})]})}const uz=[{key:"plan",label:"Plan",Component:rz},{key:"preferences",label:"Preferences",Component:function(){return(0,Xt.jsx)("div",{className:"space-y-6","data-testid":"account-panel-preferences-content",children:(0,Xt.jsx)(dz,{})})}},{key:"settings",label:"Settings",Component:function(){const[e,t]=(0,s.useState)(null),[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(null),[o,l]=(0,s.useState)(!0),[d,u]=(0,s.useState)(!1),m=(0,s.useCallback)(async()=>{l(!0);try{const e=await(0,zt.n)("/api/profile/me"),n=e.profile||{};n.skills_json=Array.isArray(n.skills_json)?n.skills_json:[],t(n),a((0,c.A)({},n)),i(e.primary_cv||null)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to load profile.")}finally{l(!1)}},[]);(0,s.useEffect)(()=>{m()},[m]);const p=e=>t=>{const n=null!==t&&void 0!==t&&t.target?t.target.value:t;a(t=>(0,c.A)((0,c.A)({},t),{},{[e]:n}))},h=(0,s.useMemo)(()=>e&&n?function(e,t){const n={};for(const s of DM){var a,r;if("skills_json"===s){const a=Array.isArray(null===e||void 0===e?void 0:e.skills_json)?e.skills_json:[],r=Array.isArray(null===t||void 0===t?void 0:t.skills_json)?t.skills_json:[];AM(a,r)||(n.skills_json=r);continue}const i=CM(null!==(a=null===e||void 0===e?void 0:e[s])&&void 0!==a?a:""),o=CM(null!==(r=null===t||void 0===t?void 0:t[s])&&void 0!==r?r:"");i!==o&&(n[s]="years_experience"===s?""===o.trim()?null:Number(o):""===o.trim()?null:o.trim())}return n}(e,n):{},[e,n]),f=Object.keys(h).length>0;return o||!n?(0,Xt.jsxs)("div",{"data-testid":"settings-page",className:"space-y-6",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h2",{className:"text-2xl font-semibold tracking-tight text-ndor-ink font-outfit",children:"Settings"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-1 font-manrope",children:"Loading your profile\u2026"})]}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge shadow-sm",children:(0,Xt.jsx)(Py,{className:"p-10 flex items-center justify-center",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin text-ndor-ink-muted"})})})]}):(0,Xt.jsxs)("div",{"data-testid":"settings-page",className:"space-y-6",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("h2",{className:"text-2xl font-semibold tracking-tight text-ndor-ink font-outfit",children:"Settings"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary mt-1 font-manrope",children:"Update the profile that NDOR uses to match and score roles for you."})]}),(0,Xt.jsx)(jM,{}),(0,Xt.jsxs)(Fy,{className:"border-ndor-edge shadow-sm","data-testid":"profile-editor-card",id:"profile-section",children:[(0,Xt.jsx)(Ry,{className:"pb-3",children:(0,Xt.jsxs)(Iy,{className:"flex items-center gap-2 text-base font-medium text-ndor-ink",children:[(0,Xt.jsx)(En,{className:"h-5 w-5 text-ndor-ink-muted"}),"Profile"]})}),(0,Xt.jsxs)(Py,{className:"space-y-5",children:[(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Full name"}),(0,Xt.jsx)(Ag,{value:CM(n.full_name),onChange:p("full_name"),placeholder:"Jane Doe",className:"h-10","data-testid":"profile-field-full_name"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Headline"}),(0,Xt.jsx)(Ag,{value:CM(n.headline),onChange:p("headline"),placeholder:"Senior Product Designer",className:"h-10","data-testid":"profile-field-headline"})]})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Current job title"}),(0,Xt.jsx)(Ag,{value:CM(n.current_job_title),onChange:p("current_job_title"),placeholder:"Product Designer",className:"h-10","data-testid":"profile-field-current_job_title"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Current company"}),(0,Xt.jsx)(Ag,{value:CM(n.current_company),onChange:p("current_company"),placeholder:"Acme Inc.",className:"h-10","data-testid":"profile-field-current_company"})]})]}),(0,Xt.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Years of experience"}),(0,Xt.jsx)(Ag,{type:"number",min:0,max:80,value:CM(n.years_experience),onChange:p("years_experience"),placeholder:"5",className:"h-10","data-testid":"profile-field-years_experience"})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Location"}),(0,Xt.jsx)(Ag,{value:CM(n.location),onChange:p("location"),placeholder:"London, UK",className:"h-10","data-testid":"profile-field-location"})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Visa / work authorisation"}),(0,Xt.jsxs)(Vv,{value:CM(n.visa_status),onValueChange:e=>a(t=>(0,c.A)((0,c.A)({},t),{},{visa_status:e})),children:[(0,Xt.jsx)(Wv,{className:"h-10","data-testid":"profile-field-visa_status",children:(0,Xt.jsx)(qv,{placeholder:"Select status"})}),(0,Xt.jsx)(Kv,{children:_M.map(e=>(0,Xt.jsx)(Yv,{value:e,children:e},e))})]})]}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)(Pg,{className:"text-ndor-ink",children:"Experience summary"}),(0,Xt.jsx)(Hw,{value:CM(n.summary),onChange:p("summary"),placeholder:"A brief overview of your experience and goals\u2026",rows:4,"data-testid":"profile-field-summary"}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-muted",children:"NDOR uses this to frame fit analysis. Keep it concise and specific \u2014 what you do, for whom, and what outcomes you drive."})]}),(0,Xt.jsx)(EM,{value:CM(n.primary_domain),onChange:e=>a(t=>(0,c.A)((0,c.A)({},t),{},{primary_domain:e}))}),(0,Xt.jsx)(SM,{value:Array.isArray(n.skills_json)?n.skills_json:[],onChange:e=>a(t=>(0,c.A)((0,c.A)({},t),{},{skills_json:e}))}),(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsxs)(Pg,{className:"text-ndor-ink flex items-center gap-1.5",children:[(0,Xt.jsx)(Nn,{className:"h-4 w-4 text-ndor-ink-muted"}),"Primary Source CV"]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-ndor-edge bg-ndor-surface-alt px-3 py-2","data-testid":"profile-primary-cv",children:[(0,Xt.jsx)("span",{className:"text-sm text-ndor-ink truncate",children:(null===r||void 0===r?void 0:r.original_filename)||(0,Xt.jsx)("span",{className:"text-ndor-ink-muted",children:"No primary Source CV set yet."})}),(0,Xt.jsx)("a",{href:"/documents",className:"text-xs text-ndor-gold hover:underline shrink-0 ml-2","data-testid":"profile-primary-cv-manage-link",children:"Manage in Documents \u2192"})]})]}),(0,Xt.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-ndor-edge",children:[(0,Xt.jsx)(Rr,{variant:"ghost",size:"sm",onClick:()=>{e&&a((0,c.A)({},e))},disabled:!f||d,"data-testid":"profile-revert-button",children:"Revert"}),(0,Xt.jsxs)(Rr,{size:"sm",onClick:async()=>
2{if(f&&!d){u(!0);try{const e=await(0,zt.n)("/api/profile/me",{method:"POST",body:h});t(e.profile),a((0,c.A)({},e.profile)),fy.success("Profile saved."),window.dispatchEvent(new Event("ndor:profile-refresh"))}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Failed to save profile.")}finally{u(!1)}}},disabled:!f||d,"data-testid":"profile-save-button",className:"bg-ndor-ink text-ndor-surface hover:bg-ndor-ink-muted",children:[d?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):(0,Xt.jsx)($N,{className:"h-4 w-4 mr-1.5"}),d?"Saving\u2026":"Save changes"]})]})]})]}),(0,Xt.jsx)(NM,{})]})}},{key:"privacy",label:"Privacy",Component:function(){return(0,Xt.jsx)(IM,{embedded:!0})}}];function mz(){const[e,t]=Pt(),n=e.get("tab")||"plan",a=(0,s.useMemo)(()=>{var e;return(null===(e=uz.find(e=>e.key===n))||void 0===e?void 0:e.Component)||rz},[n]);return(0,Xt.jsxs)("div",{className:"space-y-6","data-testid":"account-workspace",children:[(0,Xt.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui",children:"Workspace"}),(0,Xt.jsx)("h1",{className:"text-3xl sm:text-4xl font-serif-display font-semibold text-ndor-ink tracking-tight",children:"Account"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary",children:"Plan, profile preferences, and privacy controls."})]}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface",children:(0,Xt.jsxs)(Py,{className:"p-0",children:[(0,Xt.jsx)("nav",{className:"flex border-b border-ndor-edge","data-testid":"account-tabs",role:"tablist",children:uz.map(e=>{const a=e.key===n;return(0,Xt.jsxs)(Et,{to:"/account?tab=".concat(e.key),role:"tab","aria-selected":a,"data-testid":"account-tab-".concat(e.key),onClick:n=>{n.preventDefault(),t({tab:e.key})},className:"relative flex-1 text-center px-4 py-4 text-sm transition-colors\n ".concat(a?"text-ndor-ink font-semibold bg-ndor-surface-alt/50":"text-ndor-ink-muted hover:text-ndor-ink hover:bg-ndor-surface-alt/30"),children:[(0,Xt.jsx)("span",{className:"tracking-tight",children:e.label}),a&&(0,Xt.jsx)("span",{"aria-hidden":!0,className:"absolute left-6 right-6 bottom-0 h-[2px] bg-ndor-gold rounded-full"})]},e.key)})}),(0,Xt.jsx)("div",{className:"p-4 sm:p-6","data-testid":"account-panel-".concat(n),children:(0,Xt.jsx)(a,{})})]})})]})}const pz=wn("list-filter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]),hz=wn("mouse-pointer-click",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]),fz=wn("list-checks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]),xz=[{icon:oI,label:"Add a job by URL",copy:"Paste any public job URL on /jobs (eFinancialCareers, Greenhouse, company careers pages, etc.). NDORFlow fetches the page, parses the title, company, location and description into structured fields, and dedupes against URLs you have already saved."},{icon:hb,label:"Add a job manually",copy:"Some sites block automated fetching (LinkedIn, Indeed). Paste the job text directly and NDORFlow still structures it for you. The flow falls back to this mode automatically when an import times out or returns insufficient text."},{icon:pz,label:"Browse the jobs list",copy:"Open /jobs to see every job in your workspace. Filter by title, company, location, employment type, seniority, or fit-score band. Click any row to open the Job Detail page."}],vz=[{code:"manual",icon:zg,title:"1. Manual Review",bullets:["You control everything \u2014 NDORFlow does nothing in the background.","You run Analyse Fit yourself from the Job Detail page.","Credits apply for each manual Analyse Fit.","Available on every plan (Base, Focus, Flow)."]},{code:"assisted",icon:Ln,title:"2. Assisted Review",bullets:["NDORFlow suggests jobs in a Review Queue based on your Source CV.","You decide what to act on \u2014 every application is still your call.","Backgroun
2d Flow automation is OFF in this mode.","Available on Focus and Flow."]},{code:"flow",icon:Cn,title:"3. Automation (Flow)",bullets:["Runs automatically in the background.","Pre-screens jobs first using cheap deterministic signals.","Fully analyses the strongest matches (full A+B+C scoring).","Does NOT use your Credits \u2014 covered by your Flow subscription.","Can be paused at any time from the Workflow page.","Available on Flow only."]}],gz=[{icon:hz,title:"Apply to job",body:"When a job catches your eye, click [Apply to this job] on the Job Detail page. This is the only way to launch the four-step application wizard. The wizard never opens on its own."},{icon:Nn,title:"Choose CV",body:"Pick the CV NDORFlow will pin into your application pack. Use your Source CV (no charge \u2014 your existing fit score carries through), or generate a Tailored Variant (charges Credits) that maps your strongest evidence onto this specific role. Variants never invent experience."},{icon:Bg,title:"Cover letter",body:"Generate a cover letter for the job in one click, edit it inline if you want, or skip the letter entirely. The latest draft is locked into the pack on the next step."},{icon:XN,title:"Analyse Fit",body:'If you kept your Source CV, the wizard reuses your existing baseline fit \u2014 no re-run, no Credits. If you generated a Tailored Variant, click [Analyse Fit] to score the variant and see the "+X vs Source CV" delta. Re-running is optional.'},{icon:fz,title:"Review",body:"Confirm the CV, cover letter, and fit result that will be locked into the pack. The pack name auto-fills from the job; add private notes if you like."},{icon:Rw,title:"Create pack",body:"Click [Create Application Pack] and NDORFlow assembles a self-contained, immutable record of this application \u2014 tailored CV, cover letter, fit score with reasoning, interview prep prompts."},{icon:zy,title:"Export",body:"Download the bundle in one click \u2014 [Download PDF] or [Download DOCX] are at the top of the pack page. NDORFlow never auto-applies; you submit every application yourself."}],yz=[{icon:Cn,label:"Automation is plan-driven",copy:"Automation (Flow) runs only on the Flow plan. It is fully managed by NDORFlow \u2014 you do not need to click anything to start it. The Workflow page becomes a review surface; you only intervene when you want to act on a match."},{icon:zg,label:"Manual overrides automation",copy:"Picking Manual Review on the Workflow page pauses Flow automation for your account. Background scoring stops immediately \u2014 your plan is unchanged, but nothing runs until you switch back to Assisted Review or Automation (Flow)."},{icon:Ln,label:"Assisted is the intermediate mode",copy:"Assisted Review batches Analyse Fit against your Source CV in the background, capped to a daily budget. Matches above your fit threshold appear in your Review Queue. Background Flow automation is OFF in this mode \u2014 Assisted is on its own clock, you trigger each batch by visiting the Workflow page."},{icon:ty,label:"No Credits used for background analysis",copy:"Both Assisted Review and Automation (Flow) are operator-absorbed \u2014 your Credit balance is NEVER charged for background scoring. You only spend Credits when you click [Analyse Fit] yourself on a Job Detail page, or when you generate a Tailored CV variant or cover letter inside the application wizard."}],bz=[{code:"base",icon:Bn,name:"Base",accent:"border-ndor-edge",headline:"For candidates who find roles themselves.",bullets:["2 free Analyse Fit per day","Manual Review only","CV upload, structured parse, full application pack composer"]},{code:"focus",icon:Kn,name:"Focus",accent:"border-ndor-primary/40",headline:"For candidates who want help surfacing matches.",bullets:["Higher monthly Credits allowance","Manual Review + Assisted Review","Assisted Review uses your preferences + Source CV + a deterministic pre-screen first; only prescreen-surviving jobs are analysed with NDOR","Background scoring is operator-absorbed \u2014 not charged to your Credits","Capped at a small daily batch so you stay in control","Matches above your fit threshold appear in your Review Queue"]},{code:"flow",icon:Cn,name:"Flow",accent:"border-ndor-gold/40",headline:"For candidates running a serious search at scale.",bullets:["Everything in Focus","Manual Review + Assisted Review + Automation (Flow)","Flow is paused by default until you turn it on","Continuous background work uses the shared job pool + your preferences + Source CV + deterministic pre-screen \u2014 only survivors reach NDOR","Backgroun
2d Flow scoring is operator-absorbed \u2014 not charged to your Credits","Strongest matches surface in your Top Opportunities feed throughout the day","NDORFlow never auto-applies and never auto-tailors"]}];function wz(e){let{letter:t,title:n,blurb:a}=e;return(0,Xt.jsxs)("div",{className:"space-y-1.5","data-testid":"how-it-works-section-".concat(t.toLowerCase()),children:[(0,Xt.jsxs)("p",{className:"text-[10px] font-mono-ui uppercase tracking-[0.22em] text-ndor-gold",children:[t,"."]}),(0,Xt.jsx)("h2",{className:"text-xl sm:text-2xl font-serif-display font-semibold text-ndor-ink",children:n}),a&&(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary max-w-2xl leading-relaxed",children:a})]})}function jz(){const e=ke();return(0,Xt.jsxs)("div",{className:"max-w-4xl w-full mx-auto px-4 sm:px-6 py-8 sm:py-10 space-y-12 sm:space-y-14","data-testid":"how-it-works-page",children:[(0,Xt.jsxs)("header",{className:"space-y-3",children:[(0,Xt.jsx)(Vw,{className:"bg-ndor-gold/10 text-ndor-gold border-0 uppercase tracking-[0.18em] text-[10px]",children:"Walkthrough"}),(0,Xt.jsx)("h1",{className:"text-3xl sm:text-4xl lg:text-5xl font-serif-display font-semibold tracking-tight text-ndor-ink","data-testid":"how-it-works-title",children:"How NDORFlow works"}),(0,Xt.jsx)("p",{className:"text-base text-ndor-ink-secondary max-w-2xl leading-relaxed",children:"Four short sections from a job URL to an exported application pack. Pick the level of automation that matches your search style; NDORFlow never auto-applies on any plan, and your Credits are never used for background analysis."})]}),(0,Xt.jsxs)("section",{className:"space-y-4","data-testid":"how-it-works-getting-jobs",children:[(0,Xt.jsx)(wz,{letter:"A",title:"Getting Jobs In",blurb:"Three ways to populate the workspace before any analysis runs."}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:xz.map((e,t)=>{const n=e.icon;return(0,Xt.jsx)(Fy,{className:"border-ndor-edge","data-testid":"how-it-works-getting-jobs-".concat(t+1),children:(0,Xt.jsxs)(Py,{className:"p-4 sm:p-5 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(n,{className:"h-4 w-4 text-ndor-gold shrink-0","aria-hidden":"true"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:e.label})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:e.copy})]})},e.label)})})]}),(0,Xt.jsxs)("section",{className:"space-y-4","data-testid":"how-it-works-ways-to-work",children:[(0,Xt.jsx)(wz,{letter:"B",title:"Three Ways to Work",blurb:"The Workflow page is the master switch. Pick one \u2014 your selection decides whether anything runs in the background."}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-3",children:vz.map(e=>{const t=e.icon;return(0,Xt.jsx)(Fy,{className:"border-ndor-edge h-full","data-testid":"how-it-works-mode-".concat(e.code),children:(0,Xt.jsxs)(Py,{className:"p-4 sm:p-5 flex flex-col gap-3 h-full",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(t,{className:"h-4 w-4 text-ndor-gold shrink-0","aria-hidden":"true"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:e.title})]}),(0,Xt.jsx)("ul",{className:"text-xs text-ndor-ink-secondary list-disc pl-4 space-y-1.5 leading-relaxed",children:e.bullets.map((e,t)=>(0,Xt.jsx)("li",{children:e},t))})]})},e.code)})})]}),(0,Xt.jsxs)("section",{className:"space-y-4","data-testid":"how-it-works-application-flow",children:[(0,Xt.jsx)(wz,{letter:"C",title:"Application Flow",blurb:"When you decide to act on a job, NDORFlow walks you through seven small steps."}),(0,Xt.jsx)("div",{className:"space-y-3",children:gz.map((e,t)=>{const n=e.icon;return(0,Xt.jsx)(Fy,{className:"border-ndor-edge","data-testid":"how-it-works-app-step-".concat(t+1),children:(0,Xt.jsxs)(Py,{className:"p-4 sm:p-5 flex items-start gap-3 sm:gap-4",children:[(0,Xt.jsx)("div",{className:"rounded-md border border-ndor-edge bg-ndor-surface-alt/40 p-2 shrink-0",children:(0,Xt.jsx)(n,{className:"h-4 w-4 sm:h-5 sm:w-5 text-ndor-gold","aria-hidden":"true"})}),(0,Xt.jsxs)("div",{className:"space-y-1.5 min-w-0 flex-1",children:[(0,Xt.jsxs)("p",{className:"text-sm font-medium text-ndor-ink",children:[t+1,". ",e.title]}),(0,Xt.jsx)("p",{className:"text-xs sm:text-sm text-ndor-ink-secondary leading-relaxed",children:e.body})]})]})}
2,e.title)})})]}),(0,Xt.jsxs)("section",{className:"space-y-4","data-testid":"how-it-works-clarifications",children:[(0,Xt.jsx)(wz,{letter:"D",title:"Key Clarifications",blurb:"Common misunderstandings, settled."}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:yz.map((e,t)=>{const n=e.icon;return(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface-alt/30","data-testid":"how-it-works-clarify-".concat(t+1),children:(0,Xt.jsxs)(Py,{className:"p-4 sm:p-5 space-y-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(n,{className:"h-4 w-4 text-ndor-gold shrink-0","aria-hidden":"true"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:e.label})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:e.copy})]})},e.label)})}),(0,Xt.jsx)(Fy,{className:"border-ndor-gold/30 bg-ndor-gold/5","data-testid":"how-it-works-never-auto-apply",children:(0,Xt.jsxs)(Py,{className:"p-4 sm:p-5 flex items-start gap-3",children:[(0,Xt.jsx)(zf,{className:"h-4 w-4 text-ndor-gold mt-0.5 shrink-0","aria-hidden":"true"}),(0,Xt.jsxs)("p",{className:"text-xs sm:text-sm text-ndor-ink-secondary leading-relaxed",children:[(0,Xt.jsx)("span",{className:"text-ndor-ink font-medium",children:"NDORFlow never auto-applies."})," ","Every submission goes out by you, on your schedule. The product accelerates analysis, drafting, and packaging \u2014 never the send."]})]})})]}),(0,Xt.jsxs)("section",{className:"space-y-4","data-testid":"how-it-works-plans-section",children:[(0,Xt.jsxs)("div",{className:"space-y-1.5",children:[(0,Xt.jsx)("h2",{className:"text-xl sm:text-2xl font-serif-display font-semibold text-ndor-ink",children:"Pick a plan"}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-secondary",children:["You can change this any time from ",(0,Xt.jsx)("span",{className:"font-mono-ui",children:"Account \u2192 Plan"}),"."]})]}),(0,Xt.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:bz.map(e=>{const t=e.icon;return(0,Xt.jsx)(Fy,{className:"border-2 ".concat(e.accent," h-full"),"data-testid":"how-it-works-plan-".concat(e.code),children:(0,Xt.jsxs)(Py,{className:"p-4 sm:p-5 flex flex-col gap-3 h-full",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(t,{className:"h-4 w-4 text-ndor-gold shrink-0","aria-hidden":"true"}),(0,Xt.jsx)("p",{className:"text-sm font-medium text-ndor-ink",children:e.name})]}),(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-relaxed",children:e.headline}),(0,Xt.jsx)("ul",{className:"text-xs text-ndor-ink-secondary list-disc pl-4 space-y-1 leading-relaxed",children:e.bullets.map((e,t)=>(0,Xt.jsx)("li",{children:e},t))})]})},e.code)})}),(0,Xt.jsx)("div",{className:"pt-2",children:(0,Xt.jsxs)(Rr,{onClick:()=>e("/onboarding/plan",{state:{from:"/how-it-works"}}),"data-testid":"how-it-works-pick-plan",children:["Pick your plan ",(0,Xt.jsx)(zy,{className:"h-4 w-4 ml-1.5"})]})})]}),(0,Xt.jsxs)("footer",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-3 pt-4 border-t border-ndor-edge",children:[(0,Xt.jsxs)(Rr,{variant:"ghost",onClick:()=>e("/dashboard"),"data-testid":"how-it-works-back",className:"justify-start sm:justify-center",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"})," Back to dashboard"]}),(0,Xt.jsxs)(Rr,{onClick:()=>e("/jobs"),"data-testid":"how-it-works-find-jobs",children:["Find a job ",(0,Xt.jsx)(zy,{className:"h-4 w-4 ml-1.5"})]})]})]})}function kz(){}function Nz(){}const _z=/^(?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u
20EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE4
20-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2-\uDFF6]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[\$0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088F\u0897-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3C-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C5C\u0C5D\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDC-\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1-\u0CF3\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1ABF-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA827\uA82C\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
2D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF65-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD6D\uDD6F-\uDD85\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDEC2-\uDEC7\uDEFA-\uDF1C\uDF27\uDF30-\uDF50\uDF70-\uDF85\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC75\uDC7F-\uDCBA\uDCC2\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E-\uDE41\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD3\uDFE1\uDFE2]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDED0-\uDEE3\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39\uDF40-\uDF46]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8\uDF60-\uDF67\uDFC0-\uDFE0\uDFF0-\uDFF9]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDDB0-\uDDDB\uDDE0-\uDDE9\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDF50-\uDF5A\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD39]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDD70-\uDD79\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0-\uDFF6]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD833[\uDCF0-\uDCF9\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC30-\uDC6D\uDC8F\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAE\uDEC0-\uDEF9]|\uD839[\uDCD0-\uDCF9\uDDD0-\uDDFA\uDEC0-\uDEDE\uDEE0-\uDEF5\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]|\uDB40[\uDD00-\uDDEF])*$/,Dz=/^(?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u
20EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE4
20-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2-\uDFF6]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[\$\x2D0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088F\u0897-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3C-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C5C\u0C5D\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDC-\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1-\u0CF3\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1ABF-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA827\uA82C\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
2D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF65-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD6D\uDD6F-\uDD85\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDEC2-\uDEC7\uDEFA-\uDF1C\uDF27\uDF30-\uDF50\uDF70-\uDF85\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC75\uDC7F-\uDCBA\uDCC2\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E-\uDE41\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD3\uDFE1\uDFE2]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDED0-\uDEE3\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39\uDF40-\uDF46]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8\uDF60-\uDF67\uDFC0-\uDFE0\uDFF0-\uDFF9]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDDB0-\uDDDB\uDDE0-\uDDE9\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDF50-\uDF5A\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD39]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDD70-\uDD79\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0-\uDFF6]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD833[\uDCF0-\uDCF9\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC30-\uDC6D\uDC8F\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAE\uDEC0-\uDEF9]|\uD839[\uDCD0-\uDCF9\uDDD0-\uDDFA\uDEC0-\uDEDE\uDEE0-\uDEF5\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]|\uDB40[\uDD00-\uDDEF])*$/,Cz={};function Az(e,t){return((t||Cz).jsx?Dz:_z).test(e)}const Sz=/[ \t\n\f\r]/g;function Ez(e){return""===e.replace(Sz,"")}class Fz{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function Rz(e,t){const n={},a={};for(const r of e)Object.assign(n,r.property),Object.assign(a,r.normal);return new Fz(n,a,t)}function Iz(e){return e.toLowerCase()}Fz.prototype.normal={},Fz.prototype.property={},Fz.prototype.space=void 0;class Tz{constructor(e,t){this.attribute=t,this.property=e}}Tz.prototype.attribute="",Tz.prototype.booleanish=!1,Tz.prototype.boolean=!1,Tz.prototype.commaOrSpaceSeparated=!1,Tz.prototype.commaSeparated=!1,Tz.prototype.defined=!1,Tz.prototype.mustUseProperty=!1,Tz.prototype.number=!1,Tz.prototype.overloadedBoolean=!1,Tz.prototype.property="",Tz.prototype.spaceSeparated=!1,Tz.prototype.space=void 0;let Pz=0;const Oz=qz(),Bz=qz(),Lz=qz(),Mz=qz(),zz=qz(),Uz=qz(),Vz=qz();function qz(){return 2**++Pz}const Wz=Object.keys(a);class Hz extends Tz{constructor(e,t,n,r){let s=-1;if(super(e,t),Gz(this,"space",r),"number"===typeof n)for(;++s<Wz.length;){const e=Wz[s];Gz(this,Wz[s],(n&a[e])===a[e])}}}function Gz(e,t,n){n&&(e[t]=n)}function Kz(e){const t={},n={};
vendor: 4,423 bytes, line 2
2for(const[a,r]of Object.entries(e.properties)){const s=new Hz(a,e.transform(e.attributes||{},a),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(s.mustUseProperty=!0),t[a]=s,n[Iz(a)]=a,n[Iz(s.attribute)]=a}return new Fz(t,n,e.space)}Hz.prototype.defined=!0;const Yz=Kz({properties:{ariaActiveDescendant:null,ariaAtomic:Bz,ariaAutoComplete:null,ariaBusy:Bz,ariaChecked:Bz,ariaColCount:Mz,ariaColIndex:Mz,ariaColSpan:Mz,ariaControls:zz,ariaCurrent:null,ariaDescribedBy:zz,ariaDetails:null,ariaDisabled:Bz,ariaDropEffect:zz,ariaErrorMessage:null,ariaExpanded:Bz,ariaFlowTo:zz,ariaGrabbed:Bz,ariaHasPopup:null,ariaHidden:Bz,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:zz,ariaLevel:Mz,ariaLive:null,ariaModal:Bz,ariaMultiLine:Bz,ariaMultiSelectable:Bz,ariaOrientation:null,ariaOwns:zz,ariaPlaceholder:null,ariaPosInSet:Mz,ariaPressed:Bz,ariaReadOnly:Bz,ariaRelevant:null,ariaRequired:Bz,ariaRoleDescription:zz,ariaRowCount:Mz,ariaRowIndex:Mz,ariaRowSpan:Mz,ariaSelected:Bz,ariaSetSize:Mz,ariaSort:null,ariaValueMax:Mz,ariaValueMin:Mz,ariaValueNow:Mz,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function Jz(e,t){return t in e?e[t]:t}function $z(e,t){return Jz(e,t.toLowerCase())}const Xz=Kz({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Uz,acceptCharset:zz,accessKey:zz,action:null,allow:null,allowFullScreen:Oz,allowPaymentRequest:Oz,allowUserMedia:Oz,alt:null,as:null,async:Oz,autoCapitalize:null,autoComplete:zz,autoFocus:Oz,autoPlay:Oz,blocking:zz,capture:null,charSet:null,checked:Oz,cite:null,className:zz,cols:Mz,colSpan:null,content:null,contentEditable:Bz,controls:Oz,controlsList:zz,coords:Mz|Uz,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Oz,defer:Oz,dir:null,dirName:null,disabled:Oz,download:Lz,draggable:Bz,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Oz,formTarget:null,headers:zz,height:Mz,hidden:Lz,high:Mz,href:null,hrefLang:null,htmlFor:zz,httpEquiv:zz,id:null,imageSizes:null,imageSrcSet:null,inert:Oz,inputMode:null,integrity:null,is:null,isMap:Oz,itemId:null,itemProp:zz,itemRef:zz,itemScope:Oz,itemType:zz,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Oz,low:Mz,manifest:null,max:null,maxLength:Mz,media:null,method:null,min:null,minLength:Mz,multiple:Oz,muted:Oz,name:null,nonce:null,noModule:Oz,noValidate:Oz,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Oz,optimum:Mz,pattern:null,ping:zz,placeholder:null,playsInline:Oz,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Oz,referrerPolicy:null,rel:zz,required:Oz,reversed:Oz,rows:Mz,rowSpan:Mz,sandbox:zz,scope:null,scoped:Oz,seamless:Oz,selected:Oz,shadowRootClonable:Oz,shadowRootDelegatesFocus:Oz,shadowRootMode:null,shape:null,size:Mz,sizes:null,slot:null,span:Mz,spell
2Check:Bz,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Mz,step:null,style:null,tabIndex:Mz,target:null,title:null,translate:null,type:null,typeMustMatch:Oz,useMap:null,value:Bz,width:Mz,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:zz,axis:null,background:null,bgColor:null,border:Mz,borderColor:null,bottomMargin:Mz,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Oz,declare:Oz,event:null,face:null,frame:null,frameBorder:null,hSpace:Mz,leftMargin:Mz,link:null,longDesc:null,lowSrc:null,marginHeight:Mz,marginWidth:Mz,noResize:Oz,noHref:Oz,noShade:Oz,noWrap:Oz,object:null,profile:null,prompt:null,rev:null,rightMargin:Mz,rules:null,scheme:null,scrolling:Bz,standby:null,summary:null,text:null,topMargin:Mz,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Mz,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Oz,disableRemotePlayback:Oz,prefix:null,property:null,results:Mz,security:null,unselectable:null},space:"html",transform:$z}),Qz=Kz({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav
2-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Vz,accentHeight:Mz,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Mz,amplitude:Mz,arabicForm:null,ascent:Mz,attributeName:null,attributeType:null,azimuth:Mz,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Mz,by:null,calcMode:null,capHeight:Mz,className:zz,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Mz,diffuseConstant:Mz,direction:null,display:null,dur:null,divisor:Mz,dominantBaseline:null,download:Oz,dx:null,dy:null,edgeMode:null,editable:null,elevation:Mz,enableBackground:null,end:null,event:null,exponent:Mz,externalResourcesRequired:null,fill:null,fillOpacity:Mz,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Uz,g2:Uz,glyphName:Uz,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Mz,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Mz,horizOriginX:Mz,horizOriginY:Mz,id:null,ideographic:Mz,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Mz,k:Mz,k1:Mz,k2:Mz,k3:Mz,k4:Mz,kernelMatrix:Vz,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Mz,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Mz,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,on
2Zoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Mz,overlineThickness:Mz,paintOrder:null,panose1:null,path:null,pathLength:Mz,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:zz,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Mz,pointsAtY:Mz,pointsAtZ:Mz,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Vz,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Vz,rev:Vz,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Vz,requiredFeatures:Vz,requiredFonts:Vz,requiredFormats:Vz,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Mz,specularExponent:Mz,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Mz,strikethroughThickness:Mz,string:null,stroke:null,strokeDashArray:Vz,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Mz,strokeOpacity:Mz,strokeWidth:null,style:null,surfaceScale:Mz,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Vz,tabIndex:Mz,tableValues:null,target:null,targetX:Mz,targetY:Mz,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Vz,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Mz,underlineThickness:Mz,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Mz,values:null,vAlphabetic:Mz,vMathematical:Mz,vectorEffect:null,vHanging:Mz,vIdeographic:Mz,version:null,vertAdvY:Mz,vertOriginX:Mz,vertOriginY:Mz,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Mz,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Jz}),Zz=Kz({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),eU=Kz({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:$z}),tU=Kz({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),nU=Rz([Yz,Xz,Zz,eU,tU],"html"),aU=Rz([Yz,Qz,Zz,eU,tU],"svg"),rU=/[A-Z]/g,sU=/-[a-z]/g,iU=/^data[-\w.:]+$/i;function oU(e){return"-"+e.toLowerCase()}function lU(e){return e.charAt(1).toUpperCase()}const cU={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var dU=n(294);const uU=pU("end"),mU=pU("start");function pU(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"===typeof n.line&&n.line>0&&"number"===typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"===typeof n.offset&&n.offset>-1?n.offset:void 0}}}function hU(e){return e&&"object"===typeof e?"position"in e||"type"in e?xU(e.position):"start"in e||"end"in e?xU(e):"line"in e||"column"in e?fU(e):"":""}function fU(e){return vU(e&&e.line)+":"+vU(e&&e.column)}function xU(e){return fU(e&&e.start)+"-"+fU(e&&e.end)}function vU(e){return e&&"number"===typeof e?e:1}class gU extends Error{constructor(e,t,n){super(),"string"===typeof t&&(n=t,t=void 0);let a="",r={},s=!1;if(t&&(r="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:(0,c.A)({},t)),"string"===typeof e?a=e:!r.cause&&e&&(s=!0,a=e.message,r.cause=e),!r.ruleId&&!r.source&&"string"===typeof n){const e=n.indexOf(":");-1===e?r.ruleId=n:(r.source=n.slice(0,e),r.ruleId=n.slice(e+1))}if(!r.place&&r.ancestors&&r.ancestors){const e=r.ancestors[r.ancestors.length-1];e&&(r.place=e.position)}const i=r.place&&"start"in r.place?r.place.start:r.place;this.ancestors=r.ancestors||void 0,this.cause=r.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=i?i.line:void 0,this.name=hU(r.place)||"1:1",this.place=r.place||void 0,this.reason=this.message,this.ruleId=r.ruleId||void 0,this.source=r.source||void 0,this.stack=s&&r.cause&&"string"===typeof r.cause.stack?r.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}gU.prototype.file="",gU.prototype.name="",gU.prototype.reason="",gU.prototype.message="",gU.prototype.stack="",gU.prototype.column=void 0,gU.prototype.line=void 0,gU.prototype.ancestors=void 0,gU.prototype.cause=void 0,gU.prototype.fatal=void 0,gU.prototype.place=void 0,gU.prototype.ruleId=void 0,gU.prototype.source=void 0;const yU={}.hasOwnProperty,bU=new Map,wU=/[A-Z]/g,jU=new Set(["table","tbody","thead","tfoot","tr"]),kU=new Set(["td","th"]),NU="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function _U(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let a;if(t.development){if("function"!==typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=function(e,t){return n;function n(n,a,r,s){const i=Array.isArray(r.children),o=mU(n);return t(a,r,s,i,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!==typeof t.jsx)throw new TypeError("Expected `jsx` in production options");
vendor: 9,767 bytes, line 2
2if("function"!==typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");a=function(e,t,n){return a;function a(e,a,r,s){const i=Array.isArray(r.children)?n:t;return s?i(a,r,s):i(a,r)}}(0,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:a,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?aU:nU,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=DU(r,e,void 0);return s&&"string"!==typeof s?s:r.create(e,r.Fragment,{children:s||void 0},void 0)}function DU(e,t,n){return"element"===t.type?function(e,t,n){const a=e.schema;let r=a;"svg"===t.tagName.toLowerCase()&&"html"===a.space&&(r=aU,e.schema=r);e.ancestors.push(t);const s=FU(e,t.tagName,!1),i=function(e,t){const n={};let a,r;for(r in t.properties)if("children"!==r&&yU.call(t.properties,r)){const s=EU(e,r,t.properties[r]);if(s){const[r,i]=s;e.tableCellAlignToStyle&&"align"===r&&"string"===typeof i&&kU.has(t.tagName)?a=i:n[r]=i}}if(a){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=a}return n}(e,t);let o=SU(e,t);jU.has(t.tagName)&&(o=o.filter(function(e){return"string"!==typeof e||!("object"===typeof(t=e)?"text"===t.type&&Ez(t.value):Ez(t));var t}));return CU(e,i,s,t),AU(i,o),e.ancestors.pop(),e.schema=a,e.create(t,s,i,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}RU(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const a=e.schema;let r=a;"svg"===t.name&&"html"===a.space&&(r=aU,e.schema=r);e.ancestors.push(t);const s=null===t.name?e.Fragment:FU(e,t.name,!0),i=function(e,t){const n={};for(const a of t.attributes)if("mdxJsxExpressionAttribute"===a.type)if(a.data&&a.data.estree&&e.evaluater){const t=a.data.estree.body[0];kz(t.type);const r=t.expression;kz(r.type);const s=r.properties[0];kz(s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else RU(e,t.position);else{const r=a.name;let s;if(a.value&&"object"===typeof a.value)if(a.value.data&&a.value.data.estree&&e.evaluater){const t=a.value.data.estree.body[0];kz(t.type),s=e.evaluater.evaluateExpression(t.expression)}else RU(e,t.position);else s=null===a.value||a.value;n[r]=s}return n}(e,t),o=SU(e,t);return CU(e,i,s,t),AU(i,o),e.ancestors.pop(),e.schema=a,e.create(t,s,i,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);RU(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const a={};return AU(a,SU(e,t)),e.create(t,e.Fragment,a,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function CU(e,t,n,a){"string"!==typeof n&&n!==e.Fragment&&e.passNode&&(t.node=a)}function AU(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function SU(e,t){const n=[];let a=-1;const r=e.passKeys?new Map:bU;for(;++a<t.children.length;){const s=t.children[a];let i;if(e.passKeys){const e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){const t=r.get(e)||0;i=e+"-"+t,r.set(e,t+1)}}const o=DU(e,s,i);void 0!==o&&n.push(o)}return n}function EU(e,t,n){const a=function(e,t){const n=Iz(t);let a=t,r=Tz;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&iU.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(sU,lU);a="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!sU.test(e)){let n=e.replace(rU,oU);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}r=Hz}return new r(a,t)}(e.schema,t);if(!(null===n||void 0===n||"number"===typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=a.commaSeparated?function(e,t){const n=t||{};return(""===e[e.length-1]?[...e,""]:e).join((n.padRight?" ":"")+","+(!1===n.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===a.property){let t="object"===typeof n?n:function(e,t){try{return dU(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,a=new gU("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=NU+"#cannot-parse-style-attribute",a}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)yU.call(e,n)&&(t[IU(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&a.space?cU[a.property]||a.property:a.attribute,n]}}function FU(e,t,n){let a;if(n)if(t.includes(".")){const e=t.split(".");let n,r=-1;for(;++r<e.length;){const t=Az(e[r])?{type:"Identifier",name:e[r]}:{type:"Literal",value:e[r]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(r&&"Literal"===t.type),optional:!1}:t}a=n}else a=Az(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else a={type:"Literal",value:t};if("Literal"===a.type){const t=a.value;return yU.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(a);RU(e)}function RU(e,t){const n=new gU("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=NU+"#cannot-handle-mdx-estrees-without-createevaluater",n}function IU(e){let t=e.replace(wU,TU);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function TU(e){return"-"+e.toLowerCase()}const PU={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},OU={};function BU(e,t){const n=t||OU;return LU(e,"boolean"!==typeof n.includeImageAlt||n.includeImageAlt,"boolean"!==typeof n.includeHtml||n.includeHtml)}function LU(e,t,n){if(function(e){return Boolean(e&&"object"===typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return MU(e.children,t,n)}return Array.isArray(e)?MU(e,t,n):""}function MU(e,t,n){const a=[];let r=-1;for(;++r<e.length;)a[r]=LU(e[r],t,n);return a.join("")}function zU(e,t,n,a){const r=e.length;let s,i=0;if(t=t<0?-t>r?0:r+t:t>r?r:t,n=n>0?n:0,a.length<1e4)s=Array.from(a),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<a.length;)s=a.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function UU(e,t){return e.length>0?(zU(e,e.length,0,t),e):t}class VU{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null===t||void 0===t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const a=t||0;this.setCursor(Math.trunc(e));const r=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return n&&qU(this.left,n),r.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),qU(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),qU(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);qU(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);qU(this.left,t.reverse())}}}function qU(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function WU(e){const t={};let n,a,r,s,i,o,l,d=-1;const u=new VU(e);for(;++d<u.length;){for(;d in t;)d=t[d];if(n=u.get(d),d&&"chunkFlow"===n[1].type&&"listItemPrefix"===u.get(d-1)[1].type&&(o=n[1]._tokenizer.events,r=0,r<o.length&&"lineEndingBlank"===o[r][1].type&&(r+=2),r<o.length&&"content"===o[r][1].type))for(;++r<o.length&&"content"!==o[r][1].type;)"chunkText"===o[r][1].type&&(o[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,HU(u,d)),d=t[d],l=!0);else if(n[1]._container){for(r=d,a=void 0;r--;)if(s=u.get(r),"lineEnding"===s[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(a&&(u.get(a)[1].type="lineEndingBlank"),s[1].type="lineEnding",a=r);else if("linePrefix"!==s[1].type&&"listItemIndent"!==s[1].type)break;a&&(n[1].end=(0,c.A)({},u.get(a)[1].start),i=u.slice(a,d),i.unshift(n),u.splice(a,d-a+1,i))}}return zU(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function HU(e,t){const n=e.get(t)[1],a=e.get(t)[2];let r=t-1;const s=[];let i=n._tokenizer;i||(i=a.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const o=i.events,l=[],c={};let d,u,m=-1,p=n,h=0,f=0;const x=[f];for(;p;){for(;e.get(++r)[1]!==p;);s.push(r),p._tokenizer||(d=a.sliceStream(p),p.next||d.push(null),u&&i.defineSki
2p(p.start),p._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),p._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),u=p,p=p.next}for(p=n;++m<o.length;)"exit"===o[m][0]&&"enter"===o[m-1][0]&&o[m][1].type===o[m-1][1].type&&o[m][1].start.line!==o[m][1].end.line&&(f=m+1,x.push(f),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(i.events=[],p?(p._tokenizer=void 0,p.previous=void 0):x.pop(),m=x.length;m--;){const t=o.slice(x[m],x[m+1]),n=s.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),m=-1;++m<l.length;)c[h+l[m][0]]=h+l[m][1],h+=l[m][1]-l[m][0]-1;return c}const GU={}.hasOwnProperty;function KU(e){const t={};let n=-1;for(;++n<e.length;)YU(t,e[n]);return t}function YU(e,t){let n;for(n in t){const a=(GU.call(e,n)?e[n]:void 0)||(e[n]={}),r=t[n];let s;if(r)for(s in r){GU.call(a,s)||(a[s]=[]);const e=r[s];JU(a[s],Array.isArray(e)?e:e?[e]:[])}}}function JU(e,t){let n=-1;const a=[];for(;++n<t.length;)("after"===t[n].add?e:a).push(t[n]);zU(e,0,0,a)}const $U=lV(/[A-Za-z]/),XU=lV(/[\dA-Za-z]/),QU=lV(/[#-'*+\--9=?A-Z^-~]/);function ZU(e){return null!==e&&(e<32||127===e)}const eV=lV(/\d/),tV=lV(/[\dA-Fa-f]/),nV=lV(/[!-/:-@[-`{-~]/);function aV(e){return null!==e&&e<-2}function rV(e){return null!==e&&(e<0||32===e)}function sV(e){return-2===e||-1===e||32===e}const iV=lV(/(?:[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B60\u1B7D-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDEAD\uDED0\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F])|(?:[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uD
vendor: 8,068 bytes, line 2
2F3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA])/),oV=lV(/\s/);function lV(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function cV(e,t,n,a){const r=a?a-1:Number.POSITIVE_INFINITY;let s=0;return function(a){if(sV(a))return e.enter(n),i(a);return t(a)};function i(a){return sV(a)&&s++<r?(e.consume(a),i):(e.exit(n),t(a))}}const dV={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),cV(e,t,"linePrefix")},function(t){return e.enter("paragraph"),a(t)});let n;return t;function a(t){const a=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=a),n=a,r(t)}function r(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):aV(t)?(e.consume(t),e.exit("chunkText"),a):(e.consume(t),r)}}};const uV={tokenize:function(e){const t=this,n=[];let a,r,s,i=0;return o;function o(a){if(i<n.length){const r=n[i];return t.containerState=r[1],e.attempt(r[0].continuation,l,d)(a)}return d(a)}function l(e){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&y();const n=t.events.length;let r,s=n;for(;s--;)if("exit"===t.events[s][0]&&"chunkFlow"===t.events[s][1].type){r=t.events[s][1].end;break}g(i);let o=n;for(;o<t.events.length;)t.events[o][1].end=(0,c.A)({},r),o++;return zU(t.events,s+1,0,t.events.slice(n)),t.events.length=o,d(e)}return o(e)}function d(r){if(i===n.length){if(!a)return p(r);if(a.currentConstruct&&a.currentConstruct.concrete)return f(r);t.interrupt=Boolean(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(mV,u,m)(r)}function u(e){return a&&y(),g(i),p(e)}function m(e){return t.parser.lazy[t.now().line]=i!==n.length,s=t.now().offset,f(e)}function p(n){return t.containerState={},e.attempt(mV,h,f)(n)}function h(e){return i++,n.push([t.currentConstruct,t.containerState]),p(e)}function f(n){return null===n?(a&&y(),g(0),void e.consume(n)):(a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:r}),x(n))}function x(n){return null===n?(v(e.exit("chunkFlow"),!0),g(0),void e.consume(n)):aV(n)?(e.consume(n),v(e.exit("chunkFlow")),i=0,t.interrupt=void 0,o):(e.consume(n),x)}function v(e,n){const o=t.sliceStream(e);if(n&&o.push(null),e.previous=r,r&&(r.next=e),r=e,a.defineSkip(e.start),a.write(o),t.parser.lazy[e.start.line]){let e=a.events.length;for(;e--;)if(a.events[e][1].start.offset<s&&(!a.events[e][1].end||a.events[e][1].end.offset>s))return;const n=t.events.length;let r,o,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(r){o=t.events[l][1].end;break}r=!0}for(g(i),e=n;e<t.events.length;)t.events[e][1].end=(0,c.A)({},o),e++;zU(t.events,l+1,0,t.events.slice(n)),t.events.length=e}}function g(a){let r=n.length;for(;r-- >a;){const a=n[r];t.containerState=a[1],a[0].exit.call(t,e)}n.length=a}function y(){a.write([null]),r=void 0,a=void 0,t.containerState._closeFlow=void 0}}},mV={tokenize:function(e,t,n){return cV(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};const pV={partial:!0,tokenize:function(e,t,n){return function(t){return sV(t)?cV(e,a,"linePrefix")(t):a(t)};function a(e){return null===e||aV(e)?t(e):n(e)}}};const hV={resolve:function(e){return WU(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(t)};function a(t){return null===t?r(t):aV(t)?e.check(fV,s,r)(t):(e.consume(t),a)}function r(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function s(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}},fV={partial:!0,tokenize:function(e,t,n){const a=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),cV(e,r,"linePrefix")};function r(r){if(null===r||aV(r))return n(r);const s=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(r):e.interrupt(a.parser.constructs.flow,n,t)(r)}}};const xV={tokenize:function(e){const t=this,n=e.attempt(pV,function(a){if(null===a)return void e.consume(a);return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n},e.attempt(this.parser.constructs.flowInitial,a,cV(e,e.attempt(this.parser.constructs.flow,a,e.attempt(hV,a)),"linePrefix")));return n;function a(a){if(null!==a)return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(a)}}};const vV={resolveAll:wV()},gV=bV("string"),yV=bV("text");function bV(e){return{resolveAll:wV("text"===e?jV:void 0),tokenize:function(t){const n=this,a=this.parser.constructs[e],r=t.attempt(a,s,i);return s;function s(e){return l(e)?r(e):i(e)}function i(e){if(null!==e)return t.enter("data"),t.consume(e),o;t.consume(e)}function o(e){return l(e)?(t.exit("data"),r(e)):(t.consume(e),o)}function l(e){if(null===e)return!0;const t=a[e];let r=-1;if(t)for(;++r<t.length;){const e=t[r];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function wV(e){return function(t,n){let a,r=-1;for(;++r<=t.length;)void 0===a?t[r]&&"data"===t[r][1].type&&(a=r,r++):t[r]&&"data"===t[r][1].type||(r!==a+2&&(t[a][1].end=t[r-1][1].end,t.splice(a+2,r-a-2),r=a+2),a=void 0);return e?e(t,n):t}}function jV(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const a=e[n-1][1],r=t.sliceStream(a);let s,i=r.length,o=-1,l=0;for(;i--;){const e=r[i];if("string"===typeof e){for(o=e.length;32===e.charCodeAt(o-1);)l++,o--;if(o)break;o=-1}else if(-2===e)s=!0,l++;else if(-1!==e){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const r={type:n===e.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:a.start._bufferIndex+o,_index:a.start._index+i,line:a.end.line,column:a.end.column-l,offset:a.end.offset-l},end:(0,c.A)({},a.end)};a.end=(0,c.A)({},r.start),a.start.offset===a.end.offset?Object.assign(a,r):(e.splice(n,0,["enter",r,t],["exit",r,t]),n+=2)}n++}return e}const kV={name:"thematicBreak",tokenize:function(e,t,n){let a,r=0;return function(t){return e.enter("thematicBreak"),function(e){return a=e,s(e)}(t)};function s(s){return s===a?(e.enter("thematicBreakSequence"),i(s)):r>=3&&(null===s||aV(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===a?(e.consume(t),r++,i):(e.exit("thematicBreakSequence"),sV(t)?cV(e,s,"whitespace")(t):s(t))}}};const NV={continuation:{tokenize:function(e,t,n){const a=this;return a.containerState._closeFlow=void 0,e.check(pV,r,s);function r(n){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,cV(e,t,"listItemIndent",a.containerState.size+1)(n)}function s(n){return a.containerState.furtherBlankLines||!sV(n)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine
vendor: 1,328 bytes, line 2
2=void 0,i(n)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,e.attempt(DV,t,i)(n))}function i(r){return a.containerState._closeFlow=!0,a.interrupt=void 0,cV(e,e.attempt(NV,t,n),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(r)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const a=this,r=a.events[a.events.length-1];let s=r&&"linePrefix"===r[1].type?r[2].sliceSerialize(r[1],!0).length:0,i=0;return function(t){const r=a.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===r?!a.containerState.marker||t===a.containerState.marker:eV(t)){if(a.containerState.type||(a.containerState.type=r,e.enter(r,{_container:!0})),"listUnordered"===r)return e.enter("listItemPrefix"),42===t||45===t?e.check(kV,n,l)(t):l(t);if(!a.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),o(t)}return n(t)};function o(t){return eV(t)&&++i<10?(e.consume(t),o):(!a.interrupt||i<2)&&(a.containerState.marker?t===a.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):n(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||t,e.check(pV,a.interrupt?n:c,e.attempt(_V,u,d))}
vendor: 9,778 bytes, line 2
2function c(e){return a.containerState.initialBlankLine=!0,s++,u(e)}function d(t){return sV(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return a.containerState.size=s+a.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},_V={partial:!0,tokenize:function(e,t,n){const a=this;return cV(e,function(e){const r=a.events[a.events.length-1];return!sV(e)&&r&&"listItemPrefixWhitespace"===r[1].type?t(e):n(e)},"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},DV={partial:!0,tokenize:function(e,t,n){const a=this;return cV(e,function(e){const r=a.events[a.events.length-1];return r&&"listItemIndent"===r[1].type&&r[2].sliceSerialize(r[1],!0).length===a.containerState.size?t(e):n(e)},"listItemIndent",a.containerState.size+1)}};const CV={continuation:{tokenize:function(e,t,n){const a=this;return function(t){if(sV(t))return cV(e,r,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return r(t)};function r(a){return e.attempt(CV,t,n)(a)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const a=this;return function(t){if(62===t){const n=a.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),r}return n(t)};function r(n){return sV(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};function AV(e,t,n,a,r,s,i,o,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(t){if(60===t)return e.enter(a),e.enter(r),e.enter(s),e.consume(t),e.exit(s),u;if(null===t||32===t||41===t||ZU(t))return n(t);return e.enter(a),e.enter(i),e.enter(o),e.enter("chunkString",{contentType:"string"}),h(t)};function u(n){return 62===n?(e.enter(s),e.consume(n),e.exit(s),e.exit(r),e.exit(a),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),m(n))}function m(t){return 62===t?(e.exit("chunkString"),e.exit(o),u(t)):null===t||60===t||aV(t)?n(t):(e.consume(t),92===t?p:m)}function p(t){return 60===t||62===t||92===t?(e.consume(t),m):m(t)}function h(r){return d||null!==r&&41!==r&&!rV(r)?d<c&&40===r?(e.consume(r),d++,h):41===r?(e.consume(r),d--,h):null===r||32===r||40===r||ZU(r)?n(r):(e.consume(r),92===r?f:h):(e.exit("chunkString"),e.exit(o),e.exit(i),e.exit(a),t(r))}function f(t){return 40===t||41===t||92===t?(e.consume(t),h):h(t)}}function SV(e,t,n,a,r,s){const i=this;let o,l=0;return function(t){return e.enter(a),e.enter(r),e.consume(t),e.exit(r),e.enter(s),c};function c(u){return l>999||null===u||91===u||93===u&&!o||94===u&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(u):93===u?(e.exit(s),e.enter(r),e.consume(u),e.exit(r),e.exit(a),t):aV(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||aV(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!sV(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function EV(e,t,n,a,r,s){let i;return function(t){if(34===t||39===t||40===t)return e.enter(a),e.enter(r),e.consume(t),e.exit(r),i=40===t?41:t,o;return n(t)};function o(n){return n===i?(e.enter(r),e.consume(n),e.exit(r),e.exit(a),t):(e.enter(s),l(n))}function l(t){return t===i?(e.exit(s),o(i)):null===t?n(t):aV(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),cV(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||aV(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===i||92===t?(e.consume(t),c):c(t)}}function FV(e,t){let n;return function a(r){if(aV(r))return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,a;if(sV(r))return cV(e,a,n?"linePrefix":"lineSuffix")(r);return t(r)}}function RV(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const IV={name:"definition",tokenize:function(e,t,n){const a=this;let r;return function(t){return e.enter("definition"),function(t){return SV.call(a,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return r=RV(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),i):n(t)}function i(t){return rV(t)?FV(e,o)(t):o(t)}function o(t){return AV(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(TV,c,c)(t)}function c(t){return sV(t)?cV(e,d,"whitespace")(t):d(t)}function d(s){return null===s||aV(s)?(e.exit("definition"),a.parser.defined.push(r),t(s)):n(s)}}},TV={partial:!0,tokenize:function(e,t,n){return function(t){return rV(t)?FV(e,a)(t):n(t)};function a(t){return EV(e,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function r(t){return sV(t)?cV(e,s,"whitespace")(t):s(t)}function s(e){return null===e||aV(e)?t(e):n(e)}}};const PV={name:"codeIndented",tokenize:function(e,t,n){const a=this;return function(t){return e.enter("codeIndented"),cV(e,r,"linePrefix",5)(t)};function r(e){const t=a.events[a.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?s(e):n(e)}function s(t){return null===t?o(t):aV(t)?e.attempt(OV,s,o)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||aV(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function o(n){return e.exit("codeIndented"),t(n)}}},OV={partial:!0,tokenize:function(e,t,n){const a=this;return r;function r(t){return a.parser.lazy[a.now().line]?n(t):aV(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r):cV(e,s,"linePrefix",5)(t)}function s(e){const s=a.events[a.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(e):aV(e)?r(e):n(e)}}};const BV={name:"headingAtx",resolve:function(e,t){let n,a,r=e.length-2,s=3;"whitespace"===e[s][1].type&&(s+=2);r-2>s&&"whitespace"===e[r][1].type&&(r-=2);"atxHeadingSequence"===e[r][1].type&&(s===r-1||r-4>s&&"whitespace"===e[r-2][1].type)&&(r-=s+1===r?2:4);r>s&&(n={type:"atxHeadingText",start:e[s][1].start,end:e[r][1].end},a={type:"chunkText",start:e[s][1].start,end:e[r][1].end,contentType:"text"},zU(e,s,r-s+1,[["enter",n,t],["enter",a,t],["exit",a,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let a=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),r(t)}(t)};function r(t){return 35===t&&a++<6?(e.consume(t),r):null===t||rV(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||aV(n)?(e.exit("atxHeading"),t(n)):sV(n)?cV(e,s,"whitespace")(n):(e.enter("atxHeadingText"),o(n))}function i(t){return 35===t?(e.consume(t),i):(e.exit("atxHeadingSequence"),s(t))}function o(t){return null===t||35===t||rV(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),o)}}};const LV={name:"setextUnderline",resolveTo:function(e,t){let n,a,r,s=e.length;for(;s--;)if("enter"===e[s][0]){if("content"===e[s][1].type){n=s;break}"paragraph"===e[s][1].type&&(a=s)}else"content"===e[s][1].type&&e.splice(s,1),r||"definition"!==e[s][1].type||(r=s);const i={type:"setextHeading",start:(0,c.A)({},e[n][1].start),end:(0,c.A)({},e[e.length-1][1].end)};e[a][1].type="setextHeadingText",r?(e.splice(a,0,["enter",i,t]),e.splice(r+1,0,["exit",e[n][1],t]),e[n][1].end=(0,c.A)({},e[r][1].end)):e[n][1]=i;return e.push(["exit",i,t]),e},tokenize:function(e,t,n){const a=this;let r;return function(t){let i,o=a.events.length;for(;o--;)if("lineEnding"!==a.events[o][1].type&&"linePrefix"!==a.events[o][1].type&&"content"!==a.events[o][1].type){i="paragraph"===a.events[o][1].type;break}if(!a.parser.lazy[a.now().line]&&(a.interrupt||i))return e.enter("setextHeadingLine"),r=t,function(t){return e.enter("setextHeadingLineSequence"),s(t)}(t);return n(t)};function s(t){return t===r?(e.consume(t),s):(e.exit("setextHeadingLineSequence"),sV(t)?cV(e,i,"lineSuffix")(t):i(t))}function i(a){return null===a||aV(a)?(e.exit("setextHeadingLine"),t(a)):n(a)}}};const MV=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],zV=["pre","script","style","textarea"],UV={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const a=this;let r,s,i,o,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(o){return 33===o?(e.consume(o),d):47===o?(e.consume(o),s=!0,p):63===o?(e.consume(o),r=3,a.interrupt?t:T):$U(o)?(e.consume(o),i=String.fromCharCode(o),h):n(o)}function d(s){return 45===s?(e.consume(s),r=2,u):91===s?(e.consume(s),r=5,o=0,m):$U(s)?(e.consume(s),r=4,a.interrupt?t:T):n(s)}function u(r){return 45===r?(e.consume(r),a.interrupt?t:T):n(r)}function m(r){const s="CDATA[";return r===s.charCodeAt(o++)?(e.consume(r),6===o?a.interrupt?t:D:m):n(r)}function p(t){return $U(t)?(e.consume(t),i=String.fromCharCode(t),h):n(t)}
vendor: 4,267 bytes, line 2
2function h(o){if(null===o||47===o||62===o||rV(o)){const l=47===o,c=i.toLowerCase();return l||s||!zV.includes(c)?MV.includes(i.toLowerCase())?(r=6,l?(e.consume(o),f):a.interrupt?t(o):D(o)):(r=7,a.interrupt&&!a.parser.lazy[a.now().line]?n(o):s?x(o):v(o)):(r=1,a.interrupt?t(o):D(o))}return 45===o||XU(o)?(e.consume(o),i+=String.fromCharCode(o),h):n(o)}function f(r){return 62===r?(e.consume(r),a.interrupt?t:D):n(r)}function x(t){return sV(t)?(e.consume(t),x):N(t)}function v(t){return 47===t?(e.consume(t),N):58===t||95===t||$U(t)?(e.consume(t),g):sV(t)?(e.consume(t),v):N(t)}function g(t){return 45===t||46===t||58===t||95===t||XU(t)?(e.consume(t),g):y(t)}function y(t){return 61===t?(e.consume(t),b):sV(t)?(e.consume(t),y):v(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):sV(t)?(e.consume(t),b):j(t)}function w(t){return t===l?(e.consume(t),l=null,k):null===t||aV(t)?n(t):(e.consume(t),w)}function j(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||rV(t)?y(t):(e.consume(t),j)}function k(e){return 47===e||62===e||sV(e)?v(e):n(e)}function N(t){return 62===t?(e.consume(t),_):n(t)}function _(t){return null===t||aV(t)?D(t):sV(t)?(e.consume(t),_):n(t)}function D(t){return 45===t&&2===r?(e.consume(t),E):60===t&&1===r?(e.consume(t),F):62===t&&4===r?(e.consume(t),P):63===t&&3===r?(e.consume(t),T):93===t&&5===r?(e.consume(t),I):!aV(t)||6!==r&&7!==r?null===t||aV(t)?(e.exit("htmlFlowData"),C(t)):(e.consume(t),D):(e.exit("htmlFlowData"),e.check(VV,O,C)(t))}function C(t){return e.check(qV,A,O)(t)}function A(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),S}function S(t){return null===t||aV(t)?C(t):(e.enter("htmlFlowData"),D(t))}function E(t){return 45===t?(e.consume(t),T):D(t)}function F(t){return 47===t?(e.consume(t),i="",R):D(t)}function R(t){if(62===t){const n=i.toLowerCase();return zV.includes(n)?(e.consume(t),P):D(t)}return $U(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),R):D(t)}function I(t){return 93===t?(e.consume(t),T):D(t)}function T(t){return 62===t?(e.consume(t),P):45===t&&2===r?(e.consume(t),T):D(t)}function P(t){return null===t||aV(t)?(e.exit("htmlFlowData"),O(t)):(e.consume(t),P)}function O(n){return e.exit("htmlFlow"),t(n)}}},VV={partial:!0,tokenize:function(e,t,n){return function(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(pV,t,n)}}},qV={partial:!0,tokenize:function(e,t,n){const a=this;return function(t){if(aV(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r;return n(t)};function r(e){return a.parser.lazy[a.now().line]?n(e):t(e)}}};const WV={partial:!0,tokenize:function(e,t,n){const a=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r};function r(e){return a.parser.lazy[a.now().line]?n(e):t(e)}}},HV={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const a=this,r={partial:!0,tokenize:function(e,t,n){let r=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),sV(t)?cV(e,c,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===s?(e.enter("codeFencedFenceSequence"),d(t)):n(t)}function d(t){return t===s?(r++,e.consume(t),d):r>=o?(e.exit("codeFencedFenceSequence"),sV(t)?cV(e,u,"whitespace")(t):u(t)):n(t)}function u(a){return null===a||aV(a)?(e.exit("codeFencedFence"),t(a)):n(a)}}};let s,i=0,o=0;return function(t){return function(t){const n=a.events[a.events.length-1];return i=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===s?(o++,e.consume(t),l):o<3?n(t):(e.exit("codeFencedFenceSequence"),sV(t)?cV(e,c,"whitespace")(t):c(t))}function c(n){return null===n||aV(n)?(e.exit("codeFencedFence"),a.interrupt?t(n):e.check(WV,p,g)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return null===t||aV(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):sV(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),cV(e,u,"whitespace")(t)):96===t&&t===s?
vendor: 6,307 bytes, line 2
2n(t):(e.consume(t),d)}function u(t){return null===t||aV(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(t))}function m(t){return null===t||aV(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?n(t):(e.consume(t),m)}function p(t){return e.attempt(r,g,h)(t)}function h(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),f}function f(t){return i>0&&sV(t)?cV(e,x,"linePrefix",i+1)(t):x(t)}function x(t){return null===t||aV(t)?e.check(WV,p,g)(t):(e.enter("codeFlowValue"),v(t))}function v(t){return null===t||aV(t)?(e.exit("codeFlowValue"),x(t)):(e.consume(t),v)}function g(n){return e.exit("codeFenced"),t(n)}}};const GV=document.createElement("i");function KV(e){const t="&"+e+";";GV.innerHTML=t;const n=GV.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}const YV={name:"characterReference",tokenize:function(e,t,n){const a=this;let r,s,i=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),o};function o(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,s=XU,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,s=tV,c):(e.enter("characterReferenceValue"),r=7,s=eV,c(t))}function c(o){if(59===o&&i){const r=e.exit("characterReferenceValue");return s!==XU||KV(a.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(o),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(o)}return s(o)&&i++<r?(e.consume(o),c):n(o)}}};const JV={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),a};function a(a){return nV(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}};const $V={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),cV(e,t,"linePrefix")}}};function XV(e,t,n){const a=[];let r=-1;for(;++r<e.length;){const s=e[r].resolveAll;s&&!a.includes(s)&&(t=s(t,n),a.push(s))}return t}const QV={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const a=e[t][1];if(n.push(e[t]),"labelImage"===a.type||"labelLink"===a.type||"labelEnd"===a.type){const e="labelImage"===a.type?4:2;a.type="data",t+=e}}e.length!==n.length&&zU(e,0,e.length,n);return e},resolveTo:function(e,t){let n,a,r,s,i=e.length,o=0;for(;i--;)if(n=e[i][1],a){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[i][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(r){if("enter"===e[i][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(a=i,"labelLink"!==n.type)){o=2;break}}else"labelEnd"===n.type&&(r=i);const l={type:"labelLink"===e[a][1].type?"link":"image",start:(0,c.A)({},e[a][1].start),end:(0,c.A)({},e[e.length-1][1].end)},d={type:"label",start:(0,c.A)({},e[a][1].start),end:(0,c.A)({},e[r][1].end)},u={type:"labelText",start:(0,c.A)({},e[a+o+2][1].end),end:(0,c.A)({},e[r-2][1].start)};return s=[["enter",l,t],["enter",d,t]],s=UU(s,e.slice(a+1,a+o+3)),s=UU(s,[["enter",u,t]]),s=UU(s,XV(t.parser.constructs.insideSpan.null,e.slice(a+o+4,r-3),t)),s=UU(s,[["exit",u,t],e[r-2],e[r-1],["exit",d,t]]),s=UU(s,e.slice(r+1)),s=UU(s,[["exit",l,t]]),zU(e,a,e.length,s),e},tokenize:function(e,t,n){const a=this;let r,s,i=a.events.length;for(;i--;)if(("labelImage"===a.events[i][1].type||"labelLink"===a.events[i][1].type)&&!a.events[i][1]._balanced){r=a.events[i][1];break}return function(t){if(!r)return n(t);if(r._inactive)return d(t);return s=a.parser.defined.includes(RV(a.sliceSerialize({start:r.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),o};function o(t){return 40===t?e.attempt(ZV,c,s?c:d)(t):91===t?e.attempt(eq,c,s?l:d)(t):s?c(t):d(t)}function l(t){return e.attempt(tq,c,d)(t)}function c(e){return t(e)}function d(e){return r._balanced=!0,n(e)}}},ZV={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),a};function a(t){return rV(t)?FV(e,r)(t):r(t)}function r(t){return 41===t?c(t):AV(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return rV(t)?FV(e,o)(t):c(t)}function i(e){return n(e)}function o(t){return 34===t||39===t||40===t?EV(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return rV(t)?FV(e,c)(t):c(t)}function c(a){return 41===a?(e.enter("resourceMarker"),e.consume(a),e.exit("resourceMarker"),e.exit("resource"),t):n(a)}}},eq={tokenize:function(e,t,n){const a=this;return function(t){return SV.call(a,e,r,s,"reference","referenceMarker","referenceString")(t)};function r(e){return a.parser.defined.includes(RV(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},tq={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),a};function a(a){return 93===a?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}};const nq={name:"labelStartImage",resolveAll:QV.resolveAll,tokenize:function(e,t,n){const a=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),r};function r(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),s):n(t)}function s(e){return 94===e&&"_hiddenFootnoteSupport"in a.parser.constructs?n(e):t(e)}}};function aq(e){return null===e||rV(e)||oV(e)?1:iV(e)?2:void 0}const rq={name:"attention",resolveAll:function(e,t){let n,a,r,s,i,o,l,d,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close)for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[
vendor: 6,536 bytes, line 2
2n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;o=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const m=(0,c.A)({},e[n][1].end),p=(0,c.A)({},e[u][1].start);sq(m,-o),sq(p,o),s={type:o>1?"strongSequence":"emphasisSequence",start:m,end:(0,c.A)({},e[n][1].end)},i={type:o>1?"strongSequence":"emphasisSequence",start:(0,c.A)({},e[u][1].start),end:p},r={type:o>1?"strongText":"emphasisText",start:(0,c.A)({},e[n][1].end),end:(0,c.A)({},e[u][1].start)},a={type:o>1?"strong":"emphasis",start:(0,c.A)({},s.start),end:(0,c.A)({},i.end)},e[n][1].end=(0,c.A)({},s.start),e[u][1].start=(0,c.A)({},i.end),l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=UU(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=UU(l,[["enter",a,t],["enter",s,t],["exit",s,t],["enter",r,t]]),l=UU(l,XV(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=UU(l,[["exit",r,t],["enter",i,t],["exit",i,t],["exit",a,t]]),e[u][1].end.offset-e[u][1].start.offset?(d=2,l=UU(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):d=0,zU(e,n-1,u-n+3,l),u=n+l.length-d-2;break}u=-1;for(;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,a=this.previous,r=aq(a);let s;return function(t){return s=t,e.enter("attentionSequence"),i(t)};function i(o){if(o===s)return e.consume(o),i;const l=e.exit("attentionSequence"),c=aq(o),d=!c||2===c&&r||n.includes(o),u=!r||2===r&&c||n.includes(a);return l._open=Boolean(42===s?d:d&&(r||!u)),l._close=Boolean(42===s?u:u&&(c||!d)),t(o)}}};function sq(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const iq={name:"autolink",tokenize:function(e,t,n){let a=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),r};function r(t){return $U(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||XU(e)?(a=1,i(e)):l(e)}function i(t){return 58===t?(e.consume(t),a=0,o):(43===t||45===t||46===t||XU(t))&&a++<32?(e.consume(t),i):(a=0,l(t))}function o(a){return 62===a?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(a),e.exit("autolinkMarker"),e.exit("autolink"),t):null===a||32===a||60===a||ZU(a)?n(a):(e.consume(a),o)}function l(t){return 64===t?(e.consume(t),c):QU(t)?(e.consume(t),l):n(t)}function c(e){return XU(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),a=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):u(n)}function u(t){if((45===t||XU(t))&&a++<63){const n=45===t?u:d;return e.consume(t),n}return n(t)}}};const oq={name:"htmlText",tokenize:function(e,t,n){const a=this;let r,s,i;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),o};function o(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),b):63===t?(e.consume(t),g):$U(t)?(e.consume(t),k):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,p):$U(t)?(e.consume(t),v):n(t)}function c(t){return 45===t?(e.consume(t),m):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):aV(t)?(i=d,R(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),m):d(t)}function m(e){return 62===e?F(e):45===e?u(e):d(e)}function p(t){const a="CDATA[";return t===a.charCodeAt(s++)?(e.consume(t),6===s?h:p):n(t)}function h(t){return null===t?n(t):93===t?(e.consume(t),f):aV(t)?(i=h,R(t)):(e.consume(t),h)}function f(t){return 93===t?(e.consume(t),x):h(t)}function x(t){return 62===t?F(t):93===t?(e.consume(t),x):h(t)}function v(t){return null===t||62===t?F(t):aV(t)?(i=v,R(t)):(e.consume(t),v)}function g(t){return null===t?n(t):63===t?(e.consume(t),y):aV(t)?(i=g,R(t)):(e.consume(t),g)}function y(e){return 62===e?F(e):g(e)}function b(t){return $U(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||XU(t)?(e.consume(t),w):j(t)}function j(t){return aV(t)?(i=j,R(t)):sV(t)?(e.consume(t),j):F(t)}function k(t){return 45===t||XU(t)?(e.consume(t),k):47===t||62===t||rV(t)?N(t):n(t)}function N(t){return 47===t?(e.consume(t),F):58===t||95===t||$U(t)?(e.consume(t),_):aV(t)?(i=N,R(t)):sV(t)?(e.consume(t),N):F(t)}function _(t){return 45===t||46===t||58===t||95===t||XU(t)?(e.consume(t),_):D(t)}function D(t){return 61===t?(e.consume(t),C):aV(t)?(i=D,R(t)):sV(t)?(e.consume(t),D):N(t)}function C(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,A):aV(t)?(i=C,R(t)):sV(t)?(e.consume(t),C):(e.consume(t),S)}function A(t){return t===r?(e.consume(t),r=void 0,E):null===t?n(t):aV(t)?(i=A,R(t)):(e.consume(t),A)}function S(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||rV(t)?N(t):(e.consume(t),S)}function E(e){return 47===e||62===e||rV(e)?N(e):n(e)}function F(a){return 62===a?(e.consume(a),e.exit("htmlTextData"),e.exit("htmlText"),t):n(a)}function R(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),I}function I(t){return sV(t)?cV(e,T,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):T(t)}function T(t){return e.enter("htmlTextData"),i(t)}}};const lq={name:"labelStartLink",resolveAll:QV.resolveAll,tokenize:function(e,t,n){const a=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),r};function r(e){return 94===e&&"_hiddenFootnoteSupport"in a.parser.constructs?n(e):t(e)}}};const cq={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),a};function a(a){return aV(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}};const dq={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,a=e.length-4,r=3;if(("lineEnding"===e[r][1].type||"space"===e[r][1].type)&&("lineEnding"===e[a][1].type||"space"===e[a][1].type))for(t=r;++t<a;)if("codeTextData"===e[t][1].type){e[r][1].type="codeTextPadding",e[a][1].type="codeTextPadding",r+=2,a-=2;break}t=r-1,a++;for(;++t<=a;)void 0===n?t!==a&&"lineEnding"!==e[t][1].type&&(n=t):t!==a&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),a-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let a,r,s=0;
vendor: 10,948 bytes, line 2
2return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),i(t)};function i(t){return 96===t?(e.consume(t),s++,i):(e.exit("codeTextSequence"),o(t))}function o(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),o):96===t?(r=e.enter("codeTextSequence"),a=0,c(t)):aV(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||aV(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),a++,c):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(r.type="codeTextData",l(n))}}};const uq={42:NV,43:NV,45:NV,48:NV,49:NV,50:NV,51:NV,52:NV,53:NV,54:NV,55:NV,56:NV,57:NV,62:CV},mq={91:IV},pq={[-2]:PV,[-1]:PV,32:PV},hq={35:BV,42:kV,45:[LV,kV],60:UV,61:LV,95:kV,96:HV,126:HV},fq={38:YV,92:JV},xq={[-5]:$V,[-4]:$V,[-3]:$V,33:nq,38:YV,42:rq,60:[iq,oq],91:lq,92:[cq,JV],93:QV,95:rq,96:dq},vq={null:[rq,vV]},gq={null:[42,95]},yq={null:[]};function bq(e,t,n){let a={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},s=[];let i=[],o=[],l=!0;const c={attempt:g(function(e,t){y(e,t.from)}),check:g(v),consume:function(e){aV(e)?(a.line++,a.column=1,a.offset+=-3===e?2:1,b()):-1!==e&&(a.column++,a.offset++);a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===i[a._index].length&&(a._bufferIndex=-1,a._index++));d.previous=e,l=!0},enter:function(e,t){const n=t||{};return n.type=e,n.start=h(),d.events.push(["enter",n,d]),o.push(n),n},exit:function(e){const t=o.pop();return t.end=h(),d.events.push(["exit",t,d]),t},interrupt:g(v,{interrupt:!0})},d={code:null,containerState:{},defineSkip:function(e){r[e.line]=e.column,b()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const a=[];let r;for(;++n<e.length;){const s=e[n];let i;if("string"===typeof s)i=s;else switch(s){case-5:i="\r";break;case-4:i="\n";break;case-3:i="\r\n";break;case-2:i=t?" ":"\t";break;case-1:if(!t&&r)continue;i=" ";break;default:i=String.fromCharCode(s)}r=-2===s,a.push(i)}return a.join("")}(p(e),t)},sliceStream:p,write:function(e){if(i=UU(i,e),f(),null!==i[i.length-1])return[];return y(t,0),d.events=XV(s,d.events,d),d.events}};let u,m=t.tokenize.call(d,c);return t.resolveAll&&s.push(t),d;function p(e){return function(e,t){const n=t.start._index,a=t.start._bufferIndex,r=t.end._index,s=t.end._bufferIndex;let i;if(n===r)i=[e[n].slice(a,s)];else{if(i=e.slice(n,r),a>-1){const e=i[0];"string"===typeof e?i[0]=e.slice(a):i.shift()}s>0&&i.push(e[r].slice(0,s))}return i}(i,e)}function h(){const{_bufferIndex:e,_index:t,line:n,column:r,offset:s}=a;return{_bufferIndex:e,_index:t,line:n,column:r,offset:s}}function f(){let e;for(;a._index<i.length;){const t=i[a._index];if("string"===typeof t)for(e=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===e&&a._bufferIndex<t.length;)x(t.charCodeAt(a._bufferIndex));else x(t)}}function x(e){l=void 0,u=e,m=m(e)}function v(e,t){t.restore()}function g(e,t){return function(n,r,s){let i,u,m,p;return Array.isArray(n)?f(n):"tokenize"in n?f([n]):function(e){return t;function t(t){const n=null!==t&&e[t],a=null!==t&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(a)?a:a?[a]:[]])(t)}}(n);function f(e){return i=e,u=0,0===e.length?s:x(e[u])}function x(e){return function(n){p=function(){const e=h(),t=d.previous,n=d.currentConstruct,r=d.events.length,s=Array.from(o);return{from:r,restore:i};function i(){a=e,d.previous=t,d.currentConstruct=n,d.events.length=r,o=s,b()}}(),m=e,e.partial||(d.currentConstruct=e);if(e.name&&d.parser.constructs.disable.null.includes(e.name))return g(n);return e.tokenize.call(t?Object.assign(Object.create(d),t):d,c,v,g)(n)}}function v(t){return l=!0,e(m,p),r}function g(e){return l=!0,p.restore(),++u<i.length?x(i[u]):s}}}function y(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&zU(d.events,t,d.events.length-t,e.resolve(d.events.slice(t),d)),e.resolveTo&&(d.events=e.resolveTo(d.events,d))}function b(){a.line in r&&a.column<2&&(a.column=r[a.line],a.offset+=r[a.line]-1)}}const wq=/[\0\t\n\r]/g;function jq(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||65535===(65535&n)||65534===(65535&n)||n>1114111?"\ufffd":String.fromCodePoint(n)}const kq=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Nq(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return jq(n.slice(t?2:1),t?16:10)}return KV(n)||e}const _q={}.hasOwnProperty;function Dq(e,t,n){return t&&"object"===typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(te),autolinkProtocol:_,autolinkEmail:_,atxHeading:s(X),blockQuote:s(G),characterEscape:_,characterReference:_,codeFenced:s(K),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(K,i),codeText:s(Y,i),codeTextData:_,data:_,codeFlowValue:_,definition:s(J),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s($),hardBreakEscape:s(Q),hardBreakTrailing:s(Q),htmlFlow:s(Z,i),htmlFlowData:_,htmlText:s(Z,i),htmlTextData:_,image:s(ee),label:i,link:s(te),listItem:s(ae),listItemValue:m,listOrdered:s(ne,u),listUnordered:s(ne),paragraph:s(re),reference:M,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:s(X),strong:s(se),thematicBreak:s(oe)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:H,autolinkProtocol:W,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:V,characterReference:q,codeFenced:l(x),codeFencedFence:f,codeFencedFenceInfo:p,codeFencedFenceMeta:h,codeFlowValue:D,codeIndented:l(v),codeText:l(F),codeTextData:D,data:D,definition:l(),definitionDestinationString:b,definitionLabelString:g,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(S),htmlFlowData:D,htmlText:l(E),htmlTextData:D,image:l(I),label:P,labelText:T,lineEnding:C,link:l(R),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:z,resourceDestinationString:O,resourceTitleString:B,resource:L,setextHeading:l(N),setextHeadingLineSequence:k,setextHeadingText:j,strong:l(),thematicBreak:l()}};Aq(t,(e||{}).mdastExtensions||[]);const n={};return a;function a(e){let a={type:"root",children:[]};const s={stack:[a],tokenStack:[],config:t,enter:o,exit:c,buffer:i,resume:d,data:n},l=[];let u=-1;for(;++u<e.length;)if("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)if("enter"===e[u][0])l.push(u);else{u=r(e,l.pop(),u)}for(u=-1;++u<e.length;){const n=t[e[u][0]];_q.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},s),e[u][1])}if(s.tokenStack.length>0){const e=s.tokenStack[s.tokenStack.length-1];(e[1]||Eq).call(s,void 0,e[0])}for(a.position={start:Cq(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Cq(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)a=t.transforms[u](a)||a;return a}function r(e,t,n){let a,r,s,i,o=t-1,l=-1,c=!1;for(;++o<=n;){const t=e[o];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,i=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!a||i||l||s||(s=o),i=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:i=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(a){let i=o;for(r=void 0;i--;){const t=e[i];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;r&&(e[r][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",r=i}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}s&&(!r||s<r)&&(a._spread=!0),a.end=Object.assign({},r?e[r][1].start:t[1].end),e.splice(r||o,0,["exit",a,t[2]]),o++,n++}if("listItemPrefix"===t[1].type){const r={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};a=r,e.splice(o,0,["enter",r,t[2]]),o++,n++,s=void 0,i=!0}}}return e[t][1]._spread=c,n}function s(e,t){return n;function n(n){o.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function o(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Cq(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),c.call(this,t)}}function c(e,t){const n=this.stack.pop(),a=this.tokenStack.pop();if(!a)throw new Error("Cannot close `"+e.type+"` ("+hU({start:e.start,end:e.end})+"): it\u2019s not open");if(a[0].type!==e.type)if(t)t.call(this,e,a[0]);else{(a[1]||Eq).call(this,e,a[0])}n.position.end=Cq(e.end)}function d(){return BU(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function m(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function h(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function f(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function g(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=RV(this.sliceSerialize(e)).toLowerCase()}function y(){const e=this.resume();this.stack[this.stack.length-1].title=e}function b(){const e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function k(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function _(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=ie(),n.position={start:Cq(e.start),end:void 0},t.push(n)),this.stack.push(n)}function D(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Cq(e.end)}function C(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=Cq(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.t
vendor: 4,539 bytes, line 2
2ype)&&(_.call(this,e),D.call(this,e))}function A(){this.data.atHardBreak=!0}function S(){const e=this.resume();this.stack[this.stack.length-1].value=e}function E(){const e=this.resume();this.stack[this.stack.length-1].value=e}function F(){const e=this.resume();this.stack[this.stack.length-1].value=e}function R(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function I(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function T(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(kq,Nq)}(t),n.identifier=RV(t).toLowerCase()}function P(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function O(){const e=this.resume();this.stack[this.stack.length-1].url=e}function B(){const e=this.resume();this.stack[this.stack.length-1].title=e}function L(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function z(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=RV(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function U(e){this.data.characterReferenceType=e.type}function V(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let a;if(n)a=jq(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{a=KV(t)}this.stack[this.stack.length-1].value+=a}function q(e){this.stack.pop().position.end=Cq(e.end)}function W(e){D.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function H(e){D.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function G(){return{type:"blockquote",children:[]}}function K(){return{type:"code",lang:null,meta:null,value:""}}function Y(){return{type:"inlineCode",value:""}}function J(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function $(){return{type:"emphasis",children:[]}}function X(){return{type:"heading",depth:0,children:[]}}function Q(){return{type:"break"}}function Z(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function ae(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function re(){return{type:"paragraph",children:[]}}function se(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function oe(){return{type:"thematicBreak"}}}(n)(function(e){for(;!WU(e););return e}(function(e){const t={constructs:KU([r,...(e||{}).extensions||[]]),content:n(dV),defined:[],document:n(uV),flow:n(xV),lazy:{},string:n(gV),text:n(yV)};return t;function n(e){return function(n){return bq(t,e,n)}}}(n).document().write(function(){let e,t=1,n="",a=!0;return function(r,s,i){const o=[];let l,c,d,u,m;for(r=n+("string"===typeof r?r.toString():new TextDecoder(s||void 0).decode(r)),d=0,n="",a&&(65279===r.charCodeAt(0)&&d++,a=void 0);d<r.length;){if(wq.lastIndex=d,l=wq.exec(r),u=l&&void 0!==l.index?l.index:r.length,m=r.charCodeAt(u),!l){n=r.slice(d);break}if(10===m&&d===u&&e)o.push(-3),e=void 0;else switch(e&&(o.push(-5),e=void 0),d<u&&(o.push(r.slice(d,u)),t+=u-d),m){case 0:o.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),o.push(-2);t++<c;)o.push(-1);break;case 10:o.push(-4),t=1;break;default:e=!0,t=1}d=u+1}return i&&(e&&o.push(-5),n&&o.push(n),o.push(null)),o}}()(e,t,!0))))}function Cq(e){return{line:e.line,column:e.column,offset:e.offset}}function Aq(e,t){let n=-1;for(;++n<t.length;){const a=t[n];Array.isArray(a)?Aq(e,a):Sq(e,a)}}function Sq(e,t){let n;for(n in t)if(_q.call(t,n))switch(n){case"canContainEols":{const a=t[n];a&&e[n].push(...a);break}case"transforms":{const a=t[n];a&&e[n].push(...a);break}case"enter":case"exit":{const a=t[n];a&&Object.assign(e[n],a);break}}}function Eq(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+hU({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+hU({start:t.start,end:t.end}
2)+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+hU({start:t.start,end:t.end})+") is still open")}function Fq(e){const t=this;t.parser=function(n){return Dq(n,(0,c.A)((0,c.A)((0,c.A)({},t.data("settings")),e),{},{extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]}))}}const Rq="object"===typeof self?self:globalThis,Iq=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new Rq[e](t)},Tq=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),a=r=>{if(e.has(r))return e.get(r);const[s,i]=t[r];switch(s){case 0:case-1:return n(i,r);case 1:{const e=n([],r);for(const t of i)e.push(a(t));return e}case 2:{const e=n({},r);for(const[t,n]of i)e[a(t)]=a(n);return e}case 3:return n(new Date(i),r);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),r)}case 5:{const e=n(new Map,r);for(const[t,n]of i)e.set(a(t),a(n));return e}case 6:{const e=n(new Set,r);for(const t of i)e.add(a(t));return e}case 7:{const{name:e,message:t}=i;return n(Iq(e,t),r)}case 8:return n(BigInt(i),r);case"BigInt":return n(Object(BigInt(i)),r);case"ArrayBuffer":return n(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:e}=new Uint8Array(i);return n(new DataView(e),i)}}return n(Iq(s,i),r)};return a})(new Map,e)(0),Pq="",{toString:Oq}={},{keys:Bq}=Object,Lq=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=Oq.call(e).slice(8,-1);switch(n){case"Array":return[1,Pq];case"Object":return[2,Pq];case"Date":return[3,Pq];case"RegExp":return[4,Pq];case"Map":return[5,Pq];case"Set":return[6,Pq];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Mq=e=>{let[t,n]=e;return 0===t&&("function"===n||"symbol"===n)},zq=function(e){let{json:t,lossy:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=[];return((e,t,n,a)=>{const r=(e,t)=>{const r=a.push(e)-1;return n.set(t,r),r},s=a=>{if(n.has(a))return n.get(a);let[i,o]=Lq(a);switch(i){case 0:{let t=a;switch(o){case"bigint":i=8,t=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);t=null;break;case"undefined":return r([-1],a)}return r([i,t],a)}case 1:{if(o){let e=a;return"DataView"===o?e=new Uint8Array(a.buffer):"ArrayBuffer"===o&&(e=new Uint8Array(a)),r([o,[...e]],a)}const e=[],t=r([i,e],a);for(const n of a)e.push(s(n));return t}case 2:{if(o)switch(o){case"BigInt":return r([o,a.toString()],a);case"Boolean":case"Number":case"String":return r([o,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const n=[],l=r([i,n],a);for(const t of Bq(a))!e&&Mq(Lq(a[t]))||n.push([s(t),s(a[t])]);return l}case 3:return r([i,a.toISOString()],a);case 4:{const{source:e,flags:t}=a;return r([i,{source:e,flags:t}],a)}case 5:{const t=[],n=r([i,t],a);for(const[r,i]of a)(e||!Mq(Lq(r))&&!Mq(Lq(i)))&&t.push([s(r),s(i)]);return n}case 6:{const t=[],n=r([i,t],a);for(const r of a)!e&&Mq(Lq(r))||t.push(s(r));return n}}const{message:l}=a;return r([i,{name:o,message:l}],a)};return s})(!(t||n),!!t,new Map,a)(e),a},Uq="function"===typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Tq(zq(e,t)):structuredClone(e):(e,t)=>Tq(zq(e,t));function Vq(e){const t=[];let n=-1,a=0,r=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&XU(e.charCodeAt(n+1))&&XU(e.charCodeAt(n+2)))r=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(i=String.fromCharCode(s));else if(s>55295&&s<57344){const t=e.charCodeAt(n+1);s<56320&&t>56319&&t<57344?(i=String.fromCharCode(s,t),r=1):i="\ufffd"}else i=String.fromCharCode(s);i&&(t.push(e.slice(a,n),encodeURIComponent(i)),a=n+r+1,i=""),r&&(n+=r,r=0)}return t.join("")+e.slice(a)}function qq(e,t){const n=[{type:"text",value:"\u21a9"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Wq(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const Hq=function(e){if(null===e||void 0===e)return Kq;if("function"===typeof e)return Gq(e);if("object"===typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Hq(e[n]);return Gq(a);function a(){let e=-1;for(var n=arguments.length,a=new Array(n),r=0;r<n;r++)a[r]=arguments[r];for(;++e<t.length;)if(t[e].apply(this,a))return!0;return!1}}(e):function(e){const t=e;return Gq(n);function n(n){const a=n;let r;for(r in e)if(a[r]!==t[r])return!1;return!0}}(e);if("string"===typeof e)return function(e){return Gq(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function Gq(e){return function(t,n,a){return Boolean(Yq(t)&&e.call(this,t,"number"===typeof n?n:void 0,a||void 0))}}function Kq(){return!0}function Yq(e){return null!==e&&"object"===typeof e&&"type"in e}const Jq=[],$q=!0,Xq=!1;function Qq(e,t,n,a){let r;"function"===typeof t&&"function"!==typeof n?(a=n,n=t):r=t;
vendor: 10,377 bytes, line 2
2const s=Hq(r),i=a?-1:1;!function e(r,o,l){const c=r&&"object"===typeof r?r:{};if("string"===typeof c.type){const e="string"===typeof c.tagName?c.tagName:"string"===typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+r.type+(e?"<"+e+">":"")+")"})}return d;function d(){let c,d,u,m=Jq;if((!t||s(r,o,l[l.length-1]||void 0))&&(m=function(e){if(Array.isArray(e))return e;if("number"===typeof e)return[$q,e];return null===e||void 0===e?Jq:[e]}(n(r,l)),m[0]===Xq))return m;if("children"in r&&r.children){const t=r;if(t.children&&"skip"!==m[0])for(d=(a?t.children.length:-1)+i,u=l.concat(t);d>-1&&d<t.children.length;){const n=t.children[d];if(c=e(n,d,u)(),c[0]===Xq)return c;d="number"===typeof c[1]?c[1]:d+i}}return m}}(e,void 0,[])()}function Zq(e,t,n,a){let r,s,i;"function"===typeof t&&"function"!==typeof n?(s=void 0,i=t,r=n):(s=t,i=n,r=a),Qq(e,s,function(e,t){const n=t[t.length-1],a=n?n.children.indexOf(e):void 0;return i(e,a,n)},r)}function eW(e,t){const n=t.referenceType;let a="]";if("collapsed"===n?a+="[]":"full"===n&&(a+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+a}];const r=e.all(t),s=r[0];s&&"text"===s.type?s.value="["+s.value:r.unshift({type:"text",value:"["});const i=r[r.length-1];return i&&"text"===i.type?i.value+=a:r.push({type:"text",value:a}),r}function tW(e){const t=e.spread;return null===t||void 0===t?e.children.length>1:t}function nW(e){const t=String(e),n=/\r?\n|\r/g;let a=n.exec(t),r=0;const s=[];for(;a;)s.push(aW(t.slice(r,a.index),r>0,!0),a[0]),r=a.index+a[0].length,a=n.exec(t);return s.push(aW(t.slice(r),r>0,!1)),s.join("")}function aW(e,t,n){let a=0,r=e.length;if(t){let t=e.codePointAt(a);for(;9===t||32===t;)a++,t=e.codePointAt(a)}if(n){let t=e.codePointAt(r-1);for(;9===t||32===t;)r--,t=e.codePointAt(r-1)}return r>a?e.slice(a,r):""}const rW={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",a={},r=t.lang?t.lang.split(/\s+/):[];r.length>0&&(a.className=["language-"+r[0]]);let s={type:"element",tagName:"code",properties:a,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"===typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",a=String(t.identifier).toUpperCase(),r=Vq(a.toLowerCase()),s=e.footnoteOrder.indexOf(a);let i,o=e.footnoteCounts.get(a);void 0===o?(o=0,e.footnoteOrder.push(a),i=e.footnoteOrder.length):i=s+1,o+=1,e.footnoteCounts.set(a,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),a=e.definitionById.get(n);if(!a)return eW(e,t);const r={src:Vq(a.url||""),alt:t.alt};null!==a.title&&void 0!==a.title&&(r.title=a.title);const s={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,s),e.applyData(t,s)},image:function(e,t){const n={src:Vq(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const a={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,a),e.applyData(t,a)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const a={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,a),e.applyData(t,a)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),a=e.definitionById.get(n);if(!a)return eW(e,t);const r={href:Vq(a.url||"")};null!==a.title&&void 0!==a.title&&(r.title=a.title);const s={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},link:function(e,t){const n={href:Vq(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const a={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},listItem:function(e,t,n){const a=e.all(t),r=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let a=-1;for(;!t&&++a<n.length;)t=tW(n[a])}return t}(n):tW(t),s={},i=[];if("boolean"===typeof t.checked){const e=a[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},a.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<a.length;){const e=a[o];(r||0!==o||"element"!==e.type||"p"!==e.tagName)&&i.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||r?i.push(e):i.push(...e.children)}const l=a[a.length-1];l&&(r||"element"!==l.type||"p"!==l.tagName)&&i.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:s,children:i};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){const n={},a=e.all(t);let r=-1;for("number"===typeof t.start&&1!==t.start&&(n.start=t.start);++r<a.length;){const e=a[r];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(a,!0)};return e.patch(t,s),e.applyData(t,s)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),a=n.shift(),r=[];if(a){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([a],!0)};e.patch(t.children[0],n),r.push(n)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},s=mU(t.children[1]),i=uU(t.children[t.children.length-1]);s&&i&&(a.position={start:s,end:i}),r.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const a=n?n.children:void 0,r=0===(a?a.indexOf(t):1)?"th":"td",s=n&&"table"===n.type?n.align:void 0,i=s?s.length:t.children.length;let o=-1;const l=[];for(;++o<i;){const n=t.children[o],a={},i=s?s[o]:void 0;i&&(a.align=i);let c={type:"element",tagName:r,properties:a,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){const n={type:"text",value:nW(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:sW,yaml:sW,definition:sW,footnoteDefinition:sW};function sW(){}const iW=["children"],oW={}.hasOwnProperty,lW={};function cW(e,t){e.position&&(t.position=function(e){const t=mU(e),n=uU(e);if(t&&n)return{start:t,end:n}}(e))}function dW(e,t){let n=t;if(e&&e.data){const t=e.data.hName,a=e.data.hChildren,r=e.data.hProperties;if("string"===typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&r&&Object.assign(n.properties,Uq(r)),"children"in n&&n.children&&null!==a&&void 0!==a&&(n.children=a)}return n}function uW(e,t){const n=t.data||{},a=!("value"in t)||oW.call(n,"hProperties")||oW.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,a),e.applyData(t,a)}function mW(e,t){const n=[];let a=-1;for(t&&n.push({type:"text",value:"\n"});++a<e.length;)a&&n.push({type:"text",value:"\n"}),n.push(e[a]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function pW(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function hW(e,t){const n=function(e,t){const n=t||lW,a=new Map,r=new Map,s=new Map,i=(0,c.A)((0,c.A)({},rW),n.handlers),o={all:function(e){const t=[];if("children"in e){const n=e.children;let a=-1;for(;++a<n.length;){const r=o.one(n[a],e);if(r){if(a&&"break"===n[a-1].type&&(Array.isArray(r)||"text"!==r.type||(r.value=pW(r.value)),!Array.isArray(r)&&"element"===r.type)){const e=r.children[0];e&&"text"===e.type&&(e.value=pW(e.value))}Array.isArray(r)?t.push(...r):t.push(r)}}}return t},applyData:dW,definitionById:a,footnoteById:r,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,a=o.handlers[n];if(oW.call(o.handlers,n)&&a)return a(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){const{children:t}=e,n=l(e,iW),a=Uq(n);return a.children=o.all(e),a}return Uq(e)}return(o.options.unknownHandler||uW)(o,e,t)},options:n,patch:cW,wrap:mW};return Zq(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?a:r,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o}(e,t),a=n.one(e,void 0),r=function(e){const t="string"===typeof e.o
2ptions.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||qq,a=e.options.footnoteBackLabel||Wq,r=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const r=e.footnoteById.get(e.footnoteOrder[l]);if(!r)continue;const s=e.all(r),i=String(r.identifier).toUpperCase(),c=Vq(i.toLowerCase());let d=0;const u=[],m=e.footnoteCounts.get(i);for(;void 0!==m&&++d<=m;){u.length>0&&u.push({type:"text",value:" "});let e="string"===typeof n?n:n(l,d);"string"===typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"===typeof a?a:a(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const p=s[s.length-1];if(p&&"element"===p.type&&"p"===p.tagName){const e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...u)}else s.push(...u);const h={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(s,!0)};e.patch(r,h),o.push(h)}if(0!==o.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:(0,c.A)((0,c.A)({},Uq(i)),{},{id:"footnote-label"}),children:[{type:"text",value:r}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)}
2,{type:"text",value:"\n"}]}}(n),s=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return r&&s.children.push({type:"text",value:"\n"},r),s}function fW(e,t){return e&&"run"in e?async function(n,a){const r=hW(n,(0,c.A)({file:a},t));await e.run(r,a)}:function(n,a){return hW(n,(0,c.A)({file:a},e||t))}}function xW(e){if(e)throw e}var vW=n(240);function gW(e){if("object"!==typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function yW(){const e=[],t={run:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];let r=-1;const s=n.pop();if("function"!==typeof s)throw new TypeError("Expected function as last argument, not "+s);!function t(a){const i=e[++r];let o=-1;if(a)s(a);else{for(var l=arguments.length,c=new Array(l>1?l-1:0),d=1;d<l;d++)c[d-1]=arguments[d];for(;++o<n.length;)null!==c[o]&&void 0!==c[o]||(c[o]=n[o]);n=c,i?function(e,t){let n;return r;function r(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];const l=e.length>r.length;let c;l&&r.push(s);try{c=e.apply(this,r)}catch(a){if(l&&n)throw a;return s(a)}l||(c&&c.then&&"function"===typeof c.then?c.then(i,s):c instanceof Error?s(c):i(c))}function s(e){if(!n){n=!0;for(var a=arguments.length,r=new Array(a>1?a-1:0),s=1;s<a;s++)r[s-1]=arguments[s];t(e,...r)}}function i(e){s(null,e)}}(i,t)(...c):s(null,...c)}}(null,...n)},use:function(n){if("function"!==typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const bW={basename:function(e,t){if(void 0!==t&&"string"!==typeof t)throw new TypeError('"ext" argument must be a string');wW(e);let n,a=0,r=-1,s=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;s--;)if(47===e.codePointAt(s)){if(n){a=s+1;break}}else r<0&&(n=!0,r=s+1);return r<0?"":e.slice(a,r)}if(t===e)return"";let i=-1,o=t.length-1;for(;s--;)if(47===e.codePointAt(s)){if(n){a=s+1;break}}else i<0&&(n=!0,i=s+1),o>-1&&(e.codePointAt(s)===t.codePointAt(o--)?o<0&&(r=s):(o=-1,r=i));a===r?r=i:r<0&&(r=e.length);return e.slice(a,r)},dirname:function(e){if(wW(e),0===e.length)return".";let t,n=-1,a=e.length;for(;--a;)if(47===e.codePointAt(a)){if(t){n=a;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){wW(e);let t,n=e.length,a=-1,r=0,s=-1,i=0;for(;n--;){const o=e.codePointAt(n);if(47!==o)a<0&&(t=!0,a=n+1),46===o?s<0?s=n:1!==i&&(i=1):s>-1&&(i=-1);else if(t){r=n+1;break}}if(s<0||a<0||0===i||1===i&&s===a-1&&s===r+1)return"";return e.slice(s,a)},join:function(){let e,t=-1;for(var n=arguments.length,a=new Array(n),r=0;r<n;r++)a[r]=arguments[r];for(;++t<a.length;)wW(a[t]),a[t]&&(e=void 0===e?a[t]:e+"/"+a[t]);return void 0===e?".":function(e){wW(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,a,r="",s=0,i=-1,o=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else{if(47===n)break;n=47}if(47===n){if(i===l-1||1===o);else if(i!==l-1&&2===o){if(r.length<2||2!==s||46!==r.codePointAt(r.length-1)||46!==r.codePointAt(r.length-2))if(r.length>2){if(a=r.lastIndexOf("/"),a!==r.length-1){a<0?(r="",s=0):(r=r.slice(0,a),s=r.length-1-r.lastIndexOf("/")),i=l,o=0;continue}}else if(r.length>0){r="",s=0,i=l,o=0;continue}t&&(r=r.length>0?r+"/..":"..",s=2)}else r.length>0?r+="/"+e.slice(i+1,l):r=e.slice(i+1,l),s=l-i-1;i=l,o=0}else 46===n&&o>-1?o++:o=-1}return r}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(e)},sep:"/"};function wW(e){if("string"!==typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const jW={cwd:function(){return"/"}};function kW(e){return Boolean(null!==e&&"object"===typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function NW(e){if("string"===typeof e)e=new URL(e);else if(!kW(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const _W=["history","path","basename","stem","extname","dirname"];class DW{constructor(e){let t;t=e?kW(e)?{path:e}:"string"===typeof e||function(e){return Boolean(e&&"object"===typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":jW.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,a=-1;for(;++a<_W.length;){const e=_W[a];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)_W.includes(n)||(this[n]=t[n])}get basename(){return"string"===typeof this.path?bW.basename(this.path):void 0}
vendor: 9,359 bytes, line 2
2set basename(e){AW(e,"basename"),CW(e,"basename"),this.path=bW.join(this.dirname||"",e)}get dirname(){return"string"===typeof this.path?bW.dirname(this.path):void 0}set dirname(e){SW(this.basename,"dirname"),this.path=bW.join(e||"",this.basename)}get extname(){return"string"===typeof this.path?bW.extname(this.path):void 0}set extname(e){if(CW(e,"extname"),SW(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=bW.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){kW(e)&&(e=NW(e)),AW(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"===typeof this.path?bW.basename(this.path,this.extname):void 0}set stem(e){AW(e,"stem"),CW(e,"stem"),this.path=bW.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const a=this.message(e,t,n);throw a.fatal=!0,a}info(e,t,n){const a=this.message(e,t,n);return a.fatal=void 0,a}message(e,t,n){const a=new gU(e,t,n);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(e){if(void 0===this.value)return"";if("string"===typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function CW(e,t){if(e&&e.includes(bW.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+bW.sep+"`")}function AW(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function SW(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const EW=function(e){const t=this.constructor.prototype,n=t[e],a=function(){return n.apply(a,arguments)};return Object.setPrototypeOf(a,t),a},FW={}.hasOwnProperty;class RW extends EW{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=yW()}copy(){const e=new RW;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(vW(!0,{},this.namespace)),e}data(e,t){return"string"===typeof e?2===arguments.length?(OW("data",this.frozen),this.namespace[e]=t,this):FW.call(this.namespace,e)&&this.namespace[e]||void 0:e?(OW("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const a=t.call(e,...n);"function"===typeof a&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=MW(e),n=this.parser||this.Parser;return TW("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),TW("process",this.parser||this.Parser),PW("process",this.compiler||this.Compiler),t?a(void 0,t):new Promise(a);function a(a,r){const s=MW(e),i=n.parse(s);function o(e,n){e||!n?r(e):a?a(n):t(void 0,n)}n.run(i,s,function(e,t,a){if(e||!t||!a)return o(e);const r=t,s=n.stringify(r,a);var i;"string"===typeof(i=s)||function(e){return Boolean(e&&"object"===typeof e&&"byteLength"in e&&"byteOffset"in e)}(i)?a.value=s:a.result=s,o(e,a)})}}processSync(e){let t,n=!1;return this.freeze(),TW("processSync",this.parser||this.Parser),PW("processSync",this.compiler||this.Compiler),this.process(e,function(e,a){n=!0,xW(e),t=a}),LW("processSync","process",n),t}run(e,t,n){BW(e),this.freeze();const a=this.transformers;return n||"function"!==typeof t||(n=t,t=void 0),n?r(void 0,n):new Promise(r);function r(r,s){const i=MW(t);a.run(e,i,function(t,a,i){const o=a||e;t?s(t):r?r(o):n(void 0,o,i)})}}runSync(e,t){let n,a=!1;return this.run(e,t,function(e,t){xW(e),n=t,a=!0}),LW("runSync","run",a),n}stringify(e,t){this.freeze();const n=MW(t),a=this.compiler||this.Compiler;return PW("stringify",a),BW(e),a(e,n)}use(e){const t=this.attachers,n=this.namespace;if(OW("use",this.frozen),null===e||void 0===e);else if("function"===typeof e){for(var a=arguments.length,r=new Array(a>1?a-1:0),s=1;s<a;s++)r[s-1]=arguments[s];c(e,r)}else{if("object"!==typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?l(e):o(e)}return this;function i(e){if("function"===typeof e)c(e,[]);else{if("object"!==typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;c(t,n)}else o(e)}}function o(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(e.plugins),e.settings&&(n.settings=vW(!0,n.settings,e.settings))}function l(e){let t=-1;if(null===e||void 0===e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){i(e[t])}}}function c(e,n){let a=-1,r=-1;for(;++a<t.length;)if(t[a][0]===e){r=a;break}if(-1===r)t.push([e,...n]);else if(n.length>0){let[a,...s]=n;const i=t[r][1];gW(i)&&gW(a)&&(a=vW(!0,i,a)),t[r]=[e,a,...s]}}}}const IW=(new RW).freeze();function TW(e,t){if("function"!==typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function PW(e,t){if("function"!==typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function OW(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function BW(e){if(!gW(e)||"string"!==typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function LW(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function MW(e){return function(e){return Boolean(e&&"object"===typeof e&&"message"in e&&"messages"in e)}(e)?e:new DW(e)}const zW=[],UW={allowDangerousHtml:!0},VW=/^(https?|ircs?|mailto|xmpp)$/i,qW=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function WW(e){const t=HW(e),n=GW(e);return KW(t.runSync(t.parse(n),n),e)}function HW(e){const t=e.rehypePlugins||zW,n=e.remarkPlugins||zW,a=e.remarkRehypeOptions?(0,c.A)((0,c.A)({},e.remarkRehypeOptions),UW):UW;return IW().use(Fq).use(n).use(fW,a).use(t)}function GW(e){const t=e.children||"",n=new DW;return"string"===typeof t&&(n.value=t),n}function KW(e,t){const n=t.allowedElements,a=t.allowElement,r=t.components,s=t.disallowedElements,i=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||YW;for(const c of qW)Object.hasOwn(t,c.from)&&Nz((c.from,c.to&&c.to,c.id));return Zq(e,function(e,t,r){if("raw"===e.type&&r&&"number"===typeof t)return i?r.children.splice(t,1):r.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in PU)if(Object.hasOwn(PU,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],a=PU[t];(null===a||a.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let i=n?!n.includes(e.tagName):!!s&&s.includes(e.tagName);if(!i&&a&&"number"===typeof t&&(i=!a(e,t,r)),i&&r&&"number"===typeof t)return o&&e.children?r.children.splice(t,1,...e.children):r.children.splice(t,1),t}}),_U(e,{Fragment:Xt.Fragment,components:r,ignoreInvalidStyle:!0,jsx:Xt.jsx,jsxs:Xt.jsxs,passKeys:!0,passNode:!0})}function YW(e){const t=e.indexOf(":"),n=e.indexOf("?"),a=e.indexOf("#"),r=e.indexOf("/");return-1===t||-1!==r&&t>r||-1!==n&&t>n||-1!==a&&t>a||VW.test(e.slice(0,t))?e:""}function JW(e,t){const n=String(e);if("string"!==typeof t)throw new TypeError("Expected character");let a=0,r=n.indexOf(t);for(;-1!==r;)a++,r=n.indexOf(t,r+t.length);return a}function $W(e,t,n){const a=Hq((n||{}).ignore||[]),r=function(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let a=-1;for(;++a<n.length;){const e=n[a];t.push([XW(e[0]),QW(e[1])])}return t}(t);let s=-1;for(;++s<r.length;)Qq(e,"text",i);function i(e,t){let n,i=-1;for(;++i<t.length;){const e=t[i],r=n?n.children:void 0;if(a(e,r?r.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){const n=t[t.length-1],a=r[s][0],i=r[s][1];let o=0;const l=n.children.indexOf(e);let c=!1,d=[];a.lastIndex=0;let u=a.exec(e.value);for(;u;){const n=u.index,r={index:u.index,input:u.input,stack:[...t,e]};let s=i(...u,r);
2if("string"===typeof s&&(s=s.length>0?{type:"text",value:s}:void 0),!1===s?a.lastIndex=n+1:(o!==n&&d.push({type:"text",value:e.value.slice(o,n)}),Array.isArray(s)?d.push(...s):s&&d.push(s),o=n+u[0].length,c=!0),!a.global)break;u=a.exec(e.value)}c?(o<e.value.length&&d.push({type:"text",value:e.value.slice(o)}),n.children.splice(l,1,...d)):d=[e];return l+d.length}(e,t)}}function XW(e){return"string"===typeof e?new RegExp(function(e){if("string"!==typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(e),"g"):e}function QW(e){return"function"===typeof e?e:function(){return e}}const ZW="phrasing",eH=["autolink","link","image","label"];function tH(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function nH(e){this.config.enter.autolinkProtocol.call(this,e)}function aH(e){this.config.exit.autolinkProtocol.call(this,e)}function rH(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function sH(e){this.config.exit.autolinkEmail.call(this,e)}function iH(e){this.exit(e)}function oH(e){$W(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,lH],[/(?<=^|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]|(?:[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B60\u1B7D-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDEAD\uDED0\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F])|(?:[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uD
2F3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]))([\+\x2D\.0-9A-Z_a-z]+)@([\x2D0-9A-Z_a-z]+(?:\.[\x2D0-9A-Z_a-z]+)+)/g,cH]],{ignore:["link","linkReference"]})}function lH(e,t,n,a,r){let s="";if(!dH(r))return!1;if(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!function(e){const t=e.split(".");if(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))return!1;return!0}(n))return!1;const i=function(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],a=n.indexOf(")");const r=JW(e,"(");let s=JW(e,")");for(;-1!==a&&r>s;)e+=n.slice(0,a+1),n=n.slice(a+1),a=n.indexOf(")"),s++;return[e,n]}(n+a);if(!i[0])return!1;const o={type:"link",title:null,url:s+t+i[0],children:[{type:"text",value:t+i[0]}]};return i[1]?[o,{type:"text",value:i[1]}]:o}function cH(e,t,n,a){return!(!dH(a,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function dH(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||oV(n)||iV(n))&&(!t||47!==n)}function uH(){this.buffer()}function mH(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function pH(){this.buffer()}function hH(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function fH(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=RV(this.sliceSerialize(e)).toLowerCase(),n.label=t}function xH(e){this.exit(e)}function vH(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=RV(this.sliceSerialize(e)).toLowerCase(),n.label=t}function gH(e){this.exit(e)}function yH(e,t,n,a){const r=n.createTracker(a);let s=r.move("[^");const i=n.enter("footnoteReference"),o=n.enter("reference");return s+=r.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),i(),s+=r.move("]"),s}function bH(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:function(e,n,a,r){const s=a.createTracker(r);let i=s.move("[^");const o=a.enter("footnoteDefinition"),l=a.enter("label");i+=s.move(a.safe(a.associationId(e),{before:i,after:"]"})),l(),i+=s.move("]:"),e.children&&e.children.length>0&&(s.shift(4),i+=s.move((t?"\n":" ")+a.indentLines(a.containerFlow(e,s.current()),t?jH:wH)));return o(),i},footnoteReference:yH},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function wH(e,t,n){return 0===t?e:jH(e,t,n)}function jH(e,t,n){return(n?"":" ")+e}yH.peek=function(){return"["};const kH=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function NH(e){this.enter({type:"delete",children:[]},e)}function _H(e){this.exit(e)}function DH(e,t,n,a){const r=n.createTracker(a),s=n.enter("strikethrough");let i=r.move("~~");return i+=n.containerPhrasing(e,(0,c.A)((0,c.A)({},r.current()),{},{before:i,after:"~"})),i+=r.move("~~"),s(),i}function CH(e){return e.length}function AH(e){return null===e||void 0===e?"":String(e)}function SH(e){const t="string"===typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}
vendor: 7,103 bytes, line 2
2function EH(e,t,n){return">"+(n?"":" ")+e}function FH(e,t){return RH(e,t.inConstruct,!0)&&!RH(e,t.notInConstruct,!1)}function RH(e,t,n){if("string"===typeof t&&(t=[t]),!t||0===t.length)return n;let a=-1;for(;++a<t.length;)if(e.includes(t[a]))return!0;return!1}function IH(e,t,n,a){let r=-1;for(;++r<n.unsafe.length;)if("\n"===n.unsafe[r].character&&FH(n.stack,n.unsafe[r]))return/[ \t]/.test(a.before)?"":" ";return"\\\n"}function TH(e,t,n){return(n?"":" ")+e}function PH(e){const t=e.options.quote||'"';if('"'!==t&&"'"!==t)throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function OH(e){return"&#x"+e.toString(16).toUpperCase()+";"}function BH(e,t,n){const a=aq(e),r=aq(t);return void 0===a?void 0===r?"_"===n?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===r?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===a?void 0===r?{inside:!1,outside:!1}:1===r?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===r?{inside:!1,outside:!1}:1===r?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function LH(e,t,n,a){const r=function(e){const t=e.options.emphasis||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}(n),s=n.enter("emphasis"),i=n.createTracker(a),o=i.move(r);let l=i.move(n.containerPhrasing(e,(0,c.A)({after:r,before:o},i.current())));const d=l.charCodeAt(0),u=BH(a.before.charCodeAt(a.before.length-1),d,r);u.inside&&(l=OH(d)+l.slice(1));const m=l.charCodeAt(l.length-1),p=BH(a.after.charCodeAt(0),m,r);p.inside&&(l=l.slice(0,-1)+OH(m));const h=i.move(r);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},o+l+h}function MH(e){return e.value||""}function zH(e,t,n,a){const r=PH(n),s='"'===r?"Quote":"Apostrophe",i=n.enter("image");let o=n.enter("label");const l=n.createTracker(a);let d=l.move("![");return d+=l.move(n.safe(e.alt,(0,c.A)({before:d,after:"]"},l.current()))),d+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),d+=l.move("<"),d+=l.move(n.safe(e.url,(0,c.A)({before:d,after:">"},l.current()))),d+=l.move(">")):(o=n.enter("destinationRaw"),d+=l.move(n.safe(e.url,(0,c.A)({before:d,after:e.title?" ":")"},l.current())))),o(),e.title&&(o=n.enter("title".concat(s)),d+=l.move(" "+r),d+=l.move(n.safe(e.title,(0,c.A)({before:d,after:r},l.current()))),d+=l.move(r),o()),d+=l.move(")"),i(),d}function UH(e,t,n,a){const r=e.referenceType,s=n.enter("imageReference");let i=n.enter("label");const o=n.createTracker(a);let l=o.move("![");const d=n.safe(e.alt,(0,c.A)({before:l,after:"]"},o.current()));l+=o.move(d+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const m=n.safe(n.associationId(e),(0,c.A)({before:l,after:"]"},o.current()));return i(),n.stack=u,s(),"full"!==r&&d&&d===m?"shortcut"===r?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(m+"]"),l}function VH(e,t,n){let a=e.value||"",r="`",s=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(a);)r+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++s<n.unsafe.length;){const e=n.unsafe[s],t=n.compilePattern(e);let r;if(e.atBreak)for(;r=t.exec(a);){let e=r.index;10===a.charCodeAt(e)&&13===a.charCodeAt(e-1)&&e--,a=a.slice(0,e)+" "+a.slice(r.index+1)}}return r+a+r}function qH(e,t){const n=BU(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function WH(e,t,n,a){const r=PH(n),s='"'===r?"Quote":"Apostrophe",i=n.createTracker(a);let o,l;if(qH(e,n)){const t=n.stack;n.stack=[],o=n.enter("autolink");let a=i.move("<");return a+=i.move(n.containerPhrasing(e,(0,c.A)({before:a,after:">"},i.current()))),a+=i.move(">"),o(),n.stack=t,a}o=n.enter("link"),l=n.enter("label");let d=i.move("[");return d+=i.move(n.containerPhrasing(e,(0,c.A)({before:d,after:"]("},i.current()))),d+=i.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),d+=i.move("<"),d+=i.move(n.safe(e.url,(0,c.A)({before:d,after:">"},i.current()))),d+=i.move(">")):(l=n.enter("destinationRaw"),d+=i.move(n.safe(e.url,(0,c.A)({before:d,after:e.title?" ":")"},i.current())))),l(),e.title&&(l=n.enter("title".concat(s)),d+=i.move(" "+r),d+=i.move(n.safe(e.title,(0,c.A)({before:d,after:r},i.current()))),d+=i.move(r),l()),d+=i.move(")"),o(),d}function HH(e,t,n,a){const r=e.referenceType,s=n.enter("linkReference");let i=n.enter("label");const o=n.createTracker(a);let l=o.move("[");const d=n.containerPhrasing(e,(0,c.A)({before:l,after:"]"},o.current()));l+=o.move(d+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const m=n.safe(n.associationId(e),(0,c.A)({before:l,after:"]"},o.current()));return i(),n.stack=u,s(),"full"!==r&&d&&d===m?"shortcut"===r?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(m+"]"),l}function GH(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function KH(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}DH.peek=function(){return"~"},LH.peek=function(e,t,n){return n.options.emphasis||"*"},MH.peek=function(){return"<"},zH.peek=function(){return"!"},UH.peek=function(){return"!"},VH.peek=function(){return"`"},WH.peek=function(e,t,n){return qH(e,n)?"<":"["},HH.peek=function(){return"["};const YH=Hq(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function JH(e,t,n,a){const r=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),s=n.enter("strong"),i=n.createTracker(a),o=i.move(r+r);let l=i.move(n.containerPhrasing(e,(0,c.A)({after:r,before:o},i.current())));const d=l.charCodeAt(0),u=BH(a.before.charCodeAt(a.before.length-1),d,r);u.inside&&(l=OH(d)+l.slice(1));const m=l.charCodeAt(l.length-1),p=BH(a.after.charCodeAt(0),m,r);p.inside&&(l=l.slice(0,-1)+OH(m));const h=i.move(r+r);return s(),n.attentionEncodeSurroundingInfo={after:p.outside,before:u.outside},o+l+h}JH.peek=function(e,t,n){return n.options.strong||"*"};const $H={blockquote:function(e,t,n,a){const r=n.enter("blockquote"),s=n.createTracker(a);s.move("> "),s.shift(2);const i=n.indentLines(n.containerFlow(e,s.current()),EH);return r(),i},break:IH,code:function(e,t,n,a){const r=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),s=e.value||"",i="`"===r?"GraveAccent":"Tilde";if(function(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}
2(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(s,TH);return e(),t}const o=n.createTracker(a),l=r.repeat(Math.max(function(e,t){const n=String(e);let a=n.indexOf(t),r=a,s=0,i=0;if("string"!==typeof t)throw new TypeError("Expected substring");for(;-1!==a;)a===r?++s>i&&(i=s):s=1,r=a+t.length,a=n.indexOf(t,r);return i}(s,r)+1,3)),d=n.enter("codeFenced");let u=o.move(l);if(e.lang){const t=n.enter("codeFencedLang".concat(i));u+=o.move(n.safe(e.lang,(0,c.A)({before:u,after:" ",encode:["`"]},o.current()))),t()}if(e.lang&&e.meta){const t=n.enter("codeFencedMeta".concat(i));u+=o.move(" "),u+=o.move(n.safe(e.meta,(0,c.A)({before:u,after:"\n",encode:["`"]},o.current()))),t()}return u+=o.move("\n"),s&&(u+=o.move(s+"\n")),u+=o.move(l),d(),u},definition:function(e,t,n,a){const r=PH(n),s='"'===r?"Quote":"Apostrophe",i=n.enter("definition");let o=n.enter("label");const l=n.createTracker(a);let d=l.move("[");return d+=l.move(n.safe(n.associationId(e),(0,c.A)({before:d,after:"]"},l.current()))),d+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),d+=l.move("<"),d+=l.move(n.safe(e.url,(0,c.A)({before:d,after:">"},l.current()))),d+=l.move(">")):(o=n.enter("destinationRaw"),d+=l.move(n.safe(e.url,(0,c.A)({before:d,after:e.title?" ":"\n"},l.current())))),o(),e.title&&(o=n.enter("title".concat(s)),d+=l.move(" "+r),d+=l.move(n.safe(e.title,(0,c.A)({before:d,after:r},l.current()))),d+=l.move(r),o()),i(),d},emphasis:LH,hardBreak:IH,heading:function(e,t,n,a){const r=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(a);if(function(e,t){let n=!1;return Zq(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,Xq}),Boolean((!e.depth||e.depth<3)&&BU(e)&&(t.options.setext||n))}(e,n)){const t=n.enter("headingSetext"),a=n.enter("phrasing"),i=n.containerPhrasing(e,(0,c.A)((0,c.A)({},s.current()),{},{before:"\n",after:"\n"}));return a(),t(),i+"\n"+(1===r?"=":"-").repeat(i.length-(Math.max(i.lastIndexOf("\r"),i.lastIndexOf("\n"))+1))}const i="#".repeat(r),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(i+" ");let d=n.containerPhrasing(e,(0,c.A)({before:"# ",after:"\n"},s.current()));return/^[\t ]/.test(d)&&(d=OH(d.charCodeAt(0))+d.slice(1)),d=d?i+" "+d:i,n.options.closeAtx&&(d+=" "+i),l(),o(),d},html:MH,image:zH,imageReference:UH,inlineCode:VH,link:WH,linkReference:HH,list:function(e,t,n,a){const r=n.enter("list"),s=n.bulletCurrent;let i=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):GH(n);const o=e.ordered?"."===i?")":".":function(e){const t=GH(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n);let l=!(!t||!n.bulletLastUsed)&&i===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==i&&"-"!==i||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(l=!0),KH(n)===i&&t){let t=-1;for(;++t<e.children.length;){const n=e.children[t];if(n&&"listItem"===n.type&&n.children&&n.children[0]&&"thematicBreak"===n.children[0].type){l=!0;break}}}}l&&(i=o),n.bulletCurrent=i;const c=n.containerFlow(e,a);return n.bulletLastUsed=i,n.bulletCurrent=s,r(),c},listItem:function(e,t,n,a){const r=function(e){const t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n);let s=n.bulletCurrent||GH(n);t&&"list"===t.type&&t.ordered&&(s=("number"===typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+s);let i=s.length+1;("tab"===r||"mixed"===r&&(t&&"list"===t.type&&t.spread||e.spread))&&(i=4*Math.ceil(i/4));const o=n.createTracker(a);o.move(s+" ".repeat(i-s.length)),o.shift(i);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),function(e,t,n){if(t)return(n?"":" ".repeat(i))+e;return(n?s:s+" ".repeat(i-s.length))+e});return l(),c},paragraph:function(e,t,n,a){const r=n.enter("paragraph"),s=n.enter("phrasing"),i=n.containerPhrasing(e,a);return s(),r(),i},root:function(e,t,n,a){return(e.children.some(function(e){return YH(e)})?n.containerPhrasing:n.containerFlow).call(n,e,a)},strong:JH,text:function(e,t,n,a){return n.safe(e.value,a)},thematicBreak:function(e,t,n){const a=(KH(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?a.slice(0,-1):a}};function XH(e){const t=e._align;this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function QH(e){this.exit(e),this.data.inTable=void 0}function ZH(e){this.enter({type:"tableRow",children:[]},e)}function eG(e){this.exit(e)}function tG(e){this.enter({type:"tableCell",children:[]},e)}function nG(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,aG));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function aG(e,t){return"|"===t?t:e}function rG(e){const t=e||{},n=t.tableCellPadding,a=t.tablePipeAlign,r=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}
vendor: 12,838 bytes, line 2
2],handlers:{inlineCode:function(e,t,n){let a=$H.inlineCode(e,t,n);n.stack.includes("tableCell")&&(a=a.replace(/\|/g,"\\$&"));return a},table:function(e,t,n,a){return o(function(e,t,n){const a=e.children;let r=-1;const s=[],i=t.enter("table");for(;++r<a.length;)s[r]=l(a[r],t,n);return i(),s}(e,n,a),e.align)},tableCell:i,tableRow:function(e,t,n,a){const r=l(e,n,a),s=o([r]);return s.slice(0,s.indexOf("\n"))}}};function i(e,t,n,a){const r=n.enter("tableCell"),i=n.enter("phrasing"),o=n.containerPhrasing(e,(0,c.A)((0,c.A)({},a),{},{before:s,after:s}));return i(),r(),o}function o(e,t){return function(e,t){const n=t||{},a=(n.align||[]).concat(),r=n.stringLength||CH,s=[],i=[],o=[],l=[];let c=0,d=-1;for(;++d<e.length;){const t=[],a=[];let s=-1;for(e[d].length>c&&(c=e[d].length);++s<e[d].length;){const i=AH(e[d][s]);if(!1!==n.alignDelimiters){const e=r(i);a[s]=e,(void 0===l[s]||e>l[s])&&(l[s]=e)}t.push(i)}i[d]=t,o[d]=a}let u=-1;if("object"===typeof a&&"length"in a)for(;++u<c;)s[u]=SH(a[u]);else{const e=SH(a);for(;++u<c;)s[u]=e}u=-1;const m=[],p=[];for(;++u<c;){const e=s[u];let t="",a="";99===e?(t=":",a=":"):108===e?t=":":114===e&&(a=":");let r=!1===n.alignDelimiters?1:Math.max(1,l[u]-t.length-a.length);const i=t+"-".repeat(r)+a;!1!==n.alignDelimiters&&(r=t.length+r+a.length,r>l[u]&&(l[u]=r),p[u]=r),m[u]=i}i.splice(1,0,m),o.splice(1,0,p),d=-1;const h=[];for(;++d<i.length;){const e=i[d],t=o[d];u=-1;const a=[];for(;++u<c;){const r=e[u]||"";let i="",o="";if(!1!==n.alignDelimiters){const e=l[u]-(t[u]||0),n=s[u];114===n?i=" ".repeat(e):99===n?e%2?(i=" ".repeat(e/2+.5),o=" ".repeat(e/2-.5)):(i=" ".repeat(e/2),o=i):o=" ".repeat(e)}!1===n.delimiterStart||u||a.push("|"),!1===n.padding||!1===n.alignDelimiters&&""===r||!1===n.delimiterStart&&!u||a.push(" "),!1!==n.alignDelimiters&&a.push(i),a.push(r),!1!==n.alignDelimiters&&a.push(o),!1!==n.padding&&a.push(" "),!1===n.delimiterEnd&&u===c-1||a.push("|")}h.push(!1===n.delimiterEnd?a.join("").replace(/ +$/,""):a.join(""))}return h.join("\n")}(e,{align:t,alignDelimiters:a,padding:n,stringLength:r})}function l(e,t,n){const a=e.children;let r=-1;const s=[],o=t.enter("tableRow");for(;++r<a.length;)s[r]=i(a[r],0,t,n);return o(),s}}function sG(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function iG(e){const t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"===typeof t.checked){const e=this.stack[this.stack.length-1];e.type;const n=e.children[0];if(n&&"text"===n.type){const a=t.children;let r,s=-1;for(;++s<a.length;){const e=a[s];if("paragraph"===e.type){r=e;break}}r===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"===typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function oG(e,t,n,a){const r=e.children[0],s="boolean"===typeof e.checked&&r&&"paragraph"===r.type,i="["+(e.checked?"x":" ")+"] ",o=n.createTracker(a);s&&o.move(i);let l=$H.listItem(e,t,n,(0,c.A)((0,c.A)({},a),o.current()));return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+i})),l}const lG={tokenize:function(e,t,n){let a=0;return function t(s){if((87===s||119===s)&&a<3)return a++,e.consume(s),t;if(46===s&&3===a)return e.consume(s),r;return n(s)};function r(e){return null===e?n(e):t(e)}},partial:!0},cG={tokenize:function(e,t,n){let a,r,s;return i;function i(t){return 46===t||95===t?e.check(uG,l,o)(t):null===t||rV(t)||oV(t)||45!==t&&iV(t)?l(t):(s=!0,e.consume(t),i)}function o(t){return 95===t?a=!0:(r=a,a=void 0),e.consume(t),i}function l(e){return r||a||!s?n(e):t(e)}},partial:!0},dG={tokenize:function(e,t){let n=0,a=0;return r;function r(i){return 40===i?(n++,e.consume(i),r):41===i&&a<n?s(i):33===i||34===i||38===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||60===i||63===i||93===i||95===i||126===i?e.check(uG,t,s)(i):null===i||rV(i)||oV(i)?t(i):(e.consume(i),r)}function s(t){return 41===t&&a++,e.consume(t),r}},partial:!0},uG={tokenize:function(e,t,n){return a;function a(i){return 33===i||34===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||63===i||95===i||126===i?(e.consume(i),a):38===i?(e.consume(i),s):93===i?(e.consume(i),r):60===i||null===i||rV(i)||oV(i)?t(i):n(i)}function r(e){return null===e||40===e||91===e||rV(e)||oV(e)?t(e):a(e)}function s(e){return $U(e)?i(e):n(e)}function i(t){return 59===t?(e.consume(t),a):$U(t)?(e.consume(t),i):n(t)}},partial:!0},mG={tokenize:function(e,t,n){return function(t){return e.consume(t),a};function a(e){return XU(e)?n(e):t(e)}},partial:!0},pG={name:"wwwAutolink",tokenize:function(e,t,n){const a=this;return function(t){if(87!==t&&119!==t||!gG.call(a,a.previous)||jG(a.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(lG,e.attempt(cG,e.attempt(dG,r),n),n)(t)};function r(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:gG},hG={name:"protocolAutolink",tokenize:function(e,t,n){const a=this;let r="",s=!1;return function(t){if((72===t||104===t)&&yG.call(a,a.previous)&&!jG(a.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(t),e.consume(t),i;return n(t)};function i(t){if($U(t)&&r.length<5)return r+=String.fromCodePoint(t),e.consume(t),i;if(58===t){const n=r.toLowerCase();if("http"===n||"https"===n)return e.consume(t),o}return n(t)}function o(t){return 47===t?(e.consume(t),s?l:(s=!0,o)):n(t)}function l(t){return null===t||ZU(t)||rV(t)||oV(t)||iV(t)?n(t):e.attempt(cG,e.attempt(dG,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:yG},fG={name:"emailAutolink",tokenize:function(e,t,n){const a=this;let r,s;return function(t){if(!wG(t)||!bG.call(a,a.previous)||jG(a.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(t)};function i(t){return wG(t)?(e.consume(t),i):64===t?(e.consume(t),o):n(t)}function o(t){return 46===t?e.check(mG,c,l)(t):45===t||95===t||XU(t)?(s=!0,e.consume(t),o):c(t)}function l(t){return e.consume(t),r=!0,o}function c(i){return s&&r&&$U(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(i)):n(i)}},previous:bG},xG={};let vG=48;for(;vG<123;)xG[vG]=fG,vG++,58===vG?vG=65:91===vG&&(vG=97);function gG(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||rV(e)}function yG(e){return!$U(e)}function bG(e){return!(47===e||wG(e))}function wG(e){return 43===e||45===e||46===e||95===e||XU(e)}function jG(e){let t=e.length,n=!1;for(;t--;){const a=e[t][1];if(("labelLink"===a.type||"labelImage"===a.type)&&!a._balanced){n=!0;break}if(a._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}xG[43]=fG,xG[45]=fG,xG[46]=fG,xG[95]=fG,xG[72]=[fG,hG],xG[104]=[fG,hG],xG[87]=[fG,pG],xG[119]=[fG,pG];const kG={tokenize:function(e,t,n){const a=this;return cV(e,function(e){const r=a.events[a.events.length-1];return r&&"gfmFootnoteDefinitionIndent"===r[1].type&&4===r[2].sliceSerialize(r[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function NG(e,t,n){const a=this;let r=a.events.length;const s=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let i;for(;r--;){const e=a.events[r][1];if("labelImage"===e.type){i=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(r){if(!i||!i._balanced)return n(r);const o=RV(a.sliceSerialize({start:i.end,end:a.now()}));if(94!==o.codePointAt(0)||!s.includes(o.slice(1)))return n(r);return e.enter("gfmFootnoteCallLabelMarker"),e.consume(r),e.exit("gfmFootnoteCallLabelMarker"),t(r)}}function _G(e,t){let n,a=e.length;for(;a--;)if("labelImage"===e[a][1].type&&"enter"===e[a][0]){n=e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[e[a+1],e[a+2],["enter",r,t],e[a+3],e[a+4],["enter",s,t],["exit",s,t],["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(a,e.length-a+1,...l),e}function DG(e,t,n){const a=this,r=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let s,i=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),o};function o(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(o){if(i>999||93===o&&!s||null===o||91===o||rV(o))return n(o);if(93===o){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return r.includes(RV(a.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return rV(o)||(s=!0),i++,e.consume(o),92===o?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),i++,l):l(t)}}function CG(e,t,n){const a=this,r=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let s,i,o=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(o>999||93===t&&!i||null===t||91===t||rV(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return s=RV(a.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),u}return rV(t)||(i=!0),o++,e.consume(t),92===t?d:c}function d(t){return 91===t||92===t||93===t?(e.consume(t),o++,c):c(t)}function u(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),r.includes(s)||r.push(s),cV(e,m,"gfmFootnoteDefinitionWhitespace")):n(t)}function m(e){return t(e)}}function AG(e,t,n){return e.check(pV,t,e.attempt(kG,t,n))}function SG(e){e.exit("gfmFootnoteDefinition")}function EG(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:function(e,n,a){const r=this.previous,s=this.events;let i=0;return function(t){if(126===r&&"characterEscape"!==s[s.length-1][1].type)return a(t);return e.enter("strikethroughSequenceTemporary"),o(t)};function o(s){const l=aq(r);if(126===s)return i>1?a(s):(e.consume(s),i++,o);if(i<2&&!t)return a(s);const c=e.exit("strikethroughSequenceTemporary"),d=aq(s);return c._open=!d||2===d&&Boolean(l),c._close=!l||2===l&&Boolean(d),n(s)}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let a=n;for(;a--;)if("exit"===e[a][0]&&"strikethroughSequenceTemporary"===e[a][1].type&&e[a][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[a][1].end.offset-e[a][1].start.offset){e[n][1].type="strikethroughSequence",e[a][1].type="strikethroughSequence";const r={type:"strikethrough",start:Object.assign({},e[a][1].start),end:Object.assign({},e[n][1].end)},s={type:"strikethroughText",start:Object.assign({},e[a][1].end),end:Object.assign({},e[n][1].start)},i=[["enter",r,t],["enter",e[a][1],t],["exit",e[a][1],t],["enter",s,t]],o=t.parser.constructs.insideSpan.null;o&&zU(i,i.length,0,XV(o,e.slice(a+1,n),t)),zU(i,i.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",r,t]]),zU(e,a-1,n-a+3,i),n=a+i.length-2;break}}n=-1;for(;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}};return null!==t&&void 0!==t||(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}}class FG{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,a){let r=0;if(0===n&&0===a.length)return;for(;r<e.map.length;){if(e.map[r][0]===t)return e.map[r][1]+=n,void e.map[r][2].push(...a);r+=1}e.map.push([t,n,a])}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length;const n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let a=n.pop();for(;a;
vendor: 2,960 bytes, line 2
2){for(const t of a)e.push(t);a=n.pop()}this.map.length=0}}function RG(e,t){let n=!1;const a=[];for(;t<e.length;){const r=e[t];if(n){if("enter"===r[0])"tableContent"===r[1].type&&a.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===r[1].type){if("tableDelimiterMarker"===e[t-1][1].type){const e=a.length-1;a[e]="left"===a[e]?"center":"right"}}else if("tableDelimiterRow"===r[1].type)break}else"enter"===r[0]&&"tableDelimiterRow"===r[1].type&&(n=!0);t+=1}return a}function IG(e,t,n){const a=this;let r,s=0,i=0;return function(e){let t=a.events.length-1;for(;t>-1;){const e=a.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const r=t>-1?a.events[t][1].type:null,s="tableHead"===r||"tableRow"===r?b:o;if(s===b&&a.parser.lazy[a.now().line])return n(e);return s(e)};function o(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){if(124===e)return l(e);return r=!0,i+=1,l(e)}(t)}function l(t){return null===t?n(t):aV(t)?i>1?(i=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),u):n(t):sV(t)?cV(e,l,"whitespace")(t):(i+=1,r&&(r=!1,s+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),r=!0,l):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||rV(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return 92===t||124===t?(e.consume(t),c):c(t)}function u(t){return a.interrupt=!1,a.parser.lazy[a.now().line]?n(t):(e.enter("tableDelimiterRow"),r=!1,sV(t)?cV(e,m,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):m(t))}function m(t){return 45===t||58===t?h(t):124===t?(r=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),p):y(t)}function p(t){return sV(t)?cV(e,h,"whitespace")(t):h(t)}function h(t){return 58===t?(i+=1,r=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),f):45===t?(i+=1,f(t)):null===t||aV(t)?g(t):y(t)}function f(t){return 45===t?(e.enter("tableDelimiterFiller"),x(t)):y(t)}function x(t){return 45===t?(e.consume(t),x):58===t?(r=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(t))}function v(t){return sV(t)?cV(e,g,"whitespace")(t):g(t)}function g(n){return 124===n?m(n):(null===n||aV(n))&&r&&s===i?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):y(n)}function y(e){return n(e)}function b(t){return e.enter("tableRow"),w(t)}function w(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),w):null===n||aV(n)?(e.exit("tableRow"),t(n)):sV(n)?cV(e,w,"whitespace")(n):(e.enter("data"),j(n))}function j(t){return null===t||124===t||rV(t)?(e.exit("data"),w(t)):(e.consume(t),92===t?k:j)}function k(t){return 92===t||124===t?(e.consume(t),j):j(t)}}function TG(e,t){let n,a,r,s=-1,i=!0,o=0,l=[0,0,0,0],c=[0,0,0,0],d=!1,u=0;const m=new FG;for(;++s<e.length;){const p=e[s],h=p[1];
vendor: 4,589 bytes, line 2
2"enter"===p[0]?"tableHead"===h.type?(d=!1,0!==u&&(OG(m,t,u,n,a),a=void 0,u=0),n={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},m.add(s,0,[["enter",n,t]])):"tableRow"===h.type||"tableDelimiterRow"===h.type?(i=!0,r=void 0,l=[0,0,0,0],c=[0,s+1,0,0],d&&(d=!1,a={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},m.add(s,0,[["enter",a,t]])),o="tableDelimiterRow"===h.type?2:a?3:1):!o||"data"!==h.type&&"tableDelimiterMarker"!==h.type&&"tableDelimiterFiller"!==h.type?"tableCellDivider"===h.type&&(i?i=!1:(0!==l[1]&&(c[0]=c[1],r=PG(m,t,l,o,void 0,r)),l=c,c=[l[1],s,0,0])):(i=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],r=PG(m,t,l,o,void 0,r),l=[0,0,0,0]),c[2]=s)):"tableHead"===h.type?(d=!0,u=s):"tableRow"===h.type||"tableDelimiterRow"===h.type?(u=s,0!==l[1]?(c[0]=c[1],r=PG(m,t,l,o,s,r)):0!==c[1]&&(r=PG(m,t,c,o,s,r)),o=0):!o||"data"!==h.type&&"tableDelimiterMarker"!==h.type&&"tableDelimiterFiller"!==h.type||(c[3]=s)}for(0!==u&&OG(m,t,u,n,a),m.consume(t.events),s=-1;++s<t.events.length;){const e=t.events[s];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=RG(t.events,s))}return e}function PG(e,t,n,a,r,s){const i=1===a?"tableHeader":2===a?"tableDelimiter":"tableData";0!==n[0]&&(s.end=Object.assign({},BG(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=BG(t.events,n[1]);if(s={type:i,start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",s,t]]),0!==n[2]){const r=BG(t.events,n[2]),s=BG(t.events,n[3]),i={type:"tableContent",start:Object.assign({},r),end:Object.assign({},s)};if(e.add(n[2],0,[["enter",i,t]]),2!==a){const a=t.events[n[2]],r=t.events[n[3]];if(a[1].end=Object.assign({},r[1].end),a[1].type="chunkText",a[1].contentType="text",n[3]>n[2]+1){const t=n[2]+1,a=n[3]-n[2]-1;e.add(t,a,[])}}e.add(n[3]+1,0,[["exit",i,t]])}return void 0!==r&&(s.end=Object.assign({},BG(t.events,r)),e.add(r,0,[["exit",s,t]]),s=void 0),s}function OG(e,t,n,a,r){const s=[],i=BG(t.events,n);r&&(r.end=Object.assign({},i),s.push(["exit",r,t])),a.end=Object.assign({},i),s.push(["exit",a,t]),e.add(n+1,0,s)}function BG(e,t){const n=e[t],a="enter"===n[0]?"start":"end";return n[1][a]}const LG={name:"tasklistCheck",tokenize:function(e,t,n){const a=this;return function(t){if(null!==a.previous||!a._gfmTasklistFirstContentOfListItem)return n(t);return e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),r};function r(t){return rV(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),s):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),s):n(t)}function s(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),i):n(t)}function i(a){return aV(a)?t(a):sV(a)?e.check({tokenize:MG},t,n)(a):n(a)}}};function MG(e,t,n){return cV(e,function(e){return null===e?n(e):t(e)},"whitespace")}const zG={};function UG(e){const t=e||zG,n=this.data(),a=n.micromarkExtensions||(n.micromarkExtensions=[]),r=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);a.push(function(e){return KU([{text:xG},{document:{91:{name:"gfmFootnoteDefinition",tokenize:CG,continuation:{tokenize:AG},exit:SG}},text:{91:{name:"gfmFootnoteCall",tokenize:DG},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:NG,resolveTo:_G}}},EG(e),{flow:{null:{name:"table",tokenize:IG,resolveAll:TG}}},{text:{91:LG}}])}(t)),r.push([{transforms:[oH],enter:{literalAutolink:tH,literalAutolinkEmail:nH,literalAutolinkHttp:nH,literalAutolinkWww:nH},exit:{literalAutolink:iH,literalAutolinkEmail:sH,literalAutolinkHttp:aH,literalAutolinkWww:rH}},{enter:{gfmFootnoteCallString:uH,gfmFootnoteCall:mH,gfmFootnoteDefinitionLabelString:pH,gfmFootnoteDefinition:hH},exit:{gfmFootnoteCallString:fH,gfmFootnoteCall:xH,gfmFootnoteDefinitionLabelString:vH,gfmFootnoteDefinition:gH}},{canContainEols:["delete"],enter:{strikethrough:NH},exit:{strikethrough:_H}},{enter:{table:XH,tableData:tG,tableHeader:tG,tableRow:ZH},exit:{codeText:nG,table:QH,tableData:eG,tableHeader:eG,tableRow:eG}},{exit:{taskListCheckValueChecked:sG,taskListCheckValueUnchecked:sG,paragraph:iG}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ZW,notInConstruct:eH},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ZW,notInConstruct:eH},{character:":",before:"[ps]",after:"\\/",inConstruct:ZW,notInConstruct:eH}]},bH(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:kH}
2],handlers:{delete:DH}},rG(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:oG}}]}}(t))}const VG=["node"],qG=["node"],WG={candidate:{file:"candidate_user_guide.md",title:"Candidate User Guide"},employer:{file:"employer_user_guide.md",title:"Employer User Guide"},reviewer:{file:"reviewer_user_guide.md",title:"Reviewer User Guide"}};function HG(){const{guide:e}=_e(),[t]=Pt(),n="1"===t.get("print"),a=WG[e],[r,i]=(0,s.useState)(null),[o,d]=(0,s.useState)(null);if((0,s.useEffect)(()=>{a?(i(null),d(null),fetch("/help/".concat(a.file)).then(e=>{if(!e.ok)throw new Error("Failed to load guide (HTTP ".concat(e.status,")"));return e.text()}).then(i).catch(e=>d(e.message||"Failed to load guide."))):d('Unknown guide: "'.concat(e,'". Try /help/candidate, /help/employer, or /help/reviewer.'))},[e,a]),o)return(0,Xt.jsx)("div",{className:"max-w-3xl mx-auto p-8","data-testid":"help-guide-".concat(e,"-error"),children:(0,Xt.jsxs)("div",{className:"flex items-start gap-3 p-5 rounded-lg border border-rose-500/40 bg-rose-500/5",children:[(0,Xt.jsx)(Oy,{className:"h-5 w-5 text-rose-400 mt-0.5"}),(0,Xt.jsx)("div",{className:"text-sm text-rose-100",children:o})]})});if(null===r)return(0,Xt.jsxs)("div",{className:"flex items-center gap-2 p-8 text-sm text-slate-300","data-testid":"help-guide-".concat(e,"-loading"),children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 animate-spin"}),"Loading ",(null===a||void 0===a?void 0:a.title)||"guide","\u2026"]});const u=n?"help-guide-print bg-white text-slate-900":"mx-auto max-w-4xl px-4 sm:px-6 lg:px-8 py-6 lg:py-10";return(0,Xt.jsxs)("div",{className:u,"data-testid":"help-guide-".concat(e),children:[!n&&(0,Xt.jsxs)("div",{className:"mb-6 flex items-center justify-between gap-3",children:[(0,Xt.jsx)("h1",{className:"sr-only",children:a.title}),(0,Xt.jsxs)("a",{href:"/help/".concat(e,"_user_guide.pdf"),download:!0,className:"inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md border border-ndor-edge bg-ndor-surface-alt text-ndor-ink-secondary hover:text-ndor-ink","data-testid":"help-guide-".concat(e,"-pdf-link"),children:[(0,Xt.jsx)(AC,{className:"h-3.5 w-3.5"}),"Download PDF"]})]}),(0,Xt.jsx)("article",{className:"help-guide-prose ".concat(n?"print-prose":""),children:(0,Xt.jsx)(WW,{remarkPlugins:[UG],components:{img:e=>{let{node:t}=e,a=l(e,VG);return(0,Xt.jsx)("img",(0,c.A)((0,c.A)({},a),{},{loading:"lazy",className:"my-5 rounded-lg border ".concat(n?"border-slate-200 shadow-sm w-full":"border-ndor-edge w-full")}))},a:e=>{var t,n;let{node:a}=e,r=l(e,qG);return(0,Xt.jsx)("a",(0,c.A)((0,c.A)({},r),{},{className:"text-ndor-info hover:text-ndor-primary-hover underline",target:null!==(t=r.href)&&void 0!==t&&t.startsWith("http")?"_blank":void 0,rel:null!==(n=r.href)&&void 0!==n&&n.startsWith("http")?"noopener noreferrer":void 0}))}},children:r})})]})}const GG=wn("circle-dollar-sign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]),KG=[{icon:Bn,label:"Secure payments by Stripe",testid:"trust-stripe"},{icon:GG,label:"Cancel any time",testid:"trust-cancel"},{icon:oM,label:"Transparent billing",testid:"trust-transparent"},{icon:b_,label:"Privacy protected",testid:"trust-privacy-badge"}],YG=[{to:"/terms",label:"Terms",icon:QC,testid:"trust-terms-link"},{to:"/refund",label:"Refund Policy",icon:Nn,testid:"trust-refund-link"},{to:"/privacy",label:"Privacy Policy",icon:Bn,testid:"trust-privacy-link"}];function JG(){return(0,Xt.jsxs)("div",{className:"mt-8 pt-6 border-t border-ndor-edge space-y-4","data-testid":"commercial-trust-strip",children:[(0,Xt.jsx)("ul",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:KG.map(e=>{let{icon:t,label:n,testid:a}=e;return(0,Xt.jsxs)("li",{"data-testid":a,className:"flex items-center gap-2 text-xs text-ndor-ink-secondary",children:[(0,Xt.jsx)(t,{className:"h-4 w-4 shrink-0 text-ndor-gold"}),(0,Xt.jsx)("span",{children:n})]},n)})}),(0,Xt.jsxs)("p",{className:"text-[11px] text-ndor-ink-muted leading-relaxed","data-testid":"trust-legal-line",children:["Secure billing powered by Stripe. Manage your subscription in accordance with your plan terms. By subscribing you agree to our"," ",YG.map((e,t)=>(0,Xt.jsxs)("span",{children:[(0,Xt.jsx)(Et,{to:e.to,"data-testid":e.testid,className:"text-ndor-ink hover:underline",children:e.label}),t<YG.length-1?", ":"."]},e.to))]})]})}const $G=[{key:"monthly",label:"Monthly"},{key:"annual",label:"Annual"}
2],XG={base:{icon:Bn,accent:"border-ndor-edge",cta:"Start free",bullets:["2 Analyse Fit per day (free-tier daily limit)","Manual Review \u2014 find roles and apply yourself","CV upload, structured parse, application pack composer"]},focus:{icon:Kn,accent:"border-ndor-primary/40",cta:"Choose Focus",bullets:["Higher monthly Credit allowance","Manual Review + Assisted Review","Assisted Review runs Analyse Fit against your Source CV in the background, up to your daily budget","Matches above your fit threshold appear in your Review Queue","You still pick the CV and submit every application yourself"]},flow:{icon:Cn,accent:"border-ndor-gold/40",cta:"Choose Flow",bullets:["Everything in Focus","Manual Review + Assisted Review + background Source CV Baseline Fit","Background Baseline Fit runs against your Source CV continuously \u2014 no daily cap, surfaces fresh-fit candidates so you spend Credits where they matter","Strongest matches surface in your Top Opportunities feed, re-ranked throughout the day","NDORFlow never auto-applies and never auto-tailors \u2014 you still review, pick the CV, generate any tailored variant, and submit every application yourself"]}};function QG(){var e,t,n,a;const r=ke(),i=be(),[o,l]=(0,s.useState)(null),[c,d]=(0,s.useState)("monthly"),[u,m]=(0,s.useState)("monthly"),{usageCosts:p}
2=If(),h=Sf(p),[f,x]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!0;return(async()=>{try{const t=await(0,zt.n)("/api/account/plan-catalogue");e&&Array.isArray(null===t||void 0===t?void 0:t.plans)&&x(t.plans)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Unable to load plan prices."),e&&x([])}})(),()=>{e=!1}},[]);const[v,g]=(0,s.useState)(null),[y,b]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=!0;return(async()=>{try{const t=await(0,zt.n)("/api/account/plan");e&&g(t)}catch(t){e&&g(null)}finally{e&&b(!0)}})(),()=>{e=!1}},[]);const w=(null===(e=i.state)||void 0===e?void 0:e.from)||("undefined"!==typeof document&&document.referrer&&document.referrer.includes("/account")?"/account?tab=plan":null),j="/onboarding"===(null===(t=i.state)||void 0===t?void 0:t.from),k="string"===typeof(null===(n=i.state)||void 0===n?void 0:n.from)&&i.state.from.startsWith("/account"),N=y&&(null===v||void 0===v?void 0:v.plan_code)&&"base"!==v.plan_code,_=j||!k&&!N,D="undefined"!==typeof window&&"number"===typeof(null===(a=window.history)||void 0===a?void 0:a.length)&&window.history.length>1;let C,A;_?(C="/onboarding",A="Back to CV upload"):w?(C=w,A="Back"):null!==v&&void 0!==v&&v.plan_code&&"base"!==v.plan_code?(C="/account?tab=plan",A="Back to account"):D?(C="__history_back__",A="Back"):(C="/dashboard",A="Back to dashboard");const S=(0,s.useMemo)(()=>["base","focus","flow"].map(e=>{const t=XG[e],n=(e=>(f||[]).find(t=>t.plan_code===e))(e);return{code:e,name:(null===n||void 0===n?void 0:n.label)||e.charAt(0).toUpperCase()+e.slice(1),icon:t.icon,accent:t.accent,cta:t.cta,bullets:t.bullets,tiers:(null===n||void 0===n?void 0:n.tiers)||{},period:"focus"===e?c:"flow"===e?u:"monthly",setPeriod:"focus"===e?d:"flow"===e?m:null}}),[f,c,u]),E=e=>{const t=e.tiers[e.period];if("base"===e.code)return"Free \u2014 pay only if you need more";if(!t)return"\u2014";if("annual"===e.period){var n;const a=e.tiers.monthly,r=null!==(n=null===a||void 0===a?void 0:a.included_usage)&&void 0!==n?n:Math.round((t.included_usage||0)/12);return"".concat(r.toLocaleString()," Credits per month \xb7 released monthly")}return"".concat(t.included_usage.toLocaleString()," included Credits / month")},F=e=>{const t=e.tiers[e.period];if("base"===e.code)return"Free";if(!t)return"\u2014";const n="annual"===e.period?"/yr":"/mo",a=t.early_access_display;return a&&"monthly"===e.period?"".concat(a).concat(n):"".concat(t.display_price).concat(n)},R=e=>{const t=e.tiers[e.period];return null!==t&&void 0!==t&&t.early_access_display&&"monthly"===e.period?(0,Xt.jsxs)(Xt.Fragment,{children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-ndor-gold font-mono-ui","data-testid":"plan-founding-member-".concat(e.code),children:"Founding Member Pricing \u2014 locked in for life"}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted leading-snug mt-0.5","data-testid":"plan-founding-member-context-".concat(e.code),children:"Your Founding Member rate is locked in below future pricing."})]}):null},I=e=>{var t,n;if("base"===e.code)return null;const a=e.tiers[e.period];if(!a)return null;return("annual"===e.period?null!==(t=null===(n=e.tiers.monthly)||void 0===n?void 0:n.included_usage)&&void 0!==t?t:Math.round((a.included_usage||0)/12):a.included_usage)&&h?(0,Xt.jsx)("p",{className:"text-xs text-ndor-ink-secondary leading-snug","data-testid":"plan-app-count-".concat(e.code),children:"Supports multiple fully tailored applications per month."}):null};return(0,Xt.jsxs)(ub,{step:2,totalSteps:2,stepLabel:"Choose your plan",testid:"onboarding-plan-page",children:[(0,Xt.jsxs)("div",{className:"max-w-5xl w-full mx-auto space-y-8",children:[(0,Xt.jsx)("div",{className:"flex pl-3 sm:pl-0",children:(0,Xt.jsxs)(Rr,{variant:"ghost",size:"sm",onClick:()=>{fy.message("Returning\u2026"),"__history_back__"!==C?r(C,{replace:!0}):r(-1)},"data-testid":"onboarding-plan-back",className:"text-ndor-ink-muted hover:text-ndor-ink",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"}),A]})}),(0,Xt.jsxs)("header",{className:"text-center space-y-3",children:[(0,Xt.jsx)("h1",{className:"text-3xl sm:text-4xl font-serif-display font-semibold tracking-tight text-ndor-ink","data-testid":"onboarding-plan-title",children:"Choose how you want to use NDORFlow"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary max-w-2xl mx-auto",children:"Start free and upgrade any time. Paid plans include a monthly Credits allowance and, on Flow, automation. Annual saves more."})]}),null===f?(0,Xt.jsxs)("div",{className:"flex items-center justify-center py-12 text-sm text-ndor-ink-muted",children:[(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-2 animate-spin"})," Loading plan prices\u2026"]}
2):(0,Xt.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:S.map(e=>{const t=e.icon,n=o===e.code;return(0,Xt.jsx)(Fy,{className:"border-2 ".concat(e.accent," bg-ndor-surface transition-shadow hover:shadow-md"),"data-testid":"plan-card-".concat(e.code),children:(0,Xt.jsxs)(Py,{className:"p-6 flex flex-col h-full gap-4",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(t,{className:"h-4 w-4 text-ndor-gold"}),(0,Xt.jsx)("h2",{className:"text-xl font-serif-display font-semibold text-ndor-ink",children:e.name})]}),(0,Xt.jsx)("div",{className:"text-2xl font-serif-display font-semibold text-ndor-ink tabular-nums","data-testid":"plan-price-".concat(e.code),children:F(e)}),R(e),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-muted","data-testid":"plan-tagline-".concat(e.code),children:E(e)}),I(e),(0,Xt.jsx)("ul",{className:"flex-1 space-y-2",children:e.bullets.map((e,t)=>(0,Xt.jsxs)("li",{className:"flex gap-2 text-sm text-ndor-ink-secondary",children:[(0,Xt.jsx)(Zm,{className:"h-4 w-4 text-ndor-gold shrink-0 mt-[2px]"}),(0,Xt.jsx)("span",{children:e})]},t))}),"base"!==e.code&&(0,Xt.jsx)("div",{className:"flex items-center gap-1.5 pt-1",children:$G.map(t=>{const n=e.period===t.key,a=e.tiers[t.key];return(0,Xt.jsx)("button",{type:"button",onClick:()=>e.setPeriod&&e.setPeriod(t.key),"data-testid":"plan-period-".concat(e.code,"-").concat(t.key),className:"text-xs px-2.5 py-1 rounded-md border transition-colors\n ".concat(n?"bg-ndor-ink text-ndor-canvas border-ndor-ink":"bg-transparent text-ndor-ink-muted border-ndor-edge hover:bg-ndor-surface-alt/50"),title:a?"".concat(a.display_price," \xb7 ").concat(a.included_usage.toLocaleString()," Credits"):"",children:t.label},t.key)})}),(0,Xt.jsxs)(Rr,{onClick:()=>(async e=>{if(o)return;l(e);const t="focus"===e?c:"flow"===e?u:"monthly";Ht("plan_selected",{plan_code:e,billing_period:t,founding:"base"!==e&&"monthly"===t});try{const n={plan_code:e};"base"!==e&&(n.billing_period=t),(await(0,zt.n)("/api/account/plan/select",{method:"POST",body:n})).payment_required?r("/onboarding/payment",{replace:!0,state:w?{from:w}:void 0}):(fy.success("Welcome to Base \u2014 you're all set."),r("/plan-activated",{replace:!0}))}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Could not save your plan selection.")}finally{l(null)}})(e.code),disabled:Boolean(o),className:"w-full ".concat("base"===e.code?"bg-ndor-surface-alt hover:bg-ndor-surface-alt/80 text-ndor-ink border border-ndor-edge":"bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground"),"data-testid":"plan-cta-".concat(e.code),children:[n?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):null,e.cta]})]})},e.code)})}),(0,Xt.jsx)("p",{className:"text-[11px] text-ndor-ink-muted text-center","data-testid":"onboarding-plan-billing-line",children:"Secure billing powered by Stripe. Manage your subscription in accordance with your plan terms. Cancel any time from Account > Plan."}),(0,Xt.jsx)(JG,{})]}),(0,Xt.jsx)(Xv,{variant:"auth"})]})}const ZG={focus:"Focus",flow:"Flow",base:"Base"},eK={monthly:"Monthly",annual:"Annual"};function tK(){var e;const t=ke(),n=be(),[a,r]=(0,s.useState)(null),[i,o]=(0,s.useState)(!0),[l,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(!1),m=(0,s.useRef)(!1),p=(null===(e=n.state)||void 0===e?void 0:e.from)||null;(0,s.useEffect)(()=>{let e=!0;return(async()=>{try{const t=new URLSearchParams(n.search),a=t.get("session_id");"1"===t.get("cancelled")&&(m.current=!0,fy.error("Checkout cancelled. You can try again whenever you are ready."));const s=await(0,zt.n)("/api/account/plan");if(!e)return;r(s),a&&await h(a,e)}catch(t){}finally{e&&o(!1)}})(),()=>{e=!1}},[]),(0,s.useEffect)(()=>{if(i||d||l||m.current)return;if(!a)return;const e=a.plan_code,r=!!new URLSearchParams(n.search).get("session_id");("focus"===e||"flow"===e)&&"pending"===a.status||r||t("/onboarding/plan",{replace:!0})},[i,a,d,l,n.search,t]);const h=async(e,n)=>{u(!0);try{for(let s=0;s<30;s++){var a,r;if(!n)return;let s;try{s=await(0,zt.n)("/api/payments/checkout/status/".concat(e))}catch(pK){return void fy.error((null===pK||void 0===pK?void 0:pK.message)||"Could not verify payment status.")}if(null!==(a=s)&&void 0!==a&&a.finalised||"finalised"===(null===(r=s)||void 0===r?void 0:r.status)){const e=await(0,zt.n)("/api/account/plan");if("active"===(null===e||void 0===e?void 0:e.status))return fy.success("".concat(ZG[e.plan_code]||"Plan"," activated.")),c(!0),void t("/plan-activated",{replace:!0})}await new Promise(e=>setTimeout(e,2e3))}fy.error("Activation is taking longer than expected. Please refresh in a moment.")}finally{u(!1)}};return i||!a&&!m.current?(0,Xt.jsx)("div",{className:"min-h-screen bg-ndor-canvas flex items-center justify-center",children:(0,Xt.jsx)(Lg,{className:"h-6 w-6 animate-spin text-ndor-ink-muted"})}):d?(0,Xt.jsx)("div",{className:"min-h-screen bg-ndor-canvas flex items-center justify-center","data-testid":"onboarding-payment-polling",children:(0,Xt.jsxs)("div",{className:"text-center space-y-3",children:[(0,Xt.jsx)(Lg,{className:"h-8 w-8 animate-spin text-ndor-gold mx-auto"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary",children:"Activating your plan\u2026"})]})}):(0,Xt.jsxs)("div",{className:"min-h-screen bg-ndor-canvas flex flex-col items-center px-4 py-16","data-testid":"onboarding-payment-page",children:[(0,Xt.jsxs)("div",{className:"max-w-lg w-full space-y-6 flex-1",children:[(0,Xt.jsxs)("header",{className:"text-center space-y-2",children:[(0,Xt.jsx)("p",{className:"text-[11px] uppercase tracking-[0.22em] text-ndor-gold font-mono-ui",children:"Activate your plan"}),(0,Xt.jsx)("h1",{className:"text-3xl font-serif-display font-semibold text-ndor-ink tracking-tight","data-testid":"onboarding-payment-title",children:"Almost there"}),(0,Xt.jsx)("p",{className:"text-sm text-ndor-ink-secondary",children:"You'll complete payment securely on Stripe. We never see or store your card details."})]}),(0,Xt.jsx)(Fy,{className:"border-ndor-edge bg-ndor-surface",children:(0,Xt.jsxs)(Py,{className:"p-6 space-y-5",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,Xt.jsxs)("div",{children:[(0,Xt.jsx)("p",{className:"text-xs uppercase tracking-[0.14em] text-ndor-ink-muted font-mono-ui",children:"Selected plan"}),(0,Xt.jsx)("p",{className:"text-2xl font-serif-display font-semibold text-ndor-ink","data-testid":"onboarding-payment-plan-name",children:ZG[null===a||void 0===a?void 0:a.plan_code]||(null===a||void 0===a?void 0:a.plan_code)}),(0,Xt.jsxs)("p",{className:"text-sm text-ndor-ink-secondary",children:[eK[null===a||void 0===a?void 0:a.billing_period]||"Monthly"," billing cycle"]})]}),(0,Xt.jsx)(iI,{className:"h-10 w-10 text-ndor-ink-muted"})]}),(0,Xt.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-ndor-edge bg-ndor-surface-alt/40 p-3 text-xs text-ndor-ink-secondary","data-testid":"onboarding-payment-stripe-note",children:[(0,Xt.jsx)(Bn,{className:"h-4 w-4 shrink-0 mt-[2px] text-ndor-gold"}),lM()?(0,Xt.jsxs)("span",{children:["Secure Stripe Checkout \u2014 TEST MODE. Use Stripe's test card",(0,Xt.jsx)("span",{className:"font-mono-ui mx-1",children:"4242 4242 4242 4242"}),"with any future expiry and any 3-digit CVC. No real money will move."]}):(0,Xt.jsxs)("span",{children:["Secure billing powered by Stripe. We never see or store your card details. Your subscription is governed by your plan terms and our ",(0,Xt.jsx)("a",{href:"/refund",className:"text-ndor-ink underline hover:text-ndor-ink/80",children:"Refund Policy"}),"."]})]}),(0,Xt.jsxs)("div",{className:"flex flex-col-reverse sm:flex-row gap-2 sm:justify-between sm:items-center",children:[(0,Xt.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[(0,Xt.jsxs)(Rr,{variant:"outline",onClick:()=>{fy.message("Returning to plans\u2026"),t("/onboarding/plan",{replace:!0,state:p?{from:p}:void 0})},"data-testid":"onboarding-payment-back",children:[(0,Xt.jsx)(Zg,{className:"h-4 w-4 mr-1.5"}),"Back to plans"]}),p&&(0,Xt.jsxs)(Rr,{variant:"ghost",onClick:()=>{fy.message("Cancelled \u2014 keeping your current plan."),t(p,{replace:!0})},"data-testid":"onboarding-payment-cancel",className:"text-ndor-ink-muted hover:text-ndor-ink",children:[(0,Xt.jsx)(xh,{className:"h-4 w-4 mr-1.5"}),"Cancel and keep current plan"]})]}),(0,Xt.jsxs)(Rr,{onClick:async()=>
2{if(null!==a&&void 0!==a&&a.plan_code&&null!==a&&void 0!==a&&a.billing_period){c(!0);try{const e=await(0,zt.n)("/api/payments/checkout/plan",{method:"POST",body:JSON.stringify({plan_code:a.plan_code,billing_period:a.billing_period})});if(null===e||void 0===e||!e.checkout_url)throw new Error("Stripe did not return a checkout URL.");window.location.assign(e.checkout_url)}catch(pK){fy.error((null===pK||void 0===pK?void 0:pK.message)||"Could not start Stripe Checkout. Please try again."),c(!1)}}},disabled:l||!(null!==a&&void 0!==a&&a.plan_code)||!(null!==a&&void 0!==a&&a.billing_period),"data-testid":"onboarding-payment-confirm",className:"bg-ndor-primary hover:bg-ndor-primary-hover text-ndor-primary-foreground",children:[l?(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-1.5 animate-spin"}):null,"Pay with Stripe"]})]})]})})]}),(0,Xt.jsx)(Xv,{variant:"auth"})]})}function nK(){const{signOut:e}=tn(),[t,n]=(0,s.useState)(!1);(0,s.useEffect)(()=>{Ht("plan_handoff_seen")},[]);return(0,Xt.jsxs)("div",{className:"flex flex-col min-h-screen bg-ndor-canvas","data-testid":"plan-activation-handoff-page",children:[(0,Xt.jsxs)("header",{className:"w-full px-6 py-5 sm:px-10 sm:py-6 flex items-center gap-3",children:[(0,Xt.jsx)(Wf,{variant:"symbol",size:36}),(0,Xt.jsxs)("span",{className:"text-[15px] font-serif-display font-semibold tracking-tight text-ndor-ink",children:["NDOR",(0,Xt.jsx)("span",{className:"text-gold-accent",children:"Flow"})]})]}),(0,Xt.jsx)("main",{className:"flex-1 flex items-center justify-center px-6 py-12",children:(0,Xt.jsxs)("div",{className:"w-full max-w-md text-center",children:[(0,Xt.jsx)("div",{className:"mx-auto mb-6 flex h-14 w-14 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-600","data-testid":"plan-activation-handoff-badge",children:(0,Xt.jsx)(Og,{className:"h-7 w-7"})}),(0,Xt.jsx)("h1",{className:"text-3xl sm:text-4xl font-serif-display font-semibold tracking-tight text-ndor-ink","data-testid":"plan-activation-handoff-headline",children:"Your plan is ready."}),(0,Xt.jsx)("p",{className:"mt-4 text-base text-ndor-ink-secondary font-manrope","data-testid":"plan-activation-handoff-body",children:"Sign in again to activate your updated dashboard securely."}),(0,Xt.jsx)("div",{className:"mt-8",children:(0,Xt.jsxs)(Rr,{size:"lg",onClick:async()=>{if(!t){n(!0),Ht("plan_handoff_cta_clicked");try{await e()}catch(a){}window.location.replace("/login?just_signed_up=1")}},disabled:t,"data-testid":"plan-activation-handoff-cta",className:"w-full sm:w-auto min-w-[220px] font-medium",children:[t&&(0,Xt.jsx)(Lg,{className:"h-4 w-4 mr-2 animate-spin"}),t?"Signing you out\u2026":"Sign in again \u2192"]})}),(0,Xt.jsx)("p",{className:"mt-6 text-xs text-ndor-ink-subtle font-manrope",children:"We sign you out for your security. A fresh session makes sure your new plan and features are loaded without leftover state."})]})}),(0,Xt.jsx)(Xv,{})]})}const aK="ndor_plan_activated_fired",rK=["/employer","/admin","/post-login","/choose-workspace","/no-access"];function sK(e){let{children:t}=e;const[n,a]=(0,s.useState)(null),[r,i]=(0,s.useState)(!0),[o,l]=(0,s.useState)(!1),{pathname:c}=be(),{allowedWorkspaces:d,loading:u,access:m}=on(),p=!rK.some(e=>c.startsWith(e)),h=Array.isArray(d)&&d.includes("candidate"),f=!u&&!!m,x=!p||f&&!h;if((0,s.useEffect)(()=>{if(x)return void i(!1);let e=!1;return(async()=>{try{const n=await(0,zt.n)("/api/account/plan");if(!e){a(n);try{if("active"===(null===n||void 0===n?void 0:n.status)&&null!==n&&void 0!==n&&n.plan_code&&"base"!==n.plan_code){sessionStorage.getItem(aK)!==n.plan_code&&(Ht("plan_activated",{plan_code:n.plan_code,source:"entitlement_hydration"}),sessionStorage.setItem(aK,n.plan_code))}}catch(t){}}}catch(n){e||l(!0)}finally{e||i(!1)}})(),()=>{e=!0}},[x]),x)return t;if(!f)return(0,Xt.jsx)("div",{className:"min-h-[240px] flex items-center justify-center text-ndor-ink-muted","data-testid":"entitlement-gate-loading",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin"})});if(r)return(0,Xt.jsx)("div",{className:"min-h-[240px] flex items-center justify-center text-ndor-ink-muted","data-testid":"entitlement-gate-loading",children:(0,Xt.jsx)(Lg,{className:"h-5 w-5 animate-spin"})});if(o)return t;if(n&&!1===n.has_entitlement&&!1===n.unmigrated)return(0,Xt.jsx)(We,{to:"/onboarding/plan",replace:!0});const v="expired"===(null===n||void 0===n?void 0:n.status);return(0,Xt.jsxs)(Xt.Fragment,{children:[v&&(0,Xt.jsxs)("div",{className:"mx-4 sm:mx-6 mt-3 rounded-md border border-rose-500/30 bg-rose-500/10 px-4 py-3 text-sm text-rose-200 flex items-center justify-between gap-3","data-testid":"entitlement-expired-banner",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Xt.jsx)(Oy,{className:"h-4 w-4"}),(0,Xt.jsx)("span",{children:"Your plan has expired \u2014 renew to restore access."})]}),(0,Xt.jsx)(Et,{to:"/onboarding/plan",className:"text-sm font-medium text-rose-200 hover:underline","data-testid":"entitlement-expired-renew-link",children:"Renew"})]}),t]})}var iK=(e,t,n,a,r,s,i,o)=>
2{let l=document.documentElement,c=["light","dark"];function d(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n="class"===e,a=n&&s?r.map(e=>s[e]||e):r;n?(l.classList.remove(...a),l.classList.add(s&&s[t]?s[t]:t)):l.setAttribute(e,t)}),function(e){o&&c.includes(e)&&(l.style.colorScheme=e)}(t)}if(a)d(a);else try{let e=localStorage.getItem(t)||n;d(i&&"system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e)}catch(u){}},oK=s.createContext(void 0),lK={setTheme:e=>{},themes:[]};s.memo(e=>{let{forcedTheme:t,storageKey:n,attribute:a,enableSystem:r,enableColorScheme:i,defaultTheme:o,value:l,themes:d,nonce:u,scriptProps:m}=e,p=JSON.stringify([a,n,o,t,d,l,r,i]).slice(1,-1);return s.createElement("script",(0,c.A)((0,c.A)({},m),{},{suppressHydrationWarning:!0,nonce:"undefined"==typeof window?u:"",dangerouslySetInnerHTML:{__html:"(".concat(iK.toString(),")(").concat(p,")")}}))});const cK=e=>{let t=Object.assign({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(e),e));const{theme:n="system"}=(()=>{var e;return null!=(e=s.useContext(oK))?e:lK})();return(0,Xt.jsx)(ky,(0,c.A)({theme:n,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}}},t))};function dK(e){let{tab:t}=e;const{search:n}=be(),a=new URLSearchParams(n);return a.set("tab",t),(0,Xt.jsx)(We,{to:"/documents?".concat(a.toString()),replace:!0})}const uK=function(){return(0,Xt.jsx)(At,{children:(0,Xt.jsx)(en,{children:(0,Xt.jsxs)(sn,{children:[(0,Xt.jsxs)(Ye,{children:[(0,Xt.jsx)(Ge,{path:"/login",element:(0,Xt.jsx)(cn,{children:(0,Xt.jsx)(Hg,{})})}),(0,Xt.jsx)(Ge,{path:"/signup",element:(0,Xt.jsx)(cn,{children:(0,Xt.jsx)(Xg,{})})}),(0,Xt.jsx)(Ge,{path:"/forgot-password",element:(0,Xt.jsx)(ey,{})}),(0,Xt.jsx)(Ge,{path:"/auth/reset",element:(0,Xt.jsx)(Ny,{})}),(0,Xt.jsx)(Ge,{path:"/help/:guide",element:(0,Xt.jsx)(HG,{})}),(0,Xt.jsx)(Ge,{path:"/invitations/accept",element:(0,Xt.jsx)(My,{})}),(0,Xt.jsx)(Ge,{path:"/terms",element:(0,Xt.jsx)(TM,{})}),(0,Xt.jsx)(Ge,{path:"/refund",element:(0,Xt.jsx)(PM,{})}),(0,Xt.jsx)(Ge,{path:"/privacy",element:(0,Xt.jsx)(IM,{})}),(0,Xt.jsx)(Ge,{path:"/proof",element:(0,Xt.jsx)(LM,{})}),(0,Xt.jsx)(Ge,{path:"/onboarding",element:(0,Xt.jsx)(ln,{requireProfile:!1,children:(0,Xt.jsx)(bb,{})})}),(0,Xt.jsx)(Ge,{path:"/onboarding/employer",element:(0,Xt.jsx)(ln,{requireProfile:!1,redirectIfProfile:!0,children:(0,Xt.jsx)(Hb,{})})}),(0,Xt.jsx)(Ge,{path:"/onboarding/plan",element:(0,Xt.jsx)(ln,{requireProfile:!0,children:(0,Xt.jsx)(QG,{})})}),(0,Xt.jsx)(Ge,{path:"/onboarding/payment",element:(0,Xt.jsx)(ln,{requireProfile:!0,children:(0,Xt.jsx)(tK,{})})}),(0,Xt.jsx)(Ge,{path:"/plan-activated",element:(0,Xt.jsx)(ln,{requireProfile:!0,children:(0,Xt.jsx)(nK,{})})}),(0,Xt.jsxs)(Ge,{element:(0,Xt.jsx)(ln,{requireProfile:!0,children:(0,Xt.jsx)(sK,{children:(0,Xt.jsx)(Dg,{})})}),children:[(0,Xt.jsx)(Ge,{path:"/post-login",element:(0,Xt.jsx)(dn,{})}),(0,Xt.jsx)(Ge,{path:"/choose-workspace",element:(0,Xt.jsx)(sM,{})}),(0,Xt.jsx)(Ge,{path:"/no-access",element:(0,Xt.jsx)(iM,{})}),(0,Xt.jsxs)(Ge,{element:(0,Xt.jsx)(un,{workspace:"candidate",children:(0,Xt.jsx)(He,{})}),children:[(0,Xt.jsx)(Ge,{path:"/dashboard",element:(0,Xt.jsx)(Mw,{})}),(0,Xt.jsx)(Ge,{path:"/jobs",element:(0,Xt.jsx)(wk,{})}),(0,Xt.jsx)(Ge,{path:"/jobs/:id",element:(0,Xt.jsx)(gC,{})}),(0,Xt.jsx)(Ge,{path:"/cv-library",element:(0,Xt.jsx)(dK,{tab:"uploaded"})}),(0,Xt.jsx)(Ge,{path:"/cv-variants",element:(0,Xt.jsx)(dK,{tab:"variants"})}),(0,Xt.jsx)(Ge,{path:"/cover-letters",element:(0,Xt.jsx)(dK,{tab:"letters"})}),(0,Xt.jsx)(Ge,{path:"/analyze-fit",element:(0,Xt.jsx)(We,{to:"/jobs",replace:!0})}),(0,Xt.jsx)(Ge,{path:"/credits",element:(0,Xt.jsx)(hM,{})}),(0,Xt.jsx)(Ge,{path:"/settings",element:(0,Xt.jsx)(We,{to:"/account?tab=settings",replace:!0})}),(0,Xt.jsx)(Ge,{path:"/documents",element:(0,Xt.jsx)(ZM,{})}),(0,Xt.jsx)(Ge,{path:"/account",element:(0,Xt.jsx)(mz,{})}),(0,Xt.jsx)(Ge,{path:"/applications",element:(0,Xt.jsx)(UC,{})}),(0,Xt.jsx)(Ge,{path:"/applications/:id",element:(0,Xt.jsx)(oA,{})}),(0,Xt.jsx)(Ge,{path:"/applications/workspace/:jobId",element:(0,Xt.jsx)(FE,{})}),(0,Xt.jsx)(Ge,{path:"/automation",element:(0,Xt.jsx)(FF,{})}),(0,Xt.jsx)(Ge,{path:"/candidate/signals",element:(0,Xt.jsx)(aM,{children:(0,Xt.jsx)(nM,{})})}),(0,Xt.jsx)(Ge,{path:"/how-it-works",element:(0,Xt.jsx)(jz,{})})]}),(0,Xt.jsxs)(Ge,{element:(0,Xt.jsx)(un,{workspace:"employer",children:(0,Xt.jsx)(He,{})}),children:[(0,Xt.jsx)(Ge,{path:"/employer",element:(0,Xt.jsx)(UT,{})}),(0,Xt.jsx)(Ge,{path:"/employer/organisation",element:(0,Xt.jsx)(YT,{})}),(0,Xt.jsx)(Ge,{path:"/employer/candidates",element:(0,Xt.jsx)(JT,{})}),(0,Xt.jsx)(Ge,{path:"/employer/signals",element:(0,Xt.jsx)(XT,{})}),(0,Xt.jsx)(Ge,{path:"/employer/account",element:(0,Xt.jsx)(OT,{})}),(0,Xt.jsx)(Ge,{path:"/employer/members",element:(0,Xt.jsx)(yP,{})}),(0,Xt.jsx)(Ge,{path:"/employer/help/permissions",element:(0,Xt.jsx)(mT,{})}),(0,Xt.jsx)(Ge,{path:"/employer/help/workflow",element:(0,Xt.jsx)(gT,{})}),(0,Xt.jsx)(Ge,{path:"/employer/reviews",element:(0,Xt.jsx)(FP,{})}),(0,Xt.jsx)(Ge,{path:"/employer/reviews/:reviewId",element:(0,Xt.jsx)(BP,{})}),(0,Xt.jsx)(Ge,{path:"/employer/reviewers",element:(0,Xt.jsx)(HP,{})}),(0,Xt.jsx)(Ge,{path:"/employer/roles",element:(0,Xt.jsx)(tO,{})}),(0,Xt.jsx)(Ge,{path:"/employer/roles/new",element:(0,Xt.jsx)(ML,{})}),(0,Xt.jsx)(Ge,{path:"/employer/roles/:id",element:(0,Xt.jsx)(eL,{})}),(0,Xt.jsx)(Ge,{path:"/employer/roles/:id/edit",element:(0,Xt.jsx)(ML,{})}),(0,Xt.jsx)(Ge,{path:"/employer/roles/:id/matches",element:(0,Xt.jsx)(aM,{children:(0,Xt.jsx)(JL,{})})})]}),(0,Xt.jsxs)(Ge,{element:(0,Xt.jsx)(un,{workspace:"admin",children:(0,Xt.jsx)(He,{})}),children:[(0,Xt.jsx)(Ge,{path:"/admin/sources",element:(0,Xt.jsx)(JF,{})}),(0,Xt.jsx)(Ge,{path:"/admin/catalogue",element:(0,Xt.jsx)(sR,{})}),(0,Xt.jsx)(Ge,{path:"/admin/jobs",element:(0,Xt.jsx)(uR,{})}),(0,Xt.jsx)(Ge,{path:"/admin/duplicates",element:(0,Xt.jsx)(gR,{})}),(0,Xt.jsx)(Ge,{path:"/admin/settings",element:(0,Xt.jsx)(_R,{})}),(0,Xt.jsx)(Ge,{path:"/admin/users",element:(0,Xt.jsx)(AR,{})}),(0,Xt.jsx)(Ge,{path:"/admin/billing",element:(0,Xt.jsx)(pI,{})}),(0,Xt.jsx)(Ge,{path:"/admin/analytics",element:(0,Xt.jsx)(kI,{})}),(0,Xt.jsx)(Ge,{path:"/admin/scoring",element:(0,Xt.jsx)(SI,{})}),(0,Xt.jsx)(Ge,{path:"/admin/retention",element:(0,Xt.jsx)(qI,{})}),(0,Xt.jsx)(Ge,{path:"/admin/employers",element:(0,Xt.jsx)(aM,{children:(0,Xt.jsx)(QI,{})})})]})]}),(0,Xt.jsx)(Ge,{path:"*",element:(0,Xt.jsx)(We,{to:"/post-login",replace:!0})})]}),(0,Xt.jsx)(cK,{position:"top-right"})]})})})};
2o.createRoot(document.getElementById("root")).render((0,Xt.jsx)(s.StrictMode,{children:(0,Xt.jsx)(uK,{})}))})(); 3//# sourceMappingURL=main.fae3918b.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.