@sanity/client 7.26.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -377
- package/dist/browserUpload-CQgx9YYo.js +86 -0
- package/dist/browserUpload-CQgx9YYo.js.map +1 -0
- package/dist/browserUpload-icWlVP15.js +86 -0
- package/dist/browserUpload-icWlVP15.js.map +1 -0
- package/dist/config-a8VajuEY.js +126 -0
- package/dist/config-a8VajuEY.js.map +1 -0
- package/dist/csm.d.ts +122 -335
- package/dist/csm.js +79 -91
- package/dist/csm.js.map +1 -1
- package/dist/dist-C9ExSk2R.js +73 -0
- package/dist/dist-C9ExSk2R.js.map +1 -0
- package/dist/dist-Z8cIRxoB.js +69 -0
- package/dist/dist-Z8cIRxoB.js.map +1 -0
- package/dist/index.d.ts +107 -6723
- package/dist/index.js +2822 -2847
- package/dist/index.js.map +1 -1
- package/dist/{index.d.cts → index.node.d.ts} +4291 -5328
- package/dist/index.node.js +3131 -0
- package/dist/index.node.js.map +1 -0
- package/dist/isRecord-Kfmt-nk-.js +7 -0
- package/dist/isRecord-Kfmt-nk-.js.map +1 -0
- package/dist/media-library.d.ts +9 -100
- package/dist/media-library.js +36 -14
- package/dist/media-library.js.map +1 -1
- package/dist/request-CJxcN16k.js +372 -0
- package/dist/request-CJxcN16k.js.map +1 -0
- package/dist/request-k7VS_NnC.js +354 -0
- package/dist/request-k7VS_NnC.js.map +1 -0
- package/dist/resolveEditInfo-sq7yF78q.js +325 -0
- package/dist/resolveEditInfo-sq7yF78q.js.map +1 -0
- package/dist/rolldown-runtime-vyAXikos.js +9 -0
- package/dist/stega.d.ts +78 -7137
- package/dist/stega.js +27 -20
- package/dist/stega.js.map +1 -1
- package/dist/stegaClean-C18wLWau.js +21 -0
- package/dist/stegaClean-C18wLWau.js.map +1 -0
- package/dist/stegaEncodeSourceMap-B2fGArSf.js +163 -0
- package/dist/stegaEncodeSourceMap-B2fGArSf.js.map +1 -0
- package/dist/stegaEncodeSourceMap-DkoIlutY.js +367 -0
- package/dist/stegaEncodeSourceMap-DkoIlutY.js.map +1 -0
- package/dist/{index.browser.d.cts → types-CUxZSgB2.d.ts} +3956 -5256
- package/dist/types-CfGzbXrl.d.ts +108 -0
- package/package.json +64 -141
- package/src/SanityClient.ts +82 -117
- package/src/agent/actions/AgentActionsClient.ts +12 -12
- package/src/agent/actions/commonTypes.ts +2 -1
- package/src/agent/actions/generate.ts +26 -6
- package/src/agent/actions/patch.ts +27 -7
- package/src/agent/actions/prompt.ts +19 -5
- package/src/agent/actions/transform.ts +23 -5
- package/src/agent/actions/translate.ts +23 -5
- package/src/assets/AssetsClient.ts +71 -23
- package/src/csm/applySourceDocuments.ts +3 -1
- package/src/csm/createEditUrl.ts +1 -1
- package/src/csm/draftUtils.ts +0 -1
- package/src/csm/index.ts +2 -2
- package/src/csm/studioPath.ts +2 -1
- package/src/csm/types.ts +8 -2
- package/src/data/dataMethods.ts +801 -349
- package/src/data/eventsource.ts +13 -10
- package/src/data/listen.ts +18 -23
- package/src/data/live.ts +44 -27
- package/src/data/resolveEventSourceFetch.ts +96 -0
- package/src/datasets/DatasetsClient.ts +58 -41
- package/src/defineCreateClient.ts +35 -23
- package/src/http/browserMiddleware.ts +7 -1
- package/src/http/browserUpload.ts +162 -0
- package/src/http/errors.ts +60 -6
- package/src/http/nodeMiddleware.ts +94 -30
- package/src/http/request.ts +310 -87
- package/src/http/requestOptions.ts +131 -15
- package/src/{index.browser.ts → index.node.ts} +9 -4
- package/src/index.ts +4 -3
- package/src/mediaLibrary/MediaLibraryVideoClient.ts +26 -11
- package/src/projects/ProjectsClient.ts +18 -16
- package/src/releases/ReleasesClient.ts +38 -33
- package/src/stega/index.ts +1 -2
- package/src/stega/stegaEncodeSourceMap.ts +5 -0
- package/src/stega/types.ts +2 -2
- package/src/types.ts +148 -105
- package/src/users/UsersClient.ts +10 -14
- package/src/util/shareReplayLatest.ts +1 -1
- package/src/warnings.ts +6 -1
- package/dist/_chunks-cjs/config.cjs +0 -206
- package/dist/_chunks-cjs/config.cjs.map +0 -1
- package/dist/_chunks-cjs/isRecord.cjs +0 -6
- package/dist/_chunks-cjs/isRecord.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveEditInfo.cjs +0 -334
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +0 -1
- package/dist/_chunks-cjs/stegaClean.cjs +0 -46
- package/dist/_chunks-cjs/stegaClean.cjs.map +0 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +0 -388
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +0 -1
- package/dist/_chunks-es/config.js +0 -207
- package/dist/_chunks-es/config.js.map +0 -1
- package/dist/_chunks-es/isRecord.js +0 -7
- package/dist/_chunks-es/isRecord.js.map +0 -1
- package/dist/_chunks-es/resolveEditInfo.js +0 -335
- package/dist/_chunks-es/resolveEditInfo.js.map +0 -1
- package/dist/_chunks-es/stegaClean.js +0 -47
- package/dist/_chunks-es/stegaClean.js.map +0 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +0 -389
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +0 -1
- package/dist/csm.cjs +0 -99
- package/dist/csm.cjs.map +0 -1
- package/dist/csm.d.cts +0 -391
- package/dist/index.browser.cjs +0 -3106
- package/dist/index.browser.cjs.map +0 -1
- package/dist/index.browser.d.ts +0 -6802
- package/dist/index.browser.js +0 -3082
- package/dist/index.browser.js.map +0 -1
- package/dist/index.cjs +0 -2946
- package/dist/index.cjs.map +0 -1
- package/dist/media-library.cjs +0 -20
- package/dist/media-library.cjs.map +0 -1
- package/dist/media-library.d.cts +0 -117
- package/dist/stega.browser.cjs +0 -29
- package/dist/stega.browser.cjs.map +0 -1
- package/dist/stega.browser.d.cts +0 -7200
- package/dist/stega.browser.d.ts +0 -7200
- package/dist/stega.browser.js +0 -24
- package/dist/stega.browser.js.map +0 -1
- package/dist/stega.cjs +0 -29
- package/dist/stega.cjs.map +0 -1
- package/dist/stega.d.cts +0 -7200
- package/src/data/eventsourcePolyfill.ts +0 -7
- package/umd/.gitkeep +0 -1
- package/umd/sanityClient.js +0 -6543
- package/umd/sanityClient.min.js +0 -6
package/dist/csm.js
CHANGED
|
@@ -1,101 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { r as validateApiPerspective } from "./config-a8VajuEY.js";
|
|
2
|
+
import { S as toString, _ as isPublishedId, a as resolveMapping, c as parseJsonPath, d as VERSION_FOLDER, f as getDraftId, g as isDraftId, h as getVersionId, i as walkMap, l as studioPathToJsonPath, m as getVersionFromId, o as jsonPath, p as getPublishedId, r as createEditUrl, s as jsonPathToStudioPath, t as resolveEditInfo, u as DRAFTS_FOLDER, v as isVersionId, x as studioPath_exports, y as get } from "./resolveEditInfo-sq7yF78q.js";
|
|
3
|
+
/**
|
|
4
|
+
* This resolves the perspectives to how documents should be resolved when applying optimistic updates,
|
|
5
|
+
* like in `applySourceDocuments`.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
4
8
|
function resolvePerspectives(perspective) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
case "published":
|
|
12
|
-
default:
|
|
13
|
-
return ["published"];
|
|
14
|
-
}
|
|
9
|
+
if (validateApiPerspective(perspective), Array.isArray(perspective)) return perspective.includes("published") ? perspective : [...perspective, "published"];
|
|
10
|
+
switch (perspective) {
|
|
11
|
+
case "previewDrafts":
|
|
12
|
+
case "drafts": return ["drafts", "published"];
|
|
13
|
+
default: return ["published"];
|
|
14
|
+
}
|
|
15
15
|
}
|
|
16
|
+
/** @internal */
|
|
16
17
|
function createSourceDocumentResolver(getCachedDocument, _perspective) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
let perspectives = resolvePerspectives(_perspective);
|
|
19
|
+
function findDocument(sourceDocument) {
|
|
20
|
+
for (let perspective of perspectives) {
|
|
21
|
+
let match = null;
|
|
22
|
+
if (perspective.startsWith("r") && (match = getCachedDocument({
|
|
23
|
+
...sourceDocument,
|
|
24
|
+
_id: getVersionId(sourceDocument._id, perspective)
|
|
25
|
+
})), perspective === "drafts" && (match = getCachedDocument({
|
|
26
|
+
...sourceDocument,
|
|
27
|
+
_id: getDraftId(sourceDocument._id)
|
|
28
|
+
})), perspective === "published" && (match = getCachedDocument({
|
|
29
|
+
...sourceDocument,
|
|
30
|
+
_id: getPublishedId(sourceDocument._id)
|
|
31
|
+
})), match) return {
|
|
32
|
+
...match,
|
|
33
|
+
_id: getPublishedId(match._id),
|
|
34
|
+
_originalId: match._id
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return function resolveSourceDocument(sourceDocument) {
|
|
40
|
+
return findDocument(sourceDocument);
|
|
41
|
+
};
|
|
38
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Optimistically applies source documents to a result, using the content source map to trace fields.
|
|
45
|
+
* Can be used to apply mutations to documents being edited in a Studio, or any mutation on Content Lake, to a result with extremely low latency.
|
|
46
|
+
* @alpha
|
|
47
|
+
*/
|
|
39
48
|
function applySourceDocuments(result, resultSourceMap, getCachedDocument, updateFn, perspective) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
return value;
|
|
63
|
-
});
|
|
49
|
+
if (!resultSourceMap) return result;
|
|
50
|
+
let resolveDocument = createSourceDocumentResolver(getCachedDocument, perspective), cachedDocuments = resultSourceMap.documents?.map?.(resolveDocument) || [];
|
|
51
|
+
return walkMap(JSON.parse(JSON.stringify(result)), (value, path) => {
|
|
52
|
+
let resolveMappingResult = resolveMapping(path, resultSourceMap);
|
|
53
|
+
if (!resolveMappingResult) return value;
|
|
54
|
+
let { mapping, pathSuffix } = resolveMappingResult;
|
|
55
|
+
if (mapping.type !== "value" || mapping.source.type !== "documentValue") return value;
|
|
56
|
+
let sourceDocument = resultSourceMap.documents[mapping.source.document], sourcePath = resultSourceMap.paths[mapping.source.path];
|
|
57
|
+
if (sourceDocument) {
|
|
58
|
+
let parsedPath = parseJsonPath(sourcePath + pathSuffix), stringifiedPath = toString(parsedPath), cachedDocument = cachedDocuments[mapping.source.document];
|
|
59
|
+
if (!cachedDocument) return value;
|
|
60
|
+
let changedValue = cachedDocument ? get(cachedDocument, stringifiedPath, value) : value;
|
|
61
|
+
return value === changedValue ? value : updateFn(changedValue, {
|
|
62
|
+
cachedDocument,
|
|
63
|
+
previousValue: value,
|
|
64
|
+
sourceDocument,
|
|
65
|
+
sourcePath: parsedPath
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
});
|
|
64
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
65
74
|
function resolvedKeyedSourcePath(options) {
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
let { keyedResultPath, pathSuffix, sourceBasePath } = options, inferredResultPath = pathSuffix === void 0 ? [] : parseJsonPath(pathSuffix), inferredPath = keyedResultPath.slice(keyedResultPath.length - inferredResultPath.length), inferredPathSuffix = inferredPath.length ? jsonPath(inferredPath).slice(1) : "";
|
|
76
|
+
return parseJsonPath(sourceBasePath + inferredPathSuffix);
|
|
68
77
|
}
|
|
78
|
+
/** @alpha */
|
|
69
79
|
function resolveEditUrl(options) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return createEditUrl(editInfo);
|
|
80
|
+
let { resultSourceMap, studioUrl } = options, resultPath = studioPathToJsonPath(options.resultPath), editInfo = resolveEditInfo({
|
|
81
|
+
resultPath,
|
|
82
|
+
resultSourceMap,
|
|
83
|
+
studioUrl
|
|
84
|
+
});
|
|
85
|
+
if (editInfo) return createEditUrl(editInfo);
|
|
77
86
|
}
|
|
78
|
-
export {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
applySourceDocuments,
|
|
82
|
-
createEditUrl,
|
|
83
|
-
getDraftId,
|
|
84
|
-
getPublishedId,
|
|
85
|
-
getVersionFromId,
|
|
86
|
-
getVersionId,
|
|
87
|
-
isDraftId,
|
|
88
|
-
isPublishedId,
|
|
89
|
-
isVersionId,
|
|
90
|
-
jsonPath,
|
|
91
|
-
jsonPathToStudioPath,
|
|
92
|
-
parseJsonPath,
|
|
93
|
-
resolveEditInfo,
|
|
94
|
-
resolveEditUrl,
|
|
95
|
-
resolveMapping,
|
|
96
|
-
resolvedKeyedSourcePath,
|
|
97
|
-
studioPath,
|
|
98
|
-
studioPathToJsonPath,
|
|
99
|
-
walkMap
|
|
100
|
-
};
|
|
101
|
-
//# sourceMappingURL=csm.js.map
|
|
87
|
+
export { DRAFTS_FOLDER, VERSION_FOLDER, applySourceDocuments, createEditUrl, getDraftId, getPublishedId, getVersionFromId, getVersionId, isDraftId, isPublishedId, isVersionId, jsonPath, jsonPathToStudioPath, parseJsonPath, resolveEditInfo, resolveEditUrl, resolveMapping, resolvedKeyedSourcePath, studioPath_exports as studioPath, studioPathToJsonPath, walkMap };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=csm.js.map
|
package/dist/csm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csm.js","sources":["../src/csm/resolvePerspectives.ts","../src/csm/createSourceDocumentResolver.ts","../src/csm/applySourceDocuments.ts","../src/csm/resolvedKeyedSourcePath.ts","../src/csm/resolveEditUrl.ts"],"sourcesContent":["import {validateApiPerspective} from '../config'\nimport type {StackablePerspective} from '../types'\nimport type {ClientPerspective} from './types'\n\n/**\n * This resolves the perspectives to how documents should be resolved when applying optimistic updates,\n * like in `applySourceDocuments`.\n * @internal\n */\nexport function resolvePerspectives(\n perspective: Exclude<ClientPerspective, 'raw'>,\n): ('published' | 'drafts' | StackablePerspective)[] {\n validateApiPerspective(perspective)\n\n if (Array.isArray(perspective)) {\n if (!perspective.includes('published')) {\n return [...perspective, 'published']\n }\n return perspective\n }\n switch (perspective) {\n case 'previewDrafts':\n case 'drafts':\n return ['drafts', 'published']\n case 'published':\n default:\n return ['published']\n }\n}\n","import {getDraftId, getPublishedId, getVersionId} from './draftUtils'\nimport {resolvePerspectives} from './resolvePerspectives'\nimport type {ClientPerspective, ContentSourceMapDocuments, SanityDocument} from './types'\n\n/** @internal */\nexport type ResolvedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type'>>\n\n/** @internal */\nexport type MatchedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type' | '_originalId'>>\n\n/** @internal */\nexport function createSourceDocumentResolver(\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) => ResolvedDocument | null | undefined,\n _perspective: Exclude<ClientPerspective, 'raw'>,\n) {\n const perspectives = resolvePerspectives(_perspective)\n function findDocument(sourceDocument: ContentSourceMapDocuments[number]) {\n for (const perspective of perspectives) {\n let match: ReturnType<typeof getCachedDocument> = null\n if (perspective.startsWith('r')) {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getVersionId(sourceDocument._id, perspective),\n })\n }\n if (perspective === 'drafts') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getDraftId(sourceDocument._id),\n })\n }\n if (perspective === 'published') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getPublishedId(sourceDocument._id),\n })\n }\n if (match) {\n return {...match, _id: getPublishedId(match._id), _originalId: match._id}\n }\n }\n return null\n }\n // define resolver that loops over source documents and perspectives\n return function resolveSourceDocument(\n sourceDocument: ContentSourceMapDocuments[number],\n ): MatchedDocument | null {\n return findDocument(sourceDocument)\n }\n}\n","import {createSourceDocumentResolver} from './createSourceDocumentResolver'\nimport {parseJsonPath} from './jsonPath'\nimport {resolveMapping} from './resolveMapping'\nimport * as paths from './studioPath'\nimport type {\n Any,\n ApplySourceDocumentsUpdateFunction,\n ClientPerspective,\n ContentSourceMap,\n ContentSourceMapDocuments,\n Path,\n SanityDocument,\n} from './types'\nimport {walkMap} from './walkMap'\n\n/**\n * Optimistically applies source documents to a result, using the content source map to trace fields.\n * Can be used to apply mutations to documents being edited in a Studio, or any mutation on Content Lake, to a result with extremely low latency.\n * @alpha\n */\nexport function applySourceDocuments<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) =>\n (Partial<SanityDocument> & Required<Pick<SanityDocument, '_id' | '_type'>>)
|
|
1
|
+
{"version":3,"file":"csm.js","names":["paths.toString","paths.get"],"sources":["../src/csm/resolvePerspectives.ts","../src/csm/createSourceDocumentResolver.ts","../src/csm/applySourceDocuments.ts","../src/csm/resolvedKeyedSourcePath.ts","../src/csm/resolveEditUrl.ts"],"sourcesContent":["import {validateApiPerspective} from '../config'\nimport type {StackablePerspective} from '../types'\nimport type {ClientPerspective} from './types'\n\n/**\n * This resolves the perspectives to how documents should be resolved when applying optimistic updates,\n * like in `applySourceDocuments`.\n * @internal\n */\nexport function resolvePerspectives(\n perspective: Exclude<ClientPerspective, 'raw'>,\n): ('published' | 'drafts' | StackablePerspective)[] {\n validateApiPerspective(perspective)\n\n if (Array.isArray(perspective)) {\n if (!perspective.includes('published')) {\n return [...perspective, 'published']\n }\n return perspective\n }\n switch (perspective) {\n case 'previewDrafts':\n case 'drafts':\n return ['drafts', 'published']\n case 'published':\n default:\n return ['published']\n }\n}\n","import {getDraftId, getPublishedId, getVersionId} from './draftUtils'\nimport {resolvePerspectives} from './resolvePerspectives'\nimport type {ClientPerspective, ContentSourceMapDocuments, SanityDocument} from './types'\n\n/** @internal */\nexport type ResolvedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type'>>\n\n/** @internal */\nexport type MatchedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type' | '_originalId'>>\n\n/** @internal */\nexport function createSourceDocumentResolver(\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) => ResolvedDocument | null | undefined,\n _perspective: Exclude<ClientPerspective, 'raw'>,\n) {\n const perspectives = resolvePerspectives(_perspective)\n function findDocument(sourceDocument: ContentSourceMapDocuments[number]) {\n for (const perspective of perspectives) {\n let match: ReturnType<typeof getCachedDocument> = null\n if (perspective.startsWith('r')) {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getVersionId(sourceDocument._id, perspective),\n })\n }\n if (perspective === 'drafts') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getDraftId(sourceDocument._id),\n })\n }\n if (perspective === 'published') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getPublishedId(sourceDocument._id),\n })\n }\n if (match) {\n return {...match, _id: getPublishedId(match._id), _originalId: match._id}\n }\n }\n return null\n }\n // define resolver that loops over source documents and perspectives\n return function resolveSourceDocument(\n sourceDocument: ContentSourceMapDocuments[number],\n ): MatchedDocument | null {\n return findDocument(sourceDocument)\n }\n}\n","import {createSourceDocumentResolver} from './createSourceDocumentResolver'\nimport {parseJsonPath} from './jsonPath'\nimport {resolveMapping} from './resolveMapping'\nimport * as paths from './studioPath'\nimport type {\n Any,\n ApplySourceDocumentsUpdateFunction,\n ClientPerspective,\n ContentSourceMap,\n ContentSourceMapDocuments,\n Path,\n SanityDocument,\n} from './types'\nimport {walkMap} from './walkMap'\n\n/**\n * Optimistically applies source documents to a result, using the content source map to trace fields.\n * Can be used to apply mutations to documents being edited in a Studio, or any mutation on Content Lake, to a result with extremely low latency.\n * @alpha\n */\nexport function applySourceDocuments<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) =>\n | (Partial<SanityDocument> & Required<Pick<SanityDocument, '_id' | '_type'>>)\n | null\n | undefined,\n updateFn: ApplySourceDocumentsUpdateFunction,\n perspective: Exclude<ClientPerspective, 'raw'>,\n): Result {\n if (!resultSourceMap) return result\n\n const resolveDocument = createSourceDocumentResolver(getCachedDocument, perspective)\n const cachedDocuments = resultSourceMap.documents?.map?.(resolveDocument) || []\n\n return walkMap(JSON.parse(JSON.stringify(result)), (value, path) => {\n const resolveMappingResult = resolveMapping(path, resultSourceMap)\n if (!resolveMappingResult) {\n return value\n }\n\n const {mapping, pathSuffix} = resolveMappingResult\n if (mapping.type !== 'value') {\n return value\n }\n\n if (mapping.source.type !== 'documentValue') {\n return value\n }\n\n const sourceDocument = resultSourceMap.documents[mapping.source.document]\n const sourcePath = resultSourceMap.paths[mapping.source.path]\n\n if (sourceDocument) {\n const parsedPath = parseJsonPath(sourcePath + pathSuffix)\n const stringifiedPath = paths.toString(parsedPath as Path)\n const cachedDocument = cachedDocuments[mapping.source.document]\n\n if (!cachedDocument) {\n return value\n }\n\n const changedValue = cachedDocument\n ? paths.get<Result[keyof Result]>(cachedDocument, stringifiedPath, value)\n : value\n return value === changedValue\n ? value\n : updateFn<Result[keyof Result]>(changedValue as Any, {\n cachedDocument,\n previousValue: value as Result[keyof Result],\n sourceDocument,\n sourcePath: parsedPath,\n })\n }\n\n return value\n }) as Result\n}\n","import {jsonPath, parseJsonPath} from './jsonPath'\nimport type {ContentSourceMapParsedPath} from './types'\n\n/**\n * @internal\n */\nexport function resolvedKeyedSourcePath(options: {\n keyedResultPath: ContentSourceMapParsedPath\n pathSuffix?: string\n sourceBasePath: string\n}): ContentSourceMapParsedPath {\n const {keyedResultPath, pathSuffix, sourceBasePath} = options\n\n const inferredResultPath = pathSuffix === undefined ? [] : parseJsonPath(pathSuffix)\n\n const inferredPath = keyedResultPath.slice(keyedResultPath.length - inferredResultPath.length)\n\n const inferredPathSuffix = inferredPath.length ? jsonPath(inferredPath).slice(1) : ''\n\n return parseJsonPath(sourceBasePath + inferredPathSuffix)\n}\n","import {createEditUrl} from './createEditUrl'\nimport {studioPathToJsonPath} from './jsonPath'\nimport {resolveEditInfo} from './resolveEditInfo'\nimport type {ResolveEditUrlOptions} from './types'\n\n/** @alpha */\nexport function resolveEditUrl(\n options: ResolveEditUrlOptions,\n): ReturnType<typeof createEditUrl> | undefined {\n const {resultSourceMap, studioUrl} = options\n const resultPath = studioPathToJsonPath(options.resultPath)\n\n const editInfo = resolveEditInfo({\n resultPath,\n resultSourceMap,\n studioUrl,\n })\n if (!editInfo) {\n return undefined\n }\n\n return createEditUrl(editInfo)\n}\n"],"mappings":";;;;;;;AASA,SAAgB,oBACd,aACmD;CAGnD,IAFA,uBAAuB,WAAW,GAE9B,MAAM,QAAQ,WAAW,GAI3B,OAHK,YAAY,SAAS,WAAW,IAG9B,cAFE,CAAC,GAAG,aAAa,WAAW;CAIvC,QAAQ,aAAR;EACE,KAAK;EACL,KAAK,UACH,OAAO,CAAC,UAAU,WAAW;EAE/B,SACE,OAAO,CAAC,WAAW;CACvB;AACF;;ACfA,SAAgB,6BACd,mBAGA,cACA;CACA,IAAM,eAAe,oBAAoB,YAAY;CACrD,SAAS,aAAa,gBAAmD;EACvE,KAAK,IAAM,eAAe,cAAc;GACtC,IAAI,QAA8C;GAmBlD,IAlBI,YAAY,WAAW,GAAG,MAC5B,QAAQ,kBAAkB;IACxB,GAAG;IACH,KAAK,aAAa,eAAe,KAAK,WAAW;GACnD,CAAC,IAEC,gBAAgB,aAClB,QAAQ,kBAAkB;IACxB,GAAG;IACH,KAAK,WAAW,eA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A,IAAY,CAAC,IAAI,cAAc,UAAU,GAE7E,eAAe,gBAAgB,MAAM,gBAAgB,SAAS,mBAAmB,MAAM,GAEvF,qBAAqB,aAAa,SAAS,SAAS,YAAY,CAAC,CAAC,MAAM,CAAC,IAAI;CAEnF,OAAO,cAAc,iBAAiB,kBAAkB;AAC1D;;ACdA,SAAgB,eACd,SAC8C;CAC9C,IAAM,EAAC,iBAAiB,cAAa,SAC/B,aAAa,qBAAqB,QAAQ,UAAU,GAEpD,WAAW,gBAAgB;EAC/B;EACA;EACA;CACF,CAAC;CACI,cAIL,OAAO,cAAc,QAAQ;AAC/B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports), require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var p = {
|
|
4
|
+
0: 8203,
|
|
5
|
+
1: 8204,
|
|
6
|
+
2: 8205,
|
|
7
|
+
3: 8290,
|
|
8
|
+
4: 8291,
|
|
9
|
+
5: 8288,
|
|
10
|
+
6: 65279,
|
|
11
|
+
7: 8289,
|
|
12
|
+
8: 119155,
|
|
13
|
+
9: 119156,
|
|
14
|
+
a: 119157,
|
|
15
|
+
b: 119158,
|
|
16
|
+
c: 119159,
|
|
17
|
+
d: 119160,
|
|
18
|
+
e: 119161,
|
|
19
|
+
f: 119162
|
|
20
|
+
}, l = {
|
|
21
|
+
0: 8203,
|
|
22
|
+
1: 8204,
|
|
23
|
+
2: 8205,
|
|
24
|
+
3: 65279
|
|
25
|
+
}, d = {
|
|
26
|
+
0: String.fromCodePoint(l[0]),
|
|
27
|
+
1: String.fromCodePoint(l[1]),
|
|
28
|
+
2: String.fromCodePoint(l[2]),
|
|
29
|
+
3: String.fromCodePoint(l[3])
|
|
30
|
+
}, u = [
|
|
31
|
+
,
|
|
32
|
+
,
|
|
33
|
+
,
|
|
34
|
+
,
|
|
35
|
+
].fill(String.fromCodePoint(l[0])).join("");
|
|
36
|
+
function A(e) {
|
|
37
|
+
let r = JSON.stringify(e), t = new TextEncoder().encode(r), i = "";
|
|
38
|
+
for (let c = 0; c < t.length; c++) {
|
|
39
|
+
let n = t[c];
|
|
40
|
+
i += d[n >> 6 & 3] + d[n >> 4 & 3] + d[n >> 2 & 3] + d[n & 3];
|
|
41
|
+
}
|
|
42
|
+
return u + i;
|
|
43
|
+
}
|
|
44
|
+
function I(e) {
|
|
45
|
+
return !Number.isNaN(Number(e)) || /[a-z]/i.test(e) && !/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(e) ? !1 : !!Date.parse(e);
|
|
46
|
+
}
|
|
47
|
+
function S(e) {
|
|
48
|
+
try {
|
|
49
|
+
new URL(e, e.startsWith("/") ? "https://acme.com" : void 0);
|
|
50
|
+
} catch {
|
|
51
|
+
return !1;
|
|
52
|
+
}
|
|
53
|
+
return !0;
|
|
54
|
+
}
|
|
55
|
+
function y(e, r, t = "auto") {
|
|
56
|
+
return t === !0 || t === "auto" && (I(e) || S(e)) ? e : `${e}${A(r)}`;
|
|
57
|
+
}
|
|
58
|
+
Object.fromEntries(Object.entries(d).map((e) => [e[1], +e[0]])), Object.fromEntries(Object.entries(p).map((e) => e.reverse()));
|
|
59
|
+
var h = `${Object.values(p).map((e) => `\\u{${e.toString(16)}}`).join("")}`, x = exports.VERCEL_STEGA_REGEX = RegExp(`[${h}]{4,}`, "gu");
|
|
60
|
+
function P(e) {
|
|
61
|
+
return {
|
|
62
|
+
cleaned: e.replace(x, ""),
|
|
63
|
+
encoded: e.match(x)?.[0] || ""
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function w(e) {
|
|
67
|
+
return e && JSON.parse(P(JSON.stringify(e)).cleaned);
|
|
68
|
+
}
|
|
69
|
+
exports.VERCEL_STEGA_REGEX = x, exports.vercelStegaClean = w, exports.vercelStegaCombine = y;
|
|
70
|
+
}));
|
|
71
|
+
export { require_dist as t };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=dist-C9ExSk2R.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-C9ExSk2R.js","names":[],"sources":["../node_modules/.pnpm/@vercel+stega@1.1.0/node_modules/@vercel/stega/dist/index.js"],"sourcesContent":["\"use strict\";Object.defineProperty(exports, \"__esModule\", {value: true});var p={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},l={0:8203,1:8204,2:8205,3:65279},d={0:String.fromCodePoint(l[0]),1:String.fromCodePoint(l[1]),2:String.fromCodePoint(l[2]),3:String.fromCodePoint(l[3])},u=new Array(4).fill(String.fromCodePoint(l[0])).join(\"\"),g=String.fromCharCode(0);function A(e){let r=JSON.stringify(e),t=new TextEncoder().encode(r),i=\"\";for(let c=0;c<t.length;c++){let n=t[c];i+=d[n>>6&3]+d[n>>4&3]+d[n>>2&3]+d[n&3]}return u+i}function C(e){let r=JSON.stringify(e);return Array.from(r).map(t=>{let i=t.charCodeAt(0);if(i>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${r} on character ${t} (${i})`);return Array.from(i.toString(16).padStart(2,\"0\")).map(c=>String.fromCodePoint(p[c])).join(\"\")}).join(\"\")}function I(e){return!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\\d+(?:[-:\\/]\\d+){2}(?:T\\d+(?:[-:\\/]\\d+){1,2}(\\.\\d+)?Z?)?/.test(e)?!1:!!Date.parse(e)}function S(e){try{new URL(e,e.startsWith(\"/\")?\"https://acme.com\":void 0)}catch (e2){return!1}return!0}function y(e,r,t=\"auto\"){return t===!0||t===\"auto\"&&(I(e)||S(e))?e:`${e}${A(r)}`}var m=Object.fromEntries(Object.entries(d).map(e=>[e[1],+e[0]])),T=Object.fromEntries(Object.entries(p).map(e=>e.reverse())),h=`${Object.values(p).map(e=>`\\\\u{${e.toString(16)}}`).join(\"\")}`,x= exports.VERCEL_STEGA_REGEX =new RegExp(`[${h}]{4,}`,\"gu\");function X(e){let r=e.match(x);if(r)return E(r[0],!0)[0]}function M(e){let r=e.match(x);if(r)return r.map(t=>E(t)).flat()}function E(e,r=!1){let t=Array.from(e),i=1/0,c=-1;for(let n=0;n<t.length;++n)t[n]===u[0]&&t[n+1]===u[1]&&t[n+2]===u[2]&&t[n+3]===u[3]&&(i=Math.min(i,n),c=Math.max(c,n));if(c===-1)return _(t,r);for(let n=i;n<=c;++n)if(!((t.length-n)%4))try{let f=t.slice(n+4),s=new Uint8Array(f.length/4);for(let o=0;o<s.length;o++)s[o]=m[f[o*4]]<<6|m[f[o*4+1]]<<4|m[f[o*4+2]]<<2|m[f[o*4+3]];let a=new TextDecoder().decode(s);if(r){let o=a.indexOf(g);return o===-1&&(o=a.length),[JSON.parse(a.slice(0,o))]}return a.split(g).filter(Boolean).map(o=>JSON.parse(o))}catch (e3){}return[]}function _(e,r){var f;let t=[];for(let s=e.length*.5;s--;){let a=`${T[e[s*2].codePointAt(0)]}${T[e[s*2+1].codePointAt(0)]}`;t.unshift(String.fromCharCode(parseInt(a,16)))}let i=[],c=[t.join(\"\")],n=10;for(;c.length;){let s=c.shift();try{if(i.push(JSON.parse(s)),r)return i}catch(a){if(!n--)throw a;let o=+((f=a.message.match(/\\sposition\\s(\\d+)$/))==null?void 0:f[1]);if(!o)throw a;c.unshift(s.substring(0,o),s.substring(o))}}return i}function P(e){var r;return{cleaned:e.replace(x,\"\"),encoded:((r=e.match(x))==null?void 0:r[0])||\"\"}}function w(e){return e&&JSON.parse(P(JSON.stringify(e)).cleaned)}exports.VERCEL_STEGA_REGEX = x; exports.legacyStegaEncode = C; exports.vercelStegaClean = w; exports.vercelStegaCombine = y; exports.vercelStegaDecode = X; exports.vercelStegaDecodeAll = M; exports.vercelStegaEncode = A; exports.vercelStegaSplit = P;\n"],"x_google_igno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
|
15
|
+
d: 119160,
|
|
16
|
+
e: 119161,
|
|
17
|
+
f: 119162
|
|
18
|
+
}, l = {
|
|
19
|
+
0: 8203,
|
|
20
|
+
1: 8204,
|
|
21
|
+
2: 8205,
|
|
22
|
+
3: 65279
|
|
23
|
+
}, d = {
|
|
24
|
+
0: String.fromCodePoint(l[0]),
|
|
25
|
+
1: String.fromCodePoint(l[1]),
|
|
26
|
+
2: String.fromCodePoint(l[2]),
|
|
27
|
+
3: String.fromCodePoint(l[3])
|
|
28
|
+
}, u = [
|
|
29
|
+
,
|
|
30
|
+
,
|
|
31
|
+
,
|
|
32
|
+
,
|
|
33
|
+
].fill(String.fromCodePoint(l[0])).join("");
|
|
34
|
+
function A(e) {
|
|
35
|
+
let r = JSON.stringify(e), t = new TextEncoder().encode(r), i = "";
|
|
36
|
+
for (let c = 0; c < t.length; c++) {
|
|
37
|
+
let n = t[c];
|
|
38
|
+
i += d[n >> 6 & 3] + d[n >> 4 & 3] + d[n >> 2 & 3] + d[n & 3];
|
|
39
|
+
}
|
|
40
|
+
return u + i;
|
|
41
|
+
}
|
|
42
|
+
function I(e) {
|
|
43
|
+
return !Number.isNaN(Number(e)) || /[a-z]/i.test(e) && !/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(e) ? !1 : !!Date.parse(e);
|
|
44
|
+
}
|
|
45
|
+
function S(e) {
|
|
46
|
+
try {
|
|
47
|
+
new URL(e, e.startsWith("/") ? "https://acme.com" : void 0);
|
|
48
|
+
} catch {
|
|
49
|
+
return !1;
|
|
50
|
+
}
|
|
51
|
+
return !0;
|
|
52
|
+
}
|
|
53
|
+
function y(e, r, t = "auto") {
|
|
54
|
+
return t === !0 || t === "auto" && (I(e) || S(e)) ? e : `${e}${A(r)}`;
|
|
55
|
+
}
|
|
56
|
+
Object.fromEntries(Object.entries(d).map((e) => [e[1], +e[0]])), Object.fromEntries(Object.entries(p).map((e) => e.reverse()));
|
|
57
|
+
var h = `${Object.values(p).map((e) => `\\u{${e.toString(16)}}`).join("")}`, x = RegExp(`[${h}]{4,}`, "gu");
|
|
58
|
+
function P(e) {
|
|
59
|
+
return {
|
|
60
|
+
cleaned: e.replace(x, ""),
|
|
61
|
+
encoded: e.match(x)?.[0] || ""
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function w(e) {
|
|
65
|
+
return e && JSON.parse(P(JSON.stringify(e)).cleaned);
|
|
66
|
+
}
|
|
67
|
+
export { y as n, w as t };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=dist-Z8cIRxoB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-Z8cIRxoB.js","names":[],"sources":["../node_modules/.pnpm/@vercel+stega@1.1.0/node_modules/@vercel/stega/dist/index.mjs"],"sourcesContent":["var p={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},l={0:8203,1:8204,2:8205,3:65279},d={0:String.fromCodePoint(l[0]),1:String.fromCodePoint(l[1]),2:String.fromCodePoint(l[2]),3:String.fromCodePoint(l[3])},u=new Array(4).fill(String.fromCodePoint(l[0])).join(\"\"),g=String.fromCharCode(0);function A(e){let r=JSON.stringify(e),t=new TextEncoder().encode(r),i=\"\";for(let c=0;c<t.length;c++){let n=t[c];i+=d[n>>6&3]+d[n>>4&3]+d[n>>2&3]+d[n&3]}return u+i}function C(e){let r=JSON.stringify(e);return Array.from(r).map(t=>{let i=t.charCodeAt(0);if(i>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${r} on character ${t} (${i})`);return Array.from(i.toString(16).padStart(2,\"0\")).map(c=>String.fromCodePoint(p[c])).join(\"\")}).join(\"\")}function I(e){return!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\\d+(?:[-:\\/]\\d+){2}(?:T\\d+(?:[-:\\/]\\d+){1,2}(\\.\\d+)?Z?)?/.test(e)?!1:!!Date.parse(e)}function S(e){try{new URL(e,e.startsWith(\"/\")?\"https://acme.com\":void 0)}catch{return!1}return!0}function y(e,r,t=\"auto\"){return t===!0||t===\"auto\"&&(I(e)||S(e))?e:`${e}${A(r)}`}var m=Object.fromEntries(Object.entries(d).map(e=>[e[1],+e[0]])),T=Object.fromEntries(Object.entries(p).map(e=>e.reverse())),h=`${Object.values(p).map(e=>`\\\\u{${e.toString(16)}}`).join(\"\")}`,x=new RegExp(`[${h}]{4,}`,\"gu\");function X(e){let r=e.match(x);if(r)return E(r[0],!0)[0]}function M(e){let r=e.match(x);if(r)return r.map(t=>E(t)).flat()}function E(e,r=!1){let t=Array.from(e),i=1/0,c=-1;for(let n=0;n<t.length;++n)t[n]===u[0]&&t[n+1]===u[1]&&t[n+2]===u[2]&&t[n+3]===u[3]&&(i=Math.min(i,n),c=Math.max(c,n));if(c===-1)return _(t,r);for(let n=i;n<=c;++n)if(!((t.length-n)%4))try{let f=t.slice(n+4),s=new Uint8Array(f.length/4);for(let o=0;o<s.length;o++)s[o]=m[f[o*4]]<<6|m[f[o*4+1]]<<4|m[f[o*4+2]]<<2|m[f[o*4+3]];let a=new TextDecoder().decode(s);if(r){let o=a.indexOf(g);return o===-1&&(o=a.length),[JSON.parse(a.slice(0,o))]}return a.split(g).filter(Boolean).map(o=>JSON.parse(o))}catch{}return[]}function _(e,r){var f;let t=[];for(let s=e.length*.5;s--;){let a=`${T[e[s*2].codePointAt(0)]}${T[e[s*2+1].codePointAt(0)]}`;t.unshift(String.fromCharCode(parseInt(a,16)))}let i=[],c=[t.join(\"\")],n=10;for(;c.length;){let s=c.shift();try{if(i.push(JSON.parse(s)),r)return i}catch(a){if(!n--)throw a;let o=+((f=a.message.match(/\\sposition\\s(\\d+)$/))==null?void 0:f[1]);if(!o)throw a;c.unshift(s.substring(0,o),s.substring(o))}}return i}function P(e){var r;return{cleaned:e.replace(x,\"\"),encoded:((r=e.match(x))==null?void 0:r[0])||\"\"}}function w(e){return e&&JSON.parse(P(JSON.stringify(e)).cleaned)}export{x as VERCEL_STEGA_REGEX,C as legacyStegaEncode,w as vercelStegaClean,y as vercelStegaCombine,X as vercelStegaDecode,M as vercelStegaDecodeAll,A as vercelStegaEncode,P as vercelStegaSplit};\n"],"x_google_ignoreList":[0],"mappings":"AAAA,IAAI,IAAE;CAAC,GAAE;CAAK,GAAE;CAAK,GAAE;CAAK,GAAE;CAAK,GAAE;CAAK,GAAE;CAAK,GAAE;CAAM,GAAE;CAAK,GAAE;CAAO,GAAE;CAAO,GAAE;CAAO,GAAE;CAAO,GAAE;CAAO,GAAE;CAAO,GAAE;CAAO,GAAE;AAAM,GAAE,IAAE;CAAC,GAAE;CAAK,GAAE;CAAK,GAAE;CAAK,GAAE;AAAK,GAAE,IAAE;CAAC,GAAE,OAAO,cAAc,EAAE,EAAE;CAAE,GAAE,OAAO,cAAc,EAAE,EAAE;CAAE,GAAE,OAAO,cAAc,EAAE,EAAE;CAAE,GAAE,OAAO,cAAc,EAAE,EAAE;AAAC,GAAE,IAAE;;;;;AAAW,CAAC,CAAC,KAAK,OAAO,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE;AAA2B,SAAS,EAAE,GAAE;CAAC,IAAI,IAAE,KAAK,UAAU,CAAC,GAAE,IAAE,IAAI,YAAY,CAAC,CAAC,OAAO,CAAC,GAAE,IAAE;CAAG,KAAI,IAAI,IAAE,GAAE,IAAE,EAAE,QAAO,KAAI;EAAC,IAAI,IAAE,EAAE;EAAG,KAAG,EAAE,KAAG,IAAE,KAAG,EAAE,KAAG,IAAE,KAAG,EAAE,KAAG,IAAE,KAAG,EAAE,IAAE;CAAE;CAAC,OAAO,IAAE;AAAC;AAA6T,SAAS,EAAE,GAAE;CAAC,OAAM,CAAC,OAAO,MAAM,OAAO,CAAC,CAAC,KAAG,SAAS,KAAK,CAAC,KAAG,CAAC,2DAA2D,KAAK,CAAC,IAAE,CAAC,IAAE,CAAC,CAAC,KAAK,MAAM,CAAC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