specweave 1.0.277 → 1.0.279

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/dashboard/assets/{index-BKdLA_6x.js → index-DQ_KfIRg.js} +1 -1
  2. package/dist/dashboard/index.html +1 -1
  3. package/dist/src/cli/commands/refresh-plugins.d.ts +5 -5
  4. package/dist/src/cli/commands/refresh-plugins.d.ts.map +1 -1
  5. package/dist/src/cli/commands/refresh-plugins.js +37 -167
  6. package/dist/src/cli/commands/refresh-plugins.js.map +1 -1
  7. package/dist/src/cli/commands/update.d.ts.map +1 -1
  8. package/dist/src/cli/commands/update.js +2 -3
  9. package/dist/src/cli/commands/update.js.map +1 -1
  10. package/dist/src/cli/helpers/init/plugin-installer.d.ts +3 -3
  11. package/dist/src/cli/helpers/init/plugin-installer.d.ts.map +1 -1
  12. package/dist/src/cli/helpers/init/plugin-installer.js +32 -98
  13. package/dist/src/cli/helpers/init/plugin-installer.js.map +1 -1
  14. package/dist/src/core/doctor/checkers/plugins-checker.js +3 -3
  15. package/dist/src/core/doctor/checkers/plugins-checker.js.map +1 -1
  16. package/dist/src/core/plugins/skill-trigger-index.js +1 -1
  17. package/dist/src/core/plugins/skill-trigger-index.js.map +1 -1
  18. package/dist/src/dashboard/server/command-runner.js +1 -1
  19. package/dist/src/dashboard/server/command-runner.js.map +1 -1
  20. package/dist/src/utils/plugin-copier.d.ts +77 -0
  21. package/dist/src/utils/plugin-copier.d.ts.map +1 -0
  22. package/dist/src/utils/plugin-copier.js +216 -0
  23. package/dist/src/utils/plugin-copier.js.map +1 -0
  24. package/package.json +1 -1
  25. package/plugins/specweave/hooks/user-prompt-submit.sh +45 -34
  26. package/plugins/specweave-jira/skills/jira-sync/SKILL.md +114 -129
  27. package/plugins/specweave-mobile/PLUGIN.md +1 -0
  28. package/plugins/specweave-mobile/skills/appstore/SKILL.md +1099 -0
  29. package/plugins/specweave-mobile/skills/capacitor-ionic/SKILL.md +1 -0
  30. package/plugins/specweave-mobile/skills/deep-linking-push/SKILL.md +1 -0
  31. package/plugins/specweave-mobile/skills/expo/SKILL.md +1 -0
  32. package/plugins/specweave-mobile/skills/flutter/SKILL.md +7 -0
  33. package/plugins/specweave-mobile/skills/jetpack-compose/SKILL.md +7 -0
  34. package/plugins/specweave-mobile/skills/mobile-testing/SKILL.md +1 -0
  35. package/plugins/specweave-mobile/skills/react-native-expert/SKILL.md +1 -0
  36. package/plugins/specweave-mobile/skills/swiftui/SKILL.md +6 -0
  37. package/dist/src/cli/commands/refresh-marketplace.d.ts +0 -21
  38. package/dist/src/cli/commands/refresh-marketplace.d.ts.map +0 -1
  39. package/dist/src/cli/commands/refresh-marketplace.js +0 -25
  40. package/dist/src/cli/commands/refresh-marketplace.js.map +0 -1
@@ -8,4 +8,4 @@ Error generating stack: `+l.message+`
8
8
  `+l.stack}}var zi=Object.prototype.hasOwnProperty,_i=r.unstable_scheduleCallback,Di=r.unstable_cancelCallback,Em=r.unstable_shouldYield,Tm=r.unstable_requestPaint,ht=r.unstable_now,Cm=r.unstable_getCurrentPriorityLevel,bu=r.unstable_ImmediatePriority,ju=r.unstable_UserBlockingPriority,ts=r.unstable_NormalPriority,Am=r.unstable_LowPriority,Nu=r.unstable_IdlePriority,wm=r.log,Mm=r.unstable_setDisableYieldValue,Fl=null,gt=null;function ma(e){if(typeof wm=="function"&&Mm(e),gt&&typeof gt.setStrictMode=="function")try{gt.setStrictMode(Fl,e)}catch{}}var yt=Math.clz32?Math.clz32:_m,Rm=Math.log,zm=Math.LN2;function _m(e){return e>>>=0,e===0?32:31-(Rm(e)/zm|0)|0}var as=256,ls=262144,ns=4194304;function $a(e){var t=e&42;if(t!==0)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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ss(e,t,a){var l=e.pendingLanes;if(l===0)return 0;var s=0,i=e.suspendedLanes,d=e.pingedLanes;e=e.warmLanes;var h=l&134217727;return h!==0?(l=h&~i,l!==0?s=$a(l):(d&=h,d!==0?s=$a(d):a||(a=h&~e,a!==0&&(s=$a(a))))):(h=l&~i,h!==0?s=$a(h):d!==0?s=$a(d):a||(a=l&~e,a!==0&&(s=$a(a)))),s===0?0:t!==0&&t!==s&&(t&i)===0&&(i=s&-s,a=t&-t,i>=a||i===32&&(a&4194048)!==0)?t:s}function Pl(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Dm(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;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Su(){var e=ns;return ns<<=1,(ns&62914560)===0&&(ns=4194304),e}function Oi(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function Il(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Om(e,t,a,l,s,i){var d=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var h=e.entanglements,j=e.expirationTimes,M=e.hiddenUpdates;for(a=d&~a;0<a;){var L=31-yt(a),q=1<<L;h[L]=0,j[L]=-1;var z=M[L];if(z!==null)for(M[L]=null,L=0;L<z.length;L++){var D=z[L];D!==null&&(D.lane&=-536870913)}a&=~q}l!==0&&Eu(e,l,0),i!==0&&s===0&&e.tag!==0&&(e.suspendedLanes|=i&~(d&~t))}function Eu(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var l=31-yt(t);e.entangledLanes|=t,e.entanglements[l]=e.entanglements[l]|1073741824|a&261930}function Tu(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var l=31-yt(a),s=1<<l;s&t|e[l]&t&&(e[l]|=t),a&=~s}}function Cu(e,t){var a=t&-t;return a=(a&42)!==0?1:Ui(a),(a&(e.suspendedLanes|t))!==0?0:a}function Ui(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 Li(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Au(){var e=k.p;return e!==0?e:(e=window.event,e===void 0?32:x0(e.type))}function wu(e,t){var a=k.p;try{return k.p=e,t()}finally{k.p=a}}var xa=Math.random().toString(36).slice(2),Fe="__reactFiber$"+xa,rt="__reactProps$"+xa,il="__reactContainer$"+xa,Hi="__reactEvents$"+xa,Um="__reactListeners$"+xa,Lm="__reactHandles$"+xa,Mu="__reactResources$"+xa,en="__reactMarker$"+xa;function Bi(e){delete e[Fe],delete e[rt],delete e[Hi],delete e[Um],delete e[Lm]}function rl(e){var t=e[Fe];if(t)return t;for(var a=e.parentNode;a;){if(t=a[il]||a[Fe]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=Pf(e);e!==null;){if(a=e[Fe])return a;e=Pf(e)}return t}e=a,a=e.parentNode}return null}function cl(e){if(e=e[Fe]||e[il]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function tn(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(u(33))}function ul(e){var t=e[Mu];return t||(t=e[Mu]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Je(e){e[en]=!0}var Ru=new Set,zu={};function Va(e,t){ol(e,t),ol(e+"Capture",t)}function ol(e,t){for(zu[e]=t,e=0;e<t.length;e++)Ru.add(t[e])}var Hm=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),_u={},Du={};function Bm(e){return zi.call(Du,e)?!0:zi.call(_u,e)?!1:Hm.test(e)?Du[e]=!0:(_u[e]=!0,!1)}function is(e,t,a){if(Bm(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var l=t.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function rs(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function kt(e,t,a,l){if(l===null)e.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+l)}}function Tt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ou(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function qm(e,t,a){var l=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var s=l.get,i=l.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(d){a=""+d,i.call(this,d)}}),Object.defineProperty(e,t,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(d){a=""+d},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function qi(e){if(!e._valueTracker){var t=Ou(e)?"checked":"value";e._valueTracker=qm(e,t,""+e[t])}}function Uu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),l="";return e&&(l=Ou(e)?e.checked?"true":"false":e.value),e=l,e!==a?(t.setValue(e),!0):!1}function cs(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Ym=/[\n"\\]/g;function Ct(e){return e.replace(Ym,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Yi(e,t,a,l,s,i,d,h){e.name="",d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"?e.type=d:e.removeAttribute("type"),t!=null?d==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Tt(t)):e.value!==""+Tt(t)&&(e.value=""+Tt(t)):d!=="submit"&&d!=="reset"||e.removeAttribute("value"),t!=null?Gi(e,d,Tt(t)):a!=null?Gi(e,d,Tt(a)):l!=null&&e.removeAttribute("value"),s==null&&i!=null&&(e.defaultChecked=!!i),s!=null&&(e.checked=s&&typeof s!="function"&&typeof s!="symbol"),h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?e.name=""+Tt(h):e.removeAttribute("name")}function Lu(e,t,a,l,s,i,d,h){if(i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"&&(e.type=i),t!=null||a!=null){if(!(i!=="submit"&&i!=="reset"||t!=null)){qi(e);return}a=a!=null?""+Tt(a):"",t=t!=null?""+Tt(t):a,h||t===e.value||(e.value=t),e.defaultValue=t}l=l??s,l=typeof l!="function"&&typeof l!="symbol"&&!!l,e.checked=h?e.checked:!!l,e.defaultChecked=!!l,d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(e.name=d),qi(e)}function Gi(e,t,a){t==="number"&&cs(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function dl(e,t,a,l){if(e=e.options,t){t={};for(var s=0;s<a.length;s++)t["$"+a[s]]=!0;for(a=0;a<e.length;a++)s=t.hasOwnProperty("$"+e[a].value),e[a].selected!==s&&(e[a].selected=s),s&&l&&(e[a].defaultSelected=!0)}else{for(a=""+Tt(a),t=null,s=0;s<e.length;s++){if(e[s].value===a){e[s].selected=!0,l&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function Hu(e,t,a){if(t!=null&&(t=""+Tt(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+Tt(a):""}function Bu(e,t,a,l){if(t==null){if(l!=null){if(a!=null)throw Error(u(92));if($e(l)){if(1<l.length)throw Error(u(93));l=l[0]}a=l}a==null&&(a=""),t=a}a=Tt(t),e.defaultValue=a,l=e.textContent,l===a&&l!==""&&l!==null&&(e.value=l),qi(e)}function fl(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var Gm=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 qu(e,t,a){var l=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":l?e.setProperty(t,a):typeof a!="number"||a===0||Gm.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function Yu(e,t,a){if(t!=null&&typeof t!="object")throw Error(u(62));if(e=e.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||t!=null&&t.hasOwnProperty(l)||(l.indexOf("--")===0?e.setProperty(l,""):l==="float"?e.cssFloat="":e[l]="");for(var s in t)l=t[s],t.hasOwnProperty(s)&&a[s]!==l&&qu(e,s,l)}else for(var i in t)t.hasOwnProperty(i)&&qu(e,i,t[i])}function $i(e){if(e.indexOf("-")===-1)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 $m=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-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"]]),Vm=/^[\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 us(e){return Vm.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Zt(){}var Vi=null;function Qi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ml=null,xl=null;function Gu(e){var t=cl(e);if(t&&(e=t.stateNode)){var a=e[rt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Yi(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Ct(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var l=a[t];if(l!==e&&l.form===e.form){var s=l[rt]||null;if(!s)throw Error(u(90));Yi(l,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name)}}for(t=0;t<a.length;t++)l=a[t],l.form===e.form&&Uu(l)}break e;case"textarea":Hu(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&dl(e,!!a.multiple,t,!1)}}}var Xi=!1;function $u(e,t,a){if(Xi)return e(t,a);Xi=!0;try{var l=e(t);return l}finally{if(Xi=!1,(ml!==null||xl!==null)&&(Ws(),ml&&(t=ml,e=xl,xl=ml=null,Gu(t),e)))for(t=0;t<e.length;t++)Gu(e[t])}}function an(e,t){var a=e.stateNode;if(a===null)return null;var l=a[rt]||null;if(l===null)return null;a=l[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":(l=!l.disabled)||(e=e.type,l=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!l;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(u(231,t,typeof a));return a}var Kt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ki=!1;if(Kt)try{var ln={};Object.defineProperty(ln,"passive",{get:function(){ki=!0}}),window.addEventListener("test",ln,ln),window.removeEventListener("test",ln,ln)}catch{ki=!1}var ha=null,Zi=null,os=null;function Vu(){if(os)return os;var e,t=Zi,a=t.length,l,s="value"in ha?ha.value:ha.textContent,i=s.length;for(e=0;e<a&&t[e]===s[e];e++);var d=a-e;for(l=1;l<=d&&t[a-l]===s[i-l];l++);return os=s.slice(e,1<l?1-l:void 0)}function ds(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function fs(){return!0}function Qu(){return!1}function ct(e){function t(a,l,s,i,d){this._reactName=a,this._targetInst=s,this.type=l,this.nativeEvent=i,this.target=d,this.currentTarget=null;for(var h in e)e.hasOwnProperty(h)&&(a=e[h],this[h]=a?a(i):i[h]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?fs:Qu,this.isPropagationStopped=Qu,this}return y(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=fs)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=fs)},persist:function(){},isPersistent:fs}),t}var Qa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ms=ct(Qa),nn=y({},Qa,{view:0,detail:0}),Qm=ct(nn),Ki,Ji,sn,xs=y({},nn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Fi,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==sn&&(sn&&e.type==="mousemove"?(Ki=e.screenX-sn.screenX,Ji=e.screenY-sn.screenY):Ji=Ki=0,sn=e),Ki)},movementY:function(e){return"movementY"in e?e.movementY:Ji}}),Xu=ct(xs),Xm=y({},xs,{dataTransfer:0}),km=ct(Xm),Zm=y({},nn,{relatedTarget:0}),Wi=ct(Zm),Km=y({},Qa,{animationName:0,elapsedTime:0,pseudoElement:0}),Jm=ct(Km),Wm=y({},Qa,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Fm=ct(Wm),Pm=y({},Qa,{data:0}),ku=ct(Pm),Im={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ex={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"},tx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ax(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=tx[e])?!!t[e]:!1}function Fi(){return ax}var lx=y({},nn,{key:function(e){if(e.key){var t=Im[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ds(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?ex[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Fi,charCode:function(e){return e.type==="keypress"?ds(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ds(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),nx=ct(lx),sx=y({},xs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Zu=ct(sx),ix=y({},nn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Fi}),rx=ct(ix),cx=y({},Qa,{propertyName:0,elapsedTime:0,pseudoElement:0}),ux=ct(cx),ox=y({},xs,{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}),dx=ct(ox),fx=y({},Qa,{newState:0,oldState:0}),mx=ct(fx),xx=[9,13,27,32],Pi=Kt&&"CompositionEvent"in window,rn=null;Kt&&"documentMode"in document&&(rn=document.documentMode);var hx=Kt&&"TextEvent"in window&&!rn,Ku=Kt&&(!Pi||rn&&8<rn&&11>=rn),Ju=" ",Wu=!1;function Fu(e,t){switch(e){case"keyup":return xx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var hl=!1;function gx(e,t){switch(e){case"compositionend":return Pu(t);case"keypress":return t.which!==32?null:(Wu=!0,Ju);case"textInput":return e=t.data,e===Ju&&Wu?null:e;default:return null}}function yx(e,t){if(hl)return e==="compositionend"||!Pi&&Fu(e,t)?(e=Vu(),os=Zi=ha=null,hl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ku&&t.locale!=="ko"?null:t.data;default:return null}}var px={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 Iu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!px[e.type]:t==="textarea"}function eo(e,t,a,l){ml?xl?xl.push(l):xl=[l]:ml=l,t=li(t,"onChange"),0<t.length&&(a=new ms("onChange","change",null,a,l),e.push({event:a,listeners:t}))}var cn=null,un=null;function vx(e){Bf(e,0)}function hs(e){var t=tn(e);if(Uu(t))return e}function to(e,t){if(e==="change")return t}var ao=!1;if(Kt){var Ii;if(Kt){var er="oninput"in document;if(!er){var lo=document.createElement("div");lo.setAttribute("oninput","return;"),er=typeof lo.oninput=="function"}Ii=er}else Ii=!1;ao=Ii&&(!document.documentMode||9<document.documentMode)}function no(){cn&&(cn.detachEvent("onpropertychange",so),un=cn=null)}function so(e){if(e.propertyName==="value"&&hs(un)){var t=[];eo(t,un,e,Qi(e)),$u(vx,t)}}function bx(e,t,a){e==="focusin"?(no(),cn=t,un=a,cn.attachEvent("onpropertychange",so)):e==="focusout"&&no()}function jx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return hs(un)}function Nx(e,t){if(e==="click")return hs(t)}function Sx(e,t){if(e==="input"||e==="change")return hs(t)}function Ex(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var pt=typeof Object.is=="function"?Object.is:Ex;function on(e,t){if(pt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),l=Object.keys(t);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var s=a[l];if(!zi.call(t,s)||!pt(e[s],t[s]))return!1}return!0}function io(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ro(e,t){var a=io(e);e=0;for(var l;a;){if(a.nodeType===3){if(l=e+a.textContent.length,e<=t&&l>=t)return{node:a,offset:t-e};e=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=io(a)}}function co(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?co(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function uo(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=cs(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=cs(e.document)}return t}function tr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Tx=Kt&&"documentMode"in document&&11>=document.documentMode,gl=null,ar=null,dn=null,lr=!1;function oo(e,t,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;lr||gl==null||gl!==cs(l)||(l=gl,"selectionStart"in l&&tr(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),dn&&on(dn,l)||(dn=l,l=li(ar,"onSelect"),0<l.length&&(t=new ms("onSelect","select",null,t,a),e.push({event:t,listeners:l}),t.target=gl)))}function Xa(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var yl={animationend:Xa("Animation","AnimationEnd"),animationiteration:Xa("Animation","AnimationIteration"),animationstart:Xa("Animation","AnimationStart"),transitionrun:Xa("Transition","TransitionRun"),transitionstart:Xa("Transition","TransitionStart"),transitioncancel:Xa("Transition","TransitionCancel"),transitionend:Xa("Transition","TransitionEnd")},nr={},fo={};Kt&&(fo=document.createElement("div").style,"AnimationEvent"in window||(delete yl.animationend.animation,delete yl.animationiteration.animation,delete yl.animationstart.animation),"TransitionEvent"in window||delete yl.transitionend.transition);function ka(e){if(nr[e])return nr[e];if(!yl[e])return e;var t=yl[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in fo)return nr[e]=t[a];return e}var mo=ka("animationend"),xo=ka("animationiteration"),ho=ka("animationstart"),Cx=ka("transitionrun"),Ax=ka("transitionstart"),wx=ka("transitioncancel"),go=ka("transitionend"),yo=new Map,sr="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(" ");sr.push("scrollEnd");function Lt(e,t){yo.set(e,t),Va(t,[e])}var gs=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},At=[],pl=0,ir=0;function ys(){for(var e=pl,t=ir=pl=0;t<e;){var a=At[t];At[t++]=null;var l=At[t];At[t++]=null;var s=At[t];At[t++]=null;var i=At[t];if(At[t++]=null,l!==null&&s!==null){var d=l.pending;d===null?s.next=s:(s.next=d.next,d.next=s),l.pending=s}i!==0&&po(a,s,i)}}function ps(e,t,a,l){At[pl++]=e,At[pl++]=t,At[pl++]=a,At[pl++]=l,ir|=l,e.lanes|=l,e=e.alternate,e!==null&&(e.lanes|=l)}function rr(e,t,a,l){return ps(e,t,a,l),vs(e)}function Za(e,t){return ps(e,null,null,t),vs(e)}function po(e,t,a){e.lanes|=a;var l=e.alternate;l!==null&&(l.lanes|=a);for(var s=!1,i=e.return;i!==null;)i.childLanes|=a,l=i.alternate,l!==null&&(l.childLanes|=a),i.tag===22&&(e=i.stateNode,e===null||e._visibility&1||(s=!0)),e=i,i=i.return;return e.tag===3?(i=e.stateNode,s&&t!==null&&(s=31-yt(a),e=i.hiddenUpdates,l=e[s],l===null?e[s]=[t]:l.push(t),t.lane=a|536870912),i):null}function vs(e){if(50<Dn)throw Dn=0,gc=null,Error(u(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var vl={};function Mx(e,t,a,l){this.tag=e,this.key=a,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=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vt(e,t,a,l){return new Mx(e,t,a,l)}function cr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jt(e,t){var a=e.alternate;return a===null?(a=vt(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function vo(e,t){e.flags&=65011714;var a=e.alternate;return a===null?(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=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function bs(e,t,a,l,s,i){var d=0;if(l=e,typeof e=="function")cr(e)&&(d=1);else if(typeof e=="string")d=Oh(e,a,F.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case B:return e=vt(31,a,t,s),e.elementType=B,e.lanes=i,e;case $:return Ka(a.children,s,i,t);case _:d=8,s|=24;break;case G:return e=vt(12,a,t,s|2),e.elementType=G,e.lanes=i,e;case P:return e=vt(13,a,t,s),e.elementType=P,e.lanes=i,e;case J:return e=vt(19,a,t,s),e.elementType=J,e.lanes=i,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case V:d=10;break e;case A:d=9;break e;case re:d=11;break e;case Q:d=14;break e;case Z:d=16,l=null;break e}d=29,a=Error(u(130,e===null?"null":typeof e,"")),l=null}return t=vt(d,a,t,s),t.elementType=e,t.type=l,t.lanes=i,t}function Ka(e,t,a,l){return e=vt(7,e,l,t),e.lanes=a,e}function ur(e,t,a){return e=vt(6,e,null,t),e.lanes=a,e}function bo(e){var t=vt(18,null,null,0);return t.stateNode=e,t}function or(e,t,a){return t=vt(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var jo=new WeakMap;function wt(e,t){if(typeof e=="object"&&e!==null){var a=jo.get(e);return a!==void 0?a:(t={value:e,source:t,stack:vu(t)},jo.set(e,t),t)}return{value:e,source:t,stack:vu(t)}}var bl=[],jl=0,js=null,fn=0,Mt=[],Rt=0,ga=null,Yt=1,Gt="";function Wt(e,t){bl[jl++]=fn,bl[jl++]=js,js=e,fn=t}function No(e,t,a){Mt[Rt++]=Yt,Mt[Rt++]=Gt,Mt[Rt++]=ga,ga=e;var l=Yt;e=Gt;var s=32-yt(l)-1;l&=~(1<<s),a+=1;var i=32-yt(t)+s;if(30<i){var d=s-s%5;i=(l&(1<<d)-1).toString(32),l>>=d,s-=d,Yt=1<<32-yt(t)+s|a<<s|l,Gt=i+e}else Yt=1<<i|a<<s|l,Gt=e}function dr(e){e.return!==null&&(Wt(e,1),No(e,1,0))}function fr(e){for(;e===js;)js=bl[--jl],bl[jl]=null,fn=bl[--jl],bl[jl]=null;for(;e===ga;)ga=Mt[--Rt],Mt[Rt]=null,Gt=Mt[--Rt],Mt[Rt]=null,Yt=Mt[--Rt],Mt[Rt]=null}function So(e,t){Mt[Rt++]=Yt,Mt[Rt++]=Gt,Mt[Rt++]=ga,Yt=t.id,Gt=t.overflow,ga=e}var Pe=null,ze=null,ve=!1,ya=null,zt=!1,mr=Error(u(519));function pa(e){var t=Error(u(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw mn(wt(t,e)),mr}function Eo(e){var t=e.stateNode,a=e.type,l=e.memoizedProps;switch(t[Fe]=e,t[rt]=l,a){case"dialog":ge("cancel",t),ge("close",t);break;case"iframe":case"object":case"embed":ge("load",t);break;case"video":case"audio":for(a=0;a<Un.length;a++)ge(Un[a],t);break;case"source":ge("error",t);break;case"img":case"image":case"link":ge("error",t),ge("load",t);break;case"details":ge("toggle",t);break;case"input":ge("invalid",t),Lu(t,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":ge("invalid",t);break;case"textarea":ge("invalid",t),Bu(t,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||l.suppressHydrationWarning===!0||$f(t.textContent,a)?(l.popover!=null&&(ge("beforetoggle",t),ge("toggle",t)),l.onScroll!=null&&ge("scroll",t),l.onScrollEnd!=null&&ge("scrollend",t),l.onClick!=null&&(t.onclick=Zt),t=!0):t=!1,t||pa(e,!0)}function To(e){for(Pe=e.return;Pe;)switch(Pe.tag){case 5:case 31:case 13:zt=!1;return;case 27:case 3:zt=!0;return;default:Pe=Pe.return}}function Nl(e){if(e!==Pe)return!1;if(!ve)return To(e),ve=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||zc(e.type,e.memoizedProps)),a=!a),a&&ze&&pa(e),To(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(u(317));ze=Ff(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(u(317));ze=Ff(e)}else t===27?(t=ze,_a(e.type)?(e=Lc,Lc=null,ze=e):ze=t):ze=Pe?Dt(e.stateNode.nextSibling):null;return!0}function Ja(){ze=Pe=null,ve=!1}function xr(){var e=ya;return e!==null&&(ft===null?ft=e:ft.push.apply(ft,e),ya=null),e}function mn(e){ya===null?ya=[e]:ya.push(e)}var hr=T(null),Wa=null,Ft=null;function va(e,t,a){K(hr,t._currentValue),t._currentValue=a}function Pt(e){e._currentValue=hr.current,Y(hr)}function gr(e,t,a){for(;e!==null;){var l=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),e===a)break;e=e.return}}function yr(e,t,a,l){var s=e.child;for(s!==null&&(s.return=e);s!==null;){var i=s.dependencies;if(i!==null){var d=s.child;i=i.firstContext;e:for(;i!==null;){var h=i;i=s;for(var j=0;j<t.length;j++)if(h.context===t[j]){i.lanes|=a,h=i.alternate,h!==null&&(h.lanes|=a),gr(i.return,a,e),l||(d=null);break e}i=h.next}}else if(s.tag===18){if(d=s.return,d===null)throw Error(u(341));d.lanes|=a,i=d.alternate,i!==null&&(i.lanes|=a),gr(d,a,e),d=null}else d=s.child;if(d!==null)d.return=s;else for(d=s;d!==null;){if(d===e){d=null;break}if(s=d.sibling,s!==null){s.return=d.return,d=s;break}d=d.return}s=d}}function Sl(e,t,a,l){e=null;for(var s=t,i=!1;s!==null;){if(!i){if((s.flags&524288)!==0)i=!0;else if((s.flags&262144)!==0)break}if(s.tag===10){var d=s.alternate;if(d===null)throw Error(u(387));if(d=d.memoizedProps,d!==null){var h=s.type;pt(s.pendingProps.value,d.value)||(e!==null?e.push(h):e=[h])}}else if(s===I.current){if(d=s.alternate,d===null)throw Error(u(387));d.memoizedState.memoizedState!==s.memoizedState.memoizedState&&(e!==null?e.push(Yn):e=[Yn])}s=s.return}e!==null&&yr(t,e,a,l),t.flags|=262144}function Ns(e){for(e=e.firstContext;e!==null;){if(!pt(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Fa(e){Wa=e,Ft=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ie(e){return Co(Wa,e)}function Ss(e,t){return Wa===null&&Fa(e),Co(e,t)}function Co(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},Ft===null){if(e===null)throw Error(u(308));Ft=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ft=Ft.next=t;return a}var Rx=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,l){e.push(l)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},zx=r.unstable_scheduleCallback,_x=r.unstable_NormalPriority,Ve={$$typeof:V,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function pr(){return{controller:new Rx,data:new Map,refCount:0}}function xn(e){e.refCount--,e.refCount===0&&zx(_x,function(){e.controller.abort()})}var hn=null,vr=0,El=0,Tl=null;function Dx(e,t){if(hn===null){var a=hn=[];vr=0,El=Nc(),Tl={status:"pending",value:void 0,then:function(l){a.push(l)}}}return vr++,t.then(Ao,Ao),t}function Ao(){if(--vr===0&&hn!==null){Tl!==null&&(Tl.status="fulfilled");var e=hn;hn=null,El=0,Tl=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ox(e,t){var a=[],l={status:"pending",value:null,reason:null,then:function(s){a.push(s)}};return e.then(function(){l.status="fulfilled",l.value=t;for(var s=0;s<a.length;s++)(0,a[s])(t)},function(s){for(l.status="rejected",l.reason=s,s=0;s<a.length;s++)(0,a[s])(void 0)}),l}var wo=U.S;U.S=function(e,t){ff=ht(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Dx(e,t),wo!==null&&wo(e,t)};var Pa=T(null);function br(){var e=Pa.current;return e!==null?e:we.pooledCache}function Es(e,t){t===null?K(Pa,Pa.current):K(Pa,t.pool)}function Mo(){var e=br();return e===null?null:{parent:Ve._currentValue,pool:e}}var Cl=Error(u(460)),jr=Error(u(474)),Ts=Error(u(542)),Cs={then:function(){}};function Ro(e){return e=e.status,e==="fulfilled"||e==="rejected"}function zo(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(Zt,Zt),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Do(e),e;default:if(typeof t.status=="string")t.then(Zt,Zt);else{if(e=we,e!==null&&100<e.shellSuspendCounter)throw Error(u(482));e=t,e.status="pending",e.then(function(l){if(t.status==="pending"){var s=t;s.status="fulfilled",s.value=l}},function(l){if(t.status==="pending"){var s=t;s.status="rejected",s.reason=l}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Do(e),e}throw el=t,Cl}}function Ia(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(el=a,Cl):a}}var el=null;function _o(){if(el===null)throw Error(u(459));var e=el;return el=null,e}function Do(e){if(e===Cl||e===Ts)throw Error(u(483))}var Al=null,gn=0;function As(e){var t=gn;return gn+=1,Al===null&&(Al=[]),zo(Al,e,t)}function yn(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function ws(e,t){throw t.$$typeof===N?Error(u(525)):(e=Object.prototype.toString.call(t),Error(u(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Oo(e){function t(C,E){if(e){var w=C.deletions;w===null?(C.deletions=[E],C.flags|=16):w.push(E)}}function a(C,E){if(!e)return null;for(;E!==null;)t(C,E),E=E.sibling;return null}function l(C){for(var E=new Map;C!==null;)C.key!==null?E.set(C.key,C):E.set(C.index,C),C=C.sibling;return E}function s(C,E){return C=Jt(C,E),C.index=0,C.sibling=null,C}function i(C,E,w){return C.index=w,e?(w=C.alternate,w!==null?(w=w.index,w<E?(C.flags|=67108866,E):w):(C.flags|=67108866,E)):(C.flags|=1048576,E)}function d(C){return e&&C.alternate===null&&(C.flags|=67108866),C}function h(C,E,w,H){return E===null||E.tag!==6?(E=ur(w,C.mode,H),E.return=C,E):(E=s(E,w),E.return=C,E)}function j(C,E,w,H){var ae=w.type;return ae===$?L(C,E,w.props.children,H,w.key):E!==null&&(E.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===Z&&Ia(ae)===E.type)?(E=s(E,w.props),yn(E,w),E.return=C,E):(E=bs(w.type,w.key,w.props,null,C.mode,H),yn(E,w),E.return=C,E)}function M(C,E,w,H){return E===null||E.tag!==4||E.stateNode.containerInfo!==w.containerInfo||E.stateNode.implementation!==w.implementation?(E=or(w,C.mode,H),E.return=C,E):(E=s(E,w.children||[]),E.return=C,E)}function L(C,E,w,H,ae){return E===null||E.tag!==7?(E=Ka(w,C.mode,H,ae),E.return=C,E):(E=s(E,w),E.return=C,E)}function q(C,E,w){if(typeof E=="string"&&E!==""||typeof E=="number"||typeof E=="bigint")return E=ur(""+E,C.mode,w),E.return=C,E;if(typeof E=="object"&&E!==null){switch(E.$$typeof){case R:return w=bs(E.type,E.key,E.props,null,C.mode,w),yn(w,E),w.return=C,w;case O:return E=or(E,C.mode,w),E.return=C,E;case Z:return E=Ia(E),q(C,E,w)}if($e(E)||Oe(E))return E=Ka(E,C.mode,w,null),E.return=C,E;if(typeof E.then=="function")return q(C,As(E),w);if(E.$$typeof===V)return q(C,Ss(C,E),w);ws(C,E)}return null}function z(C,E,w,H){var ae=E!==null?E.key:null;if(typeof w=="string"&&w!==""||typeof w=="number"||typeof w=="bigint")return ae!==null?null:h(C,E,""+w,H);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case R:return w.key===ae?j(C,E,w,H):null;case O:return w.key===ae?M(C,E,w,H):null;case Z:return w=Ia(w),z(C,E,w,H)}if($e(w)||Oe(w))return ae!==null?null:L(C,E,w,H,null);if(typeof w.then=="function")return z(C,E,As(w),H);if(w.$$typeof===V)return z(C,E,Ss(C,w),H);ws(C,w)}return null}function D(C,E,w,H,ae){if(typeof H=="string"&&H!==""||typeof H=="number"||typeof H=="bigint")return C=C.get(w)||null,h(E,C,""+H,ae);if(typeof H=="object"&&H!==null){switch(H.$$typeof){case R:return C=C.get(H.key===null?w:H.key)||null,j(E,C,H,ae);case O:return C=C.get(H.key===null?w:H.key)||null,M(E,C,H,ae);case Z:return H=Ia(H),D(C,E,w,H,ae)}if($e(H)||Oe(H))return C=C.get(w)||null,L(E,C,H,ae,null);if(typeof H.then=="function")return D(C,E,w,As(H),ae);if(H.$$typeof===V)return D(C,E,w,Ss(E,H),ae);ws(E,H)}return null}function W(C,E,w,H){for(var ae=null,be=null,ee=E,de=E=0,pe=null;ee!==null&&de<w.length;de++){ee.index>de?(pe=ee,ee=null):pe=ee.sibling;var je=z(C,ee,w[de],H);if(je===null){ee===null&&(ee=pe);break}e&&ee&&je.alternate===null&&t(C,ee),E=i(je,E,de),be===null?ae=je:be.sibling=je,be=je,ee=pe}if(de===w.length)return a(C,ee),ve&&Wt(C,de),ae;if(ee===null){for(;de<w.length;de++)ee=q(C,w[de],H),ee!==null&&(E=i(ee,E,de),be===null?ae=ee:be.sibling=ee,be=ee);return ve&&Wt(C,de),ae}for(ee=l(ee);de<w.length;de++)pe=D(ee,C,de,w[de],H),pe!==null&&(e&&pe.alternate!==null&&ee.delete(pe.key===null?de:pe.key),E=i(pe,E,de),be===null?ae=pe:be.sibling=pe,be=pe);return e&&ee.forEach(function(Ha){return t(C,Ha)}),ve&&Wt(C,de),ae}function se(C,E,w,H){if(w==null)throw Error(u(151));for(var ae=null,be=null,ee=E,de=E=0,pe=null,je=w.next();ee!==null&&!je.done;de++,je=w.next()){ee.index>de?(pe=ee,ee=null):pe=ee.sibling;var Ha=z(C,ee,je.value,H);if(Ha===null){ee===null&&(ee=pe);break}e&&ee&&Ha.alternate===null&&t(C,ee),E=i(Ha,E,de),be===null?ae=Ha:be.sibling=Ha,be=Ha,ee=pe}if(je.done)return a(C,ee),ve&&Wt(C,de),ae;if(ee===null){for(;!je.done;de++,je=w.next())je=q(C,je.value,H),je!==null&&(E=i(je,E,de),be===null?ae=je:be.sibling=je,be=je);return ve&&Wt(C,de),ae}for(ee=l(ee);!je.done;de++,je=w.next())je=D(ee,C,de,je.value,H),je!==null&&(e&&je.alternate!==null&&ee.delete(je.key===null?de:je.key),E=i(je,E,de),be===null?ae=je:be.sibling=je,be=je);return e&&ee.forEach(function(Xh){return t(C,Xh)}),ve&&Wt(C,de),ae}function Ae(C,E,w,H){if(typeof w=="object"&&w!==null&&w.type===$&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case R:e:{for(var ae=w.key;E!==null;){if(E.key===ae){if(ae=w.type,ae===$){if(E.tag===7){a(C,E.sibling),H=s(E,w.props.children),H.return=C,C=H;break e}}else if(E.elementType===ae||typeof ae=="object"&&ae!==null&&ae.$$typeof===Z&&Ia(ae)===E.type){a(C,E.sibling),H=s(E,w.props),yn(H,w),H.return=C,C=H;break e}a(C,E);break}else t(C,E);E=E.sibling}w.type===$?(H=Ka(w.props.children,C.mode,H,w.key),H.return=C,C=H):(H=bs(w.type,w.key,w.props,null,C.mode,H),yn(H,w),H.return=C,C=H)}return d(C);case O:e:{for(ae=w.key;E!==null;){if(E.key===ae)if(E.tag===4&&E.stateNode.containerInfo===w.containerInfo&&E.stateNode.implementation===w.implementation){a(C,E.sibling),H=s(E,w.children||[]),H.return=C,C=H;break e}else{a(C,E);break}else t(C,E);E=E.sibling}H=or(w,C.mode,H),H.return=C,C=H}return d(C);case Z:return w=Ia(w),Ae(C,E,w,H)}if($e(w))return W(C,E,w,H);if(Oe(w)){if(ae=Oe(w),typeof ae!="function")throw Error(u(150));return w=ae.call(w),se(C,E,w,H)}if(typeof w.then=="function")return Ae(C,E,As(w),H);if(w.$$typeof===V)return Ae(C,E,Ss(C,w),H);ws(C,w)}return typeof w=="string"&&w!==""||typeof w=="number"||typeof w=="bigint"?(w=""+w,E!==null&&E.tag===6?(a(C,E.sibling),H=s(E,w),H.return=C,C=H):(a(C,E),H=ur(w,C.mode,H),H.return=C,C=H),d(C)):a(C,E)}return function(C,E,w,H){try{gn=0;var ae=Ae(C,E,w,H);return Al=null,ae}catch(ee){if(ee===Cl||ee===Ts)throw ee;var be=vt(29,ee,null,C.mode);return be.lanes=H,be.return=C,be}}}var tl=Oo(!0),Uo=Oo(!1),ba=!1;function Nr(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Sr(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 ja(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Na(e,t,a){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ne&2)!==0){var s=l.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),l.pending=t,t=vs(e),po(e,null,a),t}return ps(e,l,t,a),vs(e)}function pn(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,Tu(e,a)}}function Er(e,t){var a=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var s=null,i=null;if(a=a.firstBaseUpdate,a!==null){do{var d={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};i===null?s=i=d:i=i.next=d,a=a.next}while(a!==null);i===null?s=i=t:i=i.next=t}else s=i=t;a={baseState:l.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:l.shared,callbacks:l.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var Tr=!1;function vn(){if(Tr){var e=Tl;if(e!==null)throw e}}function bn(e,t,a,l){Tr=!1;var s=e.updateQueue;ba=!1;var i=s.firstBaseUpdate,d=s.lastBaseUpdate,h=s.shared.pending;if(h!==null){s.shared.pending=null;var j=h,M=j.next;j.next=null,d===null?i=M:d.next=M,d=j;var L=e.alternate;L!==null&&(L=L.updateQueue,h=L.lastBaseUpdate,h!==d&&(h===null?L.firstBaseUpdate=M:h.next=M,L.lastBaseUpdate=j))}if(i!==null){var q=s.baseState;d=0,L=M=j=null,h=i;do{var z=h.lane&-536870913,D=z!==h.lane;if(D?(ye&z)===z:(l&z)===z){z!==0&&z===El&&(Tr=!0),L!==null&&(L=L.next={lane:0,tag:h.tag,payload:h.payload,callback:null,next:null});e:{var W=e,se=h;z=t;var Ae=a;switch(se.tag){case 1:if(W=se.payload,typeof W=="function"){q=W.call(Ae,q,z);break e}q=W;break e;case 3:W.flags=W.flags&-65537|128;case 0:if(W=se.payload,z=typeof W=="function"?W.call(Ae,q,z):W,z==null)break e;q=y({},q,z);break e;case 2:ba=!0}}z=h.callback,z!==null&&(e.flags|=64,D&&(e.flags|=8192),D=s.callbacks,D===null?s.callbacks=[z]:D.push(z))}else D={lane:z,tag:h.tag,payload:h.payload,callback:h.callback,next:null},L===null?(M=L=D,j=q):L=L.next=D,d|=z;if(h=h.next,h===null){if(h=s.shared.pending,h===null)break;D=h,h=D.next,D.next=null,s.lastBaseUpdate=D,s.shared.pending=null}}while(!0);L===null&&(j=q),s.baseState=j,s.firstBaseUpdate=M,s.lastBaseUpdate=L,i===null&&(s.shared.lanes=0),Aa|=d,e.lanes=d,e.memoizedState=q}}function Lo(e,t){if(typeof e!="function")throw Error(u(191,e));e.call(t)}function Ho(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)Lo(a[e],t)}var wl=T(null),Ms=T(0);function Bo(e,t){e=ra,K(Ms,e),K(wl,t),ra=e|t.baseLanes}function Cr(){K(Ms,ra),K(wl,wl.current)}function Ar(){ra=Ms.current,Y(wl),Y(Ms)}var bt=T(null),_t=null;function Sa(e){var t=e.alternate;K(qe,qe.current&1),K(bt,e),_t===null&&(t===null||wl.current!==null||t.memoizedState!==null)&&(_t=e)}function wr(e){K(qe,qe.current),K(bt,e),_t===null&&(_t=e)}function qo(e){e.tag===22?(K(qe,qe.current),K(bt,e),_t===null&&(_t=e)):Ea()}function Ea(){K(qe,qe.current),K(bt,bt.current)}function jt(e){Y(bt),_t===e&&(_t=null),Y(qe)}var qe=T(0);function Rs(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Oc(a)||Uc(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var It=0,oe=null,Te=null,Qe=null,zs=!1,Ml=!1,al=!1,_s=0,jn=0,Rl=null,Ux=0;function Le(){throw Error(u(321))}function Mr(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!pt(e[a],t[a]))return!1;return!0}function Rr(e,t,a,l,s,i){return It=i,oe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,U.H=e===null||e.memoizedState===null?Nd:Xr,al=!1,i=a(l,s),al=!1,Ml&&(i=Go(t,a,l,s)),Yo(e),i}function Yo(e){U.H=En;var t=Te!==null&&Te.next!==null;if(It=0,Qe=Te=oe=null,zs=!1,jn=0,Rl=null,t)throw Error(u(300));e===null||Xe||(e=e.dependencies,e!==null&&Ns(e)&&(Xe=!0))}function Go(e,t,a,l){oe=e;var s=0;do{if(Ml&&(Rl=null),jn=0,Ml=!1,25<=s)throw Error(u(301));if(s+=1,Qe=Te=null,e.updateQueue!=null){var i=e.updateQueue;i.lastEffect=null,i.events=null,i.stores=null,i.memoCache!=null&&(i.memoCache.index=0)}U.H=Sd,i=t(a,l)}while(Ml);return i}function Lx(){var e=U.H,t=e.useState()[0];return t=typeof t.then=="function"?Nn(t):t,e=e.useState()[0],(Te!==null?Te.memoizedState:null)!==e&&(oe.flags|=1024),t}function zr(){var e=_s!==0;return _s=0,e}function _r(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function Dr(e){if(zs){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}zs=!1}It=0,Qe=Te=oe=null,Ml=!1,jn=_s=0,Rl=null}function it(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Qe===null?oe.memoizedState=Qe=e:Qe=Qe.next=e,Qe}function Ye(){if(Te===null){var e=oe.alternate;e=e!==null?e.memoizedState:null}else e=Te.next;var t=Qe===null?oe.memoizedState:Qe.next;if(t!==null)Qe=t,Te=e;else{if(e===null)throw oe.alternate===null?Error(u(467)):Error(u(310));Te=e,e={memoizedState:Te.memoizedState,baseState:Te.baseState,baseQueue:Te.baseQueue,queue:Te.queue,next:null},Qe===null?oe.memoizedState=Qe=e:Qe=Qe.next=e}return Qe}function Ds(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Nn(e){var t=jn;return jn+=1,Rl===null&&(Rl=[]),e=zo(Rl,e,t),t=oe,(Qe===null?t.memoizedState:Qe.next)===null&&(t=t.alternate,U.H=t===null||t.memoizedState===null?Nd:Xr),e}function Os(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Nn(e);if(e.$$typeof===V)return Ie(e)}throw Error(u(438,String(e)))}function Or(e){var t=null,a=oe.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var l=oe.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(t={data:l.data.map(function(s){return s.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=Ds(),oe.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),l=0;l<e;l++)a[l]=te;return t.index++,a}function ea(e,t){return typeof t=="function"?t(e):t}function Us(e){var t=Ye();return Ur(t,Te,e)}function Ur(e,t,a){var l=e.queue;if(l===null)throw Error(u(311));l.lastRenderedReducer=a;var s=e.baseQueue,i=l.pending;if(i!==null){if(s!==null){var d=s.next;s.next=i.next,i.next=d}t.baseQueue=s=i,l.pending=null}if(i=e.baseState,s===null)e.memoizedState=i;else{t=s.next;var h=d=null,j=null,M=t,L=!1;do{var q=M.lane&-536870913;if(q!==M.lane?(ye&q)===q:(It&q)===q){var z=M.revertLane;if(z===0)j!==null&&(j=j.next={lane:0,revertLane:0,gesture:null,action:M.action,hasEagerState:M.hasEagerState,eagerState:M.eagerState,next:null}),q===El&&(L=!0);else if((It&z)===z){M=M.next,z===El&&(L=!0);continue}else q={lane:0,revertLane:M.revertLane,gesture:null,action:M.action,hasEagerState:M.hasEagerState,eagerState:M.eagerState,next:null},j===null?(h=j=q,d=i):j=j.next=q,oe.lanes|=z,Aa|=z;q=M.action,al&&a(i,q),i=M.hasEagerState?M.eagerState:a(i,q)}else z={lane:q,revertLane:M.revertLane,gesture:M.gesture,action:M.action,hasEagerState:M.hasEagerState,eagerState:M.eagerState,next:null},j===null?(h=j=z,d=i):j=j.next=z,oe.lanes|=q,Aa|=q;M=M.next}while(M!==null&&M!==t);if(j===null?d=i:j.next=h,!pt(i,e.memoizedState)&&(Xe=!0,L&&(a=Tl,a!==null)))throw a;e.memoizedState=i,e.baseState=d,e.baseQueue=j,l.lastRenderedState=i}return s===null&&(l.lanes=0),[e.memoizedState,l.dispatch]}function Lr(e){var t=Ye(),a=t.queue;if(a===null)throw Error(u(311));a.lastRenderedReducer=e;var l=a.dispatch,s=a.pending,i=t.memoizedState;if(s!==null){a.pending=null;var d=s=s.next;do i=e(i,d.action),d=d.next;while(d!==s);pt(i,t.memoizedState)||(Xe=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),a.lastRenderedState=i}return[i,l]}function $o(e,t,a){var l=oe,s=Ye(),i=ve;if(i){if(a===void 0)throw Error(u(407));a=a()}else a=t();var d=!pt((Te||s).memoizedState,a);if(d&&(s.memoizedState=a,Xe=!0),s=s.queue,qr(Xo.bind(null,l,s,e),[e]),s.getSnapshot!==t||d||Qe!==null&&Qe.memoizedState.tag&1){if(l.flags|=2048,zl(9,{destroy:void 0},Qo.bind(null,l,s,a,t),null),we===null)throw Error(u(349));i||(It&127)!==0||Vo(l,t,a)}return a}function Vo(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=oe.updateQueue,t===null?(t=Ds(),oe.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Qo(e,t,a,l){t.value=a,t.getSnapshot=l,ko(t)&&Zo(e)}function Xo(e,t,a){return a(function(){ko(t)&&Zo(e)})}function ko(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!pt(e,a)}catch{return!0}}function Zo(e){var t=Za(e,2);t!==null&&mt(t,e,2)}function Hr(e){var t=it();if(typeof e=="function"){var a=e;if(e=a(),al){ma(!0);try{a()}finally{ma(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ea,lastRenderedState:e},t}function Ko(e,t,a,l){return e.baseState=a,Ur(e,Te,typeof l=="function"?l:ea)}function Hx(e,t,a,l,s){if(Bs(e))throw Error(u(485));if(e=t.action,e!==null){var i={payload:s,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(d){i.listeners.push(d)}};U.T!==null?a(!0):i.isTransition=!1,l(i),a=t.pending,a===null?(i.next=t.pending=i,Jo(t,i)):(i.next=a.next,t.pending=a.next=i)}}function Jo(e,t){var a=t.action,l=t.payload,s=e.state;if(t.isTransition){var i=U.T,d={};U.T=d;try{var h=a(s,l),j=U.S;j!==null&&j(d,h),Wo(e,t,h)}catch(M){Br(e,t,M)}finally{i!==null&&d.types!==null&&(i.types=d.types),U.T=i}}else try{i=a(s,l),Wo(e,t,i)}catch(M){Br(e,t,M)}}function Wo(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Fo(e,t,l)},function(l){return Br(e,t,l)}):Fo(e,t,a)}function Fo(e,t,a){t.status="fulfilled",t.value=a,Po(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Jo(e,a)))}function Br(e,t,a){var l=e.pending;if(e.pending=null,l!==null){l=l.next;do t.status="rejected",t.reason=a,Po(t),t=t.next;while(t!==l)}e.action=null}function Po(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Io(e,t){return t}function ed(e,t){if(ve){var a=we.formState;if(a!==null){e:{var l=oe;if(ve){if(ze){t:{for(var s=ze,i=zt;s.nodeType!==8;){if(!i){s=null;break t}if(s=Dt(s.nextSibling),s===null){s=null;break t}}i=s.data,s=i==="F!"||i==="F"?s:null}if(s){ze=Dt(s.nextSibling),l=s.data==="F!";break e}}pa(l)}l=!1}l&&(t=a[0])}}return a=it(),a.memoizedState=a.baseState=t,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Io,lastRenderedState:t},a.queue=l,a=vd.bind(null,oe,l),l.dispatch=a,l=Hr(!1),i=Qr.bind(null,oe,!1,l.queue),l=it(),s={state:t,dispatch:null,action:e,pending:null},l.queue=s,a=Hx.bind(null,oe,s,i,a),s.dispatch=a,l.memoizedState=e,[t,a,!1]}function td(e){var t=Ye();return ad(t,Te,e)}function ad(e,t,a){if(t=Ur(e,t,Io)[0],e=Us(ea)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var l=Nn(t)}catch(d){throw d===Cl?Ts:d}else l=t;t=Ye();var s=t.queue,i=s.dispatch;return a!==t.memoizedState&&(oe.flags|=2048,zl(9,{destroy:void 0},Bx.bind(null,s,a),null)),[l,i,e]}function Bx(e,t){e.action=t}function ld(e){var t=Ye(),a=Te;if(a!==null)return ad(t,a,e);Ye(),t=t.memoizedState,a=Ye();var l=a.queue.dispatch;return a.memoizedState=e,[t,l,!1]}function zl(e,t,a,l){return e={tag:e,create:a,deps:l,inst:t,next:null},t=oe.updateQueue,t===null&&(t=Ds(),oe.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(l=a.next,a.next=e,e.next=l,t.lastEffect=e),e}function nd(){return Ye().memoizedState}function Ls(e,t,a,l){var s=it();oe.flags|=e,s.memoizedState=zl(1|t,{destroy:void 0},a,l===void 0?null:l)}function Hs(e,t,a,l){var s=Ye();l=l===void 0?null:l;var i=s.memoizedState.inst;Te!==null&&l!==null&&Mr(l,Te.memoizedState.deps)?s.memoizedState=zl(t,i,a,l):(oe.flags|=e,s.memoizedState=zl(1|t,i,a,l))}function sd(e,t){Ls(8390656,8,e,t)}function qr(e,t){Hs(2048,8,e,t)}function qx(e){oe.flags|=4;var t=oe.updateQueue;if(t===null)t=Ds(),oe.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function id(e){var t=Ye().memoizedState;return qx({ref:t,nextImpl:e}),function(){if((Ne&2)!==0)throw Error(u(440));return t.impl.apply(void 0,arguments)}}function rd(e,t){return Hs(4,2,e,t)}function cd(e,t){return Hs(4,4,e,t)}function ud(e,t){if(typeof t=="function"){e=e();var a=t(e);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function od(e,t,a){a=a!=null?a.concat([e]):null,Hs(4,4,ud.bind(null,t,e),a)}function Yr(){}function dd(e,t){var a=Ye();t=t===void 0?null:t;var l=a.memoizedState;return t!==null&&Mr(t,l[1])?l[0]:(a.memoizedState=[e,t],e)}function fd(e,t){var a=Ye();t=t===void 0?null:t;var l=a.memoizedState;if(t!==null&&Mr(t,l[1]))return l[0];if(l=e(),al){ma(!0);try{e()}finally{ma(!1)}}return a.memoizedState=[l,t],l}function Gr(e,t,a){return a===void 0||(It&1073741824)!==0&&(ye&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=xf(),oe.lanes|=e,Aa|=e,a)}function md(e,t,a,l){return pt(a,t)?a:wl.current!==null?(e=Gr(e,a,l),pt(e,t)||(Xe=!0),e):(It&42)===0||(It&1073741824)!==0&&(ye&261930)===0?(Xe=!0,e.memoizedState=a):(e=xf(),oe.lanes|=e,Aa|=e,t)}function xd(e,t,a,l,s){var i=k.p;k.p=i!==0&&8>i?i:8;var d=U.T,h={};U.T=h,Qr(e,!1,t,a);try{var j=s(),M=U.S;if(M!==null&&M(h,j),j!==null&&typeof j=="object"&&typeof j.then=="function"){var L=Ox(j,l);Sn(e,t,L,Et(e))}else Sn(e,t,l,Et(e))}catch(q){Sn(e,t,{then:function(){},status:"rejected",reason:q},Et())}finally{k.p=i,d!==null&&h.types!==null&&(d.types=h.types),U.T=d}}function Yx(){}function $r(e,t,a,l){if(e.tag!==5)throw Error(u(476));var s=hd(e).queue;xd(e,s,t,ne,a===null?Yx:function(){return gd(e),a(l)})}function hd(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ea,lastRenderedState:ne},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ea,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function gd(e){var t=hd(e);t.next===null&&(t=e.alternate.memoizedState),Sn(e,t.next.queue,{},Et())}function Vr(){return Ie(Yn)}function yd(){return Ye().memoizedState}function pd(){return Ye().memoizedState}function Gx(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=Et();e=ja(a);var l=Na(t,e,a);l!==null&&(mt(l,t,a),pn(l,t,a)),t={cache:pr()},e.payload=t;return}t=t.return}}function $x(e,t,a){var l=Et();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bs(e)?bd(t,a):(a=rr(e,t,a,l),a!==null&&(mt(a,e,l),jd(a,t,l)))}function vd(e,t,a){var l=Et();Sn(e,t,a,l)}function Sn(e,t,a,l){var s={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bs(e))bd(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var d=t.lastRenderedState,h=i(d,a);if(s.hasEagerState=!0,s.eagerState=h,pt(h,d))return ps(e,t,s,0),we===null&&ys(),!1}catch{}if(a=rr(e,t,s,l),a!==null)return mt(a,e,l),jd(a,t,l),!0}return!1}function Qr(e,t,a,l){if(l={lane:2,revertLane:Nc(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Bs(e)){if(t)throw Error(u(479))}else t=rr(e,a,l,2),t!==null&&mt(t,e,2)}function Bs(e){var t=e.alternate;return e===oe||t!==null&&t===oe}function bd(e,t){Ml=zs=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function jd(e,t,a){if((a&4194048)!==0){var l=t.lanes;l&=e.pendingLanes,a|=l,t.lanes=a,Tu(e,a)}}var En={readContext:Ie,use:Os,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useLayoutEffect:Le,useInsertionEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useSyncExternalStore:Le,useId:Le,useHostTransitionStatus:Le,useFormState:Le,useActionState:Le,useOptimistic:Le,useMemoCache:Le,useCacheRefresh:Le};En.useEffectEvent=Le;var Nd={readContext:Ie,use:Os,useCallback:function(e,t){return it().memoizedState=[e,t===void 0?null:t],e},useContext:Ie,useEffect:sd,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,Ls(4194308,4,ud.bind(null,t,e),a)},useLayoutEffect:function(e,t){return Ls(4194308,4,e,t)},useInsertionEffect:function(e,t){Ls(4,2,e,t)},useMemo:function(e,t){var a=it();t=t===void 0?null:t;var l=e();if(al){ma(!0);try{e()}finally{ma(!1)}}return a.memoizedState=[l,t],l},useReducer:function(e,t,a){var l=it();if(a!==void 0){var s=a(t);if(al){ma(!0);try{a(t)}finally{ma(!1)}}}else s=t;return l.memoizedState=l.baseState=s,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:s},l.queue=e,e=e.dispatch=$x.bind(null,oe,e),[l.memoizedState,e]},useRef:function(e){var t=it();return e={current:e},t.memoizedState=e},useState:function(e){e=Hr(e);var t=e.queue,a=vd.bind(null,oe,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Yr,useDeferredValue:function(e,t){var a=it();return Gr(a,e,t)},useTransition:function(){var e=Hr(!1);return e=xd.bind(null,oe,e.queue,!0,!1),it().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var l=oe,s=it();if(ve){if(a===void 0)throw Error(u(407));a=a()}else{if(a=t(),we===null)throw Error(u(349));(ye&127)!==0||Vo(l,t,a)}s.memoizedState=a;var i={value:a,getSnapshot:t};return s.queue=i,sd(Xo.bind(null,l,i,e),[e]),l.flags|=2048,zl(9,{destroy:void 0},Qo.bind(null,l,i,a,t),null),a},useId:function(){var e=it(),t=we.identifierPrefix;if(ve){var a=Gt,l=Yt;a=(l&~(1<<32-yt(l)-1)).toString(32)+a,t="_"+t+"R_"+a,a=_s++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=Ux++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Vr,useFormState:ed,useActionState:ed,useOptimistic:function(e){var t=it();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Qr.bind(null,oe,!0,a),a.dispatch=t,[e,t]},useMemoCache:Or,useCacheRefresh:function(){return it().memoizedState=Gx.bind(null,oe)},useEffectEvent:function(e){var t=it(),a={impl:e};return t.memoizedState=a,function(){if((Ne&2)!==0)throw Error(u(440));return a.impl.apply(void 0,arguments)}}},Xr={readContext:Ie,use:Os,useCallback:dd,useContext:Ie,useEffect:qr,useImperativeHandle:od,useInsertionEffect:rd,useLayoutEffect:cd,useMemo:fd,useReducer:Us,useRef:nd,useState:function(){return Us(ea)},useDebugValue:Yr,useDeferredValue:function(e,t){var a=Ye();return md(a,Te.memoizedState,e,t)},useTransition:function(){var e=Us(ea)[0],t=Ye().memoizedState;return[typeof e=="boolean"?e:Nn(e),t]},useSyncExternalStore:$o,useId:yd,useHostTransitionStatus:Vr,useFormState:td,useActionState:td,useOptimistic:function(e,t){var a=Ye();return Ko(a,Te,e,t)},useMemoCache:Or,useCacheRefresh:pd};Xr.useEffectEvent=id;var Sd={readContext:Ie,use:Os,useCallback:dd,useContext:Ie,useEffect:qr,useImperativeHandle:od,useInsertionEffect:rd,useLayoutEffect:cd,useMemo:fd,useReducer:Lr,useRef:nd,useState:function(){return Lr(ea)},useDebugValue:Yr,useDeferredValue:function(e,t){var a=Ye();return Te===null?Gr(a,e,t):md(a,Te.memoizedState,e,t)},useTransition:function(){var e=Lr(ea)[0],t=Ye().memoizedState;return[typeof e=="boolean"?e:Nn(e),t]},useSyncExternalStore:$o,useId:yd,useHostTransitionStatus:Vr,useFormState:ld,useActionState:ld,useOptimistic:function(e,t){var a=Ye();return Te!==null?Ko(a,Te,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Or,useCacheRefresh:pd};Sd.useEffectEvent=id;function kr(e,t,a,l){t=e.memoizedState,a=a(l,t),a=a==null?t:y({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Zr={enqueueSetState:function(e,t,a){e=e._reactInternals;var l=Et(),s=ja(l);s.payload=t,a!=null&&(s.callback=a),t=Na(e,s,l),t!==null&&(mt(t,e,l),pn(t,e,l))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var l=Et(),s=ja(l);s.tag=1,s.payload=t,a!=null&&(s.callback=a),t=Na(e,s,l),t!==null&&(mt(t,e,l),pn(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=Et(),l=ja(a);l.tag=2,t!=null&&(l.callback=t),t=Na(e,l,a),t!==null&&(mt(t,e,a),pn(t,e,a))}};function Ed(e,t,a,l,s,i,d){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(l,i,d):t.prototype&&t.prototype.isPureReactComponent?!on(a,l)||!on(s,i):!0}function Td(e,t,a,l){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,l),t.state!==e&&Zr.enqueueReplaceState(t,t.state,null)}function ll(e,t){var a=t;if("ref"in t){a={};for(var l in t)l!=="ref"&&(a[l]=t[l])}if(e=e.defaultProps){a===t&&(a=y({},a));for(var s in e)a[s]===void 0&&(a[s]=e[s])}return a}function Cd(e){gs(e)}function Ad(e){console.error(e)}function wd(e){gs(e)}function qs(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(l){setTimeout(function(){throw l})}}function Md(e,t,a){try{var l=e.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(s){setTimeout(function(){throw s})}}function Kr(e,t,a){return a=ja(a),a.tag=3,a.payload={element:null},a.callback=function(){qs(e,t)},a}function Rd(e){return e=ja(e),e.tag=3,e}function zd(e,t,a,l){var s=a.type.getDerivedStateFromError;if(typeof s=="function"){var i=l.value;e.payload=function(){return s(i)},e.callback=function(){Md(t,a,l)}}var d=a.stateNode;d!==null&&typeof d.componentDidCatch=="function"&&(e.callback=function(){Md(t,a,l),typeof s!="function"&&(wa===null?wa=new Set([this]):wa.add(this));var h=l.stack;this.componentDidCatch(l.value,{componentStack:h!==null?h:""})})}function Vx(e,t,a,l,s){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(t=a.alternate,t!==null&&Sl(t,a,s,!0),a=bt.current,a!==null){switch(a.tag){case 31:case 13:return _t===null?Fs():a.alternate===null&&He===0&&(He=3),a.flags&=-257,a.flags|=65536,a.lanes=s,l===Cs?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([l]):t.add(l),vc(e,l,s)),!1;case 22:return a.flags|=65536,l===Cs?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([l]):a.add(l)),vc(e,l,s)),!1}throw Error(u(435,a.tag))}return vc(e,l,s),Fs(),!1}if(ve)return t=bt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=s,l!==mr&&(e=Error(u(422),{cause:l}),mn(wt(e,a)))):(l!==mr&&(t=Error(u(423),{cause:l}),mn(wt(t,a))),e=e.current.alternate,e.flags|=65536,s&=-s,e.lanes|=s,l=wt(l,a),s=Kr(e.stateNode,l,s),Er(e,s),He!==4&&(He=2)),!1;var i=Error(u(520),{cause:l});if(i=wt(i,a),_n===null?_n=[i]:_n.push(i),He!==4&&(He=2),t===null)return!0;l=wt(l,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=s&-s,a.lanes|=e,e=Kr(a.stateNode,l,e),Er(a,e),!1;case 1:if(t=a.type,i=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||i!==null&&typeof i.componentDidCatch=="function"&&(wa===null||!wa.has(i))))return a.flags|=65536,s&=-s,a.lanes|=s,s=Rd(s),zd(s,e,a,l),Er(a,s),!1}a=a.return}while(a!==null);return!1}var Jr=Error(u(461)),Xe=!1;function et(e,t,a,l){t.child=e===null?Uo(t,null,a,l):tl(t,e.child,a,l)}function _d(e,t,a,l,s){a=a.render;var i=t.ref;if("ref"in l){var d={};for(var h in l)h!=="ref"&&(d[h]=l[h])}else d=l;return Fa(t),l=Rr(e,t,a,d,i,s),h=zr(),e!==null&&!Xe?(_r(e,t,s),ta(e,t,s)):(ve&&h&&dr(t),t.flags|=1,et(e,t,l,s),t.child)}function Dd(e,t,a,l,s){if(e===null){var i=a.type;return typeof i=="function"&&!cr(i)&&i.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=i,Od(e,t,i,l,s)):(e=bs(a.type,null,l,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!lc(e,s)){var d=i.memoizedProps;if(a=a.compare,a=a!==null?a:on,a(d,l)&&e.ref===t.ref)return ta(e,t,s)}return t.flags|=1,e=Jt(i,l),e.ref=t.ref,e.return=t,t.child=e}function Od(e,t,a,l,s){if(e!==null){var i=e.memoizedProps;if(on(i,l)&&e.ref===t.ref)if(Xe=!1,t.pendingProps=l=i,lc(e,s))(e.flags&131072)!==0&&(Xe=!0);else return t.lanes=e.lanes,ta(e,t,s)}return Wr(e,t,a,l,s)}function Ud(e,t,a,l){var s=l.children,i=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((t.flags&128)!==0){if(i=i!==null?i.baseLanes|a:a,e!==null){for(l=t.child=e.child,s=0;l!==null;)s=s|l.lanes|l.childLanes,l=l.sibling;l=s&~i}else l=0,t.child=null;return Ld(e,t,i,a,l)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Es(t,i!==null?i.cachePool:null),i!==null?Bo(t,i):Cr(),qo(t);else return l=t.lanes=536870912,Ld(e,t,i!==null?i.baseLanes|a:a,a,l)}else i!==null?(Es(t,i.cachePool),Bo(t,i),Ea(),t.memoizedState=null):(e!==null&&Es(t,null),Cr(),Ea());return et(e,t,s,a),t.child}function Tn(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Ld(e,t,a,l,s){var i=br();return i=i===null?null:{parent:Ve._currentValue,pool:i},t.memoizedState={baseLanes:a,cachePool:i},e!==null&&Es(t,null),Cr(),qo(t),e!==null&&Sl(e,t,l,!0),t.childLanes=s,null}function Ys(e,t){return t=$s({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Hd(e,t,a){return tl(t,e.child,null,a),e=Ys(t,t.pendingProps),e.flags|=2,jt(t),t.memoizedState=null,e}function Qx(e,t,a){var l=t.pendingProps,s=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(ve){if(l.mode==="hidden")return e=Ys(t,l),t.lanes=536870912,Tn(null,e);if(wr(t),(e=ze)?(e=Wf(e,zt),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ga!==null?{id:Yt,overflow:Gt}:null,retryLane:536870912,hydrationErrors:null},a=bo(e),a.return=t,t.child=a,Pe=t,ze=null)):e=null,e===null)throw pa(t);return t.lanes=536870912,null}return Ys(t,l)}var i=e.memoizedState;if(i!==null){var d=i.dehydrated;if(wr(t),s)if(t.flags&256)t.flags&=-257,t=Hd(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(u(558));else if(Xe||Sl(e,t,a,!1),s=(a&e.childLanes)!==0,Xe||s){if(l=we,l!==null&&(d=Cu(l,a),d!==0&&d!==i.retryLane))throw i.retryLane=d,Za(e,d),mt(l,e,d),Jr;Fs(),t=Hd(e,t,a)}else e=i.treeContext,ze=Dt(d.nextSibling),Pe=t,ve=!0,ya=null,zt=!1,e!==null&&So(t,e),t=Ys(t,l),t.flags|=4096;return t}return e=Jt(e.child,{mode:l.mode,children:l.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Gs(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(u(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function Wr(e,t,a,l,s){return Fa(t),a=Rr(e,t,a,l,void 0,s),l=zr(),e!==null&&!Xe?(_r(e,t,s),ta(e,t,s)):(ve&&l&&dr(t),t.flags|=1,et(e,t,a,s),t.child)}function Bd(e,t,a,l,s,i){return Fa(t),t.updateQueue=null,a=Go(t,l,a,s),Yo(e),l=zr(),e!==null&&!Xe?(_r(e,t,i),ta(e,t,i)):(ve&&l&&dr(t),t.flags|=1,et(e,t,a,i),t.child)}function qd(e,t,a,l,s){if(Fa(t),t.stateNode===null){var i=vl,d=a.contextType;typeof d=="object"&&d!==null&&(i=Ie(d)),i=new a(l,i),t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=Zr,t.stateNode=i,i._reactInternals=t,i=t.stateNode,i.props=l,i.state=t.memoizedState,i.refs={},Nr(t),d=a.contextType,i.context=typeof d=="object"&&d!==null?Ie(d):vl,i.state=t.memoizedState,d=a.getDerivedStateFromProps,typeof d=="function"&&(kr(t,a,d,l),i.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(d=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),d!==i.state&&Zr.enqueueReplaceState(i,i.state,null),bn(t,l,i,s),vn(),i.state=t.memoizedState),typeof i.componentDidMount=="function"&&(t.flags|=4194308),l=!0}else if(e===null){i=t.stateNode;var h=t.memoizedProps,j=ll(a,h);i.props=j;var M=i.context,L=a.contextType;d=vl,typeof L=="object"&&L!==null&&(d=Ie(L));var q=a.getDerivedStateFromProps;L=typeof q=="function"||typeof i.getSnapshotBeforeUpdate=="function",h=t.pendingProps!==h,L||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(h||M!==d)&&Td(t,i,l,d),ba=!1;var z=t.memoizedState;i.state=z,bn(t,l,i,s),vn(),M=t.memoizedState,h||z!==M||ba?(typeof q=="function"&&(kr(t,a,q,l),M=t.memoizedState),(j=ba||Ed(t,a,j,l,z,M,d))?(L||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=M),i.props=l,i.state=M,i.context=d,l=j):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{i=t.stateNode,Sr(e,t),d=t.memoizedProps,L=ll(a,d),i.props=L,q=t.pendingProps,z=i.context,M=a.contextType,j=vl,typeof M=="object"&&M!==null&&(j=Ie(M)),h=a.getDerivedStateFromProps,(M=typeof h=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(d!==q||z!==j)&&Td(t,i,l,j),ba=!1,z=t.memoizedState,i.state=z,bn(t,l,i,s),vn();var D=t.memoizedState;d!==q||z!==D||ba||e!==null&&e.dependencies!==null&&Ns(e.dependencies)?(typeof h=="function"&&(kr(t,a,h,l),D=t.memoizedState),(L=ba||Ed(t,a,L,l,z,D,j)||e!==null&&e.dependencies!==null&&Ns(e.dependencies))?(M||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(l,D,j),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(l,D,j)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||d===e.memoizedProps&&z===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&z===e.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=D),i.props=l,i.state=D,i.context=j,l=L):(typeof i.componentDidUpdate!="function"||d===e.memoizedProps&&z===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||d===e.memoizedProps&&z===e.memoizedState||(t.flags|=1024),l=!1)}return i=l,Gs(e,t),l=(t.flags&128)!==0,i||l?(i=t.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:i.render(),t.flags|=1,e!==null&&l?(t.child=tl(t,e.child,null,s),t.child=tl(t,null,a,s)):et(e,t,a,s),t.memoizedState=i.state,e=t.child):e=ta(e,t,s),e}function Yd(e,t,a,l){return Ja(),t.flags|=256,et(e,t,a,l),t.child}var Fr={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Pr(e){return{baseLanes:e,cachePool:Mo()}}function Ir(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=St),e}function Gd(e,t,a){var l=t.pendingProps,s=!1,i=(t.flags&128)!==0,d;if((d=i)||(d=e!==null&&e.memoizedState===null?!1:(qe.current&2)!==0),d&&(s=!0,t.flags&=-129),d=(t.flags&32)!==0,t.flags&=-33,e===null){if(ve){if(s?Sa(t):Ea(),(e=ze)?(e=Wf(e,zt),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ga!==null?{id:Yt,overflow:Gt}:null,retryLane:536870912,hydrationErrors:null},a=bo(e),a.return=t,t.child=a,Pe=t,ze=null)):e=null,e===null)throw pa(t);return Uc(e)?t.lanes=32:t.lanes=536870912,null}var h=l.children;return l=l.fallback,s?(Ea(),s=t.mode,h=$s({mode:"hidden",children:h},s),l=Ka(l,s,a,null),h.return=t,l.return=t,h.sibling=l,t.child=h,l=t.child,l.memoizedState=Pr(a),l.childLanes=Ir(e,d,a),t.memoizedState=Fr,Tn(null,l)):(Sa(t),ec(t,h))}var j=e.memoizedState;if(j!==null&&(h=j.dehydrated,h!==null)){if(i)t.flags&256?(Sa(t),t.flags&=-257,t=tc(e,t,a)):t.memoizedState!==null?(Ea(),t.child=e.child,t.flags|=128,t=null):(Ea(),h=l.fallback,s=t.mode,l=$s({mode:"visible",children:l.children},s),h=Ka(h,s,a,null),h.flags|=2,l.return=t,h.return=t,l.sibling=h,t.child=l,tl(t,e.child,null,a),l=t.child,l.memoizedState=Pr(a),l.childLanes=Ir(e,d,a),t.memoizedState=Fr,t=Tn(null,l));else if(Sa(t),Uc(h)){if(d=h.nextSibling&&h.nextSibling.dataset,d)var M=d.dgst;d=M,l=Error(u(419)),l.stack="",l.digest=d,mn({value:l,source:null,stack:null}),t=tc(e,t,a)}else if(Xe||Sl(e,t,a,!1),d=(a&e.childLanes)!==0,Xe||d){if(d=we,d!==null&&(l=Cu(d,a),l!==0&&l!==j.retryLane))throw j.retryLane=l,Za(e,l),mt(d,e,l),Jr;Oc(h)||Fs(),t=tc(e,t,a)}else Oc(h)?(t.flags|=192,t.child=e.child,t=null):(e=j.treeContext,ze=Dt(h.nextSibling),Pe=t,ve=!0,ya=null,zt=!1,e!==null&&So(t,e),t=ec(t,l.children),t.flags|=4096);return t}return s?(Ea(),h=l.fallback,s=t.mode,j=e.child,M=j.sibling,l=Jt(j,{mode:"hidden",children:l.children}),l.subtreeFlags=j.subtreeFlags&65011712,M!==null?h=Jt(M,h):(h=Ka(h,s,a,null),h.flags|=2),h.return=t,l.return=t,l.sibling=h,t.child=l,Tn(null,l),l=t.child,h=e.child.memoizedState,h===null?h=Pr(a):(s=h.cachePool,s!==null?(j=Ve._currentValue,s=s.parent!==j?{parent:j,pool:j}:s):s=Mo(),h={baseLanes:h.baseLanes|a,cachePool:s}),l.memoizedState=h,l.childLanes=Ir(e,d,a),t.memoizedState=Fr,Tn(e.child,l)):(Sa(t),a=e.child,e=a.sibling,a=Jt(a,{mode:"visible",children:l.children}),a.return=t,a.sibling=null,e!==null&&(d=t.deletions,d===null?(t.deletions=[e],t.flags|=16):d.push(e)),t.child=a,t.memoizedState=null,a)}function ec(e,t){return t=$s({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function $s(e,t){return e=vt(22,e,null,t),e.lanes=0,e}function tc(e,t,a){return tl(t,e.child,null,a),e=ec(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function $d(e,t,a){e.lanes|=t;var l=e.alternate;l!==null&&(l.lanes|=t),gr(e.return,t,a)}function ac(e,t,a,l,s,i){var d=e.memoizedState;d===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:s,treeForkCount:i}:(d.isBackwards=t,d.rendering=null,d.renderingStartTime=0,d.last=l,d.tail=a,d.tailMode=s,d.treeForkCount=i)}function Vd(e,t,a){var l=t.pendingProps,s=l.revealOrder,i=l.tail;l=l.children;var d=qe.current,h=(d&2)!==0;if(h?(d=d&1|2,t.flags|=128):d&=1,K(qe,d),et(e,t,l,a),l=ve?fn:0,!h&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&$d(e,a,t);else if(e.tag===19)$d(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(s){case"forwards":for(a=t.child,s=null;a!==null;)e=a.alternate,e!==null&&Rs(e)===null&&(s=a),a=a.sibling;a=s,a===null?(s=t.child,t.child=null):(s=a.sibling,a.sibling=null),ac(t,!1,s,a,i,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Rs(e)===null){t.child=s;break}e=s.sibling,s.sibling=a,a=s,s=e}ac(t,!0,a,null,i,l);break;case"together":ac(t,!1,null,null,void 0,l);break;default:t.memoizedState=null}return t.child}function ta(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),Aa|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Sl(e,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(u(153));if(t.child!==null){for(e=t.child,a=Jt(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=Jt(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function lc(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Ns(e)))}function Xx(e,t,a){switch(t.tag){case 3:Ze(t,t.stateNode.containerInfo),va(t,Ve,e.memoizedState.cache),Ja();break;case 27:case 5:Wl(t);break;case 4:Ze(t,t.stateNode.containerInfo);break;case 10:va(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,wr(t),null;break;case 13:var l=t.memoizedState;if(l!==null)return l.dehydrated!==null?(Sa(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Gd(e,t,a):(Sa(t),e=ta(e,t,a),e!==null?e.sibling:null);Sa(t);break;case 19:var s=(e.flags&128)!==0;if(l=(a&t.childLanes)!==0,l||(Sl(e,t,a,!1),l=(a&t.childLanes)!==0),s){if(l)return Vd(e,t,a);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),K(qe,qe.current),l)break;return null;case 22:return t.lanes=0,Ud(e,t,a,t.pendingProps);case 24:va(t,Ve,e.memoizedState.cache)}return ta(e,t,a)}function Qd(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)Xe=!0;else{if(!lc(e,a)&&(t.flags&128)===0)return Xe=!1,Xx(e,t,a);Xe=(e.flags&131072)!==0}else Xe=!1,ve&&(t.flags&1048576)!==0&&No(t,fn,t.index);switch(t.lanes=0,t.tag){case 16:e:{var l=t.pendingProps;if(e=Ia(t.elementType),t.type=e,typeof e=="function")cr(e)?(l=ll(e,l),t.tag=1,t=qd(null,t,e,l,a)):(t.tag=0,t=Wr(null,t,e,l,a));else{if(e!=null){var s=e.$$typeof;if(s===re){t.tag=11,t=_d(null,t,e,l,a);break e}else if(s===Q){t.tag=14,t=Dd(null,t,e,l,a);break e}}throw t=Re(e)||e,Error(u(306,t,""))}}return t;case 0:return Wr(e,t,t.type,t.pendingProps,a);case 1:return l=t.type,s=ll(l,t.pendingProps),qd(e,t,l,s,a);case 3:e:{if(Ze(t,t.stateNode.containerInfo),e===null)throw Error(u(387));l=t.pendingProps;var i=t.memoizedState;s=i.element,Sr(e,t),bn(t,l,null,a);var d=t.memoizedState;if(l=d.cache,va(t,Ve,l),l!==i.cache&&yr(t,[Ve],a,!0),vn(),l=d.element,i.isDehydrated)if(i={element:l,isDehydrated:!1,cache:d.cache},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){t=Yd(e,t,l,a);break e}else if(l!==s){s=wt(Error(u(424)),t),mn(s),t=Yd(e,t,l,a);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,ze=Dt(e.firstChild),Pe=t,ve=!0,ya=null,zt=!0,a=Uo(t,null,l,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Ja(),l===s){t=ta(e,t,a);break e}et(e,t,l,a)}t=t.child}return t;case 26:return Gs(e,t),e===null?(a=a0(t.type,null,t.pendingProps,null))?t.memoizedState=a:ve||(a=t.type,e=t.pendingProps,l=ni(xe.current).createElement(a),l[Fe]=t,l[rt]=e,tt(l,a,e),Je(l),t.stateNode=l):t.memoizedState=a0(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Wl(t),e===null&&ve&&(l=t.stateNode=If(t.type,t.pendingProps,xe.current),Pe=t,zt=!0,s=ze,_a(t.type)?(Lc=s,ze=Dt(l.firstChild)):ze=s),et(e,t,t.pendingProps.children,a),Gs(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&ve&&((s=l=ze)&&(l=jh(l,t.type,t.pendingProps,zt),l!==null?(t.stateNode=l,Pe=t,ze=Dt(l.firstChild),zt=!1,s=!0):s=!1),s||pa(t)),Wl(t),s=t.type,i=t.pendingProps,d=e!==null?e.memoizedProps:null,l=i.children,zc(s,i)?l=null:d!==null&&zc(s,d)&&(t.flags|=32),t.memoizedState!==null&&(s=Rr(e,t,Lx,null,null,a),Yn._currentValue=s),Gs(e,t),et(e,t,l,a),t.child;case 6:return e===null&&ve&&((e=a=ze)&&(a=Nh(a,t.pendingProps,zt),a!==null?(t.stateNode=a,Pe=t,ze=null,e=!0):e=!1),e||pa(t)),null;case 13:return Gd(e,t,a);case 4:return Ze(t,t.stateNode.containerInfo),l=t.pendingProps,e===null?t.child=tl(t,null,l,a):et(e,t,l,a),t.child;case 11:return _d(e,t,t.type,t.pendingProps,a);case 7:return et(e,t,t.pendingProps,a),t.child;case 8:return et(e,t,t.pendingProps.children,a),t.child;case 12:return et(e,t,t.pendingProps.children,a),t.child;case 10:return l=t.pendingProps,va(t,t.type,l.value),et(e,t,l.children,a),t.child;case 9:return s=t.type._context,l=t.pendingProps.children,Fa(t),s=Ie(s),l=l(s),t.flags|=1,et(e,t,l,a),t.child;case 14:return Dd(e,t,t.type,t.pendingProps,a);case 15:return Od(e,t,t.type,t.pendingProps,a);case 19:return Vd(e,t,a);case 31:return Qx(e,t,a);case 22:return Ud(e,t,a,t.pendingProps);case 24:return Fa(t),l=Ie(Ve),e===null?(s=br(),s===null&&(s=we,i=pr(),s.pooledCache=i,i.refCount++,i!==null&&(s.pooledCacheLanes|=a),s=i),t.memoizedState={parent:l,cache:s},Nr(t),va(t,Ve,s)):((e.lanes&a)!==0&&(Sr(e,t),bn(t,null,null,a),vn()),s=e.memoizedState,i=t.memoizedState,s.parent!==l?(s={parent:l,cache:l},t.memoizedState=s,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=s),va(t,Ve,l)):(l=i.cache,va(t,Ve,l),l!==s.cache&&yr(t,[Ve],a,!0))),et(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(u(156,t.tag))}function aa(e){e.flags|=4}function nc(e,t,a,l,s){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(s&335544128)===s)if(e.stateNode.complete)e.flags|=8192;else if(pf())e.flags|=8192;else throw el=Cs,jr}else e.flags&=-16777217}function Xd(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!r0(t))if(pf())e.flags|=8192;else throw el=Cs,jr}function Vs(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Su():536870912,e.lanes|=t,Ul|=t)}function Cn(e,t){if(!ve)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function _e(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,l=0;if(t)for(var s=e.child;s!==null;)a|=s.lanes|s.childLanes,l|=s.subtreeFlags&65011712,l|=s.flags&65011712,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)a|=s.lanes|s.childLanes,l|=s.subtreeFlags,l|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=l,e.childLanes=a,t}function kx(e,t,a){var l=t.pendingProps;switch(fr(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _e(t),null;case 1:return _e(t),null;case 3:return a=t.stateNode,l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Pt(Ve),Be(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(Nl(t)?aa(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,xr())),_e(t),null;case 26:var s=t.type,i=t.memoizedState;return e===null?(aa(t),i!==null?(_e(t),Xd(t,i)):(_e(t),nc(t,s,null,l,a))):i?i!==e.memoizedState?(aa(t),_e(t),Xd(t,i)):(_e(t),t.flags&=-16777217):(e=e.memoizedProps,e!==l&&aa(t),_e(t),nc(t,s,e,l,a)),null;case 27:if(es(t),a=xe.current,s=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&aa(t);else{if(!l){if(t.stateNode===null)throw Error(u(166));return _e(t),null}e=F.current,Nl(t)?Eo(t):(e=If(s,l,a),t.stateNode=e,aa(t))}return _e(t),null;case 5:if(es(t),s=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==l&&aa(t);else{if(!l){if(t.stateNode===null)throw Error(u(166));return _e(t),null}if(i=F.current,Nl(t))Eo(t);else{var d=ni(xe.current);switch(i){case 1:i=d.createElementNS("http://www.w3.org/2000/svg",s);break;case 2:i=d.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;default:switch(s){case"svg":i=d.createElementNS("http://www.w3.org/2000/svg",s);break;case"math":i=d.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;case"script":i=d.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild);break;case"select":i=typeof l.is=="string"?d.createElement("select",{is:l.is}):d.createElement("select"),l.multiple?i.multiple=!0:l.size&&(i.size=l.size);break;default:i=typeof l.is=="string"?d.createElement(s,{is:l.is}):d.createElement(s)}}i[Fe]=t,i[rt]=l;e:for(d=t.child;d!==null;){if(d.tag===5||d.tag===6)i.appendChild(d.stateNode);else if(d.tag!==4&&d.tag!==27&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===t)break e;for(;d.sibling===null;){if(d.return===null||d.return===t)break e;d=d.return}d.sibling.return=d.return,d=d.sibling}t.stateNode=i;e:switch(tt(i,s,l),s){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&aa(t)}}return _e(t),nc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==l&&aa(t);else{if(typeof l!="string"&&t.stateNode===null)throw Error(u(166));if(e=xe.current,Nl(t)){if(e=t.stateNode,a=t.memoizedProps,l=null,s=Pe,s!==null)switch(s.tag){case 27:case 5:l=s.memoizedProps}e[Fe]=t,e=!!(e.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||$f(e.nodeValue,a)),e||pa(t,!0)}else e=ni(e).createTextNode(l),e[Fe]=t,t.stateNode=e}return _e(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(l=Nl(t),a!==null){if(e===null){if(!l)throw Error(u(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(u(557));e[Fe]=t}else Ja(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;_e(t),e=!1}else a=xr(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(jt(t),t):(jt(t),null);if((t.flags&128)!==0)throw Error(u(558))}return _e(t),null;case 13:if(l=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(s=Nl(t),l!==null&&l.dehydrated!==null){if(e===null){if(!s)throw Error(u(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(u(317));s[Fe]=t}else Ja(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;_e(t),s=!1}else s=xr(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),s=!0;if(!s)return t.flags&256?(jt(t),t):(jt(t),null)}return jt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=l!==null,e=e!==null&&e.memoizedState!==null,a&&(l=t.child,s=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(s=l.alternate.memoizedState.cachePool.pool),i=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(i=l.memoizedState.cachePool.pool),i!==s&&(l.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),Vs(t,t.updateQueue),_e(t),null);case 4:return Be(),e===null&&Cc(t.stateNode.containerInfo),_e(t),null;case 10:return Pt(t.type),_e(t),null;case 19:if(Y(qe),l=t.memoizedState,l===null)return _e(t),null;if(s=(t.flags&128)!==0,i=l.rendering,i===null)if(s)Cn(l,!1);else{if(He!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(i=Rs(e),i!==null){for(t.flags|=128,Cn(l,!1),e=i.updateQueue,t.updateQueue=e,Vs(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)vo(a,e),a=a.sibling;return K(qe,qe.current&1|2),ve&&Wt(t,l.treeForkCount),t.child}e=e.sibling}l.tail!==null&&ht()>Ks&&(t.flags|=128,s=!0,Cn(l,!1),t.lanes=4194304)}else{if(!s)if(e=Rs(i),e!==null){if(t.flags|=128,s=!0,e=e.updateQueue,t.updateQueue=e,Vs(t,e),Cn(l,!0),l.tail===null&&l.tailMode==="hidden"&&!i.alternate&&!ve)return _e(t),null}else 2*ht()-l.renderingStartTime>Ks&&a!==536870912&&(t.flags|=128,s=!0,Cn(l,!1),t.lanes=4194304);l.isBackwards?(i.sibling=t.child,t.child=i):(e=l.last,e!==null?e.sibling=i:t.child=i,l.last=i)}return l.tail!==null?(e=l.tail,l.rendering=e,l.tail=e.sibling,l.renderingStartTime=ht(),e.sibling=null,a=qe.current,K(qe,s?a&1|2:a&1),ve&&Wt(t,l.treeForkCount),e):(_e(t),null);case 22:case 23:return jt(t),Ar(),l=t.memoizedState!==null,e!==null?e.memoizedState!==null!==l&&(t.flags|=8192):l&&(t.flags|=8192),l?(a&536870912)!==0&&(t.flags&128)===0&&(_e(t),t.subtreeFlags&6&&(t.flags|=8192)):_e(t),a=t.updateQueue,a!==null&&Vs(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),l=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),l!==a&&(t.flags|=2048),e!==null&&Y(Pa),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Pt(Ve),_e(t),null;case 25:return null;case 30:return null}throw Error(u(156,t.tag))}function Zx(e,t){switch(fr(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Pt(Ve),Be(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return es(t),null;case 31:if(t.memoizedState!==null){if(jt(t),t.alternate===null)throw Error(u(340));Ja()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(jt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(u(340));Ja()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Y(qe),null;case 4:return Be(),null;case 10:return Pt(t.type),null;case 22:case 23:return jt(t),Ar(),e!==null&&Y(Pa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Pt(Ve),null;case 25:return null;default:return null}}function kd(e,t){switch(fr(t),t.tag){case 3:Pt(Ve),Be();break;case 26:case 27:case 5:es(t);break;case 4:Be();break;case 31:t.memoizedState!==null&&jt(t);break;case 13:jt(t);break;case 19:Y(qe);break;case 10:Pt(t.type);break;case 22:case 23:jt(t),Ar(),e!==null&&Y(Pa);break;case 24:Pt(Ve)}}function An(e,t){try{var a=t.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var s=l.next;a=s;do{if((a.tag&e)===e){l=void 0;var i=a.create,d=a.inst;l=i(),d.destroy=l}a=a.next}while(a!==s)}}catch(h){Ee(t,t.return,h)}}function Ta(e,t,a){try{var l=t.updateQueue,s=l!==null?l.lastEffect:null;if(s!==null){var i=s.next;l=i;do{if((l.tag&e)===e){var d=l.inst,h=d.destroy;if(h!==void 0){d.destroy=void 0,s=t;var j=a,M=h;try{M()}catch(L){Ee(s,j,L)}}}l=l.next}while(l!==i)}}catch(L){Ee(t,t.return,L)}}function Zd(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{Ho(t,a)}catch(l){Ee(e,e.return,l)}}}function Kd(e,t,a){a.props=ll(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(l){Ee(e,t,l)}}function wn(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var l=e.stateNode;break;case 30:l=e.stateNode;break;default:l=e.stateNode}typeof a=="function"?e.refCleanup=a(l):a.current=l}}catch(s){Ee(e,t,s)}}function $t(e,t){var a=e.ref,l=e.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(s){Ee(e,t,s)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(s){Ee(e,t,s)}else a.current=null}function Jd(e){var t=e.type,a=e.memoizedProps,l=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(s){Ee(e,e.return,s)}}function sc(e,t,a){try{var l=e.stateNode;hh(l,e.type,a,t),l[rt]=t}catch(s){Ee(e,e.return,s)}}function Wd(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&_a(e.type)||e.tag===4}function ic(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Wd(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&_a(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function rc(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=Zt));else if(l!==4&&(l===27&&_a(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(rc(e,t,a),e=e.sibling;e!==null;)rc(e,t,a),e=e.sibling}function Qs(e,t,a){var l=e.tag;if(l===5||l===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(l!==4&&(l===27&&_a(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(Qs(e,t,a),e=e.sibling;e!==null;)Qs(e,t,a),e=e.sibling}function Fd(e){var t=e.stateNode,a=e.memoizedProps;try{for(var l=e.type,s=t.attributes;s.length;)t.removeAttributeNode(s[0]);tt(t,l,a),t[Fe]=e,t[rt]=a}catch(i){Ee(e,e.return,i)}}var la=!1,ke=!1,cc=!1,Pd=typeof WeakSet=="function"?WeakSet:Set,We=null;function Kx(e,t){if(e=e.containerInfo,Mc=di,e=uo(e),tr(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var s=l.anchorOffset,i=l.focusNode;l=l.focusOffset;try{a.nodeType,i.nodeType}catch{a=null;break e}var d=0,h=-1,j=-1,M=0,L=0,q=e,z=null;t:for(;;){for(var D;q!==a||s!==0&&q.nodeType!==3||(h=d+s),q!==i||l!==0&&q.nodeType!==3||(j=d+l),q.nodeType===3&&(d+=q.nodeValue.length),(D=q.firstChild)!==null;)z=q,q=D;for(;;){if(q===e)break t;if(z===a&&++M===s&&(h=d),z===i&&++L===l&&(j=d),(D=q.nextSibling)!==null)break;q=z,z=q.parentNode}q=D}a=h===-1||j===-1?null:{start:h,end:j}}else a=null}a=a||{start:0,end:0}}else a=null;for(Rc={focusedElem:e,selectionRange:a},di=!1,We=t;We!==null;)if(t=We,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,We=e;else for(;We!==null;){switch(t=We,i=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)s=e[a],s.ref.impl=s.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&i!==null){e=void 0,a=t,s=i.memoizedProps,i=i.memoizedState,l=a.stateNode;try{var W=ll(a.type,s);e=l.getSnapshotBeforeUpdate(W,i),l.__reactInternalSnapshotBeforeUpdate=e}catch(se){Ee(a,a.return,se)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)Dc(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Dc(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(u(163))}if(e=t.sibling,e!==null){e.return=t.return,We=e;break}We=t.return}}function Id(e,t,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:sa(e,a),l&4&&An(5,a);break;case 1:if(sa(e,a),l&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(d){Ee(a,a.return,d)}else{var s=ll(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(s,t,e.__reactInternalSnapshotBeforeUpdate)}catch(d){Ee(a,a.return,d)}}l&64&&Zd(a),l&512&&wn(a,a.return);break;case 3:if(sa(e,a),l&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{Ho(e,t)}catch(d){Ee(a,a.return,d)}}break;case 27:t===null&&l&4&&Fd(a);case 26:case 5:sa(e,a),t===null&&l&4&&Jd(a),l&512&&wn(a,a.return);break;case 12:sa(e,a);break;case 31:sa(e,a),l&4&&af(e,a);break;case 13:sa(e,a),l&4&&lf(e,a),l&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=lh.bind(null,a),Sh(e,a))));break;case 22:if(l=a.memoizedState!==null||la,!l){t=t!==null&&t.memoizedState!==null||ke,s=la;var i=ke;la=l,(ke=t)&&!i?ia(e,a,(a.subtreeFlags&8772)!==0):sa(e,a),la=s,ke=i}break;case 30:break;default:sa(e,a)}}function ef(e){var t=e.alternate;t!==null&&(e.alternate=null,ef(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Bi(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 De=null,ut=!1;function na(e,t,a){for(a=a.child;a!==null;)tf(e,t,a),a=a.sibling}function tf(e,t,a){if(gt&&typeof gt.onCommitFiberUnmount=="function")try{gt.onCommitFiberUnmount(Fl,a)}catch{}switch(a.tag){case 26:ke||$t(a,t),na(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:ke||$t(a,t);var l=De,s=ut;_a(a.type)&&(De=a.stateNode,ut=!1),na(e,t,a),Hn(a.stateNode),De=l,ut=s;break;case 5:ke||$t(a,t);case 6:if(l=De,s=ut,De=null,na(e,t,a),De=l,ut=s,De!==null)if(ut)try{(De.nodeType===9?De.body:De.nodeName==="HTML"?De.ownerDocument.body:De).removeChild(a.stateNode)}catch(i){Ee(a,t,i)}else try{De.removeChild(a.stateNode)}catch(i){Ee(a,t,i)}break;case 18:De!==null&&(ut?(e=De,Kf(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),Vl(e)):Kf(De,a.stateNode));break;case 4:l=De,s=ut,De=a.stateNode.containerInfo,ut=!0,na(e,t,a),De=l,ut=s;break;case 0:case 11:case 14:case 15:Ta(2,a,t),ke||Ta(4,a,t),na(e,t,a);break;case 1:ke||($t(a,t),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Kd(a,t,l)),na(e,t,a);break;case 21:na(e,t,a);break;case 22:ke=(l=ke)||a.memoizedState!==null,na(e,t,a),ke=l;break;default:na(e,t,a)}}function af(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Vl(e)}catch(a){Ee(t,t.return,a)}}}function lf(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Vl(e)}catch(a){Ee(t,t.return,a)}}function Jx(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Pd),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Pd),t;default:throw Error(u(435,e.tag))}}function Xs(e,t){var a=Jx(e);t.forEach(function(l){if(!a.has(l)){a.add(l);var s=nh.bind(null,e,l);l.then(s,s)}})}function ot(e,t){var a=t.deletions;if(a!==null)for(var l=0;l<a.length;l++){var s=a[l],i=e,d=t,h=d;e:for(;h!==null;){switch(h.tag){case 27:if(_a(h.type)){De=h.stateNode,ut=!1;break e}break;case 5:De=h.stateNode,ut=!1;break e;case 3:case 4:De=h.stateNode.containerInfo,ut=!0;break e}h=h.return}if(De===null)throw Error(u(160));tf(i,d,s),De=null,ut=!1,i=s.alternate,i!==null&&(i.return=null),s.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)nf(t,e),t=t.sibling}var Ht=null;function nf(e,t){var a=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ot(t,e),dt(e),l&4&&(Ta(3,e,e.return),An(3,e),Ta(5,e,e.return));break;case 1:ot(t,e),dt(e),l&512&&(ke||a===null||$t(a,a.return)),l&64&&la&&(e=e.updateQueue,e!==null&&(l=e.callbacks,l!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var s=Ht;if(ot(t,e),dt(e),l&512&&(ke||a===null||$t(a,a.return)),l&4){var i=a!==null?a.memoizedState:null;if(l=e.memoizedState,a===null)if(l===null)if(e.stateNode===null){e:{l=e.type,a=e.memoizedProps,s=s.ownerDocument||s;t:switch(l){case"title":i=s.getElementsByTagName("title")[0],(!i||i[en]||i[Fe]||i.namespaceURI==="http://www.w3.org/2000/svg"||i.hasAttribute("itemprop"))&&(i=s.createElement(l),s.head.insertBefore(i,s.querySelector("head > title"))),tt(i,l,a),i[Fe]=e,Je(i),l=i;break e;case"link":var d=s0("link","href",s).get(l+(a.href||""));if(d){for(var h=0;h<d.length;h++)if(i=d[h],i.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&i.getAttribute("rel")===(a.rel==null?null:a.rel)&&i.getAttribute("title")===(a.title==null?null:a.title)&&i.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){d.splice(h,1);break t}}i=s.createElement(l),tt(i,l,a),s.head.appendChild(i);break;case"meta":if(d=s0("meta","content",s).get(l+(a.content||""))){for(h=0;h<d.length;h++)if(i=d[h],i.getAttribute("content")===(a.content==null?null:""+a.content)&&i.getAttribute("name")===(a.name==null?null:a.name)&&i.getAttribute("property")===(a.property==null?null:a.property)&&i.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&i.getAttribute("charset")===(a.charSet==null?null:a.charSet)){d.splice(h,1);break t}}i=s.createElement(l),tt(i,l,a),s.head.appendChild(i);break;default:throw Error(u(468,l))}i[Fe]=e,Je(i),l=i}e.stateNode=l}else i0(s,e.type,e.stateNode);else e.stateNode=n0(s,l,e.memoizedProps);else i!==l?(i===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):i.count--,l===null?i0(s,e.type,e.stateNode):n0(s,l,e.memoizedProps)):l===null&&e.stateNode!==null&&sc(e,e.memoizedProps,a.memoizedProps)}break;case 27:ot(t,e),dt(e),l&512&&(ke||a===null||$t(a,a.return)),a!==null&&l&4&&sc(e,e.memoizedProps,a.memoizedProps);break;case 5:if(ot(t,e),dt(e),l&512&&(ke||a===null||$t(a,a.return)),e.flags&32){s=e.stateNode;try{fl(s,"")}catch(W){Ee(e,e.return,W)}}l&4&&e.stateNode!=null&&(s=e.memoizedProps,sc(e,s,a!==null?a.memoizedProps:s)),l&1024&&(cc=!0);break;case 6:if(ot(t,e),dt(e),l&4){if(e.stateNode===null)throw Error(u(162));l=e.memoizedProps,a=e.stateNode;try{a.nodeValue=l}catch(W){Ee(e,e.return,W)}}break;case 3:if(ri=null,s=Ht,Ht=si(t.containerInfo),ot(t,e),Ht=s,dt(e),l&4&&a!==null&&a.memoizedState.isDehydrated)try{Vl(t.containerInfo)}catch(W){Ee(e,e.return,W)}cc&&(cc=!1,sf(e));break;case 4:l=Ht,Ht=si(e.stateNode.containerInfo),ot(t,e),dt(e),Ht=l;break;case 12:ot(t,e),dt(e);break;case 31:ot(t,e),dt(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Xs(e,l)));break;case 13:ot(t,e),dt(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Zs=ht()),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Xs(e,l)));break;case 22:s=e.memoizedState!==null;var j=a!==null&&a.memoizedState!==null,M=la,L=ke;if(la=M||s,ke=L||j,ot(t,e),ke=L,la=M,dt(e),l&8192)e:for(t=e.stateNode,t._visibility=s?t._visibility&-2:t._visibility|1,s&&(a===null||j||la||ke||nl(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){j=a=t;try{if(i=j.stateNode,s)d=i.style,typeof d.setProperty=="function"?d.setProperty("display","none","important"):d.display="none";else{h=j.stateNode;var q=j.memoizedProps.style,z=q!=null&&q.hasOwnProperty("display")?q.display:null;h.style.display=z==null||typeof z=="boolean"?"":(""+z).trim()}}catch(W){Ee(j,j.return,W)}}}else if(t.tag===6){if(a===null){j=t;try{j.stateNode.nodeValue=s?"":j.memoizedProps}catch(W){Ee(j,j.return,W)}}}else if(t.tag===18){if(a===null){j=t;try{var D=j.stateNode;s?Jf(D,!0):Jf(j.stateNode,!1)}catch(W){Ee(j,j.return,W)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}l&4&&(l=e.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Xs(e,a))));break;case 19:ot(t,e),dt(e),l&4&&(l=e.updateQueue,l!==null&&(e.updateQueue=null,Xs(e,l)));break;case 30:break;case 21:break;default:ot(t,e),dt(e)}}function dt(e){var t=e.flags;if(t&2){try{for(var a,l=e.return;l!==null;){if(Wd(l)){a=l;break}l=l.return}if(a==null)throw Error(u(160));switch(a.tag){case 27:var s=a.stateNode,i=ic(e);Qs(e,i,s);break;case 5:var d=a.stateNode;a.flags&32&&(fl(d,""),a.flags&=-33);var h=ic(e);Qs(e,h,d);break;case 3:case 4:var j=a.stateNode.containerInfo,M=ic(e);rc(e,M,j);break;default:throw Error(u(161))}}catch(L){Ee(e,e.return,L)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function sf(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;sf(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function sa(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Id(e,t.alternate,t),t=t.sibling}function nl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Ta(4,t,t.return),nl(t);break;case 1:$t(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Kd(t,t.return,a),nl(t);break;case 27:Hn(t.stateNode);case 26:case 5:$t(t,t.return),nl(t);break;case 22:t.memoizedState===null&&nl(t);break;case 30:nl(t);break;default:nl(t)}e=e.sibling}}function ia(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var l=t.alternate,s=e,i=t,d=i.flags;switch(i.tag){case 0:case 11:case 15:ia(s,i,a),An(4,i);break;case 1:if(ia(s,i,a),l=i,s=l.stateNode,typeof s.componentDidMount=="function")try{s.componentDidMount()}catch(M){Ee(l,l.return,M)}if(l=i,s=l.updateQueue,s!==null){var h=l.stateNode;try{var j=s.shared.hiddenCallbacks;if(j!==null)for(s.shared.hiddenCallbacks=null,s=0;s<j.length;s++)Lo(j[s],h)}catch(M){Ee(l,l.return,M)}}a&&d&64&&Zd(i),wn(i,i.return);break;case 27:Fd(i);case 26:case 5:ia(s,i,a),a&&l===null&&d&4&&Jd(i),wn(i,i.return);break;case 12:ia(s,i,a);break;case 31:ia(s,i,a),a&&d&4&&af(s,i);break;case 13:ia(s,i,a),a&&d&4&&lf(s,i);break;case 22:i.memoizedState===null&&ia(s,i,a),wn(i,i.return);break;case 30:break;default:ia(s,i,a)}t=t.sibling}}function uc(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&xn(a))}function oc(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&xn(e))}function Bt(e,t,a,l){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)rf(e,t,a,l),t=t.sibling}function rf(e,t,a,l){var s=t.flags;switch(t.tag){case 0:case 11:case 15:Bt(e,t,a,l),s&2048&&An(9,t);break;case 1:Bt(e,t,a,l);break;case 3:Bt(e,t,a,l),s&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&xn(e)));break;case 12:if(s&2048){Bt(e,t,a,l),e=t.stateNode;try{var i=t.memoizedProps,d=i.id,h=i.onPostCommit;typeof h=="function"&&h(d,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(j){Ee(t,t.return,j)}}else Bt(e,t,a,l);break;case 31:Bt(e,t,a,l);break;case 13:Bt(e,t,a,l);break;case 23:break;case 22:i=t.stateNode,d=t.alternate,t.memoizedState!==null?i._visibility&2?Bt(e,t,a,l):Mn(e,t):i._visibility&2?Bt(e,t,a,l):(i._visibility|=2,_l(e,t,a,l,(t.subtreeFlags&10256)!==0||!1)),s&2048&&uc(d,t);break;case 24:Bt(e,t,a,l),s&2048&&oc(t.alternate,t);break;default:Bt(e,t,a,l)}}function _l(e,t,a,l,s){for(s=s&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var i=e,d=t,h=a,j=l,M=d.flags;switch(d.tag){case 0:case 11:case 15:_l(i,d,h,j,s),An(8,d);break;case 23:break;case 22:var L=d.stateNode;d.memoizedState!==null?L._visibility&2?_l(i,d,h,j,s):Mn(i,d):(L._visibility|=2,_l(i,d,h,j,s)),s&&M&2048&&uc(d.alternate,d);break;case 24:_l(i,d,h,j,s),s&&M&2048&&oc(d.alternate,d);break;default:_l(i,d,h,j,s)}t=t.sibling}}function Mn(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,l=t,s=l.flags;switch(l.tag){case 22:Mn(a,l),s&2048&&uc(l.alternate,l);break;case 24:Mn(a,l),s&2048&&oc(l.alternate,l);break;default:Mn(a,l)}t=t.sibling}}var Rn=8192;function Dl(e,t,a){if(e.subtreeFlags&Rn)for(e=e.child;e!==null;)cf(e,t,a),e=e.sibling}function cf(e,t,a){switch(e.tag){case 26:Dl(e,t,a),e.flags&Rn&&e.memoizedState!==null&&Uh(a,Ht,e.memoizedState,e.memoizedProps);break;case 5:Dl(e,t,a);break;case 3:case 4:var l=Ht;Ht=si(e.stateNode.containerInfo),Dl(e,t,a),Ht=l;break;case 22:e.memoizedState===null&&(l=e.alternate,l!==null&&l.memoizedState!==null?(l=Rn,Rn=16777216,Dl(e,t,a),Rn=l):Dl(e,t,a));break;default:Dl(e,t,a)}}function uf(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function zn(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];We=l,df(l,e)}uf(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)of(e),e=e.sibling}function of(e){switch(e.tag){case 0:case 11:case 15:zn(e),e.flags&2048&&Ta(9,e,e.return);break;case 3:zn(e);break;case 12:zn(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,ks(e)):zn(e);break;default:zn(e)}}function ks(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];We=l,df(l,e)}uf(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Ta(8,t,t.return),ks(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,ks(t));break;default:ks(t)}e=e.sibling}}function df(e,t){for(;We!==null;){var a=We;switch(a.tag){case 0:case 11:case 15:Ta(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:xn(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,We=l;else e:for(a=e;We!==null;){l=We;var s=l.sibling,i=l.return;if(ef(l),l===a){We=null;break e}if(s!==null){s.return=i,We=s;break e}We=i}}}var Wx={getCacheForType:function(e){var t=Ie(Ve),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return Ie(Ve).controller.signal}},Fx=typeof WeakMap=="function"?WeakMap:Map,Ne=0,we=null,he=null,ye=0,Se=0,Nt=null,Ca=!1,Ol=!1,dc=!1,ra=0,He=0,Aa=0,sl=0,fc=0,St=0,Ul=0,_n=null,ft=null,mc=!1,Zs=0,ff=0,Ks=1/0,Js=null,wa=null,Ke=0,Ma=null,Ll=null,ca=0,xc=0,hc=null,mf=null,Dn=0,gc=null;function Et(){return(Ne&2)!==0&&ye!==0?ye&-ye:U.T!==null?Nc():Au()}function xf(){if(St===0)if((ye&536870912)===0||ve){var e=ls;ls<<=1,(ls&3932160)===0&&(ls=262144),St=e}else St=536870912;return e=bt.current,e!==null&&(e.flags|=32),St}function mt(e,t,a){(e===we&&(Se===2||Se===9)||e.cancelPendingCommit!==null)&&(Hl(e,0),Ra(e,ye,St,!1)),Il(e,a),((Ne&2)===0||e!==we)&&(e===we&&((Ne&2)===0&&(sl|=a),He===4&&Ra(e,ye,St,!1)),Vt(e))}function hf(e,t,a){if((Ne&6)!==0)throw Error(u(327));var l=!a&&(t&127)===0&&(t&e.expiredLanes)===0||Pl(e,t),s=l?eh(e,t):pc(e,t,!0),i=l;do{if(s===0){Ol&&!l&&Ra(e,t,0,!1);break}else{if(a=e.current.alternate,i&&!Px(a)){s=pc(e,t,!1),i=!1;continue}if(s===2){if(i=t,e.errorRecoveryDisabledLanes&i)var d=0;else d=e.pendingLanes&-536870913,d=d!==0?d:d&536870912?536870912:0;if(d!==0){t=d;e:{var h=e;s=_n;var j=h.current.memoizedState.isDehydrated;if(j&&(Hl(h,d).flags|=256),d=pc(h,d,!1),d!==2){if(dc&&!j){h.errorRecoveryDisabledLanes|=i,sl|=i,s=4;break e}i=ft,ft=s,i!==null&&(ft===null?ft=i:ft.push.apply(ft,i))}s=d}if(i=!1,s!==2)continue}}if(s===1){Hl(e,0),Ra(e,t,0,!0);break}e:{switch(l=e,i=s,i){case 0:case 1:throw Error(u(345));case 4:if((t&4194048)!==t)break;case 6:Ra(l,t,St,!Ca);break e;case 2:ft=null;break;case 3:case 5:break;default:throw Error(u(329))}if((t&62914560)===t&&(s=Zs+300-ht(),10<s)){if(Ra(l,t,St,!Ca),ss(l,0,!0)!==0)break e;ca=t,l.timeoutHandle=kf(gf.bind(null,l,a,ft,Js,mc,t,St,sl,Ul,Ca,i,"Throttled",-0,0),s);break e}gf(l,a,ft,Js,mc,t,St,sl,Ul,Ca,i,null,-0,0)}}break}while(!0);Vt(e)}function gf(e,t,a,l,s,i,d,h,j,M,L,q,z,D){if(e.timeoutHandle=-1,q=t.subtreeFlags,q&8192||(q&16785408)===16785408){q={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Zt},cf(t,i,q);var W=(i&62914560)===i?Zs-ht():(i&4194048)===i?ff-ht():0;if(W=Lh(q,W),W!==null){ca=i,e.cancelPendingCommit=W(Ef.bind(null,e,t,i,a,l,s,d,h,j,L,q,null,z,D)),Ra(e,i,d,!M);return}}Ef(e,t,i,a,l,s,d,h,j)}function Px(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var s=a[l],i=s.getSnapshot;s=s.value;try{if(!pt(i(),s))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ra(e,t,a,l){t&=~fc,t&=~sl,e.suspendedLanes|=t,e.pingedLanes&=~t,l&&(e.warmLanes|=t),l=e.expirationTimes;for(var s=t;0<s;){var i=31-yt(s),d=1<<i;l[i]=-1,s&=~d}a!==0&&Eu(e,a,t)}function Ws(){return(Ne&6)===0?(On(0),!1):!0}function yc(){if(he!==null){if(Se===0)var e=he.return;else e=he,Ft=Wa=null,Dr(e),Al=null,gn=0,e=he;for(;e!==null;)kd(e.alternate,e),e=e.return;he=null}}function Hl(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,ph(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),ca=0,yc(),we=e,he=a=Jt(e.current,null),ye=t,Se=0,Nt=null,Ca=!1,Ol=Pl(e,t),dc=!1,Ul=St=fc=sl=Aa=He=0,ft=_n=null,mc=!1,(t&8)!==0&&(t|=t&32);var l=e.entangledLanes;if(l!==0)for(e=e.entanglements,l&=t;0<l;){var s=31-yt(l),i=1<<s;t|=e[s],l&=~i}return ra=t,ys(),a}function yf(e,t){oe=null,U.H=En,t===Cl||t===Ts?(t=_o(),Se=3):t===jr?(t=_o(),Se=4):Se=t===Jr?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Nt=t,he===null&&(He=1,qs(e,wt(t,e.current)))}function pf(){var e=bt.current;return e===null?!0:(ye&4194048)===ye?_t===null:(ye&62914560)===ye||(ye&536870912)!==0?e===_t:!1}function vf(){var e=U.H;return U.H=En,e===null?En:e}function bf(){var e=U.A;return U.A=Wx,e}function Fs(){He=4,Ca||(ye&4194048)!==ye&&bt.current!==null||(Ol=!0),(Aa&134217727)===0&&(sl&134217727)===0||we===null||Ra(we,ye,St,!1)}function pc(e,t,a){var l=Ne;Ne|=2;var s=vf(),i=bf();(we!==e||ye!==t)&&(Js=null,Hl(e,t)),t=!1;var d=He;e:do try{if(Se!==0&&he!==null){var h=he,j=Nt;switch(Se){case 8:yc(),d=6;break e;case 3:case 2:case 9:case 6:bt.current===null&&(t=!0);var M=Se;if(Se=0,Nt=null,Bl(e,h,j,M),a&&Ol){d=0;break e}break;default:M=Se,Se=0,Nt=null,Bl(e,h,j,M)}}Ix(),d=He;break}catch(L){yf(e,L)}while(!0);return t&&e.shellSuspendCounter++,Ft=Wa=null,Ne=l,U.H=s,U.A=i,he===null&&(we=null,ye=0,ys()),d}function Ix(){for(;he!==null;)jf(he)}function eh(e,t){var a=Ne;Ne|=2;var l=vf(),s=bf();we!==e||ye!==t?(Js=null,Ks=ht()+500,Hl(e,t)):Ol=Pl(e,t);e:do try{if(Se!==0&&he!==null){t=he;var i=Nt;t:switch(Se){case 1:Se=0,Nt=null,Bl(e,t,i,1);break;case 2:case 9:if(Ro(i)){Se=0,Nt=null,Nf(t);break}t=function(){Se!==2&&Se!==9||we!==e||(Se=7),Vt(e)},i.then(t,t);break e;case 3:Se=7;break e;case 4:Se=5;break e;case 7:Ro(i)?(Se=0,Nt=null,Nf(t)):(Se=0,Nt=null,Bl(e,t,i,7));break;case 5:var d=null;switch(he.tag){case 26:d=he.memoizedState;case 5:case 27:var h=he;if(d?r0(d):h.stateNode.complete){Se=0,Nt=null;var j=h.sibling;if(j!==null)he=j;else{var M=h.return;M!==null?(he=M,Ps(M)):he=null}break t}}Se=0,Nt=null,Bl(e,t,i,5);break;case 6:Se=0,Nt=null,Bl(e,t,i,6);break;case 8:yc(),He=6;break e;default:throw Error(u(462))}}th();break}catch(L){yf(e,L)}while(!0);return Ft=Wa=null,U.H=l,U.A=s,Ne=a,he!==null?0:(we=null,ye=0,ys(),He)}function th(){for(;he!==null&&!Em();)jf(he)}function jf(e){var t=Qd(e.alternate,e,ra);e.memoizedProps=e.pendingProps,t===null?Ps(e):he=t}function Nf(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=Bd(a,t,t.pendingProps,t.type,void 0,ye);break;case 11:t=Bd(a,t,t.pendingProps,t.type.render,t.ref,ye);break;case 5:Dr(t);default:kd(a,t),t=he=vo(t,ra),t=Qd(a,t,ra)}e.memoizedProps=e.pendingProps,t===null?Ps(e):he=t}function Bl(e,t,a,l){Ft=Wa=null,Dr(t),Al=null,gn=0;var s=t.return;try{if(Vx(e,s,t,a,ye)){He=1,qs(e,wt(a,e.current)),he=null;return}}catch(i){if(s!==null)throw he=s,i;He=1,qs(e,wt(a,e.current)),he=null;return}t.flags&32768?(ve||l===1?e=!0:Ol||(ye&536870912)!==0?e=!1:(Ca=e=!0,(l===2||l===9||l===3||l===6)&&(l=bt.current,l!==null&&l.tag===13&&(l.flags|=16384))),Sf(t,e)):Ps(t)}function Ps(e){var t=e;do{if((t.flags&32768)!==0){Sf(t,Ca);return}e=t.return;var a=kx(t.alternate,t,ra);if(a!==null){he=a;return}if(t=t.sibling,t!==null){he=t;return}he=t=e}while(t!==null);He===0&&(He=5)}function Sf(e,t){do{var a=Zx(e.alternate,e);if(a!==null){a.flags&=32767,he=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){he=e;return}he=e=a}while(e!==null);He=6,he=null}function Ef(e,t,a,l,s,i,d,h,j){e.cancelPendingCommit=null;do Is();while(Ke!==0);if((Ne&6)!==0)throw Error(u(327));if(t!==null){if(t===e.current)throw Error(u(177));if(i=t.lanes|t.childLanes,i|=ir,Om(e,a,i,d,h,j),e===we&&(he=we=null,ye=0),Ll=t,Ma=e,ca=a,xc=i,hc=s,mf=l,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,sh(ts,function(){return Mf(),null})):(e.callbackNode=null,e.callbackPriority=0),l=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||l){l=U.T,U.T=null,s=k.p,k.p=2,d=Ne,Ne|=4;try{Kx(e,t,a)}finally{Ne=d,k.p=s,U.T=l}}Ke=1,Tf(),Cf(),Af()}}function Tf(){if(Ke===1){Ke=0;var e=Ma,t=Ll,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=U.T,U.T=null;var l=k.p;k.p=2;var s=Ne;Ne|=4;try{nf(t,e);var i=Rc,d=uo(e.containerInfo),h=i.focusedElem,j=i.selectionRange;if(d!==h&&h&&h.ownerDocument&&co(h.ownerDocument.documentElement,h)){if(j!==null&&tr(h)){var M=j.start,L=j.end;if(L===void 0&&(L=M),"selectionStart"in h)h.selectionStart=M,h.selectionEnd=Math.min(L,h.value.length);else{var q=h.ownerDocument||document,z=q&&q.defaultView||window;if(z.getSelection){var D=z.getSelection(),W=h.textContent.length,se=Math.min(j.start,W),Ae=j.end===void 0?se:Math.min(j.end,W);!D.extend&&se>Ae&&(d=Ae,Ae=se,se=d);var C=ro(h,se),E=ro(h,Ae);if(C&&E&&(D.rangeCount!==1||D.anchorNode!==C.node||D.anchorOffset!==C.offset||D.focusNode!==E.node||D.focusOffset!==E.offset)){var w=q.createRange();w.setStart(C.node,C.offset),D.removeAllRanges(),se>Ae?(D.addRange(w),D.extend(E.node,E.offset)):(w.setEnd(E.node,E.offset),D.addRange(w))}}}}for(q=[],D=h;D=D.parentNode;)D.nodeType===1&&q.push({element:D,left:D.scrollLeft,top:D.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;h<q.length;h++){var H=q[h];H.element.scrollLeft=H.left,H.element.scrollTop=H.top}}di=!!Mc,Rc=Mc=null}finally{Ne=s,k.p=l,U.T=a}}e.current=t,Ke=2}}function Cf(){if(Ke===2){Ke=0;var e=Ma,t=Ll,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=U.T,U.T=null;var l=k.p;k.p=2;var s=Ne;Ne|=4;try{Id(e,t.alternate,t)}finally{Ne=s,k.p=l,U.T=a}}Ke=3}}function Af(){if(Ke===4||Ke===3){Ke=0,Tm();var e=Ma,t=Ll,a=ca,l=mf;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Ke=5:(Ke=0,Ll=Ma=null,wf(e,e.pendingLanes));var s=e.pendingLanes;if(s===0&&(wa=null),Li(a),t=t.stateNode,gt&&typeof gt.onCommitFiberRoot=="function")try{gt.onCommitFiberRoot(Fl,t,void 0,(t.current.flags&128)===128)}catch{}if(l!==null){t=U.T,s=k.p,k.p=2,U.T=null;try{for(var i=e.onRecoverableError,d=0;d<l.length;d++){var h=l[d];i(h.value,{componentStack:h.stack})}}finally{U.T=t,k.p=s}}(ca&3)!==0&&Is(),Vt(e),s=e.pendingLanes,(a&261930)!==0&&(s&42)!==0?e===gc?Dn++:(Dn=0,gc=e):Dn=0,On(0)}}function wf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,xn(t)))}function Is(){return Tf(),Cf(),Af(),Mf()}function Mf(){if(Ke!==5)return!1;var e=Ma,t=xc;xc=0;var a=Li(ca),l=U.T,s=k.p;try{k.p=32>a?32:a,U.T=null,a=hc,hc=null;var i=Ma,d=ca;if(Ke=0,Ll=Ma=null,ca=0,(Ne&6)!==0)throw Error(u(331));var h=Ne;if(Ne|=4,of(i.current),rf(i,i.current,d,a),Ne=h,On(0,!1),gt&&typeof gt.onPostCommitFiberRoot=="function")try{gt.onPostCommitFiberRoot(Fl,i)}catch{}return!0}finally{k.p=s,U.T=l,wf(e,t)}}function Rf(e,t,a){t=wt(a,t),t=Kr(e.stateNode,t,2),e=Na(e,t,2),e!==null&&(Il(e,2),Vt(e))}function Ee(e,t,a){if(e.tag===3)Rf(e,e,a);else for(;t!==null;){if(t.tag===3){Rf(t,e,a);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(wa===null||!wa.has(l))){e=wt(a,e),a=Rd(2),l=Na(t,a,2),l!==null&&(zd(a,l,t,e),Il(l,2),Vt(l));break}}t=t.return}}function vc(e,t,a){var l=e.pingCache;if(l===null){l=e.pingCache=new Fx;var s=new Set;l.set(t,s)}else s=l.get(t),s===void 0&&(s=new Set,l.set(t,s));s.has(a)||(dc=!0,s.add(a),e=ah.bind(null,e,t,a),t.then(e,e))}function ah(e,t,a){var l=e.pingCache;l!==null&&l.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,we===e&&(ye&a)===a&&(He===4||He===3&&(ye&62914560)===ye&&300>ht()-Zs?(Ne&2)===0&&Hl(e,0):fc|=a,Ul===ye&&(Ul=0)),Vt(e)}function zf(e,t){t===0&&(t=Su()),e=Za(e,t),e!==null&&(Il(e,t),Vt(e))}function lh(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),zf(e,a)}function nh(e,t){var a=0;switch(e.tag){case 31:case 13:var l=e.stateNode,s=e.memoizedState;s!==null&&(a=s.retryLane);break;case 19:l=e.stateNode;break;case 22:l=e.stateNode._retryCache;break;default:throw Error(u(314))}l!==null&&l.delete(t),zf(e,a)}function sh(e,t){return _i(e,t)}var ei=null,ql=null,bc=!1,ti=!1,jc=!1,za=0;function Vt(e){e!==ql&&e.next===null&&(ql===null?ei=ql=e:ql=ql.next=e),ti=!0,bc||(bc=!0,rh())}function On(e,t){if(!jc&&ti){jc=!0;do for(var a=!1,l=ei;l!==null;){if(e!==0){var s=l.pendingLanes;if(s===0)var i=0;else{var d=l.suspendedLanes,h=l.pingedLanes;i=(1<<31-yt(42|e)+1)-1,i&=s&~(d&~h),i=i&201326741?i&201326741|1:i?i|2:0}i!==0&&(a=!0,Uf(l,i))}else i=ye,i=ss(l,l===we?i:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(i&3)===0||Pl(l,i)||(a=!0,Uf(l,i));l=l.next}while(a);jc=!1}}function ih(){_f()}function _f(){ti=bc=!1;var e=0;za!==0&&yh()&&(e=za);for(var t=ht(),a=null,l=ei;l!==null;){var s=l.next,i=Df(l,t);i===0?(l.next=null,a===null?ei=s:a.next=s,s===null&&(ql=a)):(a=l,(e!==0||(i&3)!==0)&&(ti=!0)),l=s}Ke!==0&&Ke!==5||On(e),za!==0&&(za=0)}function Df(e,t){for(var a=e.suspendedLanes,l=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes&-62914561;0<i;){var d=31-yt(i),h=1<<d,j=s[d];j===-1?((h&a)===0||(h&l)!==0)&&(s[d]=Dm(h,t)):j<=t&&(e.expiredLanes|=h),i&=~h}if(t=we,a=ye,a=ss(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l=e.callbackNode,a===0||e===t&&(Se===2||Se===9)||e.cancelPendingCommit!==null)return l!==null&&l!==null&&Di(l),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||Pl(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(l!==null&&Di(l),Li(a)){case 2:case 8:a=ju;break;case 32:a=ts;break;case 268435456:a=Nu;break;default:a=ts}return l=Of.bind(null,e),a=_i(a,l),e.callbackPriority=t,e.callbackNode=a,t}return l!==null&&l!==null&&Di(l),e.callbackPriority=2,e.callbackNode=null,2}function Of(e,t){if(Ke!==0&&Ke!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(Is()&&e.callbackNode!==a)return null;var l=ye;return l=ss(e,e===we?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),l===0?null:(hf(e,l,t),Df(e,ht()),e.callbackNode!=null&&e.callbackNode===a?Of.bind(null,e):null)}function Uf(e,t){if(Is())return null;hf(e,t,!0)}function rh(){vh(function(){(Ne&6)!==0?_i(bu,ih):_f()})}function Nc(){if(za===0){var e=El;e===0&&(e=as,as<<=1,(as&261888)===0&&(as=256)),za=e}return za}function Lf(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:us(""+e)}function Hf(e,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,e.id&&a.setAttribute("form",e.id),t.parentNode.insertBefore(a,t),e=new FormData(e),a.parentNode.removeChild(a),e}function ch(e,t,a,l,s){if(t==="submit"&&a&&a.stateNode===s){var i=Lf((s[rt]||null).action),d=l.submitter;d&&(t=(t=d[rt]||null)?Lf(t.formAction):d.getAttribute("formAction"),t!==null&&(i=t,d=null));var h=new ms("action","action",null,l,s);e.push({event:h,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(za!==0){var j=d?Hf(s,d):new FormData(s);$r(a,{pending:!0,data:j,method:s.method,action:i},null,j)}}else typeof i=="function"&&(h.preventDefault(),j=d?Hf(s,d):new FormData(s),$r(a,{pending:!0,data:j,method:s.method,action:i},i,j))},currentTarget:s}]})}}for(var Sc=0;Sc<sr.length;Sc++){var Ec=sr[Sc],uh=Ec.toLowerCase(),oh=Ec[0].toUpperCase()+Ec.slice(1);Lt(uh,"on"+oh)}Lt(mo,"onAnimationEnd"),Lt(xo,"onAnimationIteration"),Lt(ho,"onAnimationStart"),Lt("dblclick","onDoubleClick"),Lt("focusin","onFocus"),Lt("focusout","onBlur"),Lt(Cx,"onTransitionRun"),Lt(Ax,"onTransitionStart"),Lt(wx,"onTransitionCancel"),Lt(go,"onTransitionEnd"),ol("onMouseEnter",["mouseout","mouseover"]),ol("onMouseLeave",["mouseout","mouseover"]),ol("onPointerEnter",["pointerout","pointerover"]),ol("onPointerLeave",["pointerout","pointerover"]),Va("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Va("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Va("onBeforeInput",["compositionend","keypress","textInput","paste"]),Va("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Va("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Va("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Un="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(" "),dh=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Un));function Bf(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var l=e[a],s=l.event;l=l.listeners;e:{var i=void 0;if(t)for(var d=l.length-1;0<=d;d--){var h=l[d],j=h.instance,M=h.currentTarget;if(h=h.listener,j!==i&&s.isPropagationStopped())break e;i=h,s.currentTarget=M;try{i(s)}catch(L){gs(L)}s.currentTarget=null,i=j}else for(d=0;d<l.length;d++){if(h=l[d],j=h.instance,M=h.currentTarget,h=h.listener,j!==i&&s.isPropagationStopped())break e;i=h,s.currentTarget=M;try{i(s)}catch(L){gs(L)}s.currentTarget=null,i=j}}}}function ge(e,t){var a=t[Hi];a===void 0&&(a=t[Hi]=new Set);var l=e+"__bubble";a.has(l)||(qf(t,e,2,!1),a.add(l))}function Tc(e,t,a){var l=0;t&&(l|=4),qf(a,e,l,t)}var ai="_reactListening"+Math.random().toString(36).slice(2);function Cc(e){if(!e[ai]){e[ai]=!0,Ru.forEach(function(a){a!=="selectionchange"&&(dh.has(a)||Tc(a,!1,e),Tc(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ai]||(t[ai]=!0,Tc("selectionchange",!1,t))}}function qf(e,t,a,l){switch(x0(t)){case 2:var s=qh;break;case 8:s=Yh;break;default:s=Gc}a=s.bind(null,t,a,e),s=void 0,!ki||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),l?s!==void 0?e.addEventListener(t,a,{capture:!0,passive:s}):e.addEventListener(t,a,!0):s!==void 0?e.addEventListener(t,a,{passive:s}):e.addEventListener(t,a,!1)}function Ac(e,t,a,l,s){var i=l;if((t&1)===0&&(t&2)===0&&l!==null)e:for(;;){if(l===null)return;var d=l.tag;if(d===3||d===4){var h=l.stateNode.containerInfo;if(h===s)break;if(d===4)for(d=l.return;d!==null;){var j=d.tag;if((j===3||j===4)&&d.stateNode.containerInfo===s)return;d=d.return}for(;h!==null;){if(d=rl(h),d===null)return;if(j=d.tag,j===5||j===6||j===26||j===27){l=i=d;continue e}h=h.parentNode}}l=l.return}$u(function(){var M=i,L=Qi(a),q=[];e:{var z=yo.get(e);if(z!==void 0){var D=ms,W=e;switch(e){case"keypress":if(ds(a)===0)break e;case"keydown":case"keyup":D=nx;break;case"focusin":W="focus",D=Wi;break;case"focusout":W="blur",D=Wi;break;case"beforeblur":case"afterblur":D=Wi;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":D=Xu;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":D=km;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":D=rx;break;case mo:case xo:case ho:D=Jm;break;case go:D=ux;break;case"scroll":case"scrollend":D=Qm;break;case"wheel":D=dx;break;case"copy":case"cut":case"paste":D=Fm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":D=Zu;break;case"toggle":case"beforetoggle":D=mx}var se=(t&4)!==0,Ae=!se&&(e==="scroll"||e==="scrollend"),C=se?z!==null?z+"Capture":null:z;se=[];for(var E=M,w;E!==null;){var H=E;if(w=H.stateNode,H=H.tag,H!==5&&H!==26&&H!==27||w===null||C===null||(H=an(E,C),H!=null&&se.push(Ln(E,H,w))),Ae)break;E=E.return}0<se.length&&(z=new D(z,W,null,a,L),q.push({event:z,listeners:se}))}}if((t&7)===0){e:{if(z=e==="mouseover"||e==="pointerover",D=e==="mouseout"||e==="pointerout",z&&a!==Vi&&(W=a.relatedTarget||a.fromElement)&&(rl(W)||W[il]))break e;if((D||z)&&(z=L.window===L?L:(z=L.ownerDocument)?z.defaultView||z.parentWindow:window,D?(W=a.relatedTarget||a.toElement,D=M,W=W?rl(W):null,W!==null&&(Ae=x(W),se=W.tag,W!==Ae||se!==5&&se!==27&&se!==6)&&(W=null)):(D=null,W=M),D!==W)){if(se=Xu,H="onMouseLeave",C="onMouseEnter",E="mouse",(e==="pointerout"||e==="pointerover")&&(se=Zu,H="onPointerLeave",C="onPointerEnter",E="pointer"),Ae=D==null?z:tn(D),w=W==null?z:tn(W),z=new se(H,E+"leave",D,a,L),z.target=Ae,z.relatedTarget=w,H=null,rl(L)===M&&(se=new se(C,E+"enter",W,a,L),se.target=w,se.relatedTarget=Ae,H=se),Ae=H,D&&W)t:{for(se=fh,C=D,E=W,w=0,H=C;H;H=se(H))w++;H=0;for(var ae=E;ae;ae=se(ae))H++;for(;0<w-H;)C=se(C),w--;for(;0<H-w;)E=se(E),H--;for(;w--;){if(C===E||E!==null&&C===E.alternate){se=C;break t}C=se(C),E=se(E)}se=null}else se=null;D!==null&&Yf(q,z,D,se,!1),W!==null&&Ae!==null&&Yf(q,Ae,W,se,!0)}}e:{if(z=M?tn(M):window,D=z.nodeName&&z.nodeName.toLowerCase(),D==="select"||D==="input"&&z.type==="file")var be=to;else if(Iu(z))if(ao)be=Sx;else{be=jx;var ee=bx}else D=z.nodeName,!D||D.toLowerCase()!=="input"||z.type!=="checkbox"&&z.type!=="radio"?M&&$i(M.elementType)&&(be=to):be=Nx;if(be&&(be=be(e,M))){eo(q,be,a,L);break e}ee&&ee(e,z,M),e==="focusout"&&M&&z.type==="number"&&M.memoizedProps.value!=null&&Gi(z,"number",z.value)}switch(ee=M?tn(M):window,e){case"focusin":(Iu(ee)||ee.contentEditable==="true")&&(gl=ee,ar=M,dn=null);break;case"focusout":dn=ar=gl=null;break;case"mousedown":lr=!0;break;case"contextmenu":case"mouseup":case"dragend":lr=!1,oo(q,a,L);break;case"selectionchange":if(Tx)break;case"keydown":case"keyup":oo(q,a,L)}var de;if(Pi)e:{switch(e){case"compositionstart":var pe="onCompositionStart";break e;case"compositionend":pe="onCompositionEnd";break e;case"compositionupdate":pe="onCompositionUpdate";break e}pe=void 0}else hl?Fu(e,a)&&(pe="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(pe="onCompositionStart");pe&&(Ku&&a.locale!=="ko"&&(hl||pe!=="onCompositionStart"?pe==="onCompositionEnd"&&hl&&(de=Vu()):(ha=L,Zi="value"in ha?ha.value:ha.textContent,hl=!0)),ee=li(M,pe),0<ee.length&&(pe=new ku(pe,e,null,a,L),q.push({event:pe,listeners:ee}),de?pe.data=de:(de=Pu(a),de!==null&&(pe.data=de)))),(de=hx?gx(e,a):yx(e,a))&&(pe=li(M,"onBeforeInput"),0<pe.length&&(ee=new ku("onBeforeInput","beforeinput",null,a,L),q.push({event:ee,listeners:pe}),ee.data=de)),ch(q,e,M,a,L)}Bf(q,t)})}function Ln(e,t,a){return{instance:e,listener:t,currentTarget:a}}function li(e,t){for(var a=t+"Capture",l=[];e!==null;){var s=e,i=s.stateNode;if(s=s.tag,s!==5&&s!==26&&s!==27||i===null||(s=an(e,a),s!=null&&l.unshift(Ln(e,s,i)),s=an(e,t),s!=null&&l.push(Ln(e,s,i))),e.tag===3)return l;e=e.return}return[]}function fh(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Yf(e,t,a,l,s){for(var i=t._reactName,d=[];a!==null&&a!==l;){var h=a,j=h.alternate,M=h.stateNode;if(h=h.tag,j!==null&&j===l)break;h!==5&&h!==26&&h!==27||M===null||(j=M,s?(M=an(a,i),M!=null&&d.unshift(Ln(a,M,j))):s||(M=an(a,i),M!=null&&d.push(Ln(a,M,j)))),a=a.return}d.length!==0&&e.push({event:t,listeners:d})}var mh=/\r\n?/g,xh=/\u0000|\uFFFD/g;function Gf(e){return(typeof e=="string"?e:""+e).replace(mh,`
9
9
  `).replace(xh,"")}function $f(e,t){return t=Gf(t),Gf(e)===t}function Ce(e,t,a,l,s,i){switch(a){case"children":typeof l=="string"?t==="body"||t==="textarea"&&l===""||fl(e,l):(typeof l=="number"||typeof l=="bigint")&&t!=="body"&&fl(e,""+l);break;case"className":rs(e,"class",l);break;case"tabIndex":rs(e,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":rs(e,a,l);break;case"style":Yu(e,l,i);break;case"data":if(t!=="object"){rs(e,"data",l);break}case"src":case"href":if(l===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=us(""+l),e.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof i=="function"&&(a==="formAction"?(t!=="input"&&Ce(e,t,"name",s.name,s,null),Ce(e,t,"formEncType",s.formEncType,s,null),Ce(e,t,"formMethod",s.formMethod,s,null),Ce(e,t,"formTarget",s.formTarget,s,null)):(Ce(e,t,"encType",s.encType,s,null),Ce(e,t,"method",s.method,s,null),Ce(e,t,"target",s.target,s,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){e.removeAttribute(a);break}l=us(""+l),e.setAttribute(a,l);break;case"onClick":l!=null&&(e.onclick=Zt);break;case"onScroll":l!=null&&ge("scroll",e);break;case"onScrollEnd":l!=null&&ge("scrollend",e);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(u(61));if(a=l.__html,a!=null){if(s.children!=null)throw Error(u(60));e.innerHTML=a}}break;case"multiple":e.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":e.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){e.removeAttribute("xlink:href");break}a=us(""+l),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""+l):e.removeAttribute(a);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"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":l===!0?e.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?e.setAttribute(a,l):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?e.setAttribute(a,l):e.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?e.removeAttribute(a):e.setAttribute(a,l);break;case"popover":ge("beforetoggle",e),ge("toggle",e),is(e,"popover",l);break;case"xlinkActuate":kt(e,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":kt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":kt(e,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":kt(e,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":kt(e,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":kt(e,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":kt(e,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":kt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":kt(e,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":is(e,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=$m.get(a)||a,is(e,a,l))}}function wc(e,t,a,l,s,i){switch(a){case"style":Yu(e,l,i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(u(61));if(a=l.__html,a!=null){if(s.children!=null)throw Error(u(60));e.innerHTML=a}}break;case"children":typeof l=="string"?fl(e,l):(typeof l=="number"||typeof l=="bigint")&&fl(e,""+l);break;case"onScroll":l!=null&&ge("scroll",e);break;case"onScrollEnd":l!=null&&ge("scrollend",e);break;case"onClick":l!=null&&(e.onclick=Zt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!zu.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(s=a.endsWith("Capture"),t=a.slice(2,s?a.length-7:void 0),i=e[rt]||null,i=i!=null?i[a]:null,typeof i=="function"&&e.removeEventListener(t,i,s),typeof l=="function")){typeof i!="function"&&i!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,l,s);break e}a in e?e[a]=l:l===!0?e.setAttribute(a,""):is(e,a,l)}}}function tt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ge("error",e),ge("load",e);var l=!1,s=!1,i;for(i in a)if(a.hasOwnProperty(i)){var d=a[i];if(d!=null)switch(i){case"src":l=!0;break;case"srcSet":s=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(u(137,t));default:Ce(e,t,i,d,a,null)}}s&&Ce(e,t,"srcSet",a.srcSet,a,null),l&&Ce(e,t,"src",a.src,a,null);return;case"input":ge("invalid",e);var h=i=d=s=null,j=null,M=null;for(l in a)if(a.hasOwnProperty(l)){var L=a[l];if(L!=null)switch(l){case"name":s=L;break;case"type":d=L;break;case"checked":j=L;break;case"defaultChecked":M=L;break;case"value":i=L;break;case"defaultValue":h=L;break;case"children":case"dangerouslySetInnerHTML":if(L!=null)throw Error(u(137,t));break;default:Ce(e,t,l,L,a,null)}}Lu(e,i,h,j,M,d,s,!1);return;case"select":ge("invalid",e),l=d=i=null;for(s in a)if(a.hasOwnProperty(s)&&(h=a[s],h!=null))switch(s){case"value":i=h;break;case"defaultValue":d=h;break;case"multiple":l=h;default:Ce(e,t,s,h,a,null)}t=i,a=d,e.multiple=!!l,t!=null?dl(e,!!l,t,!1):a!=null&&dl(e,!!l,a,!0);return;case"textarea":ge("invalid",e),i=s=l=null;for(d in a)if(a.hasOwnProperty(d)&&(h=a[d],h!=null))switch(d){case"value":l=h;break;case"defaultValue":s=h;break;case"children":i=h;break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(u(91));break;default:Ce(e,t,d,h,a,null)}Bu(e,l,s,i);return;case"option":for(j in a)a.hasOwnProperty(j)&&(l=a[j],l!=null)&&(j==="selected"?e.selected=l&&typeof l!="function"&&typeof l!="symbol":Ce(e,t,j,l,a,null));return;case"dialog":ge("beforetoggle",e),ge("toggle",e),ge("cancel",e),ge("close",e);break;case"iframe":case"object":ge("load",e);break;case"video":case"audio":for(l=0;l<Un.length;l++)ge(Un[l],e);break;case"image":ge("error",e),ge("load",e);break;case"details":ge("toggle",e);break;case"embed":case"source":case"link":ge("error",e),ge("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(M in a)if(a.hasOwnProperty(M)&&(l=a[M],l!=null))switch(M){case"children":case"dangerouslySetInnerHTML":throw Error(u(137,t));default:Ce(e,t,M,l,a,null)}return;default:if($i(t)){for(L in a)a.hasOwnProperty(L)&&(l=a[L],l!==void 0&&wc(e,t,L,l,a,void 0));return}}for(h in a)a.hasOwnProperty(h)&&(l=a[h],l!=null&&Ce(e,t,h,l,a,null))}function hh(e,t,a,l){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var s=null,i=null,d=null,h=null,j=null,M=null,L=null;for(D in a){var q=a[D];if(a.hasOwnProperty(D)&&q!=null)switch(D){case"checked":break;case"value":break;case"defaultValue":j=q;default:l.hasOwnProperty(D)||Ce(e,t,D,null,l,q)}}for(var z in l){var D=l[z];if(q=a[z],l.hasOwnProperty(z)&&(D!=null||q!=null))switch(z){case"type":i=D;break;case"name":s=D;break;case"checked":M=D;break;case"defaultChecked":L=D;break;case"value":d=D;break;case"defaultValue":h=D;break;case"children":case"dangerouslySetInnerHTML":if(D!=null)throw Error(u(137,t));break;default:D!==q&&Ce(e,t,z,D,l,q)}}Yi(e,d,h,j,M,L,i,s);return;case"select":D=d=h=z=null;for(i in a)if(j=a[i],a.hasOwnProperty(i)&&j!=null)switch(i){case"value":break;case"multiple":D=j;default:l.hasOwnProperty(i)||Ce(e,t,i,null,l,j)}for(s in l)if(i=l[s],j=a[s],l.hasOwnProperty(s)&&(i!=null||j!=null))switch(s){case"value":z=i;break;case"defaultValue":h=i;break;case"multiple":d=i;default:i!==j&&Ce(e,t,s,i,l,j)}t=h,a=d,l=D,z!=null?dl(e,!!a,z,!1):!!l!=!!a&&(t!=null?dl(e,!!a,t,!0):dl(e,!!a,a?[]:"",!1));return;case"textarea":D=z=null;for(h in a)if(s=a[h],a.hasOwnProperty(h)&&s!=null&&!l.hasOwnProperty(h))switch(h){case"value":break;case"children":break;default:Ce(e,t,h,null,l,s)}for(d in l)if(s=l[d],i=a[d],l.hasOwnProperty(d)&&(s!=null||i!=null))switch(d){case"value":z=s;break;case"defaultValue":D=s;break;case"children":break;case"dangerouslySetInnerHTML":if(s!=null)throw Error(u(91));break;default:s!==i&&Ce(e,t,d,s,l,i)}Hu(e,z,D);return;case"option":for(var W in a)z=a[W],a.hasOwnProperty(W)&&z!=null&&!l.hasOwnProperty(W)&&(W==="selected"?e.selected=!1:Ce(e,t,W,null,l,z));for(j in l)z=l[j],D=a[j],l.hasOwnProperty(j)&&z!==D&&(z!=null||D!=null)&&(j==="selected"?e.selected=z&&typeof z!="function"&&typeof z!="symbol":Ce(e,t,j,z,l,D));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 se in a)z=a[se],a.hasOwnProperty(se)&&z!=null&&!l.hasOwnProperty(se)&&Ce(e,t,se,null,l,z);for(M in l)if(z=l[M],D=a[M],l.hasOwnProperty(M)&&z!==D&&(z!=null||D!=null))switch(M){case"children":case"dangerouslySetInnerHTML":if(z!=null)throw Error(u(137,t));break;default:Ce(e,t,M,z,l,D)}return;default:if($i(t)){for(var Ae in a)z=a[Ae],a.hasOwnProperty(Ae)&&z!==void 0&&!l.hasOwnProperty(Ae)&&wc(e,t,Ae,void 0,l,z);for(L in l)z=l[L],D=a[L],!l.hasOwnProperty(L)||z===D||z===void 0&&D===void 0||wc(e,t,L,z,l,D);return}}for(var C in a)z=a[C],a.hasOwnProperty(C)&&z!=null&&!l.hasOwnProperty(C)&&Ce(e,t,C,null,l,z);for(q in l)z=l[q],D=a[q],!l.hasOwnProperty(q)||z===D||z==null&&D==null||Ce(e,t,q,z,l,D)}function Vf(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function gh(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var s=a[l],i=s.transferSize,d=s.initiatorType,h=s.duration;if(i&&h&&Vf(d)){for(d=0,h=s.responseEnd,l+=1;l<a.length;l++){var j=a[l],M=j.startTime;if(M>h)break;var L=j.transferSize,q=j.initiatorType;L&&Vf(q)&&(j=j.responseEnd,d+=L*(j<h?1:(h-M)/(j-M)))}if(--l,t+=8*(i+d)/(s.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Mc=null,Rc=null;function ni(e){return e.nodeType===9?e:e.ownerDocument}function Qf(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 Xf(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function zc(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var _c=null;function yh(){var e=window.event;return e&&e.type==="popstate"?e===_c?!1:(_c=e,!0):(_c=null,!1)}var kf=typeof setTimeout=="function"?setTimeout:void 0,ph=typeof clearTimeout=="function"?clearTimeout:void 0,Zf=typeof Promise=="function"?Promise:void 0,vh=typeof queueMicrotask=="function"?queueMicrotask:typeof Zf<"u"?function(e){return Zf.resolve(null).then(e).catch(bh)}:kf;function bh(e){setTimeout(function(){throw e})}function _a(e){return e==="head"}function Kf(e,t){var a=t,l=0;do{var s=a.nextSibling;if(e.removeChild(a),s&&s.nodeType===8)if(a=s.data,a==="/$"||a==="/&"){if(l===0){e.removeChild(s),Vl(t);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")Hn(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Hn(a);for(var i=a.firstChild;i;){var d=i.nextSibling,h=i.nodeName;i[en]||h==="SCRIPT"||h==="STYLE"||h==="LINK"&&i.rel.toLowerCase()==="stylesheet"||a.removeChild(i),i=d}}else a==="body"&&Hn(e.ownerDocument.body);a=s}while(a);Vl(t)}function Jf(e,t){var a=e;e=0;do{var l=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=l}while(a)}function Dc(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Dc(a),Bi(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function jh(e,t,a,l){for(;e.nodeType===1;){var s=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!l&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(l){if(!e[en])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(i=e.getAttribute("rel"),i==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(i!==s.rel||e.getAttribute("href")!==(s.href==null||s.href===""?null:s.href)||e.getAttribute("crossorigin")!==(s.crossOrigin==null?null:s.crossOrigin)||e.getAttribute("title")!==(s.title==null?null:s.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(i=e.getAttribute("src"),(i!==(s.src==null?null:s.src)||e.getAttribute("type")!==(s.type==null?null:s.type)||e.getAttribute("crossorigin")!==(s.crossOrigin==null?null:s.crossOrigin))&&i&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var i=s.name==null?null:""+s.name;if(s.type==="hidden"&&e.getAttribute("name")===i)return e}else return e;if(e=Dt(e.nextSibling),e===null)break}return null}function Nh(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=Dt(e.nextSibling),e===null))return null;return e}function Wf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Dt(e.nextSibling),e===null))return null;return e}function Oc(e){return e.data==="$?"||e.data==="$~"}function Uc(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Sh(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var l=function(){t(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),e._reactRetry=l}}function Dt(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var Lc=null;function Ff(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return Dt(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function Pf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return e;t--}else a!=="/$"&&a!=="/&"||t++}e=e.previousSibling}return null}function If(e,t,a){switch(t=ni(a),e){case"html":if(e=t.documentElement,!e)throw Error(u(452));return e;case"head":if(e=t.head,!e)throw Error(u(453));return e;case"body":if(e=t.body,!e)throw Error(u(454));return e;default:throw Error(u(451))}}function Hn(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Bi(e)}var Ot=new Map,e0=new Set;function si(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ua=k.d;k.d={f:Eh,r:Th,D:Ch,C:Ah,L:wh,m:Mh,X:zh,S:Rh,M:_h};function Eh(){var e=ua.f(),t=Ws();return e||t}function Th(e){var t=cl(e);t!==null&&t.tag===5&&t.type==="form"?gd(t):ua.r(e)}var Yl=typeof document>"u"?null:document;function t0(e,t,a){var l=Yl;if(l&&typeof t=="string"&&t){var s=Ct(t);s='link[rel="'+e+'"][href="'+s+'"]',typeof a=="string"&&(s+='[crossorigin="'+a+'"]'),e0.has(s)||(e0.add(s),e={rel:e,crossOrigin:a,href:t},l.querySelector(s)===null&&(t=l.createElement("link"),tt(t,"link",e),Je(t),l.head.appendChild(t)))}}function Ch(e){ua.D(e),t0("dns-prefetch",e,null)}function Ah(e,t){ua.C(e,t),t0("preconnect",e,t)}function wh(e,t,a){ua.L(e,t,a);var l=Yl;if(l&&e&&t){var s='link[rel="preload"][as="'+Ct(t)+'"]';t==="image"&&a&&a.imageSrcSet?(s+='[imagesrcset="'+Ct(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(s+='[imagesizes="'+Ct(a.imageSizes)+'"]')):s+='[href="'+Ct(e)+'"]';var i=s;switch(t){case"style":i=Gl(e);break;case"script":i=$l(e)}Ot.has(i)||(e=y({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),Ot.set(i,e),l.querySelector(s)!==null||t==="style"&&l.querySelector(Bn(i))||t==="script"&&l.querySelector(qn(i))||(t=l.createElement("link"),tt(t,"link",e),Je(t),l.head.appendChild(t)))}}function Mh(e,t){ua.m(e,t);var a=Yl;if(a&&e){var l=t&&typeof t.as=="string"?t.as:"script",s='link[rel="modulepreload"][as="'+Ct(l)+'"][href="'+Ct(e)+'"]',i=s;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=$l(e)}if(!Ot.has(i)&&(e=y({rel:"modulepreload",href:e},t),Ot.set(i,e),a.querySelector(s)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(qn(i)))return}l=a.createElement("link"),tt(l,"link",e),Je(l),a.head.appendChild(l)}}}function Rh(e,t,a){ua.S(e,t,a);var l=Yl;if(l&&e){var s=ul(l).hoistableStyles,i=Gl(e);t=t||"default";var d=s.get(i);if(!d){var h={loading:0,preload:null};if(d=l.querySelector(Bn(i)))h.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":t},a),(a=Ot.get(i))&&Hc(e,a);var j=d=l.createElement("link");Je(j),tt(j,"link",e),j._p=new Promise(function(M,L){j.onload=M,j.onerror=L}),j.addEventListener("load",function(){h.loading|=1}),j.addEventListener("error",function(){h.loading|=2}),h.loading|=4,ii(d,t,l)}d={type:"stylesheet",instance:d,count:1,state:h},s.set(i,d)}}}function zh(e,t){ua.X(e,t);var a=Yl;if(a&&e){var l=ul(a).hoistableScripts,s=$l(e),i=l.get(s);i||(i=a.querySelector(qn(s)),i||(e=y({src:e,async:!0},t),(t=Ot.get(s))&&Bc(e,t),i=a.createElement("script"),Je(i),tt(i,"link",e),a.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},l.set(s,i))}}function _h(e,t){ua.M(e,t);var a=Yl;if(a&&e){var l=ul(a).hoistableScripts,s=$l(e),i=l.get(s);i||(i=a.querySelector(qn(s)),i||(e=y({src:e,async:!0,type:"module"},t),(t=Ot.get(s))&&Bc(e,t),i=a.createElement("script"),Je(i),tt(i,"link",e),a.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},l.set(s,i))}}function a0(e,t,a,l){var s=(s=xe.current)?si(s):null;if(!s)throw Error(u(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Gl(a.href),a=ul(s).hoistableStyles,l=a.get(t),l||(l={type:"style",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=Gl(a.href);var i=ul(s).hoistableStyles,d=i.get(e);if(d||(s=s.ownerDocument||s,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},i.set(e,d),(i=s.querySelector(Bn(e)))&&!i._p&&(d.instance=i,d.state.loading=5),Ot.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Ot.set(e,a),i||Dh(s,e,a,d.state))),t&&l===null)throw Error(u(528,""));return d}if(t&&l!==null)throw Error(u(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=$l(a),a=ul(s).hoistableScripts,l=a.get(t),l||(l={type:"script",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(u(444,e))}}function Gl(e){return'href="'+Ct(e)+'"'}function Bn(e){return'link[rel="stylesheet"]['+e+"]"}function l0(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function Dh(e,t,a,l){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?l.loading=1:(t=e.createElement("link"),l.preload=t,t.addEventListener("load",function(){return l.loading|=1}),t.addEventListener("error",function(){return l.loading|=2}),tt(t,"link",a),Je(t),e.head.appendChild(t))}function $l(e){return'[src="'+Ct(e)+'"]'}function qn(e){return"script[async]"+e}function n0(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var l=e.querySelector('style[data-href~="'+Ct(a.href)+'"]');if(l)return t.instance=l,Je(l),l;var s=y({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(e.ownerDocument||e).createElement("style"),Je(l),tt(l,"style",s),ii(l,a.precedence,e),t.instance=l;case"stylesheet":s=Gl(a.href);var i=e.querySelector(Bn(s));if(i)return t.state.loading|=4,t.instance=i,Je(i),i;l=l0(a),(s=Ot.get(s))&&Hc(l,s),i=(e.ownerDocument||e).createElement("link"),Je(i);var d=i;return d._p=new Promise(function(h,j){d.onload=h,d.onerror=j}),tt(i,"link",l),t.state.loading|=4,ii(i,a.precedence,e),t.instance=i;case"script":return i=$l(a.src),(s=e.querySelector(qn(i)))?(t.instance=s,Je(s),s):(l=a,(s=Ot.get(i))&&(l=y({},a),Bc(l,s)),e=e.ownerDocument||e,s=e.createElement("script"),Je(s),tt(s,"link",l),e.head.appendChild(s),t.instance=s);case"void":return null;default:throw Error(u(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(l=t.instance,t.state.loading|=4,ii(l,a.precedence,e));return t.instance}function ii(e,t,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),s=l.length?l[l.length-1]:null,i=s,d=0;d<l.length;d++){var h=l[d];if(h.dataset.precedence===t)i=h;else if(i!==s)break}i?i.parentNode.insertBefore(e,i.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function Hc(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Bc(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var ri=null;function s0(e,t,a){if(ri===null){var l=new Map,s=ri=new Map;s.set(a,l)}else s=ri,l=s.get(a),l||(l=new Map,s.set(a,l));if(l.has(e))return l;for(l.set(e,null),a=a.getElementsByTagName(e),s=0;s<a.length;s++){var i=a[s];if(!(i[en]||i[Fe]||e==="link"&&i.getAttribute("rel")==="stylesheet")&&i.namespaceURI!=="http://www.w3.org/2000/svg"){var d=i.getAttribute(t)||"";d=e+d;var h=l.get(d);h?h.push(i):l.set(d,[i])}}return l}function i0(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function Oh(e,t,a){if(a===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function r0(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Uh(e,t,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var s=Gl(l.href),i=t.querySelector(Bn(s));if(i){t=i._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=ci.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=i,Je(i);return}i=t.ownerDocument||t,l=l0(l),(s=Ot.get(s))&&Hc(l,s),i=i.createElement("link"),Je(i);var d=i;d._p=new Promise(function(h,j){d.onload=h,d.onerror=j}),tt(i,"link",l),a.instance=i}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=ci.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var qc=0;function Lh(e,t){return e.stylesheets&&e.count===0&&oi(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var l=setTimeout(function(){if(e.stylesheets&&oi(e,e.stylesheets),e.unsuspend){var i=e.unsuspend;e.unsuspend=null,i()}},6e4+t);0<e.imgBytes&&qc===0&&(qc=62500*gh());var s=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&oi(e,e.stylesheets),e.unsuspend)){var i=e.unsuspend;e.unsuspend=null,i()}},(e.imgBytes>qc?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(l),clearTimeout(s)}}:null}function ci(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)oi(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ui=null;function oi(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ui=new Map,t.forEach(Hh,e),ui=null,ci.call(e))}function Hh(e,t){if(!(t.state.loading&4)){var a=ui.get(e);if(a)var l=a.get(null);else{a=new Map,ui.set(e,a);for(var s=e.querySelectorAll("link[data-precedence],style[data-precedence]"),i=0;i<s.length;i++){var d=s[i];(d.nodeName==="LINK"||d.getAttribute("media")!=="not all")&&(a.set(d.dataset.precedence,d),l=d)}l&&a.set(null,l)}s=t.instance,d=s.getAttribute("data-precedence"),i=a.get(d)||l,i===l&&a.set(null,s),a.set(d,s),this.count++,l=ci.bind(this),s.addEventListener("load",l),s.addEventListener("error",l),i?i.parentNode.insertBefore(s,i.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(s,e.firstChild)),t.state.loading|=4}}var Yn={$$typeof:V,Provider:null,Consumer:null,_currentValue:ne,_currentValue2:ne,_threadCount:0};function Bh(e,t,a,l,s,i,d,h,j){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=Oi(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Oi(0),this.hiddenUpdates=Oi(null),this.identifierPrefix=l,this.onUncaughtError=s,this.onCaughtError=i,this.onRecoverableError=d,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=j,this.incompleteTransitions=new Map}function c0(e,t,a,l,s,i,d,h,j,M,L,q){return e=new Bh(e,t,a,d,j,M,L,q,h),t=1,i===!0&&(t|=24),i=vt(3,null,null,t),e.current=i,i.stateNode=e,t=pr(),t.refCount++,e.pooledCache=t,t.refCount++,i.memoizedState={element:l,isDehydrated:a,cache:t},Nr(i),e}function u0(e){return e?(e=vl,e):vl}function o0(e,t,a,l,s,i){s=u0(s),l.context===null?l.context=s:l.pendingContext=s,l=ja(t),l.payload={element:a},i=i===void 0?null:i,i!==null&&(l.callback=i),a=Na(e,l,t),a!==null&&(mt(a,e,t),pn(a,e,t))}function d0(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Yc(e,t){d0(e,t),(e=e.alternate)&&d0(e,t)}function f0(e){if(e.tag===13||e.tag===31){var t=Za(e,67108864);t!==null&&mt(t,e,67108864),Yc(e,67108864)}}function m0(e){if(e.tag===13||e.tag===31){var t=Et();t=Ui(t);var a=Za(e,t);a!==null&&mt(a,e,t),Yc(e,t)}}var di=!0;function qh(e,t,a,l){var s=U.T;U.T=null;var i=k.p;try{k.p=2,Gc(e,t,a,l)}finally{k.p=i,U.T=s}}function Yh(e,t,a,l){var s=U.T;U.T=null;var i=k.p;try{k.p=8,Gc(e,t,a,l)}finally{k.p=i,U.T=s}}function Gc(e,t,a,l){if(di){var s=$c(l);if(s===null)Ac(e,t,l,fi,a),h0(e,l);else if($h(s,e,t,a,l))l.stopPropagation();else if(h0(e,l),t&4&&-1<Gh.indexOf(e)){for(;s!==null;){var i=cl(s);if(i!==null)switch(i.tag){case 3:if(i=i.stateNode,i.current.memoizedState.isDehydrated){var d=$a(i.pendingLanes);if(d!==0){var h=i;for(h.pendingLanes|=2,h.entangledLanes|=2;d;){var j=1<<31-yt(d);h.entanglements[1]|=j,d&=~j}Vt(i),(Ne&6)===0&&(Ks=ht()+500,On(0))}}break;case 31:case 13:h=Za(i,2),h!==null&&mt(h,i,2),Ws(),Yc(i,2)}if(i=$c(l),i===null&&Ac(e,t,l,fi,a),i===s)break;s=i}s!==null&&l.stopPropagation()}else Ac(e,t,l,null,a)}}function $c(e){return e=Qi(e),Vc(e)}var fi=null;function Vc(e){if(fi=null,e=rl(e),e!==null){var t=x(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=g(t),e!==null)return e;e=null}else if(a===31){if(e=b(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fi=e,null}function x0(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(Cm()){case bu:return 2;case ju:return 8;case ts:case Am:return 32;case Nu:return 268435456;default:return 32}default:return 32}}var Qc=!1,Da=null,Oa=null,Ua=null,Gn=new Map,$n=new Map,La=[],Gh="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function h0(e,t){switch(e){case"focusin":case"focusout":Da=null;break;case"dragenter":case"dragleave":Oa=null;break;case"mouseover":case"mouseout":Ua=null;break;case"pointerover":case"pointerout":Gn.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":$n.delete(t.pointerId)}}function Vn(e,t,a,l,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:a,eventSystemFlags:l,nativeEvent:i,targetContainers:[s]},t!==null&&(t=cl(t),t!==null&&f0(t)),e):(e.eventSystemFlags|=l,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function $h(e,t,a,l,s){switch(t){case"focusin":return Da=Vn(Da,e,t,a,l,s),!0;case"dragenter":return Oa=Vn(Oa,e,t,a,l,s),!0;case"mouseover":return Ua=Vn(Ua,e,t,a,l,s),!0;case"pointerover":var i=s.pointerId;return Gn.set(i,Vn(Gn.get(i)||null,e,t,a,l,s)),!0;case"gotpointercapture":return i=s.pointerId,$n.set(i,Vn($n.get(i)||null,e,t,a,l,s)),!0}return!1}function g0(e){var t=rl(e.target);if(t!==null){var a=x(t);if(a!==null){if(t=a.tag,t===13){if(t=g(a),t!==null){e.blockedOn=t,wu(e.priority,function(){m0(a)});return}}else if(t===31){if(t=b(a),t!==null){e.blockedOn=t,wu(e.priority,function(){m0(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function mi(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=$c(e.nativeEvent);if(a===null){a=e.nativeEvent;var l=new a.constructor(a.type,a);Vi=l,a.target.dispatchEvent(l),Vi=null}else return t=cl(a),t!==null&&f0(t),e.blockedOn=a,!1;t.shift()}return!0}function y0(e,t,a){mi(e)&&a.delete(t)}function Vh(){Qc=!1,Da!==null&&mi(Da)&&(Da=null),Oa!==null&&mi(Oa)&&(Oa=null),Ua!==null&&mi(Ua)&&(Ua=null),Gn.forEach(y0),$n.forEach(y0)}function xi(e,t){e.blockedOn===t&&(e.blockedOn=null,Qc||(Qc=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,Vh)))}var hi=null;function p0(e){hi!==e&&(hi=e,r.unstable_scheduleCallback(r.unstable_NormalPriority,function(){hi===e&&(hi=null);for(var t=0;t<e.length;t+=3){var a=e[t],l=e[t+1],s=e[t+2];if(typeof l!="function"){if(Vc(l||a)===null)continue;break}var i=cl(a);i!==null&&(e.splice(t,3),t-=3,$r(i,{pending:!0,data:s,method:a.method,action:l},l,s))}}))}function Vl(e){function t(j){return xi(j,e)}Da!==null&&xi(Da,e),Oa!==null&&xi(Oa,e),Ua!==null&&xi(Ua,e),Gn.forEach(t),$n.forEach(t);for(var a=0;a<La.length;a++){var l=La[a];l.blockedOn===e&&(l.blockedOn=null)}for(;0<La.length&&(a=La[0],a.blockedOn===null);)g0(a),a.blockedOn===null&&La.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var s=a[l],i=a[l+1],d=s[rt]||null;if(typeof i=="function")d||p0(a);else if(d){var h=null;if(i&&i.hasAttribute("formAction")){if(s=i,d=i[rt]||null)h=d.formAction;else if(Vc(s)!==null)continue}else h=d.action;typeof h=="function"?a[l+1]=h:(a.splice(l,3),l-=3),p0(a)}}}function v0(){function e(i){i.canIntercept&&i.info==="react-transition"&&i.intercept({handler:function(){return new Promise(function(d){return s=d})},focusReset:"manual",scroll:"manual"})}function t(){s!==null&&(s(),s=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var i=navigation.currentEntry;i&&i.url!=null&&navigation.navigate(i.url,{state:i.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,s=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),s!==null&&(s(),s=null)}}}function Xc(e){this._internalRoot=e}gi.prototype.render=Xc.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(u(409));var a=t.current,l=Et();o0(a,l,e,t,null,null)},gi.prototype.unmount=Xc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;o0(e.current,2,null,e,null,null),Ws(),t[il]=null}};function gi(e){this._internalRoot=e}gi.prototype.unstable_scheduleHydration=function(e){if(e){var t=Au();e={blockedOn:null,target:e,priority:t};for(var a=0;a<La.length&&t!==0&&t<La[a].priority;a++);La.splice(a,0,e),a===0&&g0(e)}};var b0=o.version;if(b0!=="19.2.4")throw Error(u(527,b0,"19.2.4"));k.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(u(188)):(e=Object.keys(e).join(","),Error(u(268,e)));return e=m(t),e=e!==null?v(e):null,e=e===null?null:e.stateNode,e};var Qh={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:U,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yi=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yi.isDisabled&&yi.supportsFiber)try{Fl=yi.inject(Qh),gt=yi}catch{}}return Xn.createRoot=function(e,t){if(!f(e))throw Error(u(299));var a=!1,l="",s=Cd,i=Ad,d=wd;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onUncaughtError!==void 0&&(s=t.onUncaughtError),t.onCaughtError!==void 0&&(i=t.onCaughtError),t.onRecoverableError!==void 0&&(d=t.onRecoverableError)),t=c0(e,1,!1,null,null,a,l,null,s,i,d,v0),e[il]=t.current,Cc(e),new Xc(t)},Xn.hydrateRoot=function(e,t,a){if(!f(e))throw Error(u(299));var l=!1,s="",i=Cd,d=Ad,h=wd,j=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(s=a.identifierPrefix),a.onUncaughtError!==void 0&&(i=a.onUncaughtError),a.onCaughtError!==void 0&&(d=a.onCaughtError),a.onRecoverableError!==void 0&&(h=a.onRecoverableError),a.formState!==void 0&&(j=a.formState)),t=c0(e,1,!0,t,a??null,l,s,j,i,d,h,v0),t.context=u0(null),a=t.current,l=Et(),l=Ui(l),s=ja(l),s.callback=null,Na(a,s,l),a=l,t.current.lanes=a,Il(t,a),Vt(t),e[il]=t.current,Cc(e),new gi(t)},Xn.version="19.2.4",Xn}var R0;function eg(){if(R0)return Kc.exports;R0=1;function r(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(o){console.error(o)}}return r(),Kc.exports=Ih(),Kc.exports}var tg=eg();var z0="popstate";function ag(r={}){function o(u,f){let{pathname:x,search:g,hash:b}=u.location;return nu("",{pathname:x,search:g,hash:b},f.state&&f.state.usr||null,f.state&&f.state.key||"default")}function c(u,f){return typeof f=="string"?f:Jn(f)}return ng(o,c,null,r)}function Ue(r,o){if(r===!1||r===null||typeof r>"u")throw new Error(o)}function qt(r,o){if(!r){typeof console<"u"&&console.warn(o);try{throw new Error(o)}catch{}}}function lg(){return Math.random().toString(36).substring(2,10)}function _0(r,o){return{usr:r.state,key:r.key,idx:o}}function nu(r,o,c=null,u){return{pathname:typeof r=="string"?r:r.pathname,search:"",hash:"",...typeof o=="string"?Zl(o):o,state:c,key:o&&o.key||u||lg()}}function Jn({pathname:r="/",search:o="",hash:c=""}){return o&&o!=="?"&&(r+=o.charAt(0)==="?"?o:"?"+o),c&&c!=="#"&&(r+=c.charAt(0)==="#"?c:"#"+c),r}function Zl(r){let o={};if(r){let c=r.indexOf("#");c>=0&&(o.hash=r.substring(c),r=r.substring(0,c));let u=r.indexOf("?");u>=0&&(o.search=r.substring(u),r=r.substring(0,u)),r&&(o.pathname=r)}return o}function ng(r,o,c,u={}){let{window:f=document.defaultView,v5Compat:x=!1}=u,g=f.history,b="POP",p=null,m=v();m==null&&(m=0,g.replaceState({...g.state,idx:m},""));function v(){return(g.state||{idx:null}).idx}function y(){b="POP";let _=v(),G=_==null?null:_-m;m=_,p&&p({action:b,location:$.location,delta:G})}function N(_,G){b="PUSH";let A=nu($.location,_,G);m=v()+1;let V=_0(A,m),re=$.createHref(A);try{g.pushState(V,"",re)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;f.location.assign(re)}x&&p&&p({action:b,location:$.location,delta:1})}function R(_,G){b="REPLACE";let A=nu($.location,_,G);m=v();let V=_0(A,m),re=$.createHref(A);g.replaceState(V,"",re),x&&p&&p({action:b,location:$.location,delta:0})}function O(_){return sg(_)}let $={get action(){return b},get location(){return r(f,g)},listen(_){if(p)throw new Error("A history only accepts one active listener");return f.addEventListener(z0,y),p=_,()=>{f.removeEventListener(z0,y),p=null}},createHref(_){return o(f,_)},createURL:O,encodeLocation(_){let G=O(_);return{pathname:G.pathname,search:G.search,hash:G.hash}},push:N,replace:R,go(_){return g.go(_)}};return $}function sg(r,o=!1){let c="http://localhost";typeof window<"u"&&(c=window.location.origin!=="null"?window.location.origin:window.location.href),Ue(c,"No window.location.(origin|href) available to create URL");let u=typeof r=="string"?r:Jn(r);return u=u.replace(/ $/,"%20"),!o&&u.startsWith("//")&&(u=c+u),new URL(u,c)}function K0(r,o,c="/"){return ig(r,o,c,!1)}function ig(r,o,c,u){let f=typeof o=="string"?Zl(o):o,x=fa(f.pathname||"/",c);if(x==null)return null;let g=J0(r);rg(g);let b=null;for(let p=0;b==null&&p<g.length;++p){let m=pg(x);b=gg(g[p],m,u)}return b}function J0(r,o=[],c=[],u="",f=!1){let x=(g,b,p=f,m)=>{let v={relativePath:m===void 0?g.path||"":m,caseSensitive:g.caseSensitive===!0,childrenIndex:b,route:g};if(v.relativePath.startsWith("/")){if(!v.relativePath.startsWith(u)&&p)return;Ue(v.relativePath.startsWith(u),`Absolute route path "${v.relativePath}" nested under path "${u}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),v.relativePath=v.relativePath.slice(u.length)}let y=da([u,v.relativePath]),N=c.concat(v);g.children&&g.children.length>0&&(Ue(g.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),J0(g.children,o,N,y,p)),!(g.path==null&&!g.index)&&o.push({path:y,score:xg(y,g.index),routesMeta:N})};return r.forEach((g,b)=>{if(g.path===""||!g.path?.includes("?"))x(g,b);else for(let p of W0(g.path))x(g,b,!0,p)}),o}function W0(r){let o=r.split("/");if(o.length===0)return[];let[c,...u]=o,f=c.endsWith("?"),x=c.replace(/\?$/,"");if(u.length===0)return f?[x,""]:[x];let g=W0(u.join("/")),b=[];return b.push(...g.map(p=>p===""?x:[x,p].join("/"))),f&&b.push(...g),b.map(p=>r.startsWith("/")&&p===""?"/":p)}function rg(r){r.sort((o,c)=>o.score!==c.score?c.score-o.score:hg(o.routesMeta.map(u=>u.childrenIndex),c.routesMeta.map(u=>u.childrenIndex)))}var cg=/^:[\w-]+$/,ug=3,og=2,dg=1,fg=10,mg=-2,D0=r=>r==="*";function xg(r,o){let c=r.split("/"),u=c.length;return c.some(D0)&&(u+=mg),o&&(u+=og),c.filter(f=>!D0(f)).reduce((f,x)=>f+(cg.test(x)?ug:x===""?dg:fg),u)}function hg(r,o){return r.length===o.length&&r.slice(0,-1).every((u,f)=>u===o[f])?r[r.length-1]-o[o.length-1]:0}function gg(r,o,c=!1){let{routesMeta:u}=r,f={},x="/",g=[];for(let b=0;b<u.length;++b){let p=u[b],m=b===u.length-1,v=x==="/"?o:o.slice(x.length)||"/",y=Si({path:p.relativePath,caseSensitive:p.caseSensitive,end:m},v),N=p.route;if(!y&&m&&c&&!u[u.length-1].route.index&&(y=Si({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},v)),!y)return null;Object.assign(f,y.params),g.push({params:f,pathname:da([x,y.pathname]),pathnameBase:Ng(da([x,y.pathnameBase])),route:N}),y.pathnameBase!=="/"&&(x=da([x,y.pathnameBase]))}return g}function Si(r,o){typeof r=="string"&&(r={path:r,caseSensitive:!1,end:!0});let[c,u]=yg(r.path,r.caseSensitive,r.end),f=o.match(c);if(!f)return null;let x=f[0],g=x.replace(/(.)\/+$/,"$1"),b=f.slice(1);return{params:u.reduce((m,{paramName:v,isOptional:y},N)=>{if(v==="*"){let O=b[N]||"";g=x.slice(0,x.length-O.length).replace(/(.)\/+$/,"$1")}const R=b[N];return y&&!R?m[v]=void 0:m[v]=(R||"").replace(/%2F/g,"/"),m},{}),pathname:x,pathnameBase:g,pattern:r}}function yg(r,o=!1,c=!0){qt(r==="*"||!r.endsWith("*")||r.endsWith("/*"),`Route path "${r}" will be treated as if it were "${r.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${r.replace(/\*$/,"/*")}".`);let u=[],f="^"+r.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(g,b,p)=>(u.push({paramName:b,isOptional:p!=null}),p?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return r.endsWith("*")?(u.push({paramName:"*"}),f+=r==="*"||r==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):c?f+="\\/*$":r!==""&&r!=="/"&&(f+="(?:(?=\\/|$))"),[new RegExp(f,o?void 0:"i"),u]}function pg(r){try{return r.split("/").map(o=>decodeURIComponent(o).replace(/\//g,"%2F")).join("/")}catch(o){return qt(!1,`The URL path "${r}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${o}).`),r}}function fa(r,o){if(o==="/")return r;if(!r.toLowerCase().startsWith(o.toLowerCase()))return null;let c=o.endsWith("/")?o.length-1:o.length,u=r.charAt(c);return u&&u!=="/"?null:r.slice(c)||"/"}var vg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function bg(r,o="/"){let{pathname:c,search:u="",hash:f=""}=typeof r=="string"?Zl(r):r,x;return c?(c=c.replace(/\/\/+/g,"/"),c.startsWith("/")?x=O0(c.substring(1),"/"):x=O0(c,o)):x=o,{pathname:x,search:Sg(u),hash:Eg(f)}}function O0(r,o){let c=o.replace(/\/+$/,"").split("/");return r.split("/").forEach(f=>{f===".."?c.length>1&&c.pop():f!=="."&&c.push(f)}),c.length>1?c.join("/"):"/"}function Pc(r,o,c,u){return`Cannot include a '${r}' character in a manually specified \`to.${o}\` field [${JSON.stringify(u)}]. Please separate it out to the \`to.${c}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function jg(r){return r.filter((o,c)=>c===0||o.route.path&&o.route.path.length>0)}function F0(r){let o=jg(r);return o.map((c,u)=>u===o.length-1?c.pathname:c.pathnameBase)}function P0(r,o,c,u=!1){let f;typeof r=="string"?f=Zl(r):(f={...r},Ue(!f.pathname||!f.pathname.includes("?"),Pc("?","pathname","search",f)),Ue(!f.pathname||!f.pathname.includes("#"),Pc("#","pathname","hash",f)),Ue(!f.search||!f.search.includes("#"),Pc("#","search","hash",f)));let x=r===""||f.pathname==="",g=x?"/":f.pathname,b;if(g==null)b=c;else{let y=o.length-1;if(!u&&g.startsWith("..")){let N=g.split("/");for(;N[0]==="..";)N.shift(),y-=1;f.pathname=N.join("/")}b=y>=0?o[y]:"/"}let p=bg(f,b),m=g&&g!=="/"&&g.endsWith("/"),v=(x||g===".")&&c.endsWith("/");return!p.pathname.endsWith("/")&&(m||v)&&(p.pathname+="/"),p}var da=r=>r.join("/").replace(/\/\/+/g,"/"),Ng=r=>r.replace(/\/+$/,"").replace(/^\/*/,"/"),Sg=r=>!r||r==="?"?"":r.startsWith("?")?r:"?"+r,Eg=r=>!r||r==="#"?"":r.startsWith("#")?r:"#"+r,Tg=class{constructor(r,o,c,u=!1){this.status=r,this.statusText=o||"",this.internal=u,c instanceof Error?(this.data=c.toString(),this.error=c):this.data=c}};function Cg(r){return r!=null&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.internal=="boolean"&&"data"in r}function Ag(r){return r.map(o=>o.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var I0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function em(r,o){let c=r;if(typeof c!="string"||!vg.test(c))return{absoluteURL:void 0,isExternal:!1,to:c};let u=c,f=!1;if(I0)try{let x=new URL(window.location.href),g=c.startsWith("//")?new URL(x.protocol+c):new URL(c),b=fa(g.pathname,o);g.origin===x.origin&&b!=null?c=b+g.search+g.hash:f=!0}catch{qt(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:u,isExternal:f,to:c}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var tm=["POST","PUT","PATCH","DELETE"];new Set(tm);var wg=["GET",...tm];new Set(wg);var Kl=S.createContext(null);Kl.displayName="DataRouter";var Ei=S.createContext(null);Ei.displayName="DataRouterState";var Mg=S.createContext(!1),am=S.createContext({isTransitioning:!1});am.displayName="ViewTransition";var Rg=S.createContext(new Map);Rg.displayName="Fetchers";var zg=S.createContext(null);zg.displayName="Await";var Ut=S.createContext(null);Ut.displayName="Navigation";var Wn=S.createContext(null);Wn.displayName="Location";var Qt=S.createContext({outlet:null,matches:[],isDataRoute:!1});Qt.displayName="Route";var cu=S.createContext(null);cu.displayName="RouteError";var lm="REACT_ROUTER_ERROR",_g="REDIRECT",Dg="ROUTE_ERROR_RESPONSE";function Og(r){if(r.startsWith(`${lm}:${_g}:{`))try{let o=JSON.parse(r.slice(28));if(typeof o=="object"&&o&&typeof o.status=="number"&&typeof o.statusText=="string"&&typeof o.location=="string"&&typeof o.reloadDocument=="boolean"&&typeof o.replace=="boolean")return o}catch{}}function Ug(r){if(r.startsWith(`${lm}:${Dg}:{`))try{let o=JSON.parse(r.slice(40));if(typeof o=="object"&&o&&typeof o.status=="number"&&typeof o.statusText=="string")return new Tg(o.status,o.statusText,o.data)}catch{}}function Lg(r,{relative:o}={}){Ue(Fn(),"useHref() may be used only in the context of a <Router> component.");let{basename:c,navigator:u}=S.useContext(Ut),{hash:f,pathname:x,search:g}=Pn(r,{relative:o}),b=x;return c!=="/"&&(b=x==="/"?c:da([c,x])),u.createHref({pathname:b,search:g,hash:f})}function Fn(){return S.useContext(Wn)!=null}function Ya(){return Ue(Fn(),"useLocation() may be used only in the context of a <Router> component."),S.useContext(Wn).location}var nm="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function sm(r){S.useContext(Ut).static||S.useLayoutEffect(r)}function uu(){let{isDataRoute:r}=S.useContext(Qt);return r?Wg():Hg()}function Hg(){Ue(Fn(),"useNavigate() may be used only in the context of a <Router> component.");let r=S.useContext(Kl),{basename:o,navigator:c}=S.useContext(Ut),{matches:u}=S.useContext(Qt),{pathname:f}=Ya(),x=JSON.stringify(F0(u)),g=S.useRef(!1);return sm(()=>{g.current=!0}),S.useCallback((p,m={})=>{if(qt(g.current,nm),!g.current)return;if(typeof p=="number"){c.go(p);return}let v=P0(p,JSON.parse(x),f,m.relative==="path");r==null&&o!=="/"&&(v.pathname=v.pathname==="/"?o:da([o,v.pathname])),(m.replace?c.replace:c.push)(v,m.state,m)},[o,c,x,f,r])}S.createContext(null);function Bg(){let{matches:r}=S.useContext(Qt),o=r[r.length-1];return o?o.params:{}}function Pn(r,{relative:o}={}){let{matches:c}=S.useContext(Qt),{pathname:u}=Ya(),f=JSON.stringify(F0(c));return S.useMemo(()=>P0(r,JSON.parse(f),u,o==="path"),[r,f,u,o])}function qg(r,o){return im(r,o)}function im(r,o,c,u,f){Ue(Fn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:x}=S.useContext(Ut),{matches:g}=S.useContext(Qt),b=g[g.length-1],p=b?b.params:{},m=b?b.pathname:"/",v=b?b.pathnameBase:"/",y=b&&b.route;{let A=y&&y.path||"";cm(m,!y||A.endsWith("*")||A.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${m}" (under <Route path="${A}">) 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.
10
10
 
11
- Please change the parent <Route path="${A}"> to <Route path="${A==="/"?"*":`${A}/*`}">.`)}let N=Ya(),R;if(o){let A=typeof o=="string"?Zl(o):o;Ue(v==="/"||A.pathname?.startsWith(v),`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 "${v}" but pathname "${A.pathname}" was given in the \`location\` prop.`),R=A}else R=N;let O=R.pathname||"/",$=O;if(v!=="/"){let A=v.replace(/^\//,"").split("/");$="/"+O.replace(/^\//,"").split("/").slice(A.length).join("/")}let _=K0(r,{pathname:$});qt(y||_!=null,`No routes matched location "${R.pathname}${R.search}${R.hash}" `),qt(_==null||_[_.length-1].route.element!==void 0||_[_.length-1].route.Component!==void 0||_[_.length-1].route.lazy!==void 0,`Matched leaf route at location "${R.pathname}${R.search}${R.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 G=Qg(_&&_.map(A=>Object.assign({},A,{params:Object.assign({},p,A.params),pathname:da([v,x.encodeLocation?x.encodeLocation(A.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathname]),pathnameBase:A.pathnameBase==="/"?v:da([v,x.encodeLocation?x.encodeLocation(A.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathnameBase])})),g,c,u,f);return o&&G?S.createElement(Wn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...R},navigationType:"POP"}},G):G}function Yg(){let r=Jg(),o=Cg(r)?`${r.status} ${r.statusText}`:r instanceof Error?r.message:JSON.stringify(r),c=r instanceof Error?r.stack:null,u="rgba(200,200,200, 0.5)",f={padding:"0.5rem",backgroundColor:u},x={padding:"2px 4px",backgroundColor:u},g=null;return console.error("Error handled by React Router default ErrorBoundary:",r),g=S.createElement(S.Fragment,null,S.createElement("p",null,"💿 Hey developer 👋"),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:x},"ErrorBoundary")," or"," ",S.createElement("code",{style:x},"errorElement")," prop on your route.")),S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},o),c?S.createElement("pre",{style:f},c):null,g)}var Gg=S.createElement(Yg,null),rm=class extends S.Component{constructor(r){super(r),this.state={location:r.location,revalidation:r.revalidation,error:r.error}}static getDerivedStateFromError(r){return{error:r}}static getDerivedStateFromProps(r,o){return o.location!==r.location||o.revalidation!=="idle"&&r.revalidation==="idle"?{error:r.error,location:r.location,revalidation:r.revalidation}:{error:r.error!==void 0?r.error:o.error,location:o.location,revalidation:r.revalidation||o.revalidation}}componentDidCatch(r,o){this.props.onError?this.props.onError(r,o):console.error("React Router caught the following error during render",r)}render(){let r=this.state.error;if(this.context&&typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){const c=Ug(r.digest);c&&(r=c)}let o=r!==void 0?S.createElement(Qt.Provider,{value:this.props.routeContext},S.createElement(cu.Provider,{value:r,children:this.props.component})):this.props.children;return this.context?S.createElement($g,{error:r},o):o}};rm.contextType=Mg;var Ic=new WeakMap;function $g({children:r,error:o}){let{basename:c}=S.useContext(Ut);if(typeof o=="object"&&o&&"digest"in o&&typeof o.digest=="string"){let u=Og(o.digest);if(u){let f=Ic.get(o);if(f)throw f;let x=em(u.location,c);if(I0&&!Ic.get(o))if(x.isExternal||u.reloadDocument)window.location.href=x.absoluteURL||x.to;else{const g=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(x.to,{replace:u.replace}));throw Ic.set(o,g),g}return S.createElement("meta",{httpEquiv:"refresh",content:`0;url=${x.absoluteURL||x.to}`})}}return r}function Vg({routeContext:r,match:o,children:c}){let u=S.useContext(Kl);return u&&u.static&&u.staticContext&&(o.route.errorElement||o.route.ErrorBoundary)&&(u.staticContext._deepestRenderedBoundaryId=o.route.id),S.createElement(Qt.Provider,{value:r},c)}function Qg(r,o=[],c=null,u=null,f=null){if(r==null){if(!c)return null;if(c.errors)r=c.matches;else if(o.length===0&&!c.initialized&&c.matches.length>0)r=c.matches;else return null}let x=r,g=c?.errors;if(g!=null){let v=x.findIndex(y=>y.route.id&&g?.[y.route.id]!==void 0);Ue(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(g).join(",")}`),x=x.slice(0,Math.min(x.length,v+1))}let b=!1,p=-1;if(c)for(let v=0;v<x.length;v++){let y=x[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(p=v),y.route.id){let{loaderData:N,errors:R}=c,O=y.route.loader&&!N.hasOwnProperty(y.route.id)&&(!R||R[y.route.id]===void 0);if(y.route.lazy||O){b=!0,p>=0?x=x.slice(0,p+1):x=[x[0]];break}}}let m=c&&u?(v,y)=>{u(v,{location:c.location,params:c.matches?.[0]?.params??{},unstable_pattern:Ag(c.matches),errorInfo:y})}:void 0;return x.reduceRight((v,y,N)=>{let R,O=!1,$=null,_=null;c&&(R=g&&y.route.id?g[y.route.id]:void 0,$=y.route.errorElement||Gg,b&&(p<0&&N===0?(cm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),O=!0,_=null):p===N&&(O=!0,_=y.route.hydrateFallbackElement||null)));let G=o.concat(x.slice(0,N+1)),A=()=>{let V;return R?V=$:O?V=_:y.route.Component?V=S.createElement(y.route.Component,null):y.route.element?V=y.route.element:V=v,S.createElement(Vg,{match:y,routeContext:{outlet:v,matches:G,isDataRoute:c!=null},children:V})};return c&&(y.route.ErrorBoundary||y.route.errorElement||N===0)?S.createElement(rm,{location:c.location,revalidation:c.revalidation,component:$,error:R,children:A(),routeContext:{outlet:null,matches:G,isDataRoute:!0},onError:m}):A()},null)}function ou(r){return`${r} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Xg(r){let o=S.useContext(Kl);return Ue(o,ou(r)),o}function kg(r){let o=S.useContext(Ei);return Ue(o,ou(r)),o}function Zg(r){let o=S.useContext(Qt);return Ue(o,ou(r)),o}function du(r){let o=Zg(r),c=o.matches[o.matches.length-1];return Ue(c.route.id,`${r} can only be used on routes that contain a unique "id"`),c.route.id}function Kg(){return du("useRouteId")}function Jg(){let r=S.useContext(cu),o=kg("useRouteError"),c=du("useRouteError");return r!==void 0?r:o.errors?.[c]}function Wg(){let{router:r}=Xg("useNavigate"),o=du("useNavigate"),c=S.useRef(!1);return sm(()=>{c.current=!0}),S.useCallback(async(f,x={})=>{qt(c.current,nm),c.current&&(typeof f=="number"?await r.navigate(f):await r.navigate(f,{fromRouteId:o,...x}))},[r,o])}var U0={};function cm(r,o,c){!o&&!U0[r]&&(U0[r]=!0,qt(!1,c))}S.memo(Fg);function Fg({routes:r,future:o,state:c,onError:u}){return im(r,void 0,c,u,o)}function st(r){Ue(!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 Pg({basename:r="/",children:o=null,location:c,navigationType:u="POP",navigator:f,static:x=!1,unstable_useTransitions:g}){Ue(!Fn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let b=r.replace(/^\/*/,"/"),p=S.useMemo(()=>({basename:b,navigator:f,static:x,unstable_useTransitions:g,future:{}}),[b,f,x,g]);typeof c=="string"&&(c=Zl(c));let{pathname:m="/",search:v="",hash:y="",state:N=null,key:R="default"}=c,O=S.useMemo(()=>{let $=fa(m,b);return $==null?null:{location:{pathname:$,search:v,hash:y,state:N,key:R},navigationType:u}},[b,m,v,y,N,R,u]);return qt(O!=null,`<Router basename="${b}"> is not able to match the URL "${m}${v}${y}" because it does not start with the basename, so the <Router> won't render anything.`),O==null?null:S.createElement(Ut.Provider,{value:p},S.createElement(Wn.Provider,{children:o,value:O}))}function Ig({children:r,location:o}){return qg(su(r),o)}function su(r,o=[]){let c=[];return S.Children.forEach(r,(u,f)=>{if(!S.isValidElement(u))return;let x=[...o,f];if(u.type===S.Fragment){c.push.apply(c,su(u.props.children,x));return}Ue(u.type===st,`[${typeof u.type=="string"?u.type:u.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Ue(!u.props.index||!u.props.children,"An index route cannot have child routes.");let g={id:u.props.id||x.join("-"),caseSensitive:u.props.caseSensitive,element:u.props.element,Component:u.props.Component,index:u.props.index,path:u.props.path,middleware:u.props.middleware,loader:u.props.loader,action:u.props.action,hydrateFallbackElement:u.props.hydrateFallbackElement,HydrateFallback:u.props.HydrateFallback,errorElement:u.props.errorElement,ErrorBoundary:u.props.ErrorBoundary,hasErrorBoundary:u.props.hasErrorBoundary===!0||u.props.ErrorBoundary!=null||u.props.errorElement!=null,shouldRevalidate:u.props.shouldRevalidate,handle:u.props.handle,lazy:u.props.lazy};u.props.children&&(g.children=su(u.props.children,x)),c.push(g)}),c}var ji="get",Ni="application/x-www-form-urlencoded";function Ti(r){return typeof HTMLElement<"u"&&r instanceof HTMLElement}function ey(r){return Ti(r)&&r.tagName.toLowerCase()==="button"}function ty(r){return Ti(r)&&r.tagName.toLowerCase()==="form"}function ay(r){return Ti(r)&&r.tagName.toLowerCase()==="input"}function ly(r){return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}function ny(r,o){return r.button===0&&(!o||o==="_self")&&!ly(r)}function iu(r=""){return new URLSearchParams(typeof r=="string"||Array.isArray(r)||r instanceof URLSearchParams?r:Object.keys(r).reduce((o,c)=>{let u=r[c];return o.concat(Array.isArray(u)?u.map(f=>[c,f]):[[c,u]])},[]))}function sy(r,o){let c=iu(r);return o&&o.forEach((u,f)=>{c.has(f)||o.getAll(f).forEach(x=>{c.append(f,x)})}),c}var pi=null;function iy(){if(pi===null)try{new FormData(document.createElement("form"),0),pi=!1}catch{pi=!0}return pi}var ry=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function eu(r){return r!=null&&!ry.has(r)?(qt(!1,`"${r}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ni}"`),null):r}function cy(r,o){let c,u,f,x,g;if(ty(r)){let b=r.getAttribute("action");u=b?fa(b,o):null,c=r.getAttribute("method")||ji,f=eu(r.getAttribute("enctype"))||Ni,x=new FormData(r)}else if(ey(r)||ay(r)&&(r.type==="submit"||r.type==="image")){let b=r.form;if(b==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=r.getAttribute("formaction")||b.getAttribute("action");if(u=p?fa(p,o):null,c=r.getAttribute("formmethod")||b.getAttribute("method")||ji,f=eu(r.getAttribute("formenctype"))||eu(b.getAttribute("enctype"))||Ni,x=new FormData(b,r),!iy()){let{name:m,type:v,value:y}=r;if(v==="image"){let N=m?`${m}.`:"";x.append(`${N}x`,"0"),x.append(`${N}y`,"0")}else m&&x.append(m,y)}}else{if(Ti(r))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');c=ji,u=null,f=Ni,g=r}return x&&f==="text/plain"&&(g=x,x=void 0),{action:u,method:c.toLowerCase(),encType:f,formData:x,body:g}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function fu(r,o){if(r===!1||r===null||typeof r>"u")throw new Error(o)}function uy(r,o,c,u){let f=typeof r=="string"?new URL(r,typeof window>"u"?"server://singlefetch/":window.location.origin):r;return c?f.pathname.endsWith("/")?f.pathname=`${f.pathname}_.${u}`:f.pathname=`${f.pathname}.${u}`:f.pathname==="/"?f.pathname=`_root.${u}`:o&&fa(f.pathname,o)==="/"?f.pathname=`${o.replace(/\/$/,"")}/_root.${u}`:f.pathname=`${f.pathname.replace(/\/$/,"")}.${u}`,f}async function oy(r,o){if(r.id in o)return o[r.id];try{let c=await import(r.module);return o[r.id]=c,c}catch(c){return console.error(`Error loading route module \`${r.module}\`, reloading page...`),console.error(c),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function dy(r){return r==null?!1:r.href==null?r.rel==="preload"&&typeof r.imageSrcSet=="string"&&typeof r.imageSizes=="string":typeof r.rel=="string"&&typeof r.href=="string"}async function fy(r,o,c){let u=await Promise.all(r.map(async f=>{let x=o.routes[f.route.id];if(x){let g=await oy(x,c);return g.links?g.links():[]}return[]}));return gy(u.flat(1).filter(dy).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function L0(r,o,c,u,f,x){let g=(p,m)=>c[m]?p.route.id!==c[m].route.id:!0,b=(p,m)=>c[m].pathname!==p.pathname||c[m].route.path?.endsWith("*")&&c[m].params["*"]!==p.params["*"];return x==="assets"?o.filter((p,m)=>g(p,m)||b(p,m)):x==="data"?o.filter((p,m)=>{let v=u.routes[p.route.id];if(!v||!v.hasLoader)return!1;if(g(p,m)||b(p,m))return!0;if(p.route.shouldRevalidate){let y=p.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:c[0]?.params||{},nextUrl:new URL(r,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof y=="boolean")return y}return!0}):[]}function my(r,o,{includeHydrateFallback:c}={}){return xy(r.map(u=>{let f=o.routes[u.route.id];if(!f)return[];let x=[f.module];return f.clientActionModule&&(x=x.concat(f.clientActionModule)),f.clientLoaderModule&&(x=x.concat(f.clientLoaderModule)),c&&f.hydrateFallbackModule&&(x=x.concat(f.hydrateFallbackModule)),f.imports&&(x=x.concat(f.imports)),x}).flat(1))}function xy(r){return[...new Set(r)]}function hy(r){let o={},c=Object.keys(r).sort();for(let u of c)o[u]=r[u];return o}function gy(r,o){let c=new Set;return new Set(o),r.reduce((u,f)=>{let x=JSON.stringify(hy(f));return c.has(x)||(c.add(x),u.push({key:x,link:f})),u},[])}function um(){let r=S.useContext(Kl);return fu(r,"You must render this element inside a <DataRouterContext.Provider> element"),r}function yy(){let r=S.useContext(Ei);return fu(r,"You must render this element inside a <DataRouterStateContext.Provider> element"),r}var mu=S.createContext(void 0);mu.displayName="FrameworkContext";function om(){let r=S.useContext(mu);return fu(r,"You must render this element inside a <HydratedRouter> element"),r}function py(r,o){let c=S.useContext(mu),[u,f]=S.useState(!1),[x,g]=S.useState(!1),{onFocus:b,onBlur:p,onMouseEnter:m,onMouseLeave:v,onTouchStart:y}=o,N=S.useRef(null);S.useEffect(()=>{if(r==="render"&&g(!0),r==="viewport"){let $=G=>{G.forEach(A=>{g(A.isIntersecting)})},_=new IntersectionObserver($,{threshold:.5});return N.current&&_.observe(N.current),()=>{_.disconnect()}}},[r]),S.useEffect(()=>{if(u){let $=setTimeout(()=>{g(!0)},100);return()=>{clearTimeout($)}}},[u]);let R=()=>{f(!0)},O=()=>{f(!1),g(!1)};return c?r!=="intent"?[x,N,{}]:[x,N,{onFocus:kn(b,R),onBlur:kn(p,O),onMouseEnter:kn(m,R),onMouseLeave:kn(v,O),onTouchStart:kn(y,R)}]:[!1,N,{}]}function kn(r,o){return c=>{r&&r(c),c.defaultPrevented||o(c)}}function vy({page:r,...o}){let{router:c}=um(),u=S.useMemo(()=>K0(c.routes,r,c.basename),[c.routes,r,c.basename]);return u?S.createElement(jy,{page:r,matches:u,...o}):null}function by(r){let{manifest:o,routeModules:c}=om(),[u,f]=S.useState([]);return S.useEffect(()=>{let x=!1;return fy(r,o,c).then(g=>{x||f(g)}),()=>{x=!0}},[r,o,c]),u}function jy({page:r,matches:o,...c}){let u=Ya(),{future:f,manifest:x,routeModules:g}=om(),{basename:b}=um(),{loaderData:p,matches:m}=yy(),v=S.useMemo(()=>L0(r,o,m,x,u,"data"),[r,o,m,x,u]),y=S.useMemo(()=>L0(r,o,m,x,u,"assets"),[r,o,m,x,u]),N=S.useMemo(()=>{if(r===u.pathname+u.search+u.hash)return[];let $=new Set,_=!1;if(o.forEach(A=>{let V=x.routes[A.route.id];!V||!V.hasLoader||(!v.some(re=>re.route.id===A.route.id)&&A.route.id in p&&g[A.route.id]?.shouldRevalidate||V.hasClientLoader?_=!0:$.add(A.route.id))}),$.size===0)return[];let G=uy(r,b,f.unstable_trailingSlashAwareDataRequests,"data");return _&&$.size>0&&G.searchParams.set("_routes",o.filter(A=>$.has(A.route.id)).map(A=>A.route.id).join(",")),[G.pathname+G.search]},[b,f.unstable_trailingSlashAwareDataRequests,p,u,x,v,o,r,g]),R=S.useMemo(()=>my(y,x),[y,x]),O=by(y);return S.createElement(S.Fragment,null,N.map($=>S.createElement("link",{key:$,rel:"prefetch",as:"fetch",href:$,...c})),R.map($=>S.createElement("link",{key:$,rel:"modulepreload",href:$,...c})),O.map(({key:$,link:_})=>S.createElement("link",{key:$,nonce:c.nonce,..._,crossOrigin:_.crossOrigin??c.crossOrigin})))}function Ny(...r){return o=>{r.forEach(c=>{typeof c=="function"?c(o):c!=null&&(c.current=o)})}}var Sy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Sy&&(window.__reactRouterVersion="7.13.0")}catch{}function Ey({basename:r,children:o,unstable_useTransitions:c,window:u}){let f=S.useRef();f.current==null&&(f.current=ag({window:u,v5Compat:!0}));let x=f.current,[g,b]=S.useState({action:x.action,location:x.location}),p=S.useCallback(m=>{c===!1?b(m):S.startTransition(()=>b(m))},[c]);return S.useLayoutEffect(()=>x.listen(p),[x,p]),S.createElement(Pg,{basename:r,children:o,location:g.location,navigationType:g.action,navigator:x,unstable_useTransitions:c})}var dm=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,xt=S.forwardRef(function({onClick:o,discover:c="render",prefetch:u="none",relative:f,reloadDocument:x,replace:g,state:b,target:p,to:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:N,...R},O){let{basename:$,unstable_useTransitions:_}=S.useContext(Ut),G=typeof m=="string"&&dm.test(m),A=em(m,$);m=A.to;let V=Lg(m,{relative:f}),[re,P,J]=py(u,R),Q=Ay(m,{replace:g,state:b,target:p,preventScrollReset:v,relative:f,viewTransition:y,unstable_defaultShouldRevalidate:N,unstable_useTransitions:_});function Z(te){o&&o(te),te.defaultPrevented||Q(te)}let B=S.createElement("a",{...R,...J,href:A.absoluteURL||V,onClick:A.isExternal||x?o:Z,ref:Ny(O,P),target:p,"data-discover":!G&&c==="render"?"true":void 0});return re&&!G?S.createElement(S.Fragment,null,B,S.createElement(vy,{page:V})):B});xt.displayName="Link";var fm=S.forwardRef(function({"aria-current":o="page",caseSensitive:c=!1,className:u="",end:f=!1,style:x,to:g,viewTransition:b,children:p,...m},v){let y=Pn(g,{relative:m.relative}),N=Ya(),R=S.useContext(Ei),{navigator:O,basename:$}=S.useContext(Ut),_=R!=null&&_y(y)&&b===!0,G=O.encodeLocation?O.encodeLocation(y).pathname:y.pathname,A=N.pathname,V=R&&R.navigation&&R.navigation.location?R.navigation.location.pathname:null;c||(A=A.toLowerCase(),V=V?V.toLowerCase():null,G=G.toLowerCase()),V&&$&&(V=fa(V,$)||V);const re=G!=="/"&&G.endsWith("/")?G.length-1:G.length;let P=A===G||!f&&A.startsWith(G)&&A.charAt(re)==="/",J=V!=null&&(V===G||!f&&V.startsWith(G)&&V.charAt(G.length)==="/"),Q={isActive:P,isPending:J,isTransitioning:_},Z=P?o:void 0,B;typeof u=="function"?B=u(Q):B=[u,P?"active":null,J?"pending":null,_?"transitioning":null].filter(Boolean).join(" ");let te=typeof x=="function"?x(Q):x;return S.createElement(xt,{...m,"aria-current":Z,className:B,ref:v,style:te,to:g,viewTransition:b},typeof p=="function"?p(Q):p)});fm.displayName="NavLink";var Ty=S.forwardRef(({discover:r="render",fetcherKey:o,navigate:c,reloadDocument:u,replace:f,state:x,method:g=ji,action:b,onSubmit:p,relative:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:N,...R},O)=>{let{unstable_useTransitions:$}=S.useContext(Ut),_=Ry(),G=zy(b,{relative:m}),A=g.toLowerCase()==="get"?"get":"post",V=typeof b=="string"&&dm.test(b),re=P=>{if(p&&p(P),P.defaultPrevented)return;P.preventDefault();let J=P.nativeEvent.submitter,Q=J?.getAttribute("formmethod")||g,Z=()=>_(J||P.currentTarget,{fetcherKey:o,method:Q,navigate:c,replace:f,state:x,relative:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:N});$&&c!==!1?S.startTransition(()=>Z()):Z()};return S.createElement("form",{ref:O,method:A,action:G,onSubmit:u?p:re,...R,"data-discover":!V&&r==="render"?"true":void 0})});Ty.displayName="Form";function Cy(r){return`${r} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function mm(r){let o=S.useContext(Kl);return Ue(o,Cy(r)),o}function Ay(r,{target:o,replace:c,state:u,preventScrollReset:f,relative:x,viewTransition:g,unstable_defaultShouldRevalidate:b,unstable_useTransitions:p}={}){let m=uu(),v=Ya(),y=Pn(r,{relative:x});return S.useCallback(N=>{if(ny(N,o)){N.preventDefault();let R=c!==void 0?c:Jn(v)===Jn(y),O=()=>m(r,{replace:R,state:u,preventScrollReset:f,relative:x,viewTransition:g,unstable_defaultShouldRevalidate:b});p?S.startTransition(()=>O()):O()}},[v,m,y,c,u,o,r,f,x,g,b,p])}function xu(r){qt(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let o=S.useRef(iu(r)),c=S.useRef(!1),u=Ya(),f=S.useMemo(()=>sy(u.search,c.current?null:o.current),[u.search]),x=uu(),g=S.useCallback((b,p)=>{const m=iu(typeof b=="function"?b(new URLSearchParams(f)):b);c.current=!0,x("?"+m,p)},[x,f]);return[f,g]}var wy=0,My=()=>`__${String(++wy)}__`;function Ry(){let{router:r}=mm("useSubmit"),{basename:o}=S.useContext(Ut),c=Kg(),u=r.fetch,f=r.navigate;return S.useCallback(async(x,g={})=>{let{action:b,method:p,encType:m,formData:v,body:y}=cy(x,o);if(g.navigate===!1){let N=g.fetcherKey||My();await u(N,c,g.action||b,{unstable_defaultShouldRevalidate:g.unstable_defaultShouldRevalidate,preventScrollReset:g.preventScrollReset,formData:v,body:y,formMethod:g.method||p,formEncType:g.encType||m,flushSync:g.flushSync})}else await f(g.action||b,{unstable_defaultShouldRevalidate:g.unstable_defaultShouldRevalidate,preventScrollReset:g.preventScrollReset,formData:v,body:y,formMethod:g.method||p,formEncType:g.encType||m,replace:g.replace,state:g.state,fromRouteId:c,flushSync:g.flushSync,viewTransition:g.viewTransition})},[u,f,o,c])}function zy(r,{relative:o}={}){let{basename:c}=S.useContext(Ut),u=S.useContext(Qt);Ue(u,"useFormAction must be used inside a RouteContext");let[f]=u.matches.slice(-1),x={...Pn(r||".",{relative:o})},g=Ya();if(r==null){x.search=g.search;let b=new URLSearchParams(x.search),p=b.getAll("index");if(p.some(v=>v==="")){b.delete("index"),p.filter(y=>y).forEach(y=>b.append("index",y));let v=b.toString();x.search=v?`?${v}`:""}}return(!r||r===".")&&f.route.index&&(x.search=x.search?x.search.replace(/^\?/,"?index&"):"?index"),c!=="/"&&(x.pathname=x.pathname==="/"?c:da([c,x.pathname])),Jn(x)}function _y(r,{relative:o}={}){let c=S.useContext(am);Ue(c!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:u}=mm("useViewTransitionState"),f=Pn(r,{relative:o});if(!c.isTransitioning)return!1;let x=fa(c.currentLocation.pathname,u)||c.currentLocation.pathname,g=fa(c.nextLocation.pathname,u)||c.nextLocation.pathname;return Si(f.pathname,g)!=null||Si(f.pathname,x)!=null}const xm=S.createContext({projects:[],activeProject:null,setActiveProject:()=>{},refreshProjects:()=>{}});function Jl(){return S.useContext(xm)}function Dy(){const[r,o]=S.useState([]),[c,u]=xu(),f=S.useCallback(async()=>{try{const m=await(await fetch("/api/projects")).json();m.ok&&o(m.data||[])}catch{}},[]);S.useEffect(()=>{f()},[f]);const x=c.get("project"),g=x?r.find(p=>p.id===x)||r[0]||null:r[0]||null,b=S.useCallback(p=>{u(m=>(m.set("project",p),m))},[u]);return{projects:r,activeProject:g,setActiveProject:b,refreshProjects:f}}function hm(r,o){const{timeout:c=3e4,retries:u=1,retryDelay:f=2e3}={},[x,g]=S.useState(null),[b,p]=S.useState(!0),[m,v]=S.useState(null),[y,N]=S.useState(0),[R,O]=S.useState(null),$=S.useCallback(()=>N(_=>_+1),[]);return S.useEffect(()=>{if(!r){p(!1),g(null);return}let _=!1;p(!0),v(null);async function G(A){const V=new AbortController,re=setTimeout(()=>V.abort(),c);try{const P=await fetch(r,{signal:V.signal});if(clearTimeout(re),!P.ok)throw new Error(`HTTP ${P.status}`);const J=await P.json();_||(g(J.data??J),v(null),O(new Date),p(!1))}catch(P){if(clearTimeout(re),_)return;if(A>0&&P.name!=="AbortError")return await new Promise(J=>setTimeout(J,f)),_?void 0:G(A-1);P.name==="AbortError"?v(`Request timed out (${Math.round(c/1e3)}s)`):v(String(P.message||P)),p(!1)}}return G(u),()=>{_=!0}},[r,y,c,u,f]),{data:x,loading:b,error:m,refetch:$,fetchedAt:R}}function Me(r,o){const{activeProject:c}=Jl(),u=r.includes("?")?"&":"?",f=c?`${r}${u}project=${c.id}`:r;return hm(f)}const hu=S.createContext(null),Oy=["heartbeat","increment-update","analytics-event","cost-update","notification","sync-update","sync-audit","error-detected","config-changed","activity","command-output","command-complete","job-progress","marketplace-scan","submission-update","verification-complete"];function Uy({url:r="/api/events",children:o}){const[c,u]=S.useState("connecting"),f=S.useRef(null),x=S.useRef(null),g=S.useRef(new Map),b=S.useCallback(()=>{f.current&&f.current.close(),u("connecting");const m=new EventSource(r);f.current=m;for(const v of Oy)m.addEventListener(v,y=>{let N;try{N=JSON.parse(y.data)}catch{return}const R=g.current.get(v);if(R)for(const O of R)try{O(N)}catch{}});m.onopen=()=>u("connected"),m.onerror=()=>{m.close(),u("disconnected"),x.current=setTimeout(()=>{f.current===m&&b()},3e3)}},[r]);S.useEffect(()=>(b(),()=>{x.current&&(clearTimeout(x.current),x.current=null),f.current?.close(),f.current=null}),[b]);const p=S.useCallback((m,v)=>(g.current.has(m)||g.current.set(m,new Set),g.current.get(m).add(v),()=>{const y=g.current.get(m);y&&(y.delete(v),y.size===0&&g.current.delete(m))}),[]);return n.jsx(hu.Provider,{value:{status:c,subscribe:p},children:o})}function Ge(r,o){const c=S.useContext(hu),u=S.useRef(o);u.current=o,S.useEffect(()=>{if(!c)return;const f=x=>u.current(x);return c.subscribe(r,f)},[c,r])}function Ly(){return S.useContext(hu)?.status??"disconnected"}const Hy=[{path:"/",label:"Overview",icon:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1"},{path:"/increments",label:"Increments",icon:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"},{path:"/analytics",label:"Analytics",icon:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"},{path:"/costs",label:"Costs",icon:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},{path:"/sync",label:"Sync",icon:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},{path:"/errors",label:"Errors",icon:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"},{path:"/activity",label:"Activity",icon:"M13 10V3L4 14h7v7l9-11h-7z"},{path:"/notifications",label:"Notifications",icon:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9",badge:!0},{path:"/config",label:"Config",icon:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z"},{path:"/plugins",label:"Plugins",icon:"M17 14v6m-3-3h6M6 10h2a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2zm10 0h2a2 2 0 002-2V6a2 2 0 00-2-2h-2a2 2 0 00-2 2v2a2 2 0 002 2zM6 20h2a2 2 0 002-2v-2a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2z"},{path:"/marketplace",label:"Marketplace",icon:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 100 4 2 2 0 000-4z"},{path:"/repos",label:"Repos",icon:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"},{path:"/services",label:"Services",icon:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"}];function By({d:r}){return n.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:r})})}function qy(){const{projects:r,activeProject:o,setActiveProject:c}=Jl(),[u]=xu(),{data:f}=Me("/api/overview"),[x,g]=S.useState(null),b=S.useCallback(N=>{const R=N;R?.pendingCount!=null&&g(R.pendingCount)},[]);Ge("notification",b);const p=Ly(),m=x??f?.notifications?.pendingCount??0,v=u.get("project"),y=N=>v?`${N}?project=${v}`:N;return n.jsxs("aside",{className:"w-56 bg-gray-900 border-r border-gray-800 flex flex-col h-screen sticky top-0",children:[n.jsx("div",{className:"px-4 py-5 border-b border-gray-800",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-8 h-8 bg-indigo-500 rounded-lg flex items-center justify-center",children:n.jsx("span",{className:"text-white font-bold text-sm",children:"SW"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-semibold text-sm",children:"SpecWeave"}),n.jsx("div",{className:"text-gray-500 text-xs",children:"Dashboard"})]})]})}),(r.length>0||v)&&n.jsxs("div",{className:"px-3 py-3 border-b border-gray-800",children:[n.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider mb-1 block",children:"Project"}),n.jsxs("select",{value:o?.id||v||"",onChange:N=>{N.target.value==="__add__"?window.location.href=y("/config"):c(N.target.value)},className:"w-full bg-gray-800 border border-gray-700 text-gray-300 text-xs rounded-lg px-2 py-1.5 focus:ring-indigo-500 focus:border-indigo-500",children:[r.map(N=>n.jsx("option",{value:N.id,children:N.name},N.id)),v&&!r.find(N=>N.id===v)&&n.jsxs("option",{value:v,children:[decodeURIComponent(v).split(/[-/]/).pop()||v," (not registered)"]}),n.jsx("option",{value:"__add__",children:"+ Add project..."})]})]}),n.jsx("nav",{className:"flex-1 overflow-y-auto py-3 px-2",children:Hy.map(N=>n.jsxs(fm,{to:y(N.path),end:N.path==="/",className:({isActive:R})=>`flex items-center gap-3 px-3 py-2 rounded-lg text-sm mb-0.5 transition-colors ${R?"bg-indigo-500/10 text-indigo-400":"text-gray-400 hover:bg-gray-800 hover:text-gray-200"}`,children:[n.jsx(By,{d:N.icon}),n.jsx("span",{className:"flex-1",children:N.label}),N.badge&&m>0&&n.jsx("span",{className:"min-w-[18px] h-[18px] px-1 bg-rose-500 text-white text-[10px] font-bold rounded-full flex items-center justify-center",children:m>99?"99+":m})]},N.path))}),n.jsx("div",{className:"px-4 py-3 border-t border-gray-800",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${p==="connected"?"bg-emerald-400 pulse-dot":p==="connecting"?"bg-amber-400 pulse-dot":"bg-gray-500"}`}),n.jsx("span",{className:"text-xs text-gray-500",children:p==="connected"?"Connected":p==="connecting"?"Connecting...":"Disconnected"})]}),n.jsxs("span",{className:"text-[10px] text-gray-600",children:[r.length," project",r.length!==1?"s":""]})]})})]})}function Yy(){const{data:r}=hm("/api/health"),{activeProject:o}=Jl(),c=o?.name||"Project",u=r?.uptime?Gy(r.uptime):"...";return n.jsxs("header",{className:"h-14 bg-gray-900/50 backdrop-blur border-b border-gray-800 flex items-center justify-between px-6",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("h1",{className:"text-gray-200 font-medium text-sm",children:c}),n.jsx("span",{className:"text-gray-600 text-xs",children:"|"}),n.jsxs("span",{className:"text-gray-500 text-xs",children:["Uptime: ",u]})]}),n.jsx("div",{className:"flex items-center gap-4",children:n.jsxs("span",{className:"text-gray-500 text-xs",children:[r?.connections??0," client",(r?.connections??0)!==1?"s":""]})})]})}function Gy(r){if(r<60)return`${Math.floor(r)}s`;if(r<3600)return`${Math.floor(r/60)}m`;const o=Math.floor(r/3600),c=Math.floor(r%3600/60);return`${o}h ${c}m`}const $y={indigo:"from-indigo-500/10 to-indigo-500/5 border-indigo-500/20",emerald:"from-emerald-500/10 to-emerald-500/5 border-emerald-500/20",amber:"from-amber-500/10 to-amber-500/5 border-amber-500/20",rose:"from-rose-500/10 to-rose-500/5 border-rose-500/20",cyan:"from-cyan-500/10 to-cyan-500/5 border-cyan-500/20"},Vy={indigo:"text-indigo-400",emerald:"text-emerald-400",amber:"text-amber-400",rose:"text-rose-400",cyan:"text-cyan-400"};function ie({title:r,value:o,subtitle:c,tooltip:u,color:f="indigo"}){return n.jsxs("div",{className:`bg-gradient-to-br ${$y[f]} border rounded-xl p-4 relative group`,title:u,children:[n.jsx("div",{className:"text-gray-400 text-xs font-medium uppercase tracking-wider mb-2",children:r}),n.jsx("div",{className:`text-2xl font-bold ${Vy[f]}`,children:o}),c&&n.jsx("div",{className:"text-gray-500 text-xs mt-1",children:c}),u&&n.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2.5 py-1.5 bg-gray-800 border border-gray-700 rounded-lg text-[10px] text-gray-300 whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10 shadow-lg",children:[u,n.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 -mt-px border-4 border-transparent border-t-gray-800"})]})]})}const Qy={active:"#6366f1",completed:"#10b981",paused:"#f59e0b",planning:"#06b6d4",abandoned:"#ef4444",backlog:"#6b7280",ready_for_review:"#8b5cf6"};function Xy(r){return Qy[r]||"#6b7280"}function ky({segments:r,size:o=160,centerLabel:c,centerValue:u}){const f=r.reduce((p,m)=>p+m.value,0);if(f===0)return n.jsx("div",{className:"flex items-center justify-center",style:{width:o,height:o},children:n.jsx("span",{className:"text-gray-600 text-xs",children:"No data"})});const x=52,g=2*Math.PI*x;let b=0;return n.jsxs("div",{className:"relative inline-flex items-center justify-center",style:{width:o,height:o},children:[n.jsx("svg",{viewBox:"0 0 128 128",className:"w-full h-full -rotate-90",children:r.map((p,m)=>{const y=p.value/f*g,N=b;return b+=y,n.jsx("circle",{cx:"64",cy:"64",r:x,fill:"none",stroke:p.color,strokeWidth:"12",strokeDasharray:`${y} ${g-y}`,strokeDashoffset:-N,className:"transition-all duration-500"},m)})}),n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[u!=null&&n.jsx("span",{className:"text-xl font-bold text-white",children:u}),c&&n.jsx("span",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:c})]})]})}function Zy(r){return Object.entries(r).filter(([o,c])=>c>0).map(([o,c])=>({label:o,value:c,color:Xy(o)}))}const Ky={default:"bg-gray-800 text-gray-300",success:"bg-emerald-500/15 text-emerald-400",warning:"bg-amber-500/15 text-amber-400",error:"bg-rose-500/15 text-rose-400",info:"bg-cyan-500/15 text-cyan-400"};function fe({label:r,variant:o="default"}){return n.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium ${Ky[o]}`,children:r})}function Ci(r){switch(r){case"active":case"running":return"info";case"completed":case"success":return"success";case"paused":case"pending":case"planning":return"warning";case"failed":case"abandoned":case"error":return"error";default:return"default"}}function Jy({size:r="md"}){const o={sm:"w-4 h-4",md:"w-6 h-6",lg:"w-8 h-8"};return n.jsxs("svg",{className:`${o[r]} animate-spin text-indigo-400`,viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function at(){return n.jsx("div",{className:"flex items-center justify-center h-64",children:n.jsx(Jy,{size:"lg"})})}function Xt({message:r,onRetry:o,title:c="Something went wrong"}){const u=r.toLowerCase().includes("timed out");return n.jsx("div",{className:"p-6",children:n.jsxs("div",{className:"bg-rose-900/30 border border-rose-700 rounded-lg px-5 py-4 space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-medium text-rose-300",children:c}),n.jsx("p",{className:"text-xs text-rose-400/80 mt-1",children:r})]}),o&&n.jsx("button",{onClick:o,className:"text-xs text-rose-400 hover:text-rose-200 px-3 py-1.5 border border-rose-700 rounded transition-colors flex-shrink-0",children:"Retry"})]}),u&&n.jsx("p",{className:"text-[10px] text-rose-400/60",children:"The server may be processing a large number of session logs. Try again in a moment."})]})})}function H0(r){switch(r){case"connected":return"success";case"sync_failed":return"warning";case"configured_never_synced":return"info";default:return"default"}}function Wy(r){switch(r){case"connected":return"Connected";case"sync_failed":return"Sync Failed";case"configured_never_synced":return"Ready";case"not_configured":return"Not Configured";default:return r||"Unknown"}}const tu=r=>r.billingContext?.planType==="subscription";function Fy(){const[r,o]=S.useState(0),{data:c,loading:u,error:f,refetch:x}=Me(`/api/overview?_r=${r}`),[g,b]=S.useState([]),{activeProject:p}=Jl();Ge("increment-update",()=>o(N=>N+1)),Ge("notification",()=>o(N=>N+1)),Ge("sync-update",()=>o(N=>N+1)),Ge("cost-update",()=>o(N=>N+1));const m=S.useRef(null);S.useEffect(()=>{if(!p||m.current===p.id)return;m.current=p.id;const N=`project=${p.id}`;fetch(`/api/activity/stream?limit=20&${N}`).then(R=>R.json()).then(R=>{R.ok&&Array.isArray(R.data)&&b(R.data)}).catch(()=>{})},[p]);const v=S.useCallback(N=>{b(R=>[N,...R].slice(0,20))},[]);if(Ge("activity",v),u)return n.jsx(at,{});if(f)return n.jsx(Xt,{message:f,onRetry:x});if(!c)return null;const y=Zy(c.project.statusBreakdown);return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("h2",{className:"text-lg font-semibold text-gray-200",children:[c.project.name||"Project"," Overview"]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(xt,{to:"/increments?status=active",className:"group",children:n.jsx(ie,{title:"Active Increments",value:c.project.activeIncrements,subtitle:`${c.project.totalIncrements} total`,color:"indigo"})}),n.jsx(xt,{to:"/increments?status=completed",className:"group",children:n.jsx(ie,{title:"Completed",value:c.project.completedIncrements,subtitle:`${Math.round(c.project.completedIncrements/Math.max(c.project.totalIncrements,1)*100)}% done`,color:"emerald"})}),n.jsx(xt,{to:"/costs",className:"group",children:n.jsx(ie,{title:tu(c.costs)?"Usage Value":"Total Cost",value:`$${c.costs.totalCost.toFixed(2)}`,subtitle:tu(c.costs)?`$${c.costs.billingContext?.monthlyAmount??"?"}/mo plan`:`${c.costs.sessionCount.toLocaleString()} sessions`,color:"amber"})}),n.jsx(xt,{to:"/analytics",className:"group",children:n.jsx(ie,{title:"Events Today",value:c.analytics.last24hEvents,subtitle:`${c.analytics.totalEvents.toLocaleString()} total`,color:"cyan"})})]}),n.jsx(Py,{}),tu(c.costs)&&n.jsxs("div",{className:"bg-indigo-500/10 border border-indigo-500/20 rounded-xl px-4 py-3 flex items-center gap-3",children:[n.jsx(fe,{label:"Subscription",variant:"info"}),n.jsx("span",{className:"text-xs text-gray-300",children:"Costs shown as API-equivalent usage value."})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Increment Status"}),n.jsx("div",{className:"flex items-center justify-center",children:n.jsx(ky,{segments:y,centerValue:c.project.totalIncrements,centerLabel:"total"})}),n.jsx("div",{className:"flex flex-wrap gap-2 mt-4 justify-center",children:y.map(N=>n.jsxs(xt,{to:`/increments?status=${N.label.toLowerCase()}`,className:"flex items-center gap-1.5 hover:opacity-80 transition-opacity",children:[n.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:N.color}}),n.jsxs("span",{className:"text-xs text-gray-500 hover:text-gray-300",children:[N.label," (",N.value,")"]})]},N.label))})]}),n.jsxs(xt,{to:"/sync",className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5 hover:border-gray-700 transition-colors block",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Sync Health"}),n.jsx("div",{className:"space-y-3",children:Object.entries(c.sync.platforms).length===0?n.jsx("p",{className:"text-gray-600 text-xs",children:"No sync platforms configured"}):Object.entries(c.sync.platforms).map(([N,R])=>n.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-sm text-gray-300 capitalize",children:N}),R.configDetail&&n.jsx("div",{className:"text-[10px] text-gray-600 mt-0.5",children:R.configDetail}),!R.configDetail&&R.lastImport&&n.jsxs("div",{className:"text-xs text-gray-600 mt-0.5",children:["Last: ",new Date(R.lastImport).toLocaleDateString()]})]}),n.jsx(fe,{label:Wy(R.connectionStatus||R.lastSyncResult),variant:H0(R.connectionStatus)!=="default"?H0(R.connectionStatus):Ci(R.lastSyncResult||"")})]},N))}),n.jsx("div",{className:"mt-4 pt-4 border-t border-gray-800",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500",children:"Notifications"}),n.jsxs("div",{className:"flex gap-2",children:[c.notifications.criticalCount>0&&n.jsx(xt,{to:"/notifications",onClick:N=>N.stopPropagation(),children:n.jsx(fe,{label:`${c.notifications.criticalCount} critical`,variant:"error"})}),n.jsx(xt,{to:"/notifications",onClick:N=>N.stopPropagation(),children:n.jsx(fe,{label:`${c.notifications.pendingCount} pending`,variant:c.notifications.pendingCount>0?"warning":"default"})})]})]})})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Live Activity"}),n.jsx(xt,{to:"/activity",className:"text-[10px] text-indigo-400 hover:text-indigo-300",children:"View all"})]}),n.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto custom-scrollbar",children:g.length===0?n.jsx("p",{className:"text-gray-600 text-xs",children:"No recent activity"}):g.map((N,R)=>n.jsxs("div",{className:"flex items-start gap-2 py-1 slide-in",children:[n.jsx("div",{className:`w-1.5 h-1.5 rounded-full mt-1.5 ${N.severity==="error"?"bg-rose-400":N.severity==="warning"?"bg-amber-400":"bg-gray-600"}`}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-xs text-gray-400 truncate",children:N.title}),n.jsxs("div",{className:"text-[10px] text-gray-600",children:[N.category,N.timestamp&&` · ${Iy(N.timestamp)}`]})]})]},R))})]})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Increment Types"}),n.jsx("div",{className:"flex gap-4 flex-wrap",children:Object.entries(c.project.typeBreakdown).map(([N,R])=>n.jsxs(xt,{to:`/increments?type=${N}`,className:"flex items-center gap-2 px-3 py-2 bg-gray-800/50 rounded-lg hover:bg-gray-800/80 transition-colors",children:[n.jsx("span",{className:"text-sm text-gray-300 capitalize",children:N}),n.jsx("span",{className:"text-xs text-gray-500 bg-gray-800 px-2 py-0.5 rounded",children:R})]},N))})]})]})}function Py(){const[r,o]=S.useState(0);Ge("error-detected",()=>o(R=>R+1));const{data:c}=Me(`/api/prompt-health?_r=${r}`);if(!c?.health||c.health.warningLevel==="normal")return null;const{health:u,alert:f}=c,x=f?.level==="emergency",g=u.warningLevel==="critical"||x,b=g?"border-rose-500/30":"border-amber-500/20",p=g?"bg-rose-500/10":"bg-amber-500/10",m=g?"text-rose-400":"text-amber-400",v=Math.round(u.baseline/1e3),y=Math.min(Math.round(u.baseline/2e5*100),100),N=g?"bg-rose-500":"bg-amber-500";return n.jsxs("div",{className:`${p} border ${b} rounded-xl px-4 py-3 space-y-2`,children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(fe,{label:g?"Critical":"Warning",variant:g?"error":"warning"}),n.jsxs("span",{className:`text-xs ${m}`,children:["Prompt baseline: ",v,"KB (",y,"% of context window)"]})]}),n.jsx(xt,{to:"/errors",className:"text-[10px] text-gray-500 hover:text-gray-300",children:"Details"})]}),n.jsx("div",{className:"w-full bg-gray-800 rounded-full h-1.5",children:n.jsx("div",{className:`${N} h-1.5 rounded-full`,style:{width:`${y}%`}})}),n.jsxs("div",{className:"flex gap-4 text-[10px] text-gray-500",children:[n.jsxs("span",{children:["CLAUDE.md: ",Math.round(u.claudeMdSize/1e3),"KB"]}),n.jsxs("span",{children:["MEMORY.md: ",Math.round(u.memoryMdSize/1e3),"KB"]}),n.jsxs("span",{children:["Skills: ",Math.round(u.skillBudget/1e3),"KB"]}),f&&n.jsxs("span",{className:m,children:["Compactions: ",f.compactionCount]})]})]})}function Iy(r){try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return""}}const Zn=new Map;let au=!1,gm=null;function ep(){au||(au=!0,queueMicrotask(()=>{au=!1;const r=gm;if(!r||Zn.size===0){Zn.clear();return}const o=new Map(Zn);Zn.clear(),r(c=>{const u=new URLSearchParams(c);for(const[f,{value:x,defaultValue:g}]of o)x&&x!==g?u.set(f,x):u.delete(f);return u})}))}function qa(r,o=""){const[c,u]=xu(),f=c.get(r)??o,x=S.useCallback(g=>{gm=u,Zn.set(r,{value:g,defaultValue:o}),ep()},[r,o,u]);return[f,x]}function gu({title:r,description:o}){return n.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[n.jsx("div",{className:"w-12 h-12 rounded-full bg-gray-800 flex items-center justify-center mb-4",children:n.jsx("svg",{className:"w-6 h-6 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})})}),n.jsx("h3",{className:"text-gray-400 text-sm font-medium",children:r}),o&&n.jsx("p",{className:"text-gray-600 text-xs mt-1 max-w-xs",children:o})]})}function tp(){const[r,o]=S.useState(0);Ge("increment-update",()=>o(O=>O+1));const{data:c,loading:u,error:f,refetch:x}=Me(`/api/increments?_r=${r}`),[g,b]=qa("status","all"),[p,m]=qa("type","all"),v=uu();if(u)return n.jsx(at,{});if(f)return n.jsx(Xt,{message:f,onRetry:x});if(!c)return null;const y=c.increments.filter(O=>!(g!=="all"&&O.status!==g||p!=="all"&&O.type!==p)),N=[...new Set(c.increments.map(O=>O.status))],R=[...new Set(c.increments.map(O=>O.type))];return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Increments"}),n.jsxs("span",{className:"text-sm text-gray-500",children:[c.increments.length," total"]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"text-xs text-gray-500 w-14",children:"Status:"}),n.jsxs("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:[n.jsx(vi,{label:"All",active:g==="all",onClick:()=>b("all")}),N.map(O=>n.jsx(vi,{label:O,active:g===O,onClick:()=>b(O),count:c.increments.filter($=>$.status===O).length},O))]})]}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"text-xs text-gray-500 w-14",children:"Type:"}),n.jsxs("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:[n.jsx(vi,{label:"All",active:p==="all",onClick:()=>m("all")}),R.map(O=>n.jsx(vi,{label:O,active:p===O,onClick:()=>m(O),count:c.increments.filter($=>$.type===O).length},O))]})]}),n.jsxs("span",{className:"text-xs text-gray-500",children:[y.length," matching"]})]}),y.length===0?n.jsx(gu,{title:"No increments match filters",description:"Try adjusting your filters"}):n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"ID"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Title"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Status"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Type"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Priority"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Tasks"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"ACs"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Last Activity"})]})}),n.jsx("tbody",{children:y.map(O=>n.jsxs("tr",{onClick:()=>v(`/increments/${O.id}`),className:"border-b border-gray-800/50 hover:bg-gray-800/30 transition-colors cursor-pointer",children:[n.jsx("td",{className:"px-4 py-3",children:n.jsx("span",{className:"text-xs text-indigo-400 font-mono",children:O.id})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx("span",{className:"text-sm text-gray-300",children:O.title})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx(fe,{label:O.status,variant:Ci(O.status)})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx("span",{className:"text-xs text-gray-400 capitalize",children:O.type})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx(ap,{priority:O.priority})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx(B0,{completed:O.tasks.completed,total:O.tasks.total})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx(B0,{completed:O.acs.completed,total:O.acs.total})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx("span",{className:"text-xs text-gray-500",children:O.lastActivity?lp(O.lastActivity):"-"})})]},O.id))})]})})]})}function vi({label:r,active:o,onClick:c,count:u}){return n.jsxs("button",{onClick:c,className:`px-3 py-1 text-xs rounded-md transition-colors capitalize ${o?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:[r,u!==void 0&&n.jsx("span",{className:"ml-1 text-[10px] text-gray-500",children:u})]})}function B0({completed:r,total:o}){const c=o>0?Math.round(r/o*100):0;return n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-16 h-1.5 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${c}%`}})}),n.jsxs("span",{className:"text-xs text-gray-500",children:[r,"/",o]})]})}function ap({priority:r}){const o={P0:"text-rose-400 bg-rose-500/10",P1:"text-amber-400 bg-amber-500/10",P2:"text-cyan-400 bg-cyan-500/10",P3:"text-gray-400 bg-gray-500/10"};return n.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${o[r]||o.P2}`,children:r})}function lp(r){try{const o=new Date(r),u=new Date().getTime()-o.getTime(),f=Math.floor(u/6e4);if(f<1)return"Just now";if(f<60)return`${f}m ago`;const x=Math.floor(f/60);if(x<24)return`${x}h ago`;const g=Math.floor(x/24);return g<7?`${g}d ago`:o.toLocaleDateString()}catch{return r}}function np(){const[r,o]=S.useState("commands"),[c,u]=S.useState(!1),[f,x]=S.useState(0);Ge("analytics-event",()=>x(G=>G+1));const{data:g,loading:b,error:p,refetch:m,fetchedAt:v}=Me(`/api/analytics/summary?_r=${f}`),{data:y,loading:N,refetch:R}=Me(`/api/analytics/skills?_r=${f}`);if(b||N)return n.jsx(at,{});if(p)return n.jsx(Xt,{message:p,onRetry:m});if(!g)return null;const O=g.topCommands?.reduce((G,A)=>G+A.count,0)||0,$=g.topSkills?.reduce((G,A)=>G+A.count,0)||0,_=g.topAgents?.reduce((G,A)=>G+A.count,0)||0;return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Analytics"}),n.jsxs("div",{className:"flex items-center gap-3",children:[v&&n.jsxs("span",{className:"text-[10px] text-gray-600",children:["Updated ",v.toLocaleTimeString()]}),n.jsxs("span",{className:"text-sm text-gray-500",children:[g.totalEvents.toLocaleString()," total events"]}),n.jsx("button",{onClick:()=>{u(!0),m(),R(),setTimeout(()=>u(!1),600)},disabled:c,className:"p-1.5 text-gray-500 hover:text-gray-300 hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50",title:"Refresh analytics",children:n.jsx("svg",{className:`w-4 h-4 ${c?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Total Events",value:g.totalEvents.toLocaleString(),subtitle:`${g.successRate}% success rate`,color:"indigo",tooltip:`${g.totalEvents} events tracked from analytics JSONL`}),n.jsx(ie,{title:"Commands",value:O.toLocaleString(),subtitle:`${g.topCommands?.length||0} unique`,color:"cyan",tooltip:`${O} total command invocations across ${g.topCommands?.length||0} distinct commands`}),n.jsx(ie,{title:"Skills",value:$.toLocaleString(),subtitle:`${g.topSkills?.length||0} unique`,color:"emerald",tooltip:`${$} total skill activations across ${g.topSkills?.length||0} distinct skills`}),n.jsx(ie,{title:"Agents",value:_.toLocaleString(),subtitle:`${g.topAgents?.length||0} unique`,color:"amber",tooltip:`${_} agent spawns across ${g.topAgents?.length||0} distinct agent types`})]}),n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:[{key:"commands",label:"Commands"},{key:"skills",label:"Skills"},{key:"agents",label:"Agents"},{key:"daily",label:"Daily Trends"}].map(G=>n.jsx("button",{onClick:()=>o(G.key),className:`flex-1 px-3 py-1.5 text-xs rounded-md transition-colors ${r===G.key?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:G.label},G.key))}),r==="commands"&&n.jsx(sp,{commands:g.topCommands||[]}),r==="skills"&&n.jsx(ip,{skills:y||[]}),r==="agents"&&n.jsx(rp,{agents:g.topAgents||[]}),r==="daily"&&n.jsx(cp,{days:g.dailySummaries||[]})]})}function sp({commands:r}){if(r.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No command data available"})});const o=[...r].sort((u,f)=>f.count-u.count),c=o[0]?.count||1;return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Top Commands"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500 w-12",children:"Rank"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Command"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Usage"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Count"})]})}),n.jsx("tbody",{children:o.map((u,f)=>{const x=Math.max(2,u.count/c*100);return n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsxs("td",{className:"px-4 py-2.5 text-xs text-gray-600",children:["#",f+1]}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-sm text-gray-300 font-mono",children:u.name})}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("div",{className:"w-full h-1.5 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-indigo-500/60 transition-all",style:{width:`${x}%`}})})}),n.jsx("td",{className:"px-4 py-2.5 text-sm font-mono text-gray-400 text-right",children:u.count.toLocaleString()})]},u.name)})})]})]})}function ip({skills:r}){const o=[...r].sort((c,u)=>u.count-c.count);return o.length===0?n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No skill usage data available"})}):n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Skill Usage Leaderboard"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500 w-12",children:"Rank"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Skill Name"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Plugin"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Invocations"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Success Rate"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Last Used"})]})}),n.jsx("tbody",{children:o.map((c,u)=>{const f=c.count>0?Math.round(c.successCount/c.count*100):100,x=f>=90?"success":f>=70?"warning":"error";return n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsxs("td",{className:"px-4 py-2.5 text-xs text-gray-600",children:["#",u+1]}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-sm text-gray-300 font-mono",children:c.name})}),n.jsx("td",{className:"px-4 py-2.5",children:c.plugin&&n.jsx("span",{className:"text-[10px] text-gray-600 bg-gray-800 px-1.5 py-0.5 rounded",children:c.plugin})}),n.jsx("td",{className:"px-4 py-2.5 text-sm font-mono text-gray-400 text-right",children:c.count.toLocaleString()}),n.jsx("td",{className:"px-4 py-2.5 text-right",children:n.jsx(fe,{label:`${f}%`,variant:x})}),n.jsx("td",{className:"px-4 py-2.5 text-xs text-gray-600 text-right whitespace-nowrap",children:c.lastUsed?up(c.lastUsed):"-"})]},c.name)})})]})]})}function rp({agents:r}){if(r.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No agent data available"})});const o=[...r].sort((u,f)=>f.count-u.count),c=o[0]?.count||1;return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Top Agents"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500 w-12",children:"Rank"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Agent"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Usage"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Count"})]})}),n.jsx("tbody",{children:o.map((u,f)=>{const x=Math.max(2,u.count/c*100);return n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsxs("td",{className:"px-4 py-2.5 text-xs text-gray-600",children:["#",f+1]}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-sm text-gray-300",children:u.name})}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("div",{className:"w-full h-1.5 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-cyan-500/60 transition-all",style:{width:`${x}%`}})})}),n.jsx("td",{className:"px-4 py-2.5 text-sm font-mono text-gray-400 text-right",children:u.count.toLocaleString()})]},u.name)})})]})]})}function cp({days:r}){const o=r.slice(-14);if(o.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No daily data available"})});const c=Math.max(...o.map(x=>x.totalEvents),1),u=o.reduce((x,g)=>x+g.totalEvents,0),f=Math.round(u/o.length);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[n.jsx(ie,{title:"Period Total",value:u.toLocaleString(),subtitle:`Last ${o.length} days`,color:"indigo"}),n.jsx(ie,{title:"Daily Average",value:f.toLocaleString(),color:"cyan"}),n.jsx(ie,{title:"Peak Day",value:c.toLocaleString(),subtitle:o.find(x=>x.totalEvents===c)?.date||"",color:"emerald"})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:["Daily Events (Last ",o.length," Days)"]}),n.jsx("div",{className:"flex items-end gap-1.5 h-40",children:o.map(x=>{const g=Math.max(2,x.totalEvents/c*100),b=x.date.slice(5);return n.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1",children:[n.jsx("span",{className:"text-[9px] text-gray-500",children:x.totalEvents}),n.jsx("div",{className:"w-full bg-indigo-500/40 rounded-t hover:bg-indigo-500/60 transition-colors cursor-default",style:{height:`${g}%`},title:`${x.date}: ${x.totalEvents} events`}),n.jsx("span",{className:"text-[8px] text-gray-700",children:b})]},x.date)})})]})]})}function up(r){if(!r)return"";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return""}}function ym({items:r,maxBars:o=10}){const c=[...r].sort((f,x)=>x.value-f.value).slice(0,o),u=Math.max(...c.map(f=>f.value),1);return n.jsx("div",{className:"space-y-2",children:c.map((f,x)=>n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:"text-xs text-gray-400 w-28 truncate text-right",title:f.label,children:f.label}),n.jsx("div",{className:"flex-1 h-5 bg-gray-800 rounded overflow-hidden",children:n.jsx("div",{className:"h-full rounded transition-all duration-500",style:{width:`${f.value/u*100}%`,backgroundColor:f.color||"#6366f1"}})}),n.jsx("span",{className:"text-xs text-gray-500 w-10 text-right",children:f.value})]},x))})}function op(){const[r,o]=S.useState("overview"),[c,u]=S.useState(null),[f,x]=S.useState(0);Ge("cost-update",()=>x(A=>A+1));const{data:g,loading:b,error:p,refetch:m}=Me(`/api/costs/summary?_r=${f}`);if(b)return n.jsx(at,{});if(p)return n.jsx(Xt,{message:p,onRetry:m});if(!g)return null;const v=g.sessions||[],y=g.billingContext?.planType==="subscription",N=g.modelBreakdown?Object.entries(g.modelBreakdown).map(([A,V])=>({model:A,...V})).sort((A,V)=>V.cost-A.cost):fp(v),R=v.reduce((A,V)=>A+(V.inputTokens||0),0),O=v.reduce((A,V)=>A+(V.outputTokens||0),0),$=v.reduce((A,V)=>A+(V.cacheReadTokens||0),0),_=v.reduce((A,V)=>A+(V.cacheWriteTokens||0),0),G=R+O+$+_;return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Token Usage & Costs"}),y&&n.jsxs("div",{className:"bg-indigo-500/10 border border-indigo-500/20 rounded-xl px-4 py-3 flex items-center gap-3",children:[n.jsx(fe,{label:"Subscription",variant:"info"}),n.jsxs("span",{className:"text-xs text-gray-300",children:[g.billingContext?.monthlyAmount?`$${g.billingContext.monthlyAmount}/mo plan. `:"","Costs shown as API-equivalent value for usage analytics."]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:y?"API-Equivalent Value":"Total Cost",value:`$${g.totalCost.toFixed(2)}`,subtitle:y&&g.billingContext?.monthlyAmount?`Your plan: $${g.billingContext.monthlyAmount}/mo`:void 0,color:"amber"}),n.jsx(ie,{title:y?"Cache Efficiency":"Cache Savings",value:`$${g.totalSavings.toFixed(2)}`,subtitle:y?"API-equivalent savings from cache":void 0,color:"emerald"}),n.jsx(ie,{title:"Total Tokens",value:Xl(g.totalTokens),subtitle:mp(g.totalTokens),color:"indigo"}),n.jsx(ie,{title:"Sessions",value:g.sessionCount.toLocaleString(),color:"cyan"})]}),n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:["overview","sessions"].map(A=>n.jsx("button",{onClick:()=>o(A),className:`flex-1 px-3 py-1.5 text-xs rounded-md transition-colors ${r===A?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:A==="overview"?"Breakdown":`Sessions (${v.length})`},A))}),r==="overview"&&n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:y?"Usage Value by Model":"Cost by Model"}),N.length>0?n.jsx(ym,{items:N.map(A=>({label:A.model,value:parseFloat(A.cost.toFixed(2)),color:"#f59e0b"}))}):n.jsx("p",{className:"text-gray-600 text-xs",children:"No model data"})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Token Breakdown"}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(bi,{label:"Input",value:R,total:G,color:"bg-indigo-500"}),n.jsx(bi,{label:"Output",value:O,total:G,color:"bg-cyan-500"}),$>0&&n.jsx(bi,{label:"Cache Read",value:$,total:G,color:"bg-emerald-500"}),_>0&&n.jsx(bi,{label:"Cache Write",value:_,total:G,color:"bg-amber-500"})]})]}),N.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden lg:col-span-2",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Model Details"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Model"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Sessions"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Tokens"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Cost"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Avg/Session"})]})}),n.jsx("tbody",{children:N.map(A=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsx("td",{className:"px-4 py-2 text-sm text-gray-300",children:A.model}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:A.sessions.toLocaleString()}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:Xl(A.tokens)}),n.jsxs("td",{className:"px-4 py-2 text-xs text-amber-400 text-right",children:["$",A.cost.toFixed(2)]}),n.jsxs("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:["$",A.sessions>0?(A.cost/A.sessions).toFixed(4):"0"]})]},A.model))})]})]})]}),r==="sessions"&&n.jsx(dp,{sessions:v,expandedSession:c,onToggle:A=>u(c===A?null:A)})]})}const lu=30;function dp({sessions:r,expandedSession:o,onToggle:c}){const[u,f]=S.useState(0);if(r.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No session data available"})});const x=Math.ceil(r.length/lu),g=u*lu,b=g+lu,p=r.slice(g,b);return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsxs("div",{className:"px-5 py-3 border-b border-gray-800 flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Recent Sessions"}),n.jsxs("span",{className:"text-xs text-gray-500",children:[g+1,"-",Math.min(b,r.length)," of ",r.length]})]}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500 w-8"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Session"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Model"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Input"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Output"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Cache"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Cost"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Duration"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"When"})]})}),n.jsx("tbody",{children:p.map(m=>{const v=m.sessionId||"-",y=o===v,N=(m.cacheReadTokens||0)+(m.cacheWriteTokens||0);return n.jsxs(S.Fragment,{children:[n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30 cursor-pointer",onClick:()=>c(v),children:[n.jsx("td",{className:"px-4 py-2 text-xs text-gray-600",children:n.jsx("span",{className:`inline-block transition-transform ${y?"rotate-90":""}`,children:"▸"})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400 font-mono",children:v.slice(0,8)}),n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:m.model||"unknown",variant:"default"})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:Xl(m.inputTokens)}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:Xl(m.outputTokens)}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:N>0?Xl(N):"-"}),n.jsxs("td",{className:"px-4 py-2 text-xs text-amber-400 text-right",children:["$",m.cost?.toFixed(4)||"0.0000"]}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:m.duration?q0(m.duration):"-"}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500",children:xp(m.timestamp)})]}),y&&n.jsx("tr",{className:"border-b border-gray-800/50",children:n.jsx("td",{colSpan:9,className:"px-6 py-3 bg-gray-800/20",children:n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-xs",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Input Tokens"}),n.jsx("span",{className:"text-gray-300 font-mono",children:m.inputTokens.toLocaleString()})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Output Tokens"}),n.jsx("span",{className:"text-gray-300 font-mono",children:m.outputTokens.toLocaleString()})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Cache Write"}),n.jsx("span",{className:"text-gray-300 font-mono",children:(m.cacheWriteTokens||0).toLocaleString()})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Cache Read"}),n.jsx("span",{className:"text-gray-300 font-mono",children:(m.cacheReadTokens||0).toLocaleString()})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Cost"}),n.jsxs("span",{className:"text-amber-400 font-mono",children:["$",m.cost?.toFixed(6)||"0"]})]}),m.savings!=null&&m.savings>0&&n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Cache Savings"}),n.jsxs("span",{className:"text-emerald-400 font-mono",children:["$",m.savings.toFixed(6)]})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Duration"}),n.jsx("span",{className:"text-gray-300",children:m.duration?q0(m.duration):"-"})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Session ID"}),n.jsx("span",{className:"text-gray-400 font-mono text-[10px]",children:m.sessionId})]})]})})})]},v)})})]}),x>1&&n.jsxs("div",{className:"px-5 py-3 border-t border-gray-800 flex items-center justify-between",children:[n.jsx("button",{onClick:()=>f(m=>Math.max(0,m-1)),disabled:u===0,className:"px-3 py-1 text-xs text-gray-400 hover:text-gray-200 border border-gray-700 rounded disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Previous"}),n.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(x,7)},(m,v)=>{let y;return x<=7||u<3?y=v:u>x-4?y=x-7+v:y=u-3+v,n.jsx("button",{onClick:()=>f(y),className:`w-7 h-7 text-xs rounded transition-colors ${u===y?"bg-indigo-600 text-white":"text-gray-500 hover:text-gray-300 hover:bg-gray-800"}`,children:y+1},y)})}),n.jsx("button",{onClick:()=>f(m=>Math.min(x-1,m+1)),disabled:u>=x-1,className:"px-3 py-1 text-xs text-gray-400 hover:text-gray-200 border border-gray-700 rounded disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Next"})]})]})}function bi({label:r,value:o,total:c,color:u}){const f=c>0?o/c*100:0,x={"bg-indigo-500":"rgb(99 102 241 / 0.6)","bg-cyan-500":"rgb(6 182 212 / 0.6)","bg-emerald-500":"rgb(16 185 129 / 0.6)","bg-amber-500":"rgb(245 158 11 / 0.6)"};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-1",children:[n.jsx("span",{className:"text-xs text-gray-400",children:r}),n.jsxs("span",{className:"text-xs text-gray-500",children:[Xl(o)," (",f.toFixed(1),"%)"]})]}),n.jsx("div",{className:"h-2 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${f}%`,backgroundColor:x[u]||u}})})]})}function fp(r){const o=new Map;for(const c of r){const u=c.model||"unknown",f=o.get(u)||{cost:0,tokens:0,sessions:0};f.cost+=c.cost||0,f.tokens+=(c.inputTokens||0)+(c.outputTokens||0),f.sessions++,o.set(u,f)}return Array.from(o.entries()).map(([c,u])=>({model:c,...u})).sort((c,u)=>u.cost-c.cost)}function Xl(r){return r?r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:String(r):"0"}function mp(r){return r?r.toLocaleString():"0"}function q0(r){const o=Math.round(r);if(o<60)return`${o}s`;const c=Math.floor(o/60),u=o%60;return c<60?`${c}m ${u}s`:`${Math.floor(c/60)}h ${c%60}m`}function xp(r){if(!r)return"-";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return"-"}}function Ai(){const[r,o]=S.useState(!1),[c,u]=S.useState(null),[f,x]=S.useState(null),[g,b]=S.useState([]),[p,m]=S.useState("idle"),v=S.useRef(null),y=S.useRef(null);Ge("command-output",O=>{const $=O;y.current&&$.executionId===y.current&&$.line&&b(_=>[..._,$.line])}),Ge("command-complete",O=>{const $=O;if(y.current&&$.executionId===y.current){if(v.current&&(clearTimeout(v.current),v.current=null),o(!1),$.exitCode===0)m("success"),b(_=>[..._,"Command completed successfully."]);else{m("error");const _=`Command failed (exit code ${$.exitCode??"unknown"})`;x(_),b(G=>[...G,_])}y.current=null}}),S.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const N=S.useCallback(async O=>{o(!0),x(null),b([`> specweave ${O}`]),m("running");try{const _=await(await fetch(`/api/commands/${O}`,{method:"POST"})).json();return _.ok?(u(_.data),y.current=_.data?.id||null,v.current=setTimeout(()=>{y.current&&(y.current=null,o(!1),m("error"),x("Command timed out after 60 seconds"),b(G=>[...G,"Timed out after 60 seconds."]))},6e4),_.data):(x(_.error||"Command failed"),m("error"),b(G=>[...G,`Error: ${_.error||"Command failed"}`]),o(!1),null)}catch($){return x(String($)),m("error"),b(_=>[..._,`Error: ${String($)}`]),o(!1),null}},[]),R=S.useCallback(()=>{o(!1),u(null),x(null),b([]),m("idle"),y.current=null,v.current&&(clearTimeout(v.current),v.current=null)},[]);return{execute:N,running:r,result:c,error:f,output:g,status:p,reset:R}}function hp(r){switch(r){case"connected":return"success";case"sync_failed":return"warning";case"configured_never_synced":return"info";default:return"default"}}function gp(r){switch(r){case"connected":return"Connected";case"sync_failed":return"Sync Failed";case"configured_never_synced":return"Ready";case"not_configured":return"Not Configured";default:return r||"Unknown"}}function yp(){const[r,o]=S.useState("health"),[c,u]=S.useState(null),[f,x]=S.useState(0);Ge("sync-update",()=>x(J=>J+1));const{data:g,loading:b,error:p,refetch:m}=Me(`/api/sync/status?_r=${f}`),{data:v,loading:y}=Me(`/api/sync/audit?limit=100&_r=${f}`),{data:N,loading:R}=Me(`/api/sync/audit/summary?_r=${f}`),{execute:O,running:$}=Ai(),_=async J=>{u(J);try{const Q=new URLSearchParams(window.location.search).get("project")||"",Z=Q?`?platform=${J}&project=${Q}`:`?platform=${J}`;await fetch(`/api/sync/verify${Z}`,{method:"POST"}),m()}catch{}u(null)};if(b||y||R)return n.jsx(at,{});if(p)return n.jsx(Xt,{message:p,onRetry:m});if(!g)return null;const G=Object.entries(g.platforms).filter(([J])=>["github","jira","ado"].includes(J)),A=v?.length||0,V=v?.filter(J=>J.result==="error").length||0,re=v?.filter(J=>J.conflict)||[],P=G.filter(([,J])=>J.connectionStatus==="connected").length;return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Sync Health"}),n.jsx("button",{onClick:()=>O("sync-push"),disabled:$,className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:$?"Syncing...":"Sync Now"})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Platforms",value:G.length,subtitle:`${P} connected`,color:"indigo"}),n.jsx(ie,{title:"Audit Entries",value:A,color:"cyan"}),n.jsx(ie,{title:"Errors",value:V,color:"rose"}),n.jsx(ie,{title:"Conflicts",value:re.length,color:"amber"})]}),n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:["health","audit","conflicts"].map(J=>n.jsx("button",{onClick:()=>o(J),className:`flex-1 px-3 py-1.5 text-xs rounded-md transition-colors ${r===J?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:J==="health"?"Platform Health":J==="audit"?"Audit Log":`Conflicts (${re.length})`},J))}),r==="health"&&n.jsx(n.Fragment,{children:G.length===0?n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No sync platforms configured"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"Configure GitHub, JIRA, or ADO in your config"})]}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:G.map(([J,Q])=>{const Z=N?.[J],B=Q.connectionStatus||"unknown";return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(pm,{platform:J}),n.jsxs("div",{children:[n.jsx("span",{className:"text-sm font-medium text-gray-300 capitalize",children:J}),Q.configDetail&&n.jsx("div",{className:"text-[10px] text-gray-600 mt-0.5",children:Q.configDetail})]})]}),n.jsx(fe,{label:gp(B),variant:hp(B)})]}),Q.diagnosticMessage&&n.jsx("div",{className:"text-xs text-gray-500 mb-3 p-2 bg-gray-800/30 rounded-lg",children:Q.diagnosticMessage}),B==="not_configured"&&n.jsx(xt,{to:"/config",className:"block text-center text-xs text-indigo-400 hover:text-indigo-300 py-2 border border-gray-800 rounded-lg hover:border-indigo-500/30 transition-colors",children:"Configure in Settings"}),B==="configured_never_synced"&&n.jsx("button",{onClick:()=>_(J),disabled:c===J,className:"w-full text-xs text-indigo-400 hover:text-indigo-300 py-2 border border-gray-800 rounded-lg hover:border-indigo-500/30 transition-colors disabled:opacity-50",children:c===J?"Verifying...":"Verify Connection"}),B==="sync_failed"&&n.jsx("button",{onClick:()=>_(J),disabled:c===J,className:"w-full text-xs text-amber-400 hover:text-amber-300 py-2 border border-amber-500/20 rounded-lg hover:border-amber-500/40 transition-colors disabled:opacity-50",children:c===J?"Verifying...":"Retry Sync"}),n.jsxs("div",{className:"space-y-2 mt-3",children:[Q.lastImport&&n.jsx(Ql,{label:"Last Import",value:new Date(Q.lastImport).toLocaleString()}),B==="connected"&&!Q.lastImport&&n.jsx(Ql,{label:"Status",value:"Connected, no imports yet"}),Q.lastImportCount!=null&&n.jsx(Ql,{label:"Items Imported",value:Q.lastImportCount.toLocaleString()}),Q.lastSkippedCount!=null&&Q.lastSkippedCount>0&&n.jsx(Ql,{label:"Skipped",value:Q.lastSkippedCount.toLocaleString()}),Z&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-gray-800 my-2"}),n.jsx(Ql,{label:"Total Ops",value:Z.total.toLocaleString()}),n.jsx(Ql,{label:"Success",value:Z.success.toLocaleString()}),Z.errors>0&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500",children:"Errors"}),n.jsx(fe,{label:String(Z.errors),variant:"error"})]})]})]})]},J)})})}),r==="audit"&&n.jsx(Y0,{entries:v||[]}),r==="conflicts"&&n.jsx(Y0,{entries:re}),g.lastUpdated&&n.jsxs("p",{className:"text-xs text-gray-600",children:["Last metadata update: ",new Date(g.lastUpdated).toLocaleString()]})]})}function Y0({entries:r}){if(r.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No audit entries"})});const o={success:"success",error:"error",denied:"warning",skipped:"default"};return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Time"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Platform"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Operation"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Item"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Direction"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Result"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Duration"})]})}),n.jsx("tbody",{children:r.map((c,u)=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500",children:pp(c.timestamp)}),n.jsx("td",{className:"px-4 py-2",children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(pm,{platform:c.platform}),n.jsx("span",{className:"text-xs text-gray-400 capitalize",children:c.platform})]})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400",children:c.operation}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 font-mono max-w-[120px] truncate",children:c.itemId||"-"}),n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:c.direction,variant:c.direction==="push"?"info":"default"})}),n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:c.result,variant:o[c.result]||"default"})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-600 text-right",children:c.duration?`${c.duration}ms`:"-"})]},u))})]})})}function Ql({label:r,value:o}){return n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500",children:r}),n.jsx("span",{className:"text-xs text-gray-400",children:o})]})}function pm({platform:r}){const o={github:"bg-gray-700",jira:"bg-blue-700",ado:"bg-blue-600"};return n.jsx("div",{className:`w-5 h-5 rounded ${o[r]||"bg-gray-700"} flex items-center justify-center`,children:n.jsx("span",{className:"text-[9px] text-white font-bold",children:r[0]?.toUpperCase()})})}function pp(r){if(!r)return"-";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return"-"}}const vm={prompt_too_long:"error",api_error:"warning",tool_failure:"info",hook_error:"default",rate_limit:"warning",unknown:"default"},Kn=50;function vp(){const[r,o]=qa("tab","groups"),[c,u]=qa("type",""),[f,x]=qa("q",""),[g,b]=qa("session",""),[p,m]=S.useState(0),[v,y]=S.useState(f),N=p*Kn,R=c?`&type=${encodeURIComponent(c)}`:"",O=f?`&search=${encodeURIComponent(f)}`:"",[$,_]=S.useState(0);Ge("error-detected",()=>_(I=>I+1));const{data:G,loading:A,error:V}=Me(r==="groups"?`/api/errors/groups?_r=${$}`:""),{data:re,loading:P,error:J}=Me(r==="errors"||r==="groups"?`/api/errors/recent?limit=${Kn}&offset=${N}${R}${O}&_r=${$}`:""),{data:Q,loading:Z,error:B}=Me(r==="sessions"||g?`/api/errors/sessions?limit=50&_r=${$}`:""),{data:te,loading:le,error:Oe}=Me(r==="timeline"?`/api/errors/timeline?bucket=60&_r=${$}`:""),lt=S.useCallback(()=>{x(v.trim()),m(0),v.trim()&&o("errors")},[v,x,o]);S.useEffect(()=>{g&&Q&&!Q.find(I=>I.sessionId===g)&&b("")},[g,Q,b]);const Re=r==="groups"&&A||r==="errors"&&P||r==="timeline"&&le||r==="sessions"&&Z,$e=V||J||B||Oe,U=re?.total||0,k=re?.errors||[],ne=G?.length||0,X=G?.reduce((I,Ze)=>I+Ze.sessions,0)||0,me=G?.[0]?.type||"-",T=g?Q?.find(I=>I.sessionId===g):null,Y=c?(Q||[]).filter(I=>I.errors.some(Ze=>Ze.type===c)):Q||[],K=Math.ceil(U/Kn),F=I=>{u(I),o("errors"),b(""),m(0)},ce=I=>{o(I),b(""),I!=="errors"&&m(0)},xe=()=>{u(""),x(""),y(""),m(0)};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Error Tracing"}),n.jsx("span",{className:"text-xs text-gray-500",children:"Observability for Claude Code sessions"})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("input",{type:"text",value:v,onChange:I=>y(I.target.value),onKeyDown:I=>I.key==="Enter"&&lt(),placeholder:"Search errors by message, tool name, or context...",className:"w-full px-3 py-2 text-sm bg-gray-900/50 border border-gray-700 rounded-lg text-gray-300 placeholder-gray-600 focus:outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/30"}),f&&n.jsx("button",{onClick:()=>{x(""),y(""),m(0)},className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300 text-xs",children:"clear"})]}),n.jsx("button",{onClick:lt,className:"px-4 py-2 text-sm bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg transition-colors",children:"Search"})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Total Errors",value:U,color:"rose"}),n.jsx(ie,{title:"Error Types",value:ne,color:"amber"}),n.jsx(ie,{title:"Affected Sessions",value:X,color:"indigo"}),n.jsx(ie,{title:"Most Common",value:me,color:"cyan"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:["groups","errors","timeline","sessions"].map(I=>n.jsx("button",{onClick:()=>ce(I),className:`flex-1 px-3 py-1.5 text-xs rounded-md transition-colors ${r===I?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:I==="groups"?"Error Groups":I==="errors"?"All Errors":I==="timeline"?"Timeline":"Sessions"},I))}),(c||f)&&n.jsxs("div",{className:"flex items-center gap-2",children:[c&&n.jsx(fe,{label:`type: ${c.replace(/_/g," ")}`,variant:"info"}),f&&n.jsx(fe,{label:`search: ${f.slice(0,20)}`,variant:"default"}),n.jsx("button",{onClick:xe,className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"clear all"})]})]}),$e&&n.jsxs("div",{className:"bg-rose-900/30 border border-rose-700 rounded-lg px-4 py-3 flex items-center justify-between",children:[n.jsx("div",{className:"text-sm text-rose-300",children:$e}),n.jsx("button",{onClick:()=>window.location.reload(),className:"text-xs text-rose-400 hover:text-rose-200 px-2 py-1 border border-rose-700 rounded transition-colors",children:"Retry"})]}),g&&T&&n.jsx(Ep,{session:T,onClose:()=>b("")}),Re&&!g&&n.jsx(at,{}),!g&&!Re&&r==="groups"&&n.jsx(bp,{groups:G||[],onGroupClick:F}),!g&&!Re&&r==="errors"&&n.jsx(jp,{errors:k,total:U,page:p,totalPages:K,onPageChange:m,onSessionClick:I=>{b(I),o("sessions")}}),!g&&!Re&&r==="timeline"&&n.jsx(Np,{buckets:te||[],errors:k,onSessionClick:I=>b(I)}),!g&&!Re&&r==="sessions"&&n.jsx(Sp,{sessions:Y,onSelect:I=>b(I)}),!Re&&!$e&&U===0&&!g&&n.jsx(gu,{title:"No errors detected",description:"Claude Code session logs are clean"})]})}function bp({groups:r,onGroupClick:o}){return r.length===0?null:n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Error Groups"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Type"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Count"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Sessions"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Last Seen"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Sample Message"})]})}),n.jsx("tbody",{children:r.map(c=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:c.type.replace(/_/g," "),variant:vm[c.type]||"default"})}),n.jsx("td",{className:"px-4 py-2 text-right",children:n.jsx("button",{onClick:()=>o(c.type),className:"text-sm text-indigo-400 hover:text-indigo-300 font-mono transition-colors",title:`View all ${c.count} errors of this type`,children:c.count})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:c.sessions}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-300 font-mono",title:kl(c.lastSeen),children:In(c.lastSeen)}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 max-w-xs truncate",children:c.recentMessages[0]||"-"})]},c.type))})]})]})}function jp({errors:r,total:o,page:c,totalPages:u,onPageChange:f,onSessionClick:x}){const[g,b]=S.useState(new Set),p=S.useCallback(y=>{b(N=>{const R=new Set(N);return R.has(y)?R.delete(y):R.add(y),R})},[]);if(r.length===0)return n.jsx(gu,{title:"No errors",description:"No errors match the current filter"});const m=c*Kn+1,v=Math.min(c*Kn+r.length,o);return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsxs("div",{className:"px-5 py-3 border-b border-gray-800 flex items-center justify-between",children:[n.jsxs("h3",{className:"text-sm font-medium text-gray-300",children:["Errors ",m,"–",v," of ",o]}),u>1&&n.jsx(G0,{page:c,totalPages:u,onChange:f})]}),n.jsx("div",{className:"divide-y divide-gray-800/50",children:r.map((y,N)=>{const R=g.has(N),O=y.message.length>120;return n.jsx("div",{className:"px-4 py-3 hover:bg-gray-800/20 transition-colors",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex-shrink-0 mt-0.5",children:n.jsx(fe,{label:y.type.replace(/_/g," "),variant:vm[y.type]||"default"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:`text-xs text-gray-300 ${R?"whitespace-pre-wrap break-words":"truncate"} ${O?"cursor-pointer":""}`,onClick:()=>O&&p(N),title:O?R?"Click to collapse":"Click to expand details":void 0,children:[O&&n.jsx("span",{className:"text-indigo-400 mr-1 text-[10px] inline-block w-3",children:R?"▼":"▶"}),R?y.message:y.message.slice(0,200),!R&&O&&n.jsx("span",{className:"text-indigo-400 ml-1",children:"...more"})]}),y.context?.toolName&&n.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[n.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 bg-gray-800 border border-gray-700 rounded text-amber-400",children:y.context.toolName}),y.context.toolInput&&n.jsx("span",{className:"text-[10px] text-gray-500 font-mono truncate max-w-md",children:y.context.toolInput})]}),R&&n.jsx(bm,{context:y.context})]}),n.jsxs("div",{className:"flex-shrink-0 text-right",children:[n.jsx("div",{className:"text-[10px] text-gray-300 font-mono",title:kl(y.timestamp),children:In(y.timestamp)}),n.jsx("div",{className:"text-[10px] text-gray-600",children:kl(y.timestamp)}),n.jsx("button",{onClick:()=>x(y.sessionId),className:"text-[10px] text-indigo-400 hover:text-indigo-300 font-mono mt-0.5 transition-colors",title:"View full session",children:y.sessionId.slice(0,8)}),y.context?.messageIndex!=null&&n.jsxs("div",{className:"text-[10px] text-gray-600",children:["msg #",y.context.messageIndex]})]})]})},`${y.sessionId}-${y.timestamp}-${N}`)})}),u>1&&n.jsx("div",{className:"px-5 py-3 border-t border-gray-800 flex justify-end",children:n.jsx(G0,{page:c,totalPages:u,onChange:f})})]})}function bm({context:r}){if(!r)return null;const{precedingAction:o,recentTools:c}=r;return!o&&(!c||c.length===0)?null:n.jsxs("div",{className:"mt-2 p-2 bg-gray-900/60 border border-gray-800 rounded-lg space-y-1.5",children:[o&&n.jsxs("div",{children:[n.jsx("span",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"What preceded this error:"}),n.jsx("div",{className:"text-[11px] text-gray-400 font-mono mt-0.5",children:o})]}),c&&c.length>0&&n.jsxs("div",{children:[n.jsx("span",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Recent tool chain:"}),n.jsx("div",{className:"flex flex-col gap-0.5 mt-0.5",children:c.map((u,f)=>n.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[n.jsxs("span",{className:"text-gray-600",children:[c.length-f,"."]}),n.jsx("span",{className:"font-mono text-amber-400/80",children:u.name}),u.input&&n.jsx("span",{className:"text-gray-600 font-mono truncate max-w-sm",children:u.input})]},f))})]})]})}function G0({page:r,totalPages:o,onChange:c}){return n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{onClick:()=>c(Math.max(0,r-1)),disabled:r===0,className:"px-2 py-1 text-xs rounded transition-colors disabled:text-gray-700 text-gray-400 hover:text-white hover:bg-gray-700",children:"Prev"}),n.jsxs("span",{className:"text-[10px] text-gray-500 px-2",children:[r+1," / ",o]}),n.jsx("button",{onClick:()=>c(Math.min(o-1,r+1)),disabled:r>=o-1,className:"px-2 py-1 text-xs rounded transition-colors disabled:text-gray-700 text-gray-400 hover:text-white hover:bg-gray-700",children:"Next"})]})}function Np({buckets:r,errors:o,onSessionClick:c}){const[u,f]=S.useState(null),x=Math.max(...r.map(m=>m.count),1),g={tool_failure:"bg-blue-500",prompt_too_long:"bg-rose-500",api_error:"bg-amber-500",hook_error:"bg-gray-500",rate_limit:"bg-amber-400",unknown:"bg-gray-600"},b=u?o.filter(m=>{const v=new Date(m.timestamp).getTime();return v>=new Date(u.start).getTime()&&v<new Date(u.end).getTime()}):o,p=m=>{try{return new Date(m).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return m}};return n.jsxs("div",{className:"space-y-4",children:[r.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Error Density (per hour)"}),u&&n.jsx("button",{onClick:()=>f(null),className:"text-[10px] text-indigo-400 hover:text-indigo-300",children:"Clear filter"})]}),n.jsx("div",{className:"flex items-end gap-px h-24",children:r.map((m,v)=>{const y=m.count/x*100,N=u?.start===m.start;return n.jsx("div",{className:"flex-1 flex flex-col items-center justify-end cursor-pointer group relative",onClick:()=>f(N?null:m),title:`${p(m.start)}: ${m.count} errors`,children:n.jsx("div",{className:`w-full min-h-[2px] rounded-t transition-all ${N?"bg-indigo-400":"bg-rose-500/70 group-hover:bg-rose-400"}`,style:{height:`${Math.max(y,2)}%`}})},v)})}),n.jsxs("div",{className:"flex justify-between mt-1",children:[n.jsx("span",{className:"text-[9px] text-gray-600",children:r.length>0?p(r[0].start):""}),n.jsx("span",{className:"text-[9px] text-gray-600",children:r.length>0?p(r[r.length-1].start):""})]}),n.jsx("div",{className:"flex gap-3 mt-2",children:Object.entries(g).map(([m,v])=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${v}`}),n.jsx("span",{className:"text-[9px] text-gray-600",children:m.replace(/_/g," ")})]},m))})]}),u&&n.jsxs("div",{className:"text-xs text-gray-400 px-1",children:["Showing ",b.length," errors from ",p(u.start)]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:u?"Filtered Errors":"Recent Errors"}),n.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto custom-scrollbar",children:[b.length===0&&n.jsx("p",{className:"text-xs text-gray-600",children:"No errors in this time range"}),b.slice(0,100).map((m,v)=>n.jsxs("div",{className:"flex items-start gap-3 py-2 px-2 hover:bg-gray-800/30 rounded cursor-pointer",onClick:()=>c(m.sessionId),children:[n.jsx("div",{className:`w-2 h-2 rounded-full mt-1.5 flex-shrink-0 ${g[m.type]||"bg-gray-500"}`}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-xs text-gray-400 font-mono",children:m.type.replace(/_/g," ")}),m.context?.toolName&&n.jsx("span",{className:"text-[10px] font-mono px-1 py-0.5 bg-gray-800 border border-gray-700 rounded text-amber-400",children:m.context.toolName}),n.jsx("span",{className:"text-[10px] text-gray-300 font-mono",children:In(m.timestamp)}),n.jsx("span",{className:"text-[10px] text-gray-600",children:kl(m.timestamp)})]}),n.jsx("div",{className:"text-xs text-gray-500 truncate mt-0.5",children:m.message}),m.context?.precedingAction&&n.jsxs("div",{className:"text-[10px] text-gray-600 mt-0.5 truncate",children:["After: ",m.context.precedingAction]})]})]},v))]})]})]})}function Sp({sessions:r,onSelect:o}){return r.length===0?null:n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Recent Sessions"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Session"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Branch"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Messages"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Tool Calls"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Errors"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Started"})]})}),n.jsx("tbody",{children:r.map(c=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30 cursor-pointer",onClick:()=>o(c.sessionId),children:[n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400 font-mono",children:c.sessionId.slice(0,8)}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500",children:c.gitBranch||"-"}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:c.messageCount}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:c.toolCallCount}),n.jsx("td",{className:"px-4 py-2 text-right",children:c.errors.length>0?n.jsx(fe,{label:String(c.errors.length),variant:"error"}):n.jsx("span",{className:"text-xs text-gray-600",children:"0"})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-300 font-mono",title:kl(c.startTime),children:In(c.startTime)})]},c.sessionId))})]})]})}function Ep({session:r,onClose:o}){const[c,u]=S.useState(new Set),f=x=>{u(g=>{const b=new Set(g);return b.has(x)?b.delete(x):b.add(x),b})};return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{children:[n.jsxs("h3",{className:"text-sm font-medium text-gray-300",children:["Session: ",n.jsx("span",{className:"font-mono",children:r.sessionId.slice(0,12)})]}),n.jsxs("div",{className:"text-[10px] text-gray-600 mt-0.5",children:["v",r.version," | ",r.gitBranch," | ",r.messageCount," messages | ",r.toolCallCount," tool calls"]})]}),n.jsx("button",{onClick:o,className:"px-2 py-1 text-xs text-gray-400 hover:text-white hover:bg-gray-700 rounded transition-colors",children:"Back"})]}),n.jsxs("div",{className:"flex gap-3 mb-4",children:[n.jsxs("div",{className:"text-xs text-gray-500",children:["Started: ",new Date(r.startTime).toLocaleString()]}),r.endTime&&n.jsxs("div",{className:"text-xs text-gray-500",children:["Ended: ",new Date(r.endTime).toLocaleString()]})]}),r.errors.length===0?n.jsx("p",{className:"text-gray-600 text-xs",children:"No errors in this session"}):n.jsx("div",{className:"space-y-2",children:r.errors.map((x,g)=>{const b=c.has(g),p=x.message.length>150;return n.jsxs("div",{className:"p-3 bg-gray-800/50 rounded-lg border-l-2 border-rose-500/50",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(fe,{label:x.type.replace(/_/g," "),variant:"error"}),x.context?.toolName&&n.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 bg-gray-800 border border-gray-700 rounded text-amber-400",children:x.context.toolName}),n.jsx("span",{className:"text-[10px] text-gray-300 font-mono",children:In(x.timestamp)}),n.jsx("span",{className:"text-[10px] text-gray-600",children:kl(x.timestamp)})]}),n.jsxs("div",{className:`text-xs text-gray-400 ${b?"whitespace-pre-wrap break-words":""} ${p?"cursor-pointer":""}`,onClick:()=>p&&f(g),title:p?b?"Click to collapse":"Click to expand":void 0,children:[p&&n.jsx("span",{className:"text-indigo-400 mr-1 text-[10px] inline-block w-3",children:b?"▼":"▶"}),b?x.message:x.message.slice(0,300),!b&&p&&n.jsx("span",{className:"text-indigo-400 ml-1",children:"...more"})]}),x.context?.toolInput&&n.jsx("div",{className:"text-[10px] text-gray-500 font-mono mt-1.5 bg-gray-900/50 px-2 py-1 rounded",children:x.context.toolInput}),x.context?.messageIndex!=null&&n.jsxs("div",{className:"text-[10px] text-gray-600 mt-1",children:["At message #",x.context.messageIndex]}),b&&n.jsx(bm,{context:x.context})]},g)})})]})}function kl(r){if(!r)return"-";const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}function In(r){if(!r)return"-";try{return new Date(r).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return r}}const Tp=[{value:"all",label:"All"},{value:"command",label:"Commands"},{value:"hook",label:"Hooks"},{value:"notification",label:"Notifications"},{value:"cost",label:"Cost"}],Cp=[{value:"all",label:"All Levels"},{value:"error",label:"Errors"},{value:"warning",label:"Warnings"},{value:"info",label:"Info"}];function Ap(){const[r,o]=qa("category","all"),[c,u]=qa("severity","all"),f=r||"all",x=c||"all",[g,b]=S.useState([]),[p,m]=S.useState(200),[v,y]=S.useState(null),N=new URLSearchParams;N.set("limit",String(p)),f!=="all"&&N.set("categories",f),x!=="all"&&N.set("severity",x);const{data:R,loading:O}=Me(`/api/activity/stream?${N.toString()}`),$=S.useCallback(B=>{b(te=>[B,...te].slice(0,50))},[]);if(Ge("activity",$),O)return n.jsx(at,{});const _=[...g,...R||[]],G=new Set,A=[];for(const B of _){const te=`${B.timestamp}:${B.title}`;G.has(te)||(G.add(te),A.push(B))}const V=A.filter(B=>!(f!=="all"&&B.category!==f||x!=="all"&&B.severity!==x)),re=A.filter(B=>B.severity==="error").length,P=A.filter(B=>B.severity==="warning").length,J=new Set(A.map(B=>B.source)),Q=B=>{y(te=>te===B?null:B)},Z=()=>{m(B=>B+200)};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Activity Stream"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 pulse-dot"}),n.jsx("span",{className:"text-xs text-gray-500",children:"Live"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Total Events",value:A.length,color:"indigo"}),n.jsx(ie,{title:"Errors",value:re,color:"rose"}),n.jsx(ie,{title:"Warnings",value:P,color:"amber"}),n.jsx(ie,{title:"Sources",value:J.size,color:"cyan"})]}),n.jsxs("div",{className:"flex flex-wrap gap-4",children:[n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:Tp.map(B=>n.jsx("button",{onClick:()=>o(B.value),className:`px-3 py-1 text-xs rounded-md transition-colors ${f===B.value?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:B.label},B.value))}),n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:Cp.map(B=>n.jsx("button",{onClick:()=>u(B.value),className:`px-3 py-1 text-xs rounded-md transition-colors ${x===B.value?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:B.label},B.value))}),n.jsxs("span",{className:"text-xs text-gray-500 self-center",children:[V.length," events"]})]}),n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl divide-y divide-gray-800/50",children:V.length===0?n.jsxs("div",{className:"p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No events match filters"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"Try adjusting category or severity filters"})]}):n.jsxs(n.Fragment,{children:[V.slice(0,p).map((B,te)=>{const le=`${B.timestamp}-${te}`,Oe=v===le;return n.jsx(wp,{event:B,isExpanded:Oe,onToggle:()=>Q(le)},le)}),V.length>=p&&n.jsx("div",{className:"p-4 text-center",children:n.jsx("button",{onClick:Z,className:"px-4 py-2 text-xs text-indigo-400 hover:text-indigo-300 border border-indigo-500/30 rounded-lg transition-colors",children:"Load more events"})})]})})]})}function wp({event:r,isExpanded:o,onToggle:c}){const u=r.severity==="error"?"bg-rose-400":r.severity==="warning"?"bg-amber-400":"bg-gray-600",f={command:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z",hook:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101",notification:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9",cost:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1",sync:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581"},x=r.detail||r.metadata&&Object.keys(r.metadata).length>0;return n.jsxs("div",{children:[n.jsxs("div",{className:`px-4 py-3 flex items-start gap-3 transition-colors ${x?"cursor-pointer hover:bg-gray-800/20":""}`,onClick:x?c:void 0,children:[n.jsx("div",{className:`w-1.5 h-1.5 rounded-full mt-2 flex-shrink-0 ${u}`}),n.jsx("div",{className:"w-5 h-5 flex-shrink-0 mt-0.5 text-gray-500",children:n.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:f[r.category]||f.command})})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-gray-300",children:r.title}),n.jsx(fe,{label:r.category,variant:Ci(r.severity)})]}),r.detail&&!o&&n.jsx("p",{className:"text-xs text-gray-500 mt-0.5 truncate",children:r.detail}),r.source&&n.jsxs("span",{className:"text-[10px] text-gray-600 mt-0.5 block",children:["via ",r.source]})]}),n.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.timestamp&&n.jsx("span",{className:"text-[10px] text-gray-600 whitespace-nowrap",children:Mp(r.timestamp)}),x&&n.jsx("svg",{className:`w-4 h-4 text-gray-600 transition-transform duration-200 ${o?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),o&&n.jsxs("div",{className:"px-4 pb-3 ml-10 space-y-2",children:[r.detail&&n.jsxs("div",{className:"bg-gray-800/50 rounded p-3",children:[n.jsx("span",{className:"text-[10px] text-gray-500 uppercase block mb-1",children:"Detail"}),n.jsx("p",{className:"text-xs text-gray-300 whitespace-pre-wrap",children:r.detail})]}),r.metadata&&Object.keys(r.metadata).length>0&&n.jsxs("div",{className:"bg-gray-800/50 rounded p-3",children:[n.jsx("span",{className:"text-[10px] text-gray-500 uppercase block mb-1",children:"Metadata"}),n.jsx("pre",{className:"text-xs text-gray-400 font-mono whitespace-pre-wrap overflow-x-auto",children:JSON.stringify(r.metadata,null,2)})]})]})]})}function Mp(r){if(!r)return"-";const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}function Rp(){const[r,o]=S.useState(0);Ge("config-changed",()=>o(Z=>Z+1));const{data:c,loading:u,error:f,refetch:x}=Me(`/api/config?_r=${r}`),{activeProject:g}=Jl(),[b,p]=S.useState(new Set),[m,v]=S.useState({}),[y,N]=S.useState(!1),[R,O]=S.useState(null),[$,_]=S.useState([]);if(u)return n.jsx(at,{});if(f)return n.jsx(Xt,{message:f,onRetry:x});if(!c)return null;const G=Z=>{p(B=>{const te=new Set(B);return te.has(Z)?te.delete(Z):te.add(Z),te})},A=Object.keys(m).length>0,V=(Z,B)=>{v(te=>({...te,[Z]:B})),_(te=>te.filter(le=>le.path!==Z))},re=async()=>{if(A){N(!0),O(null),_([]);try{const Z={};for(const[Re,$e]of Object.entries(m))_p(Z,Re,$e);const B=g?`?project=${g.id}`:"",le=await(await fetch(`/api/config/validate${B}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)})).json();if(le.errors&&le.errors.length>0){_(le.errors),O("Validation failed. Fix errors before saving."),N(!1);return}const lt=await(await fetch(`/api/config${B}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)})).json();lt.ok?(O("Saved successfully"),v({}),_([]),x(),setTimeout(()=>O(null),3e3)):O(`Error: ${lt.error}`)}catch(Z){O(`Error: ${Z}`)}finally{N(!1)}}},P=()=>{v({}),O(null),_([])},J=Object.entries(c).filter(([Z,B])=>typeof B=="object"&&B!==null),Q=Object.entries(c).filter(([Z,B])=>typeof B!="object"||B===null);return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Configuration"}),n.jsx("span",{className:"text-xs text-gray-500",children:".specweave/config.json"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[R&&n.jsx("span",{className:`text-xs ${R.startsWith("Error")||R.startsWith("Validation")?"text-rose-400":"text-emerald-400"}`,children:R}),A&&n.jsxs(n.Fragment,{children:[n.jsx(fe,{label:`${Object.keys(m).length} changes`,variant:"warning"}),n.jsx("button",{onClick:P,className:"px-3 py-1.5 text-xs text-gray-400 hover:text-gray-200 border border-gray-700 rounded-lg transition-colors",children:"Discard"}),n.jsx("button",{onClick:re,disabled:y,className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:y?"Saving...":"Save Changes"})]})]})]}),R&&!A&&R==="Saved successfully"&&n.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/30 rounded-lg px-4 py-2 flex items-center gap-2",children:[n.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400"}),n.jsx("span",{className:"text-xs text-emerald-400",children:"Configuration saved successfully"})]}),$.length>0&&n.jsxs("div",{className:"bg-rose-500/10 border border-rose-500/30 rounded-lg px-4 py-3 space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("div",{className:"w-2 h-2 rounded-full bg-rose-400"}),n.jsx("span",{className:"text-xs text-rose-400 font-medium",children:"Validation errors"})]}),$.map((Z,B)=>n.jsxs("div",{className:"text-xs text-rose-300 pl-4",children:[n.jsx("span",{className:"font-mono text-rose-400",children:Z.path}),": ",Z.message]},B))]}),Q.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-3",children:"General"}),n.jsx("div",{className:"space-y-3",children:Q.map(([Z,B])=>n.jsx(Nm,{path:Z,label:Z,value:m[Z]!==void 0?m[Z]:B,original:B,onChange:te=>V(Z,te),edited:m[Z]!==void 0,validationError:$.find(te=>te.path===Z)?.message},Z))})]}),J.map(([Z,B])=>n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsxs("button",{onClick:()=>G(Z),className:"w-full px-5 py-3 flex items-center justify-between hover:bg-gray-800/30 transition-colors",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 capitalize",children:Z}),$0(m,Z)>0&&n.jsx(fe,{label:`${$0(m,Z)} edited`,variant:"warning"}),$.some(te=>te.path.startsWith(Z+"."))&&n.jsx(fe,{label:"errors",variant:"error"})]}),n.jsx("svg",{className:`w-4 h-4 text-gray-500 transition-transform duration-200 ${b.has(Z)?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),b.has(Z)&&n.jsx("div",{className:"px-5 py-3 border-t border-gray-800",children:n.jsx(jm,{data:B,path:Z,edits:m,onChange:V,validationErrors:$,depth:0})})]},Z))]})}function jm({data:r,path:o,edits:c,onChange:u,validationErrors:f,depth:x}){return x>4?n.jsx("span",{className:"text-xs text-gray-600",children:"..."}):n.jsx("div",{className:"space-y-3",style:{marginLeft:x>0?16:0},children:Object.entries(r).map(([g,b])=>{const p=`${o}.${g}`;return b&&typeof b=="object"&&!Array.isArray(b)?n.jsxs("div",{children:[n.jsx("span",{className:"text-xs text-gray-400 font-mono font-medium",children:g}),n.jsx(jm,{data:b,path:p,edits:c,onChange:u,validationErrors:f,depth:x+1})]},g):n.jsx(Nm,{path:p,label:g,value:c[p]!==void 0?c[p]:b,original:b,onChange:m=>u(p,m),edited:c[p]!==void 0,validationError:f.find(m=>m.path===p)?.message},g)})})}function Nm({path:r,label:o,value:c,original:u,onChange:f,edited:x,validationError:g}){return typeof u=="boolean"||typeof c=="boolean"?n.jsxs("div",{className:"py-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:o}),n.jsx("button",{onClick:()=>f(!c),className:`relative w-9 h-5 rounded-full transition-colors ${c?"bg-indigo-600":"bg-gray-700"} ${x?"ring-1 ring-amber-500/50":""}`,children:n.jsx("div",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-transform ${c?"left-[18px]":"left-0.5"}`})})]}),g&&n.jsx("p",{className:"text-[10px] text-rose-400 mt-0.5",children:g})]}):typeof u=="number"||typeof c=="number"?n.jsxs("div",{className:"py-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:o}),n.jsx("input",{type:"number",value:String(c??""),onChange:b=>f(b.target.value?Number(b.target.value):0),className:`bg-gray-800 border text-xs text-amber-400 font-mono rounded px-2 py-1 w-24 text-right ${g?"border-rose-500":x?"border-amber-500/50":"border-gray-700"} focus:ring-indigo-500 focus:border-indigo-500`})]}),g&&n.jsx("p",{className:"text-[10px] text-rose-400 mt-0.5 text-right",children:g})]}):Array.isArray(u)||Array.isArray(c)?n.jsx(zp,{path:r,label:o,value:Array.isArray(c)?c:Array.isArray(u)?u:[],edited:x,onChange:f,validationError:g}):n.jsxs("div",{className:"py-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:o}),n.jsx("input",{type:"text",value:String(c??""),onChange:b=>f(b.target.value),className:`bg-gray-800 border text-xs text-gray-300 rounded px-2 py-1 w-48 text-right ${g?"border-rose-500":x?"border-amber-500/50":"border-gray-700"} focus:ring-indigo-500 focus:border-indigo-500`})]}),g&&n.jsx("p",{className:"text-[10px] text-rose-400 mt-0.5 text-right",children:g})]})}function zp({path:r,label:o,value:c,edited:u,onChange:f,validationError:x}){const[g,b]=S.useState(!1),[p,m]=S.useState(""),v=R=>{const O=[...c];O.splice(R,1),f(O)},y=()=>{const R=p.trim();R&&(f([...c,R]),m(""))},N=R=>{R.key==="Enter"&&(R.preventDefault(),y())};return n.jsxs("div",{className:"py-1",children:[n.jsxs("button",{onClick:()=>b(R=>!R),className:"flex items-center justify-between w-full group",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:o}),n.jsxs("div",{className:"flex items-center gap-2",children:[u&&n.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-500"}),n.jsxs("span",{className:"text-xs text-gray-400 font-mono",children:["[",c.length," items]"]}),n.jsx("svg",{className:`w-3 h-3 text-gray-500 transition-transform duration-200 ${g?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),g&&n.jsxs("div",{className:"mt-2 ml-4 space-y-1",children:[c.length===0&&n.jsx("p",{className:"text-[10px] text-gray-600",children:"No items"}),c.map((R,O)=>n.jsxs("div",{className:"flex items-center gap-2 group/item",children:[n.jsx("span",{className:"text-xs text-gray-300 font-mono flex-1 truncate",children:String(R)}),n.jsx("button",{onClick:()=>v(O),className:"text-[10px] text-gray-600 hover:text-rose-400 opacity-0 group-hover/item:opacity-100 transition-opacity",children:"remove"})]},O)),n.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[n.jsx("input",{type:"text",value:p,onChange:R=>m(R.target.value),onKeyDown:N,placeholder:"Add item...",className:"bg-gray-800 border border-gray-700 text-xs text-gray-300 rounded px-2 py-1 flex-1 focus:ring-indigo-500 focus:border-indigo-500"}),n.jsx("button",{onClick:y,disabled:!p.trim(),className:"px-2 py-1 text-[10px] text-indigo-400 hover:text-indigo-300 border border-indigo-500/30 rounded disabled:opacity-50 transition-colors",children:"Add"})]})]}),x&&n.jsx("p",{className:"text-[10px] text-rose-400 mt-0.5",children:x})]})}function $0(r,o){return Object.keys(r).filter(c=>c.startsWith(o+".")).length}function _p(r,o,c){const u=o.split(".");let f=r;for(let x=0;x<u.length-1;x++)(!f[u[x]]||typeof f[u[x]]!="object")&&(f[u[x]]={}),f=f[u[x]];f[u[u.length-1]]=c}function yu({lines:r,status:o,onDismiss:c}){const u=S.useRef(null);return S.useEffect(()=>{u.current?.scrollIntoView({behavior:"smooth"})},[r]),r.length===0&&o==="idle"?null:n.jsxs("div",{className:"mt-4 rounded-lg bg-gray-950 border border-gray-700 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-900 border-b border-gray-700",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${o==="running"?"bg-yellow-400 animate-pulse":o==="success"?"bg-green-400":o==="error"?"bg-red-400":"bg-gray-500"}`}),n.jsx("span",{className:"text-xs text-gray-400 font-mono",children:o==="running"?"Running...":o==="success"?"Completed":o==="error"?"Failed":"Output"})]}),o!=="running"&&c&&n.jsx("button",{onClick:c,className:"text-gray-500 hover:text-gray-300 text-xs",children:"Dismiss"})]}),n.jsxs("div",{className:"p-3 max-h-48 overflow-y-auto font-mono text-xs text-gray-300 whitespace-pre-wrap",children:[r.map((f,x)=>n.jsx("div",{children:f},x)),n.jsx("div",{ref:u})]})]})}function Dp(){const{data:r,loading:o}=Me("/api/plugins/full"),{execute:c,running:u,output:f,status:x,reset:g}=Ai(),[b,p]=S.useState(null);if(o)return n.jsx(at,{});const m=r?.plugins||[],v=r?.skills||[],y=r?.lsp,N=r?.warmup,R=r?.triggerCount||0,O=m.reduce((A,V)=>A+V.skillCount,0),$=m.reduce((A,V)=>A+V.commandCount,0),_=A=>v.filter(V=>V.plugin===A).sort((V,re)=>re.count-V.count),G=A=>{p(V=>V===A?null:A)};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Plugins & LSP"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:()=>c("lsp-status"),disabled:u,className:"px-3 py-1.5 bg-gray-700 hover:bg-gray-600 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:"Check LSP"}),n.jsx("button",{onClick:()=>c("refresh-marketplace"),disabled:u,className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:u?"Running...":"Refresh Marketplace"})]})]}),n.jsx(yu,{lines:f,status:x,onDismiss:g}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[n.jsx(Ba,{label:"Plugins",value:m.length}),n.jsx(Ba,{label:"Total Skills",value:O}),n.jsx(Ba,{label:"Total Commands",value:$}),n.jsx(Ba,{label:"Trigger Keywords",value:R})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Installed Plugins"})}),m.length===0?n.jsx("div",{className:"p-5 text-gray-500 text-xs",children:"No plugins installed"}):n.jsx("div",{className:"divide-y divide-gray-800/50",children:m.map(A=>{const V=b===A.name,re=_(A.name);return n.jsxs("div",{children:[n.jsxs("button",{onClick:()=>G(A.name),className:"w-full px-4 py-3 flex items-center justify-between hover:bg-gray-800/30 transition-colors text-left",children:[n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("span",{className:"text-sm text-gray-300",children:A.name}),n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:A.version})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(fe,{label:`${A.skillCount} skills`,variant:"info"}),n.jsx(fe,{label:`${A.commandCount} cmds`,variant:"default"}),n.jsx("svg",{className:`w-4 h-4 text-gray-500 transition-transform duration-200 ${V?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),V&&n.jsx("div",{className:"px-4 pb-4 bg-gray-800/20",children:re.length===0?n.jsx("p",{className:"text-xs text-gray-600 py-2",children:"No skill usage data for this plugin"}):n.jsxs("div",{className:"space-y-1 mt-1",children:[n.jsxs("div",{className:"grid grid-cols-[1fr,80px,80px,120px] gap-2 px-2 py-1",children:[n.jsx("span",{className:"text-[10px] text-gray-600 uppercase",children:"Skill"}),n.jsx("span",{className:"text-[10px] text-gray-600 uppercase text-right",children:"Invocations"}),n.jsx("span",{className:"text-[10px] text-gray-600 uppercase text-right",children:"Success"}),n.jsx("span",{className:"text-[10px] text-gray-600 uppercase text-right",children:"Last Used"})]}),re.map(P=>n.jsxs("div",{className:"grid grid-cols-[1fr,80px,80px,120px] gap-2 px-2 py-1.5 bg-gray-800/40 rounded",children:[n.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:P.name}),n.jsx("span",{className:"text-xs text-gray-400 text-right font-mono",children:P.count}),n.jsxs("span",{className:"text-xs text-right font-mono",children:[n.jsx("span",{className:"text-emerald-400",children:P.successCount}),P.failureCount>0&&n.jsxs("span",{className:"text-rose-400",children:["/",P.failureCount]})]}),n.jsx("span",{className:"text-[10px] text-gray-500 text-right",children:P.lastUsed?Op(P.lastUsed):"-"})]},P.name))]})})]},A.name)})})]}),v.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Skill Usage Leaderboard"}),n.jsx(ym,{items:v.sort((A,V)=>V.count-A.count).slice(0,20).map(A=>({label:A.name,value:A.count,color:"#10b981"})),maxBars:20})]}),y&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"LSP Status"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(fe,{label:y.status,variant:y.status==="ok"?"success":"warning"}),y.checked&&n.jsxs("span",{className:"text-[10px] text-gray-600",children:["Checked: ",new Date(y.checked).toLocaleDateString()]})]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-4",children:[n.jsx(Ba,{label:"Total Languages",value:y.stats.totalLanguages}),n.jsx(Ba,{label:"Checked",value:y.stats.checkedLanguages}),n.jsx(Ba,{label:"Binary Missing",value:y.stats.binaryMissing}),n.jsx(Ba,{label:"Plugin Missing",value:y.stats.pluginMissing})]}),y.missing.length>0&&n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"text-xs text-gray-500",children:"Missing Languages"}),y.missing.map((A,V)=>n.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-800/50 rounded",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(fe,{label:A.type,variant:A.type==="binary"?"warning":"default"}),n.jsx("span",{className:"text-xs text-gray-300",children:A.language})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"text-[10px] text-gray-500",children:A.binaryInstall}),A.message&&n.jsx("span",{className:"text-[10px] text-gray-600 max-w-[200px] truncate",children:A.message})]})]},V))]})]}),N&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"LSP Warmup Status"}),n.jsxs("span",{className:"text-[10px] text-gray-600",children:[N.elapsed?`${(N.elapsed/1e3).toFixed(1)}s`:""," |"," ",N.timestamp?new Date(N.timestamp).toLocaleString():""]})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[N.warmedUp.map(A=>n.jsx(fe,{label:A,variant:"success"},A)),N.failed.map(A=>n.jsx(fe,{label:A,variant:"error"},A))]}),N.warmedUp.length===0&&N.failed.length===0&&n.jsx("p",{className:"text-gray-600 text-xs",children:"No warmup data"})]})]})}function Ba({label:r,value:o}){return n.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-3 text-center",children:[n.jsx("div",{className:"text-lg font-bold text-gray-300",children:o}),n.jsx("div",{className:"text-[10px] text-gray-500",children:r})]})}function Op(r){if(!r)return"-";const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}function Up(){const{data:r,loading:o}=Me("/api/links"),{data:c,loading:u,refetch:f}=Me("/api/services"),{execute:x,running:g,output:b,status:p,reset:m}=Ai();if(o||u)return n.jsx(at,{});const v=(c||[]).filter(_=>_.status==="running").length,y=(c||[]).length,N=new Map;for(const _ of c||[])if(_.port>0&&_.status==="running"){const G=N.get(_.port)||[];G.push(_.name),N.set(_.port,G)}const R=Array.from(N.entries()).filter(([,_])=>_.length>1),O=async _=>{await x(_),setTimeout(()=>f(),3e3)},$=async _=>{await x(_),setTimeout(()=>f(),2e3)};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Services & Links"}),n.jsx(yu,{lines:b,status:p,onDismiss:m}),R.length>0&&n.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-xl p-4 flex items-start gap-3",children:[n.jsx("svg",{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium text-amber-300",children:"Port Conflict Detected"}),n.jsx("div",{className:"text-xs text-amber-400/80 mt-1",children:R.map(([_,G])=>n.jsxs("span",{className:"block",children:["Port ",_," is used by: ",G.join(", ")]},_))})]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Services",value:y,color:"indigo",tooltip:`${y} managed services`}),n.jsx(ie,{title:"Running",value:v,color:"emerald",tooltip:`${v} services currently active`}),n.jsx(ie,{title:"External Links",value:(r||[]).length,color:"cyan",tooltip:"Configured external links (docs, repos, etc.)"}),n.jsx(ie,{title:"Stopped",value:y-v,color:"rose",tooltip:`${y-v} services not running`})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Service Status"}),n.jsx("div",{className:"space-y-3",children:(c||[]).map((_,G)=>n.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${_.status==="running"?"bg-emerald-400":"bg-gray-600"}`}),n.jsxs("div",{children:[n.jsx("span",{className:"text-sm text-gray-300",children:_.name}),n.jsx("div",{className:"text-[10px] text-gray-600",children:_.status==="running"&&_.detail?n.jsx("a",{href:_.detail,target:"_blank",rel:"noopener noreferrer",className:"text-indigo-400 hover:text-indigo-300 underline transition-colors",children:_.detail}):_.detail})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[_.status==="running"&&_.port>0&&n.jsx(fe,{label:`Port ${_.port}`,variant:"info"}),_.status==="running"?n.jsx(fe,{label:"Running",variant:"success"}):n.jsx(fe,{label:"Stopped",variant:"default"}),_.name==="Docs Preview"&&(_.status==="running"?n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("a",{href:_.detail,target:"_blank",rel:"noopener noreferrer",className:"px-2 py-1 text-[10px] text-indigo-400 hover:text-indigo-300 border border-indigo-500/30 rounded transition-colors",children:"Open"}),n.jsx("button",{onClick:()=>$("docs-preview-stop"),disabled:g,className:"px-2 py-1 text-[10px] text-rose-400 hover:text-rose-300 border border-rose-500/30 rounded transition-colors disabled:opacity-50",children:"Stop"})]}):n.jsx("button",{onClick:()=>O("docs-preview-start"),disabled:g,className:"px-2 py-1 text-[10px] text-emerald-400 hover:text-emerald-300 border border-emerald-500/30 rounded transition-colors disabled:opacity-50",children:g?"Starting...":"Start"})),_.status==="running"&&_.name!=="Docs Preview"&&n.jsx("a",{href:_.detail,target:"_blank",rel:"noopener noreferrer",className:"px-2 py-1 text-[10px] text-indigo-400 hover:text-indigo-300 border border-indigo-500/30 rounded transition-colors",children:"Open"})]})]},G))})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"External Links"}),(r||[]).length===0?n.jsx("p",{className:"text-xs text-gray-500",children:"No external links configured"}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:(r||[]).map((_,G)=>n.jsxs("a",{href:_.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg hover:bg-gray-800 transition-colors group",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Lp,{type:_.type}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-gray-300 group-hover:text-white transition-colors",children:_.name}),n.jsx("div",{className:"text-[10px] text-gray-600 truncate max-w-[200px]",children:_.url})]})]}),n.jsx("svg",{className:"w-4 h-4 text-gray-600 group-hover:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]},G))})]})]})}function Lp({type:r}){const o={docs:"bg-indigo-600",github:"bg-gray-700",jira:"bg-blue-700",ado:"bg-blue-600"};return n.jsx("div",{className:`w-8 h-8 rounded-lg ${o[r]||"bg-gray-700"} flex items-center justify-center`,children:n.jsx("span",{className:"text-xs text-white font-bold",children:r[0]?.toUpperCase()})})}const V0={critical:0,warning:1,info:2};function Hp(){const[r,o]=S.useState("pending"),[c,u]=S.useState(null),[f,x]=S.useState(0);Ge("notification",()=>x(B=>B+1));const{activeProject:g}=Jl(),{data:b,loading:p,error:m,refetch:v}=Me(`/api/notifications?_r=${f}`);if(p)return n.jsx(at,{});if(m)return n.jsx(Xt,{message:m,onRetry:v});const y=b||[],N=y.filter(B=>!B.dismissedAt),R=y.filter(B=>!!B.dismissedAt),O=N.filter(B=>B.severity==="critical"),$=N.filter(B=>B.severity==="warning"),G=[...r==="pending"?N:r==="dismissed"?R:y].sort((B,te)=>{const le=V0[B.severity]??3,Oe=V0[te.severity]??3;return le!==Oe?le-Oe:new Date(te.createdAt).getTime()-new Date(B.createdAt).getTime()}),A=async B=>{u(B);try{const te=g?`?project=${g.id}`:"";(await fetch(`/api/notifications/${B}/dismiss${te}`,{method:"POST"})).ok&&v()}finally{u(null)}},V=async()=>{u("__all__");try{const B=g?`?project=${g.id}`:"";for(const te of N)await fetch(`/api/notifications/${te.id}/dismiss${B}`,{method:"POST"});v()}finally{u(null)}},re=B=>B==="critical"?"error":B==="warning"?"warning":"info",P=B=>B==="critical"?"border-l-rose-500":B==="warning"?"border-l-amber-500":"border-l-blue-500",Q=(B=>{const te={};for(const le of B)te[le.severity]||(te[le.severity]=[]),te[le.severity].push(le);return te})(G),Z={critical:"Critical",warning:"Warnings",info:"Informational"};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Notifications"}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Pending",value:N.length,color:"indigo"}),n.jsx(ie,{title:"Critical",value:O.length,color:"rose"}),n.jsx(ie,{title:"Warnings",value:$.length,color:"amber"}),n.jsx(ie,{title:"Dismissed",value:R.length,color:"cyan"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:[{value:"pending",label:`Pending (${N.length})`},{value:"dismissed",label:`Dismissed (${R.length})`},{value:"all",label:`All (${y.length})`}].map(B=>n.jsx("button",{onClick:()=>o(B.value),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${r===B.value?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:B.label},B.value))}),N.length>0&&n.jsx("button",{onClick:V,disabled:c==="__all__",className:"px-3 py-1.5 text-xs text-gray-400 hover:text-gray-200 border border-gray-700 rounded-lg transition-colors disabled:opacity-50",children:c==="__all__"?"Dismissing...":"Dismiss All"})]}),G.length===0?n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:[n.jsx("div",{className:"w-12 h-12 rounded-full bg-gray-800 flex items-center justify-center mx-auto mb-4",children:n.jsx("svg",{className:"w-6 h-6 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"})})}),n.jsx("p",{className:"text-gray-400 text-sm font-medium",children:r==="pending"?"No pending notifications":"No notifications"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1 max-w-xs mx-auto",children:"Notifications appear here when imports complete, discrepancies are found, or syncs fail"})]}):n.jsx("div",{className:"space-y-4",children:["critical","warning","info"].map(B=>{const te=Q[B];return!te||te.length===0?null:n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx("h3",{className:"text-xs font-medium text-gray-400 uppercase",children:Z[B]||B}),n.jsxs("span",{className:"text-[10px] text-gray-600",children:["(",te.length,")"]})]}),n.jsx("div",{className:"space-y-2",children:te.map(le=>n.jsxs("div",{className:`bg-gray-900/50 border border-gray-800 border-l-4 ${P(le.severity)} rounded-xl p-4 flex items-start gap-4 ${le.dismissedAt?"opacity-60":""}`,children:[n.jsx(Bp,{severity:le.severity}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("span",{className:"text-sm font-medium text-gray-200",children:le.title}),n.jsx(fe,{label:le.severity,variant:re(le.severity)}),le.type&&n.jsx(fe,{label:le.type,variant:"default"})]}),le.message&&n.jsx("p",{className:"text-xs text-gray-400 mb-2",children:le.message}),n.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-gray-600",children:[n.jsx("span",{children:new Date(le.createdAt).toLocaleString()}),le.source&&n.jsxs("span",{children:["via ",le.source]}),le.dismissedAt&&n.jsxs("span",{children:["Dismissed ",new Date(le.dismissedAt).toLocaleString()]})]})]}),!le.dismissedAt&&n.jsx("button",{onClick:()=>A(le.id),disabled:c===le.id,className:"px-2 py-1 text-xs text-gray-500 hover:text-gray-300 hover:bg-gray-800 rounded transition-colors disabled:opacity-50 flex-shrink-0",children:c===le.id?"...":"Dismiss"})]},le.id))})]},B)})})]})}function Bp({severity:r}){return r==="critical"?n.jsx("div",{className:"w-8 h-8 rounded-full bg-rose-500/10 flex items-center justify-center flex-shrink-0",children:n.jsx("svg",{className:"w-4 h-4 text-rose-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"})})}):r==="warning"?n.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/10 flex items-center justify-center flex-shrink-0",children:n.jsx("svg",{className:"w-4 h-4 text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}):n.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500/10 flex items-center justify-center flex-shrink-0",children:n.jsx("svg",{className:"w-4 h-4 text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}function qp(r){if(!r)return null;if(r.startsWith("https://"))return r.replace(/\.git$/,"");const o=r.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(o)return`https://${o[1]}/${o[2]}`;const c=r.match(/^ssh:\/\/git@([^/]+)\/(.+?)(?:\.git)?$/);return c?`https://${c[1]}/${c[2]}`:null}function Yp(){const{data:r,loading:o,error:c,refetch:u}=Me("/api/repos");if(o)return n.jsx(at,{});if(c)return n.jsx(Xt,{message:c,onRetry:u});const f=r||[],x=[...new Set(f.map(p=>p.org))],g=f.filter(p=>p.hasSpecweave).length,b=f.find(p=>p.isCurrent);return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Repositories"}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Repositories",value:f.length,color:"indigo"}),n.jsx(ie,{title:"Organizations",value:x.length,color:"cyan"}),n.jsx(ie,{title:"With SpecWeave",value:g,color:"emerald"}),n.jsx(ie,{title:"Current",value:b?b.name:"-",subtitle:b?`${b.org}/${b.name}`:"No current project",color:"amber"})]}),f.length===0?n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No repositories found"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"This project doesn't use multi-repo mode, or the repositories/ directory hasn't been set up yet"})]}):n.jsx(n.Fragment,{children:x.map(p=>{const m=f.filter(v=>v.org===p);return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(Gp,{}),n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:p}),n.jsxs("span",{className:"text-[10px] text-gray-600",children:[m.length," ",m.length===1?"repo":"repos"]})]}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:m.map(v=>{const y=qp(v.remote);return n.jsxs("div",{className:`bg-gray-900/50 border rounded-xl p-4 ${v.isCurrent?"border-indigo-500/30":"border-gray-800"}`,children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx($p,{}),n.jsx("span",{className:"text-sm font-medium text-gray-300",children:v.name})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[v.isCurrent&&n.jsx(fe,{label:"Current Project",variant:"info"}),n.jsx(fe,{label:v.hasSpecweave?"SpecWeave":"No SpecWeave",variant:v.hasSpecweave?"success":"default"})]})]}),n.jsxs("div",{className:"space-y-1.5 mt-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Organization"}),n.jsx("span",{className:"text-[10px] text-gray-400",children:v.org})]}),v.branch&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Branch"}),n.jsx(fe,{label:v.branch,variant:"default"})]}),y&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Remote"}),n.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-indigo-400 hover:text-indigo-300 hover:underline truncate max-w-[180px]",title:y,children:y.replace("https://","")})]}),!y&&v.remote&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Remote"}),n.jsx("span",{className:"text-[10px] text-gray-600 font-mono truncate max-w-[180px]",title:v.remote,children:v.remote})]}),v.path&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Path"}),n.jsx("span",{className:"text-[10px] text-gray-600 font-mono truncate max-w-[180px]",title:v.path,children:v.path.split("/").slice(-3).join("/")})]}),v.lastModified&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Last Modified"}),n.jsx("span",{className:"text-[10px] text-gray-400",children:Qp(v.lastModified)})]})]}),y&&n.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"mt-3 flex items-center justify-center gap-1.5 text-xs text-gray-400 hover:text-gray-200 py-2 border border-gray-800 rounded-lg hover:border-gray-700 transition-colors",children:[n.jsx(Vp,{}),"Open on GitHub"]})]},v.path||`${v.org}/${v.name}`)})})]},p)})})]})}function Gp(){return n.jsx("div",{className:"w-6 h-6 rounded bg-gray-700 flex items-center justify-center",children:n.jsx("svg",{className:"w-3.5 h-3.5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"})})})}function $p(){return n.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}function Vp(){return n.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})})}function Qp(r){if(!r)return"-";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return"-"}}const Xp=[{value:"",label:"All"},{value:"discovered",label:"Discovered"},{value:"scanning",label:"Scanning"},{value:"tier1_passed",label:"Passed"},{value:"tier1_failed",label:"Failed"},{value:"verified",label:"Verified"},{value:"rejected",label:"Rejected"}],oa=20;function kp(r){switch(r){case"discovered":return"default";case"queued":return"info";case"scanning":return"warning";case"tier1_passed":return"success";case"tier1_failed":return"error";case"tier2_pending":return"info";case"verified":return"success";case"rejected":return"error";default:return"default"}}function Zp(r){switch(r){case"discovered":return"Discovered";case"queued":return"Queued";case"scanning":return"Scanning";case"tier1_passed":return"T1 Passed";case"tier1_failed":return"T1 Failed";case"tier2_pending":return"T2 Pending";case"verified":return"Verified";case"rejected":return"Rejected";default:return r}}function Q0(r){if(!r)return"-";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return"-"}}function X0(r){return r>=80?"text-emerald-400":r>=50?"text-amber-400":"text-rose-400"}function Kp(r,o){if(o===0)return"rose";const c=r/o;return c>.5?"emerald":c>.1?"amber":"rose"}function Jp(){const[r,o]=S.useState(""),[c,u]=S.useState(0),[f,x]=S.useState(0),[g,b]=S.useState(null),{output:p,status:m,reset:v}=Ai(),y=r?`status=${r}&limit=${oa}&offset=${c}`:`limit=${oa}&offset=${c}`,{data:N,loading:R,error:O,refetch:$}=Me(`/api/marketplace/scanner/status?_r=${f}`),{data:_,loading:G,refetch:A}=Me(`/api/marketplace/queue?${y}&_r=${f}`),{data:V,loading:re}=Me(`/api/marketplace/verified?_r=${f}`),{data:P,loading:J}=Me(`/api/marketplace/insights?_r=${f}`),Q=S.useCallback(()=>{x(X=>X+1)},[]);Ge("submission-update",S.useCallback(()=>{Q()},[Q])),Ge("marketplace-scan",S.useCallback(()=>{Q()},[Q])),Ge("verification-complete",S.useCallback(()=>{Q()},[Q]));const Z=async()=>{try{const X=new URLSearchParams(window.location.search).get("project")||"",me=X?`?project=${X}`:"";await fetch(`/api/marketplace/scanner/start${me}`,{method:"POST"}),$()}catch{}},B=async()=>{try{const X=new URLSearchParams(window.location.search).get("project")||"",me=X?`?project=${X}`:"";await fetch(`/api/marketplace/scanner/stop${me}`,{method:"POST"}),$()}catch{}},te=async X=>{b(X);try{const me=new URLSearchParams(window.location.search).get("project")||"",T=me?`?project=${me}`:"";await fetch(`/api/marketplace/queue/${X}/approve${T}`,{method:"POST"}),A()}catch{}b(null)},le=async X=>{b(X);try{const me=new URLSearchParams(window.location.search).get("project")||"",T=me?`?project=${me}`:"";await fetch(`/api/marketplace/queue/${X}/reject${T}`,{method:"POST"}),A()}catch{}b(null)};if(R&&G&&re&&J)return n.jsx(at,{});const lt=_?.items||[],Re=_?.total||0,$e=V||[],U=Math.floor(c/oa)+1,k=Math.ceil(Re/oa),ne=X=>X==="tier1_passed"||X==="tier2_pending";return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Marketplace Scanner"}),n.jsx("div",{className:"flex gap-2",children:N?.running?n.jsx("button",{onClick:B,className:"px-3 py-1.5 bg-rose-600 hover:bg-rose-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:"Stop Scanner"}):n.jsx("button",{onClick:Z,className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:"Start Scanner"})})]}),n.jsx(yu,{lines:p,status:m,onDismiss:v}),O&&n.jsx(Xt,{message:O,onRetry:$}),N?n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Scanner",value:N.running?"Running":"Stopped",subtitle:N.running?"Active":"Idle",color:N.running?"emerald":"amber"}),n.jsx(ie,{title:"Last Scan",value:N.lastScanTime?Q0(N.lastScanTime):"Never",color:"cyan"}),n.jsx(ie,{title:"Repos Scanned",value:N.reposScanned,color:"indigo"}),n.jsx(ie,{title:"Rate Limit",value:`${N.rateLimitRemaining}/${N.rateLimitTotal}`,subtitle:N.rateLimitTotal>0?`${Math.round(N.rateLimitRemaining/N.rateLimitTotal*100)}% remaining`:"Unknown",color:Kp(N.rateLimitRemaining,N.rateLimitTotal)})]}):!R&&!O?n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:[n.jsx("div",{className:"text-gray-400 text-sm mb-2",children:"No scanner data available"}),n.jsx("p",{className:"text-gray-600 text-xs mb-4",children:"Start the marketplace scanner to discover and verify community skills."}),n.jsx("button",{onClick:Z,className:"px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm rounded-lg transition-colors",children:"Start Scanner"})]}):null,n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsxs("div",{className:"px-5 py-3 border-b border-gray-800 flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Submission Queue"}),n.jsxs("span",{className:"text-xs text-gray-500",children:[Re," total"]})]}),n.jsx("div",{className:"flex gap-1 px-4 pt-3 pb-2 overflow-x-auto",children:Xp.map(X=>n.jsx("button",{onClick:()=>{o(X.value),u(0)},className:`px-3 py-1.5 text-xs rounded-md transition-colors whitespace-nowrap ${r===X.value?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300 hover:bg-gray-800"}`,children:X.label},X.value))}),G?n.jsx("div",{className:"p-8 flex justify-center",children:n.jsx(at,{})}):lt.length===0?n.jsxs("div",{className:"p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No submissions found"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:r?"Try a different filter.":"Submissions will appear here once the scanner discovers repos."})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Repo"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Author"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Stars"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Status"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Tier"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Security"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Discovered"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Actions"})]})}),n.jsx("tbody",{children:lt.map(X=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsx("td",{className:"px-4 py-2",children:X.repoUrl?n.jsx("a",{href:X.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-indigo-400 hover:text-indigo-300 font-mono",children:X.repoFullName}):n.jsx("span",{className:"text-xs text-gray-300 font-mono",children:X.repoFullName})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400",children:X.author}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400 text-right font-mono",children:X.stars.toLocaleString()}),n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:Zp(X.status),variant:kp(X.status)})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400",children:X.tier||"-"}),n.jsx("td",{className:`px-4 py-2 text-xs text-right font-mono ${X0(X.securityScore)}`,children:X.securityScore!=null?X.securityScore:"-"}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500",children:Q0(X.discoveredAt)}),n.jsx("td",{className:"px-4 py-2 text-right",children:ne(X.status)&&n.jsxs("div",{className:"flex gap-1 justify-end",children:[n.jsx("button",{onClick:()=>te(X.id),disabled:g===X.id,className:"px-2 py-1 bg-emerald-600/20 hover:bg-emerald-600/40 text-emerald-400 text-[10px] rounded transition-colors disabled:opacity-50",children:"Approve"}),n.jsx("button",{onClick:()=>le(X.id),disabled:g===X.id,className:"px-2 py-1 bg-rose-600/20 hover:bg-rose-600/40 text-rose-400 text-[10px] rounded transition-colors disabled:opacity-50",children:"Reject"})]})})]},X.id))})]})}),Re>oa&&n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-800",children:[n.jsxs("span",{className:"text-xs text-gray-500",children:[c+1,"-",Math.min(c+oa,Re)," of ",Re]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx("button",{onClick:()=>u(Math.max(0,c-oa)),disabled:c===0,className:"px-2 py-1 text-xs text-gray-400 hover:text-gray-200 disabled:opacity-30 disabled:cursor-not-allowed",children:"Prev"}),n.jsxs("span",{className:"px-2 py-1 text-xs text-gray-500",children:["Page ",U," of ",k]}),n.jsx("button",{onClick:()=>u(c+oa),disabled:c+oa>=Re,className:"px-2 py-1 text-xs text-gray-400 hover:text-gray-200 disabled:opacity-30 disabled:cursor-not-allowed",children:"Next"})]})]})]})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Verified Skills"})}),re?n.jsx("div",{className:"p-8 flex justify-center",children:n.jsx(at,{})}):$e.length===0?n.jsxs("div",{className:"p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No verified skills yet"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"Skills will appear here after passing security verification."})]}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4",children:$e.map(X=>n.jsxs("div",{className:"bg-gray-800/50 border border-gray-700/50 rounded-lg p-4 hover:border-gray-600 transition-colors",children:[n.jsxs("div",{className:"flex items-start justify-between mb-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm font-medium text-gray-200 truncate",children:X.repoFullName}),n.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:X.author})]}),n.jsx(fe,{label:"Verified",variant:"success"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("span",{className:"text-xs text-gray-400 flex items-center gap-1",children:[n.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),X.stars.toLocaleString()]}),n.jsxs("span",{className:`text-xs font-mono ${X0(X.securityScore)}`,children:["Score: ",X.securityScore]})]}),X.repoUrl&&n.jsx("a",{href:X.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"GitHub"})]})]},X.id))})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Insights"})}),J?n.jsx("div",{className:"p-8 flex justify-center",children:n.jsx(at,{})}):P?n.jsxs("div",{className:"p-4 space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Discovered",value:P.totalDiscovered,color:"cyan"}),n.jsx(ie,{title:"Verified",value:P.totalVerified,color:"emerald"}),n.jsx(ie,{title:"Rejected",value:P.totalRejected,color:"rose"}),n.jsx(ie,{title:"Pending",value:P.totalPending,color:"amber"})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(k0,{label:"Tier 1 Pass Rate",rate:P.tier1PassRate}),n.jsx(k0,{label:"Tier 2 Pass Rate",rate:P.tier2PassRate})]})]}):n.jsx("div",{className:"p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No insights data available"})})]})]})}function k0({label:r,rate:o}){const c=Math.round(o),u=c>=70?"bg-emerald-500":c>=40?"bg-amber-500":"bg-rose-500";return n.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("span",{className:"text-xs text-gray-400",children:r}),n.jsxs("span",{className:"text-sm font-bold text-gray-200",children:[c,"%"]})]}),n.jsx("div",{className:"w-full h-2 bg-gray-700 rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full ${u} rounded-full transition-all duration-500`,style:{width:`${c}%`}})})]})}function Wp(){const{id:r}=Bg(),[o,c]=S.useState(0);Ge("increment-update",()=>c(m=>m+1));const{data:u,loading:f,error:x,refetch:g}=Me(`/api/increments/${r||"_none"}?_r=${o}`);if(!r)return n.jsx("div",{className:"p-6 text-gray-500 text-sm",children:"No increment ID specified"});if(f)return n.jsx(at,{});if(x)return n.jsx(Xt,{message:x,onRetry:g});if(!u)return n.jsx("div",{className:"p-6 text-gray-500 text-sm",children:"Increment not found"});const b=u.taskSummary.total>0?Math.round(u.taskSummary.completed/u.taskSummary.total*100):0,p=u.acSummary.total>0?Math.round(u.acSummary.completed/u.acSummary.total*100):0;return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[n.jsx("span",{className:"text-xs text-indigo-400 font-mono",children:u.dirName}),n.jsx(fe,{label:u.metadata.status||"unknown",variant:Ci(u.metadata.status||"")}),u.metadata.type&&n.jsx("span",{className:"text-xs text-gray-400 capitalize",children:u.metadata.type}),u.metadata.priority&&n.jsx(Fp,{priority:u.metadata.priority})]}),n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:u.metadata.title||u.id}),u.metadata.project&&n.jsxs("span",{className:"text-xs text-gray-500",children:["Project: ",u.metadata.project]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Tasks",value:`${u.taskSummary.completed}/${u.taskSummary.total}`,color:"indigo"}),n.jsx(ie,{title:"Task Progress",value:`${b}%`,color:"cyan"}),n.jsx(ie,{title:"ACs",value:`${u.acSummary.completed}/${u.acSummary.total}`,color:"emerald"}),n.jsx(ie,{title:"AC Progress",value:`${p}%`,color:"amber"})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5 space-y-4",children:[n.jsx(Z0,{label:"Tasks",completed:u.taskSummary.completed,total:u.taskSummary.total,color:"indigo"}),n.jsx(Z0,{label:"Acceptance Criteria",completed:u.acSummary.completed,total:u.acSummary.total,color:"emerald"})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsxs("h3",{className:"text-sm font-medium text-gray-300",children:["Tasks (",u.tasks.length,")"]})}),u.tasks.length===0?n.jsx("div",{className:"p-5 text-center text-gray-500 text-xs",children:"No tasks found in tasks.md"}):n.jsx("div",{className:"divide-y divide-gray-800/50",children:u.tasks.map(m=>n.jsxs("div",{className:"px-5 py-3 flex items-center gap-3",children:[n.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 ${m.status==="completed"?"bg-indigo-500/20 border-indigo-500 text-indigo-400":"border-gray-600"}`,children:m.status==="completed"&&n.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:m.id}),n.jsx("span",{className:`text-sm ${m.status==="completed"?"text-gray-500 line-through":"text-gray-300"}`,children:m.title})]}),(m.userStory||m.acs)&&n.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[m.userStory&&n.jsx("span",{className:"text-[10px] text-indigo-400",children:m.userStory}),m.acs?.map(v=>n.jsx("span",{className:"text-[10px] text-emerald-500",children:v},v))]})]})]},m.id))})]}),u.acs.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsxs("h3",{className:"text-sm font-medium text-gray-300",children:["Acceptance Criteria (",u.acs.length,")"]})}),n.jsx("div",{className:"divide-y divide-gray-800/50",children:u.acs.map(m=>n.jsxs("div",{className:"px-5 py-3 flex items-start gap-3",children:[n.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 mt-0.5 ${m.completed?"bg-emerald-500/20 border-emerald-500 text-emerald-400":"border-gray-600"}`,children:m.completed&&n.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),n.jsxs("div",{children:[n.jsx("span",{className:"text-xs text-emerald-500 font-mono",children:m.id}),n.jsx("span",{className:`text-sm ml-2 ${m.completed?"text-gray-500 line-through":"text-gray-300"}`,children:m.text})]})]},m.id))})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-3",children:"Metadata"}),n.jsx("div",{className:"space-y-1.5",children:Object.entries(u.metadata).filter(([m])=>!["title"].includes(m)).map(([m,v])=>n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:m}),n.jsx("span",{className:"text-xs text-gray-400",children:typeof v=="object"?JSON.stringify(v):String(v??"")})]},m))})]})]})}function Z0({label:r,completed:o,total:c,color:u}){const f=c>0?Math.round(o/c*100):0,x=u==="emerald"?"bg-emerald-500":"bg-indigo-500";return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[n.jsx("span",{className:"text-xs text-gray-400",children:r}),n.jsxs("span",{className:"text-xs text-gray-500",children:[o,"/",c," (",f,"%)"]})]}),n.jsx("div",{className:"w-full h-2 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full ${x} rounded-full transition-all`,style:{width:`${f}%`}})})]})}function Fp({priority:r}){const o={P0:"text-rose-400 bg-rose-500/10",P1:"text-amber-400 bg-amber-500/10",P2:"text-cyan-400 bg-cyan-500/10",P3:"text-gray-400 bg-gray-500/10"};return n.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${o[r]||o.P2}`,children:r})}function Pp(){const r=Dy();return n.jsx(xm.Provider,{value:r,children:n.jsx(Uy,{children:n.jsxs("div",{className:"flex min-h-screen bg-gray-950 text-gray-100",children:[n.jsx(qy,{}),n.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n.jsx(Yy,{}),n.jsx("main",{className:"flex-1 overflow-y-auto",children:n.jsxs(Ig,{children:[n.jsx(st,{path:"/",element:n.jsx(Fy,{})}),n.jsx(st,{path:"/increments",element:n.jsx(tp,{})}),n.jsx(st,{path:"/increments/:id",element:n.jsx(Wp,{})}),n.jsx(st,{path:"/analytics",element:n.jsx(np,{})}),n.jsx(st,{path:"/costs",element:n.jsx(op,{})}),n.jsx(st,{path:"/sync",element:n.jsx(yp,{})}),n.jsx(st,{path:"/errors",element:n.jsx(vp,{})}),n.jsx(st,{path:"/activity",element:n.jsx(Ap,{})}),n.jsx(st,{path:"/config",element:n.jsx(Rp,{})}),n.jsx(st,{path:"/plugins",element:n.jsx(Dp,{})}),n.jsx(st,{path:"/services",element:n.jsx(Up,{})}),n.jsx(st,{path:"/notifications",element:n.jsx(Hp,{})}),n.jsx(st,{path:"/repos",element:n.jsx(Yp,{})}),n.jsx(st,{path:"/marketplace",element:n.jsx(Jp,{})}),n.jsx(st,{path:"*",element:n.jsxs("div",{className:"p-6 text-center",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200 mb-2",children:"Page Not Found"}),n.jsx("p",{className:"text-sm text-gray-500",children:"The page you're looking for doesn't exist."})]})})]})})]})]})})})}tg.createRoot(document.getElementById("root")).render(n.jsx(S.StrictMode,{children:n.jsx(Ey,{children:n.jsx(Pp,{})})}));
11
+ Please change the parent <Route path="${A}"> to <Route path="${A==="/"?"*":`${A}/*`}">.`)}let N=Ya(),R;if(o){let A=typeof o=="string"?Zl(o):o;Ue(v==="/"||A.pathname?.startsWith(v),`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 "${v}" but pathname "${A.pathname}" was given in the \`location\` prop.`),R=A}else R=N;let O=R.pathname||"/",$=O;if(v!=="/"){let A=v.replace(/^\//,"").split("/");$="/"+O.replace(/^\//,"").split("/").slice(A.length).join("/")}let _=K0(r,{pathname:$});qt(y||_!=null,`No routes matched location "${R.pathname}${R.search}${R.hash}" `),qt(_==null||_[_.length-1].route.element!==void 0||_[_.length-1].route.Component!==void 0||_[_.length-1].route.lazy!==void 0,`Matched leaf route at location "${R.pathname}${R.search}${R.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 G=Qg(_&&_.map(A=>Object.assign({},A,{params:Object.assign({},p,A.params),pathname:da([v,x.encodeLocation?x.encodeLocation(A.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathname]),pathnameBase:A.pathnameBase==="/"?v:da([v,x.encodeLocation?x.encodeLocation(A.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:A.pathnameBase])})),g,c,u,f);return o&&G?S.createElement(Wn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...R},navigationType:"POP"}},G):G}function Yg(){let r=Jg(),o=Cg(r)?`${r.status} ${r.statusText}`:r instanceof Error?r.message:JSON.stringify(r),c=r instanceof Error?r.stack:null,u="rgba(200,200,200, 0.5)",f={padding:"0.5rem",backgroundColor:u},x={padding:"2px 4px",backgroundColor:u},g=null;return console.error("Error handled by React Router default ErrorBoundary:",r),g=S.createElement(S.Fragment,null,S.createElement("p",null,"💿 Hey developer 👋"),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:x},"ErrorBoundary")," or"," ",S.createElement("code",{style:x},"errorElement")," prop on your route.")),S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},o),c?S.createElement("pre",{style:f},c):null,g)}var Gg=S.createElement(Yg,null),rm=class extends S.Component{constructor(r){super(r),this.state={location:r.location,revalidation:r.revalidation,error:r.error}}static getDerivedStateFromError(r){return{error:r}}static getDerivedStateFromProps(r,o){return o.location!==r.location||o.revalidation!=="idle"&&r.revalidation==="idle"?{error:r.error,location:r.location,revalidation:r.revalidation}:{error:r.error!==void 0?r.error:o.error,location:o.location,revalidation:r.revalidation||o.revalidation}}componentDidCatch(r,o){this.props.onError?this.props.onError(r,o):console.error("React Router caught the following error during render",r)}render(){let r=this.state.error;if(this.context&&typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){const c=Ug(r.digest);c&&(r=c)}let o=r!==void 0?S.createElement(Qt.Provider,{value:this.props.routeContext},S.createElement(cu.Provider,{value:r,children:this.props.component})):this.props.children;return this.context?S.createElement($g,{error:r},o):o}};rm.contextType=Mg;var Ic=new WeakMap;function $g({children:r,error:o}){let{basename:c}=S.useContext(Ut);if(typeof o=="object"&&o&&"digest"in o&&typeof o.digest=="string"){let u=Og(o.digest);if(u){let f=Ic.get(o);if(f)throw f;let x=em(u.location,c);if(I0&&!Ic.get(o))if(x.isExternal||u.reloadDocument)window.location.href=x.absoluteURL||x.to;else{const g=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(x.to,{replace:u.replace}));throw Ic.set(o,g),g}return S.createElement("meta",{httpEquiv:"refresh",content:`0;url=${x.absoluteURL||x.to}`})}}return r}function Vg({routeContext:r,match:o,children:c}){let u=S.useContext(Kl);return u&&u.static&&u.staticContext&&(o.route.errorElement||o.route.ErrorBoundary)&&(u.staticContext._deepestRenderedBoundaryId=o.route.id),S.createElement(Qt.Provider,{value:r},c)}function Qg(r,o=[],c=null,u=null,f=null){if(r==null){if(!c)return null;if(c.errors)r=c.matches;else if(o.length===0&&!c.initialized&&c.matches.length>0)r=c.matches;else return null}let x=r,g=c?.errors;if(g!=null){let v=x.findIndex(y=>y.route.id&&g?.[y.route.id]!==void 0);Ue(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(g).join(",")}`),x=x.slice(0,Math.min(x.length,v+1))}let b=!1,p=-1;if(c)for(let v=0;v<x.length;v++){let y=x[v];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(p=v),y.route.id){let{loaderData:N,errors:R}=c,O=y.route.loader&&!N.hasOwnProperty(y.route.id)&&(!R||R[y.route.id]===void 0);if(y.route.lazy||O){b=!0,p>=0?x=x.slice(0,p+1):x=[x[0]];break}}}let m=c&&u?(v,y)=>{u(v,{location:c.location,params:c.matches?.[0]?.params??{},unstable_pattern:Ag(c.matches),errorInfo:y})}:void 0;return x.reduceRight((v,y,N)=>{let R,O=!1,$=null,_=null;c&&(R=g&&y.route.id?g[y.route.id]:void 0,$=y.route.errorElement||Gg,b&&(p<0&&N===0?(cm("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),O=!0,_=null):p===N&&(O=!0,_=y.route.hydrateFallbackElement||null)));let G=o.concat(x.slice(0,N+1)),A=()=>{let V;return R?V=$:O?V=_:y.route.Component?V=S.createElement(y.route.Component,null):y.route.element?V=y.route.element:V=v,S.createElement(Vg,{match:y,routeContext:{outlet:v,matches:G,isDataRoute:c!=null},children:V})};return c&&(y.route.ErrorBoundary||y.route.errorElement||N===0)?S.createElement(rm,{location:c.location,revalidation:c.revalidation,component:$,error:R,children:A(),routeContext:{outlet:null,matches:G,isDataRoute:!0},onError:m}):A()},null)}function ou(r){return`${r} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Xg(r){let o=S.useContext(Kl);return Ue(o,ou(r)),o}function kg(r){let o=S.useContext(Ei);return Ue(o,ou(r)),o}function Zg(r){let o=S.useContext(Qt);return Ue(o,ou(r)),o}function du(r){let o=Zg(r),c=o.matches[o.matches.length-1];return Ue(c.route.id,`${r} can only be used on routes that contain a unique "id"`),c.route.id}function Kg(){return du("useRouteId")}function Jg(){let r=S.useContext(cu),o=kg("useRouteError"),c=du("useRouteError");return r!==void 0?r:o.errors?.[c]}function Wg(){let{router:r}=Xg("useNavigate"),o=du("useNavigate"),c=S.useRef(!1);return sm(()=>{c.current=!0}),S.useCallback(async(f,x={})=>{qt(c.current,nm),c.current&&(typeof f=="number"?await r.navigate(f):await r.navigate(f,{fromRouteId:o,...x}))},[r,o])}var U0={};function cm(r,o,c){!o&&!U0[r]&&(U0[r]=!0,qt(!1,c))}S.memo(Fg);function Fg({routes:r,future:o,state:c,onError:u}){return im(r,void 0,c,u,o)}function st(r){Ue(!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 Pg({basename:r="/",children:o=null,location:c,navigationType:u="POP",navigator:f,static:x=!1,unstable_useTransitions:g}){Ue(!Fn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let b=r.replace(/^\/*/,"/"),p=S.useMemo(()=>({basename:b,navigator:f,static:x,unstable_useTransitions:g,future:{}}),[b,f,x,g]);typeof c=="string"&&(c=Zl(c));let{pathname:m="/",search:v="",hash:y="",state:N=null,key:R="default"}=c,O=S.useMemo(()=>{let $=fa(m,b);return $==null?null:{location:{pathname:$,search:v,hash:y,state:N,key:R},navigationType:u}},[b,m,v,y,N,R,u]);return qt(O!=null,`<Router basename="${b}"> is not able to match the URL "${m}${v}${y}" because it does not start with the basename, so the <Router> won't render anything.`),O==null?null:S.createElement(Ut.Provider,{value:p},S.createElement(Wn.Provider,{children:o,value:O}))}function Ig({children:r,location:o}){return qg(su(r),o)}function su(r,o=[]){let c=[];return S.Children.forEach(r,(u,f)=>{if(!S.isValidElement(u))return;let x=[...o,f];if(u.type===S.Fragment){c.push.apply(c,su(u.props.children,x));return}Ue(u.type===st,`[${typeof u.type=="string"?u.type:u.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Ue(!u.props.index||!u.props.children,"An index route cannot have child routes.");let g={id:u.props.id||x.join("-"),caseSensitive:u.props.caseSensitive,element:u.props.element,Component:u.props.Component,index:u.props.index,path:u.props.path,middleware:u.props.middleware,loader:u.props.loader,action:u.props.action,hydrateFallbackElement:u.props.hydrateFallbackElement,HydrateFallback:u.props.HydrateFallback,errorElement:u.props.errorElement,ErrorBoundary:u.props.ErrorBoundary,hasErrorBoundary:u.props.hasErrorBoundary===!0||u.props.ErrorBoundary!=null||u.props.errorElement!=null,shouldRevalidate:u.props.shouldRevalidate,handle:u.props.handle,lazy:u.props.lazy};u.props.children&&(g.children=su(u.props.children,x)),c.push(g)}),c}var ji="get",Ni="application/x-www-form-urlencoded";function Ti(r){return typeof HTMLElement<"u"&&r instanceof HTMLElement}function ey(r){return Ti(r)&&r.tagName.toLowerCase()==="button"}function ty(r){return Ti(r)&&r.tagName.toLowerCase()==="form"}function ay(r){return Ti(r)&&r.tagName.toLowerCase()==="input"}function ly(r){return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}function ny(r,o){return r.button===0&&(!o||o==="_self")&&!ly(r)}function iu(r=""){return new URLSearchParams(typeof r=="string"||Array.isArray(r)||r instanceof URLSearchParams?r:Object.keys(r).reduce((o,c)=>{let u=r[c];return o.concat(Array.isArray(u)?u.map(f=>[c,f]):[[c,u]])},[]))}function sy(r,o){let c=iu(r);return o&&o.forEach((u,f)=>{c.has(f)||o.getAll(f).forEach(x=>{c.append(f,x)})}),c}var pi=null;function iy(){if(pi===null)try{new FormData(document.createElement("form"),0),pi=!1}catch{pi=!0}return pi}var ry=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function eu(r){return r!=null&&!ry.has(r)?(qt(!1,`"${r}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ni}"`),null):r}function cy(r,o){let c,u,f,x,g;if(ty(r)){let b=r.getAttribute("action");u=b?fa(b,o):null,c=r.getAttribute("method")||ji,f=eu(r.getAttribute("enctype"))||Ni,x=new FormData(r)}else if(ey(r)||ay(r)&&(r.type==="submit"||r.type==="image")){let b=r.form;if(b==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=r.getAttribute("formaction")||b.getAttribute("action");if(u=p?fa(p,o):null,c=r.getAttribute("formmethod")||b.getAttribute("method")||ji,f=eu(r.getAttribute("formenctype"))||eu(b.getAttribute("enctype"))||Ni,x=new FormData(b,r),!iy()){let{name:m,type:v,value:y}=r;if(v==="image"){let N=m?`${m}.`:"";x.append(`${N}x`,"0"),x.append(`${N}y`,"0")}else m&&x.append(m,y)}}else{if(Ti(r))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');c=ji,u=null,f=Ni,g=r}return x&&f==="text/plain"&&(g=x,x=void 0),{action:u,method:c.toLowerCase(),encType:f,formData:x,body:g}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function fu(r,o){if(r===!1||r===null||typeof r>"u")throw new Error(o)}function uy(r,o,c,u){let f=typeof r=="string"?new URL(r,typeof window>"u"?"server://singlefetch/":window.location.origin):r;return c?f.pathname.endsWith("/")?f.pathname=`${f.pathname}_.${u}`:f.pathname=`${f.pathname}.${u}`:f.pathname==="/"?f.pathname=`_root.${u}`:o&&fa(f.pathname,o)==="/"?f.pathname=`${o.replace(/\/$/,"")}/_root.${u}`:f.pathname=`${f.pathname.replace(/\/$/,"")}.${u}`,f}async function oy(r,o){if(r.id in o)return o[r.id];try{let c=await import(r.module);return o[r.id]=c,c}catch(c){return console.error(`Error loading route module \`${r.module}\`, reloading page...`),console.error(c),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function dy(r){return r==null?!1:r.href==null?r.rel==="preload"&&typeof r.imageSrcSet=="string"&&typeof r.imageSizes=="string":typeof r.rel=="string"&&typeof r.href=="string"}async function fy(r,o,c){let u=await Promise.all(r.map(async f=>{let x=o.routes[f.route.id];if(x){let g=await oy(x,c);return g.links?g.links():[]}return[]}));return gy(u.flat(1).filter(dy).filter(f=>f.rel==="stylesheet"||f.rel==="preload").map(f=>f.rel==="stylesheet"?{...f,rel:"prefetch",as:"style"}:{...f,rel:"prefetch"}))}function L0(r,o,c,u,f,x){let g=(p,m)=>c[m]?p.route.id!==c[m].route.id:!0,b=(p,m)=>c[m].pathname!==p.pathname||c[m].route.path?.endsWith("*")&&c[m].params["*"]!==p.params["*"];return x==="assets"?o.filter((p,m)=>g(p,m)||b(p,m)):x==="data"?o.filter((p,m)=>{let v=u.routes[p.route.id];if(!v||!v.hasLoader)return!1;if(g(p,m)||b(p,m))return!0;if(p.route.shouldRevalidate){let y=p.route.shouldRevalidate({currentUrl:new URL(f.pathname+f.search+f.hash,window.origin),currentParams:c[0]?.params||{},nextUrl:new URL(r,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof y=="boolean")return y}return!0}):[]}function my(r,o,{includeHydrateFallback:c}={}){return xy(r.map(u=>{let f=o.routes[u.route.id];if(!f)return[];let x=[f.module];return f.clientActionModule&&(x=x.concat(f.clientActionModule)),f.clientLoaderModule&&(x=x.concat(f.clientLoaderModule)),c&&f.hydrateFallbackModule&&(x=x.concat(f.hydrateFallbackModule)),f.imports&&(x=x.concat(f.imports)),x}).flat(1))}function xy(r){return[...new Set(r)]}function hy(r){let o={},c=Object.keys(r).sort();for(let u of c)o[u]=r[u];return o}function gy(r,o){let c=new Set;return new Set(o),r.reduce((u,f)=>{let x=JSON.stringify(hy(f));return c.has(x)||(c.add(x),u.push({key:x,link:f})),u},[])}function um(){let r=S.useContext(Kl);return fu(r,"You must render this element inside a <DataRouterContext.Provider> element"),r}function yy(){let r=S.useContext(Ei);return fu(r,"You must render this element inside a <DataRouterStateContext.Provider> element"),r}var mu=S.createContext(void 0);mu.displayName="FrameworkContext";function om(){let r=S.useContext(mu);return fu(r,"You must render this element inside a <HydratedRouter> element"),r}function py(r,o){let c=S.useContext(mu),[u,f]=S.useState(!1),[x,g]=S.useState(!1),{onFocus:b,onBlur:p,onMouseEnter:m,onMouseLeave:v,onTouchStart:y}=o,N=S.useRef(null);S.useEffect(()=>{if(r==="render"&&g(!0),r==="viewport"){let $=G=>{G.forEach(A=>{g(A.isIntersecting)})},_=new IntersectionObserver($,{threshold:.5});return N.current&&_.observe(N.current),()=>{_.disconnect()}}},[r]),S.useEffect(()=>{if(u){let $=setTimeout(()=>{g(!0)},100);return()=>{clearTimeout($)}}},[u]);let R=()=>{f(!0)},O=()=>{f(!1),g(!1)};return c?r!=="intent"?[x,N,{}]:[x,N,{onFocus:kn(b,R),onBlur:kn(p,O),onMouseEnter:kn(m,R),onMouseLeave:kn(v,O),onTouchStart:kn(y,R)}]:[!1,N,{}]}function kn(r,o){return c=>{r&&r(c),c.defaultPrevented||o(c)}}function vy({page:r,...o}){let{router:c}=um(),u=S.useMemo(()=>K0(c.routes,r,c.basename),[c.routes,r,c.basename]);return u?S.createElement(jy,{page:r,matches:u,...o}):null}function by(r){let{manifest:o,routeModules:c}=om(),[u,f]=S.useState([]);return S.useEffect(()=>{let x=!1;return fy(r,o,c).then(g=>{x||f(g)}),()=>{x=!0}},[r,o,c]),u}function jy({page:r,matches:o,...c}){let u=Ya(),{future:f,manifest:x,routeModules:g}=om(),{basename:b}=um(),{loaderData:p,matches:m}=yy(),v=S.useMemo(()=>L0(r,o,m,x,u,"data"),[r,o,m,x,u]),y=S.useMemo(()=>L0(r,o,m,x,u,"assets"),[r,o,m,x,u]),N=S.useMemo(()=>{if(r===u.pathname+u.search+u.hash)return[];let $=new Set,_=!1;if(o.forEach(A=>{let V=x.routes[A.route.id];!V||!V.hasLoader||(!v.some(re=>re.route.id===A.route.id)&&A.route.id in p&&g[A.route.id]?.shouldRevalidate||V.hasClientLoader?_=!0:$.add(A.route.id))}),$.size===0)return[];let G=uy(r,b,f.unstable_trailingSlashAwareDataRequests,"data");return _&&$.size>0&&G.searchParams.set("_routes",o.filter(A=>$.has(A.route.id)).map(A=>A.route.id).join(",")),[G.pathname+G.search]},[b,f.unstable_trailingSlashAwareDataRequests,p,u,x,v,o,r,g]),R=S.useMemo(()=>my(y,x),[y,x]),O=by(y);return S.createElement(S.Fragment,null,N.map($=>S.createElement("link",{key:$,rel:"prefetch",as:"fetch",href:$,...c})),R.map($=>S.createElement("link",{key:$,rel:"modulepreload",href:$,...c})),O.map(({key:$,link:_})=>S.createElement("link",{key:$,nonce:c.nonce,..._,crossOrigin:_.crossOrigin??c.crossOrigin})))}function Ny(...r){return o=>{r.forEach(c=>{typeof c=="function"?c(o):c!=null&&(c.current=o)})}}var Sy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Sy&&(window.__reactRouterVersion="7.13.0")}catch{}function Ey({basename:r,children:o,unstable_useTransitions:c,window:u}){let f=S.useRef();f.current==null&&(f.current=ag({window:u,v5Compat:!0}));let x=f.current,[g,b]=S.useState({action:x.action,location:x.location}),p=S.useCallback(m=>{c===!1?b(m):S.startTransition(()=>b(m))},[c]);return S.useLayoutEffect(()=>x.listen(p),[x,p]),S.createElement(Pg,{basename:r,children:o,location:g.location,navigationType:g.action,navigator:x,unstable_useTransitions:c})}var dm=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,xt=S.forwardRef(function({onClick:o,discover:c="render",prefetch:u="none",relative:f,reloadDocument:x,replace:g,state:b,target:p,to:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:N,...R},O){let{basename:$,unstable_useTransitions:_}=S.useContext(Ut),G=typeof m=="string"&&dm.test(m),A=em(m,$);m=A.to;let V=Lg(m,{relative:f}),[re,P,J]=py(u,R),Q=Ay(m,{replace:g,state:b,target:p,preventScrollReset:v,relative:f,viewTransition:y,unstable_defaultShouldRevalidate:N,unstable_useTransitions:_});function Z(te){o&&o(te),te.defaultPrevented||Q(te)}let B=S.createElement("a",{...R,...J,href:A.absoluteURL||V,onClick:A.isExternal||x?o:Z,ref:Ny(O,P),target:p,"data-discover":!G&&c==="render"?"true":void 0});return re&&!G?S.createElement(S.Fragment,null,B,S.createElement(vy,{page:V})):B});xt.displayName="Link";var fm=S.forwardRef(function({"aria-current":o="page",caseSensitive:c=!1,className:u="",end:f=!1,style:x,to:g,viewTransition:b,children:p,...m},v){let y=Pn(g,{relative:m.relative}),N=Ya(),R=S.useContext(Ei),{navigator:O,basename:$}=S.useContext(Ut),_=R!=null&&_y(y)&&b===!0,G=O.encodeLocation?O.encodeLocation(y).pathname:y.pathname,A=N.pathname,V=R&&R.navigation&&R.navigation.location?R.navigation.location.pathname:null;c||(A=A.toLowerCase(),V=V?V.toLowerCase():null,G=G.toLowerCase()),V&&$&&(V=fa(V,$)||V);const re=G!=="/"&&G.endsWith("/")?G.length-1:G.length;let P=A===G||!f&&A.startsWith(G)&&A.charAt(re)==="/",J=V!=null&&(V===G||!f&&V.startsWith(G)&&V.charAt(G.length)==="/"),Q={isActive:P,isPending:J,isTransitioning:_},Z=P?o:void 0,B;typeof u=="function"?B=u(Q):B=[u,P?"active":null,J?"pending":null,_?"transitioning":null].filter(Boolean).join(" ");let te=typeof x=="function"?x(Q):x;return S.createElement(xt,{...m,"aria-current":Z,className:B,ref:v,style:te,to:g,viewTransition:b},typeof p=="function"?p(Q):p)});fm.displayName="NavLink";var Ty=S.forwardRef(({discover:r="render",fetcherKey:o,navigate:c,reloadDocument:u,replace:f,state:x,method:g=ji,action:b,onSubmit:p,relative:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:N,...R},O)=>{let{unstable_useTransitions:$}=S.useContext(Ut),_=Ry(),G=zy(b,{relative:m}),A=g.toLowerCase()==="get"?"get":"post",V=typeof b=="string"&&dm.test(b),re=P=>{if(p&&p(P),P.defaultPrevented)return;P.preventDefault();let J=P.nativeEvent.submitter,Q=J?.getAttribute("formmethod")||g,Z=()=>_(J||P.currentTarget,{fetcherKey:o,method:Q,navigate:c,replace:f,state:x,relative:m,preventScrollReset:v,viewTransition:y,unstable_defaultShouldRevalidate:N});$&&c!==!1?S.startTransition(()=>Z()):Z()};return S.createElement("form",{ref:O,method:A,action:G,onSubmit:u?p:re,...R,"data-discover":!V&&r==="render"?"true":void 0})});Ty.displayName="Form";function Cy(r){return`${r} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function mm(r){let o=S.useContext(Kl);return Ue(o,Cy(r)),o}function Ay(r,{target:o,replace:c,state:u,preventScrollReset:f,relative:x,viewTransition:g,unstable_defaultShouldRevalidate:b,unstable_useTransitions:p}={}){let m=uu(),v=Ya(),y=Pn(r,{relative:x});return S.useCallback(N=>{if(ny(N,o)){N.preventDefault();let R=c!==void 0?c:Jn(v)===Jn(y),O=()=>m(r,{replace:R,state:u,preventScrollReset:f,relative:x,viewTransition:g,unstable_defaultShouldRevalidate:b});p?S.startTransition(()=>O()):O()}},[v,m,y,c,u,o,r,f,x,g,b,p])}function xu(r){qt(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let o=S.useRef(iu(r)),c=S.useRef(!1),u=Ya(),f=S.useMemo(()=>sy(u.search,c.current?null:o.current),[u.search]),x=uu(),g=S.useCallback((b,p)=>{const m=iu(typeof b=="function"?b(new URLSearchParams(f)):b);c.current=!0,x("?"+m,p)},[x,f]);return[f,g]}var wy=0,My=()=>`__${String(++wy)}__`;function Ry(){let{router:r}=mm("useSubmit"),{basename:o}=S.useContext(Ut),c=Kg(),u=r.fetch,f=r.navigate;return S.useCallback(async(x,g={})=>{let{action:b,method:p,encType:m,formData:v,body:y}=cy(x,o);if(g.navigate===!1){let N=g.fetcherKey||My();await u(N,c,g.action||b,{unstable_defaultShouldRevalidate:g.unstable_defaultShouldRevalidate,preventScrollReset:g.preventScrollReset,formData:v,body:y,formMethod:g.method||p,formEncType:g.encType||m,flushSync:g.flushSync})}else await f(g.action||b,{unstable_defaultShouldRevalidate:g.unstable_defaultShouldRevalidate,preventScrollReset:g.preventScrollReset,formData:v,body:y,formMethod:g.method||p,formEncType:g.encType||m,replace:g.replace,state:g.state,fromRouteId:c,flushSync:g.flushSync,viewTransition:g.viewTransition})},[u,f,o,c])}function zy(r,{relative:o}={}){let{basename:c}=S.useContext(Ut),u=S.useContext(Qt);Ue(u,"useFormAction must be used inside a RouteContext");let[f]=u.matches.slice(-1),x={...Pn(r||".",{relative:o})},g=Ya();if(r==null){x.search=g.search;let b=new URLSearchParams(x.search),p=b.getAll("index");if(p.some(v=>v==="")){b.delete("index"),p.filter(y=>y).forEach(y=>b.append("index",y));let v=b.toString();x.search=v?`?${v}`:""}}return(!r||r===".")&&f.route.index&&(x.search=x.search?x.search.replace(/^\?/,"?index&"):"?index"),c!=="/"&&(x.pathname=x.pathname==="/"?c:da([c,x.pathname])),Jn(x)}function _y(r,{relative:o}={}){let c=S.useContext(am);Ue(c!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:u}=mm("useViewTransitionState"),f=Pn(r,{relative:o});if(!c.isTransitioning)return!1;let x=fa(c.currentLocation.pathname,u)||c.currentLocation.pathname,g=fa(c.nextLocation.pathname,u)||c.nextLocation.pathname;return Si(f.pathname,g)!=null||Si(f.pathname,x)!=null}const xm=S.createContext({projects:[],activeProject:null,setActiveProject:()=>{},refreshProjects:()=>{}});function Jl(){return S.useContext(xm)}function Dy(){const[r,o]=S.useState([]),[c,u]=xu(),f=S.useCallback(async()=>{try{const m=await(await fetch("/api/projects")).json();m.ok&&o(m.data||[])}catch{}},[]);S.useEffect(()=>{f()},[f]);const x=c.get("project"),g=x?r.find(p=>p.id===x)||r[0]||null:r[0]||null,b=S.useCallback(p=>{u(m=>(m.set("project",p),m))},[u]);return{projects:r,activeProject:g,setActiveProject:b,refreshProjects:f}}function hm(r,o){const{timeout:c=3e4,retries:u=1,retryDelay:f=2e3}={},[x,g]=S.useState(null),[b,p]=S.useState(!0),[m,v]=S.useState(null),[y,N]=S.useState(0),[R,O]=S.useState(null),$=S.useCallback(()=>N(_=>_+1),[]);return S.useEffect(()=>{if(!r){p(!1),g(null);return}let _=!1;p(!0),v(null);async function G(A){const V=new AbortController,re=setTimeout(()=>V.abort(),c);try{const P=await fetch(r,{signal:V.signal});if(clearTimeout(re),!P.ok)throw new Error(`HTTP ${P.status}`);const J=await P.json();_||(g(J.data??J),v(null),O(new Date),p(!1))}catch(P){if(clearTimeout(re),_)return;if(A>0&&P.name!=="AbortError")return await new Promise(J=>setTimeout(J,f)),_?void 0:G(A-1);P.name==="AbortError"?v(`Request timed out (${Math.round(c/1e3)}s)`):v(String(P.message||P)),p(!1)}}return G(u),()=>{_=!0}},[r,y,c,u,f]),{data:x,loading:b,error:m,refetch:$,fetchedAt:R}}function Me(r,o){const{activeProject:c}=Jl(),u=r.includes("?")?"&":"?",f=c?`${r}${u}project=${c.id}`:r;return hm(f)}const hu=S.createContext(null),Oy=["heartbeat","increment-update","analytics-event","cost-update","notification","sync-update","sync-audit","error-detected","config-changed","activity","command-output","command-complete","job-progress","marketplace-scan","submission-update","verification-complete"];function Uy({url:r="/api/events",children:o}){const[c,u]=S.useState("connecting"),f=S.useRef(null),x=S.useRef(null),g=S.useRef(new Map),b=S.useCallback(()=>{f.current&&f.current.close(),u("connecting");const m=new EventSource(r);f.current=m;for(const v of Oy)m.addEventListener(v,y=>{let N;try{N=JSON.parse(y.data)}catch{return}const R=g.current.get(v);if(R)for(const O of R)try{O(N)}catch{}});m.onopen=()=>u("connected"),m.onerror=()=>{m.close(),u("disconnected"),x.current=setTimeout(()=>{f.current===m&&b()},3e3)}},[r]);S.useEffect(()=>(b(),()=>{x.current&&(clearTimeout(x.current),x.current=null),f.current?.close(),f.current=null}),[b]);const p=S.useCallback((m,v)=>(g.current.has(m)||g.current.set(m,new Set),g.current.get(m).add(v),()=>{const y=g.current.get(m);y&&(y.delete(v),y.size===0&&g.current.delete(m))}),[]);return n.jsx(hu.Provider,{value:{status:c,subscribe:p},children:o})}function Ge(r,o){const c=S.useContext(hu),u=S.useRef(o);u.current=o,S.useEffect(()=>{if(!c)return;const f=x=>u.current(x);return c.subscribe(r,f)},[c,r])}function Ly(){return S.useContext(hu)?.status??"disconnected"}const Hy=[{path:"/",label:"Overview",icon:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1"},{path:"/increments",label:"Increments",icon:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"},{path:"/analytics",label:"Analytics",icon:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"},{path:"/costs",label:"Costs",icon:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},{path:"/sync",label:"Sync",icon:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},{path:"/errors",label:"Errors",icon:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"},{path:"/activity",label:"Activity",icon:"M13 10V3L4 14h7v7l9-11h-7z"},{path:"/notifications",label:"Notifications",icon:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9",badge:!0},{path:"/config",label:"Config",icon:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z"},{path:"/plugins",label:"Plugins",icon:"M17 14v6m-3-3h6M6 10h2a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2zm10 0h2a2 2 0 002-2V6a2 2 0 00-2-2h-2a2 2 0 00-2 2v2a2 2 0 002 2zM6 20h2a2 2 0 002-2v-2a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2z"},{path:"/marketplace",label:"Marketplace",icon:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 100 4 2 2 0 000-4z"},{path:"/repos",label:"Repos",icon:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"},{path:"/services",label:"Services",icon:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"}];function By({d:r}){return n.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:r})})}function qy(){const{projects:r,activeProject:o,setActiveProject:c}=Jl(),[u]=xu(),{data:f}=Me("/api/overview"),[x,g]=S.useState(null),b=S.useCallback(N=>{const R=N;R?.pendingCount!=null&&g(R.pendingCount)},[]);Ge("notification",b);const p=Ly(),m=x??f?.notifications?.pendingCount??0,v=u.get("project"),y=N=>v?`${N}?project=${v}`:N;return n.jsxs("aside",{className:"w-56 bg-gray-900 border-r border-gray-800 flex flex-col h-screen sticky top-0",children:[n.jsx("div",{className:"px-4 py-5 border-b border-gray-800",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-8 h-8 bg-indigo-500 rounded-lg flex items-center justify-center",children:n.jsx("span",{className:"text-white font-bold text-sm",children:"SW"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-semibold text-sm",children:"SpecWeave"}),n.jsx("div",{className:"text-gray-500 text-xs",children:"Dashboard"})]})]})}),(r.length>0||v)&&n.jsxs("div",{className:"px-3 py-3 border-b border-gray-800",children:[n.jsx("label",{className:"text-[10px] text-gray-500 uppercase tracking-wider mb-1 block",children:"Project"}),n.jsxs("select",{value:o?.id||v||"",onChange:N=>{N.target.value==="__add__"?window.location.href=y("/config"):c(N.target.value)},className:"w-full bg-gray-800 border border-gray-700 text-gray-300 text-xs rounded-lg px-2 py-1.5 focus:ring-indigo-500 focus:border-indigo-500",children:[r.map(N=>n.jsx("option",{value:N.id,children:N.name},N.id)),v&&!r.find(N=>N.id===v)&&n.jsxs("option",{value:v,children:[decodeURIComponent(v).split(/[-/]/).pop()||v," (not registered)"]}),n.jsx("option",{value:"__add__",children:"+ Add project..."})]})]}),n.jsx("nav",{className:"flex-1 overflow-y-auto py-3 px-2",children:Hy.map(N=>n.jsxs(fm,{to:y(N.path),end:N.path==="/",className:({isActive:R})=>`flex items-center gap-3 px-3 py-2 rounded-lg text-sm mb-0.5 transition-colors ${R?"bg-indigo-500/10 text-indigo-400":"text-gray-400 hover:bg-gray-800 hover:text-gray-200"}`,children:[n.jsx(By,{d:N.icon}),n.jsx("span",{className:"flex-1",children:N.label}),N.badge&&m>0&&n.jsx("span",{className:"min-w-[18px] h-[18px] px-1 bg-rose-500 text-white text-[10px] font-bold rounded-full flex items-center justify-center",children:m>99?"99+":m})]},N.path))}),n.jsx("div",{className:"px-4 py-3 border-t border-gray-800",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${p==="connected"?"bg-emerald-400 pulse-dot":p==="connecting"?"bg-amber-400 pulse-dot":"bg-gray-500"}`}),n.jsx("span",{className:"text-xs text-gray-500",children:p==="connected"?"Connected":p==="connecting"?"Connecting...":"Disconnected"})]}),n.jsxs("span",{className:"text-[10px] text-gray-600",children:[r.length," project",r.length!==1?"s":""]})]})})]})}function Yy(){const{data:r}=hm("/api/health"),{activeProject:o}=Jl(),c=o?.name||"Project",u=r?.uptime?Gy(r.uptime):"...";return n.jsxs("header",{className:"h-14 bg-gray-900/50 backdrop-blur border-b border-gray-800 flex items-center justify-between px-6",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("h1",{className:"text-gray-200 font-medium text-sm",children:c}),n.jsx("span",{className:"text-gray-600 text-xs",children:"|"}),n.jsxs("span",{className:"text-gray-500 text-xs",children:["Uptime: ",u]})]}),n.jsx("div",{className:"flex items-center gap-4",children:n.jsxs("span",{className:"text-gray-500 text-xs",children:[r?.connections??0," client",(r?.connections??0)!==1?"s":""]})})]})}function Gy(r){if(r<60)return`${Math.floor(r)}s`;if(r<3600)return`${Math.floor(r/60)}m`;const o=Math.floor(r/3600),c=Math.floor(r%3600/60);return`${o}h ${c}m`}const $y={indigo:"from-indigo-500/10 to-indigo-500/5 border-indigo-500/20",emerald:"from-emerald-500/10 to-emerald-500/5 border-emerald-500/20",amber:"from-amber-500/10 to-amber-500/5 border-amber-500/20",rose:"from-rose-500/10 to-rose-500/5 border-rose-500/20",cyan:"from-cyan-500/10 to-cyan-500/5 border-cyan-500/20"},Vy={indigo:"text-indigo-400",emerald:"text-emerald-400",amber:"text-amber-400",rose:"text-rose-400",cyan:"text-cyan-400"};function ie({title:r,value:o,subtitle:c,tooltip:u,color:f="indigo"}){return n.jsxs("div",{className:`bg-gradient-to-br ${$y[f]} border rounded-xl p-4 relative group`,title:u,children:[n.jsx("div",{className:"text-gray-400 text-xs font-medium uppercase tracking-wider mb-2",children:r}),n.jsx("div",{className:`text-2xl font-bold ${Vy[f]}`,children:o}),c&&n.jsx("div",{className:"text-gray-500 text-xs mt-1",children:c}),u&&n.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2.5 py-1.5 bg-gray-800 border border-gray-700 rounded-lg text-[10px] text-gray-300 whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10 shadow-lg",children:[u,n.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 -mt-px border-4 border-transparent border-t-gray-800"})]})]})}const Qy={active:"#6366f1",completed:"#10b981",paused:"#f59e0b",planning:"#06b6d4",abandoned:"#ef4444",backlog:"#6b7280",ready_for_review:"#8b5cf6"};function Xy(r){return Qy[r]||"#6b7280"}function ky({segments:r,size:o=160,centerLabel:c,centerValue:u}){const f=r.reduce((p,m)=>p+m.value,0);if(f===0)return n.jsx("div",{className:"flex items-center justify-center",style:{width:o,height:o},children:n.jsx("span",{className:"text-gray-600 text-xs",children:"No data"})});const x=52,g=2*Math.PI*x;let b=0;return n.jsxs("div",{className:"relative inline-flex items-center justify-center",style:{width:o,height:o},children:[n.jsx("svg",{viewBox:"0 0 128 128",className:"w-full h-full -rotate-90",children:r.map((p,m)=>{const y=p.value/f*g,N=b;return b+=y,n.jsx("circle",{cx:"64",cy:"64",r:x,fill:"none",stroke:p.color,strokeWidth:"12",strokeDasharray:`${y} ${g-y}`,strokeDashoffset:-N,className:"transition-all duration-500"},m)})}),n.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[u!=null&&n.jsx("span",{className:"text-xl font-bold text-white",children:u}),c&&n.jsx("span",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:c})]})]})}function Zy(r){return Object.entries(r).filter(([o,c])=>c>0).map(([o,c])=>({label:o,value:c,color:Xy(o)}))}const Ky={default:"bg-gray-800 text-gray-300",success:"bg-emerald-500/15 text-emerald-400",warning:"bg-amber-500/15 text-amber-400",error:"bg-rose-500/15 text-rose-400",info:"bg-cyan-500/15 text-cyan-400"};function fe({label:r,variant:o="default"}){return n.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium ${Ky[o]}`,children:r})}function Ci(r){switch(r){case"active":case"running":return"info";case"completed":case"success":return"success";case"paused":case"pending":case"planning":return"warning";case"failed":case"abandoned":case"error":return"error";default:return"default"}}function Jy({size:r="md"}){const o={sm:"w-4 h-4",md:"w-6 h-6",lg:"w-8 h-8"};return n.jsxs("svg",{className:`${o[r]} animate-spin text-indigo-400`,viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function at(){return n.jsx("div",{className:"flex items-center justify-center h-64",children:n.jsx(Jy,{size:"lg"})})}function Xt({message:r,onRetry:o,title:c="Something went wrong"}){const u=r.toLowerCase().includes("timed out");return n.jsx("div",{className:"p-6",children:n.jsxs("div",{className:"bg-rose-900/30 border border-rose-700 rounded-lg px-5 py-4 space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-sm font-medium text-rose-300",children:c}),n.jsx("p",{className:"text-xs text-rose-400/80 mt-1",children:r})]}),o&&n.jsx("button",{onClick:o,className:"text-xs text-rose-400 hover:text-rose-200 px-3 py-1.5 border border-rose-700 rounded transition-colors flex-shrink-0",children:"Retry"})]}),u&&n.jsx("p",{className:"text-[10px] text-rose-400/60",children:"The server may be processing a large number of session logs. Try again in a moment."})]})})}function H0(r){switch(r){case"connected":return"success";case"sync_failed":return"warning";case"configured_never_synced":return"info";default:return"default"}}function Wy(r){switch(r){case"connected":return"Connected";case"sync_failed":return"Sync Failed";case"configured_never_synced":return"Ready";case"not_configured":return"Not Configured";default:return r||"Unknown"}}const tu=r=>r.billingContext?.planType==="subscription";function Fy(){const[r,o]=S.useState(0),{data:c,loading:u,error:f,refetch:x}=Me(`/api/overview?_r=${r}`),[g,b]=S.useState([]),{activeProject:p}=Jl();Ge("increment-update",()=>o(N=>N+1)),Ge("notification",()=>o(N=>N+1)),Ge("sync-update",()=>o(N=>N+1)),Ge("cost-update",()=>o(N=>N+1));const m=S.useRef(null);S.useEffect(()=>{if(!p||m.current===p.id)return;m.current=p.id;const N=`project=${p.id}`;fetch(`/api/activity/stream?limit=20&${N}`).then(R=>R.json()).then(R=>{R.ok&&Array.isArray(R.data)&&b(R.data)}).catch(()=>{})},[p]);const v=S.useCallback(N=>{b(R=>[N,...R].slice(0,20))},[]);if(Ge("activity",v),u)return n.jsx(at,{});if(f)return n.jsx(Xt,{message:f,onRetry:x});if(!c)return null;const y=Zy(c.project.statusBreakdown);return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("h2",{className:"text-lg font-semibold text-gray-200",children:[c.project.name||"Project"," Overview"]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(xt,{to:"/increments?status=active",className:"group",children:n.jsx(ie,{title:"Active Increments",value:c.project.activeIncrements,subtitle:`${c.project.totalIncrements} total`,color:"indigo"})}),n.jsx(xt,{to:"/increments?status=completed",className:"group",children:n.jsx(ie,{title:"Completed",value:c.project.completedIncrements,subtitle:`${Math.round(c.project.completedIncrements/Math.max(c.project.totalIncrements,1)*100)}% done`,color:"emerald"})}),n.jsx(xt,{to:"/costs",className:"group",children:n.jsx(ie,{title:tu(c.costs)?"Usage Value":"Total Cost",value:`$${c.costs.totalCost.toFixed(2)}`,subtitle:tu(c.costs)?`$${c.costs.billingContext?.monthlyAmount??"?"}/mo plan`:`${c.costs.sessionCount.toLocaleString()} sessions`,color:"amber"})}),n.jsx(xt,{to:"/analytics",className:"group",children:n.jsx(ie,{title:"Events Today",value:c.analytics.last24hEvents,subtitle:`${c.analytics.totalEvents.toLocaleString()} total`,color:"cyan"})})]}),n.jsx(Py,{}),tu(c.costs)&&n.jsxs("div",{className:"bg-indigo-500/10 border border-indigo-500/20 rounded-xl px-4 py-3 flex items-center gap-3",children:[n.jsx(fe,{label:"Subscription",variant:"info"}),n.jsx("span",{className:"text-xs text-gray-300",children:"Costs shown as API-equivalent usage value."})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Increment Status"}),n.jsx("div",{className:"flex items-center justify-center",children:n.jsx(ky,{segments:y,centerValue:c.project.totalIncrements,centerLabel:"total"})}),n.jsx("div",{className:"flex flex-wrap gap-2 mt-4 justify-center",children:y.map(N=>n.jsxs(xt,{to:`/increments?status=${N.label.toLowerCase()}`,className:"flex items-center gap-1.5 hover:opacity-80 transition-opacity",children:[n.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:N.color}}),n.jsxs("span",{className:"text-xs text-gray-500 hover:text-gray-300",children:[N.label," (",N.value,")"]})]},N.label))})]}),n.jsxs(xt,{to:"/sync",className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5 hover:border-gray-700 transition-colors block",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Sync Health"}),n.jsx("div",{className:"space-y-3",children:Object.entries(c.sync.platforms).length===0?n.jsx("p",{className:"text-gray-600 text-xs",children:"No sync platforms configured"}):Object.entries(c.sync.platforms).map(([N,R])=>n.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-sm text-gray-300 capitalize",children:N}),R.configDetail&&n.jsx("div",{className:"text-[10px] text-gray-600 mt-0.5",children:R.configDetail}),!R.configDetail&&R.lastImport&&n.jsxs("div",{className:"text-xs text-gray-600 mt-0.5",children:["Last: ",new Date(R.lastImport).toLocaleDateString()]})]}),n.jsx(fe,{label:Wy(R.connectionStatus||R.lastSyncResult),variant:H0(R.connectionStatus)!=="default"?H0(R.connectionStatus):Ci(R.lastSyncResult||"")})]},N))}),n.jsx("div",{className:"mt-4 pt-4 border-t border-gray-800",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500",children:"Notifications"}),n.jsxs("div",{className:"flex gap-2",children:[c.notifications.criticalCount>0&&n.jsx(xt,{to:"/notifications",onClick:N=>N.stopPropagation(),children:n.jsx(fe,{label:`${c.notifications.criticalCount} critical`,variant:"error"})}),n.jsx(xt,{to:"/notifications",onClick:N=>N.stopPropagation(),children:n.jsx(fe,{label:`${c.notifications.pendingCount} pending`,variant:c.notifications.pendingCount>0?"warning":"default"})})]})]})})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Live Activity"}),n.jsx(xt,{to:"/activity",className:"text-[10px] text-indigo-400 hover:text-indigo-300",children:"View all"})]}),n.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto custom-scrollbar",children:g.length===0?n.jsx("p",{className:"text-gray-600 text-xs",children:"No recent activity"}):g.map((N,R)=>n.jsxs("div",{className:"flex items-start gap-2 py-1 slide-in",children:[n.jsx("div",{className:`w-1.5 h-1.5 rounded-full mt-1.5 ${N.severity==="error"?"bg-rose-400":N.severity==="warning"?"bg-amber-400":"bg-gray-600"}`}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-xs text-gray-400 truncate",children:N.title}),n.jsxs("div",{className:"text-[10px] text-gray-600",children:[N.category,N.timestamp&&` · ${Iy(N.timestamp)}`]})]})]},R))})]})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Increment Types"}),n.jsx("div",{className:"flex gap-4 flex-wrap",children:Object.entries(c.project.typeBreakdown).map(([N,R])=>n.jsxs(xt,{to:`/increments?type=${N}`,className:"flex items-center gap-2 px-3 py-2 bg-gray-800/50 rounded-lg hover:bg-gray-800/80 transition-colors",children:[n.jsx("span",{className:"text-sm text-gray-300 capitalize",children:N}),n.jsx("span",{className:"text-xs text-gray-500 bg-gray-800 px-2 py-0.5 rounded",children:R})]},N))})]})]})}function Py(){const[r,o]=S.useState(0);Ge("error-detected",()=>o(R=>R+1));const{data:c}=Me(`/api/prompt-health?_r=${r}`);if(!c?.health||c.health.warningLevel==="normal")return null;const{health:u,alert:f}=c,x=f?.level==="emergency",g=u.warningLevel==="critical"||x,b=g?"border-rose-500/30":"border-amber-500/20",p=g?"bg-rose-500/10":"bg-amber-500/10",m=g?"text-rose-400":"text-amber-400",v=Math.round(u.baseline/1e3),y=Math.min(Math.round(u.baseline/2e5*100),100),N=g?"bg-rose-500":"bg-amber-500";return n.jsxs("div",{className:`${p} border ${b} rounded-xl px-4 py-3 space-y-2`,children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(fe,{label:g?"Critical":"Warning",variant:g?"error":"warning"}),n.jsxs("span",{className:`text-xs ${m}`,children:["Prompt baseline: ",v,"KB (",y,"% of context window)"]})]}),n.jsx(xt,{to:"/errors",className:"text-[10px] text-gray-500 hover:text-gray-300",children:"Details"})]}),n.jsx("div",{className:"w-full bg-gray-800 rounded-full h-1.5",children:n.jsx("div",{className:`${N} h-1.5 rounded-full`,style:{width:`${y}%`}})}),n.jsxs("div",{className:"flex gap-4 text-[10px] text-gray-500",children:[n.jsxs("span",{children:["CLAUDE.md: ",Math.round(u.claudeMdSize/1e3),"KB"]}),n.jsxs("span",{children:["MEMORY.md: ",Math.round(u.memoryMdSize/1e3),"KB"]}),n.jsxs("span",{children:["Skills: ",Math.round(u.skillBudget/1e3),"KB"]}),f&&n.jsxs("span",{className:m,children:["Compactions: ",f.compactionCount]})]})]})}function Iy(r){try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return""}}const Zn=new Map;let au=!1,gm=null;function ep(){au||(au=!0,queueMicrotask(()=>{au=!1;const r=gm;if(!r||Zn.size===0){Zn.clear();return}const o=new Map(Zn);Zn.clear(),r(c=>{const u=new URLSearchParams(c);for(const[f,{value:x,defaultValue:g}]of o)x&&x!==g?u.set(f,x):u.delete(f);return u})}))}function qa(r,o=""){const[c,u]=xu(),f=c.get(r)??o,x=S.useCallback(g=>{gm=u,Zn.set(r,{value:g,defaultValue:o}),ep()},[r,o,u]);return[f,x]}function gu({title:r,description:o}){return n.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[n.jsx("div",{className:"w-12 h-12 rounded-full bg-gray-800 flex items-center justify-center mb-4",children:n.jsx("svg",{className:"w-6 h-6 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})})}),n.jsx("h3",{className:"text-gray-400 text-sm font-medium",children:r}),o&&n.jsx("p",{className:"text-gray-600 text-xs mt-1 max-w-xs",children:o})]})}function tp(){const[r,o]=S.useState(0);Ge("increment-update",()=>o(O=>O+1));const{data:c,loading:u,error:f,refetch:x}=Me(`/api/increments?_r=${r}`),[g,b]=qa("status","all"),[p,m]=qa("type","all"),v=uu();if(u)return n.jsx(at,{});if(f)return n.jsx(Xt,{message:f,onRetry:x});if(!c)return null;const y=c.increments.filter(O=>!(g!=="all"&&O.status!==g||p!=="all"&&O.type!==p)),N=[...new Set(c.increments.map(O=>O.status))],R=[...new Set(c.increments.map(O=>O.type))];return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Increments"}),n.jsxs("span",{className:"text-sm text-gray-500",children:[c.increments.length," total"]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"text-xs text-gray-500 w-14",children:"Status:"}),n.jsxs("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:[n.jsx(vi,{label:"All",active:g==="all",onClick:()=>b("all")}),N.map(O=>n.jsx(vi,{label:O,active:g===O,onClick:()=>b(O),count:c.increments.filter($=>$.status===O).length},O))]})]}),n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"text-xs text-gray-500 w-14",children:"Type:"}),n.jsxs("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:[n.jsx(vi,{label:"All",active:p==="all",onClick:()=>m("all")}),R.map(O=>n.jsx(vi,{label:O,active:p===O,onClick:()=>m(O),count:c.increments.filter($=>$.type===O).length},O))]})]}),n.jsxs("span",{className:"text-xs text-gray-500",children:[y.length," matching"]})]}),y.length===0?n.jsx(gu,{title:"No increments match filters",description:"Try adjusting your filters"}):n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"ID"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Title"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Status"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Type"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Priority"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Tasks"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"ACs"}),n.jsx("th",{className:"text-left px-4 py-3 text-xs text-gray-500 font-medium uppercase",children:"Last Activity"})]})}),n.jsx("tbody",{children:y.map(O=>n.jsxs("tr",{onClick:()=>v(`/increments/${O.id}`),className:"border-b border-gray-800/50 hover:bg-gray-800/30 transition-colors cursor-pointer",children:[n.jsx("td",{className:"px-4 py-3",children:n.jsx("span",{className:"text-xs text-indigo-400 font-mono",children:O.id})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx("span",{className:"text-sm text-gray-300",children:O.title})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx(fe,{label:O.status,variant:Ci(O.status)})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx("span",{className:"text-xs text-gray-400 capitalize",children:O.type})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx(ap,{priority:O.priority})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx(B0,{completed:O.tasks.completed,total:O.tasks.total})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx(B0,{completed:O.acs.completed,total:O.acs.total})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx("span",{className:"text-xs text-gray-500",children:O.lastActivity?lp(O.lastActivity):"-"})})]},O.id))})]})})]})}function vi({label:r,active:o,onClick:c,count:u}){return n.jsxs("button",{onClick:c,className:`px-3 py-1 text-xs rounded-md transition-colors capitalize ${o?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:[r,u!==void 0&&n.jsx("span",{className:"ml-1 text-[10px] text-gray-500",children:u})]})}function B0({completed:r,total:o}){const c=o>0?Math.round(r/o*100):0;return n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-16 h-1.5 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full bg-indigo-500 rounded-full transition-all",style:{width:`${c}%`}})}),n.jsxs("span",{className:"text-xs text-gray-500",children:[r,"/",o]})]})}function ap({priority:r}){const o={P0:"text-rose-400 bg-rose-500/10",P1:"text-amber-400 bg-amber-500/10",P2:"text-cyan-400 bg-cyan-500/10",P3:"text-gray-400 bg-gray-500/10"};return n.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${o[r]||o.P2}`,children:r})}function lp(r){try{const o=new Date(r),u=new Date().getTime()-o.getTime(),f=Math.floor(u/6e4);if(f<1)return"Just now";if(f<60)return`${f}m ago`;const x=Math.floor(f/60);if(x<24)return`${x}h ago`;const g=Math.floor(x/24);return g<7?`${g}d ago`:o.toLocaleDateString()}catch{return r}}function np(){const[r,o]=S.useState("commands"),[c,u]=S.useState(!1),[f,x]=S.useState(0);Ge("analytics-event",()=>x(G=>G+1));const{data:g,loading:b,error:p,refetch:m,fetchedAt:v}=Me(`/api/analytics/summary?_r=${f}`),{data:y,loading:N,refetch:R}=Me(`/api/analytics/skills?_r=${f}`);if(b||N)return n.jsx(at,{});if(p)return n.jsx(Xt,{message:p,onRetry:m});if(!g)return null;const O=g.topCommands?.reduce((G,A)=>G+A.count,0)||0,$=g.topSkills?.reduce((G,A)=>G+A.count,0)||0,_=g.topAgents?.reduce((G,A)=>G+A.count,0)||0;return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Analytics"}),n.jsxs("div",{className:"flex items-center gap-3",children:[v&&n.jsxs("span",{className:"text-[10px] text-gray-600",children:["Updated ",v.toLocaleTimeString()]}),n.jsxs("span",{className:"text-sm text-gray-500",children:[g.totalEvents.toLocaleString()," total events"]}),n.jsx("button",{onClick:()=>{u(!0),m(),R(),setTimeout(()=>u(!1),600)},disabled:c,className:"p-1.5 text-gray-500 hover:text-gray-300 hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50",title:"Refresh analytics",children:n.jsx("svg",{className:`w-4 h-4 ${c?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Total Events",value:g.totalEvents.toLocaleString(),subtitle:`${g.successRate}% success rate`,color:"indigo",tooltip:`${g.totalEvents} events tracked from analytics JSONL`}),n.jsx(ie,{title:"Commands",value:O.toLocaleString(),subtitle:`${g.topCommands?.length||0} unique`,color:"cyan",tooltip:`${O} total command invocations across ${g.topCommands?.length||0} distinct commands`}),n.jsx(ie,{title:"Skills",value:$.toLocaleString(),subtitle:`${g.topSkills?.length||0} unique`,color:"emerald",tooltip:`${$} total skill activations across ${g.topSkills?.length||0} distinct skills`}),n.jsx(ie,{title:"Agents",value:_.toLocaleString(),subtitle:`${g.topAgents?.length||0} unique`,color:"amber",tooltip:`${_} agent spawns across ${g.topAgents?.length||0} distinct agent types`})]}),n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:[{key:"commands",label:"Commands"},{key:"skills",label:"Skills"},{key:"agents",label:"Agents"},{key:"daily",label:"Daily Trends"}].map(G=>n.jsx("button",{onClick:()=>o(G.key),className:`flex-1 px-3 py-1.5 text-xs rounded-md transition-colors ${r===G.key?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:G.label},G.key))}),r==="commands"&&n.jsx(sp,{commands:g.topCommands||[]}),r==="skills"&&n.jsx(ip,{skills:y||[]}),r==="agents"&&n.jsx(rp,{agents:g.topAgents||[]}),r==="daily"&&n.jsx(cp,{days:g.dailySummaries||[]})]})}function sp({commands:r}){if(r.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No command data available"})});const o=[...r].sort((u,f)=>f.count-u.count),c=o[0]?.count||1;return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Top Commands"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500 w-12",children:"Rank"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Command"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Usage"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Count"})]})}),n.jsx("tbody",{children:o.map((u,f)=>{const x=Math.max(2,u.count/c*100);return n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsxs("td",{className:"px-4 py-2.5 text-xs text-gray-600",children:["#",f+1]}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-sm text-gray-300 font-mono",children:u.name})}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("div",{className:"w-full h-1.5 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-indigo-500/60 transition-all",style:{width:`${x}%`}})})}),n.jsx("td",{className:"px-4 py-2.5 text-sm font-mono text-gray-400 text-right",children:u.count.toLocaleString()})]},u.name)})})]})]})}function ip({skills:r}){const o=[...r].sort((c,u)=>u.count-c.count);return o.length===0?n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No skill usage data available"})}):n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Skill Usage Leaderboard"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500 w-12",children:"Rank"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Skill Name"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Plugin"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Invocations"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Success Rate"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Last Used"})]})}),n.jsx("tbody",{children:o.map((c,u)=>{const f=c.count>0?Math.round(c.successCount/c.count*100):100,x=f>=90?"success":f>=70?"warning":"error";return n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsxs("td",{className:"px-4 py-2.5 text-xs text-gray-600",children:["#",u+1]}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-sm text-gray-300 font-mono",children:c.name})}),n.jsx("td",{className:"px-4 py-2.5",children:c.plugin&&n.jsx("span",{className:"text-[10px] text-gray-600 bg-gray-800 px-1.5 py-0.5 rounded",children:c.plugin})}),n.jsx("td",{className:"px-4 py-2.5 text-sm font-mono text-gray-400 text-right",children:c.count.toLocaleString()}),n.jsx("td",{className:"px-4 py-2.5 text-right",children:n.jsx(fe,{label:`${f}%`,variant:x})}),n.jsx("td",{className:"px-4 py-2.5 text-xs text-gray-600 text-right whitespace-nowrap",children:c.lastUsed?up(c.lastUsed):"-"})]},c.name)})})]})]})}function rp({agents:r}){if(r.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No agent data available"})});const o=[...r].sort((u,f)=>f.count-u.count),c=o[0]?.count||1;return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Top Agents"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500 w-12",children:"Rank"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Agent"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Usage"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Count"})]})}),n.jsx("tbody",{children:o.map((u,f)=>{const x=Math.max(2,u.count/c*100);return n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsxs("td",{className:"px-4 py-2.5 text-xs text-gray-600",children:["#",f+1]}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("span",{className:"text-sm text-gray-300",children:u.name})}),n.jsx("td",{className:"px-4 py-2.5",children:n.jsx("div",{className:"w-full h-1.5 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full bg-cyan-500/60 transition-all",style:{width:`${x}%`}})})}),n.jsx("td",{className:"px-4 py-2.5 text-sm font-mono text-gray-400 text-right",children:u.count.toLocaleString()})]},u.name)})})]})]})}function cp({days:r}){const o=r.slice(-14);if(o.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No daily data available"})});const c=Math.max(...o.map(x=>x.totalEvents),1),u=o.reduce((x,g)=>x+g.totalEvents,0),f=Math.round(u/o.length);return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[n.jsx(ie,{title:"Period Total",value:u.toLocaleString(),subtitle:`Last ${o.length} days`,color:"indigo"}),n.jsx(ie,{title:"Daily Average",value:f.toLocaleString(),color:"cyan"}),n.jsx(ie,{title:"Peak Day",value:c.toLocaleString(),subtitle:o.find(x=>x.totalEvents===c)?.date||"",color:"emerald"})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:["Daily Events (Last ",o.length," Days)"]}),n.jsx("div",{className:"flex items-end gap-1.5 h-40",children:o.map(x=>{const g=Math.max(2,x.totalEvents/c*100),b=x.date.slice(5);return n.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1",children:[n.jsx("span",{className:"text-[9px] text-gray-500",children:x.totalEvents}),n.jsx("div",{className:"w-full bg-indigo-500/40 rounded-t hover:bg-indigo-500/60 transition-colors cursor-default",style:{height:`${g}%`},title:`${x.date}: ${x.totalEvents} events`}),n.jsx("span",{className:"text-[8px] text-gray-700",children:b})]},x.date)})})]})]})}function up(r){if(!r)return"";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return""}}function ym({items:r,maxBars:o=10}){const c=[...r].sort((f,x)=>x.value-f.value).slice(0,o),u=Math.max(...c.map(f=>f.value),1);return n.jsx("div",{className:"space-y-2",children:c.map((f,x)=>n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:"text-xs text-gray-400 w-28 truncate text-right",title:f.label,children:f.label}),n.jsx("div",{className:"flex-1 h-5 bg-gray-800 rounded overflow-hidden",children:n.jsx("div",{className:"h-full rounded transition-all duration-500",style:{width:`${f.value/u*100}%`,backgroundColor:f.color||"#6366f1"}})}),n.jsx("span",{className:"text-xs text-gray-500 w-10 text-right",children:f.value})]},x))})}function op(){const[r,o]=S.useState("overview"),[c,u]=S.useState(null),[f,x]=S.useState(0);Ge("cost-update",()=>x(A=>A+1));const{data:g,loading:b,error:p,refetch:m}=Me(`/api/costs/summary?_r=${f}`);if(b)return n.jsx(at,{});if(p)return n.jsx(Xt,{message:p,onRetry:m});if(!g)return null;const v=g.sessions||[],y=g.billingContext?.planType==="subscription",N=g.modelBreakdown?Object.entries(g.modelBreakdown).map(([A,V])=>({model:A,...V})).sort((A,V)=>V.cost-A.cost):fp(v),R=v.reduce((A,V)=>A+(V.inputTokens||0),0),O=v.reduce((A,V)=>A+(V.outputTokens||0),0),$=v.reduce((A,V)=>A+(V.cacheReadTokens||0),0),_=v.reduce((A,V)=>A+(V.cacheWriteTokens||0),0),G=R+O+$+_;return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Token Usage & Costs"}),y&&n.jsxs("div",{className:"bg-indigo-500/10 border border-indigo-500/20 rounded-xl px-4 py-3 flex items-center gap-3",children:[n.jsx(fe,{label:"Subscription",variant:"info"}),n.jsxs("span",{className:"text-xs text-gray-300",children:[g.billingContext?.monthlyAmount?`$${g.billingContext.monthlyAmount}/mo plan. `:"","Costs shown as API-equivalent value for usage analytics."]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:y?"API-Equivalent Value":"Total Cost",value:`$${g.totalCost.toFixed(2)}`,subtitle:y&&g.billingContext?.monthlyAmount?`Your plan: $${g.billingContext.monthlyAmount}/mo`:void 0,color:"amber"}),n.jsx(ie,{title:y?"Cache Efficiency":"Cache Savings",value:`$${g.totalSavings.toFixed(2)}`,subtitle:y?"API-equivalent savings from cache":void 0,color:"emerald"}),n.jsx(ie,{title:"Total Tokens",value:Xl(g.totalTokens),subtitle:mp(g.totalTokens),color:"indigo"}),n.jsx(ie,{title:"Sessions",value:g.sessionCount.toLocaleString(),color:"cyan"})]}),n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:["overview","sessions"].map(A=>n.jsx("button",{onClick:()=>o(A),className:`flex-1 px-3 py-1.5 text-xs rounded-md transition-colors ${r===A?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:A==="overview"?"Breakdown":`Sessions (${v.length})`},A))}),r==="overview"&&n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:y?"Usage Value by Model":"Cost by Model"}),N.length>0?n.jsx(ym,{items:N.map(A=>({label:A.model,value:parseFloat(A.cost.toFixed(2)),color:"#f59e0b"}))}):n.jsx("p",{className:"text-gray-600 text-xs",children:"No model data"})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Token Breakdown"}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(bi,{label:"Input",value:R,total:G,color:"bg-indigo-500"}),n.jsx(bi,{label:"Output",value:O,total:G,color:"bg-cyan-500"}),$>0&&n.jsx(bi,{label:"Cache Read",value:$,total:G,color:"bg-emerald-500"}),_>0&&n.jsx(bi,{label:"Cache Write",value:_,total:G,color:"bg-amber-500"})]})]}),N.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden lg:col-span-2",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Model Details"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Model"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Sessions"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Tokens"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Cost"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Avg/Session"})]})}),n.jsx("tbody",{children:N.map(A=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsx("td",{className:"px-4 py-2 text-sm text-gray-300",children:A.model}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:A.sessions.toLocaleString()}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:Xl(A.tokens)}),n.jsxs("td",{className:"px-4 py-2 text-xs text-amber-400 text-right",children:["$",A.cost.toFixed(2)]}),n.jsxs("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:["$",A.sessions>0?(A.cost/A.sessions).toFixed(4):"0"]})]},A.model))})]})]})]}),r==="sessions"&&n.jsx(dp,{sessions:v,expandedSession:c,onToggle:A=>u(c===A?null:A)})]})}const lu=30;function dp({sessions:r,expandedSession:o,onToggle:c}){const[u,f]=S.useState(0);if(r.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No session data available"})});const x=Math.ceil(r.length/lu),g=u*lu,b=g+lu,p=r.slice(g,b);return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsxs("div",{className:"px-5 py-3 border-b border-gray-800 flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Recent Sessions"}),n.jsxs("span",{className:"text-xs text-gray-500",children:[g+1,"-",Math.min(b,r.length)," of ",r.length]})]}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500 w-8"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Session"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Model"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Input"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Output"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Cache"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Cost"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Duration"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"When"})]})}),n.jsx("tbody",{children:p.map(m=>{const v=m.sessionId||"-",y=o===v,N=(m.cacheReadTokens||0)+(m.cacheWriteTokens||0);return n.jsxs(S.Fragment,{children:[n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30 cursor-pointer",onClick:()=>c(v),children:[n.jsx("td",{className:"px-4 py-2 text-xs text-gray-600",children:n.jsx("span",{className:`inline-block transition-transform ${y?"rotate-90":""}`,children:"▸"})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400 font-mono",children:v.slice(0,8)}),n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:m.model||"unknown",variant:"default"})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:Xl(m.inputTokens)}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:Xl(m.outputTokens)}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:N>0?Xl(N):"-"}),n.jsxs("td",{className:"px-4 py-2 text-xs text-amber-400 text-right",children:["$",m.cost?.toFixed(4)||"0.0000"]}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:m.duration?q0(m.duration):"-"}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500",children:xp(m.timestamp)})]}),y&&n.jsx("tr",{className:"border-b border-gray-800/50",children:n.jsx("td",{colSpan:9,className:"px-6 py-3 bg-gray-800/20",children:n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-xs",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Input Tokens"}),n.jsx("span",{className:"text-gray-300 font-mono",children:m.inputTokens.toLocaleString()})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Output Tokens"}),n.jsx("span",{className:"text-gray-300 font-mono",children:m.outputTokens.toLocaleString()})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Cache Write"}),n.jsx("span",{className:"text-gray-300 font-mono",children:(m.cacheWriteTokens||0).toLocaleString()})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Cache Read"}),n.jsx("span",{className:"text-gray-300 font-mono",children:(m.cacheReadTokens||0).toLocaleString()})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Cost"}),n.jsxs("span",{className:"text-amber-400 font-mono",children:["$",m.cost?.toFixed(6)||"0"]})]}),m.savings!=null&&m.savings>0&&n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Cache Savings"}),n.jsxs("span",{className:"text-emerald-400 font-mono",children:["$",m.savings.toFixed(6)]})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Duration"}),n.jsx("span",{className:"text-gray-300",children:m.duration?q0(m.duration):"-"})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500 block mb-1",children:"Session ID"}),n.jsx("span",{className:"text-gray-400 font-mono text-[10px]",children:m.sessionId})]})]})})})]},v)})})]}),x>1&&n.jsxs("div",{className:"px-5 py-3 border-t border-gray-800 flex items-center justify-between",children:[n.jsx("button",{onClick:()=>f(m=>Math.max(0,m-1)),disabled:u===0,className:"px-3 py-1 text-xs text-gray-400 hover:text-gray-200 border border-gray-700 rounded disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Previous"}),n.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(x,7)},(m,v)=>{let y;return x<=7||u<3?y=v:u>x-4?y=x-7+v:y=u-3+v,n.jsx("button",{onClick:()=>f(y),className:`w-7 h-7 text-xs rounded transition-colors ${u===y?"bg-indigo-600 text-white":"text-gray-500 hover:text-gray-300 hover:bg-gray-800"}`,children:y+1},y)})}),n.jsx("button",{onClick:()=>f(m=>Math.min(x-1,m+1)),disabled:u>=x-1,className:"px-3 py-1 text-xs text-gray-400 hover:text-gray-200 border border-gray-700 rounded disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Next"})]})]})}function bi({label:r,value:o,total:c,color:u}){const f=c>0?o/c*100:0,x={"bg-indigo-500":"rgb(99 102 241 / 0.6)","bg-cyan-500":"rgb(6 182 212 / 0.6)","bg-emerald-500":"rgb(16 185 129 / 0.6)","bg-amber-500":"rgb(245 158 11 / 0.6)"};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-1",children:[n.jsx("span",{className:"text-xs text-gray-400",children:r}),n.jsxs("span",{className:"text-xs text-gray-500",children:[Xl(o)," (",f.toFixed(1),"%)"]})]}),n.jsx("div",{className:"h-2 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full rounded-full",style:{width:`${f}%`,backgroundColor:x[u]||u}})})]})}function fp(r){const o=new Map;for(const c of r){const u=c.model||"unknown",f=o.get(u)||{cost:0,tokens:0,sessions:0};f.cost+=c.cost||0,f.tokens+=(c.inputTokens||0)+(c.outputTokens||0),f.sessions++,o.set(u,f)}return Array.from(o.entries()).map(([c,u])=>({model:c,...u})).sort((c,u)=>u.cost-c.cost)}function Xl(r){return r?r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:String(r):"0"}function mp(r){return r?r.toLocaleString():"0"}function q0(r){const o=Math.round(r);if(o<60)return`${o}s`;const c=Math.floor(o/60),u=o%60;return c<60?`${c}m ${u}s`:`${Math.floor(c/60)}h ${c%60}m`}function xp(r){if(!r)return"-";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return"-"}}function Ai(){const[r,o]=S.useState(!1),[c,u]=S.useState(null),[f,x]=S.useState(null),[g,b]=S.useState([]),[p,m]=S.useState("idle"),v=S.useRef(null),y=S.useRef(null);Ge("command-output",O=>{const $=O;y.current&&$.executionId===y.current&&$.line&&b(_=>[..._,$.line])}),Ge("command-complete",O=>{const $=O;if(y.current&&$.executionId===y.current){if(v.current&&(clearTimeout(v.current),v.current=null),o(!1),$.exitCode===0)m("success"),b(_=>[..._,"Command completed successfully."]);else{m("error");const _=`Command failed (exit code ${$.exitCode??"unknown"})`;x(_),b(G=>[...G,_])}y.current=null}}),S.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const N=S.useCallback(async O=>{o(!0),x(null),b([`> specweave ${O}`]),m("running");try{const _=await(await fetch(`/api/commands/${O}`,{method:"POST"})).json();return _.ok?(u(_.data),y.current=_.data?.id||null,v.current=setTimeout(()=>{y.current&&(y.current=null,o(!1),m("error"),x("Command timed out after 60 seconds"),b(G=>[...G,"Timed out after 60 seconds."]))},6e4),_.data):(x(_.error||"Command failed"),m("error"),b(G=>[...G,`Error: ${_.error||"Command failed"}`]),o(!1),null)}catch($){return x(String($)),m("error"),b(_=>[..._,`Error: ${String($)}`]),o(!1),null}},[]),R=S.useCallback(()=>{o(!1),u(null),x(null),b([]),m("idle"),y.current=null,v.current&&(clearTimeout(v.current),v.current=null)},[]);return{execute:N,running:r,result:c,error:f,output:g,status:p,reset:R}}function hp(r){switch(r){case"connected":return"success";case"sync_failed":return"warning";case"configured_never_synced":return"info";default:return"default"}}function gp(r){switch(r){case"connected":return"Connected";case"sync_failed":return"Sync Failed";case"configured_never_synced":return"Ready";case"not_configured":return"Not Configured";default:return r||"Unknown"}}function yp(){const[r,o]=S.useState("health"),[c,u]=S.useState(null),[f,x]=S.useState(0);Ge("sync-update",()=>x(J=>J+1));const{data:g,loading:b,error:p,refetch:m}=Me(`/api/sync/status?_r=${f}`),{data:v,loading:y}=Me(`/api/sync/audit?limit=100&_r=${f}`),{data:N,loading:R}=Me(`/api/sync/audit/summary?_r=${f}`),{execute:O,running:$}=Ai(),_=async J=>{u(J);try{const Q=new URLSearchParams(window.location.search).get("project")||"",Z=Q?`?platform=${J}&project=${Q}`:`?platform=${J}`;await fetch(`/api/sync/verify${Z}`,{method:"POST"}),m()}catch{}u(null)};if(b||y||R)return n.jsx(at,{});if(p)return n.jsx(Xt,{message:p,onRetry:m});if(!g)return null;const G=Object.entries(g.platforms).filter(([J])=>["github","jira","ado"].includes(J)),A=v?.length||0,V=v?.filter(J=>J.result==="error").length||0,re=v?.filter(J=>J.conflict)||[],P=G.filter(([,J])=>J.connectionStatus==="connected").length;return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Sync Health"}),n.jsx("button",{onClick:()=>O("sync-push"),disabled:$,className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:$?"Syncing...":"Sync Now"})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Platforms",value:G.length,subtitle:`${P} connected`,color:"indigo"}),n.jsx(ie,{title:"Audit Entries",value:A,color:"cyan"}),n.jsx(ie,{title:"Errors",value:V,color:"rose"}),n.jsx(ie,{title:"Conflicts",value:re.length,color:"amber"})]}),n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:["health","audit","conflicts"].map(J=>n.jsx("button",{onClick:()=>o(J),className:`flex-1 px-3 py-1.5 text-xs rounded-md transition-colors ${r===J?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:J==="health"?"Platform Health":J==="audit"?"Audit Log":`Conflicts (${re.length})`},J))}),r==="health"&&n.jsx(n.Fragment,{children:G.length===0?n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No sync platforms configured"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"Configure GitHub, JIRA, or ADO in your config"})]}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:G.map(([J,Q])=>{const Z=N?.[J],B=Q.connectionStatus||"unknown";return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(pm,{platform:J}),n.jsxs("div",{children:[n.jsx("span",{className:"text-sm font-medium text-gray-300 capitalize",children:J}),Q.configDetail&&n.jsx("div",{className:"text-[10px] text-gray-600 mt-0.5",children:Q.configDetail})]})]}),n.jsx(fe,{label:gp(B),variant:hp(B)})]}),Q.diagnosticMessage&&n.jsx("div",{className:"text-xs text-gray-500 mb-3 p-2 bg-gray-800/30 rounded-lg",children:Q.diagnosticMessage}),B==="not_configured"&&n.jsx(xt,{to:"/config",className:"block text-center text-xs text-indigo-400 hover:text-indigo-300 py-2 border border-gray-800 rounded-lg hover:border-indigo-500/30 transition-colors",children:"Configure in Settings"}),B==="configured_never_synced"&&n.jsx("button",{onClick:()=>_(J),disabled:c===J,className:"w-full text-xs text-indigo-400 hover:text-indigo-300 py-2 border border-gray-800 rounded-lg hover:border-indigo-500/30 transition-colors disabled:opacity-50",children:c===J?"Verifying...":"Verify Connection"}),B==="sync_failed"&&n.jsx("button",{onClick:()=>_(J),disabled:c===J,className:"w-full text-xs text-amber-400 hover:text-amber-300 py-2 border border-amber-500/20 rounded-lg hover:border-amber-500/40 transition-colors disabled:opacity-50",children:c===J?"Verifying...":"Retry Sync"}),n.jsxs("div",{className:"space-y-2 mt-3",children:[Q.lastImport&&n.jsx(Ql,{label:"Last Import",value:new Date(Q.lastImport).toLocaleString()}),B==="connected"&&!Q.lastImport&&n.jsx(Ql,{label:"Status",value:"Connected, no imports yet"}),Q.lastImportCount!=null&&n.jsx(Ql,{label:"Items Imported",value:Q.lastImportCount.toLocaleString()}),Q.lastSkippedCount!=null&&Q.lastSkippedCount>0&&n.jsx(Ql,{label:"Skipped",value:Q.lastSkippedCount.toLocaleString()}),Z&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-t border-gray-800 my-2"}),n.jsx(Ql,{label:"Total Ops",value:Z.total.toLocaleString()}),n.jsx(Ql,{label:"Success",value:Z.success.toLocaleString()}),Z.errors>0&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500",children:"Errors"}),n.jsx(fe,{label:String(Z.errors),variant:"error"})]})]})]})]},J)})})}),r==="audit"&&n.jsx(Y0,{entries:v||[]}),r==="conflicts"&&n.jsx(Y0,{entries:re}),g.lastUpdated&&n.jsxs("p",{className:"text-xs text-gray-600",children:["Last metadata update: ",new Date(g.lastUpdated).toLocaleString()]})]})}function Y0({entries:r}){if(r.length===0)return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No audit entries"})});const o={success:"success",error:"error",denied:"warning",skipped:"default"};return n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Time"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Platform"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Operation"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Item"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Direction"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Result"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Duration"})]})}),n.jsx("tbody",{children:r.map((c,u)=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500",children:pp(c.timestamp)}),n.jsx("td",{className:"px-4 py-2",children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(pm,{platform:c.platform}),n.jsx("span",{className:"text-xs text-gray-400 capitalize",children:c.platform})]})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400",children:c.operation}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 font-mono max-w-[120px] truncate",children:c.itemId||"-"}),n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:c.direction,variant:c.direction==="push"?"info":"default"})}),n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:c.result,variant:o[c.result]||"default"})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-600 text-right",children:c.duration?`${c.duration}ms`:"-"})]},u))})]})})}function Ql({label:r,value:o}){return n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500",children:r}),n.jsx("span",{className:"text-xs text-gray-400",children:o})]})}function pm({platform:r}){const o={github:"bg-gray-700",jira:"bg-blue-700",ado:"bg-blue-600"};return n.jsx("div",{className:`w-5 h-5 rounded ${o[r]||"bg-gray-700"} flex items-center justify-center`,children:n.jsx("span",{className:"text-[9px] text-white font-bold",children:r[0]?.toUpperCase()})})}function pp(r){if(!r)return"-";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return"-"}}const vm={prompt_too_long:"error",api_error:"warning",tool_failure:"info",hook_error:"default",rate_limit:"warning",unknown:"default"},Kn=50;function vp(){const[r,o]=qa("tab","groups"),[c,u]=qa("type",""),[f,x]=qa("q",""),[g,b]=qa("session",""),[p,m]=S.useState(0),[v,y]=S.useState(f),N=p*Kn,R=c?`&type=${encodeURIComponent(c)}`:"",O=f?`&search=${encodeURIComponent(f)}`:"",[$,_]=S.useState(0);Ge("error-detected",()=>_(I=>I+1));const{data:G,loading:A,error:V}=Me(r==="groups"?`/api/errors/groups?_r=${$}`:""),{data:re,loading:P,error:J}=Me(r==="errors"||r==="groups"?`/api/errors/recent?limit=${Kn}&offset=${N}${R}${O}&_r=${$}`:""),{data:Q,loading:Z,error:B}=Me(r==="sessions"||g?`/api/errors/sessions?limit=50&_r=${$}`:""),{data:te,loading:le,error:Oe}=Me(r==="timeline"?`/api/errors/timeline?bucket=60&_r=${$}`:""),lt=S.useCallback(()=>{x(v.trim()),m(0),v.trim()&&o("errors")},[v,x,o]);S.useEffect(()=>{g&&Q&&!Q.find(I=>I.sessionId===g)&&b("")},[g,Q,b]);const Re=r==="groups"&&A||r==="errors"&&P||r==="timeline"&&le||r==="sessions"&&Z,$e=V||J||B||Oe,U=re?.total||0,k=re?.errors||[],ne=G?.length||0,X=G?.reduce((I,Ze)=>I+Ze.sessions,0)||0,me=G?.[0]?.type||"-",T=g?Q?.find(I=>I.sessionId===g):null,Y=c?(Q||[]).filter(I=>I.errors.some(Ze=>Ze.type===c)):Q||[],K=Math.ceil(U/Kn),F=I=>{u(I),o("errors"),b(""),m(0)},ce=I=>{o(I),b(""),I!=="errors"&&m(0)},xe=()=>{u(""),x(""),y(""),m(0)};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Error Tracing"}),n.jsx("span",{className:"text-xs text-gray-500",children:"Observability for Claude Code sessions"})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("input",{type:"text",value:v,onChange:I=>y(I.target.value),onKeyDown:I=>I.key==="Enter"&&lt(),placeholder:"Search errors by message, tool name, or context...",className:"w-full px-3 py-2 text-sm bg-gray-900/50 border border-gray-700 rounded-lg text-gray-300 placeholder-gray-600 focus:outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/30"}),f&&n.jsx("button",{onClick:()=>{x(""),y(""),m(0)},className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300 text-xs",children:"clear"})]}),n.jsx("button",{onClick:lt,className:"px-4 py-2 text-sm bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg transition-colors",children:"Search"})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Total Errors",value:U,color:"rose"}),n.jsx(ie,{title:"Error Types",value:ne,color:"amber"}),n.jsx(ie,{title:"Affected Sessions",value:X,color:"indigo"}),n.jsx(ie,{title:"Most Common",value:me,color:"cyan"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:["groups","errors","timeline","sessions"].map(I=>n.jsx("button",{onClick:()=>ce(I),className:`flex-1 px-3 py-1.5 text-xs rounded-md transition-colors ${r===I?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:I==="groups"?"Error Groups":I==="errors"?"All Errors":I==="timeline"?"Timeline":"Sessions"},I))}),(c||f)&&n.jsxs("div",{className:"flex items-center gap-2",children:[c&&n.jsx(fe,{label:`type: ${c.replace(/_/g," ")}`,variant:"info"}),f&&n.jsx(fe,{label:`search: ${f.slice(0,20)}`,variant:"default"}),n.jsx("button",{onClick:xe,className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"clear all"})]})]}),$e&&n.jsxs("div",{className:"bg-rose-900/30 border border-rose-700 rounded-lg px-4 py-3 flex items-center justify-between",children:[n.jsx("div",{className:"text-sm text-rose-300",children:$e}),n.jsx("button",{onClick:()=>window.location.reload(),className:"text-xs text-rose-400 hover:text-rose-200 px-2 py-1 border border-rose-700 rounded transition-colors",children:"Retry"})]}),g&&T&&n.jsx(Ep,{session:T,onClose:()=>b("")}),Re&&!g&&n.jsx(at,{}),!g&&!Re&&r==="groups"&&n.jsx(bp,{groups:G||[],onGroupClick:F}),!g&&!Re&&r==="errors"&&n.jsx(jp,{errors:k,total:U,page:p,totalPages:K,onPageChange:m,onSessionClick:I=>{b(I),o("sessions")}}),!g&&!Re&&r==="timeline"&&n.jsx(Np,{buckets:te||[],errors:k,onSessionClick:I=>b(I)}),!g&&!Re&&r==="sessions"&&n.jsx(Sp,{sessions:Y,onSelect:I=>b(I)}),!Re&&!$e&&U===0&&!g&&n.jsx(gu,{title:"No errors detected",description:"Claude Code session logs are clean"})]})}function bp({groups:r,onGroupClick:o}){return r.length===0?null:n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Error Groups"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Type"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Count"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Sessions"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Last Seen"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Sample Message"})]})}),n.jsx("tbody",{children:r.map(c=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:c.type.replace(/_/g," "),variant:vm[c.type]||"default"})}),n.jsx("td",{className:"px-4 py-2 text-right",children:n.jsx("button",{onClick:()=>o(c.type),className:"text-sm text-indigo-400 hover:text-indigo-300 font-mono transition-colors",title:`View all ${c.count} errors of this type`,children:c.count})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:c.sessions}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-300 font-mono",title:kl(c.lastSeen),children:In(c.lastSeen)}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 max-w-xs truncate",children:c.recentMessages[0]||"-"})]},c.type))})]})]})}function jp({errors:r,total:o,page:c,totalPages:u,onPageChange:f,onSessionClick:x}){const[g,b]=S.useState(new Set),p=S.useCallback(y=>{b(N=>{const R=new Set(N);return R.has(y)?R.delete(y):R.add(y),R})},[]);if(r.length===0)return n.jsx(gu,{title:"No errors",description:"No errors match the current filter"});const m=c*Kn+1,v=Math.min(c*Kn+r.length,o);return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsxs("div",{className:"px-5 py-3 border-b border-gray-800 flex items-center justify-between",children:[n.jsxs("h3",{className:"text-sm font-medium text-gray-300",children:["Errors ",m,"–",v," of ",o]}),u>1&&n.jsx(G0,{page:c,totalPages:u,onChange:f})]}),n.jsx("div",{className:"divide-y divide-gray-800/50",children:r.map((y,N)=>{const R=g.has(N),O=y.message.length>120;return n.jsx("div",{className:"px-4 py-3 hover:bg-gray-800/20 transition-colors",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex-shrink-0 mt-0.5",children:n.jsx(fe,{label:y.type.replace(/_/g," "),variant:vm[y.type]||"default"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:`text-xs text-gray-300 ${R?"whitespace-pre-wrap break-words":"truncate"} ${O?"cursor-pointer":""}`,onClick:()=>O&&p(N),title:O?R?"Click to collapse":"Click to expand details":void 0,children:[O&&n.jsx("span",{className:"text-indigo-400 mr-1 text-[10px] inline-block w-3",children:R?"▼":"▶"}),R?y.message:y.message.slice(0,200),!R&&O&&n.jsx("span",{className:"text-indigo-400 ml-1",children:"...more"})]}),y.context?.toolName&&n.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[n.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 bg-gray-800 border border-gray-700 rounded text-amber-400",children:y.context.toolName}),y.context.toolInput&&n.jsx("span",{className:"text-[10px] text-gray-500 font-mono truncate max-w-md",children:y.context.toolInput})]}),R&&n.jsx(bm,{context:y.context})]}),n.jsxs("div",{className:"flex-shrink-0 text-right",children:[n.jsx("div",{className:"text-[10px] text-gray-300 font-mono",title:kl(y.timestamp),children:In(y.timestamp)}),n.jsx("div",{className:"text-[10px] text-gray-600",children:kl(y.timestamp)}),n.jsx("button",{onClick:()=>x(y.sessionId),className:"text-[10px] text-indigo-400 hover:text-indigo-300 font-mono mt-0.5 transition-colors",title:"View full session",children:y.sessionId.slice(0,8)}),y.context?.messageIndex!=null&&n.jsxs("div",{className:"text-[10px] text-gray-600",children:["msg #",y.context.messageIndex]})]})]})},`${y.sessionId}-${y.timestamp}-${N}`)})}),u>1&&n.jsx("div",{className:"px-5 py-3 border-t border-gray-800 flex justify-end",children:n.jsx(G0,{page:c,totalPages:u,onChange:f})})]})}function bm({context:r}){if(!r)return null;const{precedingAction:o,recentTools:c}=r;return!o&&(!c||c.length===0)?null:n.jsxs("div",{className:"mt-2 p-2 bg-gray-900/60 border border-gray-800 rounded-lg space-y-1.5",children:[o&&n.jsxs("div",{children:[n.jsx("span",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"What preceded this error:"}),n.jsx("div",{className:"text-[11px] text-gray-400 font-mono mt-0.5",children:o})]}),c&&c.length>0&&n.jsxs("div",{children:[n.jsx("span",{className:"text-[10px] text-gray-500 uppercase tracking-wider",children:"Recent tool chain:"}),n.jsx("div",{className:"flex flex-col gap-0.5 mt-0.5",children:c.map((u,f)=>n.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[n.jsxs("span",{className:"text-gray-600",children:[c.length-f,"."]}),n.jsx("span",{className:"font-mono text-amber-400/80",children:u.name}),u.input&&n.jsx("span",{className:"text-gray-600 font-mono truncate max-w-sm",children:u.input})]},f))})]})]})}function G0({page:r,totalPages:o,onChange:c}){return n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{onClick:()=>c(Math.max(0,r-1)),disabled:r===0,className:"px-2 py-1 text-xs rounded transition-colors disabled:text-gray-700 text-gray-400 hover:text-white hover:bg-gray-700",children:"Prev"}),n.jsxs("span",{className:"text-[10px] text-gray-500 px-2",children:[r+1," / ",o]}),n.jsx("button",{onClick:()=>c(Math.min(o-1,r+1)),disabled:r>=o-1,className:"px-2 py-1 text-xs rounded transition-colors disabled:text-gray-700 text-gray-400 hover:text-white hover:bg-gray-700",children:"Next"})]})}function Np({buckets:r,errors:o,onSessionClick:c}){const[u,f]=S.useState(null),x=Math.max(...r.map(m=>m.count),1),g={tool_failure:"bg-blue-500",prompt_too_long:"bg-rose-500",api_error:"bg-amber-500",hook_error:"bg-gray-500",rate_limit:"bg-amber-400",unknown:"bg-gray-600"},b=u?o.filter(m=>{const v=new Date(m.timestamp).getTime();return v>=new Date(u.start).getTime()&&v<new Date(u.end).getTime()}):o,p=m=>{try{return new Date(m).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return m}};return n.jsxs("div",{className:"space-y-4",children:[r.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Error Density (per hour)"}),u&&n.jsx("button",{onClick:()=>f(null),className:"text-[10px] text-indigo-400 hover:text-indigo-300",children:"Clear filter"})]}),n.jsx("div",{className:"flex items-end gap-px h-24",children:r.map((m,v)=>{const y=m.count/x*100,N=u?.start===m.start;return n.jsx("div",{className:"flex-1 flex flex-col items-center justify-end cursor-pointer group relative",onClick:()=>f(N?null:m),title:`${p(m.start)}: ${m.count} errors`,children:n.jsx("div",{className:`w-full min-h-[2px] rounded-t transition-all ${N?"bg-indigo-400":"bg-rose-500/70 group-hover:bg-rose-400"}`,style:{height:`${Math.max(y,2)}%`}})},v)})}),n.jsxs("div",{className:"flex justify-between mt-1",children:[n.jsx("span",{className:"text-[9px] text-gray-600",children:r.length>0?p(r[0].start):""}),n.jsx("span",{className:"text-[9px] text-gray-600",children:r.length>0?p(r[r.length-1].start):""})]}),n.jsx("div",{className:"flex gap-3 mt-2",children:Object.entries(g).map(([m,v])=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${v}`}),n.jsx("span",{className:"text-[9px] text-gray-600",children:m.replace(/_/g," ")})]},m))})]}),u&&n.jsxs("div",{className:"text-xs text-gray-400 px-1",children:["Showing ",b.length," errors from ",p(u.start)]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:u?"Filtered Errors":"Recent Errors"}),n.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto custom-scrollbar",children:[b.length===0&&n.jsx("p",{className:"text-xs text-gray-600",children:"No errors in this time range"}),b.slice(0,100).map((m,v)=>n.jsxs("div",{className:"flex items-start gap-3 py-2 px-2 hover:bg-gray-800/30 rounded cursor-pointer",onClick:()=>c(m.sessionId),children:[n.jsx("div",{className:`w-2 h-2 rounded-full mt-1.5 flex-shrink-0 ${g[m.type]||"bg-gray-500"}`}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-xs text-gray-400 font-mono",children:m.type.replace(/_/g," ")}),m.context?.toolName&&n.jsx("span",{className:"text-[10px] font-mono px-1 py-0.5 bg-gray-800 border border-gray-700 rounded text-amber-400",children:m.context.toolName}),n.jsx("span",{className:"text-[10px] text-gray-300 font-mono",children:In(m.timestamp)}),n.jsx("span",{className:"text-[10px] text-gray-600",children:kl(m.timestamp)})]}),n.jsx("div",{className:"text-xs text-gray-500 truncate mt-0.5",children:m.message}),m.context?.precedingAction&&n.jsxs("div",{className:"text-[10px] text-gray-600 mt-0.5 truncate",children:["After: ",m.context.precedingAction]})]})]},v))]})]})]})}function Sp({sessions:r,onSelect:o}){return r.length===0?null:n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Recent Sessions"})}),n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Session"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Branch"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Messages"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Tool Calls"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Errors"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Started"})]})}),n.jsx("tbody",{children:r.map(c=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30 cursor-pointer",onClick:()=>o(c.sessionId),children:[n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400 font-mono",children:c.sessionId.slice(0,8)}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500",children:c.gitBranch||"-"}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:c.messageCount}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500 text-right",children:c.toolCallCount}),n.jsx("td",{className:"px-4 py-2 text-right",children:c.errors.length>0?n.jsx(fe,{label:String(c.errors.length),variant:"error"}):n.jsx("span",{className:"text-xs text-gray-600",children:"0"})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-300 font-mono",title:kl(c.startTime),children:In(c.startTime)})]},c.sessionId))})]})]})}function Ep({session:r,onClose:o}){const[c,u]=S.useState(new Set),f=x=>{u(g=>{const b=new Set(g);return b.has(x)?b.delete(x):b.add(x),b})};return n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{children:[n.jsxs("h3",{className:"text-sm font-medium text-gray-300",children:["Session: ",n.jsx("span",{className:"font-mono",children:r.sessionId.slice(0,12)})]}),n.jsxs("div",{className:"text-[10px] text-gray-600 mt-0.5",children:["v",r.version," | ",r.gitBranch," | ",r.messageCount," messages | ",r.toolCallCount," tool calls"]})]}),n.jsx("button",{onClick:o,className:"px-2 py-1 text-xs text-gray-400 hover:text-white hover:bg-gray-700 rounded transition-colors",children:"Back"})]}),n.jsxs("div",{className:"flex gap-3 mb-4",children:[n.jsxs("div",{className:"text-xs text-gray-500",children:["Started: ",new Date(r.startTime).toLocaleString()]}),r.endTime&&n.jsxs("div",{className:"text-xs text-gray-500",children:["Ended: ",new Date(r.endTime).toLocaleString()]})]}),r.errors.length===0?n.jsx("p",{className:"text-gray-600 text-xs",children:"No errors in this session"}):n.jsx("div",{className:"space-y-2",children:r.errors.map((x,g)=>{const b=c.has(g),p=x.message.length>150;return n.jsxs("div",{className:"p-3 bg-gray-800/50 rounded-lg border-l-2 border-rose-500/50",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(fe,{label:x.type.replace(/_/g," "),variant:"error"}),x.context?.toolName&&n.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 bg-gray-800 border border-gray-700 rounded text-amber-400",children:x.context.toolName}),n.jsx("span",{className:"text-[10px] text-gray-300 font-mono",children:In(x.timestamp)}),n.jsx("span",{className:"text-[10px] text-gray-600",children:kl(x.timestamp)})]}),n.jsxs("div",{className:`text-xs text-gray-400 ${b?"whitespace-pre-wrap break-words":""} ${p?"cursor-pointer":""}`,onClick:()=>p&&f(g),title:p?b?"Click to collapse":"Click to expand":void 0,children:[p&&n.jsx("span",{className:"text-indigo-400 mr-1 text-[10px] inline-block w-3",children:b?"▼":"▶"}),b?x.message:x.message.slice(0,300),!b&&p&&n.jsx("span",{className:"text-indigo-400 ml-1",children:"...more"})]}),x.context?.toolInput&&n.jsx("div",{className:"text-[10px] text-gray-500 font-mono mt-1.5 bg-gray-900/50 px-2 py-1 rounded",children:x.context.toolInput}),x.context?.messageIndex!=null&&n.jsxs("div",{className:"text-[10px] text-gray-600 mt-1",children:["At message #",x.context.messageIndex]}),b&&n.jsx(bm,{context:x.context})]},g)})})]})}function kl(r){if(!r)return"-";const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}function In(r){if(!r)return"-";try{return new Date(r).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return r}}const Tp=[{value:"all",label:"All"},{value:"command",label:"Commands"},{value:"hook",label:"Hooks"},{value:"notification",label:"Notifications"},{value:"cost",label:"Cost"}],Cp=[{value:"all",label:"All Levels"},{value:"error",label:"Errors"},{value:"warning",label:"Warnings"},{value:"info",label:"Info"}];function Ap(){const[r,o]=qa("category","all"),[c,u]=qa("severity","all"),f=r||"all",x=c||"all",[g,b]=S.useState([]),[p,m]=S.useState(200),[v,y]=S.useState(null),N=new URLSearchParams;N.set("limit",String(p)),f!=="all"&&N.set("categories",f),x!=="all"&&N.set("severity",x);const{data:R,loading:O}=Me(`/api/activity/stream?${N.toString()}`),$=S.useCallback(B=>{b(te=>[B,...te].slice(0,50))},[]);if(Ge("activity",$),O)return n.jsx(at,{});const _=[...g,...R||[]],G=new Set,A=[];for(const B of _){const te=`${B.timestamp}:${B.title}`;G.has(te)||(G.add(te),A.push(B))}const V=A.filter(B=>!(f!=="all"&&B.category!==f||x!=="all"&&B.severity!==x)),re=A.filter(B=>B.severity==="error").length,P=A.filter(B=>B.severity==="warning").length,J=new Set(A.map(B=>B.source)),Q=B=>{y(te=>te===B?null:B)},Z=()=>{m(B=>B+200)};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Activity Stream"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 pulse-dot"}),n.jsx("span",{className:"text-xs text-gray-500",children:"Live"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Total Events",value:A.length,color:"indigo"}),n.jsx(ie,{title:"Errors",value:re,color:"rose"}),n.jsx(ie,{title:"Warnings",value:P,color:"amber"}),n.jsx(ie,{title:"Sources",value:J.size,color:"cyan"})]}),n.jsxs("div",{className:"flex flex-wrap gap-4",children:[n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:Tp.map(B=>n.jsx("button",{onClick:()=>o(B.value),className:`px-3 py-1 text-xs rounded-md transition-colors ${f===B.value?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:B.label},B.value))}),n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:Cp.map(B=>n.jsx("button",{onClick:()=>u(B.value),className:`px-3 py-1 text-xs rounded-md transition-colors ${x===B.value?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:B.label},B.value))}),n.jsxs("span",{className:"text-xs text-gray-500 self-center",children:[V.length," events"]})]}),n.jsx("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl divide-y divide-gray-800/50",children:V.length===0?n.jsxs("div",{className:"p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No events match filters"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"Try adjusting category or severity filters"})]}):n.jsxs(n.Fragment,{children:[V.slice(0,p).map((B,te)=>{const le=`${B.timestamp}-${te}`,Oe=v===le;return n.jsx(wp,{event:B,isExpanded:Oe,onToggle:()=>Q(le)},le)}),V.length>=p&&n.jsx("div",{className:"p-4 text-center",children:n.jsx("button",{onClick:Z,className:"px-4 py-2 text-xs text-indigo-400 hover:text-indigo-300 border border-indigo-500/30 rounded-lg transition-colors",children:"Load more events"})})]})})]})}function wp({event:r,isExpanded:o,onToggle:c}){const u=r.severity==="error"?"bg-rose-400":r.severity==="warning"?"bg-amber-400":"bg-gray-600",f={command:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z",hook:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101",notification:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9",cost:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1",sync:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581"},x=r.detail||r.metadata&&Object.keys(r.metadata).length>0;return n.jsxs("div",{children:[n.jsxs("div",{className:`px-4 py-3 flex items-start gap-3 transition-colors ${x?"cursor-pointer hover:bg-gray-800/20":""}`,onClick:x?c:void 0,children:[n.jsx("div",{className:`w-1.5 h-1.5 rounded-full mt-2 flex-shrink-0 ${u}`}),n.jsx("div",{className:"w-5 h-5 flex-shrink-0 mt-0.5 text-gray-500",children:n.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:f[r.category]||f.command})})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-gray-300",children:r.title}),n.jsx(fe,{label:r.category,variant:Ci(r.severity)})]}),r.detail&&!o&&n.jsx("p",{className:"text-xs text-gray-500 mt-0.5 truncate",children:r.detail}),r.source&&n.jsxs("span",{className:"text-[10px] text-gray-600 mt-0.5 block",children:["via ",r.source]})]}),n.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.timestamp&&n.jsx("span",{className:"text-[10px] text-gray-600 whitespace-nowrap",children:Mp(r.timestamp)}),x&&n.jsx("svg",{className:`w-4 h-4 text-gray-600 transition-transform duration-200 ${o?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),o&&n.jsxs("div",{className:"px-4 pb-3 ml-10 space-y-2",children:[r.detail&&n.jsxs("div",{className:"bg-gray-800/50 rounded p-3",children:[n.jsx("span",{className:"text-[10px] text-gray-500 uppercase block mb-1",children:"Detail"}),n.jsx("p",{className:"text-xs text-gray-300 whitespace-pre-wrap",children:r.detail})]}),r.metadata&&Object.keys(r.metadata).length>0&&n.jsxs("div",{className:"bg-gray-800/50 rounded p-3",children:[n.jsx("span",{className:"text-[10px] text-gray-500 uppercase block mb-1",children:"Metadata"}),n.jsx("pre",{className:"text-xs text-gray-400 font-mono whitespace-pre-wrap overflow-x-auto",children:JSON.stringify(r.metadata,null,2)})]})]})]})}function Mp(r){if(!r)return"-";const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}function Rp(){const[r,o]=S.useState(0);Ge("config-changed",()=>o(Z=>Z+1));const{data:c,loading:u,error:f,refetch:x}=Me(`/api/config?_r=${r}`),{activeProject:g}=Jl(),[b,p]=S.useState(new Set),[m,v]=S.useState({}),[y,N]=S.useState(!1),[R,O]=S.useState(null),[$,_]=S.useState([]);if(u)return n.jsx(at,{});if(f)return n.jsx(Xt,{message:f,onRetry:x});if(!c)return null;const G=Z=>{p(B=>{const te=new Set(B);return te.has(Z)?te.delete(Z):te.add(Z),te})},A=Object.keys(m).length>0,V=(Z,B)=>{v(te=>({...te,[Z]:B})),_(te=>te.filter(le=>le.path!==Z))},re=async()=>{if(A){N(!0),O(null),_([]);try{const Z={};for(const[Re,$e]of Object.entries(m))_p(Z,Re,$e);const B=g?`?project=${g.id}`:"",le=await(await fetch(`/api/config/validate${B}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)})).json();if(le.errors&&le.errors.length>0){_(le.errors),O("Validation failed. Fix errors before saving."),N(!1);return}const lt=await(await fetch(`/api/config${B}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)})).json();lt.ok?(O("Saved successfully"),v({}),_([]),x(),setTimeout(()=>O(null),3e3)):O(`Error: ${lt.error}`)}catch(Z){O(`Error: ${Z}`)}finally{N(!1)}}},P=()=>{v({}),O(null),_([])},J=Object.entries(c).filter(([Z,B])=>typeof B=="object"&&B!==null),Q=Object.entries(c).filter(([Z,B])=>typeof B!="object"||B===null);return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Configuration"}),n.jsx("span",{className:"text-xs text-gray-500",children:".specweave/config.json"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[R&&n.jsx("span",{className:`text-xs ${R.startsWith("Error")||R.startsWith("Validation")?"text-rose-400":"text-emerald-400"}`,children:R}),A&&n.jsxs(n.Fragment,{children:[n.jsx(fe,{label:`${Object.keys(m).length} changes`,variant:"warning"}),n.jsx("button",{onClick:P,className:"px-3 py-1.5 text-xs text-gray-400 hover:text-gray-200 border border-gray-700 rounded-lg transition-colors",children:"Discard"}),n.jsx("button",{onClick:re,disabled:y,className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:y?"Saving...":"Save Changes"})]})]})]}),R&&!A&&R==="Saved successfully"&&n.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/30 rounded-lg px-4 py-2 flex items-center gap-2",children:[n.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400"}),n.jsx("span",{className:"text-xs text-emerald-400",children:"Configuration saved successfully"})]}),$.length>0&&n.jsxs("div",{className:"bg-rose-500/10 border border-rose-500/30 rounded-lg px-4 py-3 space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("div",{className:"w-2 h-2 rounded-full bg-rose-400"}),n.jsx("span",{className:"text-xs text-rose-400 font-medium",children:"Validation errors"})]}),$.map((Z,B)=>n.jsxs("div",{className:"text-xs text-rose-300 pl-4",children:[n.jsx("span",{className:"font-mono text-rose-400",children:Z.path}),": ",Z.message]},B))]}),Q.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-3",children:"General"}),n.jsx("div",{className:"space-y-3",children:Q.map(([Z,B])=>n.jsx(Nm,{path:Z,label:Z,value:m[Z]!==void 0?m[Z]:B,original:B,onChange:te=>V(Z,te),edited:m[Z]!==void 0,validationError:$.find(te=>te.path===Z)?.message},Z))})]}),J.map(([Z,B])=>n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsxs("button",{onClick:()=>G(Z),className:"w-full px-5 py-3 flex items-center justify-between hover:bg-gray-800/30 transition-colors",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 capitalize",children:Z}),$0(m,Z)>0&&n.jsx(fe,{label:`${$0(m,Z)} edited`,variant:"warning"}),$.some(te=>te.path.startsWith(Z+"."))&&n.jsx(fe,{label:"errors",variant:"error"})]}),n.jsx("svg",{className:`w-4 h-4 text-gray-500 transition-transform duration-200 ${b.has(Z)?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),b.has(Z)&&n.jsx("div",{className:"px-5 py-3 border-t border-gray-800",children:n.jsx(jm,{data:B,path:Z,edits:m,onChange:V,validationErrors:$,depth:0})})]},Z))]})}function jm({data:r,path:o,edits:c,onChange:u,validationErrors:f,depth:x}){return x>4?n.jsx("span",{className:"text-xs text-gray-600",children:"..."}):n.jsx("div",{className:"space-y-3",style:{marginLeft:x>0?16:0},children:Object.entries(r).map(([g,b])=>{const p=`${o}.${g}`;return b&&typeof b=="object"&&!Array.isArray(b)?n.jsxs("div",{children:[n.jsx("span",{className:"text-xs text-gray-400 font-mono font-medium",children:g}),n.jsx(jm,{data:b,path:p,edits:c,onChange:u,validationErrors:f,depth:x+1})]},g):n.jsx(Nm,{path:p,label:g,value:c[p]!==void 0?c[p]:b,original:b,onChange:m=>u(p,m),edited:c[p]!==void 0,validationError:f.find(m=>m.path===p)?.message},g)})})}function Nm({path:r,label:o,value:c,original:u,onChange:f,edited:x,validationError:g}){return typeof u=="boolean"||typeof c=="boolean"?n.jsxs("div",{className:"py-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:o}),n.jsx("button",{onClick:()=>f(!c),className:`relative w-9 h-5 rounded-full transition-colors ${c?"bg-indigo-600":"bg-gray-700"} ${x?"ring-1 ring-amber-500/50":""}`,children:n.jsx("div",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-transform ${c?"left-[18px]":"left-0.5"}`})})]}),g&&n.jsx("p",{className:"text-[10px] text-rose-400 mt-0.5",children:g})]}):typeof u=="number"||typeof c=="number"?n.jsxs("div",{className:"py-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:o}),n.jsx("input",{type:"number",value:String(c??""),onChange:b=>f(b.target.value?Number(b.target.value):0),className:`bg-gray-800 border text-xs text-amber-400 font-mono rounded px-2 py-1 w-24 text-right ${g?"border-rose-500":x?"border-amber-500/50":"border-gray-700"} focus:ring-indigo-500 focus:border-indigo-500`})]}),g&&n.jsx("p",{className:"text-[10px] text-rose-400 mt-0.5 text-right",children:g})]}):Array.isArray(u)||Array.isArray(c)?n.jsx(zp,{path:r,label:o,value:Array.isArray(c)?c:Array.isArray(u)?u:[],edited:x,onChange:f,validationError:g}):n.jsxs("div",{className:"py-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:o}),n.jsx("input",{type:"text",value:String(c??""),onChange:b=>f(b.target.value),className:`bg-gray-800 border text-xs text-gray-300 rounded px-2 py-1 w-48 text-right ${g?"border-rose-500":x?"border-amber-500/50":"border-gray-700"} focus:ring-indigo-500 focus:border-indigo-500`})]}),g&&n.jsx("p",{className:"text-[10px] text-rose-400 mt-0.5 text-right",children:g})]})}function zp({path:r,label:o,value:c,edited:u,onChange:f,validationError:x}){const[g,b]=S.useState(!1),[p,m]=S.useState(""),v=R=>{const O=[...c];O.splice(R,1),f(O)},y=()=>{const R=p.trim();R&&(f([...c,R]),m(""))},N=R=>{R.key==="Enter"&&(R.preventDefault(),y())};return n.jsxs("div",{className:"py-1",children:[n.jsxs("button",{onClick:()=>b(R=>!R),className:"flex items-center justify-between w-full group",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:o}),n.jsxs("div",{className:"flex items-center gap-2",children:[u&&n.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-500"}),n.jsxs("span",{className:"text-xs text-gray-400 font-mono",children:["[",c.length," items]"]}),n.jsx("svg",{className:`w-3 h-3 text-gray-500 transition-transform duration-200 ${g?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),g&&n.jsxs("div",{className:"mt-2 ml-4 space-y-1",children:[c.length===0&&n.jsx("p",{className:"text-[10px] text-gray-600",children:"No items"}),c.map((R,O)=>n.jsxs("div",{className:"flex items-center gap-2 group/item",children:[n.jsx("span",{className:"text-xs text-gray-300 font-mono flex-1 truncate",children:String(R)}),n.jsx("button",{onClick:()=>v(O),className:"text-[10px] text-gray-600 hover:text-rose-400 opacity-0 group-hover/item:opacity-100 transition-opacity",children:"remove"})]},O)),n.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[n.jsx("input",{type:"text",value:p,onChange:R=>m(R.target.value),onKeyDown:N,placeholder:"Add item...",className:"bg-gray-800 border border-gray-700 text-xs text-gray-300 rounded px-2 py-1 flex-1 focus:ring-indigo-500 focus:border-indigo-500"}),n.jsx("button",{onClick:y,disabled:!p.trim(),className:"px-2 py-1 text-[10px] text-indigo-400 hover:text-indigo-300 border border-indigo-500/30 rounded disabled:opacity-50 transition-colors",children:"Add"})]})]}),x&&n.jsx("p",{className:"text-[10px] text-rose-400 mt-0.5",children:x})]})}function $0(r,o){return Object.keys(r).filter(c=>c.startsWith(o+".")).length}function _p(r,o,c){const u=o.split(".");let f=r;for(let x=0;x<u.length-1;x++)(!f[u[x]]||typeof f[u[x]]!="object")&&(f[u[x]]={}),f=f[u[x]];f[u[u.length-1]]=c}function yu({lines:r,status:o,onDismiss:c}){const u=S.useRef(null);return S.useEffect(()=>{u.current?.scrollIntoView({behavior:"smooth"})},[r]),r.length===0&&o==="idle"?null:n.jsxs("div",{className:"mt-4 rounded-lg bg-gray-950 border border-gray-700 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-900 border-b border-gray-700",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${o==="running"?"bg-yellow-400 animate-pulse":o==="success"?"bg-green-400":o==="error"?"bg-red-400":"bg-gray-500"}`}),n.jsx("span",{className:"text-xs text-gray-400 font-mono",children:o==="running"?"Running...":o==="success"?"Completed":o==="error"?"Failed":"Output"})]}),o!=="running"&&c&&n.jsx("button",{onClick:c,className:"text-gray-500 hover:text-gray-300 text-xs",children:"Dismiss"})]}),n.jsxs("div",{className:"p-3 max-h-48 overflow-y-auto font-mono text-xs text-gray-300 whitespace-pre-wrap",children:[r.map((f,x)=>n.jsx("div",{children:f},x)),n.jsx("div",{ref:u})]})]})}function Dp(){const{data:r,loading:o}=Me("/api/plugins/full"),{execute:c,running:u,output:f,status:x,reset:g}=Ai(),[b,p]=S.useState(null);if(o)return n.jsx(at,{});const m=r?.plugins||[],v=r?.skills||[],y=r?.lsp,N=r?.warmup,R=r?.triggerCount||0,O=m.reduce((A,V)=>A+V.skillCount,0),$=m.reduce((A,V)=>A+V.commandCount,0),_=A=>v.filter(V=>V.plugin===A).sort((V,re)=>re.count-V.count),G=A=>{p(V=>V===A?null:A)};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Plugins & LSP"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:()=>c("lsp-status"),disabled:u,className:"px-3 py-1.5 bg-gray-700 hover:bg-gray-600 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:"Check LSP"}),n.jsx("button",{onClick:()=>c("refresh-plugins"),disabled:u,className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:u?"Running...":"Refresh Plugins"})]})]}),n.jsx(yu,{lines:f,status:x,onDismiss:g}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[n.jsx(Ba,{label:"Plugins",value:m.length}),n.jsx(Ba,{label:"Total Skills",value:O}),n.jsx(Ba,{label:"Total Commands",value:$}),n.jsx(Ba,{label:"Trigger Keywords",value:R})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Installed Plugins"})}),m.length===0?n.jsx("div",{className:"p-5 text-gray-500 text-xs",children:"No plugins installed"}):n.jsx("div",{className:"divide-y divide-gray-800/50",children:m.map(A=>{const V=b===A.name,re=_(A.name);return n.jsxs("div",{children:[n.jsxs("button",{onClick:()=>G(A.name),className:"w-full px-4 py-3 flex items-center justify-between hover:bg-gray-800/30 transition-colors text-left",children:[n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("span",{className:"text-sm text-gray-300",children:A.name}),n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:A.version})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(fe,{label:`${A.skillCount} skills`,variant:"info"}),n.jsx(fe,{label:`${A.commandCount} cmds`,variant:"default"}),n.jsx("svg",{className:`w-4 h-4 text-gray-500 transition-transform duration-200 ${V?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),V&&n.jsx("div",{className:"px-4 pb-4 bg-gray-800/20",children:re.length===0?n.jsx("p",{className:"text-xs text-gray-600 py-2",children:"No skill usage data for this plugin"}):n.jsxs("div",{className:"space-y-1 mt-1",children:[n.jsxs("div",{className:"grid grid-cols-[1fr,80px,80px,120px] gap-2 px-2 py-1",children:[n.jsx("span",{className:"text-[10px] text-gray-600 uppercase",children:"Skill"}),n.jsx("span",{className:"text-[10px] text-gray-600 uppercase text-right",children:"Invocations"}),n.jsx("span",{className:"text-[10px] text-gray-600 uppercase text-right",children:"Success"}),n.jsx("span",{className:"text-[10px] text-gray-600 uppercase text-right",children:"Last Used"})]}),re.map(P=>n.jsxs("div",{className:"grid grid-cols-[1fr,80px,80px,120px] gap-2 px-2 py-1.5 bg-gray-800/40 rounded",children:[n.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:P.name}),n.jsx("span",{className:"text-xs text-gray-400 text-right font-mono",children:P.count}),n.jsxs("span",{className:"text-xs text-right font-mono",children:[n.jsx("span",{className:"text-emerald-400",children:P.successCount}),P.failureCount>0&&n.jsxs("span",{className:"text-rose-400",children:["/",P.failureCount]})]}),n.jsx("span",{className:"text-[10px] text-gray-500 text-right",children:P.lastUsed?Op(P.lastUsed):"-"})]},P.name))]})})]},A.name)})})]}),v.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Skill Usage Leaderboard"}),n.jsx(ym,{items:v.sort((A,V)=>V.count-A.count).slice(0,20).map(A=>({label:A.name,value:A.count,color:"#10b981"})),maxBars:20})]}),y&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"LSP Status"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(fe,{label:y.status,variant:y.status==="ok"?"success":"warning"}),y.checked&&n.jsxs("span",{className:"text-[10px] text-gray-600",children:["Checked: ",new Date(y.checked).toLocaleDateString()]})]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-4",children:[n.jsx(Ba,{label:"Total Languages",value:y.stats.totalLanguages}),n.jsx(Ba,{label:"Checked",value:y.stats.checkedLanguages}),n.jsx(Ba,{label:"Binary Missing",value:y.stats.binaryMissing}),n.jsx(Ba,{label:"Plugin Missing",value:y.stats.pluginMissing})]}),y.missing.length>0&&n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"text-xs text-gray-500",children:"Missing Languages"}),y.missing.map((A,V)=>n.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-800/50 rounded",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(fe,{label:A.type,variant:A.type==="binary"?"warning":"default"}),n.jsx("span",{className:"text-xs text-gray-300",children:A.language})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"text-[10px] text-gray-500",children:A.binaryInstall}),A.message&&n.jsx("span",{className:"text-[10px] text-gray-600 max-w-[200px] truncate",children:A.message})]})]},V))]})]}),N&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"LSP Warmup Status"}),n.jsxs("span",{className:"text-[10px] text-gray-600",children:[N.elapsed?`${(N.elapsed/1e3).toFixed(1)}s`:""," |"," ",N.timestamp?new Date(N.timestamp).toLocaleString():""]})]}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[N.warmedUp.map(A=>n.jsx(fe,{label:A,variant:"success"},A)),N.failed.map(A=>n.jsx(fe,{label:A,variant:"error"},A))]}),N.warmedUp.length===0&&N.failed.length===0&&n.jsx("p",{className:"text-gray-600 text-xs",children:"No warmup data"})]})]})}function Ba({label:r,value:o}){return n.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-3 text-center",children:[n.jsx("div",{className:"text-lg font-bold text-gray-300",children:o}),n.jsx("div",{className:"text-[10px] text-gray-500",children:r})]})}function Op(r){if(!r)return"-";const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}function Up(){const{data:r,loading:o}=Me("/api/links"),{data:c,loading:u,refetch:f}=Me("/api/services"),{execute:x,running:g,output:b,status:p,reset:m}=Ai();if(o||u)return n.jsx(at,{});const v=(c||[]).filter(_=>_.status==="running").length,y=(c||[]).length,N=new Map;for(const _ of c||[])if(_.port>0&&_.status==="running"){const G=N.get(_.port)||[];G.push(_.name),N.set(_.port,G)}const R=Array.from(N.entries()).filter(([,_])=>_.length>1),O=async _=>{await x(_),setTimeout(()=>f(),3e3)},$=async _=>{await x(_),setTimeout(()=>f(),2e3)};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Services & Links"}),n.jsx(yu,{lines:b,status:p,onDismiss:m}),R.length>0&&n.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-xl p-4 flex items-start gap-3",children:[n.jsx("svg",{className:"w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-medium text-amber-300",children:"Port Conflict Detected"}),n.jsx("div",{className:"text-xs text-amber-400/80 mt-1",children:R.map(([_,G])=>n.jsxs("span",{className:"block",children:["Port ",_," is used by: ",G.join(", ")]},_))})]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Services",value:y,color:"indigo",tooltip:`${y} managed services`}),n.jsx(ie,{title:"Running",value:v,color:"emerald",tooltip:`${v} services currently active`}),n.jsx(ie,{title:"External Links",value:(r||[]).length,color:"cyan",tooltip:"Configured external links (docs, repos, etc.)"}),n.jsx(ie,{title:"Stopped",value:y-v,color:"rose",tooltip:`${y-v} services not running`})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"Service Status"}),n.jsx("div",{className:"space-y-3",children:(c||[]).map((_,G)=>n.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${_.status==="running"?"bg-emerald-400":"bg-gray-600"}`}),n.jsxs("div",{children:[n.jsx("span",{className:"text-sm text-gray-300",children:_.name}),n.jsx("div",{className:"text-[10px] text-gray-600",children:_.status==="running"&&_.detail?n.jsx("a",{href:_.detail,target:"_blank",rel:"noopener noreferrer",className:"text-indigo-400 hover:text-indigo-300 underline transition-colors",children:_.detail}):_.detail})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[_.status==="running"&&_.port>0&&n.jsx(fe,{label:`Port ${_.port}`,variant:"info"}),_.status==="running"?n.jsx(fe,{label:"Running",variant:"success"}):n.jsx(fe,{label:"Stopped",variant:"default"}),_.name==="Docs Preview"&&(_.status==="running"?n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("a",{href:_.detail,target:"_blank",rel:"noopener noreferrer",className:"px-2 py-1 text-[10px] text-indigo-400 hover:text-indigo-300 border border-indigo-500/30 rounded transition-colors",children:"Open"}),n.jsx("button",{onClick:()=>$("docs-preview-stop"),disabled:g,className:"px-2 py-1 text-[10px] text-rose-400 hover:text-rose-300 border border-rose-500/30 rounded transition-colors disabled:opacity-50",children:"Stop"})]}):n.jsx("button",{onClick:()=>O("docs-preview-start"),disabled:g,className:"px-2 py-1 text-[10px] text-emerald-400 hover:text-emerald-300 border border-emerald-500/30 rounded transition-colors disabled:opacity-50",children:g?"Starting...":"Start"})),_.status==="running"&&_.name!=="Docs Preview"&&n.jsx("a",{href:_.detail,target:"_blank",rel:"noopener noreferrer",className:"px-2 py-1 text-[10px] text-indigo-400 hover:text-indigo-300 border border-indigo-500/30 rounded transition-colors",children:"Open"})]})]},G))})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-4",children:"External Links"}),(r||[]).length===0?n.jsx("p",{className:"text-xs text-gray-500",children:"No external links configured"}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:(r||[]).map((_,G)=>n.jsxs("a",{href:_.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg hover:bg-gray-800 transition-colors group",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Lp,{type:_.type}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-gray-300 group-hover:text-white transition-colors",children:_.name}),n.jsx("div",{className:"text-[10px] text-gray-600 truncate max-w-[200px]",children:_.url})]})]}),n.jsx("svg",{className:"w-4 h-4 text-gray-600 group-hover:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]},G))})]})]})}function Lp({type:r}){const o={docs:"bg-indigo-600",github:"bg-gray-700",jira:"bg-blue-700",ado:"bg-blue-600"};return n.jsx("div",{className:`w-8 h-8 rounded-lg ${o[r]||"bg-gray-700"} flex items-center justify-center`,children:n.jsx("span",{className:"text-xs text-white font-bold",children:r[0]?.toUpperCase()})})}const V0={critical:0,warning:1,info:2};function Hp(){const[r,o]=S.useState("pending"),[c,u]=S.useState(null),[f,x]=S.useState(0);Ge("notification",()=>x(B=>B+1));const{activeProject:g}=Jl(),{data:b,loading:p,error:m,refetch:v}=Me(`/api/notifications?_r=${f}`);if(p)return n.jsx(at,{});if(m)return n.jsx(Xt,{message:m,onRetry:v});const y=b||[],N=y.filter(B=>!B.dismissedAt),R=y.filter(B=>!!B.dismissedAt),O=N.filter(B=>B.severity==="critical"),$=N.filter(B=>B.severity==="warning"),G=[...r==="pending"?N:r==="dismissed"?R:y].sort((B,te)=>{const le=V0[B.severity]??3,Oe=V0[te.severity]??3;return le!==Oe?le-Oe:new Date(te.createdAt).getTime()-new Date(B.createdAt).getTime()}),A=async B=>{u(B);try{const te=g?`?project=${g.id}`:"";(await fetch(`/api/notifications/${B}/dismiss${te}`,{method:"POST"})).ok&&v()}finally{u(null)}},V=async()=>{u("__all__");try{const B=g?`?project=${g.id}`:"";for(const te of N)await fetch(`/api/notifications/${te.id}/dismiss${B}`,{method:"POST"});v()}finally{u(null)}},re=B=>B==="critical"?"error":B==="warning"?"warning":"info",P=B=>B==="critical"?"border-l-rose-500":B==="warning"?"border-l-amber-500":"border-l-blue-500",Q=(B=>{const te={};for(const le of B)te[le.severity]||(te[le.severity]=[]),te[le.severity].push(le);return te})(G),Z={critical:"Critical",warning:"Warnings",info:"Informational"};return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Notifications"}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Pending",value:N.length,color:"indigo"}),n.jsx(ie,{title:"Critical",value:O.length,color:"rose"}),n.jsx(ie,{title:"Warnings",value:$.length,color:"amber"}),n.jsx(ie,{title:"Dismissed",value:R.length,color:"cyan"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("div",{className:"flex gap-1 bg-gray-900/50 border border-gray-800 rounded-lg p-1",children:[{value:"pending",label:`Pending (${N.length})`},{value:"dismissed",label:`Dismissed (${R.length})`},{value:"all",label:`All (${y.length})`}].map(B=>n.jsx("button",{onClick:()=>o(B.value),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${r===B.value?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300"}`,children:B.label},B.value))}),N.length>0&&n.jsx("button",{onClick:V,disabled:c==="__all__",className:"px-3 py-1.5 text-xs text-gray-400 hover:text-gray-200 border border-gray-700 rounded-lg transition-colors disabled:opacity-50",children:c==="__all__"?"Dismissing...":"Dismiss All"})]}),G.length===0?n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:[n.jsx("div",{className:"w-12 h-12 rounded-full bg-gray-800 flex items-center justify-center mx-auto mb-4",children:n.jsx("svg",{className:"w-6 h-6 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"})})}),n.jsx("p",{className:"text-gray-400 text-sm font-medium",children:r==="pending"?"No pending notifications":"No notifications"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1 max-w-xs mx-auto",children:"Notifications appear here when imports complete, discrepancies are found, or syncs fail"})]}):n.jsx("div",{className:"space-y-4",children:["critical","warning","info"].map(B=>{const te=Q[B];return!te||te.length===0?null:n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx("h3",{className:"text-xs font-medium text-gray-400 uppercase",children:Z[B]||B}),n.jsxs("span",{className:"text-[10px] text-gray-600",children:["(",te.length,")"]})]}),n.jsx("div",{className:"space-y-2",children:te.map(le=>n.jsxs("div",{className:`bg-gray-900/50 border border-gray-800 border-l-4 ${P(le.severity)} rounded-xl p-4 flex items-start gap-4 ${le.dismissedAt?"opacity-60":""}`,children:[n.jsx(Bp,{severity:le.severity}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("span",{className:"text-sm font-medium text-gray-200",children:le.title}),n.jsx(fe,{label:le.severity,variant:re(le.severity)}),le.type&&n.jsx(fe,{label:le.type,variant:"default"})]}),le.message&&n.jsx("p",{className:"text-xs text-gray-400 mb-2",children:le.message}),n.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-gray-600",children:[n.jsx("span",{children:new Date(le.createdAt).toLocaleString()}),le.source&&n.jsxs("span",{children:["via ",le.source]}),le.dismissedAt&&n.jsxs("span",{children:["Dismissed ",new Date(le.dismissedAt).toLocaleString()]})]})]}),!le.dismissedAt&&n.jsx("button",{onClick:()=>A(le.id),disabled:c===le.id,className:"px-2 py-1 text-xs text-gray-500 hover:text-gray-300 hover:bg-gray-800 rounded transition-colors disabled:opacity-50 flex-shrink-0",children:c===le.id?"...":"Dismiss"})]},le.id))})]},B)})})]})}function Bp({severity:r}){return r==="critical"?n.jsx("div",{className:"w-8 h-8 rounded-full bg-rose-500/10 flex items-center justify-center flex-shrink-0",children:n.jsx("svg",{className:"w-4 h-4 text-rose-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"})})}):r==="warning"?n.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/10 flex items-center justify-center flex-shrink-0",children:n.jsx("svg",{className:"w-4 h-4 text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}):n.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-500/10 flex items-center justify-center flex-shrink-0",children:n.jsx("svg",{className:"w-4 h-4 text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}function qp(r){if(!r)return null;if(r.startsWith("https://"))return r.replace(/\.git$/,"");const o=r.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(o)return`https://${o[1]}/${o[2]}`;const c=r.match(/^ssh:\/\/git@([^/]+)\/(.+?)(?:\.git)?$/);return c?`https://${c[1]}/${c[2]}`:null}function Yp(){const{data:r,loading:o,error:c,refetch:u}=Me("/api/repos");if(o)return n.jsx(at,{});if(c)return n.jsx(Xt,{message:c,onRetry:u});const f=r||[],x=[...new Set(f.map(p=>p.org))],g=f.filter(p=>p.hasSpecweave).length,b=f.find(p=>p.isCurrent);return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Repositories"}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Repositories",value:f.length,color:"indigo"}),n.jsx(ie,{title:"Organizations",value:x.length,color:"cyan"}),n.jsx(ie,{title:"With SpecWeave",value:g,color:"emerald"}),n.jsx(ie,{title:"Current",value:b?b.name:"-",subtitle:b?`${b.org}/${b.name}`:"No current project",color:"amber"})]}),f.length===0?n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No repositories found"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"This project doesn't use multi-repo mode, or the repositories/ directory hasn't been set up yet"})]}):n.jsx(n.Fragment,{children:x.map(p=>{const m=f.filter(v=>v.org===p);return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(Gp,{}),n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:p}),n.jsxs("span",{className:"text-[10px] text-gray-600",children:[m.length," ",m.length===1?"repo":"repos"]})]}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:m.map(v=>{const y=qp(v.remote);return n.jsxs("div",{className:`bg-gray-900/50 border rounded-xl p-4 ${v.isCurrent?"border-indigo-500/30":"border-gray-800"}`,children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx($p,{}),n.jsx("span",{className:"text-sm font-medium text-gray-300",children:v.name})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[v.isCurrent&&n.jsx(fe,{label:"Current Project",variant:"info"}),n.jsx(fe,{label:v.hasSpecweave?"SpecWeave":"No SpecWeave",variant:v.hasSpecweave?"success":"default"})]})]}),n.jsxs("div",{className:"space-y-1.5 mt-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Organization"}),n.jsx("span",{className:"text-[10px] text-gray-400",children:v.org})]}),v.branch&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Branch"}),n.jsx(fe,{label:v.branch,variant:"default"})]}),y&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Remote"}),n.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-indigo-400 hover:text-indigo-300 hover:underline truncate max-w-[180px]",title:y,children:y.replace("https://","")})]}),!y&&v.remote&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Remote"}),n.jsx("span",{className:"text-[10px] text-gray-600 font-mono truncate max-w-[180px]",title:v.remote,children:v.remote})]}),v.path&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Path"}),n.jsx("span",{className:"text-[10px] text-gray-600 font-mono truncate max-w-[180px]",title:v.path,children:v.path.split("/").slice(-3).join("/")})]}),v.lastModified&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-[10px] text-gray-500",children:"Last Modified"}),n.jsx("span",{className:"text-[10px] text-gray-400",children:Qp(v.lastModified)})]})]}),y&&n.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"mt-3 flex items-center justify-center gap-1.5 text-xs text-gray-400 hover:text-gray-200 py-2 border border-gray-800 rounded-lg hover:border-gray-700 transition-colors",children:[n.jsx(Vp,{}),"Open on GitHub"]})]},v.path||`${v.org}/${v.name}`)})})]},p)})})]})}function Gp(){return n.jsx("div",{className:"w-6 h-6 rounded bg-gray-700 flex items-center justify-center",children:n.jsx("svg",{className:"w-3.5 h-3.5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"})})})}function $p(){return n.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})})}function Vp(){return n.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})})}function Qp(r){if(!r)return"-";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return"-"}}const Xp=[{value:"",label:"All"},{value:"discovered",label:"Discovered"},{value:"scanning",label:"Scanning"},{value:"tier1_passed",label:"Passed"},{value:"tier1_failed",label:"Failed"},{value:"verified",label:"Verified"},{value:"rejected",label:"Rejected"}],oa=20;function kp(r){switch(r){case"discovered":return"default";case"queued":return"info";case"scanning":return"warning";case"tier1_passed":return"success";case"tier1_failed":return"error";case"tier2_pending":return"info";case"verified":return"success";case"rejected":return"error";default:return"default"}}function Zp(r){switch(r){case"discovered":return"Discovered";case"queued":return"Queued";case"scanning":return"Scanning";case"tier1_passed":return"T1 Passed";case"tier1_failed":return"T1 Failed";case"tier2_pending":return"T2 Pending";case"verified":return"Verified";case"rejected":return"Rejected";default:return r}}function Q0(r){if(!r)return"-";try{const o=Date.now()-new Date(r).getTime(),c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}catch{return"-"}}function X0(r){return r>=80?"text-emerald-400":r>=50?"text-amber-400":"text-rose-400"}function Kp(r,o){if(o===0)return"rose";const c=r/o;return c>.5?"emerald":c>.1?"amber":"rose"}function Jp(){const[r,o]=S.useState(""),[c,u]=S.useState(0),[f,x]=S.useState(0),[g,b]=S.useState(null),{output:p,status:m,reset:v}=Ai(),y=r?`status=${r}&limit=${oa}&offset=${c}`:`limit=${oa}&offset=${c}`,{data:N,loading:R,error:O,refetch:$}=Me(`/api/marketplace/scanner/status?_r=${f}`),{data:_,loading:G,refetch:A}=Me(`/api/marketplace/queue?${y}&_r=${f}`),{data:V,loading:re}=Me(`/api/marketplace/verified?_r=${f}`),{data:P,loading:J}=Me(`/api/marketplace/insights?_r=${f}`),Q=S.useCallback(()=>{x(X=>X+1)},[]);Ge("submission-update",S.useCallback(()=>{Q()},[Q])),Ge("marketplace-scan",S.useCallback(()=>{Q()},[Q])),Ge("verification-complete",S.useCallback(()=>{Q()},[Q]));const Z=async()=>{try{const X=new URLSearchParams(window.location.search).get("project")||"",me=X?`?project=${X}`:"";await fetch(`/api/marketplace/scanner/start${me}`,{method:"POST"}),$()}catch{}},B=async()=>{try{const X=new URLSearchParams(window.location.search).get("project")||"",me=X?`?project=${X}`:"";await fetch(`/api/marketplace/scanner/stop${me}`,{method:"POST"}),$()}catch{}},te=async X=>{b(X);try{const me=new URLSearchParams(window.location.search).get("project")||"",T=me?`?project=${me}`:"";await fetch(`/api/marketplace/queue/${X}/approve${T}`,{method:"POST"}),A()}catch{}b(null)},le=async X=>{b(X);try{const me=new URLSearchParams(window.location.search).get("project")||"",T=me?`?project=${me}`:"";await fetch(`/api/marketplace/queue/${X}/reject${T}`,{method:"POST"}),A()}catch{}b(null)};if(R&&G&&re&&J)return n.jsx(at,{});const lt=_?.items||[],Re=_?.total||0,$e=V||[],U=Math.floor(c/oa)+1,k=Math.ceil(Re/oa),ne=X=>X==="tier1_passed"||X==="tier2_pending";return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Marketplace Scanner"}),n.jsx("div",{className:"flex gap-2",children:N?.running?n.jsx("button",{onClick:B,className:"px-3 py-1.5 bg-rose-600 hover:bg-rose-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:"Stop Scanner"}):n.jsx("button",{onClick:Z,className:"px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 text-white text-xs rounded-lg transition-colors",children:"Start Scanner"})})]}),n.jsx(yu,{lines:p,status:m,onDismiss:v}),O&&n.jsx(Xt,{message:O,onRetry:$}),N?n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Scanner",value:N.running?"Running":"Stopped",subtitle:N.running?"Active":"Idle",color:N.running?"emerald":"amber"}),n.jsx(ie,{title:"Last Scan",value:N.lastScanTime?Q0(N.lastScanTime):"Never",color:"cyan"}),n.jsx(ie,{title:"Repos Scanned",value:N.reposScanned,color:"indigo"}),n.jsx(ie,{title:"Rate Limit",value:`${N.rateLimitRemaining}/${N.rateLimitTotal}`,subtitle:N.rateLimitTotal>0?`${Math.round(N.rateLimitRemaining/N.rateLimitTotal*100)}% remaining`:"Unknown",color:Kp(N.rateLimitRemaining,N.rateLimitTotal)})]}):!R&&!O?n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-8 text-center",children:[n.jsx("div",{className:"text-gray-400 text-sm mb-2",children:"No scanner data available"}),n.jsx("p",{className:"text-gray-600 text-xs mb-4",children:"Start the marketplace scanner to discover and verify community skills."}),n.jsx("button",{onClick:Z,className:"px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm rounded-lg transition-colors",children:"Start Scanner"})]}):null,n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsxs("div",{className:"px-5 py-3 border-b border-gray-800 flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Submission Queue"}),n.jsxs("span",{className:"text-xs text-gray-500",children:[Re," total"]})]}),n.jsx("div",{className:"flex gap-1 px-4 pt-3 pb-2 overflow-x-auto",children:Xp.map(X=>n.jsx("button",{onClick:()=>{o(X.value),u(0)},className:`px-3 py-1.5 text-xs rounded-md transition-colors whitespace-nowrap ${r===X.value?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-300 hover:bg-gray-800"}`,children:X.label},X.value))}),G?n.jsx("div",{className:"p-8 flex justify-center",children:n.jsx(at,{})}):lt.length===0?n.jsxs("div",{className:"p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No submissions found"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:r?"Try a different filter.":"Submissions will appear here once the scanner discovers repos."})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-800",children:[n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Repo"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Author"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Stars"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Status"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Tier"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Security"}),n.jsx("th",{className:"text-left px-4 py-2 text-xs text-gray-500",children:"Discovered"}),n.jsx("th",{className:"text-right px-4 py-2 text-xs text-gray-500",children:"Actions"})]})}),n.jsx("tbody",{children:lt.map(X=>n.jsxs("tr",{className:"border-b border-gray-800/50 hover:bg-gray-800/30",children:[n.jsx("td",{className:"px-4 py-2",children:X.repoUrl?n.jsx("a",{href:X.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-indigo-400 hover:text-indigo-300 font-mono",children:X.repoFullName}):n.jsx("span",{className:"text-xs text-gray-300 font-mono",children:X.repoFullName})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400",children:X.author}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400 text-right font-mono",children:X.stars.toLocaleString()}),n.jsx("td",{className:"px-4 py-2",children:n.jsx(fe,{label:Zp(X.status),variant:kp(X.status)})}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-400",children:X.tier||"-"}),n.jsx("td",{className:`px-4 py-2 text-xs text-right font-mono ${X0(X.securityScore)}`,children:X.securityScore!=null?X.securityScore:"-"}),n.jsx("td",{className:"px-4 py-2 text-xs text-gray-500",children:Q0(X.discoveredAt)}),n.jsx("td",{className:"px-4 py-2 text-right",children:ne(X.status)&&n.jsxs("div",{className:"flex gap-1 justify-end",children:[n.jsx("button",{onClick:()=>te(X.id),disabled:g===X.id,className:"px-2 py-1 bg-emerald-600/20 hover:bg-emerald-600/40 text-emerald-400 text-[10px] rounded transition-colors disabled:opacity-50",children:"Approve"}),n.jsx("button",{onClick:()=>le(X.id),disabled:g===X.id,className:"px-2 py-1 bg-rose-600/20 hover:bg-rose-600/40 text-rose-400 text-[10px] rounded transition-colors disabled:opacity-50",children:"Reject"})]})})]},X.id))})]})}),Re>oa&&n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-800",children:[n.jsxs("span",{className:"text-xs text-gray-500",children:[c+1,"-",Math.min(c+oa,Re)," of ",Re]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx("button",{onClick:()=>u(Math.max(0,c-oa)),disabled:c===0,className:"px-2 py-1 text-xs text-gray-400 hover:text-gray-200 disabled:opacity-30 disabled:cursor-not-allowed",children:"Prev"}),n.jsxs("span",{className:"px-2 py-1 text-xs text-gray-500",children:["Page ",U," of ",k]}),n.jsx("button",{onClick:()=>u(c+oa),disabled:c+oa>=Re,className:"px-2 py-1 text-xs text-gray-400 hover:text-gray-200 disabled:opacity-30 disabled:cursor-not-allowed",children:"Next"})]})]})]})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Verified Skills"})}),re?n.jsx("div",{className:"p-8 flex justify-center",children:n.jsx(at,{})}):$e.length===0?n.jsxs("div",{className:"p-8 text-center",children:[n.jsx("p",{className:"text-gray-500 text-sm",children:"No verified skills yet"}),n.jsx("p",{className:"text-gray-600 text-xs mt-1",children:"Skills will appear here after passing security verification."})]}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4",children:$e.map(X=>n.jsxs("div",{className:"bg-gray-800/50 border border-gray-700/50 rounded-lg p-4 hover:border-gray-600 transition-colors",children:[n.jsxs("div",{className:"flex items-start justify-between mb-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm font-medium text-gray-200 truncate",children:X.repoFullName}),n.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:X.author})]}),n.jsx(fe,{label:"Verified",variant:"success"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("span",{className:"text-xs text-gray-400 flex items-center gap-1",children:[n.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),X.stars.toLocaleString()]}),n.jsxs("span",{className:`text-xs font-mono ${X0(X.securityScore)}`,children:["Score: ",X.securityScore]})]}),X.repoUrl&&n.jsx("a",{href:X.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"GitHub"})]})]},X.id))})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsx("h3",{className:"text-sm font-medium text-gray-300",children:"Insights"})}),J?n.jsx("div",{className:"p-8 flex justify-center",children:n.jsx(at,{})}):P?n.jsxs("div",{className:"p-4 space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Discovered",value:P.totalDiscovered,color:"cyan"}),n.jsx(ie,{title:"Verified",value:P.totalVerified,color:"emerald"}),n.jsx(ie,{title:"Rejected",value:P.totalRejected,color:"rose"}),n.jsx(ie,{title:"Pending",value:P.totalPending,color:"amber"})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(k0,{label:"Tier 1 Pass Rate",rate:P.tier1PassRate}),n.jsx(k0,{label:"Tier 2 Pass Rate",rate:P.tier2PassRate})]})]}):n.jsx("div",{className:"p-8 text-center",children:n.jsx("p",{className:"text-gray-500 text-sm",children:"No insights data available"})})]})]})}function k0({label:r,rate:o}){const c=Math.round(o),u=c>=70?"bg-emerald-500":c>=40?"bg-amber-500":"bg-rose-500";return n.jsxs("div",{className:"bg-gray-800/50 rounded-lg p-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("span",{className:"text-xs text-gray-400",children:r}),n.jsxs("span",{className:"text-sm font-bold text-gray-200",children:[c,"%"]})]}),n.jsx("div",{className:"w-full h-2 bg-gray-700 rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full ${u} rounded-full transition-all duration-500`,style:{width:`${c}%`}})})]})}function Wp(){const{id:r}=Bg(),[o,c]=S.useState(0);Ge("increment-update",()=>c(m=>m+1));const{data:u,loading:f,error:x,refetch:g}=Me(`/api/increments/${r||"_none"}?_r=${o}`);if(!r)return n.jsx("div",{className:"p-6 text-gray-500 text-sm",children:"No increment ID specified"});if(f)return n.jsx(at,{});if(x)return n.jsx(Xt,{message:x,onRetry:g});if(!u)return n.jsx("div",{className:"p-6 text-gray-500 text-sm",children:"Increment not found"});const b=u.taskSummary.total>0?Math.round(u.taskSummary.completed/u.taskSummary.total*100):0,p=u.acSummary.total>0?Math.round(u.acSummary.completed/u.acSummary.total*100):0;return n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[n.jsx("span",{className:"text-xs text-indigo-400 font-mono",children:u.dirName}),n.jsx(fe,{label:u.metadata.status||"unknown",variant:Ci(u.metadata.status||"")}),u.metadata.type&&n.jsx("span",{className:"text-xs text-gray-400 capitalize",children:u.metadata.type}),u.metadata.priority&&n.jsx(Fp,{priority:u.metadata.priority})]}),n.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:u.metadata.title||u.id}),u.metadata.project&&n.jsxs("span",{className:"text-xs text-gray-500",children:["Project: ",u.metadata.project]})]}),n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(ie,{title:"Tasks",value:`${u.taskSummary.completed}/${u.taskSummary.total}`,color:"indigo"}),n.jsx(ie,{title:"Task Progress",value:`${b}%`,color:"cyan"}),n.jsx(ie,{title:"ACs",value:`${u.acSummary.completed}/${u.acSummary.total}`,color:"emerald"}),n.jsx(ie,{title:"AC Progress",value:`${p}%`,color:"amber"})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5 space-y-4",children:[n.jsx(Z0,{label:"Tasks",completed:u.taskSummary.completed,total:u.taskSummary.total,color:"indigo"}),n.jsx(Z0,{label:"Acceptance Criteria",completed:u.acSummary.completed,total:u.acSummary.total,color:"emerald"})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsxs("h3",{className:"text-sm font-medium text-gray-300",children:["Tasks (",u.tasks.length,")"]})}),u.tasks.length===0?n.jsx("div",{className:"p-5 text-center text-gray-500 text-xs",children:"No tasks found in tasks.md"}):n.jsx("div",{className:"divide-y divide-gray-800/50",children:u.tasks.map(m=>n.jsxs("div",{className:"px-5 py-3 flex items-center gap-3",children:[n.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 ${m.status==="completed"?"bg-indigo-500/20 border-indigo-500 text-indigo-400":"border-gray-600"}`,children:m.status==="completed"&&n.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:m.id}),n.jsx("span",{className:`text-sm ${m.status==="completed"?"text-gray-500 line-through":"text-gray-300"}`,children:m.title})]}),(m.userStory||m.acs)&&n.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[m.userStory&&n.jsx("span",{className:"text-[10px] text-indigo-400",children:m.userStory}),m.acs?.map(v=>n.jsx("span",{className:"text-[10px] text-emerald-500",children:v},v))]})]})]},m.id))})]}),u.acs.length>0&&n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl overflow-hidden",children:[n.jsx("div",{className:"px-5 py-3 border-b border-gray-800",children:n.jsxs("h3",{className:"text-sm font-medium text-gray-300",children:["Acceptance Criteria (",u.acs.length,")"]})}),n.jsx("div",{className:"divide-y divide-gray-800/50",children:u.acs.map(m=>n.jsxs("div",{className:"px-5 py-3 flex items-start gap-3",children:[n.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 mt-0.5 ${m.completed?"bg-emerald-500/20 border-emerald-500 text-emerald-400":"border-gray-600"}`,children:m.completed&&n.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),n.jsxs("div",{children:[n.jsx("span",{className:"text-xs text-emerald-500 font-mono",children:m.id}),n.jsx("span",{className:`text-sm ml-2 ${m.completed?"text-gray-500 line-through":"text-gray-300"}`,children:m.text})]})]},m.id))})]}),n.jsxs("div",{className:"bg-gray-900/50 border border-gray-800 rounded-xl p-5",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-300 mb-3",children:"Metadata"}),n.jsx("div",{className:"space-y-1.5",children:Object.entries(u.metadata).filter(([m])=>!["title"].includes(m)).map(([m,v])=>n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-gray-500 font-mono",children:m}),n.jsx("span",{className:"text-xs text-gray-400",children:typeof v=="object"?JSON.stringify(v):String(v??"")})]},m))})]})]})}function Z0({label:r,completed:o,total:c,color:u}){const f=c>0?Math.round(o/c*100):0,x=u==="emerald"?"bg-emerald-500":"bg-indigo-500";return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[n.jsx("span",{className:"text-xs text-gray-400",children:r}),n.jsxs("span",{className:"text-xs text-gray-500",children:[o,"/",c," (",f,"%)"]})]}),n.jsx("div",{className:"w-full h-2 bg-gray-800 rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full ${x} rounded-full transition-all`,style:{width:`${f}%`}})})]})}function Fp({priority:r}){const o={P0:"text-rose-400 bg-rose-500/10",P1:"text-amber-400 bg-amber-500/10",P2:"text-cyan-400 bg-cyan-500/10",P3:"text-gray-400 bg-gray-500/10"};return n.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${o[r]||o.P2}`,children:r})}function Pp(){const r=Dy();return n.jsx(xm.Provider,{value:r,children:n.jsx(Uy,{children:n.jsxs("div",{className:"flex min-h-screen bg-gray-950 text-gray-100",children:[n.jsx(qy,{}),n.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[n.jsx(Yy,{}),n.jsx("main",{className:"flex-1 overflow-y-auto",children:n.jsxs(Ig,{children:[n.jsx(st,{path:"/",element:n.jsx(Fy,{})}),n.jsx(st,{path:"/increments",element:n.jsx(tp,{})}),n.jsx(st,{path:"/increments/:id",element:n.jsx(Wp,{})}),n.jsx(st,{path:"/analytics",element:n.jsx(np,{})}),n.jsx(st,{path:"/costs",element:n.jsx(op,{})}),n.jsx(st,{path:"/sync",element:n.jsx(yp,{})}),n.jsx(st,{path:"/errors",element:n.jsx(vp,{})}),n.jsx(st,{path:"/activity",element:n.jsx(Ap,{})}),n.jsx(st,{path:"/config",element:n.jsx(Rp,{})}),n.jsx(st,{path:"/plugins",element:n.jsx(Dp,{})}),n.jsx(st,{path:"/services",element:n.jsx(Up,{})}),n.jsx(st,{path:"/notifications",element:n.jsx(Hp,{})}),n.jsx(st,{path:"/repos",element:n.jsx(Yp,{})}),n.jsx(st,{path:"/marketplace",element:n.jsx(Jp,{})}),n.jsx(st,{path:"*",element:n.jsxs("div",{className:"p-6 text-center",children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-200 mb-2",children:"Page Not Found"}),n.jsx("p",{className:"text-sm text-gray-500",children:"The page you're looking for doesn't exist."})]})})]})})]})]})})})}tg.createRoot(document.getElementById("root")).render(n.jsx(S.StrictMode,{children:n.jsx(Ey,{children:n.jsx(Pp,{})})}));