@genispace/geniapp 0.1.0
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/LICENSE +21 -0
- package/README.md +153 -0
- package/dist/CrossAppRecordPicker-BXchXcK5.js +624 -0
- package/dist/CrossAppRecordPicker-BXchXcK5.js.map +1 -0
- package/dist/Page-wHZrMN17.js +24 -0
- package/dist/Page-wHZrMN17.js.map +1 -0
- package/dist/ai/adopt/AiSuggestionPanel.d.ts +30 -0
- package/dist/ai/adopt/BusinessGuidancePanel.d.ts +31 -0
- package/dist/ai/adopt/DetailPageAiLayout.d.ts +7 -0
- package/dist/ai/adopt/adoptPresets.d.ts +11 -0
- package/dist/ai/adopt/guidanceContent.d.ts +27 -0
- package/dist/ai/adopt/parseAiSummary.d.ts +7 -0
- package/dist/ai/components/AgentJobProgress.d.ts +124 -0
- package/dist/ai/components/AsyncCombobox.d.ts +44 -0
- package/dist/ai/components/BulkActionBar.d.ts +44 -0
- package/dist/ai/components/EntityRef.d.ts +39 -0
- package/dist/ai/components/JobProgress.d.ts +64 -0
- package/dist/ai/components/ServerDataTable.d.ts +89 -0
- package/dist/ai/components/Timeline.d.ts +35 -0
- package/dist/ai/components/useInfiniteRows.d.ts +25 -0
- package/dist/ai/errors/userFacingError.d.ts +14 -0
- package/dist/ai/errors/userFacingError.js +48 -0
- package/dist/ai/errors/userFacingError.js.map +1 -0
- package/dist/ai/index.d.ts +34 -0
- package/dist/ai/integrations/partner/createPartnerRecordPickerHook.d.ts +15 -0
- package/dist/ai/integrations/partner/partnerRecordPicker.d.ts +20 -0
- package/dist/ai/layout/ModalWithAiLayout.d.ts +11 -0
- package/dist/ai/layout/aiUi.d.ts +16 -0
- package/dist/ai/layout/layoutConstants.d.ts +19 -0
- package/dist/ai/layout/modalSizeForAi.d.ts +5 -0
- package/dist/ai/locales/sharedAiCopy.d.ts +6 -0
- package/dist/ai/managed-data/DatasourceReadonlyTable.d.ts +11 -0
- package/dist/ai/managed-data/createTableClient.d.ts +7 -0
- package/dist/ai/managed-data/emitManagedEvent.d.ts +18 -0
- package/dist/ai/managed-data/executeManagedDatasource.d.ts +21 -0
- package/dist/ai/managed-data/queryManagedDatasource.d.ts +28 -0
- package/dist/ai/providers/AppUiProviders.d.ts +6 -0
- package/dist/ai/types/app-ai.types.d.ts +29 -0
- package/dist/ai/types/index.d.ts +1 -0
- package/dist/ai.d.ts +1 -0
- package/dist/ai.js +1817 -0
- package/dist/ai.js.map +1 -0
- package/dist/case-workspace/domain.d.ts +41 -0
- package/dist/case-workspace/domain.js +24 -0
- package/dist/case-workspace/domain.js.map +1 -0
- package/dist/case-workspace/index.d.ts +91 -0
- package/dist/case-workspace.d.ts +1 -0
- package/dist/case-workspace.js +392 -0
- package/dist/case-workspace.js.map +1 -0
- package/dist/cn-B6yFEsav.js +9 -0
- package/dist/cn-B6yFEsav.js.map +1 -0
- package/dist/components/ui/calendar.css +7 -0
- package/dist/cookieSettings-D_v3KS02.js +97 -0
- package/dist/cookieSettings-D_v3KS02.js.map +1 -0
- package/dist/dashboard/index.d.ts +16 -0
- package/dist/dashboard/src/ChartFrame.d.ts +18 -0
- package/dist/dashboard/src/ChartTooltip.d.ts +38 -0
- package/dist/dashboard/src/FilterBar.d.ts +23 -0
- package/dist/dashboard/src/KpiStatCard.d.ts +29 -0
- package/dist/dashboard/src/StatGrid.d.ts +15 -0
- package/dist/dashboard/src/TimeRangePicker.d.ts +14 -0
- package/dist/dashboard/src/chart.d.ts +10 -0
- package/dist/dashboard/src/format.d.ts +16 -0
- package/dist/dashboard/src/links.d.ts +2 -0
- package/dist/dashboard/src/useDashboardRange.d.ts +27 -0
- package/dist/dashboard.d.ts +1 -0
- package/dist/dashboard.js +361 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/fonts.css +15 -0
- package/dist/hooks/access/AppAccessGate.d.ts +20 -0
- package/dist/hooks/access/AppAccessNotice.d.ts +8 -0
- package/dist/hooks/access/useAppAccess.d.ts +26 -0
- package/dist/hooks/config/businessLocale.d.ts +12 -0
- package/dist/hooks/config/currencies.d.ts +9 -0
- package/dist/hooks/index.d.ts +17 -0
- package/dist/hooks/picker/CrossAppRecordPicker.d.ts +37 -0
- package/dist/hooks/picker/managedAppPicker.d.ts +21 -0
- package/dist/hooks/picker/partnerPayload.d.ts +6 -0
- package/dist/hooks/routing/draftEntityId.d.ts +5 -0
- package/dist/hooks/routing/useRefetchOnRouteMatch.d.ts +6 -0
- package/dist/hooks/shell/resolveApiRoot.d.ts +13 -0
- package/dist/hooks/shell/shell.d.ts +4 -0
- package/dist/hooks/shell/useGenispacePlatformClient.d.ts +7 -0
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.js +42 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/kit.d.ts +50 -0
- package/dist/kit.js +2067 -0
- package/dist/kit.js.map +1 -0
- package/dist/page.d.ts +1 -0
- package/dist/page.js +5 -0
- package/dist/page.js.map +1 -0
- package/dist/shell-DIHnXIUb.js +6 -0
- package/dist/shell-DIHnXIUb.js.map +1 -0
- package/dist/shell.d.ts +30 -0
- package/dist/shell.js +104 -0
- package/dist/shell.js.map +1 -0
- package/dist/storage/assetPreview.d.ts +12 -0
- package/dist/storage/components/AssetThumbnail.d.ts +15 -0
- package/dist/storage/components/CopyStorageLinkButton.d.ts +13 -0
- package/dist/storage/components/StorageImage.d.ts +9 -0
- package/dist/storage/components/StoragePreviewContent.d.ts +22 -0
- package/dist/storage/components/StorageVideo.d.ts +9 -0
- package/dist/storage/copyTextToClipboard.d.ts +5 -0
- package/dist/storage/hooks/useAuthenticatedStorageBlobs.d.ts +3 -0
- package/dist/storage/hooks/useImageThumbnailBlobs.d.ts +4 -0
- package/dist/storage/hooks/useShareableStorageLink.d.ts +7 -0
- package/dist/storage/index.d.ts +12 -0
- package/dist/storage/openUrlInNewTab.d.ts +6 -0
- package/dist/storage/platformStorage.d.ts +43 -0
- package/dist/storage.d.ts +1 -0
- package/dist/storage.js +605 -0
- package/dist/storage.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/styles/base.css +616 -0
- package/dist/styles/reduced-motion.css +14 -0
- package/dist/styles/tailwind-preset.js +269 -0
- package/dist/task-workspace/domain.d.ts +35 -0
- package/dist/task-workspace/domain.js +45 -0
- package/dist/task-workspace/domain.js.map +1 -0
- package/dist/task-workspace/experience.d.ts +50 -0
- package/dist/task-workspace/index.d.ts +172 -0
- package/dist/task-workspace.d.ts +1 -0
- package/dist/task-workspace.js +626 -0
- package/dist/task-workspace.js.map +1 -0
- package/dist/ui/components/features/app/AppCheckboxInput.d.ts +9 -0
- package/dist/ui/components/features/app/AppConfirmDialog.d.ts +12 -0
- package/dist/ui/components/features/app/AppDashboardSkeleton.d.ts +9 -0
- package/dist/ui/components/features/app/AppDatePicker.d.ts +69 -0
- package/dist/ui/components/features/app/AppModal.d.ts +27 -0
- package/dist/ui/components/features/app/AppPageStates.d.ts +17 -0
- package/dist/ui/components/features/app/AppSelectInput.d.ts +10 -0
- package/dist/ui/components/features/app/AppTemporalInput.d.ts +19 -0
- package/dist/ui/components/features/app/Page.d.ts +14 -0
- package/dist/ui/components/features/app/QueryErrorAlert.d.ts +7 -0
- package/dist/ui/components/features/app/Sidebar.d.ts +47 -0
- package/dist/ui/components/features/app/index.d.ts +17 -0
- package/dist/ui/components/features/user/UserAvatar.d.ts +17 -0
- package/dist/ui/components/features/user/UserDisplay.d.ts +10 -0
- package/dist/ui/components/features/user/UserSelect.d.ts +14 -0
- package/dist/ui/components/features/user/useUserDirectory.d.ts +13 -0
- package/dist/ui/components/features/user/userDirectoryTypes.d.ts +18 -0
- package/dist/ui/components/patterns/form-section.d.ts +11 -0
- package/dist/ui/components/primitives/feedback/index.d.ts +2 -0
- package/dist/ui/components/primitives/feedback/toaster.d.ts +1 -0
- package/dist/ui/components/primitives/feedback/use-toast.d.ts +46 -0
- package/dist/ui/components/primitives/page-skeleton/ChartAreaSkeleton.d.ts +13 -0
- package/dist/ui/components/primitives/page-skeleton/ChartEmptyState.d.ts +14 -0
- package/dist/ui/components/primitives/page-skeleton/ComponentSkeletonShell.d.ts +16 -0
- package/dist/ui/components/primitives/page-skeleton/ConfigEditorSkeleton.d.ts +5 -0
- package/dist/ui/components/primitives/page-skeleton/DetailTabsSkeleton.d.ts +6 -0
- package/dist/ui/components/primitives/page-skeleton/EmptyStateBadge.d.ts +13 -0
- package/dist/ui/components/primitives/page-skeleton/FormCardSkeleton.d.ts +7 -0
- package/dist/ui/components/primitives/page-skeleton/FormFieldSkeleton.d.ts +6 -0
- package/dist/ui/components/primitives/page-skeleton/FormPageSkeleton.d.ts +6 -0
- package/dist/ui/components/primitives/page-skeleton/GridCardsSkeleton.d.ts +6 -0
- package/dist/ui/components/primitives/page-skeleton/ListSkeleton.d.ts +26 -0
- package/dist/ui/components/primitives/page-skeleton/PageHeaderSkeleton.d.ts +6 -0
- package/dist/ui/components/primitives/page-skeleton/SplitPaneSkeleton.d.ts +4 -0
- package/dist/ui/components/primitives/page-skeleton/StatsRowSkeleton.d.ts +5 -0
- package/dist/ui/components/primitives/page-skeleton/TableEmptyState.d.ts +27 -0
- package/dist/ui/components/primitives/page-skeleton/TablePageSkeleton.d.ts +8 -0
- package/dist/ui/components/primitives/page-skeleton/TabsBarSkeleton.d.ts +6 -0
- package/dist/ui/components/primitives/page-skeleton/index.d.ts +24 -0
- package/dist/ui/components/primitives/page-skeleton/skeletonMetrics.d.ts +9 -0
- package/dist/ui/components/primitives/page-skeleton/useVisibleCenter.d.ts +34 -0
- package/dist/ui/components/ui/accordion.d.ts +7 -0
- package/dist/ui/components/ui/ai-draft-banner.d.ts +21 -0
- package/dist/ui/components/ui/alert-dialog.d.ts +48 -0
- package/dist/ui/components/ui/alert.d.ts +8 -0
- package/dist/ui/components/ui/avatar.d.ts +6 -0
- package/dist/ui/components/ui/badge.d.ts +9 -0
- package/dist/ui/components/ui/breadcrumb.d.ts +19 -0
- package/dist/ui/components/ui/button.d.ts +11 -0
- package/dist/ui/components/ui/calendar.d.ts +8 -0
- package/dist/ui/components/ui/card.d.ts +8 -0
- package/dist/ui/components/ui/chart.d.ts +16 -0
- package/dist/ui/components/ui/checkbox.d.ts +4 -0
- package/dist/ui/components/ui/collapsible.d.ts +5 -0
- package/dist/ui/components/ui/column-config.d.ts +42 -0
- package/dist/ui/components/ui/date-picker.d.ts +9 -0
- package/dist/ui/components/ui/date-range-filter.d.ts +32 -0
- package/dist/ui/components/ui/date-range-picker.d.ts +11 -0
- package/dist/ui/components/ui/dialog-input.d.ts +17 -0
- package/dist/ui/components/ui/dialog-safe-select.d.ts +13 -0
- package/dist/ui/components/ui/dialog.d.ts +25 -0
- package/dist/ui/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/ui/components/ui/feature-guide.d.ts +43 -0
- package/dist/ui/components/ui/form.d.ts +25 -0
- package/dist/ui/components/ui/help-tip.d.ts +29 -0
- package/dist/ui/components/ui/hint-notice.d.ts +22 -0
- package/dist/ui/components/ui/index.d.ts +6 -0
- package/dist/ui/components/ui/input.d.ts +3 -0
- package/dist/ui/components/ui/label.d.ts +5 -0
- package/dist/ui/components/ui/modal-container.d.ts +56 -0
- package/dist/ui/components/ui/modal-templates.d.ts +46 -0
- package/dist/ui/components/ui/multi-select.d.ts +20 -0
- package/dist/ui/components/ui/pagination.d.ts +28 -0
- package/dist/ui/components/ui/popover.d.ts +7 -0
- package/dist/ui/components/ui/progress.d.ts +7 -0
- package/dist/ui/components/ui/radio-button-group.d.ts +18 -0
- package/dist/ui/components/ui/radio-group.d.ts +5 -0
- package/dist/ui/components/ui/scroll-area.d.ts +5 -0
- package/dist/ui/components/ui/select.d.ts +16 -0
- package/dist/ui/components/ui/separator.d.ts +7 -0
- package/dist/ui/components/ui/sheet.d.ts +25 -0
- package/dist/ui/components/ui/sidebar-rail.d.ts +9 -0
- package/dist/ui/components/ui/skeleton.d.ts +2 -0
- package/dist/ui/components/ui/slider.d.ts +13 -0
- package/dist/ui/components/ui/switch.d.ts +4 -0
- package/dist/ui/components/ui/table.d.ts +10 -0
- package/dist/ui/components/ui/tabs.d.ts +10 -0
- package/dist/ui/components/ui/textarea.d.ts +3 -0
- package/dist/ui/components/ui/toast.d.ts +21 -0
- package/dist/ui/components/ui/toggle-group.d.ts +12 -0
- package/dist/ui/components/ui/toggle.d.ts +12 -0
- package/dist/ui/components/ui/tooltip.d.ts +7 -0
- package/dist/ui/components/ui/typography.d.ts +15 -0
- package/dist/ui/components/ui/underline-tabs.d.ts +13 -0
- package/dist/ui/components/ui/view-mode-toggle.d.ts +9 -0
- package/dist/ui/hooks/useIsMobile.d.ts +16 -0
- package/dist/ui/styles/design-tokens.d.ts +189 -0
- package/dist/ui/styles/z-index-layers.d.ts +46 -0
- package/dist/ui.d.ts +2 -0
- package/dist/ui.js +35 -0
- package/dist/ui.js.map +1 -0
- package/dist/useUserDirectory-CqkyCQoR.js +2377 -0
- package/dist/useUserDirectory-CqkyCQoR.js.map +1 -0
- package/dist/utils/cookieSettings.d.ts +12 -0
- package/dist/utils/data/countryCodes.d.ts +26 -0
- package/dist/utils/index.d.ts +18 -0
- package/dist/utils/utils/appPath.d.ts +5 -0
- package/dist/utils/utils/chunkLoadRecovery.d.ts +7 -0
- package/dist/utils/utils/cn.d.ts +3 -0
- package/dist/utils/utils/crossApp.d.ts +71 -0
- package/dist/utils/utils/debounce.d.ts +1 -0
- package/dist/utils/utils/formatUserLabel.d.ts +8 -0
- package/dist/utils/utils/formatting.d.ts +18 -0
- package/dist/utils/utils/logoutNotification.d.ts +28 -0
- package/dist/utils/utils/operatorLocale.d.ts +32 -0
- package/dist/utils/utils/routeLocalePrefetch.d.ts +5 -0
- package/dist/utils/utils/shellIframeUrl.d.ts +20 -0
- package/dist/utils/utils/spaceSettings.d.ts +20 -0
- package/dist/utils/utils/sso.d.ts +42 -0
- package/dist/utils/utils/throttle.d.ts +1 -0
- package/dist/utils/utils/timezones.d.ts +14 -0
- package/dist/utils/utils/toDateInputValue.d.ts +5 -0
- package/dist/utils/utils/watermark.d.ts +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1334 -0
- package/dist/utils.js.map +1 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +74 -0
- package/dist/vite.js.map +1 -0
- package/package.json +191 -0
package/dist/ai.js
ADDED
|
@@ -0,0 +1,1817 @@
|
|
|
1
|
+
import { jsxs as d, jsx as s, Fragment as Ie } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useRef as D, useCallback as L, useEffect as Y, useMemo as be } from "react";
|
|
3
|
+
import { Loader2 as xe, Check as $e, Circle as Qe, Lightbulb as Le, RefreshCw as Ze, AlertCircle as et, CheckCircle2 as tt } from "lucide-react";
|
|
4
|
+
import { Card as oe, CardHeader as le, CardTitle as ce, CardDescription as de, CardContent as ue, Table as Oe, TableHeader as je, TableRow as me, TableHead as Ne, TableBody as ze, TableCell as we, useIsMobile as rt, Button as H, Checkbox as se, Popover as nt, PopoverTrigger as st, PopoverContent as at, Input as it, ScrollArea as ot, Progress as lt, TooltipProvider as ct, Toaster as dt, Skeleton as fe, AlertDialog as ut, Badge as Ge, toast as Ce } from "@genispace/geniapp/kit";
|
|
5
|
+
import { useTranslation as Se } from "react-i18next";
|
|
6
|
+
import { cn as Be } from "@genispace/geniapp/utils";
|
|
7
|
+
import { GeniSpace as mt } from "genispace";
|
|
8
|
+
import { UserFacingError as Br, classifyUserFacingError as Vr, diagnosticErrorText as Ur, toUserFacingError as qr } from "./ai/errors/userFacingError.js";
|
|
9
|
+
import { createUseManagedAppPicker as ft } from "@genispace/geniapp/hooks";
|
|
10
|
+
function ar(e) {
|
|
11
|
+
return {
|
|
12
|
+
async list(t, r) {
|
|
13
|
+
const n = {
|
|
14
|
+
...r?.filters ?? {}
|
|
15
|
+
};
|
|
16
|
+
return r?.limit != null && (n.limit = r.limit), r?.offset != null && (n.offset = r.offset), { items: await e.list(t, n) };
|
|
17
|
+
},
|
|
18
|
+
update: e.update
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function pt(e) {
|
|
22
|
+
return e === !0 || e === "true";
|
|
23
|
+
}
|
|
24
|
+
const he = 100, ht = 50;
|
|
25
|
+
function Pe(e, t, r) {
|
|
26
|
+
const n = e.metadata;
|
|
27
|
+
return String(e.identifier || "") === t && pt(n?.managedByGeniapp) && String(n?.geniappIdentifier || "") === r;
|
|
28
|
+
}
|
|
29
|
+
async function _e(e, t, r) {
|
|
30
|
+
try {
|
|
31
|
+
const { items: n } = await e.dataSources.listDataSources({ search: t, limit: he }), a = n.find((o) => Pe(o, t, r));
|
|
32
|
+
if (a?.id != null) return String(a.id);
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
for (let n = 1; n <= ht; n += 1) {
|
|
36
|
+
const { items: a } = await e.dataSources.listDataSources({ page: n, limit: he }), o = a.find((l) => Pe(l, t, r));
|
|
37
|
+
if (o?.id != null) return String(o.id);
|
|
38
|
+
if (a.length < he) break;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function ke(e, t) {
|
|
43
|
+
const r = e.replace(/\/$/, ""), n = new mt({ baseURL: r, apiKey: t || "" });
|
|
44
|
+
return t && n.updateAccessToken(t), n;
|
|
45
|
+
}
|
|
46
|
+
function Te(e) {
|
|
47
|
+
if (typeof e == "boolean" || e === void 0) return null;
|
|
48
|
+
const t = typeof e == "number" ? e : Number(String(e).trim());
|
|
49
|
+
return Number.isInteger(t) && t >= 0 ? t : null;
|
|
50
|
+
}
|
|
51
|
+
function Ee(e) {
|
|
52
|
+
return (e.data || []).filter((t) => t != null && typeof t == "object");
|
|
53
|
+
}
|
|
54
|
+
const gt = 20;
|
|
55
|
+
async function yt(e, t, r) {
|
|
56
|
+
const { offset: n, ...a } = r, o = Te(n);
|
|
57
|
+
if (!o)
|
|
58
|
+
return Ee(await e.dataSources.queryDataSourceRead(t, r));
|
|
59
|
+
const l = Te(r.limit), i = l && l > 0 ? l : gt, u = async (p) => {
|
|
60
|
+
const f = p * i, v = await e.dataSources.queryDataSourceRead(t, {
|
|
61
|
+
...a,
|
|
62
|
+
page: p + 1,
|
|
63
|
+
limit: i,
|
|
64
|
+
offset: f
|
|
65
|
+
});
|
|
66
|
+
return Ee(v);
|
|
67
|
+
};
|
|
68
|
+
if (o % i === 0)
|
|
69
|
+
return u(o / i);
|
|
70
|
+
const m = Math.floor(o / i), w = o - m * i, g = (await u(m)).slice(w);
|
|
71
|
+
if (g.length + w < i) return g;
|
|
72
|
+
const y = await u(m + 1);
|
|
73
|
+
return g.concat(y.slice(0, i - g.length));
|
|
74
|
+
}
|
|
75
|
+
async function Ve(e, t, r, n, a = { limit: 50 }) {
|
|
76
|
+
if (!e || !t) return [];
|
|
77
|
+
const o = ke(e, t), l = await _e(o, n, r);
|
|
78
|
+
return l ? yt(o, l, a) : [];
|
|
79
|
+
}
|
|
80
|
+
const ge = 1e3;
|
|
81
|
+
async function ir(e, t, r, n, a = {}) {
|
|
82
|
+
const o = [];
|
|
83
|
+
let l = 0;
|
|
84
|
+
for (; ; ) {
|
|
85
|
+
const i = await Ve(e, t, r, n, {
|
|
86
|
+
...a,
|
|
87
|
+
limit: ge,
|
|
88
|
+
offset: l
|
|
89
|
+
});
|
|
90
|
+
if (o.push(...i), i.length < ge) break;
|
|
91
|
+
l += ge;
|
|
92
|
+
}
|
|
93
|
+
return o;
|
|
94
|
+
}
|
|
95
|
+
async function bt(e, t, r, n, a) {
|
|
96
|
+
if (!e?.trim())
|
|
97
|
+
throw new Error("API root is not configured.");
|
|
98
|
+
if (!t?.trim())
|
|
99
|
+
throw new Error("Authentication required to execute datasource operation.");
|
|
100
|
+
const o = ke(e, t), l = await _e(o, n, r);
|
|
101
|
+
if (!l)
|
|
102
|
+
throw new Error(`Managed datasource "${n}" is not installed for app "${r}". Upgrade the application.`);
|
|
103
|
+
const i = {};
|
|
104
|
+
for (const [y, p] of Object.entries(a))
|
|
105
|
+
p != null && (i[y] = p);
|
|
106
|
+
const u = e.replace(/\/$/, ""), m = await fetch(`${u}/datasources/${encodeURIComponent(l)}/data`, {
|
|
107
|
+
method: "POST",
|
|
108
|
+
headers: {
|
|
109
|
+
"Content-Type": "application/json",
|
|
110
|
+
Authorization: `Bearer ${t}`
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify(i)
|
|
113
|
+
}), w = await m.text();
|
|
114
|
+
let g = {};
|
|
115
|
+
if (w)
|
|
116
|
+
try {
|
|
117
|
+
g = JSON.parse(w);
|
|
118
|
+
} catch {
|
|
119
|
+
throw new Error(w || `Datasource operation failed (${m.status})`);
|
|
120
|
+
}
|
|
121
|
+
if (!m.ok) {
|
|
122
|
+
const y = g.message || w || `Datasource operation failed (${m.status})`;
|
|
123
|
+
throw new Error(y);
|
|
124
|
+
}
|
|
125
|
+
return g.data ?? {};
|
|
126
|
+
}
|
|
127
|
+
async function xt(e, t, r, n, a, o = "payload") {
|
|
128
|
+
return bt(e, t, r, n, {
|
|
129
|
+
[o]: JSON.stringify(a)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function or(e, t, r = () => {
|
|
133
|
+
try {
|
|
134
|
+
return localStorage.getItem("token");
|
|
135
|
+
} catch {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}) {
|
|
139
|
+
return (n, a) => xt(
|
|
140
|
+
t(),
|
|
141
|
+
r(),
|
|
142
|
+
e,
|
|
143
|
+
n,
|
|
144
|
+
a
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
async function Nt(e, t, r, n, a, o) {
|
|
148
|
+
if (!e?.trim())
|
|
149
|
+
throw new Error("API root is not configured.");
|
|
150
|
+
if (!t?.trim())
|
|
151
|
+
throw new Error("Authentication required to emit event.");
|
|
152
|
+
const l = {
|
|
153
|
+
appIdentifier: r,
|
|
154
|
+
event: n,
|
|
155
|
+
payload: a
|
|
156
|
+
};
|
|
157
|
+
o?.idempotencyKey && (l.idempotencyKey = o.idempotencyKey);
|
|
158
|
+
const i = e.replace(/\/$/, ""), u = await fetch(`${i}/events/emit`, {
|
|
159
|
+
method: "POST",
|
|
160
|
+
headers: {
|
|
161
|
+
"Content-Type": "application/json",
|
|
162
|
+
Authorization: `Bearer ${t}`
|
|
163
|
+
},
|
|
164
|
+
body: JSON.stringify(l)
|
|
165
|
+
}), m = await u.text();
|
|
166
|
+
let w = {};
|
|
167
|
+
if (m)
|
|
168
|
+
try {
|
|
169
|
+
w = JSON.parse(m);
|
|
170
|
+
} catch {
|
|
171
|
+
throw new Error(m || `Event emit failed (${u.status})`);
|
|
172
|
+
}
|
|
173
|
+
if (!u.ok) {
|
|
174
|
+
const g = w.message || m || `Event emit failed (${u.status})`;
|
|
175
|
+
throw new Error(g);
|
|
176
|
+
}
|
|
177
|
+
return w.data ?? {};
|
|
178
|
+
}
|
|
179
|
+
function lr(e, t, r = () => {
|
|
180
|
+
try {
|
|
181
|
+
return localStorage.getItem("token");
|
|
182
|
+
} catch {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
}) {
|
|
186
|
+
return (n, a, o) => Nt(
|
|
187
|
+
t(),
|
|
188
|
+
r(),
|
|
189
|
+
e,
|
|
190
|
+
n,
|
|
191
|
+
a,
|
|
192
|
+
o
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
function cr({
|
|
196
|
+
title: e,
|
|
197
|
+
hint: t,
|
|
198
|
+
rows: r,
|
|
199
|
+
columns: n,
|
|
200
|
+
emptyLabel: a
|
|
201
|
+
}) {
|
|
202
|
+
const { t: o } = Se();
|
|
203
|
+
return r.length === 0 ? /* @__PURE__ */ d(oe, { className: "border-dashed", children: [
|
|
204
|
+
/* @__PURE__ */ d(le, { className: "pb-2", children: [
|
|
205
|
+
/* @__PURE__ */ s(ce, { className: "text-sm", children: e }),
|
|
206
|
+
t ? /* @__PURE__ */ s(de, { children: t }) : null
|
|
207
|
+
] }),
|
|
208
|
+
/* @__PURE__ */ s(ue, { children: /* @__PURE__ */ s("p", { className: "text-sm text-muted-foreground", children: a ?? o("datasourceInsight.empty", "No rows from managed datasource (install GeniApp 1.0.1+).") }) })
|
|
209
|
+
] }) : /* @__PURE__ */ d(oe, { children: [
|
|
210
|
+
/* @__PURE__ */ d(le, { className: "pb-2", children: [
|
|
211
|
+
/* @__PURE__ */ s(ce, { className: "text-sm", children: e }),
|
|
212
|
+
t ? /* @__PURE__ */ s(de, { children: t }) : null
|
|
213
|
+
] }),
|
|
214
|
+
/* @__PURE__ */ s(ue, { children: /* @__PURE__ */ s("div", { className: "overflow-x-auto", children: /* @__PURE__ */ d(Oe, { children: [
|
|
215
|
+
/* @__PURE__ */ s(je, { children: /* @__PURE__ */ s(me, { children: n.map((l) => /* @__PURE__ */ s(Ne, { children: l.label }, l.key)) }) }),
|
|
216
|
+
/* @__PURE__ */ s(ze, { children: r.map((l, i) => /* @__PURE__ */ s(me, { children: n.map((u) => /* @__PURE__ */ s(we, { children: u.format ? u.format(l[u.key]) : String(l[u.key] ?? "—") }, u.key)) }, i)) })
|
|
217
|
+
] }) }) })
|
|
218
|
+
] });
|
|
219
|
+
}
|
|
220
|
+
const wt = /* @__PURE__ */ new Set();
|
|
221
|
+
function vt({ active: e, dir: t }) {
|
|
222
|
+
return /* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-1 inline-flex text-[0.7em] leading-none text-muted-foreground", children: e ? t === "asc" ? "▲" : "▼" : "↕" });
|
|
223
|
+
}
|
|
224
|
+
function dr({
|
|
225
|
+
columns: e,
|
|
226
|
+
fetchRows: t,
|
|
227
|
+
rowKey: r,
|
|
228
|
+
labels: n,
|
|
229
|
+
pageSize: a = 50,
|
|
230
|
+
resetKey: o,
|
|
231
|
+
initialSort: l,
|
|
232
|
+
onRowClick: i,
|
|
233
|
+
emptyContent: u,
|
|
234
|
+
className: m,
|
|
235
|
+
selectable: w = !1,
|
|
236
|
+
selectedIds: g,
|
|
237
|
+
onSelectionChange: y,
|
|
238
|
+
mobileCard: p
|
|
239
|
+
}) {
|
|
240
|
+
const f = rt(), [v, P] = N(0), [T, j] = N(l ?? null), [E, k] = N([]), [h, R] = N(!1), [I, $] = N(!0), [_, M] = N(null), x = D(0), S = T ? `${T.sortKey}_${T.dir}` : void 0, C = L(async () => {
|
|
241
|
+
const b = ++x.current;
|
|
242
|
+
$(!0), M(null);
|
|
243
|
+
try {
|
|
244
|
+
const c = await t({ limit: a + 1, offset: v * a, sort: S });
|
|
245
|
+
if (b !== x.current) return;
|
|
246
|
+
R(c.length > a), k(c.slice(0, a));
|
|
247
|
+
} catch (c) {
|
|
248
|
+
if (b !== x.current) return;
|
|
249
|
+
M(c instanceof Error ? c.message : String(c)), k([]), R(!1);
|
|
250
|
+
} finally {
|
|
251
|
+
b === x.current && $(!1);
|
|
252
|
+
}
|
|
253
|
+
}, [t, a, v, S]);
|
|
254
|
+
Y(() => {
|
|
255
|
+
C();
|
|
256
|
+
}, [C]);
|
|
257
|
+
const G = D(!0);
|
|
258
|
+
Y(() => {
|
|
259
|
+
if (G.current) {
|
|
260
|
+
G.current = !1;
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
P(0);
|
|
264
|
+
}, [o]);
|
|
265
|
+
const B = L((b) => {
|
|
266
|
+
P(0), j((c) => !c || c.sortKey !== b ? { sortKey: b, dir: "asc" } : c.dir === "asc" ? { sortKey: b, dir: "desc" } : null);
|
|
267
|
+
}, []), F = g ?? wt, V = E.map((b) => r(b)), X = V.filter((b) => F.has(b)).length, K = V.length > 0 && X === V.length, Q = X > 0 && !K, O = L(
|
|
268
|
+
(b) => {
|
|
269
|
+
if (!y) return;
|
|
270
|
+
const c = new Set(F);
|
|
271
|
+
c.has(b) ? c.delete(b) : c.add(b), y(c);
|
|
272
|
+
},
|
|
273
|
+
[y, F]
|
|
274
|
+
), Z = L(() => {
|
|
275
|
+
if (!y) return;
|
|
276
|
+
const b = new Set(F);
|
|
277
|
+
if (K)
|
|
278
|
+
for (const c of V) b.delete(c);
|
|
279
|
+
else
|
|
280
|
+
for (const c of V) b.add(c);
|
|
281
|
+
y(b);
|
|
282
|
+
}, [y, F, K, V]), ee = I && E.length === 0 ? /* @__PURE__ */ d("div", { className: "space-y-2 p-4", "aria-busy": !0, children: [
|
|
283
|
+
/* @__PURE__ */ s("div", { className: "h-8 animate-pulse rounded bg-muted" }),
|
|
284
|
+
/* @__PURE__ */ s("div", { className: "h-8 animate-pulse rounded bg-muted" }),
|
|
285
|
+
/* @__PURE__ */ s("div", { className: "h-8 animate-pulse rounded bg-muted" })
|
|
286
|
+
] }) : null, re = _ ? /* @__PURE__ */ d("div", { className: "flex flex-col items-center gap-2 p-8 text-center", children: [
|
|
287
|
+
/* @__PURE__ */ s("p", { className: "text-sm text-destructive", children: _ }),
|
|
288
|
+
/* @__PURE__ */ s(H, { variant: "outline", size: "sm", onClick: () => void C(), children: n.retry })
|
|
289
|
+
] }) : null, te = !I && !_ && E.length === 0 ? /* @__PURE__ */ s("div", { className: "p-12 text-center text-sm text-muted-foreground", children: u ?? n.empty }) : null, ne = (v > 0 || h) && !_ ? /* @__PURE__ */ d("div", { className: "mt-3 flex items-center justify-end gap-2", children: [
|
|
290
|
+
/* @__PURE__ */ s("span", { className: "text-sm text-muted-foreground", children: n.page(v + 1) }),
|
|
291
|
+
/* @__PURE__ */ s(
|
|
292
|
+
H,
|
|
293
|
+
{
|
|
294
|
+
variant: "outline",
|
|
295
|
+
size: "sm",
|
|
296
|
+
disabled: v === 0 || I,
|
|
297
|
+
onClick: () => P((b) => Math.max(0, b - 1)),
|
|
298
|
+
children: n.previous
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
/* @__PURE__ */ s(
|
|
302
|
+
H,
|
|
303
|
+
{
|
|
304
|
+
variant: "outline",
|
|
305
|
+
size: "sm",
|
|
306
|
+
disabled: !h || I,
|
|
307
|
+
onClick: () => P((b) => b + 1),
|
|
308
|
+
children: n.next
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
] }) : null;
|
|
312
|
+
return f && p ? /* @__PURE__ */ d("div", { className: m, children: [
|
|
313
|
+
w && E.length > 0 ? /* @__PURE__ */ d("label", { className: "mb-2 flex min-h-[44px] items-center gap-2 px-1 text-sm text-muted-foreground", children: [
|
|
314
|
+
/* @__PURE__ */ s(
|
|
315
|
+
se,
|
|
316
|
+
{
|
|
317
|
+
checked: K ? !0 : Q ? "indeterminate" : !1,
|
|
318
|
+
onCheckedChange: Z,
|
|
319
|
+
"aria-label": n.selectAllLabel
|
|
320
|
+
}
|
|
321
|
+
),
|
|
322
|
+
n.selectAllLabel
|
|
323
|
+
] }) : null,
|
|
324
|
+
/* @__PURE__ */ s("div", { className: "space-y-2", children: E.map((b) => {
|
|
325
|
+
const c = r(b), A = !!i;
|
|
326
|
+
return /* @__PURE__ */ d(
|
|
327
|
+
"div",
|
|
328
|
+
{
|
|
329
|
+
className: `flex items-start gap-3 rounded-xl border border-border bg-card p-3 text-card-foreground shadow-sm${A ? " cursor-pointer transition-colors active:bg-accent/40" : ""}`,
|
|
330
|
+
onClick: A ? () => i?.(b) : void 0,
|
|
331
|
+
children: [
|
|
332
|
+
w ? /* @__PURE__ */ s("div", { className: "pt-0.5", onClick: (U) => U.stopPropagation(), children: /* @__PURE__ */ s(
|
|
333
|
+
se,
|
|
334
|
+
{
|
|
335
|
+
checked: F.has(c),
|
|
336
|
+
onCheckedChange: () => O(c),
|
|
337
|
+
"aria-label": n.selectRowLabel
|
|
338
|
+
}
|
|
339
|
+
) }) : null,
|
|
340
|
+
/* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: p(b) })
|
|
341
|
+
]
|
|
342
|
+
},
|
|
343
|
+
c
|
|
344
|
+
);
|
|
345
|
+
}) }),
|
|
346
|
+
ee,
|
|
347
|
+
re,
|
|
348
|
+
te,
|
|
349
|
+
ne
|
|
350
|
+
] }) : /* @__PURE__ */ d("div", { className: m, children: [
|
|
351
|
+
/* @__PURE__ */ d("div", { className: "overflow-x-auto rounded-xl border border-border bg-card shadow-sm", children: [
|
|
352
|
+
/* @__PURE__ */ d(Oe, { children: [
|
|
353
|
+
/* @__PURE__ */ s(je, { children: /* @__PURE__ */ d(me, { children: [
|
|
354
|
+
w ? /* @__PURE__ */ s(Ne, { className: "w-10", children: /* @__PURE__ */ s(
|
|
355
|
+
se,
|
|
356
|
+
{
|
|
357
|
+
checked: K ? !0 : Q ? "indeterminate" : !1,
|
|
358
|
+
onCheckedChange: Z,
|
|
359
|
+
disabled: E.length === 0,
|
|
360
|
+
"aria-label": n.selectAllLabel
|
|
361
|
+
}
|
|
362
|
+
) }) : null,
|
|
363
|
+
e.map((b) => {
|
|
364
|
+
const c = !!b.sortKey, A = c && T?.sortKey === b.sortKey;
|
|
365
|
+
return /* @__PURE__ */ s(Ne, { className: b.headClassName, children: c ? /* @__PURE__ */ d(
|
|
366
|
+
"button",
|
|
367
|
+
{
|
|
368
|
+
type: "button",
|
|
369
|
+
className: "inline-flex items-center font-medium hover:text-foreground",
|
|
370
|
+
onClick: () => B(b.sortKey),
|
|
371
|
+
"aria-label": A && T?.dir === "asc" ? n.sortDescLabel : n.sortAscLabel,
|
|
372
|
+
children: [
|
|
373
|
+
b.header,
|
|
374
|
+
/* @__PURE__ */ s(vt, { active: !!A, dir: A ? T.dir : "asc" })
|
|
375
|
+
]
|
|
376
|
+
}
|
|
377
|
+
) : b.header }, b.key);
|
|
378
|
+
})
|
|
379
|
+
] }) }),
|
|
380
|
+
/* @__PURE__ */ s(ze, { children: E.map((b) => {
|
|
381
|
+
const c = r(b);
|
|
382
|
+
return /* @__PURE__ */ d(
|
|
383
|
+
me,
|
|
384
|
+
{
|
|
385
|
+
className: i ? "cursor-pointer" : void 0,
|
|
386
|
+
onClick: i ? () => i(b) : void 0,
|
|
387
|
+
children: [
|
|
388
|
+
w ? /* @__PURE__ */ s(
|
|
389
|
+
we,
|
|
390
|
+
{
|
|
391
|
+
className: "w-10",
|
|
392
|
+
onClick: (A) => A.stopPropagation(),
|
|
393
|
+
children: /* @__PURE__ */ s(
|
|
394
|
+
se,
|
|
395
|
+
{
|
|
396
|
+
checked: F.has(c),
|
|
397
|
+
onCheckedChange: () => O(c),
|
|
398
|
+
"aria-label": n.selectRowLabel
|
|
399
|
+
}
|
|
400
|
+
)
|
|
401
|
+
}
|
|
402
|
+
) : null,
|
|
403
|
+
e.map((A) => /* @__PURE__ */ s(we, { className: A.className, children: A.cell ? A.cell(b) : String(b[A.key] ?? "—") }, A.key))
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
c
|
|
407
|
+
);
|
|
408
|
+
}) })
|
|
409
|
+
] }),
|
|
410
|
+
ee,
|
|
411
|
+
re,
|
|
412
|
+
te
|
|
413
|
+
] }),
|
|
414
|
+
ne
|
|
415
|
+
] });
|
|
416
|
+
}
|
|
417
|
+
function ur({
|
|
418
|
+
value: e,
|
|
419
|
+
onChange: t,
|
|
420
|
+
loadOptions: r,
|
|
421
|
+
resolveSelected: n,
|
|
422
|
+
labels: a,
|
|
423
|
+
disabled: o,
|
|
424
|
+
allowClear: l = !0,
|
|
425
|
+
pageSize: i = 20,
|
|
426
|
+
triggerClassName: u,
|
|
427
|
+
contentClassName: m
|
|
428
|
+
}) {
|
|
429
|
+
const [w, g] = N(!1), [y, p] = N(""), [f, v] = N(""), [P, T] = N([]), [j, E] = N(0), [k, h] = N(!1), [R, I] = N(!1), [$, _] = N(null), M = D(0);
|
|
430
|
+
Y(() => {
|
|
431
|
+
const C = setTimeout(() => v(y.trim()), 300);
|
|
432
|
+
return () => clearTimeout(C);
|
|
433
|
+
}, [y]);
|
|
434
|
+
const x = L(
|
|
435
|
+
async (C, G, B) => {
|
|
436
|
+
const F = ++M.current;
|
|
437
|
+
I(!0);
|
|
438
|
+
try {
|
|
439
|
+
const V = await r({ search: C, limit: i + 1, offset: G });
|
|
440
|
+
if (F !== M.current) return;
|
|
441
|
+
const X = V.length > i, K = V.slice(0, i);
|
|
442
|
+
h(X), E(G), T((Q) => B ? [...Q, ...K] : K);
|
|
443
|
+
} catch {
|
|
444
|
+
if (F !== M.current) return;
|
|
445
|
+
B || T([]), h(!1);
|
|
446
|
+
} finally {
|
|
447
|
+
F === M.current && I(!1);
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
[r, i]
|
|
451
|
+
);
|
|
452
|
+
Y(() => {
|
|
453
|
+
w && x(f, 0, !1);
|
|
454
|
+
}, [w, f, x]), Y(() => {
|
|
455
|
+
if (!e) {
|
|
456
|
+
_(null);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
if ($?.value === e) return;
|
|
460
|
+
const C = P.find((B) => B.value === e);
|
|
461
|
+
if (C) {
|
|
462
|
+
_(C);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (!n) return;
|
|
466
|
+
let G = !1;
|
|
467
|
+
return n(e).then((B) => {
|
|
468
|
+
!G && B && _(B);
|
|
469
|
+
}), () => {
|
|
470
|
+
G = !0;
|
|
471
|
+
};
|
|
472
|
+
}, [e, P, n, $]);
|
|
473
|
+
const S = $?.label ?? (e || a.placeholder);
|
|
474
|
+
return /* @__PURE__ */ d(nt, { open: w, onOpenChange: g, children: [
|
|
475
|
+
/* @__PURE__ */ s(st, { asChild: !0, children: /* @__PURE__ */ d(
|
|
476
|
+
H,
|
|
477
|
+
{
|
|
478
|
+
type: "button",
|
|
479
|
+
variant: "outline",
|
|
480
|
+
role: "combobox",
|
|
481
|
+
"aria-expanded": w,
|
|
482
|
+
disabled: o,
|
|
483
|
+
className: u ?? "min-w-[12rem] justify-between font-normal",
|
|
484
|
+
children: [
|
|
485
|
+
/* @__PURE__ */ s("span", { className: $ || e ? "" : "text-muted-foreground", children: S }),
|
|
486
|
+
/* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-2 text-xs text-muted-foreground", children: "▾" })
|
|
487
|
+
]
|
|
488
|
+
}
|
|
489
|
+
) }),
|
|
490
|
+
/* @__PURE__ */ d(at, { className: m ?? "w-[16rem] p-0", align: "start", children: [
|
|
491
|
+
/* @__PURE__ */ s("div", { className: "border-b border-border p-2", children: /* @__PURE__ */ s(
|
|
492
|
+
it,
|
|
493
|
+
{
|
|
494
|
+
autoFocus: !0,
|
|
495
|
+
value: y,
|
|
496
|
+
onChange: (C) => p(C.target.value),
|
|
497
|
+
placeholder: a.searchPlaceholder,
|
|
498
|
+
"aria-label": a.searchPlaceholder
|
|
499
|
+
}
|
|
500
|
+
) }),
|
|
501
|
+
/* @__PURE__ */ s(ot, { className: "max-h-64", children: /* @__PURE__ */ d("div", { className: "p-1", children: [
|
|
502
|
+
l && e ? /* @__PURE__ */ s(
|
|
503
|
+
"button",
|
|
504
|
+
{
|
|
505
|
+
type: "button",
|
|
506
|
+
className: "block w-full rounded px-2 py-1.5 text-left text-sm text-muted-foreground hover:bg-accent",
|
|
507
|
+
onClick: () => {
|
|
508
|
+
t(null), _(null), g(!1);
|
|
509
|
+
},
|
|
510
|
+
children: a.clear
|
|
511
|
+
}
|
|
512
|
+
) : null,
|
|
513
|
+
P.map((C) => /* @__PURE__ */ d(
|
|
514
|
+
"button",
|
|
515
|
+
{
|
|
516
|
+
type: "button",
|
|
517
|
+
className: `block w-full rounded px-2 py-1.5 text-left text-sm hover:bg-accent ${C.value === e ? "bg-accent font-medium" : ""}`,
|
|
518
|
+
onClick: () => {
|
|
519
|
+
t(C.value), _(C), g(!1);
|
|
520
|
+
},
|
|
521
|
+
children: [
|
|
522
|
+
/* @__PURE__ */ s("span", { children: C.label }),
|
|
523
|
+
C.hint ? /* @__PURE__ */ s("span", { className: "ml-2 text-xs text-muted-foreground", children: C.hint }) : null
|
|
524
|
+
]
|
|
525
|
+
},
|
|
526
|
+
C.value
|
|
527
|
+
)),
|
|
528
|
+
!R && P.length === 0 ? /* @__PURE__ */ s("p", { className: "px-2 py-6 text-center text-sm text-muted-foreground", children: a.empty }) : null,
|
|
529
|
+
R ? /* @__PURE__ */ d("div", { className: "space-y-1 p-1", "aria-busy": !0, children: [
|
|
530
|
+
/* @__PURE__ */ s("div", { className: "h-7 animate-pulse rounded bg-muted" }),
|
|
531
|
+
/* @__PURE__ */ s("div", { className: "h-7 animate-pulse rounded bg-muted" })
|
|
532
|
+
] }) : null,
|
|
533
|
+
k && !R ? /* @__PURE__ */ s(
|
|
534
|
+
"button",
|
|
535
|
+
{
|
|
536
|
+
type: "button",
|
|
537
|
+
className: "mt-1 block w-full rounded px-2 py-1.5 text-center text-sm text-primary hover:bg-accent",
|
|
538
|
+
onClick: () => void x(f, j + i, !0),
|
|
539
|
+
children: a.loadMore
|
|
540
|
+
}
|
|
541
|
+
) : null
|
|
542
|
+
] }) })
|
|
543
|
+
] })
|
|
544
|
+
] });
|
|
545
|
+
}
|
|
546
|
+
function mr(e, t) {
|
|
547
|
+
const r = t?.pageSize ?? 20, n = t?.resetKey, [a, o] = N([]), [l, i] = N(!1), [u, m] = N(!0), [w, g] = N(null), y = D(0), p = D(!1), f = D(!0), v = D(e);
|
|
548
|
+
v.current = e;
|
|
549
|
+
const P = D(null), T = L(async () => {
|
|
550
|
+
if (p.current || !f.current) return;
|
|
551
|
+
p.current = !0, i(!0), g(null);
|
|
552
|
+
const k = y.current;
|
|
553
|
+
try {
|
|
554
|
+
const h = await v.current({ limit: r, offset: k }), R = Array.isArray(h) ? h : [];
|
|
555
|
+
o(($) => k === 0 ? R : [...$, ...R]), y.current = k + R.length;
|
|
556
|
+
const I = R.length === r;
|
|
557
|
+
f.current = I, m(I);
|
|
558
|
+
} catch (h) {
|
|
559
|
+
g(h instanceof Error ? h.message : String(h)), f.current = !1, m(!1);
|
|
560
|
+
} finally {
|
|
561
|
+
p.current = !1, i(!1);
|
|
562
|
+
}
|
|
563
|
+
}, [r]), j = L(() => {
|
|
564
|
+
y.current = 0, f.current = !0, p.current = !1, o([]), m(!0), g(null), T();
|
|
565
|
+
}, [T]);
|
|
566
|
+
Y(() => {
|
|
567
|
+
j();
|
|
568
|
+
}, [n]);
|
|
569
|
+
const E = L(
|
|
570
|
+
(k) => {
|
|
571
|
+
P.current && (P.current.disconnect(), P.current = null), k && (P.current = new IntersectionObserver(
|
|
572
|
+
(h) => {
|
|
573
|
+
h.some((R) => R.isIntersecting) && f.current && !p.current && T();
|
|
574
|
+
},
|
|
575
|
+
{ rootMargin: "200px" }
|
|
576
|
+
), P.current.observe(k));
|
|
577
|
+
},
|
|
578
|
+
[T]
|
|
579
|
+
);
|
|
580
|
+
return Y(() => () => P.current?.disconnect(), []), { rows: a, loading: l, hasMore: u, error: w, loadMore: T, reset: j, sentinelRef: E };
|
|
581
|
+
}
|
|
582
|
+
function fr({ children: e, className: t }) {
|
|
583
|
+
return /* @__PURE__ */ s("ol", { className: `relative flex flex-col gap-12 ${t ?? ""}`, children: e });
|
|
584
|
+
}
|
|
585
|
+
function pr({
|
|
586
|
+
icon: e,
|
|
587
|
+
dotClassName: t = "text-foreground",
|
|
588
|
+
nodeClassName: r = "bg-muted",
|
|
589
|
+
accentClassName: n = "border-l-border",
|
|
590
|
+
title: a,
|
|
591
|
+
time: o,
|
|
592
|
+
meta: l,
|
|
593
|
+
children: i,
|
|
594
|
+
isLast: u
|
|
595
|
+
}) {
|
|
596
|
+
return /* @__PURE__ */ d("li", { className: "relative flex items-start gap-5", children: [
|
|
597
|
+
/* @__PURE__ */ d("div", { className: "relative flex w-9 shrink-0 flex-col items-center self-stretch", children: [
|
|
598
|
+
/* @__PURE__ */ s(
|
|
599
|
+
"span",
|
|
600
|
+
{
|
|
601
|
+
className: `z-10 flex h-9 w-9 shrink-0 items-center justify-center rounded-full ring-4 ring-background ${r} ${t}`,
|
|
602
|
+
children: e ? /* @__PURE__ */ s(e, { className: "h-4 w-4" }) : /* @__PURE__ */ s("span", { className: "h-2 w-2 rounded-full bg-current" })
|
|
603
|
+
}
|
|
604
|
+
),
|
|
605
|
+
u ? null : /* @__PURE__ */ s(
|
|
606
|
+
"span",
|
|
607
|
+
{
|
|
608
|
+
className: "mt-3 w-px flex-1 min-h-[1.5rem] bg-gradient-to-b from-border to-transparent",
|
|
609
|
+
"aria-hidden": !0
|
|
610
|
+
}
|
|
611
|
+
)
|
|
612
|
+
] }),
|
|
613
|
+
/* @__PURE__ */ d(
|
|
614
|
+
"div",
|
|
615
|
+
{
|
|
616
|
+
className: `min-w-0 flex-1 space-y-3 rounded-xl border border-l-2 border-border bg-card px-4 py-4 shadow-sm transition-shadow hover:shadow-md ${n}`,
|
|
617
|
+
children: [
|
|
618
|
+
/* @__PURE__ */ d("div", { className: "flex items-start justify-between gap-4", children: [
|
|
619
|
+
/* @__PURE__ */ s("p", { className: "text-sm font-semibold leading-normal text-foreground", children: a }),
|
|
620
|
+
o ? /* @__PURE__ */ s("span", { className: "shrink-0 text-xs leading-5 tabular-nums text-muted-foreground", children: o }) : null
|
|
621
|
+
] }),
|
|
622
|
+
l ? /* @__PURE__ */ s("p", { className: "text-xs leading-relaxed text-muted-foreground", children: l }) : null,
|
|
623
|
+
i ? /* @__PURE__ */ s("div", { className: "pt-1", children: i }) : null
|
|
624
|
+
]
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
] });
|
|
628
|
+
}
|
|
629
|
+
function hr(e) {
|
|
630
|
+
const t = D(/* @__PURE__ */ new Map()), r = D(/* @__PURE__ */ new Set()), n = D(/* @__PURE__ */ new Set()), a = D(null), [, o] = N(0), [l, i] = N(0), u = D(e);
|
|
631
|
+
u.current = e;
|
|
632
|
+
const m = L(async () => {
|
|
633
|
+
a.current = null;
|
|
634
|
+
const y = Array.from(n.current);
|
|
635
|
+
if (n.current.clear(), y.length !== 0) {
|
|
636
|
+
y.forEach((p) => r.current.add(p)), i((p) => p + 1);
|
|
637
|
+
try {
|
|
638
|
+
const p = await u.current(y);
|
|
639
|
+
y.forEach((f) => t.current.set(f, p[f]));
|
|
640
|
+
} catch {
|
|
641
|
+
y.forEach((p) => t.current.delete(p));
|
|
642
|
+
} finally {
|
|
643
|
+
y.forEach((p) => r.current.delete(p)), i((p) => Math.max(0, p - 1)), o((p) => p + 1);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}, []), w = L(
|
|
647
|
+
(y) => {
|
|
648
|
+
let p = !1;
|
|
649
|
+
for (const f of y)
|
|
650
|
+
f && (t.current.has(f) || r.current.has(f) || n.current.has(f) || (n.current.add(f), p = !0));
|
|
651
|
+
p && a.current === null && (a.current = setTimeout(() => void m(), 0));
|
|
652
|
+
},
|
|
653
|
+
[m]
|
|
654
|
+
);
|
|
655
|
+
return Y(() => () => {
|
|
656
|
+
a.current !== null && clearTimeout(a.current);
|
|
657
|
+
}, []), { resolve: L((y) => t.current.get(y), []), ensure: w, loading: l > 0 };
|
|
658
|
+
}
|
|
659
|
+
function gr({ value: e, name: t, href: r, onClick: n, fallback: a, className: o }) {
|
|
660
|
+
const l = t !== void 0, i = l ? t : a ?? e, u = l ? "" : "text-muted-foreground", m = o ? `${u} ${o}`.trim() : u || void 0;
|
|
661
|
+
return r ? /* @__PURE__ */ s(
|
|
662
|
+
"a",
|
|
663
|
+
{
|
|
664
|
+
href: r,
|
|
665
|
+
onClick: n,
|
|
666
|
+
className: m ? `${m} underline-offset-2 hover:underline` : "underline-offset-2 hover:underline",
|
|
667
|
+
children: i
|
|
668
|
+
}
|
|
669
|
+
) : n ? /* @__PURE__ */ s(
|
|
670
|
+
"button",
|
|
671
|
+
{
|
|
672
|
+
type: "button",
|
|
673
|
+
onClick: n,
|
|
674
|
+
className: m ? `${m} underline-offset-2 hover:underline` : "underline-offset-2 hover:underline",
|
|
675
|
+
children: i
|
|
676
|
+
}
|
|
677
|
+
) : /* @__PURE__ */ s("span", { className: m, children: i });
|
|
678
|
+
}
|
|
679
|
+
function yr({
|
|
680
|
+
selectedCount: e,
|
|
681
|
+
totalMatching: t,
|
|
682
|
+
allMatchingSelected: r,
|
|
683
|
+
onSelectAllMatching: n,
|
|
684
|
+
onClear: a,
|
|
685
|
+
actions: o,
|
|
686
|
+
labels: l,
|
|
687
|
+
className: i
|
|
688
|
+
}) {
|
|
689
|
+
if (e <= 0) return null;
|
|
690
|
+
const u = !r && !!n && !!l.selectAllMatching && typeof t == "number" && t > e;
|
|
691
|
+
return /* @__PURE__ */ d(
|
|
692
|
+
"div",
|
|
693
|
+
{
|
|
694
|
+
className: i ?? "sticky bottom-0 z-10 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-border bg-background/95 px-4 py-2.5 shadow-md backdrop-blur supports-[backdrop-filter]:bg-background/80",
|
|
695
|
+
role: "toolbar",
|
|
696
|
+
children: [
|
|
697
|
+
/* @__PURE__ */ s("span", { className: "text-sm font-medium", children: l.selected(e) }),
|
|
698
|
+
u ? /* @__PURE__ */ s(H, { variant: "link", size: "sm", className: "h-auto px-0", onClick: n, children: l.selectAllMatching(t) }) : null,
|
|
699
|
+
/* @__PURE__ */ d("div", { className: "ml-auto flex flex-wrap items-center gap-2", children: [
|
|
700
|
+
o.map((m) => /* @__PURE__ */ s(
|
|
701
|
+
H,
|
|
702
|
+
{
|
|
703
|
+
variant: m.variant ?? "outline",
|
|
704
|
+
size: "sm",
|
|
705
|
+
disabled: m.disabled,
|
|
706
|
+
onClick: m.onClick,
|
|
707
|
+
children: m.label
|
|
708
|
+
},
|
|
709
|
+
m.key
|
|
710
|
+
)),
|
|
711
|
+
/* @__PURE__ */ s(H, { variant: "ghost", size: "sm", onClick: a, children: l.clear })
|
|
712
|
+
] })
|
|
713
|
+
]
|
|
714
|
+
}
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
function br() {
|
|
718
|
+
const [e, t] = N("idle"), [r, n] = N(null), [a, o] = N(0), [l, i] = N(null), [u, m] = N(null), [w, g] = N(1), [y, p] = N(!1), f = D(0), v = D(!1), P = D(null), T = D(null), j = D(void 0), E = D(!1), k = D(null);
|
|
719
|
+
Y(() => () => {
|
|
720
|
+
f.current += 1, P.current?.abort();
|
|
721
|
+
}, []);
|
|
722
|
+
const h = e === "starting" || e === "running";
|
|
723
|
+
Y(() => {
|
|
724
|
+
if (!h) return;
|
|
725
|
+
const x = () => {
|
|
726
|
+
const C = k.current;
|
|
727
|
+
C != null && o(Math.max(0, Date.now() - C));
|
|
728
|
+
};
|
|
729
|
+
x();
|
|
730
|
+
const S = setInterval(x, 1e3);
|
|
731
|
+
return () => clearInterval(S);
|
|
732
|
+
}, [h]);
|
|
733
|
+
const R = L((x) => {
|
|
734
|
+
if (v.current && (T.current = x, i(x), t((S) => S === "starting" ? "running" : S), n(x.phase ?? null), x.cancelRequested && p(!0), x.createdAt)) {
|
|
735
|
+
const S = Date.parse(x.createdAt);
|
|
736
|
+
Number.isFinite(S) && k.current != null && S < k.current && (k.current = S);
|
|
737
|
+
}
|
|
738
|
+
}, []), I = L((x) => {
|
|
739
|
+
v.current && g(x);
|
|
740
|
+
}, []), $ = L(
|
|
741
|
+
async (x, S) => {
|
|
742
|
+
if (v.current) return null;
|
|
743
|
+
const C = ++f.current;
|
|
744
|
+
v.current = !0, E.current = !1, j.current = S?.cancel, T.current = null, k.current = Date.now();
|
|
745
|
+
const G = new AbortController();
|
|
746
|
+
P.current = G, t("starting"), n(null), o(0), i(null), m(null), g(1), p(!1);
|
|
747
|
+
const B = (F) => (...V) => {
|
|
748
|
+
C === f.current && F(...V);
|
|
749
|
+
};
|
|
750
|
+
try {
|
|
751
|
+
const F = await x({
|
|
752
|
+
onJob: B(R),
|
|
753
|
+
onAttempt: B(I),
|
|
754
|
+
signal: G.signal
|
|
755
|
+
});
|
|
756
|
+
return C !== f.current ? null : (t("succeeded"), F);
|
|
757
|
+
} catch (F) {
|
|
758
|
+
if (C !== f.current) return null;
|
|
759
|
+
if (E.current || G.signal.aborted || F instanceof Error && F.name === "AbortError")
|
|
760
|
+
return t("cancelled"), null;
|
|
761
|
+
throw t("failed"), m(F instanceof Error ? F.message : String(F)), F;
|
|
762
|
+
} finally {
|
|
763
|
+
C === f.current && (v.current = !1);
|
|
764
|
+
}
|
|
765
|
+
},
|
|
766
|
+
[R, I]
|
|
767
|
+
), _ = L(() => {
|
|
768
|
+
if (!v.current || E.current) return;
|
|
769
|
+
E.current = !0, p(!0);
|
|
770
|
+
const x = T.current?.id, S = j.current;
|
|
771
|
+
x && S ? Promise.resolve().then(() => S(x)).catch(() => P.current?.abort()) : P.current?.abort();
|
|
772
|
+
}, []), M = L(() => {
|
|
773
|
+
f.current += 1, v.current = !1, P.current?.abort(), P.current = null, T.current = null, k.current = null, E.current = !1, t("idle"), n(null), o(0), i(null), m(null), g(1), p(!1);
|
|
774
|
+
}, []);
|
|
775
|
+
return { state: e, phase: r, elapsedMs: a, job: l, error: u, attempt: w, cancelRequested: y, start: $, cancel: _, reset: M, observe: R, noteAttempt: I };
|
|
776
|
+
}
|
|
777
|
+
const At = {
|
|
778
|
+
title: "Working…",
|
|
779
|
+
elapsed: (e) => `${e}s elapsed`,
|
|
780
|
+
expectedNote: "",
|
|
781
|
+
slow: "Taking longer than usual — still working…",
|
|
782
|
+
queued: "Queued",
|
|
783
|
+
resolve: "Locating agent",
|
|
784
|
+
invoke: "Running",
|
|
785
|
+
finalize: "Finalizing",
|
|
786
|
+
retryNotice: "First result was invalid — retrying once…",
|
|
787
|
+
cancel: "Cancel",
|
|
788
|
+
cancelling: "Cancelling…",
|
|
789
|
+
failed: "The AI task failed.",
|
|
790
|
+
retry: "Retry",
|
|
791
|
+
cancelled: "Cancelled."
|
|
792
|
+
}, St = ["queued", "resolve", "invoke", "finalize"];
|
|
793
|
+
function _t(e, t) {
|
|
794
|
+
return e === "starting" ? 0 : t === "resolve" ? 1 : t === "finalize" ? 3 : 2;
|
|
795
|
+
}
|
|
796
|
+
function xr({
|
|
797
|
+
state: e,
|
|
798
|
+
phase: t,
|
|
799
|
+
elapsedMs: r,
|
|
800
|
+
expectedSeconds: n,
|
|
801
|
+
attempt: a = 1,
|
|
802
|
+
cancelRequested: o = !1,
|
|
803
|
+
error: l,
|
|
804
|
+
onCancel: i,
|
|
805
|
+
onRetry: u,
|
|
806
|
+
labels: m,
|
|
807
|
+
className: w
|
|
808
|
+
}) {
|
|
809
|
+
const g = { ...At, ...m };
|
|
810
|
+
if (e === "idle" || e === "succeeded") return null;
|
|
811
|
+
if (e === "failed")
|
|
812
|
+
return /* @__PURE__ */ d("div", { role: "alert", className: `space-y-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 ${w ?? ""}`, children: [
|
|
813
|
+
/* @__PURE__ */ s("p", { className: "text-sm text-destructive", children: l || g.failed }),
|
|
814
|
+
u ? /* @__PURE__ */ s(H, { type: "button", variant: "outline", size: "sm", onClick: u, children: g.retry }) : null
|
|
815
|
+
] });
|
|
816
|
+
if (e === "cancelled")
|
|
817
|
+
return /* @__PURE__ */ d("div", { role: "status", className: `space-y-2 rounded-lg border border-border bg-muted/40 p-3 ${w ?? ""}`, children: [
|
|
818
|
+
/* @__PURE__ */ s("p", { className: "text-sm text-muted-foreground", children: g.cancelled }),
|
|
819
|
+
u ? /* @__PURE__ */ s(H, { type: "button", variant: "outline", size: "sm", onClick: u, children: g.retry }) : null
|
|
820
|
+
] });
|
|
821
|
+
const y = Math.floor(r / 1e3), p = n != null && r > n * 1500, f = p ? g.slow : g.expectedNote, v = _t(e, t);
|
|
822
|
+
return /* @__PURE__ */ d(
|
|
823
|
+
"div",
|
|
824
|
+
{
|
|
825
|
+
role: "status",
|
|
826
|
+
"aria-busy": !0,
|
|
827
|
+
className: `space-y-2.5 rounded-lg border border-status-info/40 bg-status-info/10 p-3 ${w ?? ""}`,
|
|
828
|
+
children: [
|
|
829
|
+
/* @__PURE__ */ d("div", { className: "flex items-start gap-2.5", children: [
|
|
830
|
+
/* @__PURE__ */ s(xe, { className: "mt-0.5 h-4 w-4 shrink-0 animate-spin text-status-info", "aria-hidden": !0 }),
|
|
831
|
+
/* @__PURE__ */ d("div", { className: "min-w-0 flex-1 space-y-0.5", children: [
|
|
832
|
+
/* @__PURE__ */ d("p", { className: "text-sm font-medium text-foreground", children: [
|
|
833
|
+
g.title,
|
|
834
|
+
" · ",
|
|
835
|
+
g.elapsed(y),
|
|
836
|
+
f ? /* @__PURE__ */ s("span", { className: p ? "text-status-warning" : "text-muted-foreground", children: f }) : null
|
|
837
|
+
] }),
|
|
838
|
+
a > 1 ? /* @__PURE__ */ s("p", { className: "text-xs text-muted-foreground", children: g.retryNotice }) : null
|
|
839
|
+
] }),
|
|
840
|
+
i ? /* @__PURE__ */ s(H, { type: "button", variant: "outline", size: "sm", onClick: i, disabled: o, children: o ? g.cancelling : g.cancel }) : null
|
|
841
|
+
] }),
|
|
842
|
+
/* @__PURE__ */ s("ul", { className: "space-y-1 pl-[26px]", children: St.map((P, T) => {
|
|
843
|
+
const j = T < v, E = T === v;
|
|
844
|
+
return /* @__PURE__ */ d(
|
|
845
|
+
"li",
|
|
846
|
+
{
|
|
847
|
+
className: `flex items-center gap-1.5 text-xs ${E ? "font-medium text-foreground" : j ? "text-muted-foreground" : "text-muted-foreground/60"}`,
|
|
848
|
+
children: [
|
|
849
|
+
j ? /* @__PURE__ */ s($e, { className: "h-3 w-3 shrink-0 text-status-info", "aria-hidden": !0 }) : E ? /* @__PURE__ */ s(xe, { className: "h-3 w-3 shrink-0 animate-spin text-status-info", "aria-hidden": !0 }) : /* @__PURE__ */ s(Qe, { className: "h-3 w-3 shrink-0 text-muted-foreground/45", "aria-hidden": !0 }),
|
|
850
|
+
g[P]
|
|
851
|
+
]
|
|
852
|
+
},
|
|
853
|
+
P
|
|
854
|
+
);
|
|
855
|
+
}) }),
|
|
856
|
+
/* @__PURE__ */ s("div", { className: "ml-[26px] h-1 overflow-hidden rounded-full bg-status-info/20", children: /* @__PURE__ */ s("div", { className: "h-full w-full animate-pulse rounded-full bg-status-info/60" }) })
|
|
857
|
+
]
|
|
858
|
+
}
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
const ye = { done: 0, total: 0 };
|
|
862
|
+
function Nr({ run: e }) {
|
|
863
|
+
const [t, r] = N("idle"), [n, a] = N(ye), [o, l] = N(null), i = D(0), u = D(!1), m = D(e);
|
|
864
|
+
m.current = e;
|
|
865
|
+
const w = L(() => {
|
|
866
|
+
if (u.current) return;
|
|
867
|
+
const y = ++i.current;
|
|
868
|
+
u.current = !0, r("running"), a(ye), l(null);
|
|
869
|
+
const p = (f) => {
|
|
870
|
+
y === i.current && a({ done: f.done, total: f.total, message: f.message });
|
|
871
|
+
};
|
|
872
|
+
(async () => {
|
|
873
|
+
try {
|
|
874
|
+
const f = await m.current(p);
|
|
875
|
+
if (y !== i.current) return;
|
|
876
|
+
l(f), r(f.ok ? "done" : "error");
|
|
877
|
+
} catch (f) {
|
|
878
|
+
if (y !== i.current) return;
|
|
879
|
+
const v = f instanceof Error ? f.message : String(f);
|
|
880
|
+
l({ ok: !1, error: v }), r("error");
|
|
881
|
+
} finally {
|
|
882
|
+
y === i.current && (u.current = !1);
|
|
883
|
+
}
|
|
884
|
+
})();
|
|
885
|
+
}, []), g = L(() => {
|
|
886
|
+
i.current += 1, u.current = !1, r("idle"), a(ye), l(null);
|
|
887
|
+
}, []);
|
|
888
|
+
return { status: t, progress: n, result: o, start: w, reset: g };
|
|
889
|
+
}
|
|
890
|
+
function wr({ job: e, labels: t, onRetry: r, className: n }) {
|
|
891
|
+
const { status: a, progress: o, result: l } = e, { done: i, total: u, message: m } = o, w = r ?? e.start;
|
|
892
|
+
return /* @__PURE__ */ d("div", { className: n ?? "space-y-2", children: [
|
|
893
|
+
a === "idle" && t.idle ? /* @__PURE__ */ s("p", { className: "text-sm text-muted-foreground", children: t.idle }) : null,
|
|
894
|
+
a === "running" ? /* @__PURE__ */ d("div", { className: "space-y-1.5", "aria-busy": !0, children: [
|
|
895
|
+
/* @__PURE__ */ s(lt, { value: i, max: u > 0 ? u : 1 }),
|
|
896
|
+
/* @__PURE__ */ s("p", { className: "text-sm text-muted-foreground", children: m ?? t.running(i, u) })
|
|
897
|
+
] }) : null,
|
|
898
|
+
a === "done" ? /* @__PURE__ */ s("p", { className: "text-sm text-foreground", children: t.done }) : null,
|
|
899
|
+
a === "error" ? /* @__PURE__ */ d("div", { className: "space-y-2", children: [
|
|
900
|
+
/* @__PURE__ */ s("p", { className: "text-sm text-destructive", children: l?.error ?? t.error }),
|
|
901
|
+
/* @__PURE__ */ s(H, { variant: "outline", size: "sm", onClick: w, children: t.retry })
|
|
902
|
+
] }) : null
|
|
903
|
+
] });
|
|
904
|
+
}
|
|
905
|
+
function vr({ children: e }) {
|
|
906
|
+
return /* @__PURE__ */ d(ct, { children: [
|
|
907
|
+
e,
|
|
908
|
+
/* @__PURE__ */ s(dt, {})
|
|
909
|
+
] });
|
|
910
|
+
}
|
|
911
|
+
const kt = "280px", Ct = "320px", Pt = "xl", Tt = {
|
|
912
|
+
gridTemplateColumns: `minmax(0, 1fr) minmax(${kt}, ${Ct})`
|
|
913
|
+
}, Ar = "grid grid-cols-[minmax(0,1fr)_minmax(280px,320px)] gap-4", Et = "space-y-6 lg:grid lg:grid-cols-[1fr_minmax(280px,320px)] lg:gap-6 lg:space-y-0", Rt = "max-h-[70vh]";
|
|
914
|
+
function Sr({
|
|
915
|
+
children: e,
|
|
916
|
+
sidebar: t,
|
|
917
|
+
className: r = ""
|
|
918
|
+
}) {
|
|
919
|
+
return t ? /* @__PURE__ */ d(
|
|
920
|
+
"div",
|
|
921
|
+
{
|
|
922
|
+
className: `grid gap-4 ${Rt} min-h-0 ${r}`.trim(),
|
|
923
|
+
style: Tt,
|
|
924
|
+
children: [
|
|
925
|
+
/* @__PURE__ */ s("div", { className: "min-h-0 min-w-0 overflow-y-auto pr-1", children: e }),
|
|
926
|
+
/* @__PURE__ */ s("div", { className: "min-h-0 min-w-0 overflow-y-auto", children: t })
|
|
927
|
+
]
|
|
928
|
+
}
|
|
929
|
+
) : /* @__PURE__ */ s("div", { className: r, children: e });
|
|
930
|
+
}
|
|
931
|
+
function _r(e, t) {
|
|
932
|
+
return e ? Pt : t;
|
|
933
|
+
}
|
|
934
|
+
function kr({ children: e, sidebar: t }) {
|
|
935
|
+
return t ? /* @__PURE__ */ d("div", { className: Et, children: [
|
|
936
|
+
/* @__PURE__ */ s("div", { className: "min-w-0 space-y-6", children: e }),
|
|
937
|
+
/* @__PURE__ */ s("div", { className: "lg:sticky lg:top-6 lg:self-start", children: t })
|
|
938
|
+
] }) : /* @__PURE__ */ s("div", { className: "space-y-6", children: e });
|
|
939
|
+
}
|
|
940
|
+
function Ft({
|
|
941
|
+
children: e,
|
|
942
|
+
className: t
|
|
943
|
+
}) {
|
|
944
|
+
return /* @__PURE__ */ s(
|
|
945
|
+
"div",
|
|
946
|
+
{
|
|
947
|
+
className: Be(
|
|
948
|
+
"rounded-lg border border-border bg-card px-3 py-2 text-sm text-foreground",
|
|
949
|
+
t
|
|
950
|
+
),
|
|
951
|
+
children: e
|
|
952
|
+
}
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
function Mt({
|
|
956
|
+
label: e,
|
|
957
|
+
children: t,
|
|
958
|
+
action: r,
|
|
959
|
+
className: n
|
|
960
|
+
}) {
|
|
961
|
+
return /* @__PURE__ */ d("div", { className: Be("rounded-lg border border-border bg-muted/30 p-3", n), children: [
|
|
962
|
+
/* @__PURE__ */ d("div", { className: "mb-2 flex items-center justify-between gap-2", children: [
|
|
963
|
+
/* @__PURE__ */ s("span", { className: "text-xs font-medium text-muted-foreground", children: e }),
|
|
964
|
+
r
|
|
965
|
+
] }),
|
|
966
|
+
/* @__PURE__ */ s("div", { className: "text-sm text-foreground", children: t })
|
|
967
|
+
] });
|
|
968
|
+
}
|
|
969
|
+
function Dt({
|
|
970
|
+
children: e,
|
|
971
|
+
...t
|
|
972
|
+
}) {
|
|
973
|
+
return /* @__PURE__ */ s(H, { type: "button", size: "sm", variant: "outline", ...t, children: e });
|
|
974
|
+
}
|
|
975
|
+
const It = {
|
|
976
|
+
refresh: "Refresh",
|
|
977
|
+
errorTitle: "Suggestions are temporarily unavailable",
|
|
978
|
+
errorDescription: "You can continue your work and try again later.",
|
|
979
|
+
applied: "Applied",
|
|
980
|
+
dismissed: "Dismissed",
|
|
981
|
+
attention: "Needs attention",
|
|
982
|
+
ready: "Ready to review",
|
|
983
|
+
unreadable: "This suggestion needs to be refreshed before it can be shown here. No business data was changed.",
|
|
984
|
+
sources: "Sources",
|
|
985
|
+
noSources: "No verifiable source was provided; do not use this for a critical update.",
|
|
986
|
+
confidence: "Confidence"
|
|
987
|
+
}, $t = {
|
|
988
|
+
panelTitle: "Suggested updates",
|
|
989
|
+
panelHint: "Review the latest recommendation for this record. Nothing changes until you choose an action.",
|
|
990
|
+
loadError: "Suggestions are temporarily unavailable. You can continue editing this record.",
|
|
991
|
+
emptyField: "This suggestion has no usable content.",
|
|
992
|
+
adopted: "Suggestion added to this record.",
|
|
993
|
+
adoptedAll: "Suggestions added to this record.",
|
|
994
|
+
applyError: "This suggestion could not be applied. Your other changes are still safe.",
|
|
995
|
+
applyAllError: "These suggestions could not be applied. Your other changes are still safe.",
|
|
996
|
+
emptyTitle: "No suggestion needs your attention",
|
|
997
|
+
noResults: "When there is a useful recommendation for this record, it will appear here for review.",
|
|
998
|
+
added: "Added",
|
|
999
|
+
adopt: "Use suggestion",
|
|
1000
|
+
adopting: "Adding…",
|
|
1001
|
+
adoptAll: "Use all suggested updates",
|
|
1002
|
+
statusApplied: "Previously applied",
|
|
1003
|
+
statusAttention: "Needs attention",
|
|
1004
|
+
statusReady: "Ready to review",
|
|
1005
|
+
sources: "Sources",
|
|
1006
|
+
noSources: "No verifiable source was provided.",
|
|
1007
|
+
confidence: "Confidence",
|
|
1008
|
+
confirmTitle: "Review changes before applying",
|
|
1009
|
+
confirmOne: "This will update {{field}} on the current business record. Check the suggested value and its source before continuing.",
|
|
1010
|
+
confirmAll: "This will update {{count}} fields on the current business record. Check every suggested value and its source before continuing.",
|
|
1011
|
+
confirmAction: "Apply changes",
|
|
1012
|
+
cancelAction: "Keep reviewing"
|
|
1013
|
+
}, Lt = {
|
|
1014
|
+
businessGuidance: It,
|
|
1015
|
+
suggestion: $t
|
|
1016
|
+
}, Ot = {
|
|
1017
|
+
refresh: "刷新",
|
|
1018
|
+
errorTitle: "建议暂时无法读取",
|
|
1019
|
+
errorDescription: "你可以继续处理当前工作,稍后再试。",
|
|
1020
|
+
applied: "已使用",
|
|
1021
|
+
dismissed: "已忽略",
|
|
1022
|
+
attention: "需要处理",
|
|
1023
|
+
ready: "待审核",
|
|
1024
|
+
unreadable: "这条建议需要重新生成后才能显示,当前业务数据没有发生变化。",
|
|
1025
|
+
sources: "信息来源",
|
|
1026
|
+
noSources: "没有可核对的信息来源,请勿用于关键业务更新。",
|
|
1027
|
+
confidence: "可信度"
|
|
1028
|
+
}, jt = {
|
|
1029
|
+
panelTitle: "建议更新",
|
|
1030
|
+
panelHint: "请核对当前记录的最新建议。只有选择操作后,业务数据才会变化。",
|
|
1031
|
+
loadError: "建议暂时无法读取,你仍可继续编辑当前记录。",
|
|
1032
|
+
emptyField: "这条建议没有可用内容。",
|
|
1033
|
+
adopted: "建议已加入当前记录。",
|
|
1034
|
+
adoptedAll: "建议已加入当前记录。",
|
|
1035
|
+
applyError: "这条建议未能加入,其他修改仍然安全。",
|
|
1036
|
+
applyAllError: "这些建议未能加入,其他修改仍然安全。",
|
|
1037
|
+
emptyTitle: "当前没有需要处理的建议",
|
|
1038
|
+
noResults: "有适合当前记录的建议时,会在这里显示并等待审核。",
|
|
1039
|
+
added: "已加入",
|
|
1040
|
+
adopt: "使用建议",
|
|
1041
|
+
adopting: "正在加入…",
|
|
1042
|
+
adoptAll: "使用全部建议",
|
|
1043
|
+
statusApplied: "已使用",
|
|
1044
|
+
statusAttention: "需要处理",
|
|
1045
|
+
statusReady: "待审核",
|
|
1046
|
+
sources: "信息来源",
|
|
1047
|
+
noSources: "没有可核对的信息来源。",
|
|
1048
|
+
confidence: "可信度",
|
|
1049
|
+
confirmTitle: "应用前请核对变更",
|
|
1050
|
+
confirmOne: "此操作会更新当前业务记录中的“{{field}}”。继续前请核对建议值及其信息来源。",
|
|
1051
|
+
confirmAll: "此操作会更新当前业务记录中的 {{count}} 个字段。继续前请逐项核对建议值及其信息来源。",
|
|
1052
|
+
confirmAction: "应用变更",
|
|
1053
|
+
cancelAction: "继续核对"
|
|
1054
|
+
}, zt = {
|
|
1055
|
+
businessGuidance: Ot,
|
|
1056
|
+
suggestion: jt
|
|
1057
|
+
};
|
|
1058
|
+
function Ue(e) {
|
|
1059
|
+
return e === "zh" ? zt : Lt;
|
|
1060
|
+
}
|
|
1061
|
+
function qe(e) {
|
|
1062
|
+
if (e == null || String(e).trim() === "") return null;
|
|
1063
|
+
const t = String(e).trim();
|
|
1064
|
+
try {
|
|
1065
|
+
const r = JSON.parse(t);
|
|
1066
|
+
return r && typeof r == "object" && !Array.isArray(r) ? r : { summary: r };
|
|
1067
|
+
} catch {
|
|
1068
|
+
return { summary: t };
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
function ae(e, t) {
|
|
1072
|
+
if (!t) return e;
|
|
1073
|
+
const r = t.split(".");
|
|
1074
|
+
let n = e;
|
|
1075
|
+
for (const a of r) {
|
|
1076
|
+
if (n == null || typeof n != "object") return;
|
|
1077
|
+
n = n[a];
|
|
1078
|
+
}
|
|
1079
|
+
return n;
|
|
1080
|
+
}
|
|
1081
|
+
function q(e, t = "en") {
|
|
1082
|
+
if (e == null) return "";
|
|
1083
|
+
if (typeof e == "string") return e;
|
|
1084
|
+
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1085
|
+
if (Array.isArray(e))
|
|
1086
|
+
return e.map((r) => q(r, t)).filter(Boolean).join(`
|
|
1087
|
+
`);
|
|
1088
|
+
if (typeof e == "object") {
|
|
1089
|
+
const r = e;
|
|
1090
|
+
return typeof r[t] == "string" ? r[t] : typeof r.zh == "string" ? r.zh : typeof r.en == "string" ? r.en : "";
|
|
1091
|
+
}
|
|
1092
|
+
return String(e);
|
|
1093
|
+
}
|
|
1094
|
+
function ve(e, t = "en") {
|
|
1095
|
+
if (e == null) return "";
|
|
1096
|
+
if (typeof e == "string") return e;
|
|
1097
|
+
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1098
|
+
if (Array.isArray(e))
|
|
1099
|
+
return e.map((r) => ve(r, t)).filter(Boolean).join(`
|
|
1100
|
+
• `);
|
|
1101
|
+
if (typeof e == "object") {
|
|
1102
|
+
const r = e;
|
|
1103
|
+
if ("zh" in r || "en" in r) return q(r, t);
|
|
1104
|
+
for (const n of [
|
|
1105
|
+
"summary",
|
|
1106
|
+
"recommendation",
|
|
1107
|
+
"description",
|
|
1108
|
+
"title",
|
|
1109
|
+
"message",
|
|
1110
|
+
"reason",
|
|
1111
|
+
"action",
|
|
1112
|
+
"suggestion"
|
|
1113
|
+
]) {
|
|
1114
|
+
const a = q(r[n], t);
|
|
1115
|
+
if (a) return a;
|
|
1116
|
+
}
|
|
1117
|
+
return "";
|
|
1118
|
+
}
|
|
1119
|
+
return String(e);
|
|
1120
|
+
}
|
|
1121
|
+
const Re = [
|
|
1122
|
+
"summary",
|
|
1123
|
+
"recommendation",
|
|
1124
|
+
"description",
|
|
1125
|
+
"conclusion",
|
|
1126
|
+
"diagnosis",
|
|
1127
|
+
"analysis_summary",
|
|
1128
|
+
"suggestion",
|
|
1129
|
+
"reason"
|
|
1130
|
+
], Gt = [
|
|
1131
|
+
"nextSteps",
|
|
1132
|
+
"next_steps",
|
|
1133
|
+
"nextActions",
|
|
1134
|
+
"next_actions",
|
|
1135
|
+
"recommendations",
|
|
1136
|
+
"risks",
|
|
1137
|
+
"issues",
|
|
1138
|
+
"anomalies",
|
|
1139
|
+
"stockAlerts",
|
|
1140
|
+
"stock_alerts"
|
|
1141
|
+
];
|
|
1142
|
+
function ie(e, t) {
|
|
1143
|
+
if (typeof e == "string") return e.trim();
|
|
1144
|
+
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
1145
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return "";
|
|
1146
|
+
const r = e, n = r[t];
|
|
1147
|
+
if (typeof n == "string") return n.trim();
|
|
1148
|
+
const a = t === "zh" ? r.en : r.zh;
|
|
1149
|
+
return typeof a == "string" ? a.trim() : "";
|
|
1150
|
+
}
|
|
1151
|
+
function Ae(e, t) {
|
|
1152
|
+
if (Array.isArray(e))
|
|
1153
|
+
return e.flatMap((n) => {
|
|
1154
|
+
const a = ie(n, t);
|
|
1155
|
+
if (a) return [a];
|
|
1156
|
+
if (!n || typeof n != "object") return [];
|
|
1157
|
+
const o = n;
|
|
1158
|
+
for (const l of ["message", "title", "description", "reason", "action", "suggestion"]) {
|
|
1159
|
+
const i = ie(o[l], t);
|
|
1160
|
+
if (i) return [i];
|
|
1161
|
+
}
|
|
1162
|
+
return [];
|
|
1163
|
+
}).filter(Boolean);
|
|
1164
|
+
const r = ie(e, t);
|
|
1165
|
+
return r ? [r] : [];
|
|
1166
|
+
}
|
|
1167
|
+
function Bt(e) {
|
|
1168
|
+
const t = e.output;
|
|
1169
|
+
return t && typeof t == "object" && !Array.isArray(t) ? t : e;
|
|
1170
|
+
}
|
|
1171
|
+
function Vt(e, t) {
|
|
1172
|
+
const r = [e.sources, e.source_refs, e.citations, e.references];
|
|
1173
|
+
return [...new Set(r.flatMap((n) => Ae(n, t)))].slice(0, 5);
|
|
1174
|
+
}
|
|
1175
|
+
function Ut(e) {
|
|
1176
|
+
const t = e.confidence ?? e.confidence_score, r = Number(t);
|
|
1177
|
+
return Number.isFinite(r) ? Math.max(0, Math.min(1, r > 1 ? r / 100 : r)) : null;
|
|
1178
|
+
}
|
|
1179
|
+
function Ke(e, t) {
|
|
1180
|
+
const r = qe(e);
|
|
1181
|
+
if (!r) return null;
|
|
1182
|
+
const n = Bt(r);
|
|
1183
|
+
let a = "", o = null;
|
|
1184
|
+
for (const i of Re)
|
|
1185
|
+
if (a = ie(n[i], t), a) {
|
|
1186
|
+
o = i;
|
|
1187
|
+
break;
|
|
1188
|
+
}
|
|
1189
|
+
const l = [];
|
|
1190
|
+
for (const i of Re)
|
|
1191
|
+
i !== o && l.push(...Ae(n[i], t));
|
|
1192
|
+
for (const i of Gt)
|
|
1193
|
+
l.push(...Ae(n[i], t));
|
|
1194
|
+
return !a && l.length > 0 && (a = l.shift() ?? ""), a ? {
|
|
1195
|
+
summary: a,
|
|
1196
|
+
details: [...new Set(l)].filter((i) => i !== a).slice(0, 5),
|
|
1197
|
+
sources: Vt(n, t),
|
|
1198
|
+
confidence: Ut(n)
|
|
1199
|
+
} : null;
|
|
1200
|
+
}
|
|
1201
|
+
function qt(e) {
|
|
1202
|
+
const t = String(e ?? "").toLowerCase();
|
|
1203
|
+
return ["adopted", "accepted", "applied"].includes(t) ? "applied" : ["dismissed", "rejected", "ignored"].includes(t) ? "dismissed" : ["failed", "error", "blocked"].includes(t) ? "attention" : "ready";
|
|
1204
|
+
}
|
|
1205
|
+
function He(e, { sourceRecordKey: t, owners: r, limit: n }) {
|
|
1206
|
+
if (r.length === 0 || n <= 0) return [];
|
|
1207
|
+
const a = new Set(r);
|
|
1208
|
+
return [
|
|
1209
|
+
...new Map(e.map((o) => [o.id, o])).values()
|
|
1210
|
+
].filter(
|
|
1211
|
+
(o) => !t || String(o.source_record_key ?? "") === String(t)
|
|
1212
|
+
).filter((o) => !!o.owner && a.has(String(o.owner))).sort((o, l) => {
|
|
1213
|
+
const i = o.created_at ? Date.parse(o.created_at) : 0, u = l.created_at ? Date.parse(l.created_at) : 0;
|
|
1214
|
+
return (Number.isFinite(u) ? u : 0) - (Number.isFinite(i) ? i : 0);
|
|
1215
|
+
}).slice(0, n);
|
|
1216
|
+
}
|
|
1217
|
+
function Cr({
|
|
1218
|
+
recordId: e,
|
|
1219
|
+
resultsTable: t,
|
|
1220
|
+
businessTable: r,
|
|
1221
|
+
client: n,
|
|
1222
|
+
fields: a,
|
|
1223
|
+
sourceRecordKey: o,
|
|
1224
|
+
disabled: l,
|
|
1225
|
+
className: i = "",
|
|
1226
|
+
onAdopted: u,
|
|
1227
|
+
lang: m,
|
|
1228
|
+
owners: w,
|
|
1229
|
+
title: g,
|
|
1230
|
+
description: y,
|
|
1231
|
+
emptyTitle: p,
|
|
1232
|
+
emptyDescription: f,
|
|
1233
|
+
applyLabel: v,
|
|
1234
|
+
applyAllLabel: P,
|
|
1235
|
+
successMessage: T,
|
|
1236
|
+
allowEditing: j = !0
|
|
1237
|
+
}) {
|
|
1238
|
+
const { i18n: E } = Se(), k = m ?? (E.resolvedLanguage?.toLowerCase().startsWith("zh") ? "zh" : "en"), h = Je(k), [R, I] = N(!1), [$, _] = N(null), [M, x] = N(null), [S, C] = N(null), [G, B] = N({}), [F, V] = N(/* @__PURE__ */ new Set()), [X, K] = N(null), Q = o ?? e, O = be(() => qe(S?.summary), [S?.summary]), Z = be(() => Ke(S?.summary, k), [k, S?.summary]), ee = w?.join("\0") ?? "", re = a.map((c) => `${c.targetField}:${c.summaryPath}`).join("|"), te = L(async () => {
|
|
1239
|
+
if (!Q) {
|
|
1240
|
+
C(null);
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
I(!0), x(null);
|
|
1244
|
+
try {
|
|
1245
|
+
const c = ee ? new Set(ee.split("\0")) : null, A = c ? [...c] : [], U = await Promise.all(
|
|
1246
|
+
A.map(
|
|
1247
|
+
(z) => n.list(t, {
|
|
1248
|
+
filters: {
|
|
1249
|
+
source_record_key: Q,
|
|
1250
|
+
...z ? { owner: z } : {}
|
|
1251
|
+
},
|
|
1252
|
+
limit: 20
|
|
1253
|
+
})
|
|
1254
|
+
)
|
|
1255
|
+
), J = He(
|
|
1256
|
+
U.flatMap((z) => z.items ?? []),
|
|
1257
|
+
{
|
|
1258
|
+
sourceRecordKey: Q,
|
|
1259
|
+
owners: c ? [...c] : [],
|
|
1260
|
+
limit: 1
|
|
1261
|
+
}
|
|
1262
|
+
);
|
|
1263
|
+
C(J[0] ?? null);
|
|
1264
|
+
} catch (c) {
|
|
1265
|
+
console.error(`[GeniApp] ${t} record guidance load failed`, c), x(h.loadError), C(null);
|
|
1266
|
+
} finally {
|
|
1267
|
+
I(!1);
|
|
1268
|
+
}
|
|
1269
|
+
}, [n, h.loadError, Q, ee, t]);
|
|
1270
|
+
Y(() => {
|
|
1271
|
+
te();
|
|
1272
|
+
}, [te]), Y(() => {
|
|
1273
|
+
if (!O) {
|
|
1274
|
+
B({});
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
const c = {};
|
|
1278
|
+
for (const A of a) {
|
|
1279
|
+
const U = ae(O, A.summaryPath), J = A.toValue ? A.toValue(U, O, k) : U, z = ve(J, k);
|
|
1280
|
+
z && (c[A.targetField] = z);
|
|
1281
|
+
}
|
|
1282
|
+
B(c), V(/* @__PURE__ */ new Set());
|
|
1283
|
+
}, [re, O, k]);
|
|
1284
|
+
const ne = async (c) => {
|
|
1285
|
+
if (!e || !O) return;
|
|
1286
|
+
const A = ae(O, c.summaryPath), U = c.toValue ? c.toValue(A, O, k) : A, J = G[c.targetField], z = j && typeof J == "string" ? J.trim() : U;
|
|
1287
|
+
if (z == null || typeof z == "string" && z.trim() === "") {
|
|
1288
|
+
x(h.emptyField);
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
_(c.targetField), x(null);
|
|
1292
|
+
try {
|
|
1293
|
+
const W = { [c.targetField]: z };
|
|
1294
|
+
await n.update(r, e, W), u?.(W), V((pe) => new Set(pe).add(c.targetField)), Ce({
|
|
1295
|
+
title: T ?? h.adopted,
|
|
1296
|
+
variant: "success"
|
|
1297
|
+
});
|
|
1298
|
+
} catch (W) {
|
|
1299
|
+
console.error(`[GeniApp] ${r} suggestion apply failed`, W), x(h.applyError);
|
|
1300
|
+
} finally {
|
|
1301
|
+
_(null);
|
|
1302
|
+
}
|
|
1303
|
+
}, b = async () => {
|
|
1304
|
+
if (!(!e || !O)) {
|
|
1305
|
+
_("__all__"), x(null);
|
|
1306
|
+
try {
|
|
1307
|
+
const c = {};
|
|
1308
|
+
for (const A of a) {
|
|
1309
|
+
const U = ae(O, A.summaryPath), J = A.toValue ? A.toValue(U, O, k) : U, z = G[A.targetField], W = j && typeof z == "string" ? z.trim() : J;
|
|
1310
|
+
W != null && !(typeof W == "string" && W.trim() === "") && (c[A.targetField] = W);
|
|
1311
|
+
}
|
|
1312
|
+
if (Object.keys(c).length === 0) {
|
|
1313
|
+
x(h.emptyField);
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
await n.update(r, e, c), u?.(c), V(new Set(Object.keys(c))), Ce({
|
|
1317
|
+
title: T ?? h.adoptedAll,
|
|
1318
|
+
variant: "success"
|
|
1319
|
+
});
|
|
1320
|
+
} catch (c) {
|
|
1321
|
+
console.error(`[GeniApp] ${r} suggestions apply failed`, c), x(h.applyAllError);
|
|
1322
|
+
} finally {
|
|
1323
|
+
_(null);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
return e ? /* @__PURE__ */ d(
|
|
1328
|
+
oe,
|
|
1329
|
+
{
|
|
1330
|
+
className: `border-accent/30 bg-card ${i}`,
|
|
1331
|
+
"aria-label": g ?? h.panelTitle,
|
|
1332
|
+
children: [
|
|
1333
|
+
/* @__PURE__ */ s(le, { className: "pb-3", children: /* @__PURE__ */ d("div", { className: "flex items-start gap-2", children: [
|
|
1334
|
+
/* @__PURE__ */ s("div", { className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-accent text-accent-foreground", children: /* @__PURE__ */ s(Le, { className: "h-4 w-4", "aria-hidden": !0 }) }),
|
|
1335
|
+
/* @__PURE__ */ d("div", { className: "min-w-0", children: [
|
|
1336
|
+
/* @__PURE__ */ s(ce, { className: "text-sm", children: g ?? h.panelTitle }),
|
|
1337
|
+
/* @__PURE__ */ s(de, { children: y ?? h.panelHint })
|
|
1338
|
+
] })
|
|
1339
|
+
] }) }),
|
|
1340
|
+
/* @__PURE__ */ d(ue, { className: "space-y-3 pt-0", children: [
|
|
1341
|
+
R && /* @__PURE__ */ d("div", { className: "space-y-2", "aria-busy": "true", children: [
|
|
1342
|
+
/* @__PURE__ */ s(fe, { className: "h-4 w-3/4" }),
|
|
1343
|
+
/* @__PURE__ */ s(fe, { className: "h-16 w-full" })
|
|
1344
|
+
] }),
|
|
1345
|
+
!R && !S && /* @__PURE__ */ d("div", { className: "rounded-lg border border-dashed border-border px-3 py-4", children: [
|
|
1346
|
+
/* @__PURE__ */ s("p", { className: "text-sm font-medium text-foreground", children: p ?? h.emptyTitle }),
|
|
1347
|
+
/* @__PURE__ */ s("p", { className: "mt-1 text-sm leading-5 text-muted-foreground", children: f ?? h.noResults })
|
|
1348
|
+
] }),
|
|
1349
|
+
!R && S && /* @__PURE__ */ d(Ie, { children: [
|
|
1350
|
+
/* @__PURE__ */ s(Kt, { result: S, language: k }),
|
|
1351
|
+
O?.summary != null && typeof O.summary == "string" && a.length === 0 && /* @__PURE__ */ s(Ft, { children: /* @__PURE__ */ s("p", { className: "whitespace-pre-wrap", children: O.summary }) }),
|
|
1352
|
+
a.map((c) => {
|
|
1353
|
+
const A = O ? ae(O, c.summaryPath) : void 0, U = c.toValue ? c.toValue(A, O, k) : A, J = ve(U, k);
|
|
1354
|
+
if (!J) return null;
|
|
1355
|
+
const z = F.has(c.targetField);
|
|
1356
|
+
return /* @__PURE__ */ s(
|
|
1357
|
+
Mt,
|
|
1358
|
+
{
|
|
1359
|
+
label: c.label,
|
|
1360
|
+
action: /* @__PURE__ */ d(
|
|
1361
|
+
Dt,
|
|
1362
|
+
{
|
|
1363
|
+
disabled: l || $ != null || z,
|
|
1364
|
+
onClick: () => K(c.targetField),
|
|
1365
|
+
children: [
|
|
1366
|
+
$ === c.targetField ? /* @__PURE__ */ s(xe, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ s($e, { className: "h-3 w-3" }),
|
|
1367
|
+
z ? h.added : v ?? h.adopt
|
|
1368
|
+
]
|
|
1369
|
+
}
|
|
1370
|
+
),
|
|
1371
|
+
children: j ? /* @__PURE__ */ s(
|
|
1372
|
+
"textarea",
|
|
1373
|
+
{
|
|
1374
|
+
value: G[c.targetField] ?? J,
|
|
1375
|
+
onChange: (W) => B((pe) => ({
|
|
1376
|
+
...pe,
|
|
1377
|
+
[c.targetField]: W.target.value
|
|
1378
|
+
})),
|
|
1379
|
+
rows: Math.min(6, Math.max(2, (G[c.targetField] ?? J).split(`
|
|
1380
|
+
`).length)),
|
|
1381
|
+
className: "w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm leading-5 text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1382
|
+
"aria-label": c.label
|
|
1383
|
+
}
|
|
1384
|
+
) : /* @__PURE__ */ s("p", { className: "whitespace-pre-wrap leading-5", children: J })
|
|
1385
|
+
},
|
|
1386
|
+
c.targetField
|
|
1387
|
+
);
|
|
1388
|
+
}),
|
|
1389
|
+
a.length > 1 && /* @__PURE__ */ s(
|
|
1390
|
+
H,
|
|
1391
|
+
{
|
|
1392
|
+
type: "button",
|
|
1393
|
+
variant: "outline",
|
|
1394
|
+
className: "w-full",
|
|
1395
|
+
disabled: l || $ != null,
|
|
1396
|
+
onClick: () => K("__all__"),
|
|
1397
|
+
children: $ === "__all__" ? h.adopting : P ?? h.adoptAll
|
|
1398
|
+
}
|
|
1399
|
+
)
|
|
1400
|
+
] }),
|
|
1401
|
+
M && /* @__PURE__ */ s("p", { className: "text-sm text-destructive", role: "alert", children: M }),
|
|
1402
|
+
S ? /* @__PURE__ */ d("div", { className: "rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground", children: [
|
|
1403
|
+
/* @__PURE__ */ s("p", { className: "font-medium text-foreground", children: h.sources }),
|
|
1404
|
+
/* @__PURE__ */ s("p", { className: "mt-1", children: Z?.sources.length ? Z.sources.join(" · ") : h.noSources }),
|
|
1405
|
+
Z?.confidence != null ? /* @__PURE__ */ d("p", { className: "mt-1", children: [
|
|
1406
|
+
h.confidence,
|
|
1407
|
+
": ",
|
|
1408
|
+
Math.round(Z.confidence * 100),
|
|
1409
|
+
"%"
|
|
1410
|
+
] }) : null
|
|
1411
|
+
] }) : null
|
|
1412
|
+
] }),
|
|
1413
|
+
/* @__PURE__ */ s(
|
|
1414
|
+
ut,
|
|
1415
|
+
{
|
|
1416
|
+
isOpen: X != null,
|
|
1417
|
+
type: "info",
|
|
1418
|
+
title: h.confirmTitle,
|
|
1419
|
+
message: X === "__all__" ? h.confirmAll.replace("{{count}}", String(a.length)) : h.confirmOne.replace("{{field}}", a.find((c) => c.targetField === X)?.label ?? ""),
|
|
1420
|
+
confirmText: h.confirmAction,
|
|
1421
|
+
cancelText: h.cancelAction,
|
|
1422
|
+
showCancel: !0,
|
|
1423
|
+
loading: $ != null,
|
|
1424
|
+
onClose: () => K(null),
|
|
1425
|
+
onCancel: () => K(null),
|
|
1426
|
+
onConfirm: () => {
|
|
1427
|
+
const c = X;
|
|
1428
|
+
if (K(null), c === "__all__") b();
|
|
1429
|
+
else {
|
|
1430
|
+
const A = a.find((U) => U.targetField === c);
|
|
1431
|
+
A && ne(A);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
)
|
|
1436
|
+
]
|
|
1437
|
+
}
|
|
1438
|
+
) : null;
|
|
1439
|
+
}
|
|
1440
|
+
function Kt({ result: e, language: t }) {
|
|
1441
|
+
const r = Je(t), n = String(e.status ?? "").toLowerCase(), a = ["adopted", "accepted", "applied"].includes(n) ? r.statusApplied : ["failed", "error", "blocked"].includes(n) ? r.statusAttention : r.statusReady;
|
|
1442
|
+
return /* @__PURE__ */ d("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
|
|
1443
|
+
/* @__PURE__ */ s(Ge, { variant: "secondary", children: a }),
|
|
1444
|
+
e.created_at && Fe(e.created_at, t) && /* @__PURE__ */ s("time", { dateTime: e.created_at, children: Fe(e.created_at, t) })
|
|
1445
|
+
] });
|
|
1446
|
+
}
|
|
1447
|
+
function Fe(e, t) {
|
|
1448
|
+
const r = new Date(e);
|
|
1449
|
+
return Number.isNaN(r.getTime()) ? "" : new Intl.DateTimeFormat(t === "zh" ? "zh-CN" : "en-US", {
|
|
1450
|
+
dateStyle: "medium",
|
|
1451
|
+
timeStyle: "short"
|
|
1452
|
+
}).format(r);
|
|
1453
|
+
}
|
|
1454
|
+
function Je(e) {
|
|
1455
|
+
return Ue(e).suggestion;
|
|
1456
|
+
}
|
|
1457
|
+
const Pr = (e) => {
|
|
1458
|
+
const t = [
|
|
1459
|
+
{
|
|
1460
|
+
label: e.description,
|
|
1461
|
+
summaryPath: "description",
|
|
1462
|
+
targetField: "description",
|
|
1463
|
+
toValue: (r, n, a) => q(r, a ?? "en")
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
label: e.descriptionSale,
|
|
1467
|
+
summaryPath: "highlights",
|
|
1468
|
+
targetField: "description_sale",
|
|
1469
|
+
toValue: (r, n, a) => Array.isArray(r) ? r.map(String).join(`
|
|
1470
|
+
• `) : q(r, a ?? "en")
|
|
1471
|
+
}
|
|
1472
|
+
];
|
|
1473
|
+
return e.name && t.unshift({
|
|
1474
|
+
label: e.name,
|
|
1475
|
+
summaryPath: "title",
|
|
1476
|
+
targetField: "name",
|
|
1477
|
+
toValue: (r, n, a) => q(r, a ?? "en")
|
|
1478
|
+
}), t;
|
|
1479
|
+
};
|
|
1480
|
+
function Tr({
|
|
1481
|
+
client: e,
|
|
1482
|
+
resultsTable: t,
|
|
1483
|
+
title: r,
|
|
1484
|
+
description: n,
|
|
1485
|
+
emptyTitle: a,
|
|
1486
|
+
emptyDescription: o,
|
|
1487
|
+
unreadableText: l,
|
|
1488
|
+
sourceRecordKey: i,
|
|
1489
|
+
owners: u,
|
|
1490
|
+
limit: m = 3,
|
|
1491
|
+
className: w = "",
|
|
1492
|
+
footer: g,
|
|
1493
|
+
renderAction: y
|
|
1494
|
+
}) {
|
|
1495
|
+
const { i18n: p } = Se(), f = p.resolvedLanguage?.toLowerCase().startsWith("zh") ? "zh" : "en", v = Ue(f).businessGuidance, [P, T] = N([]), [j, E] = N(!0), [k, h] = N(!1), R = u?.join("\0") ?? "", I = L(async () => {
|
|
1496
|
+
E(!0), h(!1);
|
|
1497
|
+
try {
|
|
1498
|
+
const _ = R ? new Set(R.split("\0")) : null, M = _ ? [..._] : [], x = await Promise.all(
|
|
1499
|
+
M.map(
|
|
1500
|
+
(S) => e.list(t, {
|
|
1501
|
+
filters: {
|
|
1502
|
+
...i ? { source_record_key: i } : {},
|
|
1503
|
+
...S ? { owner: S } : {}
|
|
1504
|
+
},
|
|
1505
|
+
limit: Math.max(m * 4, 20)
|
|
1506
|
+
})
|
|
1507
|
+
)
|
|
1508
|
+
);
|
|
1509
|
+
T(
|
|
1510
|
+
He(
|
|
1511
|
+
x.flatMap((S) => S.items ?? []),
|
|
1512
|
+
{
|
|
1513
|
+
sourceRecordKey: i,
|
|
1514
|
+
owners: _ ? [..._] : [],
|
|
1515
|
+
limit: m
|
|
1516
|
+
}
|
|
1517
|
+
)
|
|
1518
|
+
);
|
|
1519
|
+
} catch (_) {
|
|
1520
|
+
console.error(`[GeniApp] ${t} guidance load failed`, _), T([]), h(!0);
|
|
1521
|
+
} finally {
|
|
1522
|
+
E(!1);
|
|
1523
|
+
}
|
|
1524
|
+
}, [e, m, R, t, i]);
|
|
1525
|
+
Y(() => {
|
|
1526
|
+
I();
|
|
1527
|
+
}, [I]);
|
|
1528
|
+
const $ = be(
|
|
1529
|
+
() => P.map((_) => ({ row: _, content: Ke(_.summary, f) })),
|
|
1530
|
+
[f, P]
|
|
1531
|
+
);
|
|
1532
|
+
return /* @__PURE__ */ d(oe, { className: `border-border bg-card ${w}`, "aria-label": r, children: [
|
|
1533
|
+
/* @__PURE__ */ d(le, { className: "gap-3 pb-3 sm:flex-row sm:items-start sm:justify-between", children: [
|
|
1534
|
+
/* @__PURE__ */ d("div", { className: "flex min-w-0 items-start gap-3", children: [
|
|
1535
|
+
/* @__PURE__ */ s("div", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/40 text-foreground", children: /* @__PURE__ */ s(Le, { className: "h-4 w-4", "aria-hidden": !0 }) }),
|
|
1536
|
+
/* @__PURE__ */ d("div", { className: "min-w-0", children: [
|
|
1537
|
+
/* @__PURE__ */ s(ce, { className: "text-base", children: r }),
|
|
1538
|
+
/* @__PURE__ */ s(de, { className: "mt-1 max-w-3xl leading-5", children: n })
|
|
1539
|
+
] })
|
|
1540
|
+
] }),
|
|
1541
|
+
/* @__PURE__ */ d(H, { type: "button", variant: "ghost", size: "sm", className: "shrink-0", onClick: () => void I(), children: [
|
|
1542
|
+
/* @__PURE__ */ s(Ze, { className: "mr-1.5 h-3.5 w-3.5", "aria-hidden": !0 }),
|
|
1543
|
+
v.refresh
|
|
1544
|
+
] })
|
|
1545
|
+
] }),
|
|
1546
|
+
/* @__PURE__ */ d(ue, { className: "space-y-3 pt-0", children: [
|
|
1547
|
+
j ? /* @__PURE__ */ d("div", { className: "space-y-3", "aria-busy": "true", children: [
|
|
1548
|
+
/* @__PURE__ */ s(fe, { className: "h-20 w-full" }),
|
|
1549
|
+
/* @__PURE__ */ s(fe, { className: "h-20 w-full" })
|
|
1550
|
+
] }) : k ? /* @__PURE__ */ d("div", { className: "flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-sm", role: "alert", children: [
|
|
1551
|
+
/* @__PURE__ */ s(et, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive", "aria-hidden": !0 }),
|
|
1552
|
+
/* @__PURE__ */ d("div", { children: [
|
|
1553
|
+
/* @__PURE__ */ s("p", { className: "font-medium text-foreground", children: v.errorTitle }),
|
|
1554
|
+
/* @__PURE__ */ s("p", { className: "mt-0.5 text-muted-foreground", children: v.errorDescription })
|
|
1555
|
+
] })
|
|
1556
|
+
] }) : $.length === 0 ? /* @__PURE__ */ s("div", { className: "rounded-lg border border-dashed border-border px-4 py-5", children: /* @__PURE__ */ d("div", { className: "flex items-start gap-2", children: [
|
|
1557
|
+
/* @__PURE__ */ s(tt, { className: "mt-0.5 h-4 w-4 shrink-0 text-status-success", "aria-hidden": !0 }),
|
|
1558
|
+
/* @__PURE__ */ d("div", { children: [
|
|
1559
|
+
/* @__PURE__ */ s("p", { className: "text-sm font-medium text-foreground", children: a }),
|
|
1560
|
+
/* @__PURE__ */ s("p", { className: "mt-1 text-sm leading-5 text-muted-foreground", children: o })
|
|
1561
|
+
] })
|
|
1562
|
+
] }) }) : $.map(({ row: _, content: M }) => {
|
|
1563
|
+
const x = qt(_.status);
|
|
1564
|
+
return /* @__PURE__ */ s("article", { className: "rounded-lg border border-border p-4", children: /* @__PURE__ */ d("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [
|
|
1565
|
+
/* @__PURE__ */ d("div", { className: "min-w-0 flex-1", children: [
|
|
1566
|
+
/* @__PURE__ */ d("div", { className: "mb-2 flex flex-wrap items-center gap-2", children: [
|
|
1567
|
+
/* @__PURE__ */ s(Ge, { variant: x === "attention" ? "destructive" : "secondary", children: x === "applied" ? v.applied : x === "dismissed" ? v.dismissed : x === "attention" ? v.attention : v.ready }),
|
|
1568
|
+
_.created_at ? /* @__PURE__ */ s("time", { className: "text-xs text-muted-foreground", dateTime: _.created_at, children: Ht(_.created_at, f) }) : null
|
|
1569
|
+
] }),
|
|
1570
|
+
M ? /* @__PURE__ */ d(Ie, { children: [
|
|
1571
|
+
/* @__PURE__ */ s("p", { className: "text-sm font-medium leading-6 text-foreground", children: M.summary }),
|
|
1572
|
+
M.details.length > 0 ? /* @__PURE__ */ s("ul", { className: "mt-2 space-y-1.5 text-sm leading-5 text-muted-foreground", children: M.details.map((S) => /* @__PURE__ */ d("li", { className: "flex gap-2", children: [
|
|
1573
|
+
/* @__PURE__ */ s("span", { "aria-hidden": !0, children: "•" }),
|
|
1574
|
+
/* @__PURE__ */ s("span", { children: S })
|
|
1575
|
+
] }, S)) }) : null,
|
|
1576
|
+
/* @__PURE__ */ d("div", { className: "mt-3 flex flex-wrap gap-3 text-xs text-muted-foreground", children: [
|
|
1577
|
+
M.sources.length > 0 ? /* @__PURE__ */ d("span", { children: [
|
|
1578
|
+
v.sources,
|
|
1579
|
+
": ",
|
|
1580
|
+
M.sources.join(" · ")
|
|
1581
|
+
] }) : /* @__PURE__ */ s("span", { children: v.noSources }),
|
|
1582
|
+
M.confidence != null ? /* @__PURE__ */ d("span", { children: [
|
|
1583
|
+
v.confidence,
|
|
1584
|
+
": ",
|
|
1585
|
+
Math.round(M.confidence * 100),
|
|
1586
|
+
"%"
|
|
1587
|
+
] }) : null
|
|
1588
|
+
] })
|
|
1589
|
+
] }) : /* @__PURE__ */ s("p", { className: "text-sm leading-5 text-muted-foreground", children: l ?? v.unreadable })
|
|
1590
|
+
] }),
|
|
1591
|
+
y ? /* @__PURE__ */ s("div", { className: "shrink-0", children: y(_) }) : null
|
|
1592
|
+
] }) }, _.id);
|
|
1593
|
+
}),
|
|
1594
|
+
g
|
|
1595
|
+
] })
|
|
1596
|
+
] });
|
|
1597
|
+
}
|
|
1598
|
+
function Ht(e, t) {
|
|
1599
|
+
const r = new Date(e);
|
|
1600
|
+
return Number.isNaN(r.getTime()) ? "" : new Intl.DateTimeFormat(t === "zh" ? "zh-CN" : "en-US", {
|
|
1601
|
+
dateStyle: "medium",
|
|
1602
|
+
timeStyle: "short"
|
|
1603
|
+
}).format(r);
|
|
1604
|
+
}
|
|
1605
|
+
function Er(e, t) {
|
|
1606
|
+
return {
|
|
1607
|
+
label: e,
|
|
1608
|
+
summaryPath: "summary",
|
|
1609
|
+
targetField: t,
|
|
1610
|
+
toValue: (r, n, a) => q(r, a ?? "en")
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
function Rr(e) {
|
|
1614
|
+
return {
|
|
1615
|
+
label: e,
|
|
1616
|
+
summaryPath: "narration",
|
|
1617
|
+
targetField: "narration",
|
|
1618
|
+
toValue: (t, r, n) => q(t, n ?? "en")
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
function Fr(e, t = "ref") {
|
|
1622
|
+
return {
|
|
1623
|
+
label: e,
|
|
1624
|
+
summaryPath: "recommendation",
|
|
1625
|
+
targetField: t,
|
|
1626
|
+
toValue: (r, n, a) => q(r, a ?? "en")
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
function Mr(e, t = "synopsis") {
|
|
1630
|
+
return {
|
|
1631
|
+
label: e,
|
|
1632
|
+
summaryPath: "synopsis",
|
|
1633
|
+
targetField: t,
|
|
1634
|
+
toValue: (r, n, a) => q(r, a ?? "en")
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
function Dr(e, t = "note") {
|
|
1638
|
+
return {
|
|
1639
|
+
label: e,
|
|
1640
|
+
summaryPath: "note",
|
|
1641
|
+
targetField: t,
|
|
1642
|
+
toValue: (r, n, a) => q(r, a ?? "en")
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
function Ir(e) {
|
|
1646
|
+
return {
|
|
1647
|
+
label: e,
|
|
1648
|
+
summaryPath: "internal_notes",
|
|
1649
|
+
targetField: "internal_notes",
|
|
1650
|
+
toValue: (t, r, n) => q(t, n ?? "en")
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
function $r(e) {
|
|
1654
|
+
return {
|
|
1655
|
+
label: e,
|
|
1656
|
+
summaryPath: "job_title",
|
|
1657
|
+
targetField: "job_title",
|
|
1658
|
+
toValue: (t, r, n) => q(t, n ?? "en")
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
function Lr(e, t = "description") {
|
|
1662
|
+
return {
|
|
1663
|
+
label: e,
|
|
1664
|
+
summaryPath: "description",
|
|
1665
|
+
targetField: t,
|
|
1666
|
+
toValue: (r, n, a) => q(r, a ?? "en")
|
|
1667
|
+
};
|
|
1668
|
+
}
|
|
1669
|
+
function Or(e, t, r, n) {
|
|
1670
|
+
return {
|
|
1671
|
+
label: e,
|
|
1672
|
+
summaryPath: t,
|
|
1673
|
+
targetField: r,
|
|
1674
|
+
toValue: (a, o, l) => {
|
|
1675
|
+
const i = q(a, l ?? "en").trim(), u = n?.trim() ?? "";
|
|
1676
|
+
return !i || u === i || u.includes(i) ? u || i : u ? `${u}
|
|
1677
|
+
|
|
1678
|
+
${i}` : i;
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
const Ye = "partner", We = "partner_record_picker";
|
|
1683
|
+
async function Xe(e, t) {
|
|
1684
|
+
if (!e || !t) return !1;
|
|
1685
|
+
const r = ke(e, t);
|
|
1686
|
+
return await _e(r, We, Ye) != null;
|
|
1687
|
+
}
|
|
1688
|
+
function Me(e) {
|
|
1689
|
+
const t = String(e.id ?? "").trim(), r = String(e.primary ?? e.display_name ?? e.legal_name ?? "").trim();
|
|
1690
|
+
if (!t || !r) return null;
|
|
1691
|
+
const n = String(e.secondary ?? e.partner_number ?? "").trim(), a = Jt(e.snapshot);
|
|
1692
|
+
return {
|
|
1693
|
+
id: t,
|
|
1694
|
+
label: r,
|
|
1695
|
+
...n ? { secondary: n } : {},
|
|
1696
|
+
...a ? { snapshot: a } : {}
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
function Jt(e) {
|
|
1700
|
+
if (e && typeof e == "object" && !Array.isArray(e))
|
|
1701
|
+
return e;
|
|
1702
|
+
if (!(typeof e != "string" || e.trim() === ""))
|
|
1703
|
+
try {
|
|
1704
|
+
const t = JSON.parse(e);
|
|
1705
|
+
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
1706
|
+
} catch {
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
async function De(e, t, r, n) {
|
|
1711
|
+
return Ve(e, t, Ye, We, {
|
|
1712
|
+
role: r.role ?? "",
|
|
1713
|
+
party_type: r.partyType ?? "",
|
|
1714
|
+
legal_entity_ref: r.legalEntityRef ?? "",
|
|
1715
|
+
id: n.id ?? "",
|
|
1716
|
+
search: "",
|
|
1717
|
+
limit: n.limit,
|
|
1718
|
+
offset: n.offset
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
async function Yt(e, t, r = {}) {
|
|
1722
|
+
if (!e || !t || !await Xe(e, t)) return [];
|
|
1723
|
+
const n = Math.min(Math.max(r.limit ?? 100, 1), 100), a = /* @__PURE__ */ new Map();
|
|
1724
|
+
let o = Math.max(r.offset ?? 0, 0);
|
|
1725
|
+
for (; ; ) {
|
|
1726
|
+
const l = await De(e, t, r, { limit: n, offset: o });
|
|
1727
|
+
for (const i of l) {
|
|
1728
|
+
const u = Me(i);
|
|
1729
|
+
u && a.set(u.id, u);
|
|
1730
|
+
}
|
|
1731
|
+
if (l.length < n || (o += n, o > 5e3)) break;
|
|
1732
|
+
}
|
|
1733
|
+
return await Promise.all((r.ensureIds ?? []).filter((l) => l && !a.has(l)).map(async (l) => {
|
|
1734
|
+
const i = await De(e, t, r, { id: l, limit: 1, offset: 0 }), u = i.length > 0 ? Me(i[0]) : null;
|
|
1735
|
+
u && a.set(u.id, u);
|
|
1736
|
+
})), [...a.values()];
|
|
1737
|
+
}
|
|
1738
|
+
function Wt() {
|
|
1739
|
+
try {
|
|
1740
|
+
return localStorage.getItem("token");
|
|
1741
|
+
} catch {
|
|
1742
|
+
return null;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
function jr(e, t = {}) {
|
|
1746
|
+
return ft({
|
|
1747
|
+
providerGeniappId: "partner",
|
|
1748
|
+
datasourceIdentifier: "partner_record_picker",
|
|
1749
|
+
buildApiRoot: e,
|
|
1750
|
+
readToken: Wt,
|
|
1751
|
+
probePicker: Xe,
|
|
1752
|
+
loadOptions: async (r, n, a) => (await Yt(r, n, { ...t, ensureIds: a })).map(({ id: l, label: i }) => ({ id: l, label: i }))
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
export {
|
|
1756
|
+
Ar as AI_ADOPT_GRID_CLASS,
|
|
1757
|
+
Tt as AI_ADOPT_MODAL_GRID_STYLE,
|
|
1758
|
+
Et as AI_ADOPT_PAGE_GRID_CLASS,
|
|
1759
|
+
Ct as AI_SIDEBAR_MAX,
|
|
1760
|
+
kt as AI_SIDEBAR_MIN,
|
|
1761
|
+
xr as AgentJobProgressInline,
|
|
1762
|
+
Cr as AiSuggestionPanel,
|
|
1763
|
+
vr as AppUiProviders,
|
|
1764
|
+
ur as AsyncCombobox,
|
|
1765
|
+
yr as BulkActionBar,
|
|
1766
|
+
Tr as BusinessGuidancePanel,
|
|
1767
|
+
cr as DatasourceReadonlyTable,
|
|
1768
|
+
kr as DetailPageAiLayout,
|
|
1769
|
+
gr as EntityRef,
|
|
1770
|
+
wr as JobProgress,
|
|
1771
|
+
Pt as MODAL_SIZE_WITH_AI,
|
|
1772
|
+
Sr as ModalWithAiLayout,
|
|
1773
|
+
Ye as PARTNER_GENIAPP,
|
|
1774
|
+
We as PARTNER_RECORD_PICKER_DS,
|
|
1775
|
+
dr as ServerDataTable,
|
|
1776
|
+
fr as Timeline,
|
|
1777
|
+
pr as TimelineItem,
|
|
1778
|
+
Br as UserFacingError,
|
|
1779
|
+
Or as appendTextAdoptField,
|
|
1780
|
+
Vr as classifyUserFacingError,
|
|
1781
|
+
ke as createGeniSpaceClient,
|
|
1782
|
+
lr as createManagedEventClient,
|
|
1783
|
+
jr as createPartnerRecordPickerHook,
|
|
1784
|
+
ar as createTableClient,
|
|
1785
|
+
or as createTransactionDatasourceClient,
|
|
1786
|
+
Lr as descriptionAdoptField,
|
|
1787
|
+
Ur as diagnosticErrorText,
|
|
1788
|
+
Nt as emitManagedEvent,
|
|
1789
|
+
bt as executeManagedDatasourceOperation,
|
|
1790
|
+
xt as executeManagedDatasourceTransaction,
|
|
1791
|
+
_e as findManagedAppDataSourceId,
|
|
1792
|
+
ve as formatDisplayValue,
|
|
1793
|
+
Er as genericSummaryField,
|
|
1794
|
+
ae as getByPath,
|
|
1795
|
+
Ke as guidanceContentFromSummary,
|
|
1796
|
+
qt as guidanceStatus,
|
|
1797
|
+
Ir as internalNotesAdoptField,
|
|
1798
|
+
$r as jobTitleAdoptField,
|
|
1799
|
+
Yt as loadPartnerRecordOptions,
|
|
1800
|
+
q as localizedText,
|
|
1801
|
+
_r as modalSizeForAi,
|
|
1802
|
+
Rr as narrationAdoptField,
|
|
1803
|
+
Dr as noteAdoptField,
|
|
1804
|
+
qe as parseAiSummary,
|
|
1805
|
+
Xe as probePartnerRecordPicker,
|
|
1806
|
+
Pr as productDescriptionAdoptFields,
|
|
1807
|
+
Ve as queryManagedDatasourceRows,
|
|
1808
|
+
ir as queryManagedDatasourceRowsAll,
|
|
1809
|
+
Fr as recommendationAdoptField,
|
|
1810
|
+
Mr as synopsisAdoptField,
|
|
1811
|
+
qr as toUserFacingError,
|
|
1812
|
+
br as useAgentJobRunner,
|
|
1813
|
+
Nr as useAsyncJob,
|
|
1814
|
+
hr as useEntityNames,
|
|
1815
|
+
mr as useInfiniteRows
|
|
1816
|
+
};
|
|
1817
|
+
//# sourceMappingURL=ai.js.map
|