@railtownai/railtracks-visualizer 0.0.53 → 0.0.55
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.
- package/dist/cjs/index.js +2872 -279
- package/dist/esm/index.js +2871 -281
- package/dist/types/agenthub/components/EvaluationsCompareView.d.ts +33 -0
- package/dist/types/agenthub/components/EvaluationsTable.d.ts +5 -1
- package/dist/types/agenthub/pages/evaluations-compare-drawer.d.ts +6 -6
- package/dist/types/agenthub/pages/evaluations-compare.d.ts +5 -1
- package/dist/types/agenthub/utils/evaluationsHaveSameMetrics.d.ts +15 -0
- package/dist/types/index.d.ts +6 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -8071,7 +8071,7 @@ function fixedForwardRef(render) {
|
|
|
8071
8071
|
return React.forwardRef(render);
|
|
8072
8072
|
}
|
|
8073
8073
|
// we need this hook to prevent a warning when using react-flow in SSR
|
|
8074
|
-
const useIsomorphicLayoutEffect$
|
|
8074
|
+
const useIsomorphicLayoutEffect$3 = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
8075
8075
|
/**
|
|
8076
8076
|
* This hook returns a queue that can be used to batch updates.
|
|
8077
8077
|
*
|
|
@@ -8096,7 +8096,7 @@ const useIsomorphicLayoutEffect$2 = typeof window !== 'undefined' ? React.useLay
|
|
|
8096
8096
|
* Layout effects are guaranteed to run before the next render which means we
|
|
8097
8097
|
* shouldn't run into any issues with stale state or weird issues that come from
|
|
8098
8098
|
* rendering things one frame later than expected (we used to use `setTimeout`).
|
|
8099
|
-
*/ useIsomorphicLayoutEffect$
|
|
8099
|
+
*/ useIsomorphicLayoutEffect$3(()=>{
|
|
8100
8100
|
const queueItems = queue.get();
|
|
8101
8101
|
if (queueItems.length) {
|
|
8102
8102
|
runQueue(queueItems);
|
|
@@ -15224,7 +15224,7 @@ function requireHoistNonReactStatics_cjs() {
|
|
|
15224
15224
|
|
|
15225
15225
|
requireHoistNonReactStatics_cjs();
|
|
15226
15226
|
|
|
15227
|
-
var isBrowser = true;
|
|
15227
|
+
var isBrowser$1 = true;
|
|
15228
15228
|
function getRegisteredStyles(registered, registeredStyles, classNames) {
|
|
15229
15229
|
var rawClassName = '';
|
|
15230
15230
|
classNames.split(' ').forEach(function(className) {
|
|
@@ -15246,7 +15246,7 @@ var registerStyles = function registerStyles(cache, serialized, isStringTag) {
|
|
|
15246
15246
|
// in node since emotion-server relies on whether a style is in
|
|
15247
15247
|
// the registered cache to know whether a style is global or not
|
|
15248
15248
|
// also, note that this check will be dead code eliminated in the browser
|
|
15249
|
-
isBrowser === false) && cache.registered[className] === undefined) {
|
|
15249
|
+
isBrowser$1 === false) && cache.registered[className] === undefined) {
|
|
15250
15250
|
cache.registered[className] = serialized.styles;
|
|
15251
15251
|
}
|
|
15252
15252
|
};
|
|
@@ -15894,6 +15894,21 @@ const ThemeProvider = ({ children, theme: propTheme })=>{
|
|
|
15894
15894
|
}, [
|
|
15895
15895
|
propTheme
|
|
15896
15896
|
]);
|
|
15897
|
+
// Sync html.dark class for GlobalStyles and other CSS that uses html.dark
|
|
15898
|
+
React.useEffect(()=>{
|
|
15899
|
+
const isDark = currentTheme === darkTheme;
|
|
15900
|
+
try {
|
|
15901
|
+
if (isDark) {
|
|
15902
|
+
document.documentElement.classList.add("dark");
|
|
15903
|
+
} else {
|
|
15904
|
+
document.documentElement.classList.remove("dark");
|
|
15905
|
+
}
|
|
15906
|
+
} catch (e) {
|
|
15907
|
+
// document might not be available (e.g. SSR)
|
|
15908
|
+
}
|
|
15909
|
+
}, [
|
|
15910
|
+
currentTheme
|
|
15911
|
+
]);
|
|
15897
15912
|
// Only listen for storage events if no theme prop is provided
|
|
15898
15913
|
React.useEffect(()=>{
|
|
15899
15914
|
if (propTheme) {
|
|
@@ -21001,7 +21016,7 @@ function cn(...inputs) {
|
|
|
21001
21016
|
/**
|
|
21002
21017
|
* Formats a metric value for display based on evaluator metric definitions.
|
|
21003
21018
|
* Handles Categorical (index → option label), Continuous (decimal), and fallback.
|
|
21004
|
-
*/ function formatMetricValue(evaluator, metricName, value) {
|
|
21019
|
+
*/ function formatMetricValue$1(evaluator, metricName, value) {
|
|
21005
21020
|
if (value === undefined || value === null) return "-";
|
|
21006
21021
|
const numericValue = typeof value === "number" ? value : Number(value);
|
|
21007
21022
|
if (isNaN(numericValue)) return "-";
|
|
@@ -21644,7 +21659,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
21644
21659
|
}
|
|
21645
21660
|
};
|
|
21646
21661
|
}
|
|
21647
|
-
const warning = _warning;
|
|
21662
|
+
const warning$1 = _warning;
|
|
21648
21663
|
const WarningContext = /*#__PURE__*/ React__namespace.createContext({});
|
|
21649
21664
|
/**
|
|
21650
21665
|
* This is a hook but we not named as `useWarning`
|
|
@@ -21668,7 +21683,7 @@ const WarningContext = /*#__PURE__*/ React__namespace.createContext({});
|
|
|
21668
21683
|
console.warn('[antd] There exists deprecated usage in your code:', deprecatedWarnList);
|
|
21669
21684
|
}
|
|
21670
21685
|
} else {
|
|
21671
|
-
process.env.NODE_ENV !== "production" ? warning(valid, component, message) : void 0;
|
|
21686
|
+
process.env.NODE_ENV !== "production" ? warning$1(valid, component, message) : void 0;
|
|
21672
21687
|
}
|
|
21673
21688
|
}
|
|
21674
21689
|
};
|
|
@@ -23519,6 +23534,367 @@ const useZIndex = (componentType, customZIndex)=>{
|
|
|
23519
23534
|
return result;
|
|
23520
23535
|
};
|
|
23521
23536
|
|
|
23537
|
+
const genAlertTypeStyle = (bgColor, borderColor, iconColor, token, alertCls)=>({
|
|
23538
|
+
background: bgColor,
|
|
23539
|
+
border: `${cssinjs.unit(token.lineWidth)} ${token.lineType} ${borderColor}`,
|
|
23540
|
+
[`${alertCls}-icon`]: {
|
|
23541
|
+
color: iconColor
|
|
23542
|
+
}
|
|
23543
|
+
});
|
|
23544
|
+
const genBaseStyle$6 = (token)=>{
|
|
23545
|
+
const { componentCls, motionDurationSlow: duration, marginXS, marginSM, fontSize, fontSizeLG, lineHeight, borderRadiusLG: borderRadius, motionEaseInOutCirc, withDescriptionIconSize, colorText, colorTextHeading, withDescriptionPadding, defaultPadding } = token;
|
|
23546
|
+
return {
|
|
23547
|
+
[componentCls]: {
|
|
23548
|
+
...resetComponent(token),
|
|
23549
|
+
position: 'relative',
|
|
23550
|
+
display: 'flex',
|
|
23551
|
+
alignItems: 'center',
|
|
23552
|
+
padding: defaultPadding,
|
|
23553
|
+
wordWrap: 'break-word',
|
|
23554
|
+
borderRadius,
|
|
23555
|
+
[`&${componentCls}-rtl`]: {
|
|
23556
|
+
direction: 'rtl'
|
|
23557
|
+
},
|
|
23558
|
+
[`${componentCls}-section`]: {
|
|
23559
|
+
flex: 1,
|
|
23560
|
+
minWidth: 0
|
|
23561
|
+
},
|
|
23562
|
+
[`${componentCls}-icon`]: {
|
|
23563
|
+
marginInlineEnd: marginXS,
|
|
23564
|
+
lineHeight: 0
|
|
23565
|
+
},
|
|
23566
|
+
'&-description': {
|
|
23567
|
+
display: 'none',
|
|
23568
|
+
fontSize,
|
|
23569
|
+
lineHeight
|
|
23570
|
+
},
|
|
23571
|
+
'&-title': {
|
|
23572
|
+
color: colorTextHeading
|
|
23573
|
+
},
|
|
23574
|
+
[`&${componentCls}-motion-leave`]: {
|
|
23575
|
+
overflow: 'hidden',
|
|
23576
|
+
opacity: 1,
|
|
23577
|
+
transition: [
|
|
23578
|
+
`max-height`,
|
|
23579
|
+
`opacity`,
|
|
23580
|
+
`padding-top`,
|
|
23581
|
+
`padding-bottom`,
|
|
23582
|
+
`margin-bottom`
|
|
23583
|
+
].map((prop)=>`${prop} ${duration} ${motionEaseInOutCirc}`).join(', ')
|
|
23584
|
+
},
|
|
23585
|
+
[`&${componentCls}-motion-leave-active`]: {
|
|
23586
|
+
maxHeight: 0,
|
|
23587
|
+
marginBottom: '0 !important',
|
|
23588
|
+
paddingTop: 0,
|
|
23589
|
+
paddingBottom: 0,
|
|
23590
|
+
opacity: 0
|
|
23591
|
+
}
|
|
23592
|
+
},
|
|
23593
|
+
[`${componentCls}-with-description`]: {
|
|
23594
|
+
alignItems: 'flex-start',
|
|
23595
|
+
padding: withDescriptionPadding,
|
|
23596
|
+
[`${componentCls}-icon`]: {
|
|
23597
|
+
marginInlineEnd: marginSM,
|
|
23598
|
+
fontSize: withDescriptionIconSize,
|
|
23599
|
+
lineHeight: 0
|
|
23600
|
+
},
|
|
23601
|
+
[`${componentCls}-title`]: {
|
|
23602
|
+
display: 'block',
|
|
23603
|
+
marginBottom: marginXS,
|
|
23604
|
+
color: colorTextHeading,
|
|
23605
|
+
fontSize: fontSizeLG
|
|
23606
|
+
},
|
|
23607
|
+
[`${componentCls}-description`]: {
|
|
23608
|
+
display: 'block',
|
|
23609
|
+
color: colorText
|
|
23610
|
+
}
|
|
23611
|
+
},
|
|
23612
|
+
[`${componentCls}-banner`]: {
|
|
23613
|
+
marginBottom: 0,
|
|
23614
|
+
border: '0 !important',
|
|
23615
|
+
borderRadius: 0
|
|
23616
|
+
}
|
|
23617
|
+
};
|
|
23618
|
+
};
|
|
23619
|
+
const genTypeStyle = (token)=>{
|
|
23620
|
+
const { componentCls, colorSuccess, colorSuccessBorder, colorSuccessBg, colorWarning, colorWarningBorder, colorWarningBg, colorError, colorErrorBorder, colorErrorBg, colorInfo, colorInfoBorder, colorInfoBg } = token;
|
|
23621
|
+
return {
|
|
23622
|
+
[componentCls]: {
|
|
23623
|
+
'&-success': genAlertTypeStyle(colorSuccessBg, colorSuccessBorder, colorSuccess, token, componentCls),
|
|
23624
|
+
'&-info': genAlertTypeStyle(colorInfoBg, colorInfoBorder, colorInfo, token, componentCls),
|
|
23625
|
+
'&-warning': genAlertTypeStyle(colorWarningBg, colorWarningBorder, colorWarning, token, componentCls),
|
|
23626
|
+
'&-error': {
|
|
23627
|
+
...genAlertTypeStyle(colorErrorBg, colorErrorBorder, colorError, token, componentCls),
|
|
23628
|
+
[`${componentCls}-description > pre`]: {
|
|
23629
|
+
margin: 0,
|
|
23630
|
+
padding: 0
|
|
23631
|
+
}
|
|
23632
|
+
}
|
|
23633
|
+
}
|
|
23634
|
+
};
|
|
23635
|
+
};
|
|
23636
|
+
const genActionStyle = (token)=>{
|
|
23637
|
+
const { componentCls, iconCls, motionDurationMid, marginXS, fontSizeIcon, colorIcon, colorIconHover } = token;
|
|
23638
|
+
return {
|
|
23639
|
+
[componentCls]: {
|
|
23640
|
+
'&-actions': {
|
|
23641
|
+
marginInlineStart: marginXS
|
|
23642
|
+
},
|
|
23643
|
+
[`${componentCls}-close-icon`]: {
|
|
23644
|
+
marginInlineStart: marginXS,
|
|
23645
|
+
padding: 0,
|
|
23646
|
+
overflow: 'hidden',
|
|
23647
|
+
fontSize: fontSizeIcon,
|
|
23648
|
+
lineHeight: cssinjs.unit(fontSizeIcon),
|
|
23649
|
+
backgroundColor: 'transparent',
|
|
23650
|
+
border: 'none',
|
|
23651
|
+
outline: 'none',
|
|
23652
|
+
cursor: 'pointer',
|
|
23653
|
+
[`${iconCls}-close`]: {
|
|
23654
|
+
color: colorIcon,
|
|
23655
|
+
transition: `color ${motionDurationMid}`,
|
|
23656
|
+
'&:hover': {
|
|
23657
|
+
color: colorIconHover
|
|
23658
|
+
}
|
|
23659
|
+
}
|
|
23660
|
+
},
|
|
23661
|
+
'&-close-text': {
|
|
23662
|
+
color: colorIcon,
|
|
23663
|
+
transition: `color ${motionDurationMid}`,
|
|
23664
|
+
'&:hover': {
|
|
23665
|
+
color: colorIconHover
|
|
23666
|
+
}
|
|
23667
|
+
}
|
|
23668
|
+
}
|
|
23669
|
+
};
|
|
23670
|
+
};
|
|
23671
|
+
const prepareComponentToken$n = (token)=>{
|
|
23672
|
+
const paddingHorizontal = 12; // Fixed value here.
|
|
23673
|
+
return {
|
|
23674
|
+
withDescriptionIconSize: token.fontSizeHeading3,
|
|
23675
|
+
defaultPadding: `${token.paddingContentVerticalSM}px ${paddingHorizontal}px`,
|
|
23676
|
+
withDescriptionPadding: `${token.paddingMD}px ${token.paddingContentHorizontalLG}px`
|
|
23677
|
+
};
|
|
23678
|
+
};
|
|
23679
|
+
var useStyle$u = genStyleHooks('Alert', (token)=>[
|
|
23680
|
+
genBaseStyle$6(token),
|
|
23681
|
+
genTypeStyle(token),
|
|
23682
|
+
genActionStyle(token)
|
|
23683
|
+
], prepareComponentToken$n);
|
|
23684
|
+
|
|
23685
|
+
const IconNode = (props)=>{
|
|
23686
|
+
const { icon, type, className, style, successIcon, infoIcon, warningIcon, errorIcon } = props;
|
|
23687
|
+
const iconMapFilled = {
|
|
23688
|
+
success: successIcon ?? /*#__PURE__*/ React__namespace.createElement(CheckCircleFilled, null),
|
|
23689
|
+
info: infoIcon ?? /*#__PURE__*/ React__namespace.createElement(InfoCircleFilled, null),
|
|
23690
|
+
error: errorIcon ?? /*#__PURE__*/ React__namespace.createElement(CloseCircleFilled, null),
|
|
23691
|
+
warning: warningIcon ?? /*#__PURE__*/ React__namespace.createElement(ExclamationCircleFilled, null)
|
|
23692
|
+
};
|
|
23693
|
+
return /*#__PURE__*/ React__namespace.createElement("span", {
|
|
23694
|
+
className: className,
|
|
23695
|
+
style: style
|
|
23696
|
+
}, icon ?? iconMapFilled[type]);
|
|
23697
|
+
};
|
|
23698
|
+
const CloseIconNode = (props)=>{
|
|
23699
|
+
const { isClosable, prefixCls, closeIcon, handleClose, ariaProps, className, style } = props;
|
|
23700
|
+
const mergedCloseIcon = closeIcon === true || closeIcon === undefined ? /*#__PURE__*/ React__namespace.createElement(CloseOutlined, null) : closeIcon;
|
|
23701
|
+
return isClosable ? /*#__PURE__*/ React__namespace.createElement("button", {
|
|
23702
|
+
type: "button",
|
|
23703
|
+
onClick: handleClose,
|
|
23704
|
+
className: clsx(`${prefixCls}-close-icon`, className),
|
|
23705
|
+
tabIndex: 0,
|
|
23706
|
+
style: style,
|
|
23707
|
+
...ariaProps
|
|
23708
|
+
}, mergedCloseIcon) : null;
|
|
23709
|
+
};
|
|
23710
|
+
const Alert$1 = /*#__PURE__*/ React__namespace.forwardRef((props, ref$1)=>{
|
|
23711
|
+
const { description, prefixCls: customizePrefixCls, message, title, banner, className, rootClassName, style, onMouseEnter, onMouseLeave, onClick, afterClose, showIcon, closable, closeText, closeIcon, action, id, styles, classNames, ...otherProps } = props;
|
|
23712
|
+
const mergedTitle = title ?? message;
|
|
23713
|
+
const [closed, setClosed] = React__namespace.useState(false);
|
|
23714
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
23715
|
+
const warning = devUseWarning('Alert');
|
|
23716
|
+
[
|
|
23717
|
+
[
|
|
23718
|
+
'closeText',
|
|
23719
|
+
'closable.closeIcon'
|
|
23720
|
+
],
|
|
23721
|
+
[
|
|
23722
|
+
'message',
|
|
23723
|
+
'title'
|
|
23724
|
+
]
|
|
23725
|
+
].forEach(([deprecatedName, newName])=>{
|
|
23726
|
+
warning.deprecated(!(deprecatedName in props), deprecatedName, newName);
|
|
23727
|
+
});
|
|
23728
|
+
}
|
|
23729
|
+
const internalRef = React__namespace.useRef(null);
|
|
23730
|
+
React__namespace.useImperativeHandle(ref$1, ()=>({
|
|
23731
|
+
nativeElement: internalRef.current
|
|
23732
|
+
}));
|
|
23733
|
+
const { getPrefixCls, direction, closable: contextClosable, closeIcon: contextCloseIcon, className: contextClassName, style: contextStyle, classNames: contextClassNames, styles: contextStyles, successIcon, infoIcon, warningIcon, errorIcon } = useComponentConfig('alert');
|
|
23734
|
+
const prefixCls = getPrefixCls('alert', customizePrefixCls);
|
|
23735
|
+
const [hashId, cssVarCls] = useStyle$u(prefixCls);
|
|
23736
|
+
const { onClose: closableOnClose, afterClose: closableAfterClose } = closable && typeof closable === 'object' ? closable : {};
|
|
23737
|
+
const handleClose = (e)=>{
|
|
23738
|
+
setClosed(true);
|
|
23739
|
+
(closableOnClose ?? props.onClose)?.(e);
|
|
23740
|
+
};
|
|
23741
|
+
const type = React__namespace.useMemo(()=>{
|
|
23742
|
+
if (props.type !== undefined) {
|
|
23743
|
+
return props.type;
|
|
23744
|
+
}
|
|
23745
|
+
// banner mode defaults to 'warning'
|
|
23746
|
+
return banner ? 'warning' : 'info';
|
|
23747
|
+
}, [
|
|
23748
|
+
props.type,
|
|
23749
|
+
banner
|
|
23750
|
+
]);
|
|
23751
|
+
// closeable when closeText or closeIcon is assigned
|
|
23752
|
+
const isClosable = React__namespace.useMemo(()=>{
|
|
23753
|
+
if (typeof closable === 'object' && closable.closeIcon) {
|
|
23754
|
+
return true;
|
|
23755
|
+
}
|
|
23756
|
+
if (closeText) {
|
|
23757
|
+
return true;
|
|
23758
|
+
}
|
|
23759
|
+
if (typeof closable === 'boolean') {
|
|
23760
|
+
return closable;
|
|
23761
|
+
}
|
|
23762
|
+
// should be true when closeIcon is 0 or ''
|
|
23763
|
+
if (closeIcon !== false && isNonNullable(closeIcon)) {
|
|
23764
|
+
return true;
|
|
23765
|
+
}
|
|
23766
|
+
return !!contextClosable;
|
|
23767
|
+
}, [
|
|
23768
|
+
closeText,
|
|
23769
|
+
closeIcon,
|
|
23770
|
+
closable,
|
|
23771
|
+
contextClosable
|
|
23772
|
+
]);
|
|
23773
|
+
// banner mode defaults to Icon
|
|
23774
|
+
const isShowIcon = banner && showIcon === undefined ? true : showIcon;
|
|
23775
|
+
// =========== Merged Props for Semantic ==========
|
|
23776
|
+
const mergedProps = {
|
|
23777
|
+
...props,
|
|
23778
|
+
prefixCls,
|
|
23779
|
+
type,
|
|
23780
|
+
showIcon: isShowIcon,
|
|
23781
|
+
closable: isClosable
|
|
23782
|
+
};
|
|
23783
|
+
const [mergedClassNames, mergedStyles] = useMergeSemantic([
|
|
23784
|
+
contextClassNames,
|
|
23785
|
+
classNames
|
|
23786
|
+
], [
|
|
23787
|
+
contextStyles,
|
|
23788
|
+
styles
|
|
23789
|
+
], {
|
|
23790
|
+
props: mergedProps
|
|
23791
|
+
});
|
|
23792
|
+
const alertCls = clsx(prefixCls, `${prefixCls}-${type}`, {
|
|
23793
|
+
[`${prefixCls}-with-description`]: !!description,
|
|
23794
|
+
[`${prefixCls}-no-icon`]: !isShowIcon,
|
|
23795
|
+
[`${prefixCls}-banner`]: !!banner,
|
|
23796
|
+
[`${prefixCls}-rtl`]: direction === 'rtl'
|
|
23797
|
+
}, contextClassName, className, rootClassName, mergedClassNames.root, cssVarCls, hashId);
|
|
23798
|
+
const restProps = pickAttrs(otherProps, {
|
|
23799
|
+
aria: true,
|
|
23800
|
+
data: true
|
|
23801
|
+
});
|
|
23802
|
+
const mergedCloseIcon = React__namespace.useMemo(()=>{
|
|
23803
|
+
if (typeof closable === 'object' && closable.closeIcon) {
|
|
23804
|
+
return closable.closeIcon;
|
|
23805
|
+
}
|
|
23806
|
+
if (closeText) {
|
|
23807
|
+
return closeText;
|
|
23808
|
+
}
|
|
23809
|
+
if (closeIcon !== undefined) {
|
|
23810
|
+
return closeIcon;
|
|
23811
|
+
}
|
|
23812
|
+
if (typeof contextClosable === 'object' && contextClosable.closeIcon) {
|
|
23813
|
+
return contextClosable.closeIcon;
|
|
23814
|
+
}
|
|
23815
|
+
return contextCloseIcon;
|
|
23816
|
+
}, [
|
|
23817
|
+
closeIcon,
|
|
23818
|
+
closable,
|
|
23819
|
+
contextClosable,
|
|
23820
|
+
closeText,
|
|
23821
|
+
contextCloseIcon
|
|
23822
|
+
]);
|
|
23823
|
+
const mergedAriaProps = React__namespace.useMemo(()=>{
|
|
23824
|
+
const merged = closable ?? contextClosable;
|
|
23825
|
+
if (typeof merged === 'object') {
|
|
23826
|
+
return pickAttrs(merged, {
|
|
23827
|
+
data: true,
|
|
23828
|
+
aria: true
|
|
23829
|
+
});
|
|
23830
|
+
}
|
|
23831
|
+
return {};
|
|
23832
|
+
}, [
|
|
23833
|
+
closable,
|
|
23834
|
+
contextClosable
|
|
23835
|
+
]);
|
|
23836
|
+
return /*#__PURE__*/ React__namespace.createElement(CSSMotion, {
|
|
23837
|
+
visible: !closed,
|
|
23838
|
+
motionName: `${prefixCls}-motion`,
|
|
23839
|
+
motionAppear: false,
|
|
23840
|
+
motionEnter: false,
|
|
23841
|
+
onLeaveStart: (node)=>({
|
|
23842
|
+
maxHeight: node.offsetHeight
|
|
23843
|
+
}),
|
|
23844
|
+
onLeaveEnd: closableAfterClose ?? afterClose
|
|
23845
|
+
}, ({ className: motionClassName, style: motionStyle }, setRef)=>/*#__PURE__*/ React__namespace.createElement("div", {
|
|
23846
|
+
id: id,
|
|
23847
|
+
ref: ref.composeRef(internalRef, setRef),
|
|
23848
|
+
"data-show": !closed,
|
|
23849
|
+
className: clsx(alertCls, motionClassName),
|
|
23850
|
+
style: {
|
|
23851
|
+
...mergedStyles.root,
|
|
23852
|
+
...contextStyle,
|
|
23853
|
+
...style,
|
|
23854
|
+
...motionStyle
|
|
23855
|
+
},
|
|
23856
|
+
onMouseEnter: onMouseEnter,
|
|
23857
|
+
onMouseLeave: onMouseLeave,
|
|
23858
|
+
onClick: onClick,
|
|
23859
|
+
role: "alert",
|
|
23860
|
+
...restProps
|
|
23861
|
+
}, isShowIcon ? /*#__PURE__*/ React__namespace.createElement(IconNode, {
|
|
23862
|
+
className: clsx(`${prefixCls}-icon`, mergedClassNames.icon),
|
|
23863
|
+
style: mergedStyles.icon,
|
|
23864
|
+
description: description,
|
|
23865
|
+
icon: props.icon,
|
|
23866
|
+
prefixCls: prefixCls,
|
|
23867
|
+
type: type,
|
|
23868
|
+
successIcon: successIcon,
|
|
23869
|
+
infoIcon: infoIcon,
|
|
23870
|
+
warningIcon: warningIcon,
|
|
23871
|
+
errorIcon: errorIcon
|
|
23872
|
+
}) : null, /*#__PURE__*/ React__namespace.createElement("div", {
|
|
23873
|
+
className: clsx(`${prefixCls}-section`, mergedClassNames.section),
|
|
23874
|
+
style: mergedStyles.section
|
|
23875
|
+
}, mergedTitle ? /*#__PURE__*/ React__namespace.createElement("div", {
|
|
23876
|
+
className: clsx(`${prefixCls}-title`, mergedClassNames.title),
|
|
23877
|
+
style: mergedStyles.title
|
|
23878
|
+
}, mergedTitle) : null, description ? /*#__PURE__*/ React__namespace.createElement("div", {
|
|
23879
|
+
className: clsx(`${prefixCls}-description`, mergedClassNames.description),
|
|
23880
|
+
style: mergedStyles.description
|
|
23881
|
+
}, description) : null), action ? /*#__PURE__*/ React__namespace.createElement("div", {
|
|
23882
|
+
className: clsx(`${prefixCls}-actions`, mergedClassNames.actions),
|
|
23883
|
+
style: mergedStyles.actions
|
|
23884
|
+
}, action) : null, /*#__PURE__*/ React__namespace.createElement(CloseIconNode, {
|
|
23885
|
+
className: mergedClassNames.close,
|
|
23886
|
+
style: mergedStyles.close,
|
|
23887
|
+
isClosable: isClosable,
|
|
23888
|
+
prefixCls: prefixCls,
|
|
23889
|
+
closeIcon: mergedCloseIcon,
|
|
23890
|
+
handleClose: handleClose,
|
|
23891
|
+
ariaProps: mergedAriaProps
|
|
23892
|
+
})));
|
|
23893
|
+
});
|
|
23894
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
23895
|
+
Alert$1.displayName = 'Alert';
|
|
23896
|
+
}
|
|
23897
|
+
|
|
23522
23898
|
function _classCallCheck(a, n) {
|
|
23523
23899
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
23524
23900
|
}
|
|
@@ -23560,6 +23936,110 @@ function _createClass(e, r, t) {
|
|
|
23560
23936
|
}), e;
|
|
23561
23937
|
}
|
|
23562
23938
|
|
|
23939
|
+
function _getPrototypeOf(t) {
|
|
23940
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
|
|
23941
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
23942
|
+
}, _getPrototypeOf(t);
|
|
23943
|
+
}
|
|
23944
|
+
|
|
23945
|
+
function _isNativeReflectConstruct() {
|
|
23946
|
+
try {
|
|
23947
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
23948
|
+
} catch (t) {}
|
|
23949
|
+
return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
|
|
23950
|
+
return !!t;
|
|
23951
|
+
})();
|
|
23952
|
+
}
|
|
23953
|
+
|
|
23954
|
+
function _assertThisInitialized(e) {
|
|
23955
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
23956
|
+
return e;
|
|
23957
|
+
}
|
|
23958
|
+
|
|
23959
|
+
function _possibleConstructorReturn(t, e) {
|
|
23960
|
+
if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
|
|
23961
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
23962
|
+
return _assertThisInitialized(t);
|
|
23963
|
+
}
|
|
23964
|
+
|
|
23965
|
+
function _callSuper(t, o, e) {
|
|
23966
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
23967
|
+
}
|
|
23968
|
+
|
|
23969
|
+
function _setPrototypeOf(t, e) {
|
|
23970
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, e) {
|
|
23971
|
+
return t.__proto__ = e, t;
|
|
23972
|
+
}, _setPrototypeOf(t, e);
|
|
23973
|
+
}
|
|
23974
|
+
|
|
23975
|
+
function _inherits(t, e) {
|
|
23976
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
23977
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
23978
|
+
constructor: {
|
|
23979
|
+
value: t,
|
|
23980
|
+
writable: true,
|
|
23981
|
+
configurable: true
|
|
23982
|
+
}
|
|
23983
|
+
}), Object.defineProperty(t, "prototype", {
|
|
23984
|
+
writable: false
|
|
23985
|
+
}), e && _setPrototypeOf(t, e);
|
|
23986
|
+
}
|
|
23987
|
+
|
|
23988
|
+
let ErrorBoundary$1 = /*#__PURE__*/ function(_React$Component) {
|
|
23989
|
+
function ErrorBoundary() {
|
|
23990
|
+
var _this;
|
|
23991
|
+
_classCallCheck(this, ErrorBoundary);
|
|
23992
|
+
_this = _callSuper(this, ErrorBoundary, arguments);
|
|
23993
|
+
_this.state = {
|
|
23994
|
+
error: undefined,
|
|
23995
|
+
info: {
|
|
23996
|
+
componentStack: ''
|
|
23997
|
+
}
|
|
23998
|
+
};
|
|
23999
|
+
return _this;
|
|
24000
|
+
}
|
|
24001
|
+
_inherits(ErrorBoundary, _React$Component);
|
|
24002
|
+
return _createClass(ErrorBoundary, [
|
|
24003
|
+
{
|
|
24004
|
+
key: "componentDidCatch",
|
|
24005
|
+
value: function componentDidCatch(error, info) {
|
|
24006
|
+
this.setState({
|
|
24007
|
+
error,
|
|
24008
|
+
info
|
|
24009
|
+
});
|
|
24010
|
+
}
|
|
24011
|
+
},
|
|
24012
|
+
{
|
|
24013
|
+
key: "render",
|
|
24014
|
+
value: function render() {
|
|
24015
|
+
const { message, title, description, id, children } = this.props;
|
|
24016
|
+
const { error, info } = this.state;
|
|
24017
|
+
const mergedTitle = title ?? message;
|
|
24018
|
+
const componentStack = info?.componentStack || null;
|
|
24019
|
+
const errorMessage = typeof mergedTitle === 'undefined' ? (error || '').toString() : mergedTitle;
|
|
24020
|
+
const errorDescription = typeof description === 'undefined' ? componentStack : description;
|
|
24021
|
+
if (error) {
|
|
24022
|
+
return /*#__PURE__*/ React__namespace.createElement(Alert$1, {
|
|
24023
|
+
id: id,
|
|
24024
|
+
type: "error",
|
|
24025
|
+
title: errorMessage,
|
|
24026
|
+
description: /*#__PURE__*/ React__namespace.createElement("pre", {
|
|
24027
|
+
style: {
|
|
24028
|
+
fontSize: '0.9em',
|
|
24029
|
+
overflowX: 'auto'
|
|
24030
|
+
}
|
|
24031
|
+
}, errorDescription)
|
|
24032
|
+
});
|
|
24033
|
+
}
|
|
24034
|
+
return children;
|
|
24035
|
+
}
|
|
24036
|
+
}
|
|
24037
|
+
]);
|
|
24038
|
+
}(React__namespace.Component);
|
|
24039
|
+
|
|
24040
|
+
const Alert = Alert$1;
|
|
24041
|
+
Alert.ErrorBoundary = ErrorBoundary$1;
|
|
24042
|
+
|
|
23563
24043
|
function isWindow(obj) {
|
|
23564
24044
|
return isNonNullable(obj) && obj === obj.window;
|
|
23565
24045
|
}
|
|
@@ -23842,7 +24322,7 @@ var PropWarning = process.env.NODE_ENV !== 'production' ? PropWarning$1 : ()=>nu
|
|
|
23842
24322
|
* theme register info here to help developer get warning info.
|
|
23843
24323
|
*/ let existThemeConfig = false;
|
|
23844
24324
|
const warnContext = process.env.NODE_ENV !== 'production' ? (componentName)=>{
|
|
23845
|
-
process.env.NODE_ENV !== "production" ? warning(!existThemeConfig, componentName, `Static function can not consume context like dynamic theme. Please use 'App' component instead.`) : void 0;
|
|
24325
|
+
process.env.NODE_ENV !== "production" ? warning$1(!existThemeConfig, componentName, `Static function can not consume context like dynamic theme. Please use 'App' component instead.`) : void 0;
|
|
23846
24326
|
} : /* istanbul ignore next */ null;
|
|
23847
24327
|
// These props is used by `useContext` directly in sub component
|
|
23848
24328
|
const PASSED_PROPS = [
|
|
@@ -24158,7 +24638,7 @@ ConfigProvider.config = setGlobalConfig;
|
|
|
24158
24638
|
ConfigProvider.useConfig = useConfig;
|
|
24159
24639
|
Object.defineProperty(ConfigProvider, 'SizeContext', {
|
|
24160
24640
|
get: ()=>{
|
|
24161
|
-
process.env.NODE_ENV !== "production" ? warning(false, 'ConfigProvider', 'ConfigProvider.SizeContext is deprecated. Please use `ConfigProvider.useConfig().componentSize` instead.') : void 0;
|
|
24641
|
+
process.env.NODE_ENV !== "production" ? warning$1(false, 'ConfigProvider', 'ConfigProvider.SizeContext is deprecated. Please use `ConfigProvider.useConfig().componentSize` instead.') : void 0;
|
|
24162
24642
|
return SizeContext;
|
|
24163
24643
|
}
|
|
24164
24644
|
});
|
|
@@ -46810,7 +47290,7 @@ const asyncCopy = async (text, isHtmlFormat)=>{
|
|
|
46810
47290
|
};
|
|
46811
47291
|
async function copy(text, config) {
|
|
46812
47292
|
if (typeof text !== 'string') {
|
|
46813
|
-
process.env.NODE_ENV !== "production" ? warning(false, 'The clipboard content must be of string type', '') : void 0;
|
|
47293
|
+
process.env.NODE_ENV !== "production" ? warning$1(false, 'The clipboard content must be of string type', '') : void 0;
|
|
46814
47294
|
return false;
|
|
46815
47295
|
}
|
|
46816
47296
|
const isHtmlFormat = config?.format === 'text/html';
|
|
@@ -47599,7 +48079,7 @@ const Base = /*#__PURE__*/ React__namespace.forwardRef((props, ref$1)=>{
|
|
|
47599
48079
|
}, node) : node, renderEllipsis(canEllipsis)))))));
|
|
47600
48080
|
});
|
|
47601
48081
|
|
|
47602
|
-
const Link = /*#__PURE__*/ React__namespace.forwardRef((props, ref)=>{
|
|
48082
|
+
const Link$1 = /*#__PURE__*/ React__namespace.forwardRef((props, ref)=>{
|
|
47603
48083
|
const { ellipsis, rel, children, // @ts-expect-error: https://github.com/ant-design/ant-design/issues/26622
|
|
47604
48084
|
navigate: _navigate, ...restProps } = props;
|
|
47605
48085
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -47675,7 +48155,7 @@ const Title$1 = /*#__PURE__*/ React__namespace.forwardRef((props, ref)=>{
|
|
|
47675
48155
|
|
|
47676
48156
|
const Typography = Typography$1;
|
|
47677
48157
|
Typography.Text = Text$1;
|
|
47678
|
-
Typography.Link = Link;
|
|
48158
|
+
Typography.Link = Link$1;
|
|
47679
48159
|
Typography.Title = Title$1;
|
|
47680
48160
|
Typography.Paragraph = Paragraph;
|
|
47681
48161
|
|
|
@@ -49659,7 +50139,7 @@ const Timeline = ({ stamps, currentStep, onStepChange, onToggle })=>{
|
|
|
49659
50139
|
};
|
|
49660
50140
|
|
|
49661
50141
|
// src/primitive.tsx
|
|
49662
|
-
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
50142
|
+
function composeEventHandlers$1(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
49663
50143
|
return function handleEvent(event) {
|
|
49664
50144
|
originalEventHandler?.(event);
|
|
49665
50145
|
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
@@ -50172,9 +50652,9 @@ var DismissableLayer = React__namespace.forwardRef((props, forwardedRef)=>{
|
|
|
50172
50652
|
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
50173
50653
|
...props.style
|
|
50174
50654
|
},
|
|
50175
|
-
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
50176
|
-
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
50177
|
-
onPointerDownCapture: composeEventHandlers(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
|
|
50655
|
+
onFocusCapture: composeEventHandlers$1(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
50656
|
+
onBlurCapture: composeEventHandlers$1(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
50657
|
+
onPointerDownCapture: composeEventHandlers$1(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
|
|
50178
50658
|
});
|
|
50179
50659
|
});
|
|
50180
50660
|
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
@@ -50808,7 +51288,7 @@ var noScrollbarsClassName = 'with-scroll-bars-hidden';
|
|
|
50808
51288
|
return ref.facade;
|
|
50809
51289
|
}
|
|
50810
51290
|
|
|
50811
|
-
var useIsomorphicLayoutEffect$
|
|
51291
|
+
var useIsomorphicLayoutEffect$2 = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
50812
51292
|
var currentValues = new WeakMap();
|
|
50813
51293
|
/**
|
|
50814
51294
|
* Merges two or more refs together providing a single interface to set their value
|
|
@@ -50830,7 +51310,7 @@ var currentValues = new WeakMap();
|
|
|
50830
51310
|
});
|
|
50831
51311
|
});
|
|
50832
51312
|
// handle refs changes - added or removed
|
|
50833
|
-
useIsomorphicLayoutEffect$
|
|
51313
|
+
useIsomorphicLayoutEffect$2(function() {
|
|
50834
51314
|
var oldValue = currentValues.get(callbackRef);
|
|
50835
51315
|
if (oldValue) {
|
|
50836
51316
|
var prevRefs_1 = new Set(oldValue);
|
|
@@ -51719,7 +52199,7 @@ var DialogTrigger = React__namespace.forwardRef((props, forwardedRef)=>{
|
|
|
51719
52199
|
"data-state": getState(context.open),
|
|
51720
52200
|
...triggerProps,
|
|
51721
52201
|
ref: composedTriggerRef,
|
|
51722
|
-
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
52202
|
+
onClick: composeEventHandlers$1(props.onClick, context.onOpenToggle)
|
|
51723
52203
|
});
|
|
51724
52204
|
});
|
|
51725
52205
|
DialogTrigger.displayName = TRIGGER_NAME;
|
|
@@ -51811,17 +52291,17 @@ var DialogContentModal = React__namespace.forwardRef((props, forwardedRef)=>{
|
|
|
51811
52291
|
ref: composedRefs,
|
|
51812
52292
|
trapFocus: context.open,
|
|
51813
52293
|
disableOutsidePointerEvents: true,
|
|
51814
|
-
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event)=>{
|
|
52294
|
+
onCloseAutoFocus: composeEventHandlers$1(props.onCloseAutoFocus, (event)=>{
|
|
51815
52295
|
event.preventDefault();
|
|
51816
52296
|
context.triggerRef.current?.focus();
|
|
51817
52297
|
}),
|
|
51818
|
-
onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event)=>{
|
|
52298
|
+
onPointerDownOutside: composeEventHandlers$1(props.onPointerDownOutside, (event)=>{
|
|
51819
52299
|
const originalEvent = event.detail.originalEvent;
|
|
51820
52300
|
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
51821
52301
|
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
51822
52302
|
if (isRightClick) event.preventDefault();
|
|
51823
52303
|
}),
|
|
51824
|
-
onFocusOutside: composeEventHandlers(props.onFocusOutside, (event)=>event.preventDefault())
|
|
52304
|
+
onFocusOutside: composeEventHandlers$1(props.onFocusOutside, (event)=>event.preventDefault())
|
|
51825
52305
|
});
|
|
51826
52306
|
});
|
|
51827
52307
|
var DialogContentNonModal = React__namespace.forwardRef((props, forwardedRef)=>{
|
|
@@ -51928,7 +52408,7 @@ var DialogClose = React__namespace.forwardRef((props, forwardedRef)=>{
|
|
|
51928
52408
|
type: "button",
|
|
51929
52409
|
...closeProps,
|
|
51930
52410
|
ref: forwardedRef,
|
|
51931
|
-
onClick: composeEventHandlers(props.onClick, ()=>context.onOpenChange(false))
|
|
52411
|
+
onClick: composeEventHandlers$1(props.onClick, ()=>context.onOpenChange(false))
|
|
51932
52412
|
});
|
|
51933
52413
|
});
|
|
51934
52414
|
DialogClose.displayName = CLOSE_NAME;
|
|
@@ -113521,6 +114001,12 @@ function dtoMetricToMetric(def) {
|
|
|
113521
114001
|
if (idx !== undefined && idx >= 0) {
|
|
113522
114002
|
aggregatedResults[evaluatorId][item.metric.name] = idx;
|
|
113523
114003
|
}
|
|
114004
|
+
} else if ((isLLMResult(item) || isToolResult(item)) && "result_name" in item && typeof item.value === "number") {
|
|
114005
|
+
// Raw LLM/Tool results: aggregate by result_name (metric name) for comparison view
|
|
114006
|
+
const name = item.result_name;
|
|
114007
|
+
const arr = valuesByMetric.get(name) ?? [];
|
|
114008
|
+
arr.push(item.value);
|
|
114009
|
+
valuesByMetric.set(name, arr);
|
|
113524
114010
|
}
|
|
113525
114011
|
}
|
|
113526
114012
|
// Compute mean across all values for each metric
|
|
@@ -113572,117 +114058,114 @@ function dtoMetricToMetric(def) {
|
|
|
113572
114058
|
return "evaluator_results" in x && Array.isArray(x.evaluator_results);
|
|
113573
114059
|
}
|
|
113574
114060
|
|
|
113575
|
-
|
|
113576
|
-
const
|
|
114061
|
+
/** Returns set of "evaluatorId:metricName" for all metrics in the evaluation. */ function getMetricKeys(evaluation) {
|
|
114062
|
+
const keys = new Set();
|
|
114063
|
+
for (const evaluator of evaluation.evaluators){
|
|
114064
|
+
for (const metric of evaluator.metrics){
|
|
114065
|
+
keys.add(`${evaluator.evaluator_id}:${metric.name}`);
|
|
114066
|
+
}
|
|
114067
|
+
}
|
|
114068
|
+
return keys;
|
|
114069
|
+
}
|
|
114070
|
+
/**
|
|
114071
|
+
* Returns true if both evaluations have the same set of metrics
|
|
114072
|
+
* (evaluator_id + metric name) across all evaluators.
|
|
114073
|
+
*/ function evaluationsHaveSameMetrics(a, b) {
|
|
114074
|
+
if (a == null || b == null) return false;
|
|
114075
|
+
const evalA = isEvaluationDto(a) ? transformEvaluation(a) : a;
|
|
114076
|
+
const evalB = isEvaluationDto(b) ? transformEvaluation(b) : b;
|
|
114077
|
+
const keysA = getMetricKeys(evalA);
|
|
114078
|
+
const keysB = getMetricKeys(evalB);
|
|
114079
|
+
if (keysA.size !== keysB.size) return false;
|
|
114080
|
+
for (const key of keysA){
|
|
114081
|
+
if (!keysB.has(key)) return false;
|
|
114082
|
+
}
|
|
114083
|
+
return true;
|
|
114084
|
+
}
|
|
114085
|
+
|
|
114086
|
+
function formatMetricValue(evaluation, evaluatorId, metricName, metricType, options) {
|
|
114087
|
+
const evaluatorResults = evaluation.results[evaluatorId];
|
|
114088
|
+
const value = evaluatorResults?.[metricName];
|
|
114089
|
+
if (value === undefined) return "-";
|
|
114090
|
+
if (metricType === "Categorical" && options?.length) {
|
|
114091
|
+
const index = Math.round(value);
|
|
114092
|
+
return options[index] || value.toString();
|
|
114093
|
+
}
|
|
114094
|
+
if (metricType === "Continuous") {
|
|
114095
|
+
return value.toFixed(1);
|
|
114096
|
+
}
|
|
114097
|
+
return value.toString();
|
|
114098
|
+
}
|
|
114099
|
+
function getMetricValue(evaluation, evaluatorId, metricName) {
|
|
114100
|
+
const evaluatorResults = evaluation.results[evaluatorId];
|
|
114101
|
+
return evaluatorResults?.[metricName];
|
|
114102
|
+
}
|
|
114103
|
+
const EvaluationsCompareView = ({ evaluations, evaluationId1, evaluationId2, onEvaluationId1Change, onEvaluationId2Change, loading = false, showEvaluationComparisonDropdowns = false, backHref })=>{
|
|
114104
|
+
const { theme } = useTheme$1();
|
|
113577
114105
|
const normalizedEvaluations = React.useMemo(()=>evaluations.map((e)=>isEvaluationDto(e) ? transformEvaluation(e) : e), [
|
|
113578
114106
|
evaluations
|
|
113579
114107
|
]);
|
|
113580
|
-
|
|
113581
|
-
const
|
|
113582
|
-
|
|
113583
|
-
|
|
113584
|
-
|
|
113585
|
-
|
|
113586
|
-
|
|
113587
|
-
|
|
113588
|
-
|
|
113589
|
-
|
|
113590
|
-
|
|
113591
|
-
|
|
113592
|
-
|
|
113593
|
-
|
|
113594
|
-
|
|
113595
|
-
|
|
113596
|
-
|
|
113597
|
-
|
|
113598
|
-
|
|
113599
|
-
|
|
113600
|
-
|
|
113601
|
-
|
|
113602
|
-
|
|
113603
|
-
|
|
113604
|
-
|
|
113605
|
-
|
|
113606
|
-
|
|
113607
|
-
|
|
114108
|
+
const evaluation1 = normalizedEvaluations.find((e)=>e.evaluation_id === evaluationId1);
|
|
114109
|
+
const evaluation2 = normalizedEvaluations.find((e)=>e.evaluation_id === evaluationId2);
|
|
114110
|
+
const metricsMismatch = React.useMemo(()=>!evaluationsHaveSameMetrics(evaluation1, evaluation2), [
|
|
114111
|
+
evaluation1,
|
|
114112
|
+
evaluation2
|
|
114113
|
+
]);
|
|
114114
|
+
const comparisonData = React.useMemo(()=>{
|
|
114115
|
+
if (!evaluation1 || !evaluation2) return [];
|
|
114116
|
+
const rows = [];
|
|
114117
|
+
// Build evaluator lookup by id for evaluation2 (to match evaluators between evaluations)
|
|
114118
|
+
const eval2EvaluatorsById = new Map(evaluation2.evaluators.map((e)=>[
|
|
114119
|
+
e.evaluator_id,
|
|
114120
|
+
e
|
|
114121
|
+
]));
|
|
114122
|
+
// Iterate over ALL evaluators in evaluation1 (LLM, Tool, Judge, etc.)
|
|
114123
|
+
for (const evaluator1 of evaluation1.evaluators){
|
|
114124
|
+
const evaluator2 = eval2EvaluatorsById.get(evaluator1.evaluator_id);
|
|
114125
|
+
if (!evaluator2) continue;
|
|
114126
|
+
const allMetricNames = new Set();
|
|
114127
|
+
evaluator1.metrics.forEach((m)=>allMetricNames.add(m.name));
|
|
114128
|
+
evaluator2.metrics.forEach((m)=>allMetricNames.add(m.name));
|
|
114129
|
+
for (const metricName of allMetricNames){
|
|
114130
|
+
const metric1 = evaluator1.metrics.find((m)=>m.name === metricName);
|
|
114131
|
+
const metric2 = evaluator2.metrics.find((m)=>m.name === metricName);
|
|
114132
|
+
const metricType = metric1?.type || metric2?.type || "Continuous";
|
|
114133
|
+
const options = metric1?.type === "Categorical" ? metric1.options : metric2?.type === "Categorical" ? metric2.options : undefined;
|
|
114134
|
+
const value1 = getMetricValue(evaluation1, evaluator1.evaluator_id, metricName);
|
|
114135
|
+
const value2 = getMetricValue(evaluation2, evaluator2.evaluator_id, metricName);
|
|
114136
|
+
const formatted1 = formatMetricValue(evaluation1, evaluator1.evaluator_id, metricName, metricType, options);
|
|
114137
|
+
const formatted2 = formatMetricValue(evaluation2, evaluator2.evaluator_id, metricName, metricType, options);
|
|
114138
|
+
let difference;
|
|
114139
|
+
if (metricType === "Continuous" && value1 !== undefined && value2 !== undefined) {
|
|
114140
|
+
difference = value2 - value1;
|
|
114141
|
+
}
|
|
114142
|
+
rows.push({
|
|
114143
|
+
metricName,
|
|
114144
|
+
evaluatorName: evaluator1.name,
|
|
114145
|
+
metricType,
|
|
114146
|
+
value1,
|
|
114147
|
+
value2,
|
|
114148
|
+
formatted1,
|
|
114149
|
+
formatted2,
|
|
114150
|
+
difference,
|
|
114151
|
+
rowKey: `${evaluator1.evaluator_id}:${metricName}`
|
|
113608
114152
|
});
|
|
113609
|
-
return;
|
|
113610
|
-
} catch (err) {
|
|
113611
|
-
// User cancelled or error occurred, fall back to clipboard
|
|
113612
114153
|
}
|
|
113613
114154
|
}
|
|
113614
|
-
|
|
113615
|
-
|
|
113616
|
-
|
|
113617
|
-
|
|
113618
|
-
|
|
113619
|
-
|
|
113620
|
-
|
|
113621
|
-
|
|
113622
|
-
|
|
113623
|
-
|
|
113624
|
-
const targetEvaluation = normalizedEvaluations.find((e)=>e.evaluation_id === targetEvaluationId);
|
|
113625
|
-
// Helper to format metric value (same logic as evaluations.tsx)
|
|
113626
|
-
const formatMetricValue = (evaluation, metricName)=>{
|
|
113627
|
-
const evaluator = evaluation.evaluators[0];
|
|
113628
|
-
const metric = evaluator?.metrics.find((m)=>m.name === metricName);
|
|
113629
|
-
const evaluatorId = evaluator?.evaluator_id || "";
|
|
113630
|
-
const evaluatorResults = evaluation.results[evaluatorId];
|
|
113631
|
-
const value = evaluatorResults?.[metricName];
|
|
113632
|
-
if (value === undefined) return "-";
|
|
113633
|
-
if (metric?.type === "Categorical" && metric.options) {
|
|
113634
|
-
const index = Math.round(value);
|
|
113635
|
-
return metric.options[index] || value.toString();
|
|
113636
|
-
}
|
|
113637
|
-
if (metric?.type === "Continuous") {
|
|
113638
|
-
return value.toFixed(1);
|
|
113639
|
-
}
|
|
113640
|
-
return value.toString();
|
|
113641
|
-
};
|
|
113642
|
-
// Get metric value as number for comparison
|
|
113643
|
-
const getMetricValue = (evaluation, metricName)=>{
|
|
113644
|
-
const evaluator = evaluation.evaluators[0];
|
|
113645
|
-
const evaluatorId = evaluator?.evaluator_id || "";
|
|
113646
|
-
const evaluatorResults = evaluation.results[evaluatorId];
|
|
113647
|
-
return evaluatorResults?.[metricName];
|
|
113648
|
-
};
|
|
113649
|
-
// Build comparison data
|
|
113650
|
-
const comparisonData = React.useMemo(()=>{
|
|
113651
|
-
if (!sourceEvaluation || !targetEvaluation) return [];
|
|
113652
|
-
const sourceEvaluator = sourceEvaluation.evaluators[0];
|
|
113653
|
-
const targetEvaluator = targetEvaluation.evaluators[0];
|
|
113654
|
-
if (!sourceEvaluator || !targetEvaluator) return [];
|
|
113655
|
-
// Get all unique metric names
|
|
113656
|
-
const allMetricNames = new Set();
|
|
113657
|
-
sourceEvaluator.metrics.forEach((m)=>allMetricNames.add(m.name));
|
|
113658
|
-
targetEvaluator.metrics.forEach((m)=>allMetricNames.add(m.name));
|
|
113659
|
-
return Array.from(allMetricNames).map((metricName)=>{
|
|
113660
|
-
const sourceMetric = sourceEvaluator.metrics.find((m)=>m.name === metricName);
|
|
113661
|
-
const targetMetric = targetEvaluator.metrics.find((m)=>m.name === metricName);
|
|
113662
|
-
const metricType = sourceMetric?.type || targetMetric?.type || "Continuous";
|
|
113663
|
-
const sourceValue = getMetricValue(sourceEvaluation, metricName);
|
|
113664
|
-
const targetValue = getMetricValue(targetEvaluation, metricName);
|
|
113665
|
-
const sourceFormatted = formatMetricValue(sourceEvaluation, metricName);
|
|
113666
|
-
const targetFormatted = formatMetricValue(targetEvaluation, metricName);
|
|
113667
|
-
let difference;
|
|
113668
|
-
if (metricType === "Continuous" && sourceValue !== undefined && targetValue !== undefined) {
|
|
113669
|
-
difference = targetValue - sourceValue;
|
|
113670
|
-
}
|
|
113671
|
-
return {
|
|
113672
|
-
metricName,
|
|
113673
|
-
metricType,
|
|
113674
|
-
sourceValue,
|
|
113675
|
-
targetValue,
|
|
113676
|
-
sourceFormatted,
|
|
113677
|
-
targetFormatted,
|
|
113678
|
-
difference
|
|
113679
|
-
};
|
|
114155
|
+
return rows;
|
|
114156
|
+
}, [
|
|
114157
|
+
evaluation1,
|
|
114158
|
+
evaluation2
|
|
114159
|
+
]);
|
|
114160
|
+
const allValuesIdentical = React.useMemo(()=>{
|
|
114161
|
+
if (comparisonData.length === 0) return false;
|
|
114162
|
+
return comparisonData.every((r)=>{
|
|
114163
|
+
if (r.metricType === "Continuous" && r.difference !== undefined) return r.difference === 0;
|
|
114164
|
+
return r.formatted1 === r.formatted2;
|
|
113680
114165
|
});
|
|
113681
114166
|
}, [
|
|
113682
|
-
|
|
113683
|
-
targetEvaluation
|
|
114167
|
+
comparisonData
|
|
113684
114168
|
]);
|
|
113685
|
-
// Prepare options for dropdowns
|
|
113686
114169
|
const evaluationOptions = React.useMemo(()=>{
|
|
113687
114170
|
return normalizedEvaluations.map((evaluation)=>({
|
|
113688
114171
|
label: `${evaluation.name || "Unnamed Evaluation"} (${evaluation.agent_name})`,
|
|
@@ -113699,54 +114182,261 @@ const EvaluationsCompare = ({ open, onClose, sourceEvaluationId, targetEvaluatio
|
|
|
113699
114182
|
width: 200,
|
|
113700
114183
|
render: (name, record)=>/*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("div", {
|
|
113701
114184
|
style: {
|
|
113702
|
-
fontWeight:
|
|
114185
|
+
fontWeight: theme.fontWeight.medium
|
|
113703
114186
|
}
|
|
113704
114187
|
}, name), /*#__PURE__*/ React.createElement("div", {
|
|
113705
114188
|
style: {
|
|
113706
|
-
fontSize:
|
|
113707
|
-
color:
|
|
114189
|
+
fontSize: theme.fontSize.xs,
|
|
114190
|
+
color: theme.colors.mutedForeground
|
|
113708
114191
|
}
|
|
113709
|
-
}, record.metricType))
|
|
114192
|
+
}, record.evaluatorName, " • ", record.metricType))
|
|
113710
114193
|
},
|
|
113711
114194
|
{
|
|
113712
|
-
title:
|
|
113713
|
-
key: "
|
|
114195
|
+
title: evaluation1?.name || "Evaluation 1",
|
|
114196
|
+
key: "evaluation1",
|
|
113714
114197
|
width: 150,
|
|
113715
114198
|
render: (_, record)=>/*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(Tag, {
|
|
113716
114199
|
color: "blue"
|
|
113717
|
-
}, record.
|
|
114200
|
+
}, record.formatted1))
|
|
113718
114201
|
},
|
|
113719
114202
|
{
|
|
113720
|
-
title:
|
|
113721
|
-
key: "
|
|
114203
|
+
title: evaluation2?.name || "Evaluation 2",
|
|
114204
|
+
key: "evaluation2",
|
|
113722
114205
|
width: 150,
|
|
113723
114206
|
render: (_, record)=>/*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(Tag, {
|
|
113724
114207
|
color: "green"
|
|
113725
|
-
}, record.
|
|
114208
|
+
}, record.formatted2))
|
|
113726
114209
|
},
|
|
113727
114210
|
{
|
|
113728
114211
|
title: "Difference",
|
|
113729
114212
|
key: "difference",
|
|
113730
114213
|
width: 120,
|
|
113731
114214
|
render: (_, record)=>{
|
|
113732
|
-
if (record.difference
|
|
113733
|
-
|
|
113734
|
-
|
|
113735
|
-
|
|
113736
|
-
|
|
113737
|
-
|
|
114215
|
+
if (record.difference !== undefined) {
|
|
114216
|
+
const isPositive = record.difference > 0;
|
|
114217
|
+
const isNegative = record.difference < 0;
|
|
114218
|
+
return /*#__PURE__*/ React.createElement(Tag, {
|
|
114219
|
+
color: isPositive ? "green" : isNegative ? "red" : "default"
|
|
114220
|
+
}, isPositive ? "+" : "", record.difference.toFixed(1));
|
|
114221
|
+
}
|
|
114222
|
+
// Categorical: show "Different" when values differ
|
|
114223
|
+
if (record.formatted1 !== record.formatted2) {
|
|
114224
|
+
return /*#__PURE__*/ React.createElement(Tag, {
|
|
114225
|
+
color: "orange"
|
|
114226
|
+
}, "Different");
|
|
114227
|
+
}
|
|
114228
|
+
return "-";
|
|
113738
114229
|
}
|
|
113739
114230
|
}
|
|
113740
114231
|
];
|
|
113741
|
-
const
|
|
114232
|
+
const evaluation1Label = evaluation1 ? `${evaluation1.name || "Unnamed Evaluation"} (${evaluation1.agent_name})` : "Select evaluation 1";
|
|
114233
|
+
const evaluation2Label = evaluation2 ? `${evaluation2.name || "Unnamed Evaluation"} (${evaluation2.agent_name})` : "Select evaluation 2";
|
|
114234
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, backHref && /*#__PURE__*/ React.createElement("a", {
|
|
114235
|
+
href: backHref,
|
|
114236
|
+
style: {
|
|
114237
|
+
display: "inline-flex",
|
|
114238
|
+
alignItems: "center",
|
|
114239
|
+
gap: 6,
|
|
114240
|
+
marginBottom: 24,
|
|
114241
|
+
color: theme.colors.mutedForeground,
|
|
114242
|
+
textDecoration: "none",
|
|
114243
|
+
fontSize: 14
|
|
114244
|
+
}
|
|
114245
|
+
}, /*#__PURE__*/ React.createElement(ArrowLeft, {
|
|
114246
|
+
size: 16
|
|
114247
|
+
}), "Back to Evaluations"), /*#__PURE__*/ React.createElement("div", {
|
|
114248
|
+
style: {
|
|
114249
|
+
marginBottom: theme.spacing.md,
|
|
114250
|
+
color: theme.colors.mutedForeground
|
|
114251
|
+
}
|
|
114252
|
+
}, showEvaluationComparisonDropdowns ? "Select two evaluations to compare their metrics" : /*#__PURE__*/ React.createElement("div", {
|
|
114253
|
+
style: {
|
|
114254
|
+
display: "flex",
|
|
114255
|
+
alignItems: "center",
|
|
114256
|
+
gap: theme.spacing.sm,
|
|
114257
|
+
flexWrap: "wrap"
|
|
114258
|
+
}
|
|
114259
|
+
}, /*#__PURE__*/ React.createElement("span", null, /*#__PURE__*/ React.createElement("strong", null, "Evaluation 1:"), " ", evaluation1Label), /*#__PURE__*/ React.createElement("span", {
|
|
114260
|
+
style: {
|
|
114261
|
+
color: theme.colors.border
|
|
114262
|
+
}
|
|
114263
|
+
}, "•"), /*#__PURE__*/ React.createElement("span", null, /*#__PURE__*/ React.createElement("strong", null, "Evaluation 2:"), " ", evaluation2Label))), showEvaluationComparisonDropdowns && /*#__PURE__*/ React.createElement("div", {
|
|
114264
|
+
style: {
|
|
114265
|
+
marginBottom: theme.spacing.lg
|
|
114266
|
+
}
|
|
114267
|
+
}, /*#__PURE__*/ React.createElement(Space, {
|
|
114268
|
+
size: "middle",
|
|
114269
|
+
style: {
|
|
114270
|
+
width: "100%"
|
|
114271
|
+
}
|
|
114272
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
114273
|
+
style: {
|
|
114274
|
+
flex: 1
|
|
114275
|
+
}
|
|
114276
|
+
}, /*#__PURE__*/ React.createElement("label", {
|
|
114277
|
+
style: {
|
|
114278
|
+
display: "block",
|
|
114279
|
+
marginBottom: theme.spacing.sm,
|
|
114280
|
+
fontWeight: theme.fontWeight.medium,
|
|
114281
|
+
color: theme.colors.foreground
|
|
114282
|
+
}
|
|
114283
|
+
}, "Evaluation 1"), /*#__PURE__*/ React.createElement(Select, {
|
|
114284
|
+
style: {
|
|
114285
|
+
width: "100%"
|
|
114286
|
+
},
|
|
114287
|
+
placeholder: "Select evaluation 1",
|
|
114288
|
+
value: evaluationId1,
|
|
114289
|
+
onChange: (value)=>onEvaluationId1Change(value),
|
|
114290
|
+
options: evaluationOptions,
|
|
114291
|
+
showSearch: true,
|
|
114292
|
+
loading: loading,
|
|
114293
|
+
filterOption: (input, option)=>(option?.label ?? "").toLowerCase().includes(input.toLowerCase())
|
|
114294
|
+
})), /*#__PURE__*/ React.createElement("div", {
|
|
114295
|
+
style: {
|
|
114296
|
+
flex: 1
|
|
114297
|
+
}
|
|
114298
|
+
}, /*#__PURE__*/ React.createElement("label", {
|
|
114299
|
+
style: {
|
|
114300
|
+
display: "block",
|
|
114301
|
+
marginBottom: theme.spacing.sm,
|
|
114302
|
+
fontWeight: theme.fontWeight.medium,
|
|
114303
|
+
color: theme.colors.foreground
|
|
114304
|
+
}
|
|
114305
|
+
}, "Evaluation 2"), /*#__PURE__*/ React.createElement(Select, {
|
|
114306
|
+
style: {
|
|
114307
|
+
width: "100%"
|
|
114308
|
+
},
|
|
114309
|
+
placeholder: "Select evaluation 2",
|
|
114310
|
+
value: evaluationId2,
|
|
114311
|
+
onChange: (value)=>onEvaluationId2Change(value),
|
|
114312
|
+
options: evaluationOptions,
|
|
114313
|
+
showSearch: true,
|
|
114314
|
+
loading: loading,
|
|
114315
|
+
filterOption: (input, option)=>(option?.label ?? "").toLowerCase().includes(input.toLowerCase())
|
|
114316
|
+
})))), !evaluation1 || !evaluation2 ? /*#__PURE__*/ React.createElement("div", {
|
|
114317
|
+
style: {
|
|
114318
|
+
textAlign: "center",
|
|
114319
|
+
padding: theme.spacing["2xl"],
|
|
114320
|
+
color: theme.colors.mutedForeground
|
|
114321
|
+
}
|
|
114322
|
+
}, /*#__PURE__*/ React.createElement("p", null, "Please select both evaluations to compare")) : metricsMismatch ? /*#__PURE__*/ React.createElement(Alert, {
|
|
114323
|
+
type: "error",
|
|
114324
|
+
showIcon: true,
|
|
114325
|
+
message: "Cannot compare evaluations",
|
|
114326
|
+
description: "The two evaluations must have the same metrics in order to be diffed. Please select evaluations that share the same metric set."
|
|
114327
|
+
}) : /*#__PURE__*/ React.createElement("div", null, allValuesIdentical && /*#__PURE__*/ React.createElement(Alert, {
|
|
114328
|
+
type: "info",
|
|
114329
|
+
showIcon: true,
|
|
114330
|
+
message: "Evaluations are identical",
|
|
114331
|
+
description: "All metric values match between the two evaluations.",
|
|
114332
|
+
style: {
|
|
114333
|
+
marginBottom: theme.spacing.lg
|
|
114334
|
+
}
|
|
114335
|
+
}), /*#__PURE__*/ React.createElement("div", {
|
|
114336
|
+
style: {
|
|
114337
|
+
display: "grid",
|
|
114338
|
+
gridTemplateColumns: "1fr 1fr",
|
|
114339
|
+
gap: theme.spacing.lg,
|
|
114340
|
+
marginBottom: theme.spacing.lg,
|
|
114341
|
+
padding: theme.spacing.md,
|
|
114342
|
+
borderRadius: theme.borderRadius.lg,
|
|
114343
|
+
border: `1px solid ${theme.colors.border}`,
|
|
114344
|
+
backgroundColor: theme.colors.muted
|
|
114345
|
+
}
|
|
114346
|
+
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("h3", {
|
|
114347
|
+
style: {
|
|
114348
|
+
margin: `0 0 ${theme.spacing.sm} 0`,
|
|
114349
|
+
fontSize: theme.fontSize.base,
|
|
114350
|
+
fontWeight: theme.fontWeight.semibold
|
|
114351
|
+
}
|
|
114352
|
+
}, "Evaluation 1: ", evaluation1.name || "Unnamed Evaluation"), /*#__PURE__*/ React.createElement("div", {
|
|
114353
|
+
style: {
|
|
114354
|
+
fontSize: theme.fontSize.sm,
|
|
114355
|
+
color: theme.colors.mutedForeground
|
|
114356
|
+
}
|
|
114357
|
+
}, /*#__PURE__*/ React.createElement("div", null, "Agent: ", evaluation1.agent_name), /*#__PURE__*/ React.createElement("div", null, "Runs: ", evaluation1.runs.length), /*#__PURE__*/ React.createElement("div", null, "Created: ", moment(evaluation1.created_at).format("YYYY-MM-DD HH:mm:ss")))), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("h3", {
|
|
114358
|
+
style: {
|
|
114359
|
+
margin: `0 0 ${theme.spacing.sm} 0`,
|
|
114360
|
+
fontSize: theme.fontSize.base,
|
|
114361
|
+
fontWeight: theme.fontWeight.semibold
|
|
114362
|
+
}
|
|
114363
|
+
}, "Evaluation 2: ", evaluation2.name || "Unnamed Evaluation"), /*#__PURE__*/ React.createElement("div", {
|
|
114364
|
+
style: {
|
|
114365
|
+
fontSize: theme.fontSize.sm,
|
|
114366
|
+
color: theme.colors.mutedForeground
|
|
114367
|
+
}
|
|
114368
|
+
}, /*#__PURE__*/ React.createElement("div", null, "Agent: ", evaluation2.agent_name), /*#__PURE__*/ React.createElement("div", null, "Runs: ", evaluation2.runs.length), /*#__PURE__*/ React.createElement("div", null, "Created: ", moment(evaluation2.created_at).format("YYYY-MM-DD HH:mm:ss"))))), /*#__PURE__*/ React.createElement("h3", {
|
|
114369
|
+
style: {
|
|
114370
|
+
margin: `0 0 ${theme.spacing.md} 0`,
|
|
114371
|
+
fontSize: theme.fontSize.lg,
|
|
114372
|
+
fontWeight: theme.fontWeight.semibold
|
|
114373
|
+
}
|
|
114374
|
+
}, "Metrics Comparison"), /*#__PURE__*/ React.createElement(ForwardTable, {
|
|
114375
|
+
columns: comparisonColumns,
|
|
114376
|
+
dataSource: comparisonData,
|
|
114377
|
+
rowKey: "rowKey",
|
|
114378
|
+
pagination: false,
|
|
114379
|
+
style: {
|
|
114380
|
+
background: theme.colors.card
|
|
114381
|
+
},
|
|
114382
|
+
rowClassName: (record)=>{
|
|
114383
|
+
const hasDiff = record.metricType === "Continuous" ? record.difference !== undefined && record.difference !== 0 : record.formatted1 !== record.formatted2;
|
|
114384
|
+
return hasDiff ? "evaluations-compare-diff-row" : "";
|
|
114385
|
+
}
|
|
114386
|
+
})));
|
|
114387
|
+
};
|
|
114388
|
+
|
|
114389
|
+
const extraButtonsIconSize = 24;
|
|
114390
|
+
const EvaluationsCompareDrawer = ({ open, onClose, evaluationId1, evaluationId2, evaluations, onEvaluationId1Change, onEvaluationId2Change })=>{
|
|
114391
|
+
const handleCopyIds = async ()=>{
|
|
114392
|
+
if (!evaluationId1 || !evaluationId2) {
|
|
114393
|
+
staticMethods.error("No evaluation IDs available");
|
|
114394
|
+
return;
|
|
114395
|
+
}
|
|
114396
|
+
try {
|
|
114397
|
+
const idsText = `Evaluation 1: ${evaluationId1}\nEvaluation 2: ${evaluationId2}`;
|
|
114398
|
+
await navigator.clipboard.writeText(idsText);
|
|
114399
|
+
staticMethods.success("Evaluation IDs copied to clipboard");
|
|
114400
|
+
} catch (err) {
|
|
114401
|
+
staticMethods.error("Failed to copy evaluation IDs");
|
|
114402
|
+
}
|
|
114403
|
+
};
|
|
114404
|
+
const handleShare = async ()=>{
|
|
114405
|
+
if (!evaluationId1 || !evaluationId2) {
|
|
114406
|
+
staticMethods.error("No evaluations available to share");
|
|
114407
|
+
return;
|
|
114408
|
+
}
|
|
114409
|
+
const shareUrl = `${window.location.origin}${window.location.pathname}#/evaluations?compare=${evaluationId1},${evaluationId2}`;
|
|
114410
|
+
if (navigator.share) {
|
|
114411
|
+
try {
|
|
114412
|
+
await navigator.share({
|
|
114413
|
+
title: "Evaluation Comparison",
|
|
114414
|
+
text: `Compare evaluations: ${evaluationId1} vs ${evaluationId2}`,
|
|
114415
|
+
url: shareUrl
|
|
114416
|
+
});
|
|
114417
|
+
return;
|
|
114418
|
+
} catch (err) {
|
|
114419
|
+
// User cancelled or error occurred, fall back to clipboard
|
|
114420
|
+
}
|
|
114421
|
+
}
|
|
114422
|
+
try {
|
|
114423
|
+
await navigator.clipboard.writeText(shareUrl);
|
|
114424
|
+
staticMethods.success("Share link copied to clipboard");
|
|
114425
|
+
} catch (err) {
|
|
114426
|
+
staticMethods.error("Failed to copy share link");
|
|
114427
|
+
}
|
|
114428
|
+
};
|
|
113742
114429
|
return /*#__PURE__*/ React.createElement(Drawer$2, {
|
|
113743
114430
|
title: "Compare Evaluations",
|
|
113744
114431
|
placement: "right",
|
|
113745
114432
|
size: "60%",
|
|
113746
114433
|
open: open,
|
|
113747
114434
|
onClose: onClose,
|
|
113748
|
-
extra: /*#__PURE__*/ React.createElement(
|
|
113749
|
-
|
|
114435
|
+
extra: /*#__PURE__*/ React.createElement("div", {
|
|
114436
|
+
style: {
|
|
114437
|
+
display: "flex",
|
|
114438
|
+
gap: 8
|
|
114439
|
+
}
|
|
113750
114440
|
}, /*#__PURE__*/ React.createElement(Tooltip, {
|
|
113751
114441
|
title: "Copy IDs to Clipboard"
|
|
113752
114442
|
}, /*#__PURE__*/ React.createElement(Button$1, {
|
|
@@ -113755,7 +114445,7 @@ const EvaluationsCompare = ({ open, onClose, sourceEvaluationId, targetEvaluatio
|
|
|
113755
114445
|
size: extraButtonsIconSize
|
|
113756
114446
|
}),
|
|
113757
114447
|
onClick: handleCopyIds,
|
|
113758
|
-
disabled: !
|
|
114448
|
+
disabled: !evaluationId1 || !evaluationId2
|
|
113759
114449
|
})), /*#__PURE__*/ React.createElement(Tooltip, {
|
|
113760
114450
|
title: "Share"
|
|
113761
114451
|
}, /*#__PURE__*/ React.createElement(Button$1, {
|
|
@@ -113764,123 +114454,21 @@ const EvaluationsCompare = ({ open, onClose, sourceEvaluationId, targetEvaluatio
|
|
|
113764
114454
|
size: extraButtonsIconSize
|
|
113765
114455
|
}),
|
|
113766
114456
|
onClick: handleShare,
|
|
113767
|
-
disabled: !
|
|
114457
|
+
disabled: !evaluationId1 || !evaluationId2
|
|
113768
114458
|
}))),
|
|
113769
114459
|
styles: {
|
|
113770
114460
|
body: {
|
|
113771
114461
|
padding: "24px"
|
|
113772
114462
|
}
|
|
113773
114463
|
}
|
|
113774
|
-
}, /*#__PURE__*/ React.createElement(
|
|
113775
|
-
|
|
113776
|
-
|
|
113777
|
-
|
|
113778
|
-
|
|
113779
|
-
|
|
113780
|
-
|
|
113781
|
-
|
|
113782
|
-
}
|
|
113783
|
-
}, /*#__PURE__*/ React.createElement(Space, {
|
|
113784
|
-
size: "middle",
|
|
113785
|
-
style: {
|
|
113786
|
-
width: "100%"
|
|
113787
|
-
}
|
|
113788
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
113789
|
-
style: {
|
|
113790
|
-
flex: 1
|
|
113791
|
-
}
|
|
113792
|
-
}, /*#__PURE__*/ React.createElement("label", {
|
|
113793
|
-
style: {
|
|
113794
|
-
display: "block",
|
|
113795
|
-
marginBottom: "8px",
|
|
113796
|
-
fontWeight: 500,
|
|
113797
|
-
color: isDarkMode ? "#e5e7eb" : "#1f2937"
|
|
113798
|
-
}
|
|
113799
|
-
}, "Source Evaluation"), /*#__PURE__*/ React.createElement(Select, {
|
|
113800
|
-
style: {
|
|
113801
|
-
width: "100%"
|
|
113802
|
-
},
|
|
113803
|
-
placeholder: "Select source evaluation",
|
|
113804
|
-
value: sourceEvaluationId,
|
|
113805
|
-
onChange: (value)=>onSourceChange(value),
|
|
113806
|
-
options: evaluationOptions,
|
|
113807
|
-
showSearch: true,
|
|
113808
|
-
filterOption: (input, option)=>(option?.label ?? "").toLowerCase().includes(input.toLowerCase())
|
|
113809
|
-
})), /*#__PURE__*/ React.createElement("div", {
|
|
113810
|
-
style: {
|
|
113811
|
-
flex: 1
|
|
113812
|
-
}
|
|
113813
|
-
}, /*#__PURE__*/ React.createElement("label", {
|
|
113814
|
-
style: {
|
|
113815
|
-
display: "block",
|
|
113816
|
-
marginBottom: "8px",
|
|
113817
|
-
fontWeight: 500,
|
|
113818
|
-
color: isDarkMode ? "#e5e7eb" : "#1f2937"
|
|
113819
|
-
}
|
|
113820
|
-
}, "Target Evaluation"), /*#__PURE__*/ React.createElement(Select, {
|
|
113821
|
-
style: {
|
|
113822
|
-
width: "100%"
|
|
113823
|
-
},
|
|
113824
|
-
placeholder: "Select target evaluation",
|
|
113825
|
-
value: targetEvaluationId,
|
|
113826
|
-
onChange: (value)=>onTargetChange(value),
|
|
113827
|
-
options: evaluationOptions,
|
|
113828
|
-
showSearch: true,
|
|
113829
|
-
filterOption: (input, option)=>(option?.label ?? "").toLowerCase().includes(input.toLowerCase())
|
|
113830
|
-
})))), !sourceEvaluation || !targetEvaluation ? /*#__PURE__*/ React.createElement("div", {
|
|
113831
|
-
style: {
|
|
113832
|
-
textAlign: "center",
|
|
113833
|
-
padding: "48px",
|
|
113834
|
-
color: isDarkMode ? "#8c8c8c" : "#595959"
|
|
113835
|
-
}
|
|
113836
|
-
}, /*#__PURE__*/ React.createElement("p", null, "Please select both source and target evaluations to compare")) : /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("div", {
|
|
113837
|
-
style: {
|
|
113838
|
-
display: "grid",
|
|
113839
|
-
gridTemplateColumns: "1fr 1fr",
|
|
113840
|
-
gap: "24px",
|
|
113841
|
-
marginBottom: "24px",
|
|
113842
|
-
padding: "16px",
|
|
113843
|
-
borderRadius: "8px",
|
|
113844
|
-
border: `1px solid ${isDarkMode ? "#2d2d2d" : "#e5e7eb"}`,
|
|
113845
|
-
backgroundColor: isDarkMode ? "#1a1a1a" : "#f9fafb"
|
|
113846
|
-
}
|
|
113847
|
-
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("h3", {
|
|
113848
|
-
style: {
|
|
113849
|
-
margin: "0 0 12px 0",
|
|
113850
|
-
fontSize: "16px",
|
|
113851
|
-
fontWeight: 600
|
|
113852
|
-
}
|
|
113853
|
-
}, "Source: ", sourceEvaluation.name || "Unnamed Evaluation"), /*#__PURE__*/ React.createElement("div", {
|
|
113854
|
-
style: {
|
|
113855
|
-
fontSize: "14px",
|
|
113856
|
-
color: isDarkMode ? "#a3a3a3" : "#6b7280"
|
|
113857
|
-
}
|
|
113858
|
-
}, /*#__PURE__*/ React.createElement("div", null, "Agent: ", sourceEvaluation.agent_name), /*#__PURE__*/ React.createElement("div", null, "Runs: ", sourceEvaluation.runs.length), /*#__PURE__*/ React.createElement("div", null, "Created: ", moment(sourceEvaluation.created_at).format("YYYY-MM-DD HH:mm:ss")))), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("h3", {
|
|
113859
|
-
style: {
|
|
113860
|
-
margin: "0 0 12px 0",
|
|
113861
|
-
fontSize: "16px",
|
|
113862
|
-
fontWeight: 600
|
|
113863
|
-
}
|
|
113864
|
-
}, "Target: ", targetEvaluation.name || "Unnamed Evaluation"), /*#__PURE__*/ React.createElement("div", {
|
|
113865
|
-
style: {
|
|
113866
|
-
fontSize: "14px",
|
|
113867
|
-
color: isDarkMode ? "#a3a3a3" : "#6b7280"
|
|
113868
|
-
}
|
|
113869
|
-
}, /*#__PURE__*/ React.createElement("div", null, "Agent: ", targetEvaluation.agent_name), /*#__PURE__*/ React.createElement("div", null, "Runs: ", targetEvaluation.runs.length), /*#__PURE__*/ React.createElement("div", null, "Created: ", moment(targetEvaluation.created_at).format("YYYY-MM-DD HH:mm:ss"))))), /*#__PURE__*/ React.createElement("h3", {
|
|
113870
|
-
style: {
|
|
113871
|
-
margin: "0 0 16px 0",
|
|
113872
|
-
fontSize: "18px",
|
|
113873
|
-
fontWeight: 600
|
|
113874
|
-
}
|
|
113875
|
-
}, "Metrics Comparison"), /*#__PURE__*/ React.createElement(ForwardTable, {
|
|
113876
|
-
columns: comparisonColumns,
|
|
113877
|
-
dataSource: comparisonData,
|
|
113878
|
-
rowKey: "metricName",
|
|
113879
|
-
pagination: false,
|
|
113880
|
-
style: {
|
|
113881
|
-
background: isDarkMode ? "#141414" : "#fff"
|
|
113882
|
-
}
|
|
113883
|
-
})));
|
|
114464
|
+
}, /*#__PURE__*/ React.createElement(EvaluationsCompareView, {
|
|
114465
|
+
evaluations: evaluations,
|
|
114466
|
+
evaluationId1: evaluationId1,
|
|
114467
|
+
evaluationId2: evaluationId2,
|
|
114468
|
+
onEvaluationId1Change: onEvaluationId1Change,
|
|
114469
|
+
onEvaluationId2Change: onEvaluationId2Change,
|
|
114470
|
+
showEvaluationComparisonDropdowns: false
|
|
114471
|
+
}));
|
|
113884
114472
|
};
|
|
113885
114473
|
|
|
113886
114474
|
const defaultGetEvaluatorResultsHref = (evaluationId, evaluatorId)=>`#/evaluations/${evaluationId}/results/${evaluatorId}`;
|
|
@@ -114114,13 +114702,23 @@ const EvaluationDetailsDrawer = ({ evaluation, open, onClose, getEvaluatorResult
|
|
|
114114
114702
|
})))));
|
|
114115
114703
|
};
|
|
114116
114704
|
|
|
114117
|
-
const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefresh, onRowClick, onCompare, showFilters = true, showCompare = true, emptyMessage, title })=>{
|
|
114705
|
+
const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefresh, onRowClick, onCompare, compareIdsFromUrl, onCompareUrlChange, showFilters = true, showCompare = true, emptyMessage, title })=>{
|
|
114118
114706
|
const { theme } = useTheme$1();
|
|
114119
114707
|
const [selectedAgents, setSelectedAgents] = React.useState([]);
|
|
114120
114708
|
const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
|
|
114121
114709
|
const [compareDrawerOpen, setCompareDrawerOpen] = React.useState(false);
|
|
114122
|
-
const [
|
|
114123
|
-
const [
|
|
114710
|
+
const [evaluationId1, setEvaluationId1] = React.useState(null);
|
|
114711
|
+
const [evaluationId2, setEvaluationId2] = React.useState(null);
|
|
114712
|
+
// Sync drawer when compare param comes from URL
|
|
114713
|
+
React.useEffect(()=>{
|
|
114714
|
+
if (compareIdsFromUrl) {
|
|
114715
|
+
setEvaluationId1(compareIdsFromUrl[0]);
|
|
114716
|
+
setEvaluationId2(compareIdsFromUrl[1]);
|
|
114717
|
+
setCompareDrawerOpen(true);
|
|
114718
|
+
}
|
|
114719
|
+
}, [
|
|
114720
|
+
compareIdsFromUrl
|
|
114721
|
+
]);
|
|
114124
114722
|
const [selectedEvaluation, setSelectedEvaluation] = React.useState(null);
|
|
114125
114723
|
const [detailsDrawerOpen, setDetailsDrawerOpen] = React.useState(false);
|
|
114126
114724
|
const [pageSize, setPageSize] = React.useState(50);
|
|
@@ -114184,14 +114782,23 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
|
|
|
114184
114782
|
if (selectedRowKeys.length === 2 && onCompare) {
|
|
114185
114783
|
onCompare(selectedRowKeys[0], selectedRowKeys[1]);
|
|
114186
114784
|
} else if (selectedRowKeys.length === 2 && !onCompare) {
|
|
114187
|
-
|
|
114188
|
-
|
|
114785
|
+
setEvaluationId1(selectedRowKeys[0]);
|
|
114786
|
+
setEvaluationId2(selectedRowKeys[1]);
|
|
114189
114787
|
setCompareDrawerOpen(true);
|
|
114190
114788
|
}
|
|
114191
114789
|
};
|
|
114192
114790
|
// Handle drawer close
|
|
114193
114791
|
const handleDrawerClose = ()=>{
|
|
114194
114792
|
setCompareDrawerOpen(false);
|
|
114793
|
+
onCompareUrlChange?.(null, null);
|
|
114794
|
+
};
|
|
114795
|
+
const handleEvaluationId1Change = (id)=>{
|
|
114796
|
+
setEvaluationId1(id);
|
|
114797
|
+
onCompareUrlChange?.(id, evaluationId2);
|
|
114798
|
+
};
|
|
114799
|
+
const handleEvaluationId2Change = (id)=>{
|
|
114800
|
+
setEvaluationId2(id);
|
|
114801
|
+
onCompareUrlChange?.(evaluationId1, id);
|
|
114195
114802
|
};
|
|
114196
114803
|
// Handle row click to open evaluation details
|
|
114197
114804
|
const handleRowClick = (record)=>{
|
|
@@ -114392,14 +114999,14 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
|
|
|
114392
114999
|
cursor: "pointer"
|
|
114393
115000
|
}
|
|
114394
115001
|
})
|
|
114395
|
-
}),
|
|
115002
|
+
}), compareDrawerOpen && /*#__PURE__*/ React.createElement(EvaluationsCompareDrawer, {
|
|
114396
115003
|
open: compareDrawerOpen,
|
|
114397
115004
|
onClose: handleDrawerClose,
|
|
114398
|
-
|
|
114399
|
-
|
|
115005
|
+
evaluationId1: evaluationId1,
|
|
115006
|
+
evaluationId2: evaluationId2,
|
|
114400
115007
|
evaluations: normalized,
|
|
114401
|
-
|
|
114402
|
-
|
|
115008
|
+
onEvaluationId1Change: onCompareUrlChange ? handleEvaluationId1Change : setEvaluationId1,
|
|
115009
|
+
onEvaluationId2Change: onCompareUrlChange ? handleEvaluationId2Change : setEvaluationId2
|
|
114403
115010
|
}), !onRowClick && /*#__PURE__*/ React.createElement(EvaluationDetailsDrawer, {
|
|
114404
115011
|
evaluation: selectedEvaluation,
|
|
114405
115012
|
open: detailsDrawerOpen,
|
|
@@ -114407,6 +115014,1938 @@ const EvaluationsTable = ({ evaluations, loading = false, error = null, onRefres
|
|
|
114407
115014
|
}));
|
|
114408
115015
|
};
|
|
114409
115016
|
|
|
115017
|
+
function invariant(value, message) {
|
|
115018
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
115019
|
+
throw new Error(message);
|
|
115020
|
+
}
|
|
115021
|
+
}
|
|
115022
|
+
function warning(cond, message) {
|
|
115023
|
+
if (!cond) {
|
|
115024
|
+
if (typeof console !== "undefined") console.warn(message);
|
|
115025
|
+
try {
|
|
115026
|
+
throw new Error(message);
|
|
115027
|
+
} catch (e) {}
|
|
115028
|
+
}
|
|
115029
|
+
}
|
|
115030
|
+
function createPath({ pathname = "/", search = "", hash = "" }) {
|
|
115031
|
+
if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search;
|
|
115032
|
+
if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
|
115033
|
+
return pathname;
|
|
115034
|
+
}
|
|
115035
|
+
function parsePath(path) {
|
|
115036
|
+
let parsedPath = {};
|
|
115037
|
+
if (path) {
|
|
115038
|
+
let hashIndex = path.indexOf("#");
|
|
115039
|
+
if (hashIndex >= 0) {
|
|
115040
|
+
parsedPath.hash = path.substring(hashIndex);
|
|
115041
|
+
path = path.substring(0, hashIndex);
|
|
115042
|
+
}
|
|
115043
|
+
let searchIndex = path.indexOf("?");
|
|
115044
|
+
if (searchIndex >= 0) {
|
|
115045
|
+
parsedPath.search = path.substring(searchIndex);
|
|
115046
|
+
path = path.substring(0, searchIndex);
|
|
115047
|
+
}
|
|
115048
|
+
if (path) {
|
|
115049
|
+
parsedPath.pathname = path;
|
|
115050
|
+
}
|
|
115051
|
+
}
|
|
115052
|
+
return parsedPath;
|
|
115053
|
+
}
|
|
115054
|
+
function matchRoutes(routes, locationArg, basename = "/") {
|
|
115055
|
+
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
115056
|
+
}
|
|
115057
|
+
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
115058
|
+
let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
115059
|
+
let pathname = stripBasename(location.pathname || "/", basename);
|
|
115060
|
+
if (pathname == null) {
|
|
115061
|
+
return null;
|
|
115062
|
+
}
|
|
115063
|
+
let branches = flattenRoutes(routes);
|
|
115064
|
+
rankRouteBranches(branches);
|
|
115065
|
+
let matches = null;
|
|
115066
|
+
for(let i = 0; matches == null && i < branches.length; ++i){
|
|
115067
|
+
let decoded = decodePath(pathname);
|
|
115068
|
+
matches = matchRouteBranch(branches[i], decoded, allowPartial);
|
|
115069
|
+
}
|
|
115070
|
+
return matches;
|
|
115071
|
+
}
|
|
115072
|
+
function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
|
|
115073
|
+
let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath)=>{
|
|
115074
|
+
let meta = {
|
|
115075
|
+
relativePath: relativePath === void 0 ? route.path || "" : relativePath,
|
|
115076
|
+
caseSensitive: route.caseSensitive === true,
|
|
115077
|
+
childrenIndex: index,
|
|
115078
|
+
route
|
|
115079
|
+
};
|
|
115080
|
+
if (meta.relativePath.startsWith("/")) {
|
|
115081
|
+
if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
|
|
115082
|
+
return;
|
|
115083
|
+
}
|
|
115084
|
+
invariant(meta.relativePath.startsWith(parentPath), `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`);
|
|
115085
|
+
meta.relativePath = meta.relativePath.slice(parentPath.length);
|
|
115086
|
+
}
|
|
115087
|
+
let path = joinPaths([
|
|
115088
|
+
parentPath,
|
|
115089
|
+
meta.relativePath
|
|
115090
|
+
]);
|
|
115091
|
+
let routesMeta = parentsMeta.concat(meta);
|
|
115092
|
+
if (route.children && route.children.length > 0) {
|
|
115093
|
+
invariant(// Our types know better, but runtime JS may not!
|
|
115094
|
+
// @ts-expect-error
|
|
115095
|
+
route.index !== true, `Index routes must not have child routes. Please remove all child routes from route path "${path}".`);
|
|
115096
|
+
flattenRoutes(route.children, branches, routesMeta, path, hasParentOptionalSegments);
|
|
115097
|
+
}
|
|
115098
|
+
if (route.path == null && !route.index) {
|
|
115099
|
+
return;
|
|
115100
|
+
}
|
|
115101
|
+
branches.push({
|
|
115102
|
+
path,
|
|
115103
|
+
score: computeScore(path, route.index),
|
|
115104
|
+
routesMeta
|
|
115105
|
+
});
|
|
115106
|
+
};
|
|
115107
|
+
routes.forEach((route, index)=>{
|
|
115108
|
+
if (route.path === "" || !route.path?.includes("?")) {
|
|
115109
|
+
flattenRoute(route, index);
|
|
115110
|
+
} else {
|
|
115111
|
+
for (let exploded of explodeOptionalSegments(route.path)){
|
|
115112
|
+
flattenRoute(route, index, true, exploded);
|
|
115113
|
+
}
|
|
115114
|
+
}
|
|
115115
|
+
});
|
|
115116
|
+
return branches;
|
|
115117
|
+
}
|
|
115118
|
+
function explodeOptionalSegments(path) {
|
|
115119
|
+
let segments = path.split("/");
|
|
115120
|
+
if (segments.length === 0) return [];
|
|
115121
|
+
let [first, ...rest] = segments;
|
|
115122
|
+
let isOptional = first.endsWith("?");
|
|
115123
|
+
let required = first.replace(/\?$/, "");
|
|
115124
|
+
if (rest.length === 0) {
|
|
115125
|
+
return isOptional ? [
|
|
115126
|
+
required,
|
|
115127
|
+
""
|
|
115128
|
+
] : [
|
|
115129
|
+
required
|
|
115130
|
+
];
|
|
115131
|
+
}
|
|
115132
|
+
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
115133
|
+
let result = [];
|
|
115134
|
+
result.push(...restExploded.map((subpath)=>subpath === "" ? required : [
|
|
115135
|
+
required,
|
|
115136
|
+
subpath
|
|
115137
|
+
].join("/")));
|
|
115138
|
+
if (isOptional) {
|
|
115139
|
+
result.push(...restExploded);
|
|
115140
|
+
}
|
|
115141
|
+
return result.map((exploded)=>path.startsWith("/") && exploded === "" ? "/" : exploded);
|
|
115142
|
+
}
|
|
115143
|
+
function rankRouteBranches(branches) {
|
|
115144
|
+
branches.sort((a, b)=>a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta)=>meta.childrenIndex), b.routesMeta.map((meta)=>meta.childrenIndex)));
|
|
115145
|
+
}
|
|
115146
|
+
var paramRe = /^:[\w-]+$/;
|
|
115147
|
+
var dynamicSegmentValue = 3;
|
|
115148
|
+
var indexRouteValue = 2;
|
|
115149
|
+
var emptySegmentValue = 1;
|
|
115150
|
+
var staticSegmentValue = 10;
|
|
115151
|
+
var splatPenalty = -2;
|
|
115152
|
+
var isSplat = (s)=>s === "*";
|
|
115153
|
+
function computeScore(path, index) {
|
|
115154
|
+
let segments = path.split("/");
|
|
115155
|
+
let initialScore = segments.length;
|
|
115156
|
+
if (segments.some(isSplat)) {
|
|
115157
|
+
initialScore += splatPenalty;
|
|
115158
|
+
}
|
|
115159
|
+
if (index) {
|
|
115160
|
+
initialScore += indexRouteValue;
|
|
115161
|
+
}
|
|
115162
|
+
return segments.filter((s)=>!isSplat(s)).reduce((score, segment)=>score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore);
|
|
115163
|
+
}
|
|
115164
|
+
function compareIndexes(a, b) {
|
|
115165
|
+
let siblings = a.length === b.length && a.slice(0, -1).every((n, i)=>n === b[i]);
|
|
115166
|
+
return siblings ? // If two routes are siblings, we should try to match the earlier sibling
|
|
115167
|
+
// first. This allows people to have fine-grained control over the matching
|
|
115168
|
+
// behavior by simply putting routes with identical paths in the order they
|
|
115169
|
+
// want them tried.
|
|
115170
|
+
a[a.length - 1] - b[b.length - 1] : // Otherwise, it doesn't really make sense to rank non-siblings by index,
|
|
115171
|
+
// so they sort equally.
|
|
115172
|
+
0;
|
|
115173
|
+
}
|
|
115174
|
+
function matchRouteBranch(branch, pathname, allowPartial = false) {
|
|
115175
|
+
let { routesMeta } = branch;
|
|
115176
|
+
let matchedParams = {};
|
|
115177
|
+
let matchedPathname = "/";
|
|
115178
|
+
let matches = [];
|
|
115179
|
+
for(let i = 0; i < routesMeta.length; ++i){
|
|
115180
|
+
let meta = routesMeta[i];
|
|
115181
|
+
let end = i === routesMeta.length - 1;
|
|
115182
|
+
let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
|
|
115183
|
+
let match = matchPath({
|
|
115184
|
+
path: meta.relativePath,
|
|
115185
|
+
caseSensitive: meta.caseSensitive,
|
|
115186
|
+
end
|
|
115187
|
+
}, remainingPathname);
|
|
115188
|
+
let route = meta.route;
|
|
115189
|
+
if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
|
|
115190
|
+
match = matchPath({
|
|
115191
|
+
path: meta.relativePath,
|
|
115192
|
+
caseSensitive: meta.caseSensitive,
|
|
115193
|
+
end: false
|
|
115194
|
+
}, remainingPathname);
|
|
115195
|
+
}
|
|
115196
|
+
if (!match) {
|
|
115197
|
+
return null;
|
|
115198
|
+
}
|
|
115199
|
+
Object.assign(matchedParams, match.params);
|
|
115200
|
+
matches.push({
|
|
115201
|
+
// TODO: Can this as be avoided?
|
|
115202
|
+
params: matchedParams,
|
|
115203
|
+
pathname: joinPaths([
|
|
115204
|
+
matchedPathname,
|
|
115205
|
+
match.pathname
|
|
115206
|
+
]),
|
|
115207
|
+
pathnameBase: normalizePathname(joinPaths([
|
|
115208
|
+
matchedPathname,
|
|
115209
|
+
match.pathnameBase
|
|
115210
|
+
])),
|
|
115211
|
+
route
|
|
115212
|
+
});
|
|
115213
|
+
if (match.pathnameBase !== "/") {
|
|
115214
|
+
matchedPathname = joinPaths([
|
|
115215
|
+
matchedPathname,
|
|
115216
|
+
match.pathnameBase
|
|
115217
|
+
]);
|
|
115218
|
+
}
|
|
115219
|
+
}
|
|
115220
|
+
return matches;
|
|
115221
|
+
}
|
|
115222
|
+
function matchPath(pattern, pathname) {
|
|
115223
|
+
if (typeof pattern === "string") {
|
|
115224
|
+
pattern = {
|
|
115225
|
+
path: pattern,
|
|
115226
|
+
caseSensitive: false,
|
|
115227
|
+
end: true
|
|
115228
|
+
};
|
|
115229
|
+
}
|
|
115230
|
+
let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
|
|
115231
|
+
let match = pathname.match(matcher);
|
|
115232
|
+
if (!match) return null;
|
|
115233
|
+
let matchedPathname = match[0];
|
|
115234
|
+
let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
|
|
115235
|
+
let captureGroups = match.slice(1);
|
|
115236
|
+
let params = compiledParams.reduce((memo2, { paramName, isOptional }, index)=>{
|
|
115237
|
+
if (paramName === "*") {
|
|
115238
|
+
let splatValue = captureGroups[index] || "";
|
|
115239
|
+
pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
|
|
115240
|
+
}
|
|
115241
|
+
const value = captureGroups[index];
|
|
115242
|
+
if (isOptional && !value) {
|
|
115243
|
+
memo2[paramName] = void 0;
|
|
115244
|
+
} else {
|
|
115245
|
+
memo2[paramName] = (value || "").replace(/%2F/g, "/");
|
|
115246
|
+
}
|
|
115247
|
+
return memo2;
|
|
115248
|
+
}, {});
|
|
115249
|
+
return {
|
|
115250
|
+
params,
|
|
115251
|
+
pathname: matchedPathname,
|
|
115252
|
+
pathnameBase,
|
|
115253
|
+
pattern
|
|
115254
|
+
};
|
|
115255
|
+
}
|
|
115256
|
+
function compilePath(path, caseSensitive = false, end = true) {
|
|
115257
|
+
warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`);
|
|
115258
|
+
let params = [];
|
|
115259
|
+
let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (match, paramName, isOptional, index, str)=>{
|
|
115260
|
+
params.push({
|
|
115261
|
+
paramName,
|
|
115262
|
+
isOptional: isOptional != null
|
|
115263
|
+
});
|
|
115264
|
+
if (isOptional) {
|
|
115265
|
+
let nextChar = str.charAt(index + match.length);
|
|
115266
|
+
if (nextChar && nextChar !== "/") {
|
|
115267
|
+
return "/([^\\/]*)";
|
|
115268
|
+
}
|
|
115269
|
+
return "(?:/([^\\/]*))?";
|
|
115270
|
+
}
|
|
115271
|
+
return "/([^\\/]+)";
|
|
115272
|
+
}).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
|
|
115273
|
+
if (path.endsWith("*")) {
|
|
115274
|
+
params.push({
|
|
115275
|
+
paramName: "*"
|
|
115276
|
+
});
|
|
115277
|
+
regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
|
|
115278
|
+
} else if (end) {
|
|
115279
|
+
regexpSource += "\\/*$";
|
|
115280
|
+
} else if (path !== "" && path !== "/") {
|
|
115281
|
+
regexpSource += "(?:(?=\\/|$))";
|
|
115282
|
+
} else ;
|
|
115283
|
+
let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
|
|
115284
|
+
return [
|
|
115285
|
+
matcher,
|
|
115286
|
+
params
|
|
115287
|
+
];
|
|
115288
|
+
}
|
|
115289
|
+
function decodePath(value) {
|
|
115290
|
+
try {
|
|
115291
|
+
return value.split("/").map((v)=>decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
115292
|
+
} catch (error) {
|
|
115293
|
+
warning(false, `The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`);
|
|
115294
|
+
return value;
|
|
115295
|
+
}
|
|
115296
|
+
}
|
|
115297
|
+
function stripBasename(pathname, basename) {
|
|
115298
|
+
if (basename === "/") return pathname;
|
|
115299
|
+
if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
|
|
115300
|
+
return null;
|
|
115301
|
+
}
|
|
115302
|
+
let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
|
|
115303
|
+
let nextChar = pathname.charAt(startIndex);
|
|
115304
|
+
if (nextChar && nextChar !== "/") {
|
|
115305
|
+
return null;
|
|
115306
|
+
}
|
|
115307
|
+
return pathname.slice(startIndex) || "/";
|
|
115308
|
+
}
|
|
115309
|
+
var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
115310
|
+
function resolvePath(to, fromPathname = "/") {
|
|
115311
|
+
let { pathname: toPathname, search = "", hash = "" } = typeof to === "string" ? parsePath(to) : to;
|
|
115312
|
+
let pathname;
|
|
115313
|
+
if (toPathname) {
|
|
115314
|
+
toPathname = toPathname.replace(/\/\/+/g, "/");
|
|
115315
|
+
if (toPathname.startsWith("/")) {
|
|
115316
|
+
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
115317
|
+
} else {
|
|
115318
|
+
pathname = resolvePathname(toPathname, fromPathname);
|
|
115319
|
+
}
|
|
115320
|
+
} else {
|
|
115321
|
+
pathname = fromPathname;
|
|
115322
|
+
}
|
|
115323
|
+
return {
|
|
115324
|
+
pathname,
|
|
115325
|
+
search: normalizeSearch(search),
|
|
115326
|
+
hash: normalizeHash(hash)
|
|
115327
|
+
};
|
|
115328
|
+
}
|
|
115329
|
+
function resolvePathname(relativePath, fromPathname) {
|
|
115330
|
+
let segments = fromPathname.replace(/\/+$/, "").split("/");
|
|
115331
|
+
let relativeSegments = relativePath.split("/");
|
|
115332
|
+
relativeSegments.forEach((segment)=>{
|
|
115333
|
+
if (segment === "..") {
|
|
115334
|
+
if (segments.length > 1) segments.pop();
|
|
115335
|
+
} else if (segment !== ".") {
|
|
115336
|
+
segments.push(segment);
|
|
115337
|
+
}
|
|
115338
|
+
});
|
|
115339
|
+
return segments.length > 1 ? segments.join("/") : "/";
|
|
115340
|
+
}
|
|
115341
|
+
function getInvalidPathError(char, field, dest, path) {
|
|
115342
|
+
return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(path)}]. Please separate it out to the \`to.${dest}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
|
|
115343
|
+
}
|
|
115344
|
+
function getPathContributingMatches(matches) {
|
|
115345
|
+
return matches.filter((match, index)=>index === 0 || match.route.path && match.route.path.length > 0);
|
|
115346
|
+
}
|
|
115347
|
+
function getResolveToMatches(matches) {
|
|
115348
|
+
let pathMatches = getPathContributingMatches(matches);
|
|
115349
|
+
return pathMatches.map((match, idx)=>idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
|
|
115350
|
+
}
|
|
115351
|
+
function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
|
|
115352
|
+
let to;
|
|
115353
|
+
if (typeof toArg === "string") {
|
|
115354
|
+
to = parsePath(toArg);
|
|
115355
|
+
} else {
|
|
115356
|
+
to = {
|
|
115357
|
+
...toArg
|
|
115358
|
+
};
|
|
115359
|
+
invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
|
|
115360
|
+
invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
|
|
115361
|
+
invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
|
|
115362
|
+
}
|
|
115363
|
+
let isEmptyPath = toArg === "" || to.pathname === "";
|
|
115364
|
+
let toPathname = isEmptyPath ? "/" : to.pathname;
|
|
115365
|
+
let from;
|
|
115366
|
+
if (toPathname == null) {
|
|
115367
|
+
from = locationPathname;
|
|
115368
|
+
} else {
|
|
115369
|
+
let routePathnameIndex = routePathnames.length - 1;
|
|
115370
|
+
if (!isPathRelative && toPathname.startsWith("..")) {
|
|
115371
|
+
let toSegments = toPathname.split("/");
|
|
115372
|
+
while(toSegments[0] === ".."){
|
|
115373
|
+
toSegments.shift();
|
|
115374
|
+
routePathnameIndex -= 1;
|
|
115375
|
+
}
|
|
115376
|
+
to.pathname = toSegments.join("/");
|
|
115377
|
+
}
|
|
115378
|
+
from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
|
|
115379
|
+
}
|
|
115380
|
+
let path = resolvePath(to, from);
|
|
115381
|
+
let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
|
|
115382
|
+
let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
|
|
115383
|
+
if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
|
|
115384
|
+
path.pathname += "/";
|
|
115385
|
+
}
|
|
115386
|
+
return path;
|
|
115387
|
+
}
|
|
115388
|
+
var joinPaths = (paths)=>paths.join("/").replace(/\/\/+/g, "/");
|
|
115389
|
+
var normalizePathname = (pathname)=>pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
|
|
115390
|
+
var normalizeSearch = (search)=>!search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
|
115391
|
+
var normalizeHash = (hash)=>!hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
115392
|
+
var ErrorResponseImpl = class {
|
|
115393
|
+
constructor(status, statusText, data2, internal = false){
|
|
115394
|
+
this.status = status;
|
|
115395
|
+
this.statusText = statusText || "";
|
|
115396
|
+
this.internal = internal;
|
|
115397
|
+
if (data2 instanceof Error) {
|
|
115398
|
+
this.data = data2.toString();
|
|
115399
|
+
this.error = data2;
|
|
115400
|
+
} else {
|
|
115401
|
+
this.data = data2;
|
|
115402
|
+
}
|
|
115403
|
+
}
|
|
115404
|
+
};
|
|
115405
|
+
function isRouteErrorResponse(error) {
|
|
115406
|
+
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
115407
|
+
}
|
|
115408
|
+
function getRoutePattern(matches) {
|
|
115409
|
+
return matches.map((m)=>m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
|
|
115410
|
+
}
|
|
115411
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
115412
|
+
function parseToInfo(_to, basename) {
|
|
115413
|
+
let to = _to;
|
|
115414
|
+
if (typeof to !== "string" || !ABSOLUTE_URL_REGEX.test(to)) {
|
|
115415
|
+
return {
|
|
115416
|
+
absoluteURL: void 0,
|
|
115417
|
+
isExternal: false,
|
|
115418
|
+
to
|
|
115419
|
+
};
|
|
115420
|
+
}
|
|
115421
|
+
let absoluteURL = to;
|
|
115422
|
+
let isExternal = false;
|
|
115423
|
+
if (isBrowser) {
|
|
115424
|
+
try {
|
|
115425
|
+
let currentUrl = new URL(window.location.href);
|
|
115426
|
+
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
|
|
115427
|
+
let path = stripBasename(targetUrl.pathname, basename);
|
|
115428
|
+
if (targetUrl.origin === currentUrl.origin && path != null) {
|
|
115429
|
+
to = path + targetUrl.search + targetUrl.hash;
|
|
115430
|
+
} else {
|
|
115431
|
+
isExternal = true;
|
|
115432
|
+
}
|
|
115433
|
+
} catch (e) {
|
|
115434
|
+
warning(false, `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`);
|
|
115435
|
+
}
|
|
115436
|
+
}
|
|
115437
|
+
return {
|
|
115438
|
+
absoluteURL,
|
|
115439
|
+
isExternal,
|
|
115440
|
+
to
|
|
115441
|
+
};
|
|
115442
|
+
}
|
|
115443
|
+
Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
115444
|
+
// lib/router/router.ts
|
|
115445
|
+
var validMutationMethodsArr = [
|
|
115446
|
+
"POST",
|
|
115447
|
+
"PUT",
|
|
115448
|
+
"PATCH",
|
|
115449
|
+
"DELETE"
|
|
115450
|
+
];
|
|
115451
|
+
new Set(validMutationMethodsArr);
|
|
115452
|
+
var validRequestMethodsArr = [
|
|
115453
|
+
"GET",
|
|
115454
|
+
...validMutationMethodsArr
|
|
115455
|
+
];
|
|
115456
|
+
new Set(validRequestMethodsArr);
|
|
115457
|
+
var DataRouterContext = React__namespace.createContext(null);
|
|
115458
|
+
DataRouterContext.displayName = "DataRouter";
|
|
115459
|
+
var DataRouterStateContext = React__namespace.createContext(null);
|
|
115460
|
+
DataRouterStateContext.displayName = "DataRouterState";
|
|
115461
|
+
var RSCRouterContext = React__namespace.createContext(false);
|
|
115462
|
+
var ViewTransitionContext = React__namespace.createContext({
|
|
115463
|
+
isTransitioning: false
|
|
115464
|
+
});
|
|
115465
|
+
ViewTransitionContext.displayName = "ViewTransition";
|
|
115466
|
+
var FetchersContext = React__namespace.createContext(/* @__PURE__ */ new Map());
|
|
115467
|
+
FetchersContext.displayName = "Fetchers";
|
|
115468
|
+
var AwaitContext = React__namespace.createContext(null);
|
|
115469
|
+
AwaitContext.displayName = "Await";
|
|
115470
|
+
var NavigationContext = React__namespace.createContext(null);
|
|
115471
|
+
NavigationContext.displayName = "Navigation";
|
|
115472
|
+
var LocationContext = React__namespace.createContext(null);
|
|
115473
|
+
LocationContext.displayName = "Location";
|
|
115474
|
+
var RouteContext = React__namespace.createContext({
|
|
115475
|
+
outlet: null,
|
|
115476
|
+
matches: [],
|
|
115477
|
+
isDataRoute: false
|
|
115478
|
+
});
|
|
115479
|
+
RouteContext.displayName = "Route";
|
|
115480
|
+
var RouteErrorContext = React__namespace.createContext(null);
|
|
115481
|
+
RouteErrorContext.displayName = "RouteError";
|
|
115482
|
+
// lib/errors.ts
|
|
115483
|
+
var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
|
|
115484
|
+
var ERROR_DIGEST_REDIRECT = "REDIRECT";
|
|
115485
|
+
var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
|
|
115486
|
+
function decodeRedirectErrorDigest(digest) {
|
|
115487
|
+
if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:{`)) {
|
|
115488
|
+
try {
|
|
115489
|
+
let parsed = JSON.parse(digest.slice(28));
|
|
115490
|
+
if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string" && typeof parsed.location === "string" && typeof parsed.reloadDocument === "boolean" && typeof parsed.replace === "boolean") {
|
|
115491
|
+
return parsed;
|
|
115492
|
+
}
|
|
115493
|
+
} catch {}
|
|
115494
|
+
}
|
|
115495
|
+
}
|
|
115496
|
+
function decodeRouteErrorResponseDigest(digest) {
|
|
115497
|
+
if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:{`)) {
|
|
115498
|
+
try {
|
|
115499
|
+
let parsed = JSON.parse(digest.slice(40));
|
|
115500
|
+
if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string") {
|
|
115501
|
+
return new ErrorResponseImpl(parsed.status, parsed.statusText, parsed.data);
|
|
115502
|
+
}
|
|
115503
|
+
} catch {}
|
|
115504
|
+
}
|
|
115505
|
+
}
|
|
115506
|
+
// lib/hooks.tsx
|
|
115507
|
+
function useHref(to, { relative } = {}) {
|
|
115508
|
+
invariant(useInRouterContext(), // TODO: This error is probably because they somehow have 2 versions of the
|
|
115509
|
+
// router loaded. We can help them understand how to avoid that.
|
|
115510
|
+
`useHref() may be used only in the context of a <Router> component.`);
|
|
115511
|
+
let { basename, navigator } = React__namespace.useContext(NavigationContext);
|
|
115512
|
+
let { hash, pathname, search } = useResolvedPath(to, {
|
|
115513
|
+
relative
|
|
115514
|
+
});
|
|
115515
|
+
let joinedPathname = pathname;
|
|
115516
|
+
if (basename !== "/") {
|
|
115517
|
+
joinedPathname = pathname === "/" ? basename : joinPaths([
|
|
115518
|
+
basename,
|
|
115519
|
+
pathname
|
|
115520
|
+
]);
|
|
115521
|
+
}
|
|
115522
|
+
return navigator.createHref({
|
|
115523
|
+
pathname: joinedPathname,
|
|
115524
|
+
search,
|
|
115525
|
+
hash
|
|
115526
|
+
});
|
|
115527
|
+
}
|
|
115528
|
+
function useInRouterContext() {
|
|
115529
|
+
return React__namespace.useContext(LocationContext) != null;
|
|
115530
|
+
}
|
|
115531
|
+
function useLocation() {
|
|
115532
|
+
invariant(useInRouterContext(), // TODO: This error is probably because they somehow have 2 versions of the
|
|
115533
|
+
// router loaded. We can help them understand how to avoid that.
|
|
115534
|
+
`useLocation() may be used only in the context of a <Router> component.`);
|
|
115535
|
+
return React__namespace.useContext(LocationContext).location;
|
|
115536
|
+
}
|
|
115537
|
+
var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
|
|
115538
|
+
function useIsomorphicLayoutEffect$1(cb) {
|
|
115539
|
+
let isStatic = React__namespace.useContext(NavigationContext).static;
|
|
115540
|
+
if (!isStatic) {
|
|
115541
|
+
React__namespace.useLayoutEffect(cb);
|
|
115542
|
+
}
|
|
115543
|
+
}
|
|
115544
|
+
function useNavigate() {
|
|
115545
|
+
let { isDataRoute } = React__namespace.useContext(RouteContext);
|
|
115546
|
+
return isDataRoute ? useNavigateStable() : useNavigateUnstable();
|
|
115547
|
+
}
|
|
115548
|
+
function useNavigateUnstable() {
|
|
115549
|
+
invariant(useInRouterContext(), // TODO: This error is probably because they somehow have 2 versions of the
|
|
115550
|
+
// router loaded. We can help them understand how to avoid that.
|
|
115551
|
+
`useNavigate() may be used only in the context of a <Router> component.`);
|
|
115552
|
+
let dataRouterContext = React__namespace.useContext(DataRouterContext);
|
|
115553
|
+
let { basename, navigator } = React__namespace.useContext(NavigationContext);
|
|
115554
|
+
let { matches } = React__namespace.useContext(RouteContext);
|
|
115555
|
+
let { pathname: locationPathname } = useLocation();
|
|
115556
|
+
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
115557
|
+
let activeRef = React__namespace.useRef(false);
|
|
115558
|
+
useIsomorphicLayoutEffect$1(()=>{
|
|
115559
|
+
activeRef.current = true;
|
|
115560
|
+
});
|
|
115561
|
+
let navigate = React__namespace.useCallback((to, options = {})=>{
|
|
115562
|
+
warning(activeRef.current, navigateEffectWarning);
|
|
115563
|
+
if (!activeRef.current) return;
|
|
115564
|
+
if (typeof to === "number") {
|
|
115565
|
+
navigator.go(to);
|
|
115566
|
+
return;
|
|
115567
|
+
}
|
|
115568
|
+
let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
|
|
115569
|
+
if (dataRouterContext == null && basename !== "/") {
|
|
115570
|
+
path.pathname = path.pathname === "/" ? basename : joinPaths([
|
|
115571
|
+
basename,
|
|
115572
|
+
path.pathname
|
|
115573
|
+
]);
|
|
115574
|
+
}
|
|
115575
|
+
(!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
|
|
115576
|
+
}, [
|
|
115577
|
+
basename,
|
|
115578
|
+
navigator,
|
|
115579
|
+
routePathnamesJson,
|
|
115580
|
+
locationPathname,
|
|
115581
|
+
dataRouterContext
|
|
115582
|
+
]);
|
|
115583
|
+
return navigate;
|
|
115584
|
+
}
|
|
115585
|
+
React__namespace.createContext(null);
|
|
115586
|
+
function useResolvedPath(to, { relative } = {}) {
|
|
115587
|
+
let { matches } = React__namespace.useContext(RouteContext);
|
|
115588
|
+
let { pathname: locationPathname } = useLocation();
|
|
115589
|
+
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
115590
|
+
return React__namespace.useMemo(()=>resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [
|
|
115591
|
+
to,
|
|
115592
|
+
routePathnamesJson,
|
|
115593
|
+
locationPathname,
|
|
115594
|
+
relative
|
|
115595
|
+
]);
|
|
115596
|
+
}
|
|
115597
|
+
function useRoutesImpl(routes, locationArg, dataRouterOpts) {
|
|
115598
|
+
invariant(useInRouterContext(), // TODO: This error is probably because they somehow have 2 versions of the
|
|
115599
|
+
// router loaded. We can help them understand how to avoid that.
|
|
115600
|
+
`useRoutes() may be used only in the context of a <Router> component.`);
|
|
115601
|
+
let { navigator } = React__namespace.useContext(NavigationContext);
|
|
115602
|
+
let { matches: parentMatches } = React__namespace.useContext(RouteContext);
|
|
115603
|
+
let routeMatch = parentMatches[parentMatches.length - 1];
|
|
115604
|
+
let parentParams = routeMatch ? routeMatch.params : {};
|
|
115605
|
+
let parentPathname = routeMatch ? routeMatch.pathname : "/";
|
|
115606
|
+
let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
|
|
115607
|
+
let parentRoute = routeMatch && routeMatch.route;
|
|
115608
|
+
{
|
|
115609
|
+
let parentPath = parentRoute && parentRoute.path || "";
|
|
115610
|
+
warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*") || parentPath.endsWith("*?"), `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${parentPathname}" (under <Route path="${parentPath}">) 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.
|
|
115611
|
+
|
|
115612
|
+
Please change the parent <Route path="${parentPath}"> to <Route path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`);
|
|
115613
|
+
}
|
|
115614
|
+
let locationFromContext = useLocation();
|
|
115615
|
+
let location;
|
|
115616
|
+
{
|
|
115617
|
+
location = locationFromContext;
|
|
115618
|
+
}
|
|
115619
|
+
let pathname = location.pathname || "/";
|
|
115620
|
+
let remainingPathname = pathname;
|
|
115621
|
+
if (parentPathnameBase !== "/") {
|
|
115622
|
+
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
|
|
115623
|
+
let segments = pathname.replace(/^\//, "").split("/");
|
|
115624
|
+
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
|
|
115625
|
+
}
|
|
115626
|
+
let matches = matchRoutes(routes, {
|
|
115627
|
+
pathname: remainingPathname
|
|
115628
|
+
});
|
|
115629
|
+
{
|
|
115630
|
+
warning(parentRoute || matches != null, `No routes matched location "${location.pathname}${location.search}${location.hash}" `);
|
|
115631
|
+
warning(matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0, `Matched leaf route at location "${location.pathname}${location.search}${location.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.`);
|
|
115632
|
+
}
|
|
115633
|
+
let renderedMatches = _renderMatches(matches && matches.map((match)=>Object.assign({}, match, {
|
|
115634
|
+
params: Object.assign({}, parentParams, match.params),
|
|
115635
|
+
pathname: joinPaths([
|
|
115636
|
+
parentPathnameBase,
|
|
115637
|
+
// Re-encode pathnames that were decoded inside matchRoutes.
|
|
115638
|
+
// Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
|
|
115639
|
+
// `new URL()` internally and we need to prevent it from treating
|
|
115640
|
+
// them as separators
|
|
115641
|
+
navigator.encodeLocation ? navigator.encodeLocation(match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")).pathname : match.pathname
|
|
115642
|
+
]),
|
|
115643
|
+
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
|
|
115644
|
+
parentPathnameBase,
|
|
115645
|
+
// Re-encode pathnames that were decoded inside matchRoutes
|
|
115646
|
+
// Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
|
|
115647
|
+
// `new URL()` internally and we need to prevent it from treating
|
|
115648
|
+
// them as separators
|
|
115649
|
+
navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")).pathname : match.pathnameBase
|
|
115650
|
+
])
|
|
115651
|
+
})), parentMatches, dataRouterOpts);
|
|
115652
|
+
return renderedMatches;
|
|
115653
|
+
}
|
|
115654
|
+
function DefaultErrorComponent() {
|
|
115655
|
+
let error = useRouteError();
|
|
115656
|
+
let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
|
|
115657
|
+
let stack = error instanceof Error ? error.stack : null;
|
|
115658
|
+
let lightgrey = "rgba(200,200,200, 0.5)";
|
|
115659
|
+
let preStyles = {
|
|
115660
|
+
padding: "0.5rem",
|
|
115661
|
+
backgroundColor: lightgrey
|
|
115662
|
+
};
|
|
115663
|
+
let codeStyles = {
|
|
115664
|
+
padding: "2px 4px",
|
|
115665
|
+
backgroundColor: lightgrey
|
|
115666
|
+
};
|
|
115667
|
+
let devInfo = null;
|
|
115668
|
+
{
|
|
115669
|
+
console.error("Error handled by React Router default ErrorBoundary:", error);
|
|
115670
|
+
devInfo = /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("p", null, "\u{1F4BF} Hey developer \u{1F44B}"), /* @__PURE__ */ React__namespace.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React__namespace.createElement("code", {
|
|
115671
|
+
style: codeStyles
|
|
115672
|
+
}, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React__namespace.createElement("code", {
|
|
115673
|
+
style: codeStyles
|
|
115674
|
+
}, "errorElement"), " prop on your route."));
|
|
115675
|
+
}
|
|
115676
|
+
return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React__namespace.createElement("h3", {
|
|
115677
|
+
style: {
|
|
115678
|
+
fontStyle: "italic"
|
|
115679
|
+
}
|
|
115680
|
+
}, message), stack ? /* @__PURE__ */ React__namespace.createElement("pre", {
|
|
115681
|
+
style: preStyles
|
|
115682
|
+
}, stack) : null, devInfo);
|
|
115683
|
+
}
|
|
115684
|
+
var defaultErrorElement = /* @__PURE__ */ React__namespace.createElement(DefaultErrorComponent, null);
|
|
115685
|
+
var RenderErrorBoundary = class extends React__namespace.Component {
|
|
115686
|
+
static getDerivedStateFromError(error) {
|
|
115687
|
+
return {
|
|
115688
|
+
error
|
|
115689
|
+
};
|
|
115690
|
+
}
|
|
115691
|
+
static getDerivedStateFromProps(props, state) {
|
|
115692
|
+
if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
|
|
115693
|
+
return {
|
|
115694
|
+
error: props.error,
|
|
115695
|
+
location: props.location,
|
|
115696
|
+
revalidation: props.revalidation
|
|
115697
|
+
};
|
|
115698
|
+
}
|
|
115699
|
+
return {
|
|
115700
|
+
error: props.error !== void 0 ? props.error : state.error,
|
|
115701
|
+
location: state.location,
|
|
115702
|
+
revalidation: props.revalidation || state.revalidation
|
|
115703
|
+
};
|
|
115704
|
+
}
|
|
115705
|
+
componentDidCatch(error, errorInfo) {
|
|
115706
|
+
if (this.props.onError) {
|
|
115707
|
+
this.props.onError(error, errorInfo);
|
|
115708
|
+
} else {
|
|
115709
|
+
console.error("React Router caught the following error during render", error);
|
|
115710
|
+
}
|
|
115711
|
+
}
|
|
115712
|
+
render() {
|
|
115713
|
+
let error = this.state.error;
|
|
115714
|
+
if (this.context && typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
|
|
115715
|
+
const decoded = decodeRouteErrorResponseDigest(error.digest);
|
|
115716
|
+
if (decoded) error = decoded;
|
|
115717
|
+
}
|
|
115718
|
+
let result = error !== void 0 ? /* @__PURE__ */ React__namespace.createElement(RouteContext.Provider, {
|
|
115719
|
+
value: this.props.routeContext
|
|
115720
|
+
}, /* @__PURE__ */ React__namespace.createElement(RouteErrorContext.Provider, {
|
|
115721
|
+
value: error,
|
|
115722
|
+
children: this.props.component
|
|
115723
|
+
})) : this.props.children;
|
|
115724
|
+
if (this.context) {
|
|
115725
|
+
return /* @__PURE__ */ React__namespace.createElement(RSCErrorHandler, {
|
|
115726
|
+
error
|
|
115727
|
+
}, result);
|
|
115728
|
+
}
|
|
115729
|
+
return result;
|
|
115730
|
+
}
|
|
115731
|
+
constructor(props){
|
|
115732
|
+
super(props);
|
|
115733
|
+
this.state = {
|
|
115734
|
+
location: props.location,
|
|
115735
|
+
revalidation: props.revalidation,
|
|
115736
|
+
error: props.error
|
|
115737
|
+
};
|
|
115738
|
+
}
|
|
115739
|
+
};
|
|
115740
|
+
RenderErrorBoundary.contextType = RSCRouterContext;
|
|
115741
|
+
var errorRedirectHandledMap = /* @__PURE__ */ new WeakMap();
|
|
115742
|
+
function RSCErrorHandler({ children, error }) {
|
|
115743
|
+
let { basename } = React__namespace.useContext(NavigationContext);
|
|
115744
|
+
if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
|
|
115745
|
+
let redirect2 = decodeRedirectErrorDigest(error.digest);
|
|
115746
|
+
if (redirect2) {
|
|
115747
|
+
let existingRedirect = errorRedirectHandledMap.get(error);
|
|
115748
|
+
if (existingRedirect) throw existingRedirect;
|
|
115749
|
+
let parsed = parseToInfo(redirect2.location, basename);
|
|
115750
|
+
if (isBrowser && !errorRedirectHandledMap.get(error)) {
|
|
115751
|
+
if (parsed.isExternal || redirect2.reloadDocument) {
|
|
115752
|
+
window.location.href = parsed.absoluteURL || parsed.to;
|
|
115753
|
+
} else {
|
|
115754
|
+
const redirectPromise = Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(parsed.to, {
|
|
115755
|
+
replace: redirect2.replace
|
|
115756
|
+
}));
|
|
115757
|
+
errorRedirectHandledMap.set(error, redirectPromise);
|
|
115758
|
+
throw redirectPromise;
|
|
115759
|
+
}
|
|
115760
|
+
}
|
|
115761
|
+
return /* @__PURE__ */ React__namespace.createElement("meta", {
|
|
115762
|
+
httpEquiv: "refresh",
|
|
115763
|
+
content: `0;url=${parsed.absoluteURL || parsed.to}`
|
|
115764
|
+
});
|
|
115765
|
+
}
|
|
115766
|
+
}
|
|
115767
|
+
return children;
|
|
115768
|
+
}
|
|
115769
|
+
function RenderedRoute({ routeContext, match, children }) {
|
|
115770
|
+
let dataRouterContext = React__namespace.useContext(DataRouterContext);
|
|
115771
|
+
if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
|
|
115772
|
+
dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
|
|
115773
|
+
}
|
|
115774
|
+
return /* @__PURE__ */ React__namespace.createElement(RouteContext.Provider, {
|
|
115775
|
+
value: routeContext
|
|
115776
|
+
}, children);
|
|
115777
|
+
}
|
|
115778
|
+
function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
|
|
115779
|
+
let dataRouterState = dataRouterOpts?.state;
|
|
115780
|
+
if (matches == null) {
|
|
115781
|
+
if (!dataRouterState) {
|
|
115782
|
+
return null;
|
|
115783
|
+
}
|
|
115784
|
+
if (dataRouterState.errors) {
|
|
115785
|
+
matches = dataRouterState.matches;
|
|
115786
|
+
} else if (parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
|
|
115787
|
+
matches = dataRouterState.matches;
|
|
115788
|
+
} else {
|
|
115789
|
+
return null;
|
|
115790
|
+
}
|
|
115791
|
+
}
|
|
115792
|
+
let renderedMatches = matches;
|
|
115793
|
+
let errors = dataRouterState?.errors;
|
|
115794
|
+
if (errors != null) {
|
|
115795
|
+
let errorIndex = renderedMatches.findIndex((m)=>m.route.id && errors?.[m.route.id] !== void 0);
|
|
115796
|
+
invariant(errorIndex >= 0, `Could not find a matching route for errors on route IDs: ${Object.keys(errors).join(",")}`);
|
|
115797
|
+
renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
|
|
115798
|
+
}
|
|
115799
|
+
let renderFallback = false;
|
|
115800
|
+
let fallbackIndex = -1;
|
|
115801
|
+
if (dataRouterOpts && dataRouterState) {
|
|
115802
|
+
renderFallback = dataRouterState.renderFallback;
|
|
115803
|
+
for(let i = 0; i < renderedMatches.length; i++){
|
|
115804
|
+
let match = renderedMatches[i];
|
|
115805
|
+
if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
|
|
115806
|
+
fallbackIndex = i;
|
|
115807
|
+
}
|
|
115808
|
+
if (match.route.id) {
|
|
115809
|
+
let { loaderData, errors: errors2 } = dataRouterState;
|
|
115810
|
+
let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
|
|
115811
|
+
if (match.route.lazy || needsToRunLoader) {
|
|
115812
|
+
if (dataRouterOpts.isStatic) {
|
|
115813
|
+
renderFallback = true;
|
|
115814
|
+
}
|
|
115815
|
+
if (fallbackIndex >= 0) {
|
|
115816
|
+
renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
|
|
115817
|
+
} else {
|
|
115818
|
+
renderedMatches = [
|
|
115819
|
+
renderedMatches[0]
|
|
115820
|
+
];
|
|
115821
|
+
}
|
|
115822
|
+
break;
|
|
115823
|
+
}
|
|
115824
|
+
}
|
|
115825
|
+
}
|
|
115826
|
+
}
|
|
115827
|
+
let onErrorHandler = dataRouterOpts?.onError;
|
|
115828
|
+
let onError = dataRouterState && onErrorHandler ? (error, errorInfo)=>{
|
|
115829
|
+
onErrorHandler(error, {
|
|
115830
|
+
location: dataRouterState.location,
|
|
115831
|
+
params: dataRouterState.matches?.[0]?.params ?? {},
|
|
115832
|
+
unstable_pattern: getRoutePattern(dataRouterState.matches),
|
|
115833
|
+
errorInfo
|
|
115834
|
+
});
|
|
115835
|
+
} : void 0;
|
|
115836
|
+
return renderedMatches.reduceRight((outlet, match, index)=>{
|
|
115837
|
+
let error;
|
|
115838
|
+
let shouldRenderHydrateFallback = false;
|
|
115839
|
+
let errorElement = null;
|
|
115840
|
+
let hydrateFallbackElement = null;
|
|
115841
|
+
if (dataRouterState) {
|
|
115842
|
+
error = errors && match.route.id ? errors[match.route.id] : void 0;
|
|
115843
|
+
errorElement = match.route.errorElement || defaultErrorElement;
|
|
115844
|
+
if (renderFallback) {
|
|
115845
|
+
if (fallbackIndex < 0 && index === 0) {
|
|
115846
|
+
warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration");
|
|
115847
|
+
shouldRenderHydrateFallback = true;
|
|
115848
|
+
hydrateFallbackElement = null;
|
|
115849
|
+
} else if (fallbackIndex === index) {
|
|
115850
|
+
shouldRenderHydrateFallback = true;
|
|
115851
|
+
hydrateFallbackElement = match.route.hydrateFallbackElement || null;
|
|
115852
|
+
}
|
|
115853
|
+
}
|
|
115854
|
+
}
|
|
115855
|
+
let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
|
|
115856
|
+
let getChildren = ()=>{
|
|
115857
|
+
let children;
|
|
115858
|
+
if (error) {
|
|
115859
|
+
children = errorElement;
|
|
115860
|
+
} else if (shouldRenderHydrateFallback) {
|
|
115861
|
+
children = hydrateFallbackElement;
|
|
115862
|
+
} else if (match.route.Component) {
|
|
115863
|
+
children = /* @__PURE__ */ React__namespace.createElement(match.route.Component, null);
|
|
115864
|
+
} else if (match.route.element) {
|
|
115865
|
+
children = match.route.element;
|
|
115866
|
+
} else {
|
|
115867
|
+
children = outlet;
|
|
115868
|
+
}
|
|
115869
|
+
return /* @__PURE__ */ React__namespace.createElement(RenderedRoute, {
|
|
115870
|
+
match,
|
|
115871
|
+
routeContext: {
|
|
115872
|
+
outlet,
|
|
115873
|
+
matches: matches2,
|
|
115874
|
+
isDataRoute: dataRouterState != null
|
|
115875
|
+
},
|
|
115876
|
+
children
|
|
115877
|
+
});
|
|
115878
|
+
};
|
|
115879
|
+
return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React__namespace.createElement(RenderErrorBoundary, {
|
|
115880
|
+
location: dataRouterState.location,
|
|
115881
|
+
revalidation: dataRouterState.revalidation,
|
|
115882
|
+
component: errorElement,
|
|
115883
|
+
error,
|
|
115884
|
+
children: getChildren(),
|
|
115885
|
+
routeContext: {
|
|
115886
|
+
outlet: null,
|
|
115887
|
+
matches: matches2,
|
|
115888
|
+
isDataRoute: true
|
|
115889
|
+
},
|
|
115890
|
+
onError
|
|
115891
|
+
}) : getChildren();
|
|
115892
|
+
}, null);
|
|
115893
|
+
}
|
|
115894
|
+
function getDataRouterConsoleError(hookName) {
|
|
115895
|
+
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
115896
|
+
}
|
|
115897
|
+
function useDataRouterContext(hookName) {
|
|
115898
|
+
let ctx = React__namespace.useContext(DataRouterContext);
|
|
115899
|
+
invariant(ctx, getDataRouterConsoleError(hookName));
|
|
115900
|
+
return ctx;
|
|
115901
|
+
}
|
|
115902
|
+
function useDataRouterState(hookName) {
|
|
115903
|
+
let state = React__namespace.useContext(DataRouterStateContext);
|
|
115904
|
+
invariant(state, getDataRouterConsoleError(hookName));
|
|
115905
|
+
return state;
|
|
115906
|
+
}
|
|
115907
|
+
function useRouteContext(hookName) {
|
|
115908
|
+
let route = React__namespace.useContext(RouteContext);
|
|
115909
|
+
invariant(route, getDataRouterConsoleError(hookName));
|
|
115910
|
+
return route;
|
|
115911
|
+
}
|
|
115912
|
+
function useCurrentRouteId(hookName) {
|
|
115913
|
+
let route = useRouteContext(hookName);
|
|
115914
|
+
let thisRoute = route.matches[route.matches.length - 1];
|
|
115915
|
+
invariant(thisRoute.route.id, `${hookName} can only be used on routes that contain a unique "id"`);
|
|
115916
|
+
return thisRoute.route.id;
|
|
115917
|
+
}
|
|
115918
|
+
function useRouteId() {
|
|
115919
|
+
return useCurrentRouteId("useRouteId" /* UseRouteId */ );
|
|
115920
|
+
}
|
|
115921
|
+
function useRouteError() {
|
|
115922
|
+
let error = React__namespace.useContext(RouteErrorContext);
|
|
115923
|
+
let state = useDataRouterState("useRouteError" /* UseRouteError */ );
|
|
115924
|
+
let routeId = useCurrentRouteId("useRouteError" /* UseRouteError */ );
|
|
115925
|
+
if (error !== void 0) {
|
|
115926
|
+
return error;
|
|
115927
|
+
}
|
|
115928
|
+
return state.errors?.[routeId];
|
|
115929
|
+
}
|
|
115930
|
+
function useNavigateStable() {
|
|
115931
|
+
let { router } = useDataRouterContext("useNavigate" /* UseNavigateStable */ );
|
|
115932
|
+
let id = useCurrentRouteId("useNavigate" /* UseNavigateStable */ );
|
|
115933
|
+
let activeRef = React__namespace.useRef(false);
|
|
115934
|
+
useIsomorphicLayoutEffect$1(()=>{
|
|
115935
|
+
activeRef.current = true;
|
|
115936
|
+
});
|
|
115937
|
+
let navigate = React__namespace.useCallback(async (to, options = {})=>{
|
|
115938
|
+
warning(activeRef.current, navigateEffectWarning);
|
|
115939
|
+
if (!activeRef.current) return;
|
|
115940
|
+
if (typeof to === "number") {
|
|
115941
|
+
await router.navigate(to);
|
|
115942
|
+
} else {
|
|
115943
|
+
await router.navigate(to, {
|
|
115944
|
+
fromRouteId: id,
|
|
115945
|
+
...options
|
|
115946
|
+
});
|
|
115947
|
+
}
|
|
115948
|
+
}, [
|
|
115949
|
+
router,
|
|
115950
|
+
id
|
|
115951
|
+
]);
|
|
115952
|
+
return navigate;
|
|
115953
|
+
}
|
|
115954
|
+
var alreadyWarned = {};
|
|
115955
|
+
function warningOnce(key, cond, message) {
|
|
115956
|
+
if (!cond && !alreadyWarned[key]) {
|
|
115957
|
+
alreadyWarned[key] = true;
|
|
115958
|
+
warning(false, message);
|
|
115959
|
+
}
|
|
115960
|
+
}
|
|
115961
|
+
React__namespace.memo(DataRoutes);
|
|
115962
|
+
function DataRoutes({ routes, future, state, isStatic, onError }) {
|
|
115963
|
+
return useRoutesImpl(routes, void 0, {
|
|
115964
|
+
state,
|
|
115965
|
+
isStatic,
|
|
115966
|
+
onError});
|
|
115967
|
+
}
|
|
115968
|
+
// lib/dom/dom.ts
|
|
115969
|
+
var defaultMethod = "get";
|
|
115970
|
+
var defaultEncType = "application/x-www-form-urlencoded";
|
|
115971
|
+
function isHtmlElement(object) {
|
|
115972
|
+
return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
|
|
115973
|
+
}
|
|
115974
|
+
function isButtonElement(object) {
|
|
115975
|
+
return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
|
|
115976
|
+
}
|
|
115977
|
+
function isFormElement(object) {
|
|
115978
|
+
return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
|
|
115979
|
+
}
|
|
115980
|
+
function isInputElement(object) {
|
|
115981
|
+
return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
|
|
115982
|
+
}
|
|
115983
|
+
function isModifiedEvent(event) {
|
|
115984
|
+
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
115985
|
+
}
|
|
115986
|
+
function shouldProcessLinkClick(event, target) {
|
|
115987
|
+
return event.button === 0 && // Ignore everything but left clicks
|
|
115988
|
+
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
|
|
115989
|
+
!isModifiedEvent(event);
|
|
115990
|
+
}
|
|
115991
|
+
function createSearchParams(init = "") {
|
|
115992
|
+
return new URLSearchParams(typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo2, key)=>{
|
|
115993
|
+
let value = init[key];
|
|
115994
|
+
return memo2.concat(Array.isArray(value) ? value.map((v)=>[
|
|
115995
|
+
key,
|
|
115996
|
+
v
|
|
115997
|
+
]) : [
|
|
115998
|
+
[
|
|
115999
|
+
key,
|
|
116000
|
+
value
|
|
116001
|
+
]
|
|
116002
|
+
]);
|
|
116003
|
+
}, []));
|
|
116004
|
+
}
|
|
116005
|
+
function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
|
|
116006
|
+
let searchParams = createSearchParams(locationSearch);
|
|
116007
|
+
if (defaultSearchParams) {
|
|
116008
|
+
defaultSearchParams.forEach((_, key)=>{
|
|
116009
|
+
if (!searchParams.has(key)) {
|
|
116010
|
+
defaultSearchParams.getAll(key).forEach((value)=>{
|
|
116011
|
+
searchParams.append(key, value);
|
|
116012
|
+
});
|
|
116013
|
+
}
|
|
116014
|
+
});
|
|
116015
|
+
}
|
|
116016
|
+
return searchParams;
|
|
116017
|
+
}
|
|
116018
|
+
var _formDataSupportsSubmitter = null;
|
|
116019
|
+
function isFormDataSubmitterSupported() {
|
|
116020
|
+
if (_formDataSupportsSubmitter === null) {
|
|
116021
|
+
try {
|
|
116022
|
+
new FormData(document.createElement("form"), // @ts-expect-error if FormData supports the submitter parameter, this will throw
|
|
116023
|
+
0);
|
|
116024
|
+
_formDataSupportsSubmitter = false;
|
|
116025
|
+
} catch (e) {
|
|
116026
|
+
_formDataSupportsSubmitter = true;
|
|
116027
|
+
}
|
|
116028
|
+
}
|
|
116029
|
+
return _formDataSupportsSubmitter;
|
|
116030
|
+
}
|
|
116031
|
+
var supportedFormEncTypes = /* @__PURE__ */ new Set([
|
|
116032
|
+
"application/x-www-form-urlencoded",
|
|
116033
|
+
"multipart/form-data",
|
|
116034
|
+
"text/plain"
|
|
116035
|
+
]);
|
|
116036
|
+
function getFormEncType(encType) {
|
|
116037
|
+
if (encType != null && !supportedFormEncTypes.has(encType)) {
|
|
116038
|
+
warning(false, `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`);
|
|
116039
|
+
return null;
|
|
116040
|
+
}
|
|
116041
|
+
return encType;
|
|
116042
|
+
}
|
|
116043
|
+
function getFormSubmissionInfo(target, basename) {
|
|
116044
|
+
let method;
|
|
116045
|
+
let action;
|
|
116046
|
+
let encType;
|
|
116047
|
+
let formData;
|
|
116048
|
+
let body;
|
|
116049
|
+
if (isFormElement(target)) {
|
|
116050
|
+
let attr = target.getAttribute("action");
|
|
116051
|
+
action = attr ? stripBasename(attr, basename) : null;
|
|
116052
|
+
method = target.getAttribute("method") || defaultMethod;
|
|
116053
|
+
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
|
116054
|
+
formData = new FormData(target);
|
|
116055
|
+
} else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
|
|
116056
|
+
let form = target.form;
|
|
116057
|
+
if (form == null) {
|
|
116058
|
+
throw new Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);
|
|
116059
|
+
}
|
|
116060
|
+
let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
|
116061
|
+
action = attr ? stripBasename(attr, basename) : null;
|
|
116062
|
+
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
|
|
116063
|
+
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
|
116064
|
+
formData = new FormData(form, target);
|
|
116065
|
+
if (!isFormDataSubmitterSupported()) {
|
|
116066
|
+
let { name, type, value } = target;
|
|
116067
|
+
if (type === "image") {
|
|
116068
|
+
let prefix = name ? `${name}.` : "";
|
|
116069
|
+
formData.append(`${prefix}x`, "0");
|
|
116070
|
+
formData.append(`${prefix}y`, "0");
|
|
116071
|
+
} else if (name) {
|
|
116072
|
+
formData.append(name, value);
|
|
116073
|
+
}
|
|
116074
|
+
}
|
|
116075
|
+
} else if (isHtmlElement(target)) {
|
|
116076
|
+
throw new Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);
|
|
116077
|
+
} else {
|
|
116078
|
+
method = defaultMethod;
|
|
116079
|
+
action = null;
|
|
116080
|
+
encType = defaultEncType;
|
|
116081
|
+
body = target;
|
|
116082
|
+
}
|
|
116083
|
+
if (formData && encType === "text/plain") {
|
|
116084
|
+
body = formData;
|
|
116085
|
+
formData = void 0;
|
|
116086
|
+
}
|
|
116087
|
+
return {
|
|
116088
|
+
action,
|
|
116089
|
+
method: method.toLowerCase(),
|
|
116090
|
+
encType,
|
|
116091
|
+
formData,
|
|
116092
|
+
body
|
|
116093
|
+
};
|
|
116094
|
+
}
|
|
116095
|
+
Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
116096
|
+
// lib/dom/ssr/invariant.ts
|
|
116097
|
+
function invariant2(value, message) {
|
|
116098
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
116099
|
+
throw new Error(message);
|
|
116100
|
+
}
|
|
116101
|
+
}
|
|
116102
|
+
function singleFetchUrl(reqUrl, basename, trailingSlashAware, extension) {
|
|
116103
|
+
let url = typeof reqUrl === "string" ? new URL(reqUrl, // This can be called during the SSR flow via PrefetchPageLinksImpl so
|
|
116104
|
+
// don't assume window is available
|
|
116105
|
+
typeof window === "undefined" ? "server://singlefetch/" : window.location.origin) : reqUrl;
|
|
116106
|
+
if (trailingSlashAware) {
|
|
116107
|
+
if (url.pathname.endsWith("/")) {
|
|
116108
|
+
url.pathname = `${url.pathname}_.${extension}`;
|
|
116109
|
+
} else {
|
|
116110
|
+
url.pathname = `${url.pathname}.${extension}`;
|
|
116111
|
+
}
|
|
116112
|
+
} else {
|
|
116113
|
+
if (url.pathname === "/") {
|
|
116114
|
+
url.pathname = `_root.${extension}`;
|
|
116115
|
+
} else if (basename && stripBasename(url.pathname, basename) === "/") {
|
|
116116
|
+
url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
|
|
116117
|
+
} else {
|
|
116118
|
+
url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
|
|
116119
|
+
}
|
|
116120
|
+
}
|
|
116121
|
+
return url;
|
|
116122
|
+
}
|
|
116123
|
+
// lib/dom/ssr/routeModules.ts
|
|
116124
|
+
async function loadRouteModule(route, routeModulesCache) {
|
|
116125
|
+
if (route.id in routeModulesCache) {
|
|
116126
|
+
return routeModulesCache[route.id];
|
|
116127
|
+
}
|
|
116128
|
+
try {
|
|
116129
|
+
let routeModule = await import(/* @vite-ignore */ /* webpackIgnore: true */ route.module);
|
|
116130
|
+
routeModulesCache[route.id] = routeModule;
|
|
116131
|
+
return routeModule;
|
|
116132
|
+
} catch (error) {
|
|
116133
|
+
console.error(`Error loading route module \`${route.module}\`, reloading page...`);
|
|
116134
|
+
console.error(error);
|
|
116135
|
+
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
116136
|
+
undefined) {
|
|
116137
|
+
throw error;
|
|
116138
|
+
}
|
|
116139
|
+
window.location.reload();
|
|
116140
|
+
return new Promise(()=>{});
|
|
116141
|
+
}
|
|
116142
|
+
}
|
|
116143
|
+
function isHtmlLinkDescriptor(object) {
|
|
116144
|
+
if (object == null) {
|
|
116145
|
+
return false;
|
|
116146
|
+
}
|
|
116147
|
+
if (object.href == null) {
|
|
116148
|
+
return object.rel === "preload" && typeof object.imageSrcSet === "string" && typeof object.imageSizes === "string";
|
|
116149
|
+
}
|
|
116150
|
+
return typeof object.rel === "string" && typeof object.href === "string";
|
|
116151
|
+
}
|
|
116152
|
+
async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
116153
|
+
let links = await Promise.all(matches.map(async (match)=>{
|
|
116154
|
+
let route = manifest.routes[match.route.id];
|
|
116155
|
+
if (route) {
|
|
116156
|
+
let mod = await loadRouteModule(route, routeModules);
|
|
116157
|
+
return mod.links ? mod.links() : [];
|
|
116158
|
+
}
|
|
116159
|
+
return [];
|
|
116160
|
+
}));
|
|
116161
|
+
return dedupeLinkDescriptors(links.flat(1).filter(isHtmlLinkDescriptor).filter((link)=>link.rel === "stylesheet" || link.rel === "preload").map((link)=>link.rel === "stylesheet" ? {
|
|
116162
|
+
...link,
|
|
116163
|
+
rel: "prefetch",
|
|
116164
|
+
as: "style"
|
|
116165
|
+
} : {
|
|
116166
|
+
...link,
|
|
116167
|
+
rel: "prefetch"
|
|
116168
|
+
}));
|
|
116169
|
+
}
|
|
116170
|
+
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
|
|
116171
|
+
let isNew = (match, index)=>{
|
|
116172
|
+
if (!currentMatches[index]) return true;
|
|
116173
|
+
return match.route.id !== currentMatches[index].route.id;
|
|
116174
|
+
};
|
|
116175
|
+
let matchPathChanged = (match, index)=>{
|
|
116176
|
+
return(// param change, /users/123 -> /users/456
|
|
116177
|
+
currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
|
|
116178
|
+
// e.g. /files/images/avatar.jpg -> files/finances.xls
|
|
116179
|
+
currentMatches[index].route.path?.endsWith("*") && currentMatches[index].params["*"] !== match.params["*"]);
|
|
116180
|
+
};
|
|
116181
|
+
if (mode === "assets") {
|
|
116182
|
+
return nextMatches.filter((match, index)=>isNew(match, index) || matchPathChanged(match, index));
|
|
116183
|
+
}
|
|
116184
|
+
if (mode === "data") {
|
|
116185
|
+
return nextMatches.filter((match, index)=>{
|
|
116186
|
+
let manifestRoute = manifest.routes[match.route.id];
|
|
116187
|
+
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
116188
|
+
return false;
|
|
116189
|
+
}
|
|
116190
|
+
if (isNew(match, index) || matchPathChanged(match, index)) {
|
|
116191
|
+
return true;
|
|
116192
|
+
}
|
|
116193
|
+
if (match.route.shouldRevalidate) {
|
|
116194
|
+
let routeChoice = match.route.shouldRevalidate({
|
|
116195
|
+
currentUrl: new URL(location.pathname + location.search + location.hash, window.origin),
|
|
116196
|
+
currentParams: currentMatches[0]?.params || {},
|
|
116197
|
+
nextUrl: new URL(page, window.origin),
|
|
116198
|
+
nextParams: match.params,
|
|
116199
|
+
defaultShouldRevalidate: true
|
|
116200
|
+
});
|
|
116201
|
+
if (typeof routeChoice === "boolean") {
|
|
116202
|
+
return routeChoice;
|
|
116203
|
+
}
|
|
116204
|
+
}
|
|
116205
|
+
return true;
|
|
116206
|
+
});
|
|
116207
|
+
}
|
|
116208
|
+
return [];
|
|
116209
|
+
}
|
|
116210
|
+
function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
|
|
116211
|
+
return dedupeHrefs(matches.map((match)=>{
|
|
116212
|
+
let route = manifest.routes[match.route.id];
|
|
116213
|
+
if (!route) return [];
|
|
116214
|
+
let hrefs = [
|
|
116215
|
+
route.module
|
|
116216
|
+
];
|
|
116217
|
+
if (route.clientActionModule) {
|
|
116218
|
+
hrefs = hrefs.concat(route.clientActionModule);
|
|
116219
|
+
}
|
|
116220
|
+
if (route.clientLoaderModule) {
|
|
116221
|
+
hrefs = hrefs.concat(route.clientLoaderModule);
|
|
116222
|
+
}
|
|
116223
|
+
if (includeHydrateFallback && route.hydrateFallbackModule) {
|
|
116224
|
+
hrefs = hrefs.concat(route.hydrateFallbackModule);
|
|
116225
|
+
}
|
|
116226
|
+
if (route.imports) {
|
|
116227
|
+
hrefs = hrefs.concat(route.imports);
|
|
116228
|
+
}
|
|
116229
|
+
return hrefs;
|
|
116230
|
+
}).flat(1));
|
|
116231
|
+
}
|
|
116232
|
+
function dedupeHrefs(hrefs) {
|
|
116233
|
+
return [
|
|
116234
|
+
...new Set(hrefs)
|
|
116235
|
+
];
|
|
116236
|
+
}
|
|
116237
|
+
function sortKeys(obj) {
|
|
116238
|
+
let sorted = {};
|
|
116239
|
+
let keys = Object.keys(obj).sort();
|
|
116240
|
+
for (let key of keys){
|
|
116241
|
+
sorted[key] = obj[key];
|
|
116242
|
+
}
|
|
116243
|
+
return sorted;
|
|
116244
|
+
}
|
|
116245
|
+
function dedupeLinkDescriptors(descriptors, preloads) {
|
|
116246
|
+
let set = /* @__PURE__ */ new Set();
|
|
116247
|
+
new Set(preloads);
|
|
116248
|
+
return descriptors.reduce((deduped, descriptor)=>{
|
|
116249
|
+
let key = JSON.stringify(sortKeys(descriptor));
|
|
116250
|
+
if (!set.has(key)) {
|
|
116251
|
+
set.add(key);
|
|
116252
|
+
deduped.push({
|
|
116253
|
+
key,
|
|
116254
|
+
link: descriptor
|
|
116255
|
+
});
|
|
116256
|
+
}
|
|
116257
|
+
return deduped;
|
|
116258
|
+
}, []);
|
|
116259
|
+
}
|
|
116260
|
+
// lib/dom/ssr/components.tsx
|
|
116261
|
+
function useDataRouterContext2() {
|
|
116262
|
+
let context = React__namespace.useContext(DataRouterContext);
|
|
116263
|
+
invariant2(context, "You must render this element inside a <DataRouterContext.Provider> element");
|
|
116264
|
+
return context;
|
|
116265
|
+
}
|
|
116266
|
+
function useDataRouterStateContext() {
|
|
116267
|
+
let context = React__namespace.useContext(DataRouterStateContext);
|
|
116268
|
+
invariant2(context, "You must render this element inside a <DataRouterStateContext.Provider> element");
|
|
116269
|
+
return context;
|
|
116270
|
+
}
|
|
116271
|
+
var FrameworkContext = React__namespace.createContext(void 0);
|
|
116272
|
+
FrameworkContext.displayName = "FrameworkContext";
|
|
116273
|
+
function useFrameworkContext() {
|
|
116274
|
+
let context = React__namespace.useContext(FrameworkContext);
|
|
116275
|
+
invariant2(context, "You must render this element inside a <HydratedRouter> element");
|
|
116276
|
+
return context;
|
|
116277
|
+
}
|
|
116278
|
+
function usePrefetchBehavior(prefetch, theirElementProps) {
|
|
116279
|
+
let frameworkContext = React__namespace.useContext(FrameworkContext);
|
|
116280
|
+
let [maybePrefetch, setMaybePrefetch] = React__namespace.useState(false);
|
|
116281
|
+
let [shouldPrefetch, setShouldPrefetch] = React__namespace.useState(false);
|
|
116282
|
+
let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
|
|
116283
|
+
let ref = React__namespace.useRef(null);
|
|
116284
|
+
React__namespace.useEffect(()=>{
|
|
116285
|
+
if (prefetch === "render") {
|
|
116286
|
+
setShouldPrefetch(true);
|
|
116287
|
+
}
|
|
116288
|
+
if (prefetch === "viewport") {
|
|
116289
|
+
let callback = (entries)=>{
|
|
116290
|
+
entries.forEach((entry)=>{
|
|
116291
|
+
setShouldPrefetch(entry.isIntersecting);
|
|
116292
|
+
});
|
|
116293
|
+
};
|
|
116294
|
+
let observer = new IntersectionObserver(callback, {
|
|
116295
|
+
threshold: 0.5
|
|
116296
|
+
});
|
|
116297
|
+
if (ref.current) observer.observe(ref.current);
|
|
116298
|
+
return ()=>{
|
|
116299
|
+
observer.disconnect();
|
|
116300
|
+
};
|
|
116301
|
+
}
|
|
116302
|
+
}, [
|
|
116303
|
+
prefetch
|
|
116304
|
+
]);
|
|
116305
|
+
React__namespace.useEffect(()=>{
|
|
116306
|
+
if (maybePrefetch) {
|
|
116307
|
+
let id = setTimeout(()=>{
|
|
116308
|
+
setShouldPrefetch(true);
|
|
116309
|
+
}, 100);
|
|
116310
|
+
return ()=>{
|
|
116311
|
+
clearTimeout(id);
|
|
116312
|
+
};
|
|
116313
|
+
}
|
|
116314
|
+
}, [
|
|
116315
|
+
maybePrefetch
|
|
116316
|
+
]);
|
|
116317
|
+
let setIntent = ()=>{
|
|
116318
|
+
setMaybePrefetch(true);
|
|
116319
|
+
};
|
|
116320
|
+
let cancelIntent = ()=>{
|
|
116321
|
+
setMaybePrefetch(false);
|
|
116322
|
+
setShouldPrefetch(false);
|
|
116323
|
+
};
|
|
116324
|
+
if (!frameworkContext) {
|
|
116325
|
+
return [
|
|
116326
|
+
false,
|
|
116327
|
+
ref,
|
|
116328
|
+
{}
|
|
116329
|
+
];
|
|
116330
|
+
}
|
|
116331
|
+
if (prefetch !== "intent") {
|
|
116332
|
+
return [
|
|
116333
|
+
shouldPrefetch,
|
|
116334
|
+
ref,
|
|
116335
|
+
{}
|
|
116336
|
+
];
|
|
116337
|
+
}
|
|
116338
|
+
return [
|
|
116339
|
+
shouldPrefetch,
|
|
116340
|
+
ref,
|
|
116341
|
+
{
|
|
116342
|
+
onFocus: composeEventHandlers(onFocus, setIntent),
|
|
116343
|
+
onBlur: composeEventHandlers(onBlur, cancelIntent),
|
|
116344
|
+
onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
|
|
116345
|
+
onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
|
|
116346
|
+
onTouchStart: composeEventHandlers(onTouchStart, setIntent)
|
|
116347
|
+
}
|
|
116348
|
+
];
|
|
116349
|
+
}
|
|
116350
|
+
function composeEventHandlers(theirHandler, ourHandler) {
|
|
116351
|
+
return (event)=>{
|
|
116352
|
+
theirHandler && theirHandler(event);
|
|
116353
|
+
if (!event.defaultPrevented) {
|
|
116354
|
+
ourHandler(event);
|
|
116355
|
+
}
|
|
116356
|
+
};
|
|
116357
|
+
}
|
|
116358
|
+
function PrefetchPageLinks({ page, ...linkProps }) {
|
|
116359
|
+
let { router } = useDataRouterContext2();
|
|
116360
|
+
let matches = React__namespace.useMemo(()=>matchRoutes(router.routes, page, router.basename), [
|
|
116361
|
+
router.routes,
|
|
116362
|
+
page,
|
|
116363
|
+
router.basename
|
|
116364
|
+
]);
|
|
116365
|
+
if (!matches) {
|
|
116366
|
+
return null;
|
|
116367
|
+
}
|
|
116368
|
+
return /* @__PURE__ */ React__namespace.createElement(PrefetchPageLinksImpl, {
|
|
116369
|
+
page,
|
|
116370
|
+
matches,
|
|
116371
|
+
...linkProps
|
|
116372
|
+
});
|
|
116373
|
+
}
|
|
116374
|
+
function useKeyedPrefetchLinks(matches) {
|
|
116375
|
+
let { manifest, routeModules } = useFrameworkContext();
|
|
116376
|
+
let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React__namespace.useState([]);
|
|
116377
|
+
React__namespace.useEffect(()=>{
|
|
116378
|
+
let interrupted = false;
|
|
116379
|
+
void getKeyedPrefetchLinks(matches, manifest, routeModules).then((links)=>{
|
|
116380
|
+
if (!interrupted) {
|
|
116381
|
+
setKeyedPrefetchLinks(links);
|
|
116382
|
+
}
|
|
116383
|
+
});
|
|
116384
|
+
return ()=>{
|
|
116385
|
+
interrupted = true;
|
|
116386
|
+
};
|
|
116387
|
+
}, [
|
|
116388
|
+
matches,
|
|
116389
|
+
manifest,
|
|
116390
|
+
routeModules
|
|
116391
|
+
]);
|
|
116392
|
+
return keyedPrefetchLinks;
|
|
116393
|
+
}
|
|
116394
|
+
function PrefetchPageLinksImpl({ page, matches: nextMatches, ...linkProps }) {
|
|
116395
|
+
let location = useLocation();
|
|
116396
|
+
let { future, manifest, routeModules } = useFrameworkContext();
|
|
116397
|
+
let { basename } = useDataRouterContext2();
|
|
116398
|
+
let { loaderData, matches } = useDataRouterStateContext();
|
|
116399
|
+
let newMatchesForData = React__namespace.useMemo(()=>getNewMatchesForLinks(page, nextMatches, matches, manifest, location, "data"), [
|
|
116400
|
+
page,
|
|
116401
|
+
nextMatches,
|
|
116402
|
+
matches,
|
|
116403
|
+
manifest,
|
|
116404
|
+
location
|
|
116405
|
+
]);
|
|
116406
|
+
let newMatchesForAssets = React__namespace.useMemo(()=>getNewMatchesForLinks(page, nextMatches, matches, manifest, location, "assets"), [
|
|
116407
|
+
page,
|
|
116408
|
+
nextMatches,
|
|
116409
|
+
matches,
|
|
116410
|
+
manifest,
|
|
116411
|
+
location
|
|
116412
|
+
]);
|
|
116413
|
+
let dataHrefs = React__namespace.useMemo(()=>{
|
|
116414
|
+
if (page === location.pathname + location.search + location.hash) {
|
|
116415
|
+
return [];
|
|
116416
|
+
}
|
|
116417
|
+
let routesParams = /* @__PURE__ */ new Set();
|
|
116418
|
+
let foundOptOutRoute = false;
|
|
116419
|
+
nextMatches.forEach((m)=>{
|
|
116420
|
+
let manifestRoute = manifest.routes[m.route.id];
|
|
116421
|
+
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
116422
|
+
return;
|
|
116423
|
+
}
|
|
116424
|
+
if (!newMatchesForData.some((m2)=>m2.route.id === m.route.id) && m.route.id in loaderData && routeModules[m.route.id]?.shouldRevalidate) {
|
|
116425
|
+
foundOptOutRoute = true;
|
|
116426
|
+
} else if (manifestRoute.hasClientLoader) {
|
|
116427
|
+
foundOptOutRoute = true;
|
|
116428
|
+
} else {
|
|
116429
|
+
routesParams.add(m.route.id);
|
|
116430
|
+
}
|
|
116431
|
+
});
|
|
116432
|
+
if (routesParams.size === 0) {
|
|
116433
|
+
return [];
|
|
116434
|
+
}
|
|
116435
|
+
let url = singleFetchUrl(page, basename, future.unstable_trailingSlashAwareDataRequests, "data");
|
|
116436
|
+
if (foundOptOutRoute && routesParams.size > 0) {
|
|
116437
|
+
url.searchParams.set("_routes", nextMatches.filter((m)=>routesParams.has(m.route.id)).map((m)=>m.route.id).join(","));
|
|
116438
|
+
}
|
|
116439
|
+
return [
|
|
116440
|
+
url.pathname + url.search
|
|
116441
|
+
];
|
|
116442
|
+
}, [
|
|
116443
|
+
basename,
|
|
116444
|
+
future.unstable_trailingSlashAwareDataRequests,
|
|
116445
|
+
loaderData,
|
|
116446
|
+
location,
|
|
116447
|
+
manifest,
|
|
116448
|
+
newMatchesForData,
|
|
116449
|
+
nextMatches,
|
|
116450
|
+
page,
|
|
116451
|
+
routeModules
|
|
116452
|
+
]);
|
|
116453
|
+
let moduleHrefs = React__namespace.useMemo(()=>getModuleLinkHrefs(newMatchesForAssets, manifest), [
|
|
116454
|
+
newMatchesForAssets,
|
|
116455
|
+
manifest
|
|
116456
|
+
]);
|
|
116457
|
+
let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
|
|
116458
|
+
return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, dataHrefs.map((href)=>/* @__PURE__ */ React__namespace.createElement("link", {
|
|
116459
|
+
key: href,
|
|
116460
|
+
rel: "prefetch",
|
|
116461
|
+
as: "fetch",
|
|
116462
|
+
href,
|
|
116463
|
+
...linkProps
|
|
116464
|
+
})), moduleHrefs.map((href)=>/* @__PURE__ */ React__namespace.createElement("link", {
|
|
116465
|
+
key: href,
|
|
116466
|
+
rel: "modulepreload",
|
|
116467
|
+
href,
|
|
116468
|
+
...linkProps
|
|
116469
|
+
})), keyedPrefetchLinks.map(({ key, link })=>// these don't spread `linkProps` because they are full link descriptors
|
|
116470
|
+
// already with their own props
|
|
116471
|
+
/* @__PURE__ */ React__namespace.createElement("link", {
|
|
116472
|
+
key,
|
|
116473
|
+
nonce: linkProps.nonce,
|
|
116474
|
+
...link,
|
|
116475
|
+
crossOrigin: link.crossOrigin ?? linkProps.crossOrigin
|
|
116476
|
+
})));
|
|
116477
|
+
}
|
|
116478
|
+
function mergeRefs(...refs) {
|
|
116479
|
+
return (value)=>{
|
|
116480
|
+
refs.forEach((ref)=>{
|
|
116481
|
+
if (typeof ref === "function") {
|
|
116482
|
+
ref(value);
|
|
116483
|
+
} else if (ref != null) {
|
|
116484
|
+
ref.current = value;
|
|
116485
|
+
}
|
|
116486
|
+
});
|
|
116487
|
+
};
|
|
116488
|
+
}
|
|
116489
|
+
var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
116490
|
+
try {
|
|
116491
|
+
if (isBrowser2) {
|
|
116492
|
+
window.__reactRouterVersion = "7.13.1";
|
|
116493
|
+
}
|
|
116494
|
+
} catch (e) {}
|
|
116495
|
+
var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
116496
|
+
var Link = React__namespace.forwardRef(function LinkWithRef({ onClick, discover = "render", prefetch = "none", relative, reloadDocument, replace: replace2, unstable_mask, state, target, to, preventScrollReset, viewTransition, unstable_defaultShouldRevalidate, ...rest }, forwardedRef) {
|
|
116497
|
+
let { basename, navigator, unstable_useTransitions } = React__namespace.useContext(NavigationContext);
|
|
116498
|
+
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
|
|
116499
|
+
let parsed = parseToInfo(to, basename);
|
|
116500
|
+
to = parsed.to;
|
|
116501
|
+
let href = useHref(to, {
|
|
116502
|
+
relative
|
|
116503
|
+
});
|
|
116504
|
+
let location = useLocation();
|
|
116505
|
+
let maskedHref = null;
|
|
116506
|
+
if (unstable_mask) {
|
|
116507
|
+
let resolved = resolveTo(unstable_mask, [], location.unstable_mask ? location.unstable_mask.pathname : "/", true);
|
|
116508
|
+
if (basename !== "/") {
|
|
116509
|
+
resolved.pathname = resolved.pathname === "/" ? basename : joinPaths([
|
|
116510
|
+
basename,
|
|
116511
|
+
resolved.pathname
|
|
116512
|
+
]);
|
|
116513
|
+
}
|
|
116514
|
+
maskedHref = navigator.createHref(resolved);
|
|
116515
|
+
}
|
|
116516
|
+
let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(prefetch, rest);
|
|
116517
|
+
let internalOnClick = useLinkClickHandler(to, {
|
|
116518
|
+
replace: replace2,
|
|
116519
|
+
unstable_mask,
|
|
116520
|
+
state,
|
|
116521
|
+
target,
|
|
116522
|
+
preventScrollReset,
|
|
116523
|
+
relative,
|
|
116524
|
+
viewTransition,
|
|
116525
|
+
unstable_defaultShouldRevalidate,
|
|
116526
|
+
unstable_useTransitions
|
|
116527
|
+
});
|
|
116528
|
+
function handleClick(event) {
|
|
116529
|
+
if (onClick) onClick(event);
|
|
116530
|
+
if (!event.defaultPrevented) {
|
|
116531
|
+
internalOnClick(event);
|
|
116532
|
+
}
|
|
116533
|
+
}
|
|
116534
|
+
let isSpaLink = !(parsed.isExternal || reloadDocument);
|
|
116535
|
+
let link = // eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
116536
|
+
/* @__PURE__ */ React__namespace.createElement("a", {
|
|
116537
|
+
...rest,
|
|
116538
|
+
...prefetchHandlers,
|
|
116539
|
+
href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
|
|
116540
|
+
onClick: isSpaLink ? handleClick : onClick,
|
|
116541
|
+
ref: mergeRefs(forwardedRef, prefetchRef),
|
|
116542
|
+
target,
|
|
116543
|
+
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
116544
|
+
});
|
|
116545
|
+
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, link, /* @__PURE__ */ React__namespace.createElement(PrefetchPageLinks, {
|
|
116546
|
+
page: href
|
|
116547
|
+
})) : link;
|
|
116548
|
+
});
|
|
116549
|
+
Link.displayName = "Link";
|
|
116550
|
+
var NavLink = React__namespace.forwardRef(function NavLinkWithRef({ "aria-current": ariaCurrentProp = "page", caseSensitive = false, className: classNameProp = "", end = false, style: styleProp, to, viewTransition, children, ...rest }, ref) {
|
|
116551
|
+
let path = useResolvedPath(to, {
|
|
116552
|
+
relative: rest.relative
|
|
116553
|
+
});
|
|
116554
|
+
let location = useLocation();
|
|
116555
|
+
let routerState = React__namespace.useContext(DataRouterStateContext);
|
|
116556
|
+
let { navigator, basename } = React__namespace.useContext(NavigationContext);
|
|
116557
|
+
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
116558
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
116559
|
+
useViewTransitionState(path) && viewTransition === true;
|
|
116560
|
+
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
|
|
116561
|
+
let locationPathname = location.pathname;
|
|
116562
|
+
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
|
116563
|
+
if (!caseSensitive) {
|
|
116564
|
+
locationPathname = locationPathname.toLowerCase();
|
|
116565
|
+
nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
|
|
116566
|
+
toPathname = toPathname.toLowerCase();
|
|
116567
|
+
}
|
|
116568
|
+
if (nextLocationPathname && basename) {
|
|
116569
|
+
nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
|
|
116570
|
+
}
|
|
116571
|
+
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
|
|
116572
|
+
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
|
|
116573
|
+
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
|
|
116574
|
+
let renderProps = {
|
|
116575
|
+
isActive,
|
|
116576
|
+
isPending,
|
|
116577
|
+
isTransitioning
|
|
116578
|
+
};
|
|
116579
|
+
let ariaCurrent = isActive ? ariaCurrentProp : void 0;
|
|
116580
|
+
let className;
|
|
116581
|
+
if (typeof classNameProp === "function") {
|
|
116582
|
+
className = classNameProp(renderProps);
|
|
116583
|
+
} else {
|
|
116584
|
+
className = [
|
|
116585
|
+
classNameProp,
|
|
116586
|
+
isActive ? "active" : null,
|
|
116587
|
+
isPending ? "pending" : null,
|
|
116588
|
+
isTransitioning ? "transitioning" : null
|
|
116589
|
+
].filter(Boolean).join(" ");
|
|
116590
|
+
}
|
|
116591
|
+
let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
|
|
116592
|
+
return /* @__PURE__ */ React__namespace.createElement(Link, {
|
|
116593
|
+
...rest,
|
|
116594
|
+
"aria-current": ariaCurrent,
|
|
116595
|
+
className,
|
|
116596
|
+
ref,
|
|
116597
|
+
style,
|
|
116598
|
+
to,
|
|
116599
|
+
viewTransition
|
|
116600
|
+
}, typeof children === "function" ? children(renderProps) : children);
|
|
116601
|
+
});
|
|
116602
|
+
NavLink.displayName = "NavLink";
|
|
116603
|
+
var Form = React__namespace.forwardRef(({ discover = "render", fetcherKey, navigate, reloadDocument, replace: replace2, state, method = defaultMethod, action, onSubmit, relative, preventScrollReset, viewTransition, unstable_defaultShouldRevalidate, ...props }, forwardedRef)=>{
|
|
116604
|
+
let { unstable_useTransitions } = React__namespace.useContext(NavigationContext);
|
|
116605
|
+
let submit = useSubmit();
|
|
116606
|
+
let formAction = useFormAction(action, {
|
|
116607
|
+
relative
|
|
116608
|
+
});
|
|
116609
|
+
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
|
116610
|
+
let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
|
|
116611
|
+
let submitHandler = (event)=>{
|
|
116612
|
+
onSubmit && onSubmit(event);
|
|
116613
|
+
if (event.defaultPrevented) return;
|
|
116614
|
+
event.preventDefault();
|
|
116615
|
+
let submitter = event.nativeEvent.submitter;
|
|
116616
|
+
let submitMethod = submitter?.getAttribute("formmethod") || method;
|
|
116617
|
+
let doSubmit = ()=>submit(submitter || event.currentTarget, {
|
|
116618
|
+
fetcherKey,
|
|
116619
|
+
method: submitMethod,
|
|
116620
|
+
navigate,
|
|
116621
|
+
replace: replace2,
|
|
116622
|
+
state,
|
|
116623
|
+
relative,
|
|
116624
|
+
preventScrollReset,
|
|
116625
|
+
viewTransition,
|
|
116626
|
+
unstable_defaultShouldRevalidate
|
|
116627
|
+
});
|
|
116628
|
+
if (unstable_useTransitions && navigate !== false) {
|
|
116629
|
+
React__namespace.startTransition(()=>doSubmit());
|
|
116630
|
+
} else {
|
|
116631
|
+
doSubmit();
|
|
116632
|
+
}
|
|
116633
|
+
};
|
|
116634
|
+
return /* @__PURE__ */ React__namespace.createElement("form", {
|
|
116635
|
+
ref: forwardedRef,
|
|
116636
|
+
method: formMethod,
|
|
116637
|
+
action: formAction,
|
|
116638
|
+
onSubmit: reloadDocument ? onSubmit : submitHandler,
|
|
116639
|
+
...props,
|
|
116640
|
+
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
116641
|
+
});
|
|
116642
|
+
});
|
|
116643
|
+
Form.displayName = "Form";
|
|
116644
|
+
function getDataRouterConsoleError2(hookName) {
|
|
116645
|
+
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
116646
|
+
}
|
|
116647
|
+
function useDataRouterContext3(hookName) {
|
|
116648
|
+
let ctx = React__namespace.useContext(DataRouterContext);
|
|
116649
|
+
invariant(ctx, getDataRouterConsoleError2(hookName));
|
|
116650
|
+
return ctx;
|
|
116651
|
+
}
|
|
116652
|
+
function useLinkClickHandler(to, { target, replace: replaceProp, unstable_mask, state, preventScrollReset, relative, viewTransition, unstable_defaultShouldRevalidate, unstable_useTransitions } = {}) {
|
|
116653
|
+
let navigate = useNavigate();
|
|
116654
|
+
let location = useLocation();
|
|
116655
|
+
let path = useResolvedPath(to, {
|
|
116656
|
+
relative
|
|
116657
|
+
});
|
|
116658
|
+
return React__namespace.useCallback((event)=>{
|
|
116659
|
+
if (shouldProcessLinkClick(event, target)) {
|
|
116660
|
+
event.preventDefault();
|
|
116661
|
+
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
|
|
116662
|
+
let doNavigate = ()=>navigate(to, {
|
|
116663
|
+
replace: replace2,
|
|
116664
|
+
unstable_mask,
|
|
116665
|
+
state,
|
|
116666
|
+
preventScrollReset,
|
|
116667
|
+
relative,
|
|
116668
|
+
viewTransition,
|
|
116669
|
+
unstable_defaultShouldRevalidate
|
|
116670
|
+
});
|
|
116671
|
+
if (unstable_useTransitions) {
|
|
116672
|
+
React__namespace.startTransition(()=>doNavigate());
|
|
116673
|
+
} else {
|
|
116674
|
+
doNavigate();
|
|
116675
|
+
}
|
|
116676
|
+
}
|
|
116677
|
+
}, [
|
|
116678
|
+
location,
|
|
116679
|
+
navigate,
|
|
116680
|
+
path,
|
|
116681
|
+
replaceProp,
|
|
116682
|
+
unstable_mask,
|
|
116683
|
+
state,
|
|
116684
|
+
target,
|
|
116685
|
+
to,
|
|
116686
|
+
preventScrollReset,
|
|
116687
|
+
relative,
|
|
116688
|
+
viewTransition,
|
|
116689
|
+
unstable_defaultShouldRevalidate,
|
|
116690
|
+
unstable_useTransitions
|
|
116691
|
+
]);
|
|
116692
|
+
}
|
|
116693
|
+
function useSearchParams(defaultInit) {
|
|
116694
|
+
warning(typeof URLSearchParams !== "undefined", `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.`);
|
|
116695
|
+
let defaultSearchParamsRef = React__namespace.useRef(createSearchParams(defaultInit));
|
|
116696
|
+
let hasSetSearchParamsRef = React__namespace.useRef(false);
|
|
116697
|
+
let location = useLocation();
|
|
116698
|
+
let searchParams = React__namespace.useMemo(()=>// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
116699
|
+
// Once we call that we want those to take precedence, otherwise you can't
|
|
116700
|
+
// remove a param with setSearchParams({}) if it has an initial value
|
|
116701
|
+
getSearchParamsForLocation(location.search, hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current), [
|
|
116702
|
+
location.search
|
|
116703
|
+
]);
|
|
116704
|
+
let navigate = useNavigate();
|
|
116705
|
+
let setSearchParams = React__namespace.useCallback((nextInit, navigateOptions)=>{
|
|
116706
|
+
const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit);
|
|
116707
|
+
hasSetSearchParamsRef.current = true;
|
|
116708
|
+
navigate("?" + newSearchParams, navigateOptions);
|
|
116709
|
+
}, [
|
|
116710
|
+
navigate,
|
|
116711
|
+
searchParams
|
|
116712
|
+
]);
|
|
116713
|
+
return [
|
|
116714
|
+
searchParams,
|
|
116715
|
+
setSearchParams
|
|
116716
|
+
];
|
|
116717
|
+
}
|
|
116718
|
+
var fetcherId = 0;
|
|
116719
|
+
var getUniqueFetcherId = ()=>`__${String(++fetcherId)}__`;
|
|
116720
|
+
function useSubmit() {
|
|
116721
|
+
let { router } = useDataRouterContext3("useSubmit" /* UseSubmit */ );
|
|
116722
|
+
let { basename } = React__namespace.useContext(NavigationContext);
|
|
116723
|
+
let currentRouteId = useRouteId();
|
|
116724
|
+
let routerFetch = router.fetch;
|
|
116725
|
+
let routerNavigate = router.navigate;
|
|
116726
|
+
return React__namespace.useCallback(async (target, options = {})=>{
|
|
116727
|
+
let { action, method, encType, formData, body } = getFormSubmissionInfo(target, basename);
|
|
116728
|
+
if (options.navigate === false) {
|
|
116729
|
+
let key = options.fetcherKey || getUniqueFetcherId();
|
|
116730
|
+
await routerFetch(key, currentRouteId, options.action || action, {
|
|
116731
|
+
unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
|
|
116732
|
+
preventScrollReset: options.preventScrollReset,
|
|
116733
|
+
formData,
|
|
116734
|
+
body,
|
|
116735
|
+
formMethod: options.method || method,
|
|
116736
|
+
formEncType: options.encType || encType,
|
|
116737
|
+
flushSync: options.flushSync
|
|
116738
|
+
});
|
|
116739
|
+
} else {
|
|
116740
|
+
await routerNavigate(options.action || action, {
|
|
116741
|
+
unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
|
|
116742
|
+
preventScrollReset: options.preventScrollReset,
|
|
116743
|
+
formData,
|
|
116744
|
+
body,
|
|
116745
|
+
formMethod: options.method || method,
|
|
116746
|
+
formEncType: options.encType || encType,
|
|
116747
|
+
replace: options.replace,
|
|
116748
|
+
state: options.state,
|
|
116749
|
+
fromRouteId: currentRouteId,
|
|
116750
|
+
flushSync: options.flushSync,
|
|
116751
|
+
viewTransition: options.viewTransition
|
|
116752
|
+
});
|
|
116753
|
+
}
|
|
116754
|
+
}, [
|
|
116755
|
+
routerFetch,
|
|
116756
|
+
routerNavigate,
|
|
116757
|
+
basename,
|
|
116758
|
+
currentRouteId
|
|
116759
|
+
]);
|
|
116760
|
+
}
|
|
116761
|
+
function useFormAction(action, { relative } = {}) {
|
|
116762
|
+
let { basename } = React__namespace.useContext(NavigationContext);
|
|
116763
|
+
let routeContext = React__namespace.useContext(RouteContext);
|
|
116764
|
+
invariant(routeContext, "useFormAction must be used inside a RouteContext");
|
|
116765
|
+
let [match] = routeContext.matches.slice(-1);
|
|
116766
|
+
let path = {
|
|
116767
|
+
...useResolvedPath(action ? action : ".", {
|
|
116768
|
+
relative
|
|
116769
|
+
})
|
|
116770
|
+
};
|
|
116771
|
+
let location = useLocation();
|
|
116772
|
+
if (action == null) {
|
|
116773
|
+
path.search = location.search;
|
|
116774
|
+
let params = new URLSearchParams(path.search);
|
|
116775
|
+
let indexValues = params.getAll("index");
|
|
116776
|
+
let hasNakedIndexParam = indexValues.some((v)=>v === "");
|
|
116777
|
+
if (hasNakedIndexParam) {
|
|
116778
|
+
params.delete("index");
|
|
116779
|
+
indexValues.filter((v)=>v).forEach((v)=>params.append("index", v));
|
|
116780
|
+
let qs = params.toString();
|
|
116781
|
+
path.search = qs ? `?${qs}` : "";
|
|
116782
|
+
}
|
|
116783
|
+
}
|
|
116784
|
+
if ((!action || action === ".") && match.route.index) {
|
|
116785
|
+
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
|
116786
|
+
}
|
|
116787
|
+
if (basename !== "/") {
|
|
116788
|
+
path.pathname = path.pathname === "/" ? basename : joinPaths([
|
|
116789
|
+
basename,
|
|
116790
|
+
path.pathname
|
|
116791
|
+
]);
|
|
116792
|
+
}
|
|
116793
|
+
return createPath(path);
|
|
116794
|
+
}
|
|
116795
|
+
function useViewTransitionState(to, { relative } = {}) {
|
|
116796
|
+
let vtContext = React__namespace.useContext(ViewTransitionContext);
|
|
116797
|
+
invariant(vtContext != null, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");
|
|
116798
|
+
let { basename } = useDataRouterContext3("useViewTransitionState" /* useViewTransitionState */ );
|
|
116799
|
+
let path = useResolvedPath(to, {
|
|
116800
|
+
relative
|
|
116801
|
+
});
|
|
116802
|
+
if (!vtContext.isTransitioning) {
|
|
116803
|
+
return false;
|
|
116804
|
+
}
|
|
116805
|
+
let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
|
|
116806
|
+
let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
|
|
116807
|
+
return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
|
|
116808
|
+
}
|
|
116809
|
+
|
|
116810
|
+
const EvaluationsMockContext = /*#__PURE__*/ React.createContext(undefined);
|
|
116811
|
+
const useEvaluationsMock = ()=>{
|
|
116812
|
+
return React.useContext(EvaluationsMockContext);
|
|
116813
|
+
};
|
|
116814
|
+
|
|
116815
|
+
const API_BASE = "/api";
|
|
116816
|
+
const useEvaluations = ()=>{
|
|
116817
|
+
const mockContext = useEvaluationsMock();
|
|
116818
|
+
const [evaluations, setEvaluations] = React.useState([]);
|
|
116819
|
+
const [loading, setLoading] = React.useState(false);
|
|
116820
|
+
const [error, setError] = React.useState(null);
|
|
116821
|
+
const fetchEvaluations = React.useCallback(async ()=>{
|
|
116822
|
+
setLoading(true);
|
|
116823
|
+
setError(null);
|
|
116824
|
+
try {
|
|
116825
|
+
// Check for mock data first
|
|
116826
|
+
if (mockContext?.mockEvaluations) {
|
|
116827
|
+
setEvaluations(mockContext.mockEvaluations);
|
|
116828
|
+
setLoading(false);
|
|
116829
|
+
return;
|
|
116830
|
+
}
|
|
116831
|
+
// Otherwise fetch from API (returns raw DTO)
|
|
116832
|
+
const response = await fetch(`${API_BASE}/evaluations`);
|
|
116833
|
+
if (!response.ok) {
|
|
116834
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
116835
|
+
}
|
|
116836
|
+
const data = await response.json();
|
|
116837
|
+
// Handle edge cases: null/undefined or not an array
|
|
116838
|
+
if (!data || !Array.isArray(data)) {
|
|
116839
|
+
setEvaluations([]);
|
|
116840
|
+
return;
|
|
116841
|
+
}
|
|
116842
|
+
setEvaluations(data);
|
|
116843
|
+
} catch (err) {
|
|
116844
|
+
const errorMessage = err instanceof Error ? err.message : "Unknown error occurred";
|
|
116845
|
+
setError(errorMessage);
|
|
116846
|
+
setEvaluations([]);
|
|
116847
|
+
} finally{
|
|
116848
|
+
setLoading(false);
|
|
116849
|
+
}
|
|
116850
|
+
}, [
|
|
116851
|
+
mockContext
|
|
116852
|
+
]);
|
|
116853
|
+
React.useEffect(()=>{
|
|
116854
|
+
fetchEvaluations();
|
|
116855
|
+
}, [
|
|
116856
|
+
fetchEvaluations
|
|
116857
|
+
]);
|
|
116858
|
+
return {
|
|
116859
|
+
evaluations,
|
|
116860
|
+
loading,
|
|
116861
|
+
error,
|
|
116862
|
+
refetch: fetchEvaluations
|
|
116863
|
+
};
|
|
116864
|
+
};
|
|
116865
|
+
|
|
116866
|
+
const EvaluationsComparePage = ({ backHref = "#/evaluations" })=>{
|
|
116867
|
+
const { evaluations, loading, error } = useEvaluations();
|
|
116868
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
116869
|
+
const normalizedEvaluations = React.useMemo(()=>evaluations.map((e)=>isEvaluationDto(e) ? transformEvaluation(e) : e), [
|
|
116870
|
+
evaluations
|
|
116871
|
+
]);
|
|
116872
|
+
// Support compare=id1,id2 (primary) and legacy evaluationId1/evaluationId2, source/target
|
|
116873
|
+
const [evaluationId1, evaluationId2] = React.useMemo(()=>{
|
|
116874
|
+
const compareParam = searchParams.get("compare");
|
|
116875
|
+
if (compareParam) {
|
|
116876
|
+
const [id1, id2] = compareParam.split(",").map((s)=>s.trim()).filter(Boolean);
|
|
116877
|
+
return [
|
|
116878
|
+
id1 ?? null,
|
|
116879
|
+
id2 ?? null
|
|
116880
|
+
];
|
|
116881
|
+
}
|
|
116882
|
+
const id1 = searchParams.get("evaluationId1") ?? searchParams.get("source");
|
|
116883
|
+
const id2 = searchParams.get("evaluationId2") ?? searchParams.get("target");
|
|
116884
|
+
return [
|
|
116885
|
+
id1,
|
|
116886
|
+
id2
|
|
116887
|
+
];
|
|
116888
|
+
}, [
|
|
116889
|
+
searchParams
|
|
116890
|
+
]);
|
|
116891
|
+
const updateCompareParam = React.useCallback((id1, id2)=>{
|
|
116892
|
+
const newParams = new URLSearchParams(searchParams);
|
|
116893
|
+
newParams.delete("evaluationId1");
|
|
116894
|
+
newParams.delete("evaluationId2");
|
|
116895
|
+
newParams.delete("source");
|
|
116896
|
+
newParams.delete("target");
|
|
116897
|
+
if (id1 && id2) {
|
|
116898
|
+
newParams.set("compare", `${id1},${id2}`);
|
|
116899
|
+
} else {
|
|
116900
|
+
newParams.delete("compare");
|
|
116901
|
+
}
|
|
116902
|
+
setSearchParams(newParams, {
|
|
116903
|
+
replace: true
|
|
116904
|
+
});
|
|
116905
|
+
}, [
|
|
116906
|
+
searchParams,
|
|
116907
|
+
setSearchParams
|
|
116908
|
+
]);
|
|
116909
|
+
const handleEvaluationId1Change = (id)=>{
|
|
116910
|
+
updateCompareParam(id, evaluationId2);
|
|
116911
|
+
};
|
|
116912
|
+
const handleEvaluationId2Change = (id)=>{
|
|
116913
|
+
updateCompareParam(evaluationId1, id);
|
|
116914
|
+
};
|
|
116915
|
+
if (error) {
|
|
116916
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
116917
|
+
style: {
|
|
116918
|
+
padding: "24px",
|
|
116919
|
+
textAlign: "center"
|
|
116920
|
+
}
|
|
116921
|
+
}, /*#__PURE__*/ React.createElement("p", {
|
|
116922
|
+
style: {
|
|
116923
|
+
color: "red"
|
|
116924
|
+
}
|
|
116925
|
+
}, "Error loading evaluations: ", error));
|
|
116926
|
+
}
|
|
116927
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
116928
|
+
style: {
|
|
116929
|
+
padding: "24px"
|
|
116930
|
+
}
|
|
116931
|
+
}, /*#__PURE__*/ React.createElement("h1", {
|
|
116932
|
+
style: {
|
|
116933
|
+
margin: "0 0 24px 0",
|
|
116934
|
+
fontSize: "24px",
|
|
116935
|
+
fontWeight: 600
|
|
116936
|
+
}
|
|
116937
|
+
}, "Compare Evaluations"), /*#__PURE__*/ React.createElement(EvaluationsCompareView, {
|
|
116938
|
+
evaluations: normalizedEvaluations,
|
|
116939
|
+
evaluationId1: evaluationId1,
|
|
116940
|
+
evaluationId2: evaluationId2,
|
|
116941
|
+
onEvaluationId1Change: handleEvaluationId1Change,
|
|
116942
|
+
onEvaluationId2Change: handleEvaluationId2Change,
|
|
116943
|
+
loading: loading,
|
|
116944
|
+
showEvaluationComparisonDropdowns: true,
|
|
116945
|
+
backHref: backHref
|
|
116946
|
+
}));
|
|
116947
|
+
};
|
|
116948
|
+
|
|
114410
116949
|
function isLLMNode(n) {
|
|
114411
116950
|
return isLLMResult(n);
|
|
114412
116951
|
}
|
|
@@ -114503,7 +117042,7 @@ function isLLMAggregateNode(n) {
|
|
|
114503
117042
|
const primaryMetric = sortedMetrics[0];
|
|
114504
117043
|
nodeChildren.push({
|
|
114505
117044
|
key: `${callKey}-${nodeId}`,
|
|
114506
|
-
name:
|
|
117045
|
+
name: nodeId,
|
|
114507
117046
|
level: 3,
|
|
114508
117047
|
metrics,
|
|
114509
117048
|
value: metrics[primaryMetric],
|
|
@@ -114637,11 +117176,19 @@ function buildTreeFromProcessedData(latencyByTool, failureRateByTool, usageCount
|
|
|
114637
117176
|
}
|
|
114638
117177
|
const children = [];
|
|
114639
117178
|
for (const [aid, group] of agentGroups){
|
|
114640
|
-
|
|
114641
|
-
const
|
|
117179
|
+
// Deduplicate by tool_node_id (or key) so each tool invocation appears once
|
|
117180
|
+
const seenIds = new Set();
|
|
117181
|
+
const uniqueLatencies = group.latencies.filter((l)=>{
|
|
117182
|
+
const id = l.toolNodeId ?? l.key;
|
|
117183
|
+
if (seenIds.has(id)) return false;
|
|
117184
|
+
seenIds.add(id);
|
|
117185
|
+
return true;
|
|
117186
|
+
});
|
|
117187
|
+
const totalRuntimeMs = uniqueLatencies.reduce((s, l)=>s + l.value * 1000, 0);
|
|
117188
|
+
const cnt = uniqueLatencies.length;
|
|
114642
117189
|
let failed = 0;
|
|
114643
117190
|
const failList = failureByToolAgentIndex.get(`${toolName}|${aid}`) ?? [];
|
|
114644
|
-
const leaves =
|
|
117191
|
+
const leaves = uniqueLatencies.map((l, idx)=>{
|
|
114645
117192
|
const failVal = failureByKey.get(l.key);
|
|
114646
117193
|
const failValByIndex = failList[idx];
|
|
114647
117194
|
const resolvedFail = failVal ?? (failValByIndex !== undefined ? failValByIndex : undefined);
|
|
@@ -114910,6 +117457,42 @@ const AggregateResultsTable = ({ rawResults = [], aggregateResults, agents, titl
|
|
|
114910
117457
|
}
|
|
114911
117458
|
];
|
|
114912
117459
|
const headerIconColor = theme.colors.foreground;
|
|
117460
|
+
const LLM_LABEL_BY_LEVEL = {
|
|
117461
|
+
1: "Agent",
|
|
117462
|
+
2: "LLM Call",
|
|
117463
|
+
3: "Agent Node"
|
|
117464
|
+
};
|
|
117465
|
+
const LLMTagForLevel = ({ level })=>{
|
|
117466
|
+
const label = LLM_LABEL_BY_LEVEL[level];
|
|
117467
|
+
const Icon = level === 3 ? Bot : Cpu;
|
|
117468
|
+
const tagStyle = level === 1 ? {
|
|
117469
|
+
background: theme.colors.tagToolLevel1?.bg ?? theme.colors.success,
|
|
117470
|
+
color: theme.colors.tagToolLevel1?.color ?? theme.colors.successForeground,
|
|
117471
|
+
border: "none"
|
|
117472
|
+
} : level === 2 ? {
|
|
117473
|
+
background: theme.colors.tagLlminference?.bg ?? theme.colors.muted,
|
|
117474
|
+
color: theme.colors.tagLlminference?.color ?? theme.colors.foreground,
|
|
117475
|
+
border: "none"
|
|
117476
|
+
} : {
|
|
117477
|
+
background: theme.colors.tagToolLevel2?.bg ?? theme.colors.primary,
|
|
117478
|
+
color: theme.colors.tagToolLevel2?.color ?? theme.colors.primaryForeground,
|
|
117479
|
+
border: "none"
|
|
117480
|
+
};
|
|
117481
|
+
return /*#__PURE__*/ React.createElement(Tag, {
|
|
117482
|
+
style: {
|
|
117483
|
+
marginRight: 8,
|
|
117484
|
+
display: "inline-flex",
|
|
117485
|
+
alignItems: "center",
|
|
117486
|
+
gap: 6,
|
|
117487
|
+
...tagStyle
|
|
117488
|
+
}
|
|
117489
|
+
}, /*#__PURE__*/ React.createElement(Icon, {
|
|
117490
|
+
size: 12,
|
|
117491
|
+
style: {
|
|
117492
|
+
flexShrink: 0
|
|
117493
|
+
}
|
|
117494
|
+
}), label);
|
|
117495
|
+
};
|
|
114913
117496
|
const llmColumns = [
|
|
114914
117497
|
{
|
|
114915
117498
|
title: /*#__PURE__*/ React.createElement("span", {
|
|
@@ -114928,16 +117511,14 @@ const AggregateResultsTable = ({ rawResults = [], aggregateResults, agents, titl
|
|
|
114928
117511
|
key: "name",
|
|
114929
117512
|
render: (name, row)=>/*#__PURE__*/ React.createElement("span", {
|
|
114930
117513
|
style: {
|
|
117514
|
+
display: "inline-flex",
|
|
117515
|
+
alignItems: "center",
|
|
117516
|
+
gap: 8,
|
|
114931
117517
|
fontFamily: "monospace",
|
|
114932
117518
|
fontSize: 13
|
|
114933
117519
|
}
|
|
114934
|
-
}, /*#__PURE__*/ React.createElement(
|
|
114935
|
-
|
|
114936
|
-
style: {
|
|
114937
|
-
marginRight: 8,
|
|
114938
|
-
verticalAlign: "middle",
|
|
114939
|
-
color: agentIconColor
|
|
114940
|
-
}
|
|
117520
|
+
}, /*#__PURE__*/ React.createElement(LLMTagForLevel, {
|
|
117521
|
+
level: row.level
|
|
114941
117522
|
}), name)
|
|
114942
117523
|
},
|
|
114943
117524
|
...METRIC_COLUMNS.map(({ key, title, Icon })=>({
|
|
@@ -117527,6 +120108,15 @@ const GlobalStyles = ()=>{
|
|
|
117527
120108
|
border-bottom-right-radius: 0.5rem !important;
|
|
117528
120109
|
}
|
|
117529
120110
|
|
|
120111
|
+
/* Evaluations compare: highlight rows with differing values */
|
|
120112
|
+
.ant-table-tbody > tr.evaluations-compare-diff-row > td {
|
|
120113
|
+
background-color: #fef9c3 !important;
|
|
120114
|
+
}
|
|
120115
|
+
|
|
120116
|
+
html.dark .ant-table-tbody > tr.evaluations-compare-diff-row > td {
|
|
120117
|
+
background-color: #334155 !important;
|
|
120118
|
+
}
|
|
120119
|
+
|
|
117530
120120
|
/* CSS Variables for backward compatibility */
|
|
117531
120121
|
:root {
|
|
117532
120122
|
--background: #ffffff;
|
|
@@ -117721,7 +120311,9 @@ exports.Badge = Badge;
|
|
|
117721
120311
|
exports.Drawer = Drawer;
|
|
117722
120312
|
exports.Edge = Edge;
|
|
117723
120313
|
exports.EvaluationDetailsDrawer = EvaluationDetailsDrawer;
|
|
117724
|
-
exports.
|
|
120314
|
+
exports.EvaluationsCompareDrawer = EvaluationsCompareDrawer;
|
|
120315
|
+
exports.EvaluationsComparePage = EvaluationsComparePage;
|
|
120316
|
+
exports.EvaluationsCompareView = EvaluationsCompareView;
|
|
117725
120317
|
exports.EvaluationsTable = EvaluationsTable;
|
|
117726
120318
|
exports.EvaluatorResult = EvaluatorResult;
|
|
117727
120319
|
exports.GlobalStyles = GlobalStyles;
|
|
@@ -117743,13 +120335,14 @@ exports.createSafeTheme = createSafeTheme;
|
|
|
117743
120335
|
exports.darkTheme = darkTheme;
|
|
117744
120336
|
exports.defaultTheme = defaultTheme$1;
|
|
117745
120337
|
exports.detectContentType = detectContentType;
|
|
120338
|
+
exports.evaluationsHaveSameMetrics = evaluationsHaveSameMetrics;
|
|
117746
120339
|
exports.formatCurrency = formatCurrency;
|
|
117747
120340
|
exports.formatDateFriendly = formatDateFriendly;
|
|
117748
120341
|
exports.formatDateRelative = formatDateRelative;
|
|
117749
120342
|
exports.formatDateShort = formatDateShort;
|
|
117750
120343
|
exports.formatDuration = formatDuration;
|
|
117751
120344
|
exports.formatLatency = formatLatency;
|
|
117752
|
-
exports.formatMetricValue = formatMetricValue;
|
|
120345
|
+
exports.formatMetricValue = formatMetricValue$1;
|
|
117753
120346
|
exports.formatNumberWithCommas = formatNumberWithCommas;
|
|
117754
120347
|
exports.formatToolCalls = formatToolCalls;
|
|
117755
120348
|
exports.getColor = getColor;
|