@sanity/assist 1.2.14 → 1.2.15-lang.1
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/README.md +392 -6
- package/dist/index.d.ts +170 -3
- package/dist/index.esm.js +1977 -110
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1971 -104
- package/dist/index.js.map +1 -1
- package/package.json +12 -11
- package/src/_lib/form/DocumentForm.tsx +1 -1
- package/src/assistDocument/components/instruction/InstructionInput.tsx +5 -4
- package/src/assistDocument/components/instruction/InstructionOutputField.tsx +45 -0
- package/src/assistDocument/components/instruction/InstructionOutputInput.tsx +205 -0
- package/src/assistDocument/hooks/useStudioAssistDocument.ts +5 -32
- package/src/assistFormComponents/AssistField.tsx +5 -4
- package/src/assistFormComponents/AssistFormBlock.tsx +2 -3
- package/src/assistFormComponents/validation/listItem.tsx +2 -2
- package/src/assistInspector/FieldAutocomplete.tsx +1 -0
- package/src/assistInspector/InstructionTaskHistoryButton.tsx +2 -3
- package/src/assistInspector/helpers.ts +7 -9
- package/src/assistLayout/AssistLayout.tsx +9 -6
- package/src/fieldActions/assistFieldActions.tsx +14 -8
- package/src/fieldActions/translateActions.tsx +118 -0
- package/src/helpers/assistSupported.ts +1 -1
- package/src/node_modules/.vitest/results.json +1 -0
- package/src/plugin.tsx +6 -0
- package/src/presence/AssistAvatar.tsx +1 -1
- package/src/schemas/assistDocumentSchema.tsx +39 -0
- package/src/schemas/serialize/serializeSchema.ts +6 -6
- package/src/schemas/typeDefExtensions.ts +12 -1
- package/src/translate/FieldTranslationProvider.tsx +254 -0
- package/src/translate/getLanguageParams.ts +26 -0
- package/src/translate/paths.test.ts +87 -0
- package/src/translate/paths.ts +151 -0
- package/src/translate/types.ts +159 -0
- package/src/types.ts +21 -2
- package/src/useApiClient.ts +63 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useClient, typed, useSchema, useDocumentStore, useDocumentPresence, createPatchChannel, FormBuilder, fromMutationPatches, pathToString, isObjectSchemaType, stringToPath, isKeySegment, useEditState, useCurrentUser,
|
|
3
|
-
import { Card, Stack, Box, Button, Spinner, Flex, Label, focusFirstDescendant, Text, useClickOutside, Popover, useLayer, useGlobalKeyDown, useToast, Dialog, Tooltip, TextArea, Container, Autocomplete, Breadcrumbs, Badge, useTheme, rgba, ThemeProvider, ErrorBoundary, Switch, MenuButton, Menu, MenuItem } from '@sanity/ui';
|
|
2
|
+
import { useClient, typed, useSchema, useDocumentStore, useDocumentPresence, createPatchChannel, FormBuilder, fromMutationPatches, pathToString, isObjectSchemaType, stringToPath as stringToPath$2, isKeySegment, useEditState, useCurrentUser, StatusButton, FormFieldHeaderText, PatchEvent, unset, set, useFormCallbacks, FormCallbacksProvider, FormInput, setIfMissing, insert, PresenceOverlay, VirtualizerScrollInstanceProvider, useColorSchemeValue, isArraySchemaType, isDocumentSchemaType, ObjectInputMember, defineType, defineField, defineArrayMember, isArrayOfObjectsSchemaType, getPublishedId, useSyncState, definePlugin } from 'sanity';
|
|
3
|
+
import { Card, Stack, Box, Button, Spinner, Flex, Label, focusFirstDescendant, Text, useClickOutside, Popover, useLayer, useGlobalKeyDown, useToast, Dialog, Tooltip, TextArea, Container, Autocomplete, Breadcrumbs, Badge, useTheme, rgba, Radio, Checkbox, ThemeProvider, ErrorBoundary, Switch, MenuButton, Menu, MenuItem } from '@sanity/ui';
|
|
4
4
|
import { useState, useRef, useEffect, useMemo, useCallback, createContext, useReducer, forwardRef, createElement, useContext, useId } from 'react';
|
|
5
|
-
import { SyncIcon, DocumentIcon, LinkIcon, ImageIcon, BlockContentIcon, OlistIcon, BlockquoteIcon, StringIcon, ErrorOutlineIcon, CheckmarkCircleIcon, CloseCircleIcon, ClockIcon, PlayIcon, SparklesIcon, ArrowLeftIcon, SearchIcon, RetryIcon, ArrowRightIcon, CloseIcon, CheckmarkIcon, icons, TokenIcon, DocumentTextIcon, ThListIcon, CodeIcon, ComposeIcon, LockIcon, ControlsIcon } from '@sanity/icons';
|
|
5
|
+
import { SyncIcon, DocumentIcon, LinkIcon, ImageIcon, BlockContentIcon, OlistIcon, BlockquoteIcon, StringIcon, ErrorOutlineIcon, CheckmarkCircleIcon, CloseCircleIcon, ClockIcon, PlayIcon, SparklesIcon, ArrowLeftIcon, SearchIcon, RetryIcon, ArrowRightIcon, CloseIcon, CheckmarkIcon, icons, TokenIcon, DocumentTextIcon, ThListIcon, CodeIcon, ComposeIcon, LockIcon, TranslateIcon, ControlsIcon } from '@sanity/icons';
|
|
6
6
|
import { mergeMap, share, take, filter, distinctUntilChanged, catchError, tap } from 'rxjs/operators';
|
|
7
7
|
import isEqual from 'react-fast-compare';
|
|
8
8
|
import { throwError, of, partition, merge, switchMap, delay, defer } from 'rxjs';
|
|
@@ -28,6 +28,8 @@ const instructionTaskTypeName = "sanity.assist.instructionTask";
|
|
|
28
28
|
const fieldPresenceTypeName = "sanity.assist.instructionTask.presence";
|
|
29
29
|
const assistSerializedTypeName = "sanity.assist.serialized.type";
|
|
30
30
|
const assistSerializedFieldTypeName = "sanity.assist.serialized.field";
|
|
31
|
+
const outputFieldTypeName = "sanity.assist.output.field";
|
|
32
|
+
const outputTypeTypeName = "sanity.assist.output.type";
|
|
31
33
|
const fieldPathParam = "pathKey";
|
|
32
34
|
const instructionParam = "instruction";
|
|
33
35
|
const documentRootKey = "<document>";
|
|
@@ -162,7 +164,8 @@ function isDisabled(type, allowReadonlyHidden) {
|
|
|
162
164
|
return !isSchemaAssistEnabled(type) || isUnsupportedType(type) || !allowReadonlyHidden && readonlyHidden;
|
|
163
165
|
}
|
|
164
166
|
function isUnsupportedType(type) {
|
|
165
|
-
|
|
167
|
+
var _a, _b;
|
|
168
|
+
return type.jsonType === "number" || type.name === "sanity.imageCrop" || type.name === "sanity.imageHotspot" || isType(type, "reference") && !((_b = (_a = type == null ? void 0 : type.options) == null ? void 0 : _a.aiWritingAssistance) == null ? void 0 : _b.embeddingsIndex) || isType(type, "crossDatasetReference") || isType(type, "slug") || isType(type, "url") || isType(type, "date") || isType(type, "datetime") || isType(type, "file");
|
|
166
169
|
}
|
|
167
170
|
const inlineTypes = ["document", "object", "image", "file"];
|
|
168
171
|
function serializeSchema(schema, options) {
|
|
@@ -204,13 +207,14 @@ function getSchemaStub(schemaType, schema, options) {
|
|
|
204
207
|
return removeUndef(baseSchema);
|
|
205
208
|
}
|
|
206
209
|
function getBaseFields(schema, type, typeName, options) {
|
|
207
|
-
var _a, _b, _c;
|
|
208
|
-
const
|
|
210
|
+
var _a, _b, _c, _d, _e;
|
|
211
|
+
const schemaOptions = removeUndef({
|
|
212
|
+
imagePromptField: (_a = type.options) == null ? void 0 : _a.imagePromptField,
|
|
213
|
+
embeddingsIndex: (_c = (_b = type.options) == null ? void 0 : _b.aiWritingAssistance) == null ? void 0 : _c.embeddingsIndex
|
|
214
|
+
});
|
|
209
215
|
return removeUndef({
|
|
210
|
-
options:
|
|
211
|
-
|
|
212
|
-
} : void 0,
|
|
213
|
-
values: Array.isArray((_b = type == null ? void 0 : type.options) == null ? void 0 : _b.list) ? (_c = type == null ? void 0 : type.options) == null ? void 0 : _c.list.map(v => {
|
|
216
|
+
options: Object.keys(schemaOptions).length ? schemaOptions : void 0,
|
|
217
|
+
values: Array.isArray((_d = type == null ? void 0 : type.options) == null ? void 0 : _d.list) ? (_e = type == null ? void 0 : type.options) == null ? void 0 : _e.list.map(v => {
|
|
214
218
|
var _a2;
|
|
215
219
|
return typeof v === "string" ? v : (_a2 = v.value) != null ? _a2 : "".concat(v.title);
|
|
216
220
|
}) : void 0,
|
|
@@ -588,7 +592,7 @@ function getTypePath(doc, pathString) {
|
|
|
588
592
|
if (!pathString) {
|
|
589
593
|
return void 0;
|
|
590
594
|
}
|
|
591
|
-
const path = stringToPath(pathString);
|
|
595
|
+
const path = stringToPath$2(pathString);
|
|
592
596
|
const currentPath = [];
|
|
593
597
|
let valid = true;
|
|
594
598
|
const syntheticPath = path.map(segment => {
|
|
@@ -667,7 +671,6 @@ function useStudioAssistDocument(_ref2) {
|
|
|
667
671
|
} = _ref2;
|
|
668
672
|
const documentTypeName = schemaType.name;
|
|
669
673
|
const currentUser = useCurrentUser();
|
|
670
|
-
const validation = useValidationStatus(publicId(documentId), schemaType.name).validation;
|
|
671
674
|
const assistDocument = useDocumentState(assistDocumentId(documentTypeName), assistDocumentTypeName);
|
|
672
675
|
const assistTasksStatus = useDocumentState(assistTasksStatusId(documentId != null ? documentId : ""), assistTasksStatusTypeName);
|
|
673
676
|
const client = useClient({
|
|
@@ -692,7 +695,7 @@ function useStudioAssistDocument(_ref2) {
|
|
|
692
695
|
return {
|
|
693
696
|
...assistField,
|
|
694
697
|
tasks: tasks.filter(task => task.path === assistField.path),
|
|
695
|
-
instructions: (_a2 = assistField.instructions) == null ? void 0 : _a2.filter(p => !p.userId || p.userId === (currentUser == null ? void 0 : currentUser.id)).map(instruction => asStudioInstruction(instruction, tasks
|
|
698
|
+
instructions: (_a2 = assistField.instructions) == null ? void 0 : _a2.filter(p => !p.userId || p.userId === (currentUser == null ? void 0 : currentUser.id)).map(instruction => asStudioInstruction(instruction, tasks))
|
|
696
699
|
};
|
|
697
700
|
});
|
|
698
701
|
return typed({
|
|
@@ -707,21 +710,12 @@ function useStudioAssistDocument(_ref2) {
|
|
|
707
710
|
}),
|
|
708
711
|
fields
|
|
709
712
|
});
|
|
710
|
-
}, [assistDocument, assistTasksStatus, currentUser
|
|
713
|
+
}, [assistDocument, assistTasksStatus, currentUser]);
|
|
711
714
|
}
|
|
712
|
-
function asStudioInstruction(instruction, run
|
|
713
|
-
var _a;
|
|
714
|
-
const errors = validation.filter(marker => marker.level === "error");
|
|
715
|
-
const fieldRefs = ((_a = instruction == null ? void 0 : instruction.prompt) != null ? _a : []).flatMap(block => {
|
|
716
|
-
if (block._type === "block") {
|
|
717
|
-
return block.children.filter(c => c._type === fieldReferenceTypeName);
|
|
718
|
-
}
|
|
719
|
-
return [];
|
|
720
|
-
});
|
|
715
|
+
function asStudioInstruction(instruction, run) {
|
|
721
716
|
return {
|
|
722
717
|
...instruction,
|
|
723
|
-
tasks: run.filter(task => task.instructionKey === instruction._key).filter(task => task.started && /* @__PURE__ */new Date().getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs)
|
|
724
|
-
validation: errors.filter(marker => fieldRefs.map(r => r.path).filter(p => !!p).find(path => pathToString(marker.path) === path))
|
|
718
|
+
tasks: run.filter(task => task.instructionKey === instruction._key).filter(task => task.started && ( /* @__PURE__ */new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs)
|
|
725
719
|
};
|
|
726
720
|
}
|
|
727
721
|
function useInterval(ms) {
|
|
@@ -802,13 +796,13 @@ function InstructionTaskHistoryButton(props) {
|
|
|
802
796
|
const statusDocId = assistTasksStatusId(documentId);
|
|
803
797
|
const basePath = "".concat(typed("tasks"), '[_key=="').concat(taskKey, '"]');
|
|
804
798
|
client.patch(statusDocId).set({
|
|
805
|
-
["".concat(basePath, ".").concat(typed("ended"))]: /* @__PURE__ */new Date().toISOString(),
|
|
799
|
+
["".concat(basePath, ".").concat(typed("ended"))]: ( /* @__PURE__ */new Date()).toISOString(),
|
|
806
800
|
["".concat(basePath, ".").concat(typed("reason"))]: typed("aborted")
|
|
807
801
|
}).commit().catch(console.error);
|
|
808
802
|
}, [client, documentId]);
|
|
809
803
|
const titledTasks = useMemo(() => {
|
|
810
804
|
var _a2;
|
|
811
|
-
const t = (_a2 = tasks == null ? void 0 : tasks.filter(task => task.started && /* @__PURE__ */new Date().getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs).map(task => {
|
|
805
|
+
const t = (_a2 = tasks == null ? void 0 : tasks.filter(task => task.started && ( /* @__PURE__ */new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs).map(task => {
|
|
812
806
|
var _a3;
|
|
813
807
|
const instruction = instructions == null ? void 0 : instructions.find(i => i._key === task.instructionKey);
|
|
814
808
|
return {
|
|
@@ -875,11 +869,10 @@ const TaskStatusButton = forwardRef(function TaskStatusButton2(props, ref) {
|
|
|
875
869
|
mode: "bleed",
|
|
876
870
|
onClick,
|
|
877
871
|
tone: hasErrors ? "critical" : void 0,
|
|
878
|
-
fontSize: 1,
|
|
879
872
|
disabled,
|
|
880
873
|
ref,
|
|
881
874
|
selected,
|
|
882
|
-
|
|
875
|
+
tooltipProps: TASK_STATUS_BUTTON_TOOLTIP_PROPS
|
|
883
876
|
});
|
|
884
877
|
});
|
|
885
878
|
function TaskList(props) {
|
|
@@ -966,6 +959,50 @@ function useApiClient(customApiClient) {
|
|
|
966
959
|
});
|
|
967
960
|
return useMemo(() => customApiClient ? customApiClient(client) : client, [client, customApiClient]);
|
|
968
961
|
}
|
|
962
|
+
function useTranslate(apiClient) {
|
|
963
|
+
const [loading, setLoading] = useState(false);
|
|
964
|
+
const user = useCurrentUser();
|
|
965
|
+
const schema = useSchema();
|
|
966
|
+
const types = useMemo(() => serializeSchema(schema, {
|
|
967
|
+
leanFormat: true
|
|
968
|
+
}), [schema]);
|
|
969
|
+
const toast = useToast();
|
|
970
|
+
const translate = useCallback(_ref4 => {
|
|
971
|
+
let {
|
|
972
|
+
documentId,
|
|
973
|
+
languagePath,
|
|
974
|
+
fieldLanguageMap
|
|
975
|
+
} = _ref4;
|
|
976
|
+
setLoading(true);
|
|
977
|
+
return apiClient.request({
|
|
978
|
+
method: "POST",
|
|
979
|
+
url: "/assist/tasks/translate/".concat(apiClient.config().dataset, "?projectId=").concat(apiClient.config().projectId),
|
|
980
|
+
body: {
|
|
981
|
+
documentId,
|
|
982
|
+
types,
|
|
983
|
+
languagePath,
|
|
984
|
+
fieldLanguageMap,
|
|
985
|
+
userId: user == null ? void 0 : user.id
|
|
986
|
+
}
|
|
987
|
+
}).catch(e => {
|
|
988
|
+
toast.push({
|
|
989
|
+
status: "error",
|
|
990
|
+
title: "Translate failed",
|
|
991
|
+
description: e.message
|
|
992
|
+
});
|
|
993
|
+
setLoading(false);
|
|
994
|
+
throw e;
|
|
995
|
+
}).finally(() => {
|
|
996
|
+
setTimeout(() => {
|
|
997
|
+
setLoading(false);
|
|
998
|
+
}, 2e3);
|
|
999
|
+
});
|
|
1000
|
+
}, [setLoading, apiClient, toast, user, types]);
|
|
1001
|
+
return useMemo(() => ({
|
|
1002
|
+
translate,
|
|
1003
|
+
loading
|
|
1004
|
+
}), [translate, loading]);
|
|
1005
|
+
}
|
|
969
1006
|
function useGenerateCaption(apiClient) {
|
|
970
1007
|
const [loading, setLoading] = useState(false);
|
|
971
1008
|
const user = useCurrentUser();
|
|
@@ -974,11 +1011,11 @@ function useGenerateCaption(apiClient) {
|
|
|
974
1011
|
leanFormat: true
|
|
975
1012
|
}), [schema]);
|
|
976
1013
|
const toast = useToast();
|
|
977
|
-
const generateCaption = useCallback(
|
|
1014
|
+
const generateCaption = useCallback(_ref5 => {
|
|
978
1015
|
let {
|
|
979
1016
|
path,
|
|
980
1017
|
documentId
|
|
981
|
-
} =
|
|
1018
|
+
} = _ref5;
|
|
982
1019
|
setLoading(true);
|
|
983
1020
|
return apiClient.request({
|
|
984
1021
|
method: "POST",
|
|
@@ -1197,8 +1234,8 @@ function RunInstructionProvider(props) {
|
|
|
1197
1234
|
runInstructionRequest({
|
|
1198
1235
|
...request,
|
|
1199
1236
|
instructionKey: instruction._key,
|
|
1200
|
-
userTexts: Object.entries(inputs).map(
|
|
1201
|
-
let [key, value] =
|
|
1237
|
+
userTexts: Object.entries(inputs).map(_ref6 => {
|
|
1238
|
+
let [key, value] = _ref6;
|
|
1202
1239
|
return {
|
|
1203
1240
|
blockKey: key,
|
|
1204
1241
|
userInput: value
|
|
@@ -1211,8 +1248,8 @@ function RunInstructionProvider(props) {
|
|
|
1211
1248
|
const open = !!runRequest;
|
|
1212
1249
|
const runDisabled = useMemo(() => {
|
|
1213
1250
|
var _a2, _b;
|
|
1214
|
-
return ((_b = (_a2 = runRequest == null ? void 0 : runRequest.userInputBlocks) == null ? void 0 : _a2.length) != null ? _b : 0) > Object.entries(inputs).filter(
|
|
1215
|
-
let [, value] =
|
|
1251
|
+
return ((_b = (_a2 = runRequest == null ? void 0 : runRequest.userInputBlocks) == null ? void 0 : _a2.length) != null ? _b : 0) > Object.entries(inputs).filter(_ref7 => {
|
|
1252
|
+
let [, value] = _ref7;
|
|
1216
1253
|
return !!value;
|
|
1217
1254
|
}).length;
|
|
1218
1255
|
}, [runRequest == null ? void 0 : runRequest.userInputBlocks, inputs]);
|
|
@@ -1577,7 +1614,7 @@ function useSelectedSchema(fieldPath, documentSchema) {
|
|
|
1577
1614
|
if (fieldPath === documentRootKey) {
|
|
1578
1615
|
return documentSchema;
|
|
1579
1616
|
}
|
|
1580
|
-
const path = stringToPath(fieldPath);
|
|
1617
|
+
const path = stringToPath$2(fieldPath);
|
|
1581
1618
|
let currentSchema = documentSchema;
|
|
1582
1619
|
for (let i = 0; i < path.length; i++) {
|
|
1583
1620
|
const segment = path[i];
|
|
@@ -1596,13 +1633,13 @@ function useSelectedSchema(fieldPath, documentSchema) {
|
|
|
1596
1633
|
return currentSchema;
|
|
1597
1634
|
}, [documentSchema, fieldPath]);
|
|
1598
1635
|
}
|
|
1599
|
-
function FieldsInitializer(
|
|
1636
|
+
function FieldsInitializer(_ref8) {
|
|
1600
1637
|
let {
|
|
1601
1638
|
pathKey,
|
|
1602
1639
|
activePath,
|
|
1603
1640
|
fieldExists,
|
|
1604
1641
|
onChange
|
|
1605
|
-
} =
|
|
1642
|
+
} = _ref8;
|
|
1606
1643
|
const initialized = useRef(false);
|
|
1607
1644
|
useEffect(() => {
|
|
1608
1645
|
if (initialized.current || fieldExists || activePath || !pathKey) {
|
|
@@ -1633,7 +1670,7 @@ function FieldAutocomplete(props) {
|
|
|
1633
1670
|
return getFieldRefs(schemaType);
|
|
1634
1671
|
}, [schemaType, includeDocument]);
|
|
1635
1672
|
const currentField = useMemo(() => fieldRefs.find(f => f.key === fieldPath), [fieldPath, fieldRefs]);
|
|
1636
|
-
const autocompleteOptions = useMemo(() => fieldRefs.filter(field => filter ? filter(field) : true).map(field => ({
|
|
1673
|
+
const autocompleteOptions = useMemo(() => fieldRefs.filter(field => filter ? filter(field) : true).filter(f => !isType(f.schemaType, "reference")).map(field => ({
|
|
1637
1674
|
value: field.key,
|
|
1638
1675
|
field
|
|
1639
1676
|
})), [fieldRefs, filter]);
|
|
@@ -2130,10 +2167,10 @@ const assistInspector = {
|
|
|
2130
2167
|
showAsAction: false
|
|
2131
2168
|
}),
|
|
2132
2169
|
component: AssistInspectorWrapper,
|
|
2133
|
-
onClose(
|
|
2170
|
+
onClose(_ref9) {
|
|
2134
2171
|
let {
|
|
2135
2172
|
params
|
|
2136
|
-
} =
|
|
2173
|
+
} = _ref9;
|
|
2137
2174
|
return {
|
|
2138
2175
|
params: typed({
|
|
2139
2176
|
...params,
|
|
@@ -2161,11 +2198,11 @@ function useAssistPresence(path, showFocusWithin) {
|
|
|
2161
2198
|
const activePresence = (_b = (_a = tasks == null ? void 0 : tasks.filter(task => !task.ended)) == null ? void 0 : _a.flatMap(task => {
|
|
2162
2199
|
var _a2;
|
|
2163
2200
|
return (_a2 = task.presence) != null ? _a2 : [];
|
|
2164
|
-
})) == null ? void 0 : _b.filter(p => p.started && /* @__PURE__ */new Date().getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs).filter(presence => {
|
|
2201
|
+
})) == null ? void 0 : _b.filter(p => p.started && ( /* @__PURE__ */new Date()).getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs).filter(presence => {
|
|
2165
2202
|
if (!presence.path || !path.length) {
|
|
2166
2203
|
return false;
|
|
2167
2204
|
}
|
|
2168
|
-
const statusPath = stringToPath(presence.path);
|
|
2205
|
+
const statusPath = stringToPath$2(presence.path);
|
|
2169
2206
|
if (!showFocusWithin && statusPath.length !== path.length) {
|
|
2170
2207
|
return false;
|
|
2171
2208
|
}
|
|
@@ -2195,7 +2232,7 @@ function aiPresence(presence, path, title) {
|
|
|
2195
2232
|
},
|
|
2196
2233
|
path,
|
|
2197
2234
|
sessionId: "not-available",
|
|
2198
|
-
lastActiveAt: (_a = presence == null ? void 0 : presence.started) != null ? _a : /* @__PURE__ */new Date().toISOString()
|
|
2235
|
+
lastActiveAt: (_a = presence == null ? void 0 : presence.started) != null ? _a : ( /* @__PURE__ */new Date()).toISOString()
|
|
2199
2236
|
};
|
|
2200
2237
|
}
|
|
2201
2238
|
var __freeze$3 = Object.freeze;
|
|
@@ -2206,11 +2243,11 @@ var __template$3 = (cooked, raw) => __freeze$3(__defProp$3(cooked, "raw", {
|
|
|
2206
2243
|
var _a$3, _b$1;
|
|
2207
2244
|
const fadeIn = keyframes(_a$3 || (_a$3 = __template$3(["\n 0% {\n opacity: 0;\n transform: scale(0.75);\n }\n 40% {\n opacity: 0;\n transform: scale(0.75);\n }\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n"])));
|
|
2208
2245
|
const FadeInDiv = styled.div(_b$1 || (_b$1 = __template$3(["\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n"])), fadeIn);
|
|
2209
|
-
const FadeInContent = forwardRef(function FadeInContent2(
|
|
2246
|
+
const FadeInContent = forwardRef(function FadeInContent2(_ref10, ref) {
|
|
2210
2247
|
let {
|
|
2211
2248
|
children,
|
|
2212
2249
|
durationMs = 250
|
|
2213
|
-
} =
|
|
2250
|
+
} = _ref10;
|
|
2214
2251
|
return /* @__PURE__ */jsx(FadeInDiv, {
|
|
2215
2252
|
ref,
|
|
2216
2253
|
style: {
|
|
@@ -2222,47 +2259,47 @@ const FadeInContent = forwardRef(function FadeInContent2(_ref9, ref) {
|
|
|
2222
2259
|
const purple = {
|
|
2223
2260
|
"50": {
|
|
2224
2261
|
title: "Purple 50",
|
|
2225
|
-
hex: "#
|
|
2262
|
+
hex: "#f8f5ff"
|
|
2226
2263
|
},
|
|
2227
2264
|
"100": {
|
|
2228
2265
|
title: "Purple 100",
|
|
2229
|
-
hex: "#
|
|
2266
|
+
hex: "#f1ebff"
|
|
2230
2267
|
},
|
|
2231
2268
|
"200": {
|
|
2232
2269
|
title: "Purple 200",
|
|
2233
|
-
hex: "#
|
|
2270
|
+
hex: "#ece1fe"
|
|
2234
2271
|
},
|
|
2235
2272
|
"300": {
|
|
2236
2273
|
title: "Purple 300",
|
|
2237
|
-
hex: "#
|
|
2274
|
+
hex: "#ccb1fc"
|
|
2238
2275
|
},
|
|
2239
2276
|
"400": {
|
|
2240
2277
|
title: "Purple 400",
|
|
2241
|
-
hex: "#
|
|
2278
|
+
hex: "#b087f7"
|
|
2242
2279
|
},
|
|
2243
2280
|
"500": {
|
|
2244
2281
|
title: "Purple 500",
|
|
2245
|
-
hex: "#
|
|
2282
|
+
hex: "#8f57ef"
|
|
2246
2283
|
},
|
|
2247
2284
|
"600": {
|
|
2248
2285
|
title: "Purple 600",
|
|
2249
|
-
hex: "#
|
|
2286
|
+
hex: "#721fe5"
|
|
2250
2287
|
},
|
|
2251
2288
|
"700": {
|
|
2252
2289
|
title: "Purple 700",
|
|
2253
|
-
hex: "#
|
|
2290
|
+
hex: "#4c1a9e"
|
|
2254
2291
|
},
|
|
2255
2292
|
"800": {
|
|
2256
2293
|
title: "Purple 800",
|
|
2257
|
-
hex: "#
|
|
2294
|
+
hex: "#2f1862"
|
|
2258
2295
|
},
|
|
2259
2296
|
"900": {
|
|
2260
2297
|
title: "Purple 900",
|
|
2261
|
-
hex: "#
|
|
2298
|
+
hex: "#23173f"
|
|
2262
2299
|
},
|
|
2263
2300
|
"950": {
|
|
2264
2301
|
title: "Purple 950",
|
|
2265
|
-
hex: "#
|
|
2302
|
+
hex: "#181128"
|
|
2266
2303
|
}
|
|
2267
2304
|
};
|
|
2268
2305
|
var __freeze$2 = Object.freeze;
|
|
@@ -2313,7 +2350,11 @@ function AssistAvatar(props) {
|
|
|
2313
2350
|
style: {
|
|
2314
2351
|
color: "inherit"
|
|
2315
2352
|
},
|
|
2316
|
-
children: /* @__PURE__ */jsx(SparklesIcon, {
|
|
2353
|
+
children: /* @__PURE__ */jsx(SparklesIcon, {
|
|
2354
|
+
style: {
|
|
2355
|
+
color: "inherit"
|
|
2356
|
+
}
|
|
2357
|
+
})
|
|
2317
2358
|
})
|
|
2318
2359
|
})]
|
|
2319
2360
|
});
|
|
@@ -2479,15 +2520,16 @@ function AssistField(props) {
|
|
|
2479
2520
|
showOnboarding,
|
|
2480
2521
|
dismissOnboarding
|
|
2481
2522
|
} = useOnboardingFeature(fieldOnboardingKey);
|
|
2523
|
+
const singlePresence = presence[0];
|
|
2482
2524
|
const actions = /* @__PURE__ */jsxs(Flex, {
|
|
2483
2525
|
gap: 2,
|
|
2484
2526
|
align: "center",
|
|
2485
2527
|
justify: "space-between",
|
|
2486
|
-
children: [
|
|
2528
|
+
children: [singlePresence && /* @__PURE__ */jsx(Box, {
|
|
2487
2529
|
children: /* @__PURE__ */jsx(AiFieldPresence, {
|
|
2488
|
-
presence:
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2530
|
+
presence: singlePresence
|
|
2531
|
+
})
|
|
2532
|
+
}), isFirstAssisted && showOnboarding && /* @__PURE__ */jsx(AssistOnboardingPopover, {
|
|
2491
2533
|
dismiss: dismissOnboarding
|
|
2492
2534
|
})]
|
|
2493
2535
|
});
|
|
@@ -2959,7 +3001,6 @@ function AssistConnectorsOverlay(props) {
|
|
|
2959
3001
|
zIndex: 150
|
|
2960
3002
|
// zIndex,
|
|
2961
3003
|
},
|
|
2962
|
-
|
|
2963
3004
|
children: connectors.map(connector => /* @__PURE__ */jsx(ConnectorPath, {
|
|
2964
3005
|
from: connector.from,
|
|
2965
3006
|
options,
|
|
@@ -3198,6 +3239,1502 @@ function mapBlock(block, migratedContexts) {
|
|
|
3198
3239
|
children: ((_d = textBlock.children) != null ? _d : []).map(child => mapBlock(child, migratedContexts))
|
|
3199
3240
|
};
|
|
3200
3241
|
}
|
|
3242
|
+
const MAX_DEPTH = 6;
|
|
3243
|
+
function getDocumentMembersFlat(doc, schemaType) {
|
|
3244
|
+
if (!isDocumentSchemaType(schemaType)) {
|
|
3245
|
+
console.error("Schema type is not a document");
|
|
3246
|
+
return [];
|
|
3247
|
+
}
|
|
3248
|
+
return extractPaths(doc, schemaType, [], MAX_DEPTH);
|
|
3249
|
+
}
|
|
3250
|
+
function extractPaths(doc, schemaType, path, maxDepth) {
|
|
3251
|
+
if (path.length >= maxDepth) {
|
|
3252
|
+
return [];
|
|
3253
|
+
}
|
|
3254
|
+
return schemaType.fields.reduce((acc, field) => {
|
|
3255
|
+
var _a;
|
|
3256
|
+
const fieldPath = [...path, field.name];
|
|
3257
|
+
const fieldSchema = field.type;
|
|
3258
|
+
const thisFieldWithPath = {
|
|
3259
|
+
path: fieldPath,
|
|
3260
|
+
name: field.name,
|
|
3261
|
+
schemaType: fieldSchema
|
|
3262
|
+
};
|
|
3263
|
+
if (fieldSchema.jsonType === "object") {
|
|
3264
|
+
const innerFields = extractPaths(doc, fieldSchema, fieldPath, maxDepth);
|
|
3265
|
+
return [...acc, thisFieldWithPath, ...innerFields];
|
|
3266
|
+
} else if (fieldSchema.jsonType === "array" && fieldSchema.of.length && fieldSchema.of.some(item => "fields" in item)) {
|
|
3267
|
+
const {
|
|
3268
|
+
value: arrayValue
|
|
3269
|
+
} = (_a = extractWithPath(pathToString(fieldPath), doc)[0]) != null ? _a : {};
|
|
3270
|
+
let arrayPaths = [];
|
|
3271
|
+
if (arrayValue == null ? void 0 : arrayValue.length) {
|
|
3272
|
+
for (const item of arrayValue) {
|
|
3273
|
+
const arrayItemSchema = fieldSchema.of.find(t => t.name === item._type);
|
|
3274
|
+
if (item._key && arrayItemSchema) {
|
|
3275
|
+
const itemPath = [...fieldPath, {
|
|
3276
|
+
_key: item._key
|
|
3277
|
+
}];
|
|
3278
|
+
const innerFields = extractPaths(doc, arrayItemSchema, itemPath, maxDepth);
|
|
3279
|
+
arrayPaths = [...arrayPaths, {
|
|
3280
|
+
path: itemPath,
|
|
3281
|
+
name: item._key,
|
|
3282
|
+
schemaType: arrayItemSchema
|
|
3283
|
+
}, ...innerFields];
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
return [...acc, thisFieldWithPath, ...arrayPaths];
|
|
3288
|
+
}
|
|
3289
|
+
return [...acc, thisFieldWithPath];
|
|
3290
|
+
}, []);
|
|
3291
|
+
}
|
|
3292
|
+
const defaultLanguageOutputs = function (member, enclosingType, translateFromLanguageId, translateToLanguageIds) {
|
|
3293
|
+
if (member.schemaType.jsonType === "object" && member.schemaType.name.startsWith("internationalizedArray")) {
|
|
3294
|
+
const pathEnd = member.path.slice(-1);
|
|
3295
|
+
const language = isKeySegment(pathEnd[0]) ? pathEnd[0]._key : null;
|
|
3296
|
+
return language === translateFromLanguageId ? translateToLanguageIds.map(translateToId => ({
|
|
3297
|
+
id: translateToId,
|
|
3298
|
+
outputPath: [...member.path.slice(0, -1), {
|
|
3299
|
+
_key: translateToId
|
|
3300
|
+
}]
|
|
3301
|
+
})) : void 0;
|
|
3302
|
+
}
|
|
3303
|
+
if (enclosingType.jsonType === "object" && enclosingType.name.startsWith("locale")) {
|
|
3304
|
+
return translateFromLanguageId === member.name ? translateToLanguageIds.map(translateToId => ({
|
|
3305
|
+
id: translateToId,
|
|
3306
|
+
outputPath: [...member.path.slice(0, -1), translateToId]
|
|
3307
|
+
})) : void 0;
|
|
3308
|
+
}
|
|
3309
|
+
return void 0;
|
|
3310
|
+
};
|
|
3311
|
+
function getTranslationMap(documentSchema, documentMembers, translateFromLanguageId, outputLanguageIds, langFn) {
|
|
3312
|
+
var _a, _b, _c;
|
|
3313
|
+
const translationMaps = [];
|
|
3314
|
+
for (const member of documentMembers) {
|
|
3315
|
+
const parentPath = member.path.slice(0, -1);
|
|
3316
|
+
const enclosingType = (_b = (_a = documentMembers.find(m => pathToString(m.path) === pathToString(parentPath))) == null ? void 0 : _a.schemaType) != null ? _b : documentSchema;
|
|
3317
|
+
const translations = (_c = langFn(member, enclosingType, translateFromLanguageId, outputLanguageIds)) == null ? void 0 : _c.filter(translation => translation.id !== translateFromLanguageId);
|
|
3318
|
+
if (translations) {
|
|
3319
|
+
translationMaps.push({
|
|
3320
|
+
inputLanguageId: translateFromLanguageId,
|
|
3321
|
+
inputPath: member.path,
|
|
3322
|
+
outputs: translations
|
|
3323
|
+
});
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
return translationMaps;
|
|
3327
|
+
}
|
|
3328
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3329
|
+
function getDefaultExportFromCjs(x) {
|
|
3330
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3331
|
+
}
|
|
3332
|
+
|
|
3333
|
+
/**
|
|
3334
|
+
* Checks if `value` is classified as an `Array` object.
|
|
3335
|
+
*
|
|
3336
|
+
* @static
|
|
3337
|
+
* @memberOf _
|
|
3338
|
+
* @since 0.1.0
|
|
3339
|
+
* @category Lang
|
|
3340
|
+
* @param {*} value The value to check.
|
|
3341
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
3342
|
+
* @example
|
|
3343
|
+
*
|
|
3344
|
+
* _.isArray([1, 2, 3]);
|
|
3345
|
+
* // => true
|
|
3346
|
+
*
|
|
3347
|
+
* _.isArray(document.body.children);
|
|
3348
|
+
* // => false
|
|
3349
|
+
*
|
|
3350
|
+
* _.isArray('abc');
|
|
3351
|
+
* // => false
|
|
3352
|
+
*
|
|
3353
|
+
* _.isArray(_.noop);
|
|
3354
|
+
* // => false
|
|
3355
|
+
*/
|
|
3356
|
+
|
|
3357
|
+
var isArray$3 = Array.isArray;
|
|
3358
|
+
var isArray_1 = isArray$3;
|
|
3359
|
+
|
|
3360
|
+
/** Detect free variable `global` from Node.js. */
|
|
3361
|
+
|
|
3362
|
+
var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
3363
|
+
var _freeGlobal = freeGlobal$1;
|
|
3364
|
+
var freeGlobal = _freeGlobal;
|
|
3365
|
+
|
|
3366
|
+
/** Detect free variable `self`. */
|
|
3367
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
3368
|
+
|
|
3369
|
+
/** Used as a reference to the global object. */
|
|
3370
|
+
var root$3 = freeGlobal || freeSelf || Function('return this')();
|
|
3371
|
+
var _root = root$3;
|
|
3372
|
+
var root$2 = _root;
|
|
3373
|
+
|
|
3374
|
+
/** Built-in value references. */
|
|
3375
|
+
var Symbol$3 = root$2.Symbol;
|
|
3376
|
+
var _Symbol = Symbol$3;
|
|
3377
|
+
var Symbol$2 = _Symbol;
|
|
3378
|
+
|
|
3379
|
+
/** Used for built-in method references. */
|
|
3380
|
+
var objectProto$4 = Object.prototype;
|
|
3381
|
+
|
|
3382
|
+
/** Used to check objects for own properties. */
|
|
3383
|
+
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
3384
|
+
|
|
3385
|
+
/**
|
|
3386
|
+
* Used to resolve the
|
|
3387
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
3388
|
+
* of values.
|
|
3389
|
+
*/
|
|
3390
|
+
var nativeObjectToString$1 = objectProto$4.toString;
|
|
3391
|
+
|
|
3392
|
+
/** Built-in value references. */
|
|
3393
|
+
var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
|
|
3394
|
+
|
|
3395
|
+
/**
|
|
3396
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
3397
|
+
*
|
|
3398
|
+
* @private
|
|
3399
|
+
* @param {*} value The value to query.
|
|
3400
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
3401
|
+
*/
|
|
3402
|
+
function getRawTag$1(value) {
|
|
3403
|
+
var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
|
|
3404
|
+
tag = value[symToStringTag$1];
|
|
3405
|
+
try {
|
|
3406
|
+
value[symToStringTag$1] = undefined;
|
|
3407
|
+
var unmasked = true;
|
|
3408
|
+
} catch (e) {}
|
|
3409
|
+
var result = nativeObjectToString$1.call(value);
|
|
3410
|
+
if (unmasked) {
|
|
3411
|
+
if (isOwn) {
|
|
3412
|
+
value[symToStringTag$1] = tag;
|
|
3413
|
+
} else {
|
|
3414
|
+
delete value[symToStringTag$1];
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
return result;
|
|
3418
|
+
}
|
|
3419
|
+
var _getRawTag = getRawTag$1;
|
|
3420
|
+
|
|
3421
|
+
/** Used for built-in method references. */
|
|
3422
|
+
|
|
3423
|
+
var objectProto$3 = Object.prototype;
|
|
3424
|
+
|
|
3425
|
+
/**
|
|
3426
|
+
* Used to resolve the
|
|
3427
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
3428
|
+
* of values.
|
|
3429
|
+
*/
|
|
3430
|
+
var nativeObjectToString = objectProto$3.toString;
|
|
3431
|
+
|
|
3432
|
+
/**
|
|
3433
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
3434
|
+
*
|
|
3435
|
+
* @private
|
|
3436
|
+
* @param {*} value The value to convert.
|
|
3437
|
+
* @returns {string} Returns the converted string.
|
|
3438
|
+
*/
|
|
3439
|
+
function objectToString$1(value) {
|
|
3440
|
+
return nativeObjectToString.call(value);
|
|
3441
|
+
}
|
|
3442
|
+
var _objectToString = objectToString$1;
|
|
3443
|
+
var Symbol$1 = _Symbol,
|
|
3444
|
+
getRawTag = _getRawTag,
|
|
3445
|
+
objectToString = _objectToString;
|
|
3446
|
+
|
|
3447
|
+
/** `Object#toString` result references. */
|
|
3448
|
+
var nullTag = '[object Null]',
|
|
3449
|
+
undefinedTag = '[object Undefined]';
|
|
3450
|
+
|
|
3451
|
+
/** Built-in value references. */
|
|
3452
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
3453
|
+
|
|
3454
|
+
/**
|
|
3455
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
3456
|
+
*
|
|
3457
|
+
* @private
|
|
3458
|
+
* @param {*} value The value to query.
|
|
3459
|
+
* @returns {string} Returns the `toStringTag`.
|
|
3460
|
+
*/
|
|
3461
|
+
function baseGetTag$2(value) {
|
|
3462
|
+
if (value == null) {
|
|
3463
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
3464
|
+
}
|
|
3465
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
3466
|
+
}
|
|
3467
|
+
var _baseGetTag = baseGetTag$2;
|
|
3468
|
+
|
|
3469
|
+
/**
|
|
3470
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
3471
|
+
* and has a `typeof` result of "object".
|
|
3472
|
+
*
|
|
3473
|
+
* @static
|
|
3474
|
+
* @memberOf _
|
|
3475
|
+
* @since 4.0.0
|
|
3476
|
+
* @category Lang
|
|
3477
|
+
* @param {*} value The value to check.
|
|
3478
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
3479
|
+
* @example
|
|
3480
|
+
*
|
|
3481
|
+
* _.isObjectLike({});
|
|
3482
|
+
* // => true
|
|
3483
|
+
*
|
|
3484
|
+
* _.isObjectLike([1, 2, 3]);
|
|
3485
|
+
* // => true
|
|
3486
|
+
*
|
|
3487
|
+
* _.isObjectLike(_.noop);
|
|
3488
|
+
* // => false
|
|
3489
|
+
*
|
|
3490
|
+
* _.isObjectLike(null);
|
|
3491
|
+
* // => false
|
|
3492
|
+
*/
|
|
3493
|
+
|
|
3494
|
+
function isObjectLike$1(value) {
|
|
3495
|
+
return value != null && typeof value == 'object';
|
|
3496
|
+
}
|
|
3497
|
+
var isObjectLike_1 = isObjectLike$1;
|
|
3498
|
+
var baseGetTag$1 = _baseGetTag,
|
|
3499
|
+
isObjectLike = isObjectLike_1;
|
|
3500
|
+
|
|
3501
|
+
/** `Object#toString` result references. */
|
|
3502
|
+
var symbolTag = '[object Symbol]';
|
|
3503
|
+
|
|
3504
|
+
/**
|
|
3505
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
3506
|
+
*
|
|
3507
|
+
* @static
|
|
3508
|
+
* @memberOf _
|
|
3509
|
+
* @since 4.0.0
|
|
3510
|
+
* @category Lang
|
|
3511
|
+
* @param {*} value The value to check.
|
|
3512
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
3513
|
+
* @example
|
|
3514
|
+
*
|
|
3515
|
+
* _.isSymbol(Symbol.iterator);
|
|
3516
|
+
* // => true
|
|
3517
|
+
*
|
|
3518
|
+
* _.isSymbol('abc');
|
|
3519
|
+
* // => false
|
|
3520
|
+
*/
|
|
3521
|
+
function isSymbol$3(value) {
|
|
3522
|
+
return typeof value == 'symbol' || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
|
|
3523
|
+
}
|
|
3524
|
+
var isSymbol_1 = isSymbol$3;
|
|
3525
|
+
var isArray$2 = isArray_1,
|
|
3526
|
+
isSymbol$2 = isSymbol_1;
|
|
3527
|
+
|
|
3528
|
+
/** Used to match property names within property paths. */
|
|
3529
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
|
3530
|
+
reIsPlainProp = /^\w*$/;
|
|
3531
|
+
|
|
3532
|
+
/**
|
|
3533
|
+
* Checks if `value` is a property name and not a property path.
|
|
3534
|
+
*
|
|
3535
|
+
* @private
|
|
3536
|
+
* @param {*} value The value to check.
|
|
3537
|
+
* @param {Object} [object] The object to query keys on.
|
|
3538
|
+
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
|
3539
|
+
*/
|
|
3540
|
+
function isKey$1(value, object) {
|
|
3541
|
+
if (isArray$2(value)) {
|
|
3542
|
+
return false;
|
|
3543
|
+
}
|
|
3544
|
+
var type = typeof value;
|
|
3545
|
+
if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol$2(value)) {
|
|
3546
|
+
return true;
|
|
3547
|
+
}
|
|
3548
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
3549
|
+
}
|
|
3550
|
+
var _isKey = isKey$1;
|
|
3551
|
+
|
|
3552
|
+
/**
|
|
3553
|
+
* Checks if `value` is the
|
|
3554
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
3555
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
3556
|
+
*
|
|
3557
|
+
* @static
|
|
3558
|
+
* @memberOf _
|
|
3559
|
+
* @since 0.1.0
|
|
3560
|
+
* @category Lang
|
|
3561
|
+
* @param {*} value The value to check.
|
|
3562
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
3563
|
+
* @example
|
|
3564
|
+
*
|
|
3565
|
+
* _.isObject({});
|
|
3566
|
+
* // => true
|
|
3567
|
+
*
|
|
3568
|
+
* _.isObject([1, 2, 3]);
|
|
3569
|
+
* // => true
|
|
3570
|
+
*
|
|
3571
|
+
* _.isObject(_.noop);
|
|
3572
|
+
* // => true
|
|
3573
|
+
*
|
|
3574
|
+
* _.isObject(null);
|
|
3575
|
+
* // => false
|
|
3576
|
+
*/
|
|
3577
|
+
|
|
3578
|
+
function isObject$2(value) {
|
|
3579
|
+
var type = typeof value;
|
|
3580
|
+
return value != null && (type == 'object' || type == 'function');
|
|
3581
|
+
}
|
|
3582
|
+
var isObject_1 = isObject$2;
|
|
3583
|
+
var baseGetTag = _baseGetTag,
|
|
3584
|
+
isObject$1 = isObject_1;
|
|
3585
|
+
|
|
3586
|
+
/** `Object#toString` result references. */
|
|
3587
|
+
var asyncTag = '[object AsyncFunction]',
|
|
3588
|
+
funcTag = '[object Function]',
|
|
3589
|
+
genTag = '[object GeneratorFunction]',
|
|
3590
|
+
proxyTag = '[object Proxy]';
|
|
3591
|
+
|
|
3592
|
+
/**
|
|
3593
|
+
* Checks if `value` is classified as a `Function` object.
|
|
3594
|
+
*
|
|
3595
|
+
* @static
|
|
3596
|
+
* @memberOf _
|
|
3597
|
+
* @since 0.1.0
|
|
3598
|
+
* @category Lang
|
|
3599
|
+
* @param {*} value The value to check.
|
|
3600
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
3601
|
+
* @example
|
|
3602
|
+
*
|
|
3603
|
+
* _.isFunction(_);
|
|
3604
|
+
* // => true
|
|
3605
|
+
*
|
|
3606
|
+
* _.isFunction(/abc/);
|
|
3607
|
+
* // => false
|
|
3608
|
+
*/
|
|
3609
|
+
function isFunction$1(value) {
|
|
3610
|
+
if (!isObject$1(value)) {
|
|
3611
|
+
return false;
|
|
3612
|
+
}
|
|
3613
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
3614
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
3615
|
+
var tag = baseGetTag(value);
|
|
3616
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
3617
|
+
}
|
|
3618
|
+
var isFunction_1 = isFunction$1;
|
|
3619
|
+
var root$1 = _root;
|
|
3620
|
+
|
|
3621
|
+
/** Used to detect overreaching core-js shims. */
|
|
3622
|
+
var coreJsData$1 = root$1['__core-js_shared__'];
|
|
3623
|
+
var _coreJsData = coreJsData$1;
|
|
3624
|
+
var coreJsData = _coreJsData;
|
|
3625
|
+
|
|
3626
|
+
/** Used to detect methods masquerading as native. */
|
|
3627
|
+
var maskSrcKey = function () {
|
|
3628
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
3629
|
+
return uid ? 'Symbol(src)_1.' + uid : '';
|
|
3630
|
+
}();
|
|
3631
|
+
|
|
3632
|
+
/**
|
|
3633
|
+
* Checks if `func` has its source masked.
|
|
3634
|
+
*
|
|
3635
|
+
* @private
|
|
3636
|
+
* @param {Function} func The function to check.
|
|
3637
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
3638
|
+
*/
|
|
3639
|
+
function isMasked$1(func) {
|
|
3640
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
3641
|
+
}
|
|
3642
|
+
var _isMasked = isMasked$1;
|
|
3643
|
+
|
|
3644
|
+
/** Used for built-in method references. */
|
|
3645
|
+
|
|
3646
|
+
var funcProto$1 = Function.prototype;
|
|
3647
|
+
|
|
3648
|
+
/** Used to resolve the decompiled source of functions. */
|
|
3649
|
+
var funcToString$1 = funcProto$1.toString;
|
|
3650
|
+
|
|
3651
|
+
/**
|
|
3652
|
+
* Converts `func` to its source code.
|
|
3653
|
+
*
|
|
3654
|
+
* @private
|
|
3655
|
+
* @param {Function} func The function to convert.
|
|
3656
|
+
* @returns {string} Returns the source code.
|
|
3657
|
+
*/
|
|
3658
|
+
function toSource$1(func) {
|
|
3659
|
+
if (func != null) {
|
|
3660
|
+
try {
|
|
3661
|
+
return funcToString$1.call(func);
|
|
3662
|
+
} catch (e) {}
|
|
3663
|
+
try {
|
|
3664
|
+
return func + '';
|
|
3665
|
+
} catch (e) {}
|
|
3666
|
+
}
|
|
3667
|
+
return '';
|
|
3668
|
+
}
|
|
3669
|
+
var _toSource = toSource$1;
|
|
3670
|
+
var isFunction = isFunction_1,
|
|
3671
|
+
isMasked = _isMasked,
|
|
3672
|
+
isObject = isObject_1,
|
|
3673
|
+
toSource = _toSource;
|
|
3674
|
+
|
|
3675
|
+
/**
|
|
3676
|
+
* Used to match `RegExp`
|
|
3677
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
3678
|
+
*/
|
|
3679
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
3680
|
+
|
|
3681
|
+
/** Used to detect host constructors (Safari). */
|
|
3682
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
3683
|
+
|
|
3684
|
+
/** Used for built-in method references. */
|
|
3685
|
+
var funcProto = Function.prototype,
|
|
3686
|
+
objectProto$2 = Object.prototype;
|
|
3687
|
+
|
|
3688
|
+
/** Used to resolve the decompiled source of functions. */
|
|
3689
|
+
var funcToString = funcProto.toString;
|
|
3690
|
+
|
|
3691
|
+
/** Used to check objects for own properties. */
|
|
3692
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
3693
|
+
|
|
3694
|
+
/** Used to detect if a method is native. */
|
|
3695
|
+
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
|
|
3696
|
+
|
|
3697
|
+
/**
|
|
3698
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
3699
|
+
*
|
|
3700
|
+
* @private
|
|
3701
|
+
* @param {*} value The value to check.
|
|
3702
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
3703
|
+
* else `false`.
|
|
3704
|
+
*/
|
|
3705
|
+
function baseIsNative$1(value) {
|
|
3706
|
+
if (!isObject(value) || isMasked(value)) {
|
|
3707
|
+
return false;
|
|
3708
|
+
}
|
|
3709
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
3710
|
+
return pattern.test(toSource(value));
|
|
3711
|
+
}
|
|
3712
|
+
var _baseIsNative = baseIsNative$1;
|
|
3713
|
+
|
|
3714
|
+
/**
|
|
3715
|
+
* Gets the value at `key` of `object`.
|
|
3716
|
+
*
|
|
3717
|
+
* @private
|
|
3718
|
+
* @param {Object} [object] The object to query.
|
|
3719
|
+
* @param {string} key The key of the property to get.
|
|
3720
|
+
* @returns {*} Returns the property value.
|
|
3721
|
+
*/
|
|
3722
|
+
|
|
3723
|
+
function getValue$1(object, key) {
|
|
3724
|
+
return object == null ? undefined : object[key];
|
|
3725
|
+
}
|
|
3726
|
+
var _getValue = getValue$1;
|
|
3727
|
+
var baseIsNative = _baseIsNative,
|
|
3728
|
+
getValue = _getValue;
|
|
3729
|
+
|
|
3730
|
+
/**
|
|
3731
|
+
* Gets the native function at `key` of `object`.
|
|
3732
|
+
*
|
|
3733
|
+
* @private
|
|
3734
|
+
* @param {Object} object The object to query.
|
|
3735
|
+
* @param {string} key The key of the method to get.
|
|
3736
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
3737
|
+
*/
|
|
3738
|
+
function getNative$2(object, key) {
|
|
3739
|
+
var value = getValue(object, key);
|
|
3740
|
+
return baseIsNative(value) ? value : undefined;
|
|
3741
|
+
}
|
|
3742
|
+
var _getNative = getNative$2;
|
|
3743
|
+
var getNative$1 = _getNative;
|
|
3744
|
+
|
|
3745
|
+
/* Built-in method references that are verified to be native. */
|
|
3746
|
+
var nativeCreate$4 = getNative$1(Object, 'create');
|
|
3747
|
+
var _nativeCreate = nativeCreate$4;
|
|
3748
|
+
var nativeCreate$3 = _nativeCreate;
|
|
3749
|
+
|
|
3750
|
+
/**
|
|
3751
|
+
* Removes all key-value entries from the hash.
|
|
3752
|
+
*
|
|
3753
|
+
* @private
|
|
3754
|
+
* @name clear
|
|
3755
|
+
* @memberOf Hash
|
|
3756
|
+
*/
|
|
3757
|
+
function hashClear$1() {
|
|
3758
|
+
this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
|
|
3759
|
+
this.size = 0;
|
|
3760
|
+
}
|
|
3761
|
+
var _hashClear = hashClear$1;
|
|
3762
|
+
|
|
3763
|
+
/**
|
|
3764
|
+
* Removes `key` and its value from the hash.
|
|
3765
|
+
*
|
|
3766
|
+
* @private
|
|
3767
|
+
* @name delete
|
|
3768
|
+
* @memberOf Hash
|
|
3769
|
+
* @param {Object} hash The hash to modify.
|
|
3770
|
+
* @param {string} key The key of the value to remove.
|
|
3771
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
3772
|
+
*/
|
|
3773
|
+
|
|
3774
|
+
function hashDelete$1(key) {
|
|
3775
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
3776
|
+
this.size -= result ? 1 : 0;
|
|
3777
|
+
return result;
|
|
3778
|
+
}
|
|
3779
|
+
var _hashDelete = hashDelete$1;
|
|
3780
|
+
var nativeCreate$2 = _nativeCreate;
|
|
3781
|
+
|
|
3782
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
3783
|
+
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
|
3784
|
+
|
|
3785
|
+
/** Used for built-in method references. */
|
|
3786
|
+
var objectProto$1 = Object.prototype;
|
|
3787
|
+
|
|
3788
|
+
/** Used to check objects for own properties. */
|
|
3789
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
3790
|
+
|
|
3791
|
+
/**
|
|
3792
|
+
* Gets the hash value for `key`.
|
|
3793
|
+
*
|
|
3794
|
+
* @private
|
|
3795
|
+
* @name get
|
|
3796
|
+
* @memberOf Hash
|
|
3797
|
+
* @param {string} key The key of the value to get.
|
|
3798
|
+
* @returns {*} Returns the entry value.
|
|
3799
|
+
*/
|
|
3800
|
+
function hashGet$1(key) {
|
|
3801
|
+
var data = this.__data__;
|
|
3802
|
+
if (nativeCreate$2) {
|
|
3803
|
+
var result = data[key];
|
|
3804
|
+
return result === HASH_UNDEFINED$1 ? undefined : result;
|
|
3805
|
+
}
|
|
3806
|
+
return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
|
|
3807
|
+
}
|
|
3808
|
+
var _hashGet = hashGet$1;
|
|
3809
|
+
var nativeCreate$1 = _nativeCreate;
|
|
3810
|
+
|
|
3811
|
+
/** Used for built-in method references. */
|
|
3812
|
+
var objectProto = Object.prototype;
|
|
3813
|
+
|
|
3814
|
+
/** Used to check objects for own properties. */
|
|
3815
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
3816
|
+
|
|
3817
|
+
/**
|
|
3818
|
+
* Checks if a hash value for `key` exists.
|
|
3819
|
+
*
|
|
3820
|
+
* @private
|
|
3821
|
+
* @name has
|
|
3822
|
+
* @memberOf Hash
|
|
3823
|
+
* @param {string} key The key of the entry to check.
|
|
3824
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
3825
|
+
*/
|
|
3826
|
+
function hashHas$1(key) {
|
|
3827
|
+
var data = this.__data__;
|
|
3828
|
+
return nativeCreate$1 ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
|
3829
|
+
}
|
|
3830
|
+
var _hashHas = hashHas$1;
|
|
3831
|
+
var nativeCreate = _nativeCreate;
|
|
3832
|
+
|
|
3833
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
3834
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
3835
|
+
|
|
3836
|
+
/**
|
|
3837
|
+
* Sets the hash `key` to `value`.
|
|
3838
|
+
*
|
|
3839
|
+
* @private
|
|
3840
|
+
* @name set
|
|
3841
|
+
* @memberOf Hash
|
|
3842
|
+
* @param {string} key The key of the value to set.
|
|
3843
|
+
* @param {*} value The value to set.
|
|
3844
|
+
* @returns {Object} Returns the hash instance.
|
|
3845
|
+
*/
|
|
3846
|
+
function hashSet$1(key, value) {
|
|
3847
|
+
var data = this.__data__;
|
|
3848
|
+
this.size += this.has(key) ? 0 : 1;
|
|
3849
|
+
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
|
|
3850
|
+
return this;
|
|
3851
|
+
}
|
|
3852
|
+
var _hashSet = hashSet$1;
|
|
3853
|
+
var hashClear = _hashClear,
|
|
3854
|
+
hashDelete = _hashDelete,
|
|
3855
|
+
hashGet = _hashGet,
|
|
3856
|
+
hashHas = _hashHas,
|
|
3857
|
+
hashSet = _hashSet;
|
|
3858
|
+
|
|
3859
|
+
/**
|
|
3860
|
+
* Creates a hash object.
|
|
3861
|
+
*
|
|
3862
|
+
* @private
|
|
3863
|
+
* @constructor
|
|
3864
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
3865
|
+
*/
|
|
3866
|
+
function Hash$1(entries) {
|
|
3867
|
+
var index = -1,
|
|
3868
|
+
length = entries == null ? 0 : entries.length;
|
|
3869
|
+
this.clear();
|
|
3870
|
+
while (++index < length) {
|
|
3871
|
+
var entry = entries[index];
|
|
3872
|
+
this.set(entry[0], entry[1]);
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
// Add methods to `Hash`.
|
|
3877
|
+
Hash$1.prototype.clear = hashClear;
|
|
3878
|
+
Hash$1.prototype['delete'] = hashDelete;
|
|
3879
|
+
Hash$1.prototype.get = hashGet;
|
|
3880
|
+
Hash$1.prototype.has = hashHas;
|
|
3881
|
+
Hash$1.prototype.set = hashSet;
|
|
3882
|
+
var _Hash = Hash$1;
|
|
3883
|
+
|
|
3884
|
+
/**
|
|
3885
|
+
* Removes all key-value entries from the list cache.
|
|
3886
|
+
*
|
|
3887
|
+
* @private
|
|
3888
|
+
* @name clear
|
|
3889
|
+
* @memberOf ListCache
|
|
3890
|
+
*/
|
|
3891
|
+
|
|
3892
|
+
function listCacheClear$1() {
|
|
3893
|
+
this.__data__ = [];
|
|
3894
|
+
this.size = 0;
|
|
3895
|
+
}
|
|
3896
|
+
var _listCacheClear = listCacheClear$1;
|
|
3897
|
+
|
|
3898
|
+
/**
|
|
3899
|
+
* Performs a
|
|
3900
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
3901
|
+
* comparison between two values to determine if they are equivalent.
|
|
3902
|
+
*
|
|
3903
|
+
* @static
|
|
3904
|
+
* @memberOf _
|
|
3905
|
+
* @since 4.0.0
|
|
3906
|
+
* @category Lang
|
|
3907
|
+
* @param {*} value The value to compare.
|
|
3908
|
+
* @param {*} other The other value to compare.
|
|
3909
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
3910
|
+
* @example
|
|
3911
|
+
*
|
|
3912
|
+
* var object = { 'a': 1 };
|
|
3913
|
+
* var other = { 'a': 1 };
|
|
3914
|
+
*
|
|
3915
|
+
* _.eq(object, object);
|
|
3916
|
+
* // => true
|
|
3917
|
+
*
|
|
3918
|
+
* _.eq(object, other);
|
|
3919
|
+
* // => false
|
|
3920
|
+
*
|
|
3921
|
+
* _.eq('a', 'a');
|
|
3922
|
+
* // => true
|
|
3923
|
+
*
|
|
3924
|
+
* _.eq('a', Object('a'));
|
|
3925
|
+
* // => false
|
|
3926
|
+
*
|
|
3927
|
+
* _.eq(NaN, NaN);
|
|
3928
|
+
* // => true
|
|
3929
|
+
*/
|
|
3930
|
+
|
|
3931
|
+
function eq$1(value, other) {
|
|
3932
|
+
return value === other || value !== value && other !== other;
|
|
3933
|
+
}
|
|
3934
|
+
var eq_1 = eq$1;
|
|
3935
|
+
var eq = eq_1;
|
|
3936
|
+
|
|
3937
|
+
/**
|
|
3938
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
3939
|
+
*
|
|
3940
|
+
* @private
|
|
3941
|
+
* @param {Array} array The array to inspect.
|
|
3942
|
+
* @param {*} key The key to search for.
|
|
3943
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
3944
|
+
*/
|
|
3945
|
+
function assocIndexOf$4(array, key) {
|
|
3946
|
+
var length = array.length;
|
|
3947
|
+
while (length--) {
|
|
3948
|
+
if (eq(array[length][0], key)) {
|
|
3949
|
+
return length;
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
return -1;
|
|
3953
|
+
}
|
|
3954
|
+
var _assocIndexOf = assocIndexOf$4;
|
|
3955
|
+
var assocIndexOf$3 = _assocIndexOf;
|
|
3956
|
+
|
|
3957
|
+
/** Used for built-in method references. */
|
|
3958
|
+
var arrayProto = Array.prototype;
|
|
3959
|
+
|
|
3960
|
+
/** Built-in value references. */
|
|
3961
|
+
var splice = arrayProto.splice;
|
|
3962
|
+
|
|
3963
|
+
/**
|
|
3964
|
+
* Removes `key` and its value from the list cache.
|
|
3965
|
+
*
|
|
3966
|
+
* @private
|
|
3967
|
+
* @name delete
|
|
3968
|
+
* @memberOf ListCache
|
|
3969
|
+
* @param {string} key The key of the value to remove.
|
|
3970
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
3971
|
+
*/
|
|
3972
|
+
function listCacheDelete$1(key) {
|
|
3973
|
+
var data = this.__data__,
|
|
3974
|
+
index = assocIndexOf$3(data, key);
|
|
3975
|
+
if (index < 0) {
|
|
3976
|
+
return false;
|
|
3977
|
+
}
|
|
3978
|
+
var lastIndex = data.length - 1;
|
|
3979
|
+
if (index == lastIndex) {
|
|
3980
|
+
data.pop();
|
|
3981
|
+
} else {
|
|
3982
|
+
splice.call(data, index, 1);
|
|
3983
|
+
}
|
|
3984
|
+
--this.size;
|
|
3985
|
+
return true;
|
|
3986
|
+
}
|
|
3987
|
+
var _listCacheDelete = listCacheDelete$1;
|
|
3988
|
+
var assocIndexOf$2 = _assocIndexOf;
|
|
3989
|
+
|
|
3990
|
+
/**
|
|
3991
|
+
* Gets the list cache value for `key`.
|
|
3992
|
+
*
|
|
3993
|
+
* @private
|
|
3994
|
+
* @name get
|
|
3995
|
+
* @memberOf ListCache
|
|
3996
|
+
* @param {string} key The key of the value to get.
|
|
3997
|
+
* @returns {*} Returns the entry value.
|
|
3998
|
+
*/
|
|
3999
|
+
function listCacheGet$1(key) {
|
|
4000
|
+
var data = this.__data__,
|
|
4001
|
+
index = assocIndexOf$2(data, key);
|
|
4002
|
+
return index < 0 ? undefined : data[index][1];
|
|
4003
|
+
}
|
|
4004
|
+
var _listCacheGet = listCacheGet$1;
|
|
4005
|
+
var assocIndexOf$1 = _assocIndexOf;
|
|
4006
|
+
|
|
4007
|
+
/**
|
|
4008
|
+
* Checks if a list cache value for `key` exists.
|
|
4009
|
+
*
|
|
4010
|
+
* @private
|
|
4011
|
+
* @name has
|
|
4012
|
+
* @memberOf ListCache
|
|
4013
|
+
* @param {string} key The key of the entry to check.
|
|
4014
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
4015
|
+
*/
|
|
4016
|
+
function listCacheHas$1(key) {
|
|
4017
|
+
return assocIndexOf$1(this.__data__, key) > -1;
|
|
4018
|
+
}
|
|
4019
|
+
var _listCacheHas = listCacheHas$1;
|
|
4020
|
+
var assocIndexOf = _assocIndexOf;
|
|
4021
|
+
|
|
4022
|
+
/**
|
|
4023
|
+
* Sets the list cache `key` to `value`.
|
|
4024
|
+
*
|
|
4025
|
+
* @private
|
|
4026
|
+
* @name set
|
|
4027
|
+
* @memberOf ListCache
|
|
4028
|
+
* @param {string} key The key of the value to set.
|
|
4029
|
+
* @param {*} value The value to set.
|
|
4030
|
+
* @returns {Object} Returns the list cache instance.
|
|
4031
|
+
*/
|
|
4032
|
+
function listCacheSet$1(key, value) {
|
|
4033
|
+
var data = this.__data__,
|
|
4034
|
+
index = assocIndexOf(data, key);
|
|
4035
|
+
if (index < 0) {
|
|
4036
|
+
++this.size;
|
|
4037
|
+
data.push([key, value]);
|
|
4038
|
+
} else {
|
|
4039
|
+
data[index][1] = value;
|
|
4040
|
+
}
|
|
4041
|
+
return this;
|
|
4042
|
+
}
|
|
4043
|
+
var _listCacheSet = listCacheSet$1;
|
|
4044
|
+
var listCacheClear = _listCacheClear,
|
|
4045
|
+
listCacheDelete = _listCacheDelete,
|
|
4046
|
+
listCacheGet = _listCacheGet,
|
|
4047
|
+
listCacheHas = _listCacheHas,
|
|
4048
|
+
listCacheSet = _listCacheSet;
|
|
4049
|
+
|
|
4050
|
+
/**
|
|
4051
|
+
* Creates an list cache object.
|
|
4052
|
+
*
|
|
4053
|
+
* @private
|
|
4054
|
+
* @constructor
|
|
4055
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
4056
|
+
*/
|
|
4057
|
+
function ListCache$1(entries) {
|
|
4058
|
+
var index = -1,
|
|
4059
|
+
length = entries == null ? 0 : entries.length;
|
|
4060
|
+
this.clear();
|
|
4061
|
+
while (++index < length) {
|
|
4062
|
+
var entry = entries[index];
|
|
4063
|
+
this.set(entry[0], entry[1]);
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
|
|
4067
|
+
// Add methods to `ListCache`.
|
|
4068
|
+
ListCache$1.prototype.clear = listCacheClear;
|
|
4069
|
+
ListCache$1.prototype['delete'] = listCacheDelete;
|
|
4070
|
+
ListCache$1.prototype.get = listCacheGet;
|
|
4071
|
+
ListCache$1.prototype.has = listCacheHas;
|
|
4072
|
+
ListCache$1.prototype.set = listCacheSet;
|
|
4073
|
+
var _ListCache = ListCache$1;
|
|
4074
|
+
var getNative = _getNative,
|
|
4075
|
+
root = _root;
|
|
4076
|
+
|
|
4077
|
+
/* Built-in method references that are verified to be native. */
|
|
4078
|
+
var Map$2 = getNative(root, 'Map');
|
|
4079
|
+
var _Map = Map$2;
|
|
4080
|
+
var Hash = _Hash,
|
|
4081
|
+
ListCache = _ListCache,
|
|
4082
|
+
Map$1 = _Map;
|
|
4083
|
+
|
|
4084
|
+
/**
|
|
4085
|
+
* Removes all key-value entries from the map.
|
|
4086
|
+
*
|
|
4087
|
+
* @private
|
|
4088
|
+
* @name clear
|
|
4089
|
+
* @memberOf MapCache
|
|
4090
|
+
*/
|
|
4091
|
+
function mapCacheClear$1() {
|
|
4092
|
+
this.size = 0;
|
|
4093
|
+
this.__data__ = {
|
|
4094
|
+
'hash': new Hash(),
|
|
4095
|
+
'map': new (Map$1 || ListCache)(),
|
|
4096
|
+
'string': new Hash()
|
|
4097
|
+
};
|
|
4098
|
+
}
|
|
4099
|
+
var _mapCacheClear = mapCacheClear$1;
|
|
4100
|
+
|
|
4101
|
+
/**
|
|
4102
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
4103
|
+
*
|
|
4104
|
+
* @private
|
|
4105
|
+
* @param {*} value The value to check.
|
|
4106
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
4107
|
+
*/
|
|
4108
|
+
|
|
4109
|
+
function isKeyable$1(value) {
|
|
4110
|
+
var type = typeof value;
|
|
4111
|
+
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
|
|
4112
|
+
}
|
|
4113
|
+
var _isKeyable = isKeyable$1;
|
|
4114
|
+
var isKeyable = _isKeyable;
|
|
4115
|
+
|
|
4116
|
+
/**
|
|
4117
|
+
* Gets the data for `map`.
|
|
4118
|
+
*
|
|
4119
|
+
* @private
|
|
4120
|
+
* @param {Object} map The map to query.
|
|
4121
|
+
* @param {string} key The reference key.
|
|
4122
|
+
* @returns {*} Returns the map data.
|
|
4123
|
+
*/
|
|
4124
|
+
function getMapData$4(map, key) {
|
|
4125
|
+
var data = map.__data__;
|
|
4126
|
+
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
|
|
4127
|
+
}
|
|
4128
|
+
var _getMapData = getMapData$4;
|
|
4129
|
+
var getMapData$3 = _getMapData;
|
|
4130
|
+
|
|
4131
|
+
/**
|
|
4132
|
+
* Removes `key` and its value from the map.
|
|
4133
|
+
*
|
|
4134
|
+
* @private
|
|
4135
|
+
* @name delete
|
|
4136
|
+
* @memberOf MapCache
|
|
4137
|
+
* @param {string} key The key of the value to remove.
|
|
4138
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
4139
|
+
*/
|
|
4140
|
+
function mapCacheDelete$1(key) {
|
|
4141
|
+
var result = getMapData$3(this, key)['delete'](key);
|
|
4142
|
+
this.size -= result ? 1 : 0;
|
|
4143
|
+
return result;
|
|
4144
|
+
}
|
|
4145
|
+
var _mapCacheDelete = mapCacheDelete$1;
|
|
4146
|
+
var getMapData$2 = _getMapData;
|
|
4147
|
+
|
|
4148
|
+
/**
|
|
4149
|
+
* Gets the map value for `key`.
|
|
4150
|
+
*
|
|
4151
|
+
* @private
|
|
4152
|
+
* @name get
|
|
4153
|
+
* @memberOf MapCache
|
|
4154
|
+
* @param {string} key The key of the value to get.
|
|
4155
|
+
* @returns {*} Returns the entry value.
|
|
4156
|
+
*/
|
|
4157
|
+
function mapCacheGet$1(key) {
|
|
4158
|
+
return getMapData$2(this, key).get(key);
|
|
4159
|
+
}
|
|
4160
|
+
var _mapCacheGet = mapCacheGet$1;
|
|
4161
|
+
var getMapData$1 = _getMapData;
|
|
4162
|
+
|
|
4163
|
+
/**
|
|
4164
|
+
* Checks if a map value for `key` exists.
|
|
4165
|
+
*
|
|
4166
|
+
* @private
|
|
4167
|
+
* @name has
|
|
4168
|
+
* @memberOf MapCache
|
|
4169
|
+
* @param {string} key The key of the entry to check.
|
|
4170
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
4171
|
+
*/
|
|
4172
|
+
function mapCacheHas$1(key) {
|
|
4173
|
+
return getMapData$1(this, key).has(key);
|
|
4174
|
+
}
|
|
4175
|
+
var _mapCacheHas = mapCacheHas$1;
|
|
4176
|
+
var getMapData = _getMapData;
|
|
4177
|
+
|
|
4178
|
+
/**
|
|
4179
|
+
* Sets the map `key` to `value`.
|
|
4180
|
+
*
|
|
4181
|
+
* @private
|
|
4182
|
+
* @name set
|
|
4183
|
+
* @memberOf MapCache
|
|
4184
|
+
* @param {string} key The key of the value to set.
|
|
4185
|
+
* @param {*} value The value to set.
|
|
4186
|
+
* @returns {Object} Returns the map cache instance.
|
|
4187
|
+
*/
|
|
4188
|
+
function mapCacheSet$1(key, value) {
|
|
4189
|
+
var data = getMapData(this, key),
|
|
4190
|
+
size = data.size;
|
|
4191
|
+
data.set(key, value);
|
|
4192
|
+
this.size += data.size == size ? 0 : 1;
|
|
4193
|
+
return this;
|
|
4194
|
+
}
|
|
4195
|
+
var _mapCacheSet = mapCacheSet$1;
|
|
4196
|
+
var mapCacheClear = _mapCacheClear,
|
|
4197
|
+
mapCacheDelete = _mapCacheDelete,
|
|
4198
|
+
mapCacheGet = _mapCacheGet,
|
|
4199
|
+
mapCacheHas = _mapCacheHas,
|
|
4200
|
+
mapCacheSet = _mapCacheSet;
|
|
4201
|
+
|
|
4202
|
+
/**
|
|
4203
|
+
* Creates a map cache object to store key-value pairs.
|
|
4204
|
+
*
|
|
4205
|
+
* @private
|
|
4206
|
+
* @constructor
|
|
4207
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
4208
|
+
*/
|
|
4209
|
+
function MapCache$1(entries) {
|
|
4210
|
+
var index = -1,
|
|
4211
|
+
length = entries == null ? 0 : entries.length;
|
|
4212
|
+
this.clear();
|
|
4213
|
+
while (++index < length) {
|
|
4214
|
+
var entry = entries[index];
|
|
4215
|
+
this.set(entry[0], entry[1]);
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
|
|
4219
|
+
// Add methods to `MapCache`.
|
|
4220
|
+
MapCache$1.prototype.clear = mapCacheClear;
|
|
4221
|
+
MapCache$1.prototype['delete'] = mapCacheDelete;
|
|
4222
|
+
MapCache$1.prototype.get = mapCacheGet;
|
|
4223
|
+
MapCache$1.prototype.has = mapCacheHas;
|
|
4224
|
+
MapCache$1.prototype.set = mapCacheSet;
|
|
4225
|
+
var _MapCache = MapCache$1;
|
|
4226
|
+
var MapCache = _MapCache;
|
|
4227
|
+
|
|
4228
|
+
/** Error message constants. */
|
|
4229
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
4230
|
+
|
|
4231
|
+
/**
|
|
4232
|
+
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
4233
|
+
* provided, it determines the cache key for storing the result based on the
|
|
4234
|
+
* arguments provided to the memoized function. By default, the first argument
|
|
4235
|
+
* provided to the memoized function is used as the map cache key. The `func`
|
|
4236
|
+
* is invoked with the `this` binding of the memoized function.
|
|
4237
|
+
*
|
|
4238
|
+
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
4239
|
+
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
4240
|
+
* constructor with one whose instances implement the
|
|
4241
|
+
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
4242
|
+
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
4243
|
+
*
|
|
4244
|
+
* @static
|
|
4245
|
+
* @memberOf _
|
|
4246
|
+
* @since 0.1.0
|
|
4247
|
+
* @category Function
|
|
4248
|
+
* @param {Function} func The function to have its output memoized.
|
|
4249
|
+
* @param {Function} [resolver] The function to resolve the cache key.
|
|
4250
|
+
* @returns {Function} Returns the new memoized function.
|
|
4251
|
+
* @example
|
|
4252
|
+
*
|
|
4253
|
+
* var object = { 'a': 1, 'b': 2 };
|
|
4254
|
+
* var other = { 'c': 3, 'd': 4 };
|
|
4255
|
+
*
|
|
4256
|
+
* var values = _.memoize(_.values);
|
|
4257
|
+
* values(object);
|
|
4258
|
+
* // => [1, 2]
|
|
4259
|
+
*
|
|
4260
|
+
* values(other);
|
|
4261
|
+
* // => [3, 4]
|
|
4262
|
+
*
|
|
4263
|
+
* object.a = 2;
|
|
4264
|
+
* values(object);
|
|
4265
|
+
* // => [1, 2]
|
|
4266
|
+
*
|
|
4267
|
+
* // Modify the result cache.
|
|
4268
|
+
* values.cache.set(object, ['a', 'b']);
|
|
4269
|
+
* values(object);
|
|
4270
|
+
* // => ['a', 'b']
|
|
4271
|
+
*
|
|
4272
|
+
* // Replace `_.memoize.Cache`.
|
|
4273
|
+
* _.memoize.Cache = WeakMap;
|
|
4274
|
+
*/
|
|
4275
|
+
function memoize$1(func, resolver) {
|
|
4276
|
+
if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
|
|
4277
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
4278
|
+
}
|
|
4279
|
+
var memoized = function () {
|
|
4280
|
+
var args = arguments,
|
|
4281
|
+
key = resolver ? resolver.apply(this, args) : args[0],
|
|
4282
|
+
cache = memoized.cache;
|
|
4283
|
+
if (cache.has(key)) {
|
|
4284
|
+
return cache.get(key);
|
|
4285
|
+
}
|
|
4286
|
+
var result = func.apply(this, args);
|
|
4287
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
4288
|
+
return result;
|
|
4289
|
+
};
|
|
4290
|
+
memoized.cache = new (memoize$1.Cache || MapCache)();
|
|
4291
|
+
return memoized;
|
|
4292
|
+
}
|
|
4293
|
+
|
|
4294
|
+
// Expose `MapCache`.
|
|
4295
|
+
memoize$1.Cache = MapCache;
|
|
4296
|
+
var memoize_1 = memoize$1;
|
|
4297
|
+
var memoize = memoize_1;
|
|
4298
|
+
|
|
4299
|
+
/** Used as the maximum memoize cache size. */
|
|
4300
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
4301
|
+
|
|
4302
|
+
/**
|
|
4303
|
+
* A specialized version of `_.memoize` which clears the memoized function's
|
|
4304
|
+
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
|
4305
|
+
*
|
|
4306
|
+
* @private
|
|
4307
|
+
* @param {Function} func The function to have its output memoized.
|
|
4308
|
+
* @returns {Function} Returns the new memoized function.
|
|
4309
|
+
*/
|
|
4310
|
+
function memoizeCapped$1(func) {
|
|
4311
|
+
var result = memoize(func, function (key) {
|
|
4312
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
4313
|
+
cache.clear();
|
|
4314
|
+
}
|
|
4315
|
+
return key;
|
|
4316
|
+
});
|
|
4317
|
+
var cache = result.cache;
|
|
4318
|
+
return result;
|
|
4319
|
+
}
|
|
4320
|
+
var _memoizeCapped = memoizeCapped$1;
|
|
4321
|
+
var memoizeCapped = _memoizeCapped;
|
|
4322
|
+
|
|
4323
|
+
/** Used to match property names within property paths. */
|
|
4324
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
4325
|
+
|
|
4326
|
+
/** Used to match backslashes in property paths. */
|
|
4327
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
4328
|
+
|
|
4329
|
+
/**
|
|
4330
|
+
* Converts `string` to a property path array.
|
|
4331
|
+
*
|
|
4332
|
+
* @private
|
|
4333
|
+
* @param {string} string The string to convert.
|
|
4334
|
+
* @returns {Array} Returns the property path array.
|
|
4335
|
+
*/
|
|
4336
|
+
var stringToPath$1 = memoizeCapped(function (string) {
|
|
4337
|
+
var result = [];
|
|
4338
|
+
if (string.charCodeAt(0) === 46 /* . */) {
|
|
4339
|
+
result.push('');
|
|
4340
|
+
}
|
|
4341
|
+
string.replace(rePropName, function (match, number, quote, subString) {
|
|
4342
|
+
result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
|
|
4343
|
+
});
|
|
4344
|
+
return result;
|
|
4345
|
+
});
|
|
4346
|
+
var _stringToPath = stringToPath$1;
|
|
4347
|
+
|
|
4348
|
+
/**
|
|
4349
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
4350
|
+
* shorthands.
|
|
4351
|
+
*
|
|
4352
|
+
* @private
|
|
4353
|
+
* @param {Array} [array] The array to iterate over.
|
|
4354
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
4355
|
+
* @returns {Array} Returns the new mapped array.
|
|
4356
|
+
*/
|
|
4357
|
+
|
|
4358
|
+
function arrayMap$1(array, iteratee) {
|
|
4359
|
+
var index = -1,
|
|
4360
|
+
length = array == null ? 0 : array.length,
|
|
4361
|
+
result = Array(length);
|
|
4362
|
+
while (++index < length) {
|
|
4363
|
+
result[index] = iteratee(array[index], index, array);
|
|
4364
|
+
}
|
|
4365
|
+
return result;
|
|
4366
|
+
}
|
|
4367
|
+
var _arrayMap = arrayMap$1;
|
|
4368
|
+
var Symbol = _Symbol,
|
|
4369
|
+
arrayMap = _arrayMap,
|
|
4370
|
+
isArray$1 = isArray_1,
|
|
4371
|
+
isSymbol$1 = isSymbol_1;
|
|
4372
|
+
|
|
4373
|
+
/** Used as references for various `Number` constants. */
|
|
4374
|
+
var INFINITY$1 = 1 / 0;
|
|
4375
|
+
|
|
4376
|
+
/** Used to convert symbols to primitives and strings. */
|
|
4377
|
+
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|
4378
|
+
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
4379
|
+
|
|
4380
|
+
/**
|
|
4381
|
+
* The base implementation of `_.toString` which doesn't convert nullish
|
|
4382
|
+
* values to empty strings.
|
|
4383
|
+
*
|
|
4384
|
+
* @private
|
|
4385
|
+
* @param {*} value The value to process.
|
|
4386
|
+
* @returns {string} Returns the string.
|
|
4387
|
+
*/
|
|
4388
|
+
function baseToString$1(value) {
|
|
4389
|
+
// Exit early for strings to avoid a performance hit in some environments.
|
|
4390
|
+
if (typeof value == 'string') {
|
|
4391
|
+
return value;
|
|
4392
|
+
}
|
|
4393
|
+
if (isArray$1(value)) {
|
|
4394
|
+
// Recursively convert values (susceptible to call stack limits).
|
|
4395
|
+
return arrayMap(value, baseToString$1) + '';
|
|
4396
|
+
}
|
|
4397
|
+
if (isSymbol$1(value)) {
|
|
4398
|
+
return symbolToString ? symbolToString.call(value) : '';
|
|
4399
|
+
}
|
|
4400
|
+
var result = value + '';
|
|
4401
|
+
return result == '0' && 1 / value == -INFINITY$1 ? '-0' : result;
|
|
4402
|
+
}
|
|
4403
|
+
var _baseToString = baseToString$1;
|
|
4404
|
+
var baseToString = _baseToString;
|
|
4405
|
+
|
|
4406
|
+
/**
|
|
4407
|
+
* Converts `value` to a string. An empty string is returned for `null`
|
|
4408
|
+
* and `undefined` values. The sign of `-0` is preserved.
|
|
4409
|
+
*
|
|
4410
|
+
* @static
|
|
4411
|
+
* @memberOf _
|
|
4412
|
+
* @since 4.0.0
|
|
4413
|
+
* @category Lang
|
|
4414
|
+
* @param {*} value The value to convert.
|
|
4415
|
+
* @returns {string} Returns the converted string.
|
|
4416
|
+
* @example
|
|
4417
|
+
*
|
|
4418
|
+
* _.toString(null);
|
|
4419
|
+
* // => ''
|
|
4420
|
+
*
|
|
4421
|
+
* _.toString(-0);
|
|
4422
|
+
* // => '-0'
|
|
4423
|
+
*
|
|
4424
|
+
* _.toString([1, 2, 3]);
|
|
4425
|
+
* // => '1,2,3'
|
|
4426
|
+
*/
|
|
4427
|
+
function toString$1(value) {
|
|
4428
|
+
return value == null ? '' : baseToString(value);
|
|
4429
|
+
}
|
|
4430
|
+
var toString_1 = toString$1;
|
|
4431
|
+
var isArray = isArray_1,
|
|
4432
|
+
isKey = _isKey,
|
|
4433
|
+
stringToPath = _stringToPath,
|
|
4434
|
+
toString = toString_1;
|
|
4435
|
+
|
|
4436
|
+
/**
|
|
4437
|
+
* Casts `value` to a path array if it's not one.
|
|
4438
|
+
*
|
|
4439
|
+
* @private
|
|
4440
|
+
* @param {*} value The value to inspect.
|
|
4441
|
+
* @param {Object} [object] The object to query keys on.
|
|
4442
|
+
* @returns {Array} Returns the cast property path array.
|
|
4443
|
+
*/
|
|
4444
|
+
function castPath$1(value, object) {
|
|
4445
|
+
if (isArray(value)) {
|
|
4446
|
+
return value;
|
|
4447
|
+
}
|
|
4448
|
+
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
|
4449
|
+
}
|
|
4450
|
+
var _castPath = castPath$1;
|
|
4451
|
+
var isSymbol = isSymbol_1;
|
|
4452
|
+
|
|
4453
|
+
/** Used as references for various `Number` constants. */
|
|
4454
|
+
var INFINITY = 1 / 0;
|
|
4455
|
+
|
|
4456
|
+
/**
|
|
4457
|
+
* Converts `value` to a string key if it's not a string or symbol.
|
|
4458
|
+
*
|
|
4459
|
+
* @private
|
|
4460
|
+
* @param {*} value The value to inspect.
|
|
4461
|
+
* @returns {string|symbol} Returns the key.
|
|
4462
|
+
*/
|
|
4463
|
+
function toKey$1(value) {
|
|
4464
|
+
if (typeof value == 'string' || isSymbol(value)) {
|
|
4465
|
+
return value;
|
|
4466
|
+
}
|
|
4467
|
+
var result = value + '';
|
|
4468
|
+
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
|
|
4469
|
+
}
|
|
4470
|
+
var _toKey = toKey$1;
|
|
4471
|
+
var castPath = _castPath,
|
|
4472
|
+
toKey = _toKey;
|
|
4473
|
+
|
|
4474
|
+
/**
|
|
4475
|
+
* The base implementation of `_.get` without support for default values.
|
|
4476
|
+
*
|
|
4477
|
+
* @private
|
|
4478
|
+
* @param {Object} object The object to query.
|
|
4479
|
+
* @param {Array|string} path The path of the property to get.
|
|
4480
|
+
* @returns {*} Returns the resolved value.
|
|
4481
|
+
*/
|
|
4482
|
+
function baseGet$1(object, path) {
|
|
4483
|
+
path = castPath(path, object);
|
|
4484
|
+
var index = 0,
|
|
4485
|
+
length = path.length;
|
|
4486
|
+
while (object != null && index < length) {
|
|
4487
|
+
object = object[toKey(path[index++])];
|
|
4488
|
+
}
|
|
4489
|
+
return index && index == length ? object : undefined;
|
|
4490
|
+
}
|
|
4491
|
+
var _baseGet = baseGet$1;
|
|
4492
|
+
var baseGet = _baseGet;
|
|
4493
|
+
|
|
4494
|
+
/**
|
|
4495
|
+
* Gets the value at `path` of `object`. If the resolved value is
|
|
4496
|
+
* `undefined`, the `defaultValue` is returned in its place.
|
|
4497
|
+
*
|
|
4498
|
+
* @static
|
|
4499
|
+
* @memberOf _
|
|
4500
|
+
* @since 3.7.0
|
|
4501
|
+
* @category Object
|
|
4502
|
+
* @param {Object} object The object to query.
|
|
4503
|
+
* @param {Array|string} path The path of the property to get.
|
|
4504
|
+
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
|
4505
|
+
* @returns {*} Returns the resolved value.
|
|
4506
|
+
* @example
|
|
4507
|
+
*
|
|
4508
|
+
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
|
4509
|
+
*
|
|
4510
|
+
* _.get(object, 'a[0].b.c');
|
|
4511
|
+
* // => 3
|
|
4512
|
+
*
|
|
4513
|
+
* _.get(object, ['a', '0', 'b', 'c']);
|
|
4514
|
+
* // => 3
|
|
4515
|
+
*
|
|
4516
|
+
* _.get(object, 'a.b.c', 'default');
|
|
4517
|
+
* // => 'default'
|
|
4518
|
+
*/
|
|
4519
|
+
function get(object, path, defaultValue) {
|
|
4520
|
+
var result = object == null ? undefined : baseGet(object, path);
|
|
4521
|
+
return result === undefined ? defaultValue : result;
|
|
4522
|
+
}
|
|
4523
|
+
var get_1 = get;
|
|
4524
|
+
var get$1 = /*@__PURE__*/getDefaultExportFromCjs(get_1);
|
|
4525
|
+
const getLanguageParams = (select, document) => {
|
|
4526
|
+
if (!select || !document) {
|
|
4527
|
+
return {};
|
|
4528
|
+
}
|
|
4529
|
+
const selection = select || {};
|
|
4530
|
+
const selectedValue = {};
|
|
4531
|
+
for (const [key, path] of Object.entries(selection)) {
|
|
4532
|
+
let value = get$1(document, path);
|
|
4533
|
+
if (Array.isArray(value)) {
|
|
4534
|
+
value = value.filter(item => typeof item === "object" ? (item == null ? void 0 : item._type) !== "reference" || "_ref" in item : true);
|
|
4535
|
+
}
|
|
4536
|
+
selectedValue[key] = value;
|
|
4537
|
+
}
|
|
4538
|
+
return selectedValue;
|
|
4539
|
+
};
|
|
4540
|
+
const FieldTranslationContext = createContext({
|
|
4541
|
+
openFieldTranslation: () => {},
|
|
4542
|
+
translationLoading: false
|
|
4543
|
+
});
|
|
4544
|
+
function useFieldTranslation() {
|
|
4545
|
+
return useContext(FieldTranslationContext);
|
|
4546
|
+
}
|
|
4547
|
+
function FieldTranslationProvider(props) {
|
|
4548
|
+
var _a, _b;
|
|
4549
|
+
const {
|
|
4550
|
+
config: assistConfig
|
|
4551
|
+
} = useAiAssistanceConfig();
|
|
4552
|
+
const apiClient = useApiClient(assistConfig.__customApiClient);
|
|
4553
|
+
const config = (_a = assistConfig.translate) == null ? void 0 : _a.field;
|
|
4554
|
+
const {
|
|
4555
|
+
translate: runTranslate
|
|
4556
|
+
} = useTranslate(apiClient);
|
|
4557
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
4558
|
+
const [document, setDocument] = useState();
|
|
4559
|
+
const [documentSchema, setDocumentSchema] = useState();
|
|
4560
|
+
const [languages, setLanguages] = useState();
|
|
4561
|
+
const [fromLanguage, setFromLanguage] = useState(void 0);
|
|
4562
|
+
const [toLanguages, setToLanguages] = useState(void 0);
|
|
4563
|
+
const [translationMap, setTranslationMap] = useState();
|
|
4564
|
+
const close = useCallback(() => {
|
|
4565
|
+
setDialogOpen(false);
|
|
4566
|
+
setLanguages(void 0);
|
|
4567
|
+
setDocument(void 0);
|
|
4568
|
+
setDocument(void 0);
|
|
4569
|
+
}, []);
|
|
4570
|
+
const languageClient = useClient({
|
|
4571
|
+
apiVersion: (_b = config == null ? void 0 : config.apiVersion) != null ? _b : "2022-11-27"
|
|
4572
|
+
});
|
|
4573
|
+
const documentId = document == null ? void 0 : document._id;
|
|
4574
|
+
const id = useId();
|
|
4575
|
+
const selectFromLanguage = useCallback((from, languages2, document2, documentSchema2) => {
|
|
4576
|
+
var _a2, _b2;
|
|
4577
|
+
setFromLanguage(from);
|
|
4578
|
+
if (!document2 || !documentSchema2 || !languages2) {
|
|
4579
|
+
setTranslationMap(void 0);
|
|
4580
|
+
return;
|
|
4581
|
+
}
|
|
4582
|
+
const to = languages2.filter(l => l.id !== (from == null ? void 0 : from.id));
|
|
4583
|
+
setToLanguages(to);
|
|
4584
|
+
const fromId = from == null ? void 0 : from.id;
|
|
4585
|
+
const toIds = (_a2 = to == null ? void 0 : to.map(l => l.id)) != null ? _a2 : [];
|
|
4586
|
+
const docMembers = getDocumentMembersFlat(document2, documentSchema2);
|
|
4587
|
+
if (fromId && (toIds == null ? void 0 : toIds.length)) {
|
|
4588
|
+
const transMap = getTranslationMap(documentSchema2, docMembers, fromId, toIds, (_b2 = config == null ? void 0 : config.translationOutputs) != null ? _b2 : defaultLanguageOutputs);
|
|
4589
|
+
setTranslationMap(transMap);
|
|
4590
|
+
} else {
|
|
4591
|
+
setTranslationMap(void 0);
|
|
4592
|
+
}
|
|
4593
|
+
}, [config]);
|
|
4594
|
+
const toggleToLanguage = useCallback((toggledLang, toLanguages2, languages2) => {
|
|
4595
|
+
if (!languages2) {
|
|
4596
|
+
return;
|
|
4597
|
+
}
|
|
4598
|
+
const wasSelected = !!(toLanguages2 == null ? void 0 : toLanguages2.find(l => l.id === toggledLang.id));
|
|
4599
|
+
const newToLangs = languages2.filter(anyLang => !!(toLanguages2 == null ? void 0 : toLanguages2.find(selectedLang => toggledLang.id !== selectedLang.id && selectedLang.id === anyLang.id)) || toggledLang.id === anyLang.id && !wasSelected);
|
|
4600
|
+
setToLanguages(newToLangs);
|
|
4601
|
+
}, []);
|
|
4602
|
+
const contextValue = useMemo(() => {
|
|
4603
|
+
return {
|
|
4604
|
+
openFieldTranslation: async (document2, documentSchema2) => {
|
|
4605
|
+
setDialogOpen(true);
|
|
4606
|
+
const languageParams = getLanguageParams(config == null ? void 0 : config.selectLanguageParams, document2);
|
|
4607
|
+
const languages2 = await (typeof (config == null ? void 0 : config.languages) === "function" ? config == null ? void 0 : config.languages(languageClient, languageParams) : Promise.resolve(config == null ? void 0 : config.languages));
|
|
4608
|
+
setLanguages(languages2);
|
|
4609
|
+
setDocument(document2);
|
|
4610
|
+
setDocumentSchema(documentSchema2);
|
|
4611
|
+
const fromLanguage2 = languages2 == null ? void 0 : languages2[0];
|
|
4612
|
+
if (fromLanguage2) {
|
|
4613
|
+
selectFromLanguage(fromLanguage2, languages2, document2, documentSchema2);
|
|
4614
|
+
} else {
|
|
4615
|
+
console.error("No languages available for selected language params", languageParams);
|
|
4616
|
+
}
|
|
4617
|
+
},
|
|
4618
|
+
translationLoading: false
|
|
4619
|
+
};
|
|
4620
|
+
}, [selectFromLanguage, config, languageClient]);
|
|
4621
|
+
const runDisabled = !fromLanguage || !(toLanguages == null ? void 0 : toLanguages.length) || !(translationMap == null ? void 0 : translationMap.length) || !documentId;
|
|
4622
|
+
const onRunTranslation = useCallback(() => {
|
|
4623
|
+
if (translationMap && documentId) {
|
|
4624
|
+
runTranslate({
|
|
4625
|
+
documentId,
|
|
4626
|
+
fieldLanguageMap: translationMap.map(map => ({
|
|
4627
|
+
...map,
|
|
4628
|
+
// eslint-disable-next-line max-nested-callbacks
|
|
4629
|
+
outputs: map.outputs.filter(out => !!(toLanguages == null ? void 0 : toLanguages.find(l => l.id === out.id)))
|
|
4630
|
+
}))
|
|
4631
|
+
});
|
|
4632
|
+
}
|
|
4633
|
+
close();
|
|
4634
|
+
}, [translationMap, documentId, runTranslate, close, toLanguages]);
|
|
4635
|
+
const runButton = /* @__PURE__ */jsx(Button, {
|
|
4636
|
+
text: "Translate",
|
|
4637
|
+
tone: "primary",
|
|
4638
|
+
icon: PlayIcon,
|
|
4639
|
+
style: {
|
|
4640
|
+
width: "100%"
|
|
4641
|
+
},
|
|
4642
|
+
disabled: runDisabled,
|
|
4643
|
+
onClick: onRunTranslation
|
|
4644
|
+
});
|
|
4645
|
+
return /* @__PURE__ */jsxs(FieldTranslationContext.Provider, {
|
|
4646
|
+
value: contextValue,
|
|
4647
|
+
children: [dialogOpen ? /* @__PURE__ */jsx(Dialog, {
|
|
4648
|
+
id,
|
|
4649
|
+
width: 1,
|
|
4650
|
+
open: dialogOpen,
|
|
4651
|
+
onClose: close,
|
|
4652
|
+
header: "Translate fields",
|
|
4653
|
+
footer: /* @__PURE__ */jsx(Flex, {
|
|
4654
|
+
justify: "space-between",
|
|
4655
|
+
padding: 2,
|
|
4656
|
+
flex: 1,
|
|
4657
|
+
children: runDisabled ? /* @__PURE__ */jsx(Tooltip, {
|
|
4658
|
+
content: /* @__PURE__ */jsx(Flex, {
|
|
4659
|
+
padding: 2,
|
|
4660
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
4661
|
+
children: "Nothing to translate."
|
|
4662
|
+
})
|
|
4663
|
+
}),
|
|
4664
|
+
placement: "top",
|
|
4665
|
+
children: /* @__PURE__ */jsx(Flex, {
|
|
4666
|
+
flex: 1,
|
|
4667
|
+
children: runButton
|
|
4668
|
+
})
|
|
4669
|
+
}) : runButton
|
|
4670
|
+
}),
|
|
4671
|
+
children: languages ? /* @__PURE__ */jsxs(Flex, {
|
|
4672
|
+
padding: 4,
|
|
4673
|
+
gap: 5,
|
|
4674
|
+
align: "flex-start",
|
|
4675
|
+
justify: "center",
|
|
4676
|
+
children: [/* @__PURE__ */jsxs(Stack, {
|
|
4677
|
+
space: 2,
|
|
4678
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
4679
|
+
marginBottom: 2,
|
|
4680
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
4681
|
+
weight: "semibold",
|
|
4682
|
+
children: "From"
|
|
4683
|
+
})
|
|
4684
|
+
}), languages == null ? void 0 : languages.map(l => {
|
|
4685
|
+
var _a2;
|
|
4686
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
4687
|
+
gap: 3,
|
|
4688
|
+
align: "center",
|
|
4689
|
+
children: [/* @__PURE__ */jsx(Radio, {
|
|
4690
|
+
name: "fromLang",
|
|
4691
|
+
value: l.id,
|
|
4692
|
+
checked: l.id === (fromLanguage == null ? void 0 : fromLanguage.id),
|
|
4693
|
+
onClick: () => selectFromLanguage(l, languages, document, documentSchema)
|
|
4694
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
4695
|
+
children: (_a2 = l.title) != null ? _a2 : l.id
|
|
4696
|
+
})]
|
|
4697
|
+
}, l.id);
|
|
4698
|
+
})]
|
|
4699
|
+
}), /* @__PURE__ */jsxs(Stack, {
|
|
4700
|
+
space: 2,
|
|
4701
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
4702
|
+
marginBottom: 2,
|
|
4703
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
4704
|
+
weight: "semibold",
|
|
4705
|
+
children: "To"
|
|
4706
|
+
})
|
|
4707
|
+
}), languages == null ? void 0 : languages.filter(l => l.id !== (fromLanguage == null ? void 0 : fromLanguage.id)).map(l => {
|
|
4708
|
+
var _a2;
|
|
4709
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
4710
|
+
gap: 3,
|
|
4711
|
+
align: "center",
|
|
4712
|
+
children: [/* @__PURE__ */jsx(Checkbox, {
|
|
4713
|
+
name: "toLang",
|
|
4714
|
+
value: l.id,
|
|
4715
|
+
checked: !!(toLanguages == null ? void 0 : toLanguages.find(tl => tl.id === l.id)),
|
|
4716
|
+
onClick: () => toggleToLanguage(l, toLanguages, languages),
|
|
4717
|
+
disabled: !(translationMap == null ? void 0 : translationMap.find(tm => tm.outputs.find(o => o.id === l.id)))
|
|
4718
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
4719
|
+
children: (_a2 = l.title) != null ? _a2 : l.id
|
|
4720
|
+
})]
|
|
4721
|
+
}, l.id);
|
|
4722
|
+
})]
|
|
4723
|
+
})]
|
|
4724
|
+
}) : /* @__PURE__ */jsxs(Flex, {
|
|
4725
|
+
padding: 4,
|
|
4726
|
+
gap: 2,
|
|
4727
|
+
align: "flex-start",
|
|
4728
|
+
justify: "center",
|
|
4729
|
+
children: [/* @__PURE__ */jsx(Box, {
|
|
4730
|
+
children: /* @__PURE__ */jsx(Spinner, {})
|
|
4731
|
+
}), /* @__PURE__ */jsx(Text, {
|
|
4732
|
+
children: "Loading languages..."
|
|
4733
|
+
})]
|
|
4734
|
+
})
|
|
4735
|
+
}) : null, props.children]
|
|
4736
|
+
});
|
|
4737
|
+
}
|
|
3201
4738
|
function AssistLayout(props) {
|
|
3202
4739
|
var _a;
|
|
3203
4740
|
const [connectors, setConnectors] = useState([]);
|
|
@@ -3205,14 +4742,16 @@ function AssistLayout(props) {
|
|
|
3205
4742
|
return /* @__PURE__ */jsxs(AiAssistanceConfigProvider, {
|
|
3206
4743
|
config: props.config,
|
|
3207
4744
|
children: [migrate ? /* @__PURE__ */jsx(AlphaMigration, {}) : null, /* @__PURE__ */jsx(RunInstructionProvider, {
|
|
3208
|
-
children: /* @__PURE__ */
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
4745
|
+
children: /* @__PURE__ */jsx(FieldTranslationProvider, {
|
|
4746
|
+
children: /* @__PURE__ */jsxs(ConnectorsProvider, {
|
|
4747
|
+
onConnectorsChange: setConnectors,
|
|
4748
|
+
children: [props.renderDefault(props), /* @__PURE__ */jsx(ThemeProvider, {
|
|
4749
|
+
tone: "default",
|
|
4750
|
+
children: /* @__PURE__ */jsx(AssistConnectorsOverlay, {
|
|
4751
|
+
connectors
|
|
4752
|
+
})
|
|
4753
|
+
})]
|
|
4754
|
+
})
|
|
3216
4755
|
})
|
|
3217
4756
|
})]
|
|
3218
4757
|
});
|
|
@@ -3308,6 +4847,7 @@ function AssistFormBlock(props) {
|
|
|
3308
4847
|
_key: key
|
|
3309
4848
|
}));
|
|
3310
4849
|
}, [onChange, key]);
|
|
4850
|
+
const singlePresence = presence[0];
|
|
3311
4851
|
return /* @__PURE__ */jsx(ErrorWrapper, {
|
|
3312
4852
|
onChange: localOnChange,
|
|
3313
4853
|
children: /* @__PURE__ */jsxs(Flex, {
|
|
@@ -3316,9 +4856,9 @@ function AssistFormBlock(props) {
|
|
|
3316
4856
|
children: [/* @__PURE__ */jsx(Box, {
|
|
3317
4857
|
flex: 1,
|
|
3318
4858
|
children: props.renderDefault(props)
|
|
3319
|
-
}),
|
|
3320
|
-
presence:
|
|
3321
|
-
}
|
|
4859
|
+
}), singlePresence && /* @__PURE__ */jsx(AiFieldPresence, {
|
|
4860
|
+
presence: singlePresence
|
|
4861
|
+
})]
|
|
3322
4862
|
})
|
|
3323
4863
|
});
|
|
3324
4864
|
}
|
|
@@ -3362,16 +4902,24 @@ function InstructionInput(props) {
|
|
|
3362
4902
|
...props
|
|
3363
4903
|
}), /* @__PURE__ */jsx(ShareField, {
|
|
3364
4904
|
...props
|
|
3365
|
-
}), /* @__PURE__ */jsx(
|
|
4905
|
+
}), /* @__PURE__ */jsx(ObjectMember, {
|
|
4906
|
+
fieldName: "prompt",
|
|
4907
|
+
...props
|
|
4908
|
+
}), /* @__PURE__ */jsx(ObjectMember, {
|
|
4909
|
+
fieldName: "output",
|
|
3366
4910
|
...props
|
|
3367
4911
|
})]
|
|
3368
4912
|
});
|
|
3369
4913
|
}
|
|
3370
|
-
function
|
|
3371
|
-
|
|
3372
|
-
|
|
4914
|
+
function ObjectMember(_ref11) {
|
|
4915
|
+
let {
|
|
4916
|
+
fieldName,
|
|
4917
|
+
...props
|
|
4918
|
+
} = _ref11;
|
|
4919
|
+
const member = findFieldMember(props.members, fieldName);
|
|
4920
|
+
return member ? /* @__PURE__ */jsx(ObjectInputMember, {
|
|
3373
4921
|
...props,
|
|
3374
|
-
member
|
|
4922
|
+
member
|
|
3375
4923
|
}) : null;
|
|
3376
4924
|
}
|
|
3377
4925
|
const NONE = [];
|
|
@@ -3506,8 +5054,8 @@ function IconInput(props) {
|
|
|
3506
5054
|
onChange
|
|
3507
5055
|
} = props;
|
|
3508
5056
|
const id = useId();
|
|
3509
|
-
const items = useMemo(() => Object.entries(icons).map(
|
|
3510
|
-
let [key, icon] =
|
|
5057
|
+
const items = useMemo(() => Object.entries(icons).map(_ref12 => {
|
|
5058
|
+
let [key, icon] = _ref12;
|
|
3511
5059
|
return /* @__PURE__ */jsx(IconItem, {
|
|
3512
5060
|
iconKey: key,
|
|
3513
5061
|
icon,
|
|
@@ -3535,12 +5083,12 @@ function IconInput(props) {
|
|
|
3535
5083
|
}
|
|
3536
5084
|
});
|
|
3537
5085
|
}
|
|
3538
|
-
function IconItem(
|
|
5086
|
+
function IconItem(_ref13) {
|
|
3539
5087
|
let {
|
|
3540
5088
|
icon,
|
|
3541
5089
|
iconKey: key,
|
|
3542
5090
|
onChange
|
|
3543
|
-
} =
|
|
5091
|
+
} = _ref13;
|
|
3544
5092
|
const onClick = useCallback(() => onChange(set(key)), [onChange, key]);
|
|
3545
5093
|
return /* @__PURE__ */jsx(MenuItem, {
|
|
3546
5094
|
icon,
|
|
@@ -3551,8 +5099,8 @@ function IconItem(_ref11) {
|
|
|
3551
5099
|
}
|
|
3552
5100
|
function getIcon(iconName) {
|
|
3553
5101
|
var _a, _b;
|
|
3554
|
-
return (_b = (_a = Object.entries(icons).find(
|
|
3555
|
-
let [key] =
|
|
5102
|
+
return (_b = (_a = Object.entries(icons).find(_ref14 => {
|
|
5103
|
+
let [key] = _ref14;
|
|
3556
5104
|
return key === iconName;
|
|
3557
5105
|
})) == null ? void 0 : _a[1]) != null ? _b : icons.sparkles;
|
|
3558
5106
|
}
|
|
@@ -3711,11 +5259,11 @@ const contextDocumentSchema = defineType({
|
|
|
3711
5259
|
title: "title",
|
|
3712
5260
|
context: "context"
|
|
3713
5261
|
},
|
|
3714
|
-
prepare(
|
|
5262
|
+
prepare(_ref15) {
|
|
3715
5263
|
let {
|
|
3716
5264
|
title,
|
|
3717
5265
|
context
|
|
3718
|
-
} =
|
|
5266
|
+
} = _ref15;
|
|
3719
5267
|
var _a;
|
|
3720
5268
|
const text = context == null ? void 0 : context.flatMap(block => block == null ? void 0 : block.children).flatMap(child => {
|
|
3721
5269
|
var _a2;
|
|
@@ -3801,6 +5349,200 @@ function InstructionsArrayField(props) {
|
|
|
3801
5349
|
title: " "
|
|
3802
5350
|
});
|
|
3803
5351
|
}
|
|
5352
|
+
function InstructionOutputField(props) {
|
|
5353
|
+
var _a;
|
|
5354
|
+
const {
|
|
5355
|
+
fieldSchema
|
|
5356
|
+
} = (_a = useContext(SelectedFieldContext)) != null ? _a : {};
|
|
5357
|
+
if (!fieldSchema || !(isObjectSchemaType(fieldSchema) || isArrayOfObjectsSchemaType(fieldSchema))) {
|
|
5358
|
+
return null;
|
|
5359
|
+
}
|
|
5360
|
+
return /* @__PURE__ */jsx(EnabledOutputField, {
|
|
5361
|
+
...props,
|
|
5362
|
+
fieldSchema,
|
|
5363
|
+
children: props.children
|
|
5364
|
+
});
|
|
5365
|
+
}
|
|
5366
|
+
function EnabledOutputField(_ref16) {
|
|
5367
|
+
let {
|
|
5368
|
+
fieldSchema,
|
|
5369
|
+
...props
|
|
5370
|
+
} = _ref16;
|
|
5371
|
+
var _a;
|
|
5372
|
+
const [open, setOpen] = useState(!!((_a = props.value) == null ? void 0 : _a.length));
|
|
5373
|
+
const onExpand = useCallback(() => setOpen(true), []);
|
|
5374
|
+
const onCollapse = useCallback(() => setOpen(false), []);
|
|
5375
|
+
return props.renderDefault({
|
|
5376
|
+
...props,
|
|
5377
|
+
collapsible: true,
|
|
5378
|
+
onExpand,
|
|
5379
|
+
onCollapse,
|
|
5380
|
+
collapsed: !open,
|
|
5381
|
+
level: 1,
|
|
5382
|
+
title: isObjectSchemaType(fieldSchema) ? "Allowed fields" : "Allowed types"
|
|
5383
|
+
});
|
|
5384
|
+
}
|
|
5385
|
+
function InstructionOutputInput(props) {
|
|
5386
|
+
var _a;
|
|
5387
|
+
const {
|
|
5388
|
+
fieldSchema
|
|
5389
|
+
} = (_a = useContext(SelectedFieldContext)) != null ? _a : {};
|
|
5390
|
+
if (!fieldSchema) {
|
|
5391
|
+
return null;
|
|
5392
|
+
}
|
|
5393
|
+
if (isObjectSchemaType(fieldSchema)) {
|
|
5394
|
+
return /* @__PURE__ */jsx(ObjectOutputInput, {
|
|
5395
|
+
...props,
|
|
5396
|
+
fieldSchema
|
|
5397
|
+
});
|
|
5398
|
+
}
|
|
5399
|
+
if (isArrayOfObjectsSchemaType(fieldSchema)) {
|
|
5400
|
+
return /* @__PURE__ */jsx(ArrayOutputInput, {
|
|
5401
|
+
...props,
|
|
5402
|
+
fieldSchema
|
|
5403
|
+
});
|
|
5404
|
+
}
|
|
5405
|
+
return null;
|
|
5406
|
+
}
|
|
5407
|
+
function useEmptySelectAllValue(value, allowedValues, onChange) {
|
|
5408
|
+
useEffect(() => {
|
|
5409
|
+
var _a, _b;
|
|
5410
|
+
const validValues = value == null ? void 0 : value.filter(v => allowedValues.find(f => f.name === (v._type === outputFieldTypeName ? v.relativePath : v.type)));
|
|
5411
|
+
const valueLength = (_a = value == null ? void 0 : value.length) != null ? _a : 0;
|
|
5412
|
+
const validLength = (_b = validValues == null ? void 0 : validValues.length) != null ? _b : 0;
|
|
5413
|
+
if (!validLength && valueLength || validLength >= allowedValues.length) {
|
|
5414
|
+
onChange(PatchEvent.from([unset()]));
|
|
5415
|
+
}
|
|
5416
|
+
}, [allowedValues, value, onChange]);
|
|
5417
|
+
}
|
|
5418
|
+
function ObjectOutputInput(_ref17) {
|
|
5419
|
+
let {
|
|
5420
|
+
fieldSchema,
|
|
5421
|
+
...props
|
|
5422
|
+
} = _ref17;
|
|
5423
|
+
const {
|
|
5424
|
+
value,
|
|
5425
|
+
onChange
|
|
5426
|
+
} = props;
|
|
5427
|
+
const fields = useMemo(() => fieldSchema.fields.filter(field => isAssistSupported(field.type)), [fieldSchema.fields]);
|
|
5428
|
+
useEmptySelectAllValue(value, fields, onChange);
|
|
5429
|
+
const onSelectChange = useCallback((checked, selectedValue) => {
|
|
5430
|
+
if (checked) {
|
|
5431
|
+
if (value == null ? void 0 : value.length) {
|
|
5432
|
+
onChange(PatchEvent.from(unset([{
|
|
5433
|
+
_key: selectedValue
|
|
5434
|
+
}])));
|
|
5435
|
+
} else {
|
|
5436
|
+
const items = fields.filter(f => f.name !== selectedValue).map(field => typed({
|
|
5437
|
+
_key: field.name,
|
|
5438
|
+
_type: "sanity.assist.output.field",
|
|
5439
|
+
relativePath: field.name
|
|
5440
|
+
}));
|
|
5441
|
+
onChange(PatchEvent.from([setIfMissing([]), insert(items, "after", [-1])]));
|
|
5442
|
+
}
|
|
5443
|
+
} else {
|
|
5444
|
+
const patchValue = {
|
|
5445
|
+
_key: selectedValue,
|
|
5446
|
+
_type: "sanity.assist.output.field",
|
|
5447
|
+
relativePath: selectedValue
|
|
5448
|
+
};
|
|
5449
|
+
onChange(PatchEvent.from([setIfMissing([]), insert([patchValue], "after", [-1])]));
|
|
5450
|
+
}
|
|
5451
|
+
}, [onChange, value, fields]);
|
|
5452
|
+
return /* @__PURE__ */jsx(Stack, {
|
|
5453
|
+
space: 2,
|
|
5454
|
+
children: fields.map(field => {
|
|
5455
|
+
var _a;
|
|
5456
|
+
return /* @__PURE__ */jsx(Flex, {
|
|
5457
|
+
align: "center",
|
|
5458
|
+
gap: 2,
|
|
5459
|
+
children: /* @__PURE__ */jsx(Selectable, {
|
|
5460
|
+
value: field.name,
|
|
5461
|
+
title: (_a = field.type.title) != null ? _a : field.name,
|
|
5462
|
+
arrayValue: value,
|
|
5463
|
+
onChange: onSelectChange
|
|
5464
|
+
})
|
|
5465
|
+
}, field.name);
|
|
5466
|
+
})
|
|
5467
|
+
});
|
|
5468
|
+
}
|
|
5469
|
+
function ArrayOutputInput(_ref18) {
|
|
5470
|
+
let {
|
|
5471
|
+
fieldSchema,
|
|
5472
|
+
...props
|
|
5473
|
+
} = _ref18;
|
|
5474
|
+
const {
|
|
5475
|
+
value,
|
|
5476
|
+
onChange
|
|
5477
|
+
} = props;
|
|
5478
|
+
const ofItems = useMemo(() => fieldSchema.of.filter(itemType => isAssistSupported(itemType)), [fieldSchema.of]);
|
|
5479
|
+
useEmptySelectAllValue(value, ofItems, onChange);
|
|
5480
|
+
const onSelectChange = useCallback((checked, selectedValue) => {
|
|
5481
|
+
if (checked) {
|
|
5482
|
+
if (value == null ? void 0 : value.length) {
|
|
5483
|
+
onChange(PatchEvent.from(unset([{
|
|
5484
|
+
_key: selectedValue
|
|
5485
|
+
}])));
|
|
5486
|
+
} else {
|
|
5487
|
+
const items = ofItems.filter(f => f.name !== selectedValue).map(field => typed({
|
|
5488
|
+
_key: field.name,
|
|
5489
|
+
_type: "sanity.assist.output.type",
|
|
5490
|
+
type: field.name
|
|
5491
|
+
}));
|
|
5492
|
+
onChange(PatchEvent.from([setIfMissing([]), insert(items, "after", [-1])]));
|
|
5493
|
+
}
|
|
5494
|
+
} else {
|
|
5495
|
+
const patchValue = {
|
|
5496
|
+
_key: selectedValue,
|
|
5497
|
+
_type: "sanity.assist.output.type",
|
|
5498
|
+
type: selectedValue
|
|
5499
|
+
};
|
|
5500
|
+
onChange(PatchEvent.from([setIfMissing([]), insert([patchValue], "after", [-1])]));
|
|
5501
|
+
}
|
|
5502
|
+
}, [onChange, value, ofItems]);
|
|
5503
|
+
return /* @__PURE__ */jsx(Stack, {
|
|
5504
|
+
space: 2,
|
|
5505
|
+
children: ofItems.map(itemType => {
|
|
5506
|
+
var _a;
|
|
5507
|
+
return /* @__PURE__ */jsx(Flex, {
|
|
5508
|
+
children: /* @__PURE__ */jsx(Selectable, {
|
|
5509
|
+
value: itemType.name,
|
|
5510
|
+
title: isType(itemType, "block") ? "Text" : (_a = itemType.title) != null ? _a : itemType.name,
|
|
5511
|
+
arrayValue: value,
|
|
5512
|
+
onChange: onSelectChange
|
|
5513
|
+
})
|
|
5514
|
+
}, itemType.name);
|
|
5515
|
+
})
|
|
5516
|
+
});
|
|
5517
|
+
}
|
|
5518
|
+
function Selectable(_ref19) {
|
|
5519
|
+
let {
|
|
5520
|
+
title,
|
|
5521
|
+
arrayValue,
|
|
5522
|
+
value,
|
|
5523
|
+
onChange
|
|
5524
|
+
} = _ref19;
|
|
5525
|
+
const checked = !(arrayValue == null ? void 0 : arrayValue.length) || !!(arrayValue == null ? void 0 : arrayValue.find(v => v._key === value));
|
|
5526
|
+
const handleChange = useCallback(() => onChange(checked, value), [onChange, checked, value]);
|
|
5527
|
+
return /* @__PURE__ */jsxs(Flex, {
|
|
5528
|
+
gap: 2,
|
|
5529
|
+
align: "flex-start",
|
|
5530
|
+
children: [/* @__PURE__ */jsx(Checkbox, {
|
|
5531
|
+
checked,
|
|
5532
|
+
onChange: handleChange
|
|
5533
|
+
}), /* @__PURE__ */jsx(Card, {
|
|
5534
|
+
marginTop: 1,
|
|
5535
|
+
onClick: () => handleChange,
|
|
5536
|
+
children: /* @__PURE__ */jsx(Text, {
|
|
5537
|
+
style: {
|
|
5538
|
+
cursor: "default"
|
|
5539
|
+
},
|
|
5540
|
+
size: 1,
|
|
5541
|
+
children: title
|
|
5542
|
+
})
|
|
5543
|
+
})]
|
|
5544
|
+
});
|
|
5545
|
+
}
|
|
3804
5546
|
const fieldReference = defineType({
|
|
3805
5547
|
type: "object",
|
|
3806
5548
|
name: fieldReferenceTypeName,
|
|
@@ -3844,10 +5586,10 @@ const fieldReference = defineType({
|
|
|
3844
5586
|
select: {
|
|
3845
5587
|
path: "path"
|
|
3846
5588
|
},
|
|
3847
|
-
prepare(
|
|
5589
|
+
prepare(_ref20) {
|
|
3848
5590
|
let {
|
|
3849
5591
|
path
|
|
3850
|
-
} =
|
|
5592
|
+
} = _ref20;
|
|
3851
5593
|
return {
|
|
3852
5594
|
title: path,
|
|
3853
5595
|
path,
|
|
@@ -3974,7 +5716,6 @@ const prompt = defineType({
|
|
|
3974
5716
|
type: userInput.name,
|
|
3975
5717
|
}),*/]
|
|
3976
5718
|
});
|
|
3977
|
-
|
|
3978
5719
|
const instruction = defineType({
|
|
3979
5720
|
type: "object",
|
|
3980
5721
|
name: instructionTypeName,
|
|
@@ -3993,12 +5734,12 @@ const instruction = defineType({
|
|
|
3993
5734
|
title: "title",
|
|
3994
5735
|
userId: "userId"
|
|
3995
5736
|
},
|
|
3996
|
-
prepare:
|
|
5737
|
+
prepare: _ref21 => {
|
|
3997
5738
|
let {
|
|
3998
5739
|
icon,
|
|
3999
5740
|
title,
|
|
4000
5741
|
userId
|
|
4001
|
-
} =
|
|
5742
|
+
} = _ref21;
|
|
4002
5743
|
return {
|
|
4003
5744
|
title,
|
|
4004
5745
|
icon: icon ? icons[icon] : SparklesIcon,
|
|
@@ -4103,6 +5844,33 @@ const instruction = defineType({
|
|
|
4103
5844
|
var _a, _b;
|
|
4104
5845
|
return (_b = (_a = context.currentUser) == null ? void 0 : _a.id) != null ? _b : "";
|
|
4105
5846
|
}
|
|
5847
|
+
}), defineField({
|
|
5848
|
+
type: "array",
|
|
5849
|
+
name: "output",
|
|
5850
|
+
title: "Output filter",
|
|
5851
|
+
components: {
|
|
5852
|
+
input: InstructionOutputInput,
|
|
5853
|
+
field: InstructionOutputField
|
|
5854
|
+
},
|
|
5855
|
+
of: [defineArrayMember({
|
|
5856
|
+
type: "object",
|
|
5857
|
+
name: outputFieldTypeName,
|
|
5858
|
+
title: "Output field",
|
|
5859
|
+
fields: [{
|
|
5860
|
+
type: "string",
|
|
5861
|
+
name: "path",
|
|
5862
|
+
title: "Path"
|
|
5863
|
+
}]
|
|
5864
|
+
}), defineArrayMember({
|
|
5865
|
+
type: "object",
|
|
5866
|
+
name: outputTypeTypeName,
|
|
5867
|
+
title: "Output type",
|
|
5868
|
+
fields: [{
|
|
5869
|
+
type: "string",
|
|
5870
|
+
name: "type",
|
|
5871
|
+
title: "Type"
|
|
5872
|
+
}]
|
|
5873
|
+
})]
|
|
4106
5874
|
})]
|
|
4107
5875
|
});
|
|
4108
5876
|
const fieldInstructions = defineType({
|
|
@@ -4365,7 +6133,7 @@ function ImageContextProvider(props) {
|
|
|
4365
6133
|
children: props.renderDefault(props)
|
|
4366
6134
|
});
|
|
4367
6135
|
}
|
|
4368
|
-
function node$
|
|
6136
|
+
function node$2(node2) {
|
|
4369
6137
|
return node2;
|
|
4370
6138
|
}
|
|
4371
6139
|
const generateCaptionsActions = {
|
|
@@ -4386,7 +6154,7 @@ const generateCaptionsActions = {
|
|
|
4386
6154
|
documentId
|
|
4387
6155
|
} = useAssistDocumentContext();
|
|
4388
6156
|
return useMemo(() => {
|
|
4389
|
-
return node$
|
|
6157
|
+
return node$2({
|
|
4390
6158
|
type: "action",
|
|
4391
6159
|
icon: loading ? () => /* @__PURE__ */jsx(Box, {
|
|
4392
6160
|
style: {
|
|
@@ -4417,6 +6185,97 @@ const generateCaptionsActions = {
|
|
|
4417
6185
|
return void 0;
|
|
4418
6186
|
}
|
|
4419
6187
|
};
|
|
6188
|
+
function node$1(node2) {
|
|
6189
|
+
return node2;
|
|
6190
|
+
}
|
|
6191
|
+
const translateActions = {
|
|
6192
|
+
name: "sanity-assist-translate",
|
|
6193
|
+
useAction(props) {
|
|
6194
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6195
|
+
const {
|
|
6196
|
+
config
|
|
6197
|
+
} = useAiAssistanceConfig();
|
|
6198
|
+
const apiClient = useApiClient(config == null ? void 0 : config.__customApiClient);
|
|
6199
|
+
const {
|
|
6200
|
+
translate,
|
|
6201
|
+
loading
|
|
6202
|
+
} = useTranslate(apiClient);
|
|
6203
|
+
const isDocumentLevel = props.path.length === 0;
|
|
6204
|
+
const {
|
|
6205
|
+
schemaType,
|
|
6206
|
+
documentId
|
|
6207
|
+
} = props;
|
|
6208
|
+
if (isDocumentLevel) {
|
|
6209
|
+
const {
|
|
6210
|
+
value: documentValue
|
|
6211
|
+
} = useDocumentPane();
|
|
6212
|
+
const docRef = useRef(documentValue);
|
|
6213
|
+
docRef.current = documentValue;
|
|
6214
|
+
const docTransTypes = (_b = (_a = config.translate) == null ? void 0 : _a.document) == null ? void 0 : _b.documentTypes;
|
|
6215
|
+
const documentTranslation = !docTransTypes && isAssistSupported(schemaType) || (docTransTypes == null ? void 0 : docTransTypes.includes(schemaType.name));
|
|
6216
|
+
const languagePath = (_d = (_c = config.translate) == null ? void 0 : _c.document) == null ? void 0 : _d.languageField;
|
|
6217
|
+
const translateDocumentAction = useMemo(() => languagePath && documentTranslation ? node$1({
|
|
6218
|
+
type: "action",
|
|
6219
|
+
icon: loading ? () => /* @__PURE__ */jsx(Box, {
|
|
6220
|
+
style: {
|
|
6221
|
+
height: 17
|
|
6222
|
+
},
|
|
6223
|
+
children: /* @__PURE__ */jsx(Spinner, {
|
|
6224
|
+
style: {
|
|
6225
|
+
transform: "translateY(6px)"
|
|
6226
|
+
}
|
|
6227
|
+
})
|
|
6228
|
+
}) : TranslateIcon,
|
|
6229
|
+
title: "Translate document",
|
|
6230
|
+
onAction: () => {
|
|
6231
|
+
if (loading || !languagePath || !documentId) {
|
|
6232
|
+
return;
|
|
6233
|
+
}
|
|
6234
|
+
translate({
|
|
6235
|
+
languagePath,
|
|
6236
|
+
documentId: documentId != null ? documentId : ""
|
|
6237
|
+
});
|
|
6238
|
+
},
|
|
6239
|
+
renderAsButton: true,
|
|
6240
|
+
disabled: loading
|
|
6241
|
+
}) : void 0, [languagePath, translate, documentId, loading, documentTranslation]);
|
|
6242
|
+
const fieldTranslate = useFieldTranslation();
|
|
6243
|
+
const fieldTransEnabled = (_g = (_f = (_e = config.translate) == null ? void 0 : _e.field) == null ? void 0 : _f.documentTypes) == null ? void 0 : _g.includes(schemaType.name);
|
|
6244
|
+
const translateFieldsAction = useMemo(() => fieldTransEnabled ? node$1({
|
|
6245
|
+
type: "action",
|
|
6246
|
+
icon: loading ? () => /* @__PURE__ */jsx(Box, {
|
|
6247
|
+
style: {
|
|
6248
|
+
height: 17
|
|
6249
|
+
},
|
|
6250
|
+
children: /* @__PURE__ */jsx(Spinner, {
|
|
6251
|
+
style: {
|
|
6252
|
+
transform: "translateY(6px)"
|
|
6253
|
+
}
|
|
6254
|
+
})
|
|
6255
|
+
}) : TranslateIcon,
|
|
6256
|
+
title: "Translate fields",
|
|
6257
|
+
onAction: () => {
|
|
6258
|
+
if (loading || !documentId) {
|
|
6259
|
+
return;
|
|
6260
|
+
}
|
|
6261
|
+
fieldTranslate.openFieldTranslation(docRef.current, schemaType);
|
|
6262
|
+
},
|
|
6263
|
+
renderAsButton: true,
|
|
6264
|
+
disabled: loading
|
|
6265
|
+
}) : void 0, [fieldTranslate, schemaType, documentId, loading, fieldTransEnabled]);
|
|
6266
|
+
return useMemo(() => {
|
|
6267
|
+
return node$1({
|
|
6268
|
+
type: "group",
|
|
6269
|
+
icon: () => null,
|
|
6270
|
+
title: "Translate",
|
|
6271
|
+
children: [translateDocumentAction, translateFieldsAction].filter(c => !!c),
|
|
6272
|
+
expanded: true
|
|
6273
|
+
});
|
|
6274
|
+
}, [translateDocumentAction, translateFieldsAction]);
|
|
6275
|
+
}
|
|
6276
|
+
return void 0;
|
|
6277
|
+
}
|
|
6278
|
+
};
|
|
4420
6279
|
function node(node2) {
|
|
4421
6280
|
return node2;
|
|
4422
6281
|
}
|
|
@@ -4437,7 +6296,8 @@ const assistFieldActions = {
|
|
|
4437
6296
|
documentOnChange,
|
|
4438
6297
|
documentSchemaType,
|
|
4439
6298
|
documentId,
|
|
4440
|
-
selectedPath
|
|
6299
|
+
selectedPath,
|
|
6300
|
+
assistableDocumentId
|
|
4441
6301
|
} =
|
|
4442
6302
|
// document field actions do not have access to the document context
|
|
4443
6303
|
// conditional hook _should_ be safe here since the logical path will be stable
|
|
@@ -4472,6 +6332,10 @@ const assistFieldActions = {
|
|
|
4472
6332
|
const isPathSelected = pathKey === selectedPath;
|
|
4473
6333
|
const isSelected = isInspectorOpen && isPathSelected;
|
|
4474
6334
|
const imageCaptionAction = generateCaptionsActions.useAction(props);
|
|
6335
|
+
const translateAction = translateActions.useAction({
|
|
6336
|
+
...props,
|
|
6337
|
+
documentId: assistableDocumentId
|
|
6338
|
+
});
|
|
4475
6339
|
const manageInstructions = useCallback(() => isSelected ? closeInspector(aiInspectorId) : openInspector(aiInspectorId, {
|
|
4476
6340
|
[fieldPathParam]: pathKey,
|
|
4477
6341
|
[instructionParam]: void 0
|
|
@@ -4498,7 +6362,7 @@ const assistFieldActions = {
|
|
|
4498
6362
|
}, [fieldAssist == null ? void 0 : fieldAssist.instructions]);
|
|
4499
6363
|
const instructions = useMemo(() => [...privateInstructions, ...sharedInstructions], [privateInstructions, sharedInstructions]);
|
|
4500
6364
|
const runInstructionsGroup = useMemo(() => {
|
|
4501
|
-
return (instructions == null ? void 0 : instructions.length) || imageCaptionAction ? node({
|
|
6365
|
+
return (instructions == null ? void 0 : instructions.length) || imageCaptionAction || translateAction ? node({
|
|
4502
6366
|
type: "group",
|
|
4503
6367
|
icon: () => null,
|
|
4504
6368
|
title: "Run instructions",
|
|
@@ -4509,10 +6373,10 @@ const assistFieldActions = {
|
|
|
4509
6373
|
hidden: isHidden,
|
|
4510
6374
|
documentIsNew: !!documentIsNew,
|
|
4511
6375
|
assistSupported
|
|
4512
|
-
}))), imageCaptionAction].filter(
|
|
6376
|
+
}))), imageCaptionAction].filter(a => !!a),
|
|
4513
6377
|
expanded: true
|
|
4514
6378
|
}) : void 0;
|
|
4515
|
-
}, [instructions, currentUser == null ? void 0 : currentUser.id, onInstructionAction, isHidden, documentIsNew, assistSupported, imageCaptionAction]);
|
|
6379
|
+
}, [instructions, currentUser == null ? void 0 : currentUser.id, onInstructionAction, isHidden, documentIsNew, assistSupported, imageCaptionAction, translateAction]);
|
|
4516
6380
|
const instructionsLength = (instructions == null ? void 0 : instructions.length) || 0;
|
|
4517
6381
|
const manageInstructionsItem = useMemo(() => node({
|
|
4518
6382
|
type: "action",
|
|
@@ -4525,13 +6389,13 @@ const assistFieldActions = {
|
|
|
4525
6389
|
type: "group",
|
|
4526
6390
|
icon: SparklesIcon,
|
|
4527
6391
|
title: pluginTitleShort,
|
|
4528
|
-
children: [runInstructionsGroup, assistSupported && manageInstructionsItem].filter(c => !!c),
|
|
6392
|
+
children: [runInstructionsGroup, translateAction, assistSupported && manageInstructionsItem].filter(c => !!c),
|
|
4529
6393
|
expanded: false,
|
|
4530
6394
|
renderAsButton: true,
|
|
4531
|
-
hidden: !assistSupported && !imageCaptionAction
|
|
6395
|
+
hidden: !assistSupported && !imageCaptionAction && !translateAction
|
|
4532
6396
|
}), [
|
|
4533
6397
|
//documentIsNew,
|
|
4534
|
-
runInstructionsGroup, manageInstructionsItem, assistSupported, imageCaptionAction]);
|
|
6398
|
+
runInstructionsGroup, manageInstructionsItem, assistSupported, imageCaptionAction, translateAction]);
|
|
4535
6399
|
const emptyAction = useMemo(() => node({
|
|
4536
6400
|
type: "action",
|
|
4537
6401
|
hidden: !assistSupported,
|
|
@@ -4541,7 +6405,7 @@ const assistFieldActions = {
|
|
|
4541
6405
|
title: pluginTitleShort,
|
|
4542
6406
|
selected: isSelected
|
|
4543
6407
|
}), [assistSupported, manageInstructions, isSelected]);
|
|
4544
|
-
if (instructionsLength === 0 && !imageCaptionAction) {
|
|
6408
|
+
if (instructionsLength === 0 && !imageCaptionAction && !translateAction) {
|
|
4545
6409
|
return emptyAction;
|
|
4546
6410
|
}
|
|
4547
6411
|
return group;
|
|
@@ -4654,11 +6518,11 @@ function AssistDocumentInputWrapper(props) {
|
|
|
4654
6518
|
documentId
|
|
4655
6519
|
});
|
|
4656
6520
|
}
|
|
4657
|
-
function AssistDocumentInput(
|
|
6521
|
+
function AssistDocumentInput(_ref22) {
|
|
4658
6522
|
let {
|
|
4659
6523
|
documentId,
|
|
4660
6524
|
...props
|
|
4661
|
-
} =
|
|
6525
|
+
} = _ref22;
|
|
4662
6526
|
useInstructionToaster(documentId, props.schemaType);
|
|
4663
6527
|
return /* @__PURE__ */jsx(FirstAssistedPathProvider, {
|
|
4664
6528
|
members: props.members,
|
|
@@ -4703,11 +6567,11 @@ function AssistDocumentPresence(props) {
|
|
|
4703
6567
|
const anyPresence2 = (_b = (_a = assistDocument == null ? void 0 : assistDocument.tasks) == null ? void 0 : _a.filter(run => !run.ended && !run.reason)) == null ? void 0 : _b.flatMap(run => {
|
|
4704
6568
|
var _a2;
|
|
4705
6569
|
return (_a2 = run.presence) != null ? _a2 : [];
|
|
4706
|
-
}).find(f => f.started && /* @__PURE__ */new Date().getTime() - new Date(f.started).getTime() < 3e4);
|
|
6570
|
+
}).find(f => f.started && ( /* @__PURE__ */new Date()).getTime() - new Date(f.started).getTime() < 3e4);
|
|
4707
6571
|
if (anyPresence2) {
|
|
4708
6572
|
return aiPresence(anyPresence2, []);
|
|
4709
6573
|
}
|
|
4710
|
-
const anyRun = (_d = (_c = assistDocument == null ? void 0 : assistDocument.tasks) == null ? void 0 : _c.filter(run => !run.ended && !run.reason)) == null ? void 0 : _d.find(f => f.started && /* @__PURE__ */new Date().getTime() - new Date(f.started).getTime() < 3e4);
|
|
6574
|
+
const anyRun = (_d = (_c = assistDocument == null ? void 0 : assistDocument.tasks) == null ? void 0 : _c.filter(run => !run.ended && !run.reason)) == null ? void 0 : _d.find(f => f.started && ( /* @__PURE__ */new Date()).getTime() - new Date(f.started).getTime() < 3e4);
|
|
4711
6575
|
return anyRun ? aiPresence({
|
|
4712
6576
|
started: anyRun.started,
|
|
4713
6577
|
path: documentRootKey,
|
|
@@ -4736,6 +6600,9 @@ const assist = definePlugin(config => {
|
|
|
4736
6600
|
schema: {
|
|
4737
6601
|
types: schemaTypes
|
|
4738
6602
|
},
|
|
6603
|
+
i18n: {
|
|
6604
|
+
bundles: [{}]
|
|
6605
|
+
},
|
|
4739
6606
|
document: {
|
|
4740
6607
|
inspectors: (prev, context) => {
|
|
4741
6608
|
const docSchema = context.schema.get(context.documentType);
|
|
@@ -4744,23 +6611,23 @@ const assist = definePlugin(config => {
|
|
|
4744
6611
|
}
|
|
4745
6612
|
return prev;
|
|
4746
6613
|
},
|
|
4747
|
-
unstable_fieldActions: (prev,
|
|
6614
|
+
unstable_fieldActions: (prev, _ref23) => {
|
|
4748
6615
|
let {
|
|
4749
6616
|
documentType,
|
|
4750
6617
|
schema
|
|
4751
|
-
} =
|
|
6618
|
+
} = _ref23;
|
|
4752
6619
|
const docSchema = schema.get(documentType);
|
|
4753
6620
|
if (docSchema && isSchemaAssistEnabled(docSchema)) {
|
|
4754
6621
|
return [...prev, assistFieldActions];
|
|
4755
6622
|
}
|
|
4756
6623
|
return prev;
|
|
4757
6624
|
},
|
|
4758
|
-
unstable_languageFilter: (prev,
|
|
6625
|
+
unstable_languageFilter: (prev, _ref24) => {
|
|
4759
6626
|
let {
|
|
4760
6627
|
documentId,
|
|
4761
6628
|
schema,
|
|
4762
6629
|
schemaType
|
|
4763
|
-
} =
|
|
6630
|
+
} = _ref24;
|
|
4764
6631
|
const docSchema = schema.get(schemaType);
|
|
4765
6632
|
if (docSchema && isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema)) {
|
|
4766
6633
|
return [...prev, createAssistDocumentPresence(documentId, docSchema)];
|