@sanity/document-internationalization 3.3.1 → 3.3.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/components/DeleteTranslationDialog/DocumentPreview.tsx","../src/constants.ts","../src/components/DeleteTranslationDialog/separateReferences.ts","../src/components/DeleteTranslationDialog/index.tsx","../src/components/DeleteTranslationFooter.tsx","../node_modules/suspend-react/index.js","../src/components/DocumentInternationalizationContext.tsx","../src/actions/DeleteTranslationAction.tsx","../node_modules/tslib/tslib.es6.mjs","../node_modules/rxjs/dist/esm5/internal/util/isFunction.js","../node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js","../node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js","../node_modules/rxjs/dist/esm5/internal/util/arrRemove.js","../node_modules/rxjs/dist/esm5/internal/Subscription.js","../node_modules/rxjs/dist/esm5/internal/config.js","../node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js","../node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js","../node_modules/rxjs/dist/esm5/internal/util/noop.js","../node_modules/rxjs/dist/esm5/internal/Subscriber.js","../node_modules/rxjs/dist/esm5/internal/util/lift.js","../node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js","../node_modules/rxjs/dist/esm5/internal/util/EmptyError.js","../node_modules/rxjs/dist/esm5/internal/firstValueFrom.js","../node_modules/rxjs/dist/esm5/internal/operators/filter.js","../src/hooks/useLanguageMetadata.tsx","../src/i18n/index.ts","../src/actions/DuplicateWithTranslationsAction.tsx","../src/hooks/useOpenInNewPane.tsx","../src/utils/createReference.ts","../src/components/LanguageManage.tsx","../src/utils/excludePaths.ts","../src/components/LanguageOption.tsx","../src/components/LanguagePatch.tsx","../src/components/ConstrainedBox.tsx","../src/components/Warning.tsx","../src/components/DocumentInternationalizationMenu.tsx","../src/actions/DeleteMetadataAction.tsx","../src/badges/index.tsx","../src/components/BulkPublish/DocumentCheck.tsx","../src/components/BulkPublish/InfoIcon.tsx","../src/components/BulkPublish/Info.tsx","../src/components/BulkPublish/index.tsx","../src/components/OptimisticallyStrengthen/ReferencePatcher.tsx","../src/components/OptimisticallyStrengthen/index.tsx","../src/schema/translation/metadata.ts","../src/plugin.tsx"],"sourcesContent":["import {Preview, useSchema} from 'sanity'\nimport {Feedback} from 'sanity-plugin-utils'\n\ntype DocumentPreviewProps = {\n value: unknown\n type: string\n}\n\n// Wrapper of Preview just so that the schema type is satisfied by schema.get()\nexport default function DocumentPreview(props: DocumentPreviewProps) {\n const schema = useSchema()\n\n const schemaType = schema.get(props.type)\n if (!schemaType) {\n return <Feedback tone=\"critical\" title=\"Schema type not found\" />\n }\n\n return <Preview value={props.value} schemaType={schemaType} />\n}\n","import type {PluginConfigContext} from './types'\n\nexport const METADATA_SCHEMA_NAME = `translation.metadata`\nexport const TRANSLATIONS_ARRAY_NAME = `translations`\nexport const API_VERSION = `2023-05-22`\nexport const DEFAULT_CONFIG: PluginConfigContext = {\n supportedLanguages: [],\n schemaTypes: [],\n languageField: `language`,\n weakReferences: false,\n bulkPublish: false,\n metadataFields: [],\n apiVersion: API_VERSION,\n allowCreateMetaDoc: false,\n callback: null,\n}\n","import type {SanityDocument} from 'sanity'\n\nimport {METADATA_SCHEMA_NAME} from '../../constants'\n\nexport function separateReferences(data: SanityDocument[] | null = []): {\n translations: SanityDocument[]\n otherReferences: SanityDocument[]\n} {\n const translations: SanityDocument[] = []\n const otherReferences: SanityDocument[] = []\n\n if (data && data.length > 0) {\n data.forEach((doc) => {\n if (doc._type === METADATA_SCHEMA_NAME) {\n translations.push(doc)\n } else {\n otherReferences.push(doc)\n }\n })\n }\n\n return {translations, otherReferences}\n}\n","import {Card, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {useEffect, useMemo} from 'react'\nimport type {SanityDocument} from 'sanity'\nimport {useListeningQuery} from 'sanity-plugin-utils'\n\nimport DocumentPreview from './DocumentPreview'\nimport {separateReferences} from './separateReferences'\n\ntype DeleteTranslationDialogProps = {\n doc: SanityDocument\n documentId: string\n setTranslations: (translations: SanityDocument[]) => void\n}\n\nexport default function DeleteTranslationDialog(\n props: DeleteTranslationDialogProps\n) {\n const {doc, documentId, setTranslations} = props\n\n // Get all references and check if any of them are translations metadata\n const {data, loading} = useListeningQuery<SanityDocument[]>(\n `*[references($id)]{_id, _type}`,\n {params: {id: documentId}, initialValue: []}\n )\n const {translations, otherReferences} = useMemo(\n () => separateReferences(data),\n [data]\n )\n\n useEffect(() => {\n setTranslations(translations)\n }, [setTranslations, translations])\n\n if (loading) {\n return (\n <Flex padding={4} align=\"center\" justify=\"center\">\n <Spinner />\n </Flex>\n )\n }\n\n return (\n <Stack space={4}>\n {translations && translations.length > 0 ? (\n <Text>\n This document is a language-specific version which other translations\n depend on.\n </Text>\n ) : (\n <Text>This document does not have connected translations.</Text>\n )}\n <Card border padding={3}>\n <Stack space={4}>\n <Text size={1} weight=\"semibold\">\n {translations && translations.length > 0 ? (\n <>Before this document can be deleted</>\n ) : (\n <>This document can now be deleted</>\n )}\n </Text>\n <DocumentPreview value={doc} type={doc._type} />\n {translations && translations.length > 0 ? (\n <>\n <Card borderTop />\n <Text size={1} weight=\"semibold\">\n The reference in{' '}\n {translations.length === 1\n ? `this translations document`\n : `these translations documents`}{' '}\n must be removed\n </Text>\n {translations.map((translation) => (\n <DocumentPreview\n key={translation._id}\n value={translation}\n type={translation._type}\n />\n ))}\n </>\n ) : null}\n {otherReferences && otherReferences.length > 0 ? (\n <>\n <Card borderTop />\n <Text size={1} weight=\"semibold\">\n {otherReferences.length === 1\n ? `There is an additional reference`\n : `There are additional references`}{' '}\n to this document\n </Text>\n {otherReferences.map((reference) => (\n <DocumentPreview\n key={reference._id}\n value={reference}\n type={reference._type}\n />\n ))}\n </>\n ) : null}\n </Stack>\n </Card>\n {otherReferences.length === 0 ? (\n <Text>This document has no other references.</Text>\n ) : (\n <Text>\n You may not be able to delete this document because other documents\n refer to it.\n </Text>\n )}\n </Stack>\n )\n}\n","import {Button, Grid} from '@sanity/ui'\n\ntype DeleteTranslationFooterProps = {\n translations: unknown[]\n onClose: () => void\n onProceed: () => void\n}\n\nexport default function DeleteTranslationFooter(\n props: DeleteTranslationFooterProps\n) {\n const {translations, onClose, onProceed} = props\n\n return (\n <Grid columns={2} gap={2}>\n <Button text=\"Cancel\" onClick={onClose} mode=\"ghost\" />\n <Button\n text={\n translations && translations.length > 0\n ? `Unset translation reference`\n : `Delete document`\n }\n onClick={onProceed}\n tone=\"critical\"\n />\n </Grid>\n )\n}\n","const isPromise = promise => typeof promise === 'object' && typeof promise.then === 'function';\n\nconst globalCache = [];\n\nfunction shallowEqualArrays(arrA, arrB, equal = (a, b) => a === b) {\n if (arrA === arrB) return true;\n if (!arrA || !arrB) return false;\n const len = arrA.length;\n if (arrB.length !== len) return false;\n\n for (let i = 0; i < len; i++) if (!equal(arrA[i], arrB[i])) return false;\n\n return true;\n}\n\nfunction query(fn, keys = null, preload = false, config = {}) {\n // If no keys were given, the function is the key\n if (keys === null) keys = [fn];\n\n for (const entry of globalCache) {\n // Find a match\n if (shallowEqualArrays(keys, entry.keys, entry.equal)) {\n // If we're pre-loading and the element is present, just return\n if (preload) return undefined; // If an error occurred, throw\n\n if (Object.prototype.hasOwnProperty.call(entry, 'error')) throw entry.error; // If a response was successful, return\n\n if (Object.prototype.hasOwnProperty.call(entry, 'response')) {\n if (config.lifespan && config.lifespan > 0) {\n if (entry.timeout) clearTimeout(entry.timeout);\n entry.timeout = setTimeout(entry.remove, config.lifespan);\n }\n\n return entry.response;\n } // If the promise is still unresolved, throw\n\n\n if (!preload) throw entry.promise;\n }\n } // The request is new or has changed.\n\n\n const entry = {\n keys,\n equal: config.equal,\n remove: () => {\n const index = globalCache.indexOf(entry);\n if (index !== -1) globalCache.splice(index, 1);\n },\n promise: // Execute the promise\n (isPromise(fn) ? fn : fn(...keys) // When it resolves, store its value\n ).then(response => {\n entry.response = response; // Remove the entry in time if a lifespan was given\n\n if (config.lifespan && config.lifespan > 0) {\n entry.timeout = setTimeout(entry.remove, config.lifespan);\n }\n }) // Store caught errors, they will be thrown in the render-phase to bubble into an error-bound\n .catch(error => entry.error = error)\n }; // Register the entry\n\n globalCache.push(entry); // And throw the promise, this yields control back to React\n\n if (!preload) throw entry.promise;\n return undefined;\n}\n\nconst suspend = (fn, keys, config) => query(fn, keys, false, config);\n\nconst preload = (fn, keys, config) => void query(fn, keys, true, config);\n\nconst peek = keys => {\n var _globalCache$find;\n\n return (_globalCache$find = globalCache.find(entry => shallowEqualArrays(keys, entry.keys, entry.equal))) == null ? void 0 : _globalCache$find.response;\n};\n\nconst clear = keys => {\n if (keys === undefined || keys.length === 0) globalCache.splice(0, globalCache.length);else {\n const entry = globalCache.find(entry => shallowEqualArrays(keys, entry.keys, entry.equal));\n if (entry) entry.remove();\n }\n};\n\nexport { clear, peek, preload, suspend };\n","import {useContext} from 'react'\nimport {createContext} from 'react'\nimport {type LayoutProps, useClient, useWorkspace} from 'sanity'\nimport {suspend} from 'suspend-react'\n\nimport {DEFAULT_CONFIG} from '../constants'\nimport type {PluginConfig, PluginConfigContext} from '../types'\n\nconst DocumentInternationalizationContext =\n createContext<PluginConfigContext>(DEFAULT_CONFIG)\n\nexport function useDocumentInternationalizationContext() {\n return useContext(DocumentInternationalizationContext)\n}\n\ntype DocumentInternationalizationProviderProps = LayoutProps & {\n pluginConfig: Required<PluginConfig>\n}\n\n/**\n * This Provider wraps the Studio and provides the DocumentInternationalization context to document actions and components.\n */\nexport function DocumentInternationalizationProvider(\n props: DocumentInternationalizationProviderProps\n) {\n const {pluginConfig} = props\n\n const client = useClient({apiVersion: pluginConfig.apiVersion})\n const workspace = useWorkspace()\n const supportedLanguages = Array.isArray(pluginConfig.supportedLanguages)\n ? pluginConfig.supportedLanguages\n : // eslint-disable-next-line require-await\n suspend(async () => {\n if (typeof pluginConfig.supportedLanguages === 'function') {\n return pluginConfig.supportedLanguages(client)\n }\n return pluginConfig.supportedLanguages\n }, [workspace])\n\n return (\n <DocumentInternationalizationContext.Provider\n value={{...pluginConfig, supportedLanguages}}\n >\n {props.renderDefault(props)}\n </DocumentInternationalizationContext.Provider>\n )\n}\n","import {TrashIcon} from '@sanity/icons'\nimport {type ButtonTone, useToast} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport {\n type DocumentActionComponent,\n type SanityDocument,\n useClient,\n} from 'sanity'\n\nimport DeleteTranslationDialog from '../components/DeleteTranslationDialog'\nimport DeleteTranslationFooter from '../components/DeleteTranslationFooter'\nimport {useDocumentInternationalizationContext} from '../components/DocumentInternationalizationContext'\nimport {API_VERSION, TRANSLATIONS_ARRAY_NAME} from '../constants'\n\nexport const DeleteTranslationAction: DocumentActionComponent = (props) => {\n const {id: documentId, published, draft} = props\n const doc = draft || published\n const {languageField} = useDocumentInternationalizationContext()\n\n const [isDialogOpen, setDialogOpen] = useState(false)\n const [translations, setTranslations] = useState<SanityDocument[]>([])\n const onClose = useCallback(() => setDialogOpen(false), [])\n const documentLanguage = doc ? doc[languageField] : null\n\n const toast = useToast()\n const client = useClient({apiVersion: API_VERSION})\n\n // Remove translation reference and delete document in one transaction\n const onProceed = useCallback(() => {\n const tx = client.transaction()\n let operation = 'DELETE'\n\n if (documentLanguage && translations.length > 0) {\n operation = 'UNSET'\n translations.forEach((translation) => {\n tx.patch(translation._id, (patch) =>\n patch.unset([\n `${TRANSLATIONS_ARRAY_NAME}[_key == \"${documentLanguage}\"]`,\n ])\n )\n })\n } else {\n tx.delete(documentId)\n tx.delete(`drafts.${documentId}`)\n }\n\n tx.commit()\n .then(() => {\n if (operation === 'DELETE') {\n onClose()\n }\n toast.push({\n status: 'success',\n title:\n operation === 'UNSET'\n ? 'Translation reference unset'\n : 'Document deleted',\n description:\n operation === 'UNSET' ? 'The document can now be deleted' : null,\n })\n })\n .catch((err) => {\n toast.push({\n status: 'error',\n title:\n operation === 'unset'\n ? 'Failed to unset translation reference'\n : 'Failed to delete document',\n description: err.message,\n })\n })\n }, [client, documentLanguage, translations, documentId, onClose, toast])\n\n return {\n label: `Delete translation...`,\n disabled: !doc || !documentLanguage,\n icon: TrashIcon,\n tone: 'critical' as ButtonTone,\n onHandle: () => {\n setDialogOpen(true)\n },\n dialog: isDialogOpen && {\n type: 'dialog',\n onClose,\n header: 'Delete translation',\n content: doc ? (\n <DeleteTranslationDialog\n doc={doc}\n documentId={documentId}\n setTranslations={setTranslations}\n />\n ) : null,\n footer: (\n <DeleteTranslationFooter\n onClose={onClose}\n onProceed={onProceed}\n translations={translations}\n />\n ),\n },\n }\n}\n","/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n","export function isFunction(value) {\n return typeof value === 'function';\n}\n//# sourceMappingURL=isFunction.js.map","export function createErrorClass(createImpl) {\n var _super = function (instance) {\n Error.call(instance);\n instance.stack = new Error().stack;\n };\n var ctorFunc = createImpl(_super);\n ctorFunc.prototype = Object.create(Error.prototype);\n ctorFunc.prototype.constructor = ctorFunc;\n return ctorFunc;\n}\n//# sourceMappingURL=createErrorClass.js.map","import { createErrorClass } from './createErrorClass';\nexport var UnsubscriptionError = createErrorClass(function (_super) {\n return function UnsubscriptionErrorImpl(errors) {\n _super(this);\n this.message = errors\n ? errors.length + \" errors occurred during unsubscription:\\n\" + errors.map(function (err, i) { return i + 1 + \") \" + err.toString(); }).join('\\n ')\n : '';\n this.name = 'UnsubscriptionError';\n this.errors = errors;\n };\n});\n//# sourceMappingURL=UnsubscriptionError.js.map","export function arrRemove(arr, item) {\n if (arr) {\n var index = arr.indexOf(item);\n 0 <= index && arr.splice(index, 1);\n }\n}\n//# sourceMappingURL=arrRemove.js.map","import { __read, __spreadArray, __values } from \"tslib\";\nimport { isFunction } from './util/isFunction';\nimport { UnsubscriptionError } from './util/UnsubscriptionError';\nimport { arrRemove } from './util/arrRemove';\nvar Subscription = (function () {\n function Subscription(initialTeardown) {\n this.initialTeardown = initialTeardown;\n this.closed = false;\n this._parentage = null;\n this._finalizers = null;\n }\n Subscription.prototype.unsubscribe = function () {\n var e_1, _a, e_2, _b;\n var errors;\n if (!this.closed) {\n this.closed = true;\n var _parentage = this._parentage;\n if (_parentage) {\n this._parentage = null;\n if (Array.isArray(_parentage)) {\n try {\n for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {\n var parent_1 = _parentage_1_1.value;\n parent_1.remove(this);\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);\n }\n finally { if (e_1) throw e_1.error; }\n }\n }\n else {\n _parentage.remove(this);\n }\n }\n var initialFinalizer = this.initialTeardown;\n if (isFunction(initialFinalizer)) {\n try {\n initialFinalizer();\n }\n catch (e) {\n errors = e instanceof UnsubscriptionError ? e.errors : [e];\n }\n }\n var _finalizers = this._finalizers;\n if (_finalizers) {\n this._finalizers = null;\n try {\n for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {\n var finalizer = _finalizers_1_1.value;\n try {\n execFinalizer(finalizer);\n }\n catch (err) {\n errors = errors !== null && errors !== void 0 ? errors : [];\n if (err instanceof UnsubscriptionError) {\n errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));\n }\n else {\n errors.push(err);\n }\n }\n }\n }\n catch (e_2_1) { e_2 = { error: e_2_1 }; }\n finally {\n try {\n if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);\n }\n finally { if (e_2) throw e_2.error; }\n }\n }\n if (errors) {\n throw new UnsubscriptionError(errors);\n }\n }\n };\n Subscription.prototype.add = function (teardown) {\n var _a;\n if (teardown && teardown !== this) {\n if (this.closed) {\n execFinalizer(teardown);\n }\n else {\n if (teardown instanceof Subscription) {\n if (teardown.closed || teardown._hasParent(this)) {\n return;\n }\n teardown._addParent(this);\n }\n (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);\n }\n }\n };\n Subscription.prototype._hasParent = function (parent) {\n var _parentage = this._parentage;\n return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));\n };\n Subscription.prototype._addParent = function (parent) {\n var _parentage = this._parentage;\n this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;\n };\n Subscription.prototype._removeParent = function (parent) {\n var _parentage = this._parentage;\n if (_parentage === parent) {\n this._parentage = null;\n }\n else if (Array.isArray(_parentage)) {\n arrRemove(_parentage, parent);\n }\n };\n Subscription.prototype.remove = function (teardown) {\n var _finalizers = this._finalizers;\n _finalizers && arrRemove(_finalizers, teardown);\n if (teardown instanceof Subscription) {\n teardown._removeParent(this);\n }\n };\n Subscription.EMPTY = (function () {\n var empty = new Subscription();\n empty.closed = true;\n return empty;\n })();\n return Subscription;\n}());\nexport { Subscription };\nexport var EMPTY_SUBSCRIPTION = Subscription.EMPTY;\nexport function isSubscription(value) {\n return (value instanceof Subscription ||\n (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));\n}\nfunction execFinalizer(finalizer) {\n if (isFunction(finalizer)) {\n finalizer();\n }\n else {\n finalizer.unsubscribe();\n }\n}\n//# sourceMappingURL=Subscription.js.map","export var config = {\n onUnhandledError: null,\n onStoppedNotification: null,\n Promise: undefined,\n useDeprecatedSynchronousErrorHandling: false,\n useDeprecatedNextContext: false,\n};\n//# sourceMappingURL=config.js.map","import { __read, __spreadArray } from \"tslib\";\nexport var timeoutProvider = {\n setTimeout: function (handler, timeout) {\n var args = [];\n for (var _i = 2; _i < arguments.length; _i++) {\n args[_i - 2] = arguments[_i];\n }\n var delegate = timeoutProvider.delegate;\n if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {\n return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));\n }\n return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));\n },\n clearTimeout: function (handle) {\n var delegate = timeoutProvider.delegate;\n return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);\n },\n delegate: undefined,\n};\n//# sourceMappingURL=timeoutProvider.js.map","import { config } from '../config';\nimport { timeoutProvider } from '../scheduler/timeoutProvider';\nexport function reportUnhandledError(err) {\n timeoutProvider.setTimeout(function () {\n var onUnhandledError = config.onUnhandledError;\n if (onUnhandledError) {\n onUnhandledError(err);\n }\n else {\n throw err;\n }\n });\n}\n//# sourceMappingURL=reportUnhandledError.js.map","export function noop() { }\n//# sourceMappingURL=noop.js.map","import { __extends } from \"tslib\";\nimport { isFunction } from './util/isFunction';\nimport { isSubscription, Subscription } from './Subscription';\nimport { config } from './config';\nimport { reportUnhandledError } from './util/reportUnhandledError';\nimport { noop } from './util/noop';\nimport { nextNotification, errorNotification, COMPLETE_NOTIFICATION } from './NotificationFactories';\nimport { timeoutProvider } from './scheduler/timeoutProvider';\nimport { captureError } from './util/errorContext';\nvar Subscriber = (function (_super) {\n __extends(Subscriber, _super);\n function Subscriber(destination) {\n var _this = _super.call(this) || this;\n _this.isStopped = false;\n if (destination) {\n _this.destination = destination;\n if (isSubscription(destination)) {\n destination.add(_this);\n }\n }\n else {\n _this.destination = EMPTY_OBSERVER;\n }\n return _this;\n }\n Subscriber.create = function (next, error, complete) {\n return new SafeSubscriber(next, error, complete);\n };\n Subscriber.prototype.next = function (value) {\n if (this.isStopped) {\n handleStoppedNotification(nextNotification(value), this);\n }\n else {\n this._next(value);\n }\n };\n Subscriber.prototype.error = function (err) {\n if (this.isStopped) {\n handleStoppedNotification(errorNotification(err), this);\n }\n else {\n this.isStopped = true;\n this._error(err);\n }\n };\n Subscriber.prototype.complete = function () {\n if (this.isStopped) {\n handleStoppedNotification(COMPLETE_NOTIFICATION, this);\n }\n else {\n this.isStopped = true;\n this._complete();\n }\n };\n Subscriber.prototype.unsubscribe = function () {\n if (!this.closed) {\n this.isStopped = true;\n _super.prototype.unsubscribe.call(this);\n this.destination = null;\n }\n };\n Subscriber.prototype._next = function (value) {\n this.destination.next(value);\n };\n Subscriber.prototype._error = function (err) {\n try {\n this.destination.error(err);\n }\n finally {\n this.unsubscribe();\n }\n };\n Subscriber.prototype._complete = function () {\n try {\n this.destination.complete();\n }\n finally {\n this.unsubscribe();\n }\n };\n return Subscriber;\n}(Subscription));\nexport { Subscriber };\nvar _bind = Function.prototype.bind;\nfunction bind(fn, thisArg) {\n return _bind.call(fn, thisArg);\n}\nvar ConsumerObserver = (function () {\n function ConsumerObserver(partialObserver) {\n this.partialObserver = partialObserver;\n }\n ConsumerObserver.prototype.next = function (value) {\n var partialObserver = this.partialObserver;\n if (partialObserver.next) {\n try {\n partialObserver.next(value);\n }\n catch (error) {\n handleUnhandledError(error);\n }\n }\n };\n ConsumerObserver.prototype.error = function (err) {\n var partialObserver = this.partialObserver;\n if (partialObserver.error) {\n try {\n partialObserver.error(err);\n }\n catch (error) {\n handleUnhandledError(error);\n }\n }\n else {\n handleUnhandledError(err);\n }\n };\n ConsumerObserver.prototype.complete = function () {\n var partialObserver = this.partialObserver;\n if (partialObserver.complete) {\n try {\n partialObserver.complete();\n }\n catch (error) {\n handleUnhandledError(error);\n }\n }\n };\n return ConsumerObserver;\n}());\nvar SafeSubscriber = (function (_super) {\n __extends(SafeSubscriber, _super);\n function SafeSubscriber(observerOrNext, error, complete) {\n var _this = _super.call(this) || this;\n var partialObserver;\n if (isFunction(observerOrNext) || !observerOrNext) {\n partialObserver = {\n next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),\n error: error !== null && error !== void 0 ? error : undefined,\n complete: complete !== null && complete !== void 0 ? complete : undefined,\n };\n }\n else {\n var context_1;\n if (_this && config.useDeprecatedNextContext) {\n context_1 = Object.create(observerOrNext);\n context_1.unsubscribe = function () { return _this.unsubscribe(); };\n partialObserver = {\n next: observerOrNext.next && bind(observerOrNext.next, context_1),\n error: observerOrNext.error && bind(observerOrNext.error, context_1),\n complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),\n };\n }\n else {\n partialObserver = observerOrNext;\n }\n }\n _this.destination = new ConsumerObserver(partialObserver);\n return _this;\n }\n return SafeSubscriber;\n}(Subscriber));\nexport { SafeSubscriber };\nfunction handleUnhandledError(error) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n captureError(error);\n }\n else {\n reportUnhandledError(error);\n }\n}\nfunction defaultErrorHandler(err) {\n throw err;\n}\nfunction handleStoppedNotification(notification, subscriber) {\n var onStoppedNotification = config.onStoppedNotification;\n onStoppedNotification && timeoutProvider.setTimeout(function () { return onStoppedNotification(notification, subscriber); });\n}\nexport var EMPTY_OBSERVER = {\n closed: true,\n next: noop,\n error: defaultErrorHandler,\n complete: noop,\n};\n//# sourceMappingURL=Subscriber.js.map","import { isFunction } from './isFunction';\nexport function hasLift(source) {\n return isFunction(source === null || source === void 0 ? void 0 : source.lift);\n}\nexport function operate(init) {\n return function (source) {\n if (hasLift(source)) {\n return source.lift(function (liftedSource) {\n try {\n return init(liftedSource, this);\n }\n catch (err) {\n this.error(err);\n }\n });\n }\n throw new TypeError('Unable to lift unknown Observable type');\n };\n}\n//# sourceMappingURL=lift.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {\n return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);\n}\nvar OperatorSubscriber = (function (_super) {\n __extends(OperatorSubscriber, _super);\n function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {\n var _this = _super.call(this, destination) || this;\n _this.onFinalize = onFinalize;\n _this.shouldUnsubscribe = shouldUnsubscribe;\n _this._next = onNext\n ? function (value) {\n try {\n onNext(value);\n }\n catch (err) {\n destination.error(err);\n }\n }\n : _super.prototype._next;\n _this._error = onError\n ? function (err) {\n try {\n onError(err);\n }\n catch (err) {\n destination.error(err);\n }\n finally {\n this.unsubscribe();\n }\n }\n : _super.prototype._error;\n _this._complete = onComplete\n ? function () {\n try {\n onComplete();\n }\n catch (err) {\n destination.error(err);\n }\n finally {\n this.unsubscribe();\n }\n }\n : _super.prototype._complete;\n return _this;\n }\n OperatorSubscriber.prototype.unsubscribe = function () {\n var _a;\n if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {\n var closed_1 = this.closed;\n _super.prototype.unsubscribe.call(this);\n !closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));\n }\n };\n return OperatorSubscriber;\n}(Subscriber));\nexport { OperatorSubscriber };\n//# sourceMappingURL=OperatorSubscriber.js.map","import { createErrorClass } from './createErrorClass';\nexport var EmptyError = createErrorClass(function (_super) { return function EmptyErrorImpl() {\n _super(this);\n this.name = 'EmptyError';\n this.message = 'no elements in sequence';\n}; });\n//# sourceMappingURL=EmptyError.js.map","import { EmptyError } from './util/EmptyError';\nimport { SafeSubscriber } from './Subscriber';\nexport function firstValueFrom(source, config) {\n var hasConfig = typeof config === 'object';\n return new Promise(function (resolve, reject) {\n var subscriber = new SafeSubscriber({\n next: function (value) {\n resolve(value);\n subscriber.unsubscribe();\n },\n error: reject,\n complete: function () {\n if (hasConfig) {\n resolve(config.defaultValue);\n }\n else {\n reject(new EmptyError());\n }\n },\n });\n source.subscribe(subscriber);\n });\n}\n//# sourceMappingURL=firstValueFrom.js.map","import { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function filter(predicate, thisArg) {\n return operate(function (source, subscriber) {\n var index = 0;\n source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));\n });\n}\n//# sourceMappingURL=filter.js.map","import {useListeningQuery} from 'sanity-plugin-utils'\n\nimport {METADATA_SCHEMA_NAME} from '../constants'\nimport type {Metadata} from '../types'\n\n// Using references() seemed less reliable for updating the listener\n// results than querying raw values in the array\n// AFAIK: references is _faster_ when querying with GROQ\n// const query = `*[_type == $translationSchema && references($id)]`\nconst query = `*[_type == $translationSchema && $id in translations[].value._ref]{\n _id,\n _createdAt,\n translations\n}`\n\nexport function useTranslationMetadata(id: string): {\n data: Metadata[] | null\n loading: boolean\n error: boolean | unknown | ProgressEvent\n} {\n const {data, loading, error} = useListeningQuery<Metadata[]>(query, {\n params: {id, translationSchema: METADATA_SCHEMA_NAME},\n })\n\n return {data, loading, error}\n}\n","import {defineLocaleResourceBundle} from 'sanity'\n\n/**\n * The locale namespace for the document internationalization plugin.\n *\n * @public\n */\nexport const documenti18nLocaleNamespace =\n 'document-internationalization' as const\n\n/**\n * The default locale bundle for the document internationalization plugin, which is US English.\n *\n * @internal\n */\nexport const documentInternationalizationUsEnglishLocaleBundle =\n defineLocaleResourceBundle({\n locale: 'en-US',\n namespace: documenti18nLocaleNamespace,\n resources: () => import('./resources'),\n })\n","import {CopyIcon} from '@sanity/icons'\nimport {useToast} from '@sanity/ui'\nimport {uuid} from '@sanity/uuid'\nimport {useCallback, useMemo, useState} from 'react'\nimport {filter, firstValueFrom} from 'rxjs'\nimport {\n DEFAULT_STUDIO_CLIENT_OPTIONS,\n type DocumentActionComponent,\n type Id,\n InsufficientPermissionsMessage,\n type PatchOperations,\n useClient,\n useCurrentUser,\n useDocumentOperation,\n useDocumentPairPermissions,\n useDocumentStore,\n useTranslation,\n} from 'sanity'\nimport {useRouter} from 'sanity/router'\nimport {structureLocaleNamespace} from 'sanity/structure'\n\nimport {METADATA_SCHEMA_NAME, TRANSLATIONS_ARRAY_NAME} from '../constants'\nimport {useTranslationMetadata} from '../hooks/useLanguageMetadata'\nimport {documenti18nLocaleNamespace} from '../i18n'\n\nconst DISABLED_REASON_KEY = {\n METADATA_NOT_FOUND: 'action.duplicate.disabled.missing-metadata',\n MULTIPLE_METADATA: 'action.duplicate.disabled.multiple-metadata',\n NOTHING_TO_DUPLICATE: 'action.duplicate.disabled.nothing-to-duplicate',\n NOT_READY: 'action.duplicate.disabled.not-ready',\n}\n\nexport const DuplicateWithTranslationsAction: DocumentActionComponent = ({\n id,\n type,\n onComplete,\n}) => {\n const documentStore = useDocumentStore()\n const {duplicate} = useDocumentOperation(id, type)\n const {navigateIntent} = useRouter()\n const [isDuplicating, setDuplicating] = useState(false)\n const [permissions, isPermissionsLoading] = useDocumentPairPermissions({\n id,\n type,\n permission: 'duplicate',\n })\n const {data, loading: isMetadataDocumentLoading} = useTranslationMetadata(id)\n const hasOneMetadataDocument = useMemo(() => {\n return Array.isArray(data) && data.length <= 1\n }, [data])\n const metadataDocument = Array.isArray(data) && data.length ? data[0] : null\n const client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS)\n const toast = useToast()\n const {t: s} = useTranslation(structureLocaleNamespace)\n const {t: d} = useTranslation(documenti18nLocaleNamespace)\n const currentUser = useCurrentUser()\n\n const handle = useCallback(async () => {\n setDuplicating(true)\n\n try {\n if (!metadataDocument) {\n throw new Error('Metadata document not found')\n }\n\n // 1. Duplicate the document and its localized versions\n const translations = new Map<string, Id>()\n await Promise.all(\n metadataDocument[TRANSLATIONS_ARRAY_NAME].map(async (translation) => {\n const dupeId = uuid()\n const locale = translation._key\n const docId = translation.value?._ref\n\n if (!docId) {\n throw new Error('Translation document not found')\n }\n\n const {duplicate: duplicateTranslation} = await firstValueFrom(\n documentStore.pair\n .editOperations(docId, type)\n .pipe(filter((op) => op.duplicate.disabled !== 'NOT_READY'))\n )\n\n if (duplicateTranslation.disabled) {\n throw new Error('Cannot duplicate document')\n }\n\n const duplicateTranslationSuccess = firstValueFrom(\n documentStore.pair\n .operationEvents(docId, type)\n .pipe(filter((e) => e.op === 'duplicate' && e.type === 'success'))\n )\n duplicateTranslation.execute(dupeId)\n await duplicateTranslationSuccess\n\n translations.set(locale, dupeId)\n })\n )\n\n // 2. Duplicate the metadata document\n const {duplicate: duplicateMetadata} = await firstValueFrom(\n documentStore.pair\n .editOperations(metadataDocument._id, METADATA_SCHEMA_NAME)\n .pipe(filter((op) => op.duplicate.disabled !== 'NOT_READY'))\n )\n\n if (duplicateMetadata.disabled) {\n throw new Error('Cannot duplicate document')\n }\n\n const duplicateMetadataSuccess = firstValueFrom(\n documentStore.pair\n .operationEvents(metadataDocument._id, METADATA_SCHEMA_NAME)\n .pipe(filter((e) => e.op === 'duplicate' && e.type === 'success'))\n )\n const dupeId = uuid()\n duplicateMetadata.execute(dupeId)\n await duplicateMetadataSuccess\n\n // 3. Patch the duplicated metadata document to update the references\n // TODO: use document store\n // const {patch: patchMetadata} = await firstValueFrom(\n // documentStore.pair\n // .editOperations(dupeId, METADATA_SCHEMA_NAME)\n // .pipe(filter((op) => op.patch.disabled !== 'NOT_READY'))\n // )\n\n // if (patchMetadata.disabled) {\n // throw new Error('Cannot patch document')\n // }\n\n // await firstValueFrom(\n // documentStore.pair\n // .consistencyStatus(dupeId, METADATA_SCHEMA_NAME)\n // .pipe(filter((isConsistant) => isConsistant))\n // )\n\n // const patchMetadataSuccess = firstValueFrom(\n // documentStore.pair\n // .operationEvents(dupeId, METADATA_SCHEMA_NAME)\n // .pipe(filter((e) => e.op === 'patch' && e.type === 'success'))\n // )\n\n const patch: PatchOperations = {\n set: Object.fromEntries(\n Array.from(translations.entries()).map(([locale, documentId]) => [\n `${TRANSLATIONS_ARRAY_NAME}[_key == \"${locale}\"].value._ref`,\n documentId,\n ])\n ),\n }\n\n // patchMetadata.execute([patch])\n // await patchMetadataSuccess\n await client.transaction().patch(dupeId, patch).commit()\n\n // 4. Navigate to the duplicated document\n navigateIntent('edit', {\n id: Array.from(translations.values()).at(0),\n type,\n })\n\n onComplete()\n } catch (error) {\n console.error(error)\n toast.push({\n status: 'error',\n title: 'Error duplicating document',\n description:\n error instanceof Error\n ? error.message\n : 'Failed to duplicate document',\n })\n } finally {\n setDuplicating(false)\n }\n }, [\n client,\n documentStore.pair,\n metadataDocument,\n navigateIntent,\n onComplete,\n toast,\n type,\n ])\n\n return useMemo(() => {\n if (!isPermissionsLoading && !permissions?.granted) {\n return {\n icon: CopyIcon,\n disabled: true,\n label: d('action.duplicate.label'),\n title: (\n <InsufficientPermissionsMessage\n context=\"duplicate-document\"\n currentUser={currentUser}\n />\n ),\n }\n }\n\n if (!isMetadataDocumentLoading && !metadataDocument) {\n return {\n icon: CopyIcon,\n disabled: true,\n label: d('action.duplicate.label'),\n title: d(DISABLED_REASON_KEY.METADATA_NOT_FOUND),\n }\n }\n\n if (!hasOneMetadataDocument) {\n return {\n icon: CopyIcon,\n disabled: true,\n label: d('action.duplicate.label'),\n title: d(DISABLED_REASON_KEY.MULTIPLE_METADATA),\n }\n }\n\n return {\n icon: CopyIcon,\n disabled:\n isDuplicating ||\n Boolean(duplicate.disabled) ||\n isPermissionsLoading ||\n isMetadataDocumentLoading,\n label: isDuplicating\n ? s('action.duplicate.running.label')\n : d('action.duplicate.label'),\n title: duplicate.disabled\n ? s(DISABLED_REASON_KEY[duplicate.disabled])\n : '',\n onHandle: handle,\n }\n }, [\n currentUser,\n duplicate.disabled,\n handle,\n hasOneMetadataDocument,\n isDuplicating,\n isMetadataDocumentLoading,\n isPermissionsLoading,\n metadataDocument,\n permissions?.granted,\n s,\n d,\n ])\n}\n\nDuplicateWithTranslationsAction.action = 'duplicate'\n// @ts-expect-error `displayName` is used by React DevTools\nDuplicateWithTranslationsAction.displayName = 'DuplicateWithTranslationsAction'\n","import {useCallback, useContext} from 'react'\nimport {RouterContext} from 'sanity/router'\nimport {usePaneRouter} from 'sanity/structure'\n\nexport function useOpenInNewPane(id?: string | null, type?: string) {\n const routerContext = useContext(RouterContext)\n const {routerPanesState, groupIndex} = usePaneRouter()\n\n const openInNewPane = useCallback(() => {\n if (!routerContext || !id || !type) {\n return\n }\n\n // No panes open, function might be called outside Structure\n if (!routerPanesState.length) {\n routerContext.navigateIntent('edit', {id, type})\n return\n }\n\n const panes = [...routerPanesState]\n panes.splice(groupIndex + 1, 0, [\n {\n id: id,\n params: {type},\n },\n ])\n\n const href = routerContext.resolvePathFromState({panes})\n routerContext.navigateUrl({path: href})\n }, [id, type, routerContext, routerPanesState, groupIndex])\n\n return openInNewPane\n}\n","import type {TranslationReference} from '../types'\n\nexport function createReference(\n key: string,\n ref: string,\n type: string,\n strengthenOnPublish: boolean = true\n): TranslationReference {\n return {\n _key: key,\n _type: 'internationalizedArrayReferenceValue',\n value: {\n _type: 'reference',\n _ref: ref,\n _weak: true,\n // If the user has configured weakReferences, we won't want to strengthen them\n ...(strengthenOnPublish ? {_strengthenOnPublish: {type}} : {}),\n },\n }\n}\n","import {CogIcon} from '@sanity/icons'\nimport {Box, Button, Stack, Text, Tooltip} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport {type ObjectSchemaType, useClient} from 'sanity'\n\nimport {METADATA_SCHEMA_NAME} from '../constants'\nimport {useOpenInNewPane} from '../hooks/useOpenInNewPane'\nimport {createReference} from '../utils/createReference'\nimport {useDocumentInternationalizationContext} from './DocumentInternationalizationContext'\n\ntype LanguageManageProps = {\n id?: string\n metadataId?: string | null\n schemaType: ObjectSchemaType\n documentId: string\n sourceLanguageId?: string\n}\n\nexport default function LanguageManage(props: LanguageManageProps) {\n const {id, metadataId, schemaType, documentId, sourceLanguageId} = props\n const open = useOpenInNewPane(id, METADATA_SCHEMA_NAME)\n const openCreated = useOpenInNewPane(metadataId, METADATA_SCHEMA_NAME)\n const {allowCreateMetaDoc, apiVersion, weakReferences} =\n useDocumentInternationalizationContext()\n const client = useClient({apiVersion})\n const [userHasClicked, setUserHasClicked] = useState(false)\n\n const canCreate = !id && Boolean(metadataId) && allowCreateMetaDoc\n\n const handleClick = useCallback(() => {\n if (!id && metadataId && sourceLanguageId) {\n /* Disable button while this request is pending */\n setUserHasClicked(true)\n\n // handle creation of meta document\n const transaction = client.transaction()\n\n const sourceReference = createReference(\n sourceLanguageId,\n documentId,\n schemaType.name,\n !weakReferences\n )\n const newMetadataDocument = {\n _id: metadataId,\n _type: METADATA_SCHEMA_NAME,\n schemaTypes: [schemaType.name],\n translations: [sourceReference],\n }\n\n transaction.createIfNotExists(newMetadataDocument)\n\n transaction\n .commit()\n .then(() => {\n setUserHasClicked(false)\n openCreated()\n })\n .catch((err) => {\n console.error(err)\n setUserHasClicked(false)\n })\n } else {\n open()\n }\n }, [\n id,\n metadataId,\n sourceLanguageId,\n client,\n documentId,\n schemaType.name,\n weakReferences,\n openCreated,\n open,\n ])\n\n const disabled =\n (!id && !canCreate) || (canCreate && !sourceLanguageId) || userHasClicked\n\n return (\n <Tooltip\n animate\n content={\n <Box padding={2}>\n <Text muted size={1}>\n Document has no other translations\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n disabled={Boolean(id) || canCreate}\n >\n <Stack>\n <Button\n disabled={disabled}\n mode=\"ghost\"\n text=\"Manage Translations\"\n icon={CogIcon}\n loading={userHasClicked}\n onClick={handleClick}\n />\n </Stack>\n </Tooltip>\n )\n}\n","import {extractWithPath, Mutation} from '@sanity/mutator'\nimport {\n isDocumentSchemaType,\n type ObjectSchemaType,\n type Path,\n pathToString,\n type SanityDocument,\n type SchemaType,\n} from 'sanity'\n\nexport interface DocumentMember {\n schemaType: SchemaType\n path: Path\n name: string\n value: unknown\n}\n\nexport function removeExcludedPaths(\n doc: SanityDocument | null,\n schemaType: ObjectSchemaType\n): SanityDocument | null {\n // If the supplied doc is null or the schemaType\n // isn't a document, return as is.\n if (!isDocumentSchemaType(schemaType) || !doc) {\n return doc\n }\n\n // The extractPaths function gets all the fields in the doc with\n // a value, along with their schemaTypes and paths. We'll end up\n // with an array of paths in string form which we want to exclude\n const pathsToExclude: string[] = extractPaths(doc, schemaType, [])\n // We filter for any fields which should be excluded from the document\n // duplicate action, based on the schemaType option being set.\n .filter(\n (field) =>\n field.schemaType?.options?.documentInternationalization?.exclude ===\n true\n )\n // then we return the stringified version of the path\n .map((field) => {\n return pathToString(field.path)\n })\n\n // Now we can use the Mutation class from @sanity/mutator to patch the document\n // to remove all the paths that are for one of the excluded fields. This is just\n // done locally, and the documents themselves are not patched in the Content Lake.\n const mut = new Mutation({\n mutations: [\n {\n patch: {\n id: doc._id,\n unset: pathsToExclude,\n },\n },\n ],\n })\n\n return mut.apply(doc) as SanityDocument\n}\n\nfunction extractPaths(\n doc: SanityDocument,\n schemaType: ObjectSchemaType,\n path: Path\n): DocumentMember[] {\n return schemaType.fields.reduce<DocumentMember[]>((acc, field) => {\n const fieldPath = [...path, field.name]\n const fieldSchema = field.type\n const {value} = extractWithPath(pathToString(fieldPath), doc)[0] ?? {}\n if (!value) {\n return acc\n }\n\n const thisFieldWithPath: DocumentMember = {\n path: fieldPath,\n name: field.name,\n schemaType: fieldSchema,\n value,\n }\n\n if (fieldSchema.jsonType === 'object') {\n const innerFields = extractPaths(doc, fieldSchema, fieldPath)\n\n return [...acc, thisFieldWithPath, ...innerFields]\n } else if (\n fieldSchema.jsonType === 'array' &&\n fieldSchema.of.length &&\n fieldSchema.of.some((item) => 'fields' in item)\n ) {\n const {value: arrayValue} =\n extractWithPath(pathToString(fieldPath), doc)[0] ?? {}\n\n let arrayPaths: DocumentMember[] = []\n if ((arrayValue as any)?.length) {\n for (const item of arrayValue as any[]) {\n const itemPath = [...fieldPath, {_key: item._key}]\n let itemSchema = fieldSchema.of.find((t) => t.name === item._type)\n if (!item._type) {\n itemSchema = fieldSchema.of[0]\n }\n if (item._key && itemSchema) {\n const innerFields = extractPaths(\n doc,\n itemSchema as ObjectSchemaType,\n itemPath\n )\n const arrayMember = {\n path: itemPath,\n name: item._key,\n schemaType: itemSchema,\n value: item,\n }\n arrayPaths = [...arrayPaths, arrayMember, ...innerFields]\n }\n }\n }\n\n return [...acc, thisFieldWithPath, ...arrayPaths]\n }\n\n return [...acc, thisFieldWithPath]\n }, [])\n}\n","import {AddIcon, CheckmarkIcon, SplitVerticalIcon} from '@sanity/icons'\nimport {\n Badge,\n Box,\n Button,\n Flex,\n Spinner,\n Text,\n Tooltip,\n useToast,\n} from '@sanity/ui'\nimport {uuid} from '@sanity/uuid'\nimport {useCallback, useEffect, useState} from 'react'\nimport {type ObjectSchemaType, type SanityDocument, useClient} from 'sanity'\n\nimport {METADATA_SCHEMA_NAME} from '../constants'\nimport {useOpenInNewPane} from '../hooks/useOpenInNewPane'\nimport type {\n Language,\n Metadata,\n MetadataDocument,\n TranslationReference,\n} from '../types'\nimport {createReference} from '../utils/createReference'\nimport {removeExcludedPaths} from '../utils/excludePaths'\nimport {useDocumentInternationalizationContext} from './DocumentInternationalizationContext'\n\ntype LanguageOptionProps = {\n language: Language\n schemaType: ObjectSchemaType\n documentId: string\n disabled: boolean\n current: boolean\n source: SanityDocument | null\n metadataId: string | null\n metadata?: Metadata | null\n sourceLanguageId?: string\n}\n\nexport default function LanguageOption(props: LanguageOptionProps) {\n const {\n language,\n schemaType,\n documentId,\n current,\n source,\n sourceLanguageId,\n metadata,\n metadataId,\n } = props\n /* When the user has clicked the Create button, the button should be disabled\n * to prevent double-clicks from firing onCreate twice. This creates duplicate\n * translation metadata entries, which editors will not be able to delete */\n const [userHasClicked, setUserHasClicked] = useState(false)\n const disabled =\n props.disabled ||\n userHasClicked ||\n current ||\n !source ||\n !sourceLanguageId ||\n !metadataId\n const translation: TranslationReference | undefined = metadata?.translations\n .length\n ? metadata.translations.find((t) => t._key === language.id)\n : undefined\n const {apiVersion, languageField, weakReferences, callback} =\n useDocumentInternationalizationContext()\n const client = useClient({apiVersion})\n const toast = useToast()\n\n const open = useOpenInNewPane(translation?.value?._ref, schemaType.name)\n const handleOpen = useCallback(() => open(), [open])\n\n /* Once a translation has been created, reset the userHasClicked state to false\n * so they can click on it to navigate to the translation. If a translation already\n * existed when this component was mounted, this will have no effect. */\n const hasTranslation = Boolean(translation)\n useEffect(() => {\n setUserHasClicked(false)\n }, [hasTranslation])\n\n const handleCreate = useCallback(async () => {\n if (!source) {\n throw new Error(`Cannot create translation without source document`)\n }\n\n if (!sourceLanguageId) {\n throw new Error(`Cannot create translation without source language ID`)\n }\n\n if (!metadataId) {\n throw new Error(`Cannot create translation without a metadata ID`)\n }\n /* Disable the create button while this request is pending */\n setUserHasClicked(true)\n\n const transaction = client.transaction()\n\n // 1. Duplicate source document\n const newTranslationDocumentId = uuid()\n let newTranslationDocument = {\n ...source,\n _id: `drafts.${newTranslationDocumentId}`,\n // 2. Update language of the translation\n [languageField]: language.id,\n }\n\n // Remove fields / paths we don't want to duplicate\n newTranslationDocument = removeExcludedPaths(\n newTranslationDocument,\n schemaType\n ) as SanityDocument\n\n transaction.create(newTranslationDocument)\n\n // 3. Maybe create the metadata document\n const sourceReference = createReference(\n sourceLanguageId,\n documentId,\n schemaType.name,\n !weakReferences\n )\n const newTranslationReference = createReference(\n language.id,\n newTranslationDocumentId,\n schemaType.name,\n !weakReferences\n )\n const newMetadataDocument: MetadataDocument = {\n _id: metadataId,\n _type: METADATA_SCHEMA_NAME,\n schemaTypes: [schemaType.name],\n translations: [sourceReference],\n }\n\n transaction.createIfNotExists(newMetadataDocument)\n\n // 4. Patch translation to metadata document\n // Note: If the document was only just created in the operation above\n // This patch operation will have no effect\n const metadataPatch = client\n .patch(metadataId)\n .setIfMissing({translations: [sourceReference]})\n .insert(`after`, `translations[-1]`, [newTranslationReference])\n\n transaction.patch(metadataPatch)\n\n // 5. Commit!\n transaction\n .commit()\n .then(() => {\n const metadataExisted = Boolean(metadata?._createdAt)\n\n callback?.({\n client,\n sourceLanguageId,\n sourceDocument: source,\n newDocument: newTranslationDocument,\n destinationLanguageId: language.id,\n metaDocumentId: metadataId,\n }).catch((err) => {\n toast.push({\n status: 'error',\n title: `Callback`,\n description: `Error while running callback - ${err}.`,\n })\n })\n\n return toast.push({\n status: 'success',\n title: `Created \"${language.title}\" translation`,\n description: metadataExisted\n ? `Updated Translations Metadata`\n : `Created Translations Metadata`,\n })\n })\n .catch((err) => {\n console.error(err)\n\n /* Re-enable the create button if there was an error */\n setUserHasClicked(false)\n\n return toast.push({\n status: 'error',\n title: `Error creating translation`,\n description: err.message,\n })\n })\n }, [\n client,\n documentId,\n language.id,\n language.title,\n languageField,\n metadata?._createdAt,\n metadataId,\n schemaType,\n source,\n sourceLanguageId,\n toast,\n weakReferences,\n callback,\n ])\n\n let message\n\n if (current) {\n message = `Current document`\n } else if (translation) {\n message = `Open ${language.title} translation`\n } else if (!translation) {\n message = `Create new ${language.title} translation`\n }\n\n return (\n <Tooltip\n animate\n content={\n <Box padding={2}>\n <Text muted size={1}>\n {message}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n >\n <Button\n onClick={translation ? handleOpen : handleCreate}\n mode={current && disabled ? `default` : `bleed`}\n disabled={disabled}\n >\n <Flex gap={3} align=\"center\">\n {disabled && !current ? (\n <Spinner />\n ) : (\n <Text size={2}>\n {/* eslint-disable-next-line no-nested-ternary */}\n {translation ? (\n <SplitVerticalIcon />\n ) : current ? (\n <CheckmarkIcon />\n ) : (\n <AddIcon />\n )}\n </Text>\n )}\n <Box flex={1}>\n <Text>{language.title}</Text>\n </Box>\n <Badge tone={disabled || current ? `default` : `primary`}>\n {language.id}\n </Badge>\n </Flex>\n </Button>\n </Tooltip>\n )\n}\n","import {EditIcon} from '@sanity/icons'\nimport {Badge, Box, Button, Flex, Text, useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {type SanityDocument, useClient} from 'sanity'\n\nimport type {Language} from '../types'\nimport {useDocumentInternationalizationContext} from './DocumentInternationalizationContext'\n\ntype LanguagePatchProps = {\n language: Language\n source: SanityDocument | null\n disabled: boolean\n}\n\nexport default function LanguagePatch(props: LanguagePatchProps) {\n const {language, source} = props\n const {apiVersion, languageField} = useDocumentInternationalizationContext()\n const disabled = props.disabled || !source\n const client = useClient({apiVersion})\n const toast = useToast()\n\n const handleClick = useCallback(() => {\n if (!source) {\n throw new Error(`Cannot patch missing document`)\n }\n\n const currentId = source._id\n\n client\n .patch(currentId)\n .set({[languageField]: language.id})\n .commit()\n .then(() => {\n toast.push({\n title: `Set document language to ${language.title}`,\n status: `success`,\n })\n })\n .catch((err) => {\n console.error(err)\n\n return toast.push({\n title: `Failed to set document language to ${language.title}`,\n status: `error`,\n })\n })\n }, [source, client, languageField, language, toast])\n\n return (\n <Button\n mode=\"bleed\"\n onClick={handleClick}\n disabled={disabled}\n justify=\"flex-start\"\n >\n <Flex gap={3} align=\"center\">\n <Text size={2}>\n <EditIcon />\n </Text>\n <Box flex={1}>\n <Text>{language.title}</Text>\n </Box>\n <Badge>{language.id}</Badge>\n </Flex>\n </Button>\n )\n}\n","import {Box} from '@sanity/ui'\nimport {styled} from 'styled-components'\n\nexport default styled(Box)`\n max-width: 280px;\n`\n","import {Card, Flex, Text} from '@sanity/ui'\nimport type {PropsWithChildren} from 'react'\n\nimport ConstrainedBox from './ConstrainedBox'\n\nexport default function Warning({children}: PropsWithChildren) {\n return (\n <Card tone=\"caution\" padding={3}>\n <Flex justify=\"center\">\n <ConstrainedBox>\n <Text size={1} align=\"center\">\n {children}\n </Text>\n </ConstrainedBox>\n </Flex>\n </Card>\n )\n}\n","import {TranslateIcon} from '@sanity/icons'\nimport {\n Box,\n Button,\n Card,\n Popover,\n Stack,\n Text,\n TextInput,\n useClickOutside,\n} from '@sanity/ui'\nimport {uuid} from '@sanity/uuid'\nimport {type FormEvent, useCallback, useMemo, useState} from 'react'\nimport {useEditState} from 'sanity'\n\nimport {useTranslationMetadata} from '../hooks/useLanguageMetadata'\nimport type {DocumentInternationalizationMenuProps} from '../types'\nimport {useDocumentInternationalizationContext} from './DocumentInternationalizationContext'\nimport LanguageManage from './LanguageManage'\nimport LanguageOption from './LanguageOption'\nimport LanguagePatch from './LanguagePatch'\nimport Warning from './Warning'\n\nexport function DocumentInternationalizationMenu(\n props: DocumentInternationalizationMenuProps\n) {\n const {documentId} = props\n const schemaType = props.schemaType\n const {languageField, supportedLanguages} =\n useDocumentInternationalizationContext()\n\n // Search filter query\n const [query, setQuery] = useState(``)\n const handleQuery = useCallback((event: FormEvent<HTMLInputElement>) => {\n if (event.currentTarget.value) {\n setQuery(event.currentTarget.value)\n } else {\n setQuery(``)\n }\n }, [])\n\n // UI Handlers\n const [open, setOpen] = useState(false)\n const handleClick = useCallback(() => setOpen((o) => !o), [])\n const [button, setButton] = useState<HTMLElement | null>(null)\n const [popover, setPopover] = useState<HTMLElement | null>(null)\n const handleClickOutside = useCallback(() => setOpen(false), [])\n useClickOutside(handleClickOutside, [button, popover])\n\n // Get metadata from content lake\n const {data, loading, error} = useTranslationMetadata(documentId)\n const metadata = Array.isArray(data) && data.length ? data[0] : null\n\n // Optimistically set a metadata ID for a newly created metadata document\n // Cannot rely on generated metadata._id from useTranslationMetadata\n // As the document store might not have returned it before creating another translation\n const metadataId = useMemo(() => {\n if (loading) {\n return null\n }\n\n // Once created, these two values should be the same anyway\n return metadata?._id ?? uuid()\n }, [loading, metadata?._id])\n\n // Duplicate a new language version from the most recent version of this document\n const {draft, published} = useEditState(documentId, schemaType.name)\n const source = draft || published\n\n // Check for data issues\n const documentIsInOneMetadataDocument = useMemo(() => {\n return Array.isArray(data) && data.length <= 1\n }, [data])\n const sourceLanguageId = source?.[languageField] as string | undefined\n const sourceLanguageIsValid = supportedLanguages.some(\n (l) => l.id === sourceLanguageId\n )\n const allLanguagesAreValid = useMemo(() => {\n const valid = supportedLanguages.every((l) => l.id && l.title)\n if (!valid) {\n console.warn(\n `Not all languages are valid. It should be an array of objects with an \"id\" and \"title\" property. Or a function that returns an array of objects with an \"id\" and \"title\" property.`,\n supportedLanguages\n )\n }\n\n return valid\n }, [supportedLanguages])\n\n const content = (\n <Box padding={1}>\n {error ? (\n <Card tone=\"critical\" padding={1}>\n <Text>There was an error returning translations metadata</Text>\n </Card>\n ) : (\n <Stack space={1}>\n <LanguageManage\n id={metadata?._id}\n documentId={documentId}\n metadataId={metadataId}\n schemaType={schemaType}\n sourceLanguageId={sourceLanguageId}\n />\n {supportedLanguages.length > 4 ? (\n <TextInput\n onChange={handleQuery}\n value={query}\n placeholder=\"Filter languages\"\n />\n ) : null}\n {supportedLanguages.length > 0 ? (\n <>\n {/* Once metadata is loaded, there may be issues */}\n {loading ? null : (\n <>\n {/* Not all languages are valid */}\n {data && documentIsInOneMetadataDocument ? null : (\n <Warning>\n {/* TODO: Surface these documents to the user */}\n This document has been found in more than one Translations\n Metadata documents\n </Warning>\n )}\n {/* Not all languages are valid */}\n {allLanguagesAreValid ? null : (\n <Warning>\n Not all language objects are valid. See the console.\n </Warning>\n )}\n {/* Current document has no language field */}\n {sourceLanguageId ? null : (\n <Warning>\n Choose a language to apply to{' '}\n <strong>this Document</strong>\n </Warning>\n )}\n {/* Current document has an invalid language field */}\n {sourceLanguageId && !sourceLanguageIsValid ? (\n <Warning>\n Select a supported language. Current language value:{' '}\n <code>{sourceLanguageId}</code>\n </Warning>\n ) : null}\n </>\n )}\n {supportedLanguages\n .filter((language) => {\n if (query) {\n return language.title\n .toLowerCase()\n .includes(query.toLowerCase())\n }\n return true\n })\n .map((language) =>\n !loading && sourceLanguageId && sourceLanguageIsValid ? (\n // Button to duplicate this document to a new translation\n // And either create or update the metadata document\n <LanguageOption\n key={language.id}\n language={language}\n schemaType={schemaType}\n documentId={documentId}\n disabled={loading || !allLanguagesAreValid}\n current={language.id === sourceLanguageId}\n metadata={metadata}\n metadataId={metadataId}\n source={source}\n sourceLanguageId={sourceLanguageId}\n />\n ) : (\n // Button to set a language field on *this* document\n <LanguagePatch\n key={language.id}\n source={source}\n language={language}\n // Only allow language patch change to:\n // - Keys not in metadata\n // - The key of this document in the metadata\n disabled={\n (loading ||\n !allLanguagesAreValid ||\n metadata?.translations\n .filter((t) => t?.value?._ref !== documentId)\n .some((t) => t._key === language.id)) ??\n false\n }\n />\n )\n )}\n </>\n ) : null}\n </Stack>\n )}\n </Box>\n )\n\n const issueWithTranslations =\n !loading && sourceLanguageId && !sourceLanguageIsValid\n\n if (!documentId) {\n return null\n }\n\n if (!schemaType || !schemaType.name) {\n return null\n }\n\n return (\n <Popover\n animate\n constrainSize\n content={content}\n open={open}\n portal\n ref={setPopover}\n overflow=\"auto\"\n tone=\"default\"\n >\n <Button\n text=\"Translations\"\n mode=\"bleed\"\n disabled={!source}\n tone={\n !source || loading || !issueWithTranslations ? undefined : `caution`\n }\n icon={TranslateIcon}\n onClick={handleClick}\n ref={setButton}\n selected={open}\n />\n </Popover>\n )\n}\n","import {TrashIcon} from '@sanity/icons'\nimport {type ButtonTone, useToast} from '@sanity/ui'\nimport {useCallback, useMemo, useState} from 'react'\nimport {\n type DocumentActionComponent,\n type KeyedObject,\n type Reference,\n type TypedObject,\n useClient,\n} from 'sanity'\n\nimport {API_VERSION, TRANSLATIONS_ARRAY_NAME} from '../constants'\n\ntype TranslationReference = TypedObject &\n KeyedObject & {\n value: Reference\n }\n\nexport const DeleteMetadataAction: DocumentActionComponent = (props) => {\n const {id: documentId, published, draft, onComplete} = props\n const doc = draft || published\n\n const [isDialogOpen, setDialogOpen] = useState(false)\n const onClose = useCallback(() => setDialogOpen(false), [])\n const translations: TranslationReference[] = useMemo(\n () =>\n doc && Array.isArray(doc[TRANSLATIONS_ARRAY_NAME])\n ? (doc[TRANSLATIONS_ARRAY_NAME] as TranslationReference[])\n : [],\n [doc]\n )\n\n const toast = useToast()\n const client = useClient({apiVersion: API_VERSION})\n\n // Remove translation reference and delete document in one transaction\n const onProceed = useCallback(() => {\n const tx = client.transaction()\n\n tx.patch(documentId, (patch) => patch.unset([TRANSLATIONS_ARRAY_NAME]))\n\n if (translations.length > 0) {\n translations.forEach((translation) => {\n tx.delete(translation.value._ref)\n tx.delete(`drafts.${translation.value._ref}`)\n })\n }\n\n tx.delete(documentId)\n // Shouldn't exist as this document type is in liveEdit\n tx.delete(`drafts.${documentId}`)\n\n tx.commit()\n .then(() => {\n onClose()\n\n toast.push({\n status: 'success',\n title: 'Deleted document and translations',\n })\n })\n .catch((err) => {\n toast.push({\n status: 'error',\n title: 'Failed to delete document and translations',\n description: err.message,\n })\n })\n }, [client, translations, documentId, onClose, toast])\n\n return {\n label: `Delete all translations`,\n disabled: !doc || !translations.length,\n icon: TrashIcon,\n tone: 'critical' as ButtonTone,\n onHandle: () => {\n setDialogOpen(true)\n },\n dialog: isDialogOpen && {\n type: 'confirm',\n onCancel: onComplete,\n onConfirm: () => {\n onProceed()\n onComplete()\n },\n tone: 'critical' as ButtonTone,\n message:\n translations.length === 1\n ? `Delete 1 translation and this document`\n : `Delete all ${translations.length} translations and this document`,\n },\n }\n}\n","import type {DocumentBadgeDescription, DocumentBadgeProps} from 'sanity'\n\nimport {useDocumentInternationalizationContext} from '../components/DocumentInternationalizationContext'\n\nexport function LanguageBadge(\n props: DocumentBadgeProps\n): DocumentBadgeDescription | null {\n const source = props?.draft || props?.published\n const {languageField, supportedLanguages} =\n useDocumentInternationalizationContext()\n const languageId = source?.[languageField]\n\n if (!languageId) {\n return null\n }\n\n const language = Array.isArray(supportedLanguages)\n ? supportedLanguages.find((l) => l.id === languageId)\n : null\n\n // Currently we only show the language id if the supportedLanguages are async\n return {\n label: language?.id ?? String(languageId),\n title: language?.title ?? undefined,\n color: `primary`,\n }\n}\n","import {Card, Spinner} from '@sanity/ui'\nimport {useEffect, useMemo} from 'react'\nimport {Preview, useEditState, useSchema, useValidationStatus} from 'sanity'\n\ntype DocumentCheckProps = {\n id: string\n onCheckComplete: (id: string) => void\n addInvalidId: (id: string) => void\n removeInvalidId: (id: string) => void\n addDraftId: (id: string) => void\n removeDraftId: (id: string) => void\n}\n\n// Check if the document has a draft\n// Check if that draft is valid\n// Report back to parent that it can be added to bulk publish\nexport default function DocumentCheck(props: DocumentCheckProps) {\n const {\n id,\n onCheckComplete,\n addInvalidId,\n removeInvalidId,\n addDraftId,\n removeDraftId,\n } = props\n const editState = useEditState(id, ``)\n const {isValidating, validation} = useValidationStatus(id, ``)\n const schema = useSchema()\n\n const validationHasErrors = useMemo(() => {\n return (\n !isValidating &&\n validation.length > 0 &&\n validation.some((item) => item.level === 'error')\n )\n }, [isValidating, validation])\n\n useEffect(() => {\n if (validationHasErrors) {\n addInvalidId(id)\n } else {\n removeInvalidId(id)\n }\n\n if (editState.draft) {\n addDraftId(id)\n } else {\n removeDraftId(id)\n }\n\n if (!isValidating) {\n onCheckComplete(id)\n }\n }, [\n addDraftId,\n addInvalidId,\n editState.draft,\n id,\n isValidating,\n onCheckComplete,\n removeDraftId,\n removeInvalidId,\n validationHasErrors,\n ])\n\n // We only care about drafts\n if (!editState.draft) {\n return null\n }\n\n const schemaType = schema.get(editState.draft._type)\n\n return (\n <Card\n border\n padding={2}\n tone={validationHasErrors ? `critical` : `positive`}\n >\n {editState.draft && schemaType ? (\n <Preview\n layout=\"default\"\n value={editState.draft}\n schemaType={schemaType}\n />\n ) : (\n <Spinner />\n )}\n </Card>\n )\n}\n","import {Box, type ButtonTone, Text, Tooltip} from '@sanity/ui'\nimport type {ComponentType, PropsWithChildren} from 'react'\nimport {TextWithTone} from 'sanity'\n\ntype InfoIconProps = PropsWithChildren & {\n icon: ComponentType\n tone: ButtonTone\n text?: string\n}\n\nexport default function InfoIcon(props: InfoIconProps) {\n const {text, icon, tone, children} = props\n const Icon = icon\n\n return (\n <Tooltip\n animate\n portal\n content={\n children ? (\n <>{children}</>\n ) : (\n <Box padding={2}>\n <Text size={1}>{text}</Text>\n </Box>\n )\n }\n >\n <TextWithTone tone={tone} size={1}>\n <Icon />\n </TextWithTone>\n </Tooltip>\n )\n}\n","import {InfoOutlineIcon} from '@sanity/icons'\nimport {Box, Stack, Text} from '@sanity/ui'\n\nimport InfoIcon from './InfoIcon'\n\nexport default function Info() {\n return (\n <InfoIcon icon={InfoOutlineIcon} tone=\"primary\">\n <Stack padding={3} space={4} style={{maxWidth: 250}}>\n <Box>\n <Text size={1}>Bulk publishing uses the Scheduling API.</Text>\n </Box>\n <Box>\n <Text size={1}>\n Customized Document Actions in the Studio will not execute. Webhooks\n will execute.\n </Text>\n </Box>\n <Box>\n <Text size={1}>\n Validation is checked before rendering the button below, but the\n Scheduling API will not check for – or enforce – validation.\n </Text>\n </Box>\n </Stack>\n </InfoIcon>\n )\n}\n","import {Button, Card, Dialog, Inline, Stack, Text, useToast} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport {TextWithTone, useClient, useWorkspace} from 'sanity'\n\nimport {API_VERSION} from '../../constants'\nimport type {TranslationReference} from '../../types'\nimport DocumentCheck from './DocumentCheck'\nimport Info from './Info'\n\nexport type BulkPublishProps = {\n translations: TranslationReference[]\n}\n\n// A root-level component with UI for hitting the Publishing API\nexport default function BulkPublish(props: BulkPublishProps) {\n const {translations} = props\n const client = useClient({apiVersion: API_VERSION})\n const {projectId, dataset} = useWorkspace()\n const toast = useToast()\n const [invalidIds, setInvalidIds] = useState<string[] | null>(null)\n const [checkedIds, setCheckedIds] = useState<string[]>([])\n\n const onCheckComplete = useCallback((id: string) => {\n setCheckedIds((ids) => Array.from(new Set([...ids, id])))\n }, [])\n\n // Handle dialog\n const [open, setOpen] = useState(false)\n const onOpen = useCallback(() => setOpen(true), [])\n const onClose = useCallback(() => setOpen(false), [])\n\n const addInvalidId = useCallback((id: string) => {\n setInvalidIds((ids) => (ids ? Array.from(new Set([...ids, id])) : [id]))\n }, [])\n\n const removeInvalidId = useCallback((id: string) => {\n setInvalidIds((ids) => (ids ? ids.filter((i) => i !== id) : []))\n }, [])\n\n const [draftIds, setDraftIds] = useState<string[]>([])\n\n const addDraftId = useCallback((id: string) => {\n setDraftIds((ids) => Array.from(new Set([...ids, id])))\n }, [])\n\n const removeDraftId = useCallback((id: string) => {\n setDraftIds((ids) => ids.filter((i) => i !== id))\n }, [])\n\n const handleBulkPublish = useCallback(() => {\n const body = translations.map((translation) => ({\n documentId: translation.value._ref,\n }))\n client\n .request({\n uri: `/publish/${projectId}/${dataset}`,\n method: 'POST',\n body,\n })\n .then(() => {\n toast.push({\n status: 'success',\n title: 'Success',\n description: 'Bulk publish complete',\n })\n })\n .catch((err) => {\n console.error(err)\n toast.push({\n status: 'error',\n title: 'Error',\n description: 'Bulk publish failed',\n })\n })\n }, [translations, client, projectId, dataset, toast])\n\n const disabled =\n // Not all documents have been checked\n checkedIds.length !== translations.length ||\n // Some document(s) are invalid\n Boolean(invalidIds && invalidIds?.length > 0) ||\n // No documents are drafts\n !draftIds.length\n\n return translations?.length > 0 ? (\n <Card padding={4} border radius={2}>\n <Stack space={3}>\n <Inline space={3}>\n <Text weight=\"bold\" size={1}>\n Bulk publishing\n </Text>\n <Info />\n </Inline>\n\n <Stack>\n <Button\n onClick={onOpen}\n text=\"Prepare bulk publishing\"\n mode=\"ghost\"\n />\n </Stack>\n\n {open && (\n <Dialog\n animate\n header=\"Bulk publishing\"\n id=\"bulk-publish-dialog\"\n onClose={onClose}\n zOffset={1000}\n width={3}\n >\n <Stack space={4} padding={4}>\n {draftIds.length > 0 ? (\n <Stack space={2}>\n <Text size={1}>\n There{' '}\n {draftIds.length === 1\n ? `is 1 draft document`\n : `are ${draftIds.length} draft documents`}\n .\n </Text>\n {invalidIds && invalidIds.length > 0 ? (\n <TextWithTone tone=\"critical\" size={1}>\n {invalidIds && invalidIds.length === 1\n ? `1 draft document has`\n : `${\n invalidIds && invalidIds.length\n } draft documents have`}{' '}\n validation issues that must addressed first\n </TextWithTone>\n ) : (\n <TextWithTone tone=\"positive\" size={1}>\n All drafts are valid and can be bulk published\n </TextWithTone>\n )}\n </Stack>\n ) : null}\n\n <Stack space={1}>\n {translations\n .filter((translation) => translation?.value?._ref)\n .map((translation) => (\n <DocumentCheck\n key={translation._key}\n id={translation.value._ref}\n onCheckComplete={onCheckComplete}\n addInvalidId={addInvalidId}\n removeInvalidId={removeInvalidId}\n addDraftId={addDraftId}\n removeDraftId={removeDraftId}\n />\n ))}\n </Stack>\n {draftIds.length > 0 ? (\n <Button\n mode=\"ghost\"\n tone={\n invalidIds && invalidIds?.length > 0\n ? 'caution'\n : 'positive'\n }\n text={\n draftIds.length === 1\n ? `Publish draft document`\n : `Bulk publish ${draftIds.length} draft documents`\n }\n onClick={handleBulkPublish}\n disabled={disabled}\n />\n ) : (\n <Text muted size={1}>\n No draft documents to publish\n </Text>\n )}\n </Stack>\n </Dialog>\n )}\n </Stack>\n </Card>\n ) : null\n}\n","import {useEffect} from 'react'\nimport {PatchEvent, unset, useClient, useEditState} from 'sanity'\nimport {useDocumentPane} from 'sanity/structure'\n\nimport {API_VERSION} from '../../constants'\nimport type {TranslationReference} from '../../types'\n\ntype ReferencePatcherProps = {\n translation: TranslationReference\n documentType: string\n metadataId: string\n}\n\n// For every reference, check if it is published, and if so, strengthen the reference\nexport default function ReferencePatcher(props: ReferencePatcherProps) {\n const {translation, documentType, metadataId} = props\n const editState = useEditState(translation.value._ref, documentType)\n const client = useClient({apiVersion: API_VERSION})\n const {onChange} = useDocumentPane()\n\n useEffect(() => {\n if (\n // We have a reference\n translation.value._ref &&\n // It's still weak and not-yet-strengthened\n translation.value._weak &&\n // We also want to keep this check because maybe the user *configured* weak refs\n translation.value._strengthenOnPublish &&\n // The referenced document has just been published\n !editState.draft &&\n editState.published &&\n editState.ready\n ) {\n const referencePathBase = [\n 'translations',\n {_key: translation._key},\n 'value',\n ]\n\n onChange(\n new PatchEvent([\n unset([...referencePathBase, '_weak']),\n unset([...referencePathBase, '_strengthenOnPublish']),\n ])\n )\n }\n }, [translation, editState, metadataId, client, onChange])\n\n return null\n}\n","import type {TranslationReference} from '../../types'\nimport ReferencePatcher from './ReferencePatcher'\n\ntype OptimisticallyStrengthenProps = {\n translations: TranslationReference[]\n metadataId: string\n}\n\n// There's no good reason to leave published references as weak\n// So this component will run on every render and strengthen them\nexport default function OptimisticallyStrengthen(\n props: OptimisticallyStrengthenProps\n) {\n const {translations = [], metadataId} = props\n\n if (!translations.length) {\n return null\n }\n\n return (\n <>\n {translations.map((translation) =>\n translation.value._strengthenOnPublish?.type ? (\n <ReferencePatcher\n key={translation._key}\n translation={translation}\n documentType={translation.value._strengthenOnPublish.type}\n metadataId={metadataId}\n />\n ) : null\n )}\n </>\n )\n}\n","import {TranslateIcon} from '@sanity/icons'\nimport {\n defineField,\n defineType,\n type DocumentDefinition,\n type FieldDefinition,\n} from 'sanity'\n\nimport {METADATA_SCHEMA_NAME, TRANSLATIONS_ARRAY_NAME} from '../../constants'\n\nexport default (\n schemaTypes: string[],\n metadataFields: FieldDefinition[]\n): DocumentDefinition =>\n defineType({\n type: 'document',\n name: METADATA_SCHEMA_NAME,\n title: 'Translation metadata',\n icon: TranslateIcon,\n liveEdit: true,\n fields: [\n defineField({\n name: TRANSLATIONS_ARRAY_NAME,\n type: 'internationalizedArrayReference',\n }),\n defineField({\n name: 'schemaTypes',\n description:\n 'Optional: Used to filter the reference fields above so all translations share the same types.',\n type: 'array',\n of: [{type: 'string'}],\n options: {list: schemaTypes},\n readOnly: ({value}) => Boolean(value),\n }),\n ...metadataFields,\n ],\n preview: {\n select: {\n translations: TRANSLATIONS_ARRAY_NAME,\n documentSchemaTypes: 'schemaTypes',\n },\n prepare(selection) {\n const {translations = [], documentSchemaTypes = []} = selection\n const title =\n translations.length === 1\n ? `1 Translation`\n : `${translations.length} Translations`\n const languageKeys = translations.length\n ? translations\n .map((t: {_key: string}) => t._key.toUpperCase())\n .join(', ')\n : ``\n const subtitle = [\n languageKeys ? `(${languageKeys})` : null,\n documentSchemaTypes?.length\n ? documentSchemaTypes.map((s: string) => s).join(`, `)\n : ``,\n ]\n .filter(Boolean)\n .join(` `)\n\n return {\n title,\n subtitle,\n }\n },\n },\n })\n","import {Stack} from '@sanity/ui'\nimport {defineField, definePlugin, isSanityDocument} from 'sanity'\nimport {internationalizedArray} from 'sanity-plugin-internationalized-array'\n\nimport {DeleteMetadataAction} from './actions/DeleteMetadataAction'\nimport {LanguageBadge} from './badges'\nimport BulkPublish from './components/BulkPublish'\nimport {DocumentInternationalizationProvider} from './components/DocumentInternationalizationContext'\nimport {DocumentInternationalizationMenu} from './components/DocumentInternationalizationMenu'\nimport OptimisticallyStrengthen from './components/OptimisticallyStrengthen'\nimport {API_VERSION, DEFAULT_CONFIG, METADATA_SCHEMA_NAME} from './constants'\nimport {documentInternationalizationUsEnglishLocaleBundle} from './i18n'\nimport metadata from './schema/translation/metadata'\nimport type {PluginConfig, TranslationReference} from './types'\n\nexport const documentInternationalization = definePlugin<PluginConfig>(\n (config) => {\n const pluginConfig = {...DEFAULT_CONFIG, ...config}\n const {\n supportedLanguages,\n schemaTypes,\n languageField,\n bulkPublish,\n metadataFields,\n } = pluginConfig\n\n if (schemaTypes.length === 0) {\n throw new Error(\n 'You must specify at least one schema type on which to enable document internationalization. Update the `schemaTypes` option in the documentInternationalization() configuration.'\n )\n }\n\n return {\n name: '@sanity/document-internationalization',\n\n studio: {\n components: {\n layout: (props) =>\n DocumentInternationalizationProvider({...props, pluginConfig}),\n },\n },\n\n i18n: {\n bundles: [documentInternationalizationUsEnglishLocaleBundle],\n },\n\n // Adds:\n // - A bulk-publishing UI component to the form\n // - Will only work for projects on a compatible plan\n form: {\n components: {\n input: (props) => {\n if (\n props.id === 'root' &&\n props.schemaType.name === METADATA_SCHEMA_NAME &&\n isSanityDocument(props?.value)\n ) {\n const metadataId = props?.value?._id\n const translations =\n (props?.value?.translations as TranslationReference[]) ?? []\n const weakAndTypedTranslations = translations.filter(\n ({value}) => value?._weak && value._strengthenOnPublish\n )\n\n return (\n <Stack space={5}>\n {bulkPublish ? (\n <BulkPublish translations={translations} />\n ) : null}\n {weakAndTypedTranslations.length > 0 ? (\n <OptimisticallyStrengthen\n metadataId={metadataId}\n translations={weakAndTypedTranslations}\n />\n ) : null}\n {props.renderDefault(props)}\n </Stack>\n )\n }\n\n return props.renderDefault(props)\n },\n },\n },\n\n // Adds:\n // - The `Translations` dropdown to the editing form\n // - `Badges` to documents with a language value\n // - The `DeleteMetadataAction` action to the metadata document type\n document: {\n unstable_languageFilter: (prev, ctx) => {\n const {schemaType, documentId} = ctx\n\n return schemaTypes.includes(schemaType) && documentId\n ? [\n ...prev,\n (props) =>\n DocumentInternationalizationMenu({...props, documentId}),\n ]\n : prev\n },\n badges: (prev, {schemaType}) => {\n if (!schemaTypes.includes(schemaType)) {\n return prev\n }\n\n return [(props) => LanguageBadge(props), ...prev]\n },\n actions: (prev, {schemaType}) => {\n if (schemaType === METADATA_SCHEMA_NAME) {\n return [...prev, DeleteMetadataAction]\n }\n\n return prev\n },\n },\n\n // Adds:\n // - The `Translations metadata` document type to the schema\n schema: {\n // Create the metadata document type\n types: [metadata(schemaTypes, metadataFields)],\n\n // For every schema type this plugin is enabled on\n // Create an initial value template to set the language\n templates: (prev, {schema}) => {\n // Templates are not setup for async languages\n if (!Array.isArray(supportedLanguages)) {\n return prev\n }\n\n const parameterizedTemplates = schemaTypes.map((schemaType) => ({\n id: `${schemaType}-parameterized`,\n title: `${\n schema?.get(schemaType)?.title ?? schemaType\n }: with Language`,\n schemaType,\n parameters: [\n {name: `languageId`, title: `Language ID`, type: `string`},\n ],\n value: ({languageId}: {languageId: string}) => ({\n [languageField]: languageId,\n }),\n }))\n\n const staticTemplates = schemaTypes.flatMap((schemaType) => {\n return supportedLanguages.map((language) => ({\n id: `${schemaType}-${language.id}`,\n title: `${language.title} ${\n schema?.get(schemaType)?.title ?? schemaType\n }`,\n schemaType,\n value: {\n [languageField]: language.id,\n },\n }))\n })\n\n return [...prev, ...parameterizedTemplates, ...staticTemplates]\n },\n },\n\n // Uses:\n // - `sanity-plugin-internationalized-array` to maintain the translations array\n plugins: [\n // Translation metadata stores its references using this plugin\n // It cuts down on attribute usage and gives UI conveniences to add new translations\n internationalizedArray({\n languages: supportedLanguages,\n fieldTypes: [\n defineField(\n {\n name: 'reference',\n type: 'reference',\n to: schemaTypes.map((type) => ({type})),\n weak: pluginConfig.weakReferences,\n // Reference filters don't actually enforce validation!\n validation: (Rule) =>\n // @ts-expect-error - fix typings\n Rule.custom(async (item: TranslationReference, context) => {\n if (!item?.value?._ref || !item?._key) {\n return true\n }\n\n const client = context.getClient({apiVersion: API_VERSION})\n const valueLanguage = await client.fetch(\n `*[_id in [$ref, $draftRef]][0].${languageField}`,\n {\n ref: item.value._ref,\n draftRef: `drafts.${item.value._ref}`,\n }\n )\n\n if (valueLanguage && valueLanguage === item._key) {\n return true\n }\n\n return `Referenced document does not have the correct language value`\n }),\n options: {\n // @ts-expect-error - Update type once it knows the values of this filter\n filter: ({parent, document}) => {\n if (!parent) return null\n\n // I'm not sure in what instance there's an array of parents\n // But the Type suggests it's possible\n const parentArray = Array.isArray(parent)\n ? parent\n : [parent]\n const language = parentArray.find((p) => p._key)\n\n if (!language?._key) return null\n\n if (document.schemaTypes) {\n return {\n filter: `_type in $schemaTypes && ${languageField} == $language`,\n params: {\n schemaTypes: document.schemaTypes,\n language: language._key,\n },\n }\n }\n\n return {\n filter: `${languageField} == $language`,\n params: {language: language._key},\n }\n },\n },\n },\n {strict: false}\n ),\n ],\n }),\n ],\n }\n }\n)\n"],"names":["query","config","entry","__spreadProps","__spreadValues","d","b","Subscription","Subscriber","ConsumerObserver","SafeSubscriber","OperatorSubscriber","err","dupeId","metadata","_a"],"mappings":";;;;;;;;;;;;AASA,SAAwB,gBAAgB,OAA6B;AAGnE,QAAM,aAFS,UAAA,EAEW,IAAI,MAAM,IAAI;AACxC,SAAK,aAIE,oBAAC,SAAQ,EAAA,OAAO,MAAM,OAAO,WAAwB,CAAA,IAHlD,oBAAA,UAAA,EAAS,MAAK,YAAW,OAAM,yBAAwB;AAInE;AChBO,MAAM,uBAAuB,wBACvB,0BAA0B,gBAC1B,cAAc,cACd,iBAAsC;AAAA,EACjD,oBAAoB,CAAC;AAAA,EACrB,aAAa,CAAC;AAAA,EACd,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,gBAAgB,CAAC;AAAA,EACjB,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,UAAU;AACZ;ACXgB,SAAA,mBAAmB,OAAgC,IAGjE;AACA,QAAM,e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QAAM,QAAA,KAAA;AACxB,6BAAA;AAIH,0BAAA,gBAAgB,MADP,QAAQ,UAAU,EAAC,YAAY,YAAY,CAAA,EACvB;AAAA,sBACjC,kCAAkC,aAAa;AAAA,sBAC/C;AAAA,wBACE,KAAK,KAAK,MAAM;AAAA,wBAChB,UAAU,UAAU,KAAK,MAAM,IAAI;AAAA,sBAAA;AAAA,oBAEvC;AAEA,2BAAI,iBAAiB,kBAAkB,KAAK,OACnC,KAGF;AAAA,kBACR,CAAA;AAAA;AAAA,gBACH,SAAS;AAAA;AAAA,kBAEP,QAAQ,CAAC,EAAC,QAAQ,eAAc;AAC9B,wBAAI,CAAC;AAAe,6BAAA;AAOpB,0BAAM,YAHc,MAAM,QAAQ,MAAM,IACpC,SACA,CAAC,MAAM,GACkB,KAAK,CAAC,MAAM,EAAE,IAAI;AAE1C,2BAAA,YAAA,QAAA,SAAU,OAEX,SAAS,cACJ;AAAA,sBACL,QAAQ,4BAA4B,aAAa;AAAA,sBACjD,QAAQ;AAAA,wBACN,aAAa,SAAS;AAAA,wBACtB,UAAU,SAAS;AAAA,sBAAA;AAAA,oBACrB,IAIG;AAAA,sBACL,QAAQ,GAAG,aAAa;AAAA,sBACxB,QAAQ,EAAC,UAAU,SAAS,KAAI;AAAA,oBAAA,IAdN;AAAA,kBAAA;AAAA,gBAgB9B;AAAA,cAEJ;AAAA,cACA,EAAC,QAAQ,GAAK;AAAA,YAAA;AAAA,UAChB;AAAA,QAEH,CAAA;AAAA,MAAA;AAAA,IAEL;AAAA,EAAA;AAEJ;","x_google_ignoreList":[5,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/components/DeleteTranslationDialog/DocumentPreview.tsx","../src/constants.ts","../src/components/DeleteTranslationDialog/separateReferences.ts","../src/components/DeleteTranslationDialog/index.tsx","../src/components/DeleteTranslationFooter.tsx","../node_modules/suspend-react/index.js","../src/components/DocumentInternationalizationContext.tsx","../src/actions/DeleteTranslationAction.tsx","../node_modules/tslib/tslib.es6.mjs","../node_modules/rxjs/dist/esm5/internal/util/isFunction.js","../node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js","../node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js","../node_modules/rxjs/dist/esm5/internal/util/arrRemove.js","../node_modules/rxjs/dist/esm5/internal/Subscription.js","../node_modules/rxjs/dist/esm5/internal/config.js","../node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js","../node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js","../node_modules/rxjs/dist/esm5/internal/util/noop.js","../node_modules/rxjs/dist/esm5/internal/Subscriber.js","../node_modules/rxjs/dist/esm5/internal/util/lift.js","../node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js","../node_modules/rxjs/dist/esm5/internal/util/EmptyError.js","../node_modules/rxjs/dist/esm5/internal/firstValueFrom.js","../node_modules/rxjs/dist/esm5/internal/operators/filter.js","../src/hooks/useLanguageMetadata.tsx","../src/i18n/index.ts","../src/actions/DuplicateWithTranslationsAction.tsx","../src/hooks/useOpenInNewPane.tsx","../src/utils/createReference.ts","../src/components/LanguageManage.tsx","../src/utils/excludePaths.ts","../src/components/LanguageOption.tsx","../src/components/LanguagePatch.tsx","../src/components/ConstrainedBox.tsx","../src/components/Warning.tsx","../src/components/DocumentInternationalizationMenu.tsx","../src/actions/DeleteMetadataAction.tsx","../src/badges/index.tsx","../src/components/BulkPublish/DocumentCheck.tsx","../src/components/BulkPublish/InfoIcon.tsx","../src/components/BulkPublish/Info.tsx","../src/components/BulkPublish/index.tsx","../src/components/OptimisticallyStrengthen/ReferencePatcher.tsx","../src/components/OptimisticallyStrengthen/index.tsx","../src/schema/translation/metadata.ts","../src/plugin.tsx"],"sourcesContent":["import {Preview, useSchema} from 'sanity'\nimport {Feedback} from 'sanity-plugin-utils'\n\ntype DocumentPreviewProps = {\n value: unknown\n type: string\n}\n\n// Wrapper of Preview just so that the schema type is satisfied by schema.get()\nexport default function DocumentPreview(props: DocumentPreviewProps) {\n const schema = useSchema()\n\n const schemaType = schema.get(props.type)\n if (!schemaType) {\n return <Feedback tone=\"critical\" title=\"Schema type not found\" />\n }\n\n return <Preview value={props.value} schemaType={schemaType} />\n}\n","import type {PluginConfigContext} from './types'\n\nexport const METADATA_SCHEMA_NAME = `translation.metadata`\nexport const TRANSLATIONS_ARRAY_NAME = `translations`\nexport const API_VERSION = `2025-02-19`\nexport const DEFAULT_CONFIG: PluginConfigContext = {\n supportedLanguages: [],\n schemaTypes: [],\n languageField: `language`,\n weakReferences: false,\n bulkPublish: false,\n metadataFields: [],\n apiVersion: API_VERSION,\n allowCreateMetaDoc: false,\n callback: null,\n}\n","import type {SanityDocument} from 'sanity'\n\nimport {METADATA_SCHEMA_NAME} from '../../constants'\n\nexport function separateReferences(data: SanityDocument[] | null = []): {\n translations: SanityDocument[]\n otherReferences: SanityDocument[]\n} {\n const translations: SanityDocument[] = []\n const otherReferences: SanityDocument[] = []\n\n if (data && data.length > 0) {\n data.forEach((doc) => {\n if (doc._type === METADATA_SCHEMA_NAME) {\n translations.push(doc)\n } else {\n otherReferences.push(doc)\n }\n })\n }\n\n return {translations, otherReferences}\n}\n","import {Card, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {useEffect, useMemo} from 'react'\nimport type {SanityDocument} from 'sanity'\nimport {useListeningQuery} from 'sanity-plugin-utils'\n\nimport DocumentPreview from './DocumentPreview'\nimport {separateReferences} from './separateReferences'\n\ntype DeleteTranslationDialogProps = {\n doc: SanityDocument\n documentId: string\n setTranslations: (translations: SanityDocument[]) => void\n}\n\nexport default function DeleteTranslationDialog(\n props: DeleteTranslationDialogProps\n) {\n const {doc, documentId, setTranslations} = props\n\n // Get all references and check if any of them are translations metadata\n const {data, loading} = useListeningQuery<SanityDocument[]>(\n `*[references($id)]{_id, _type}`,\n {params: {id: documentId}, initialValue: []}\n )\n const {translations, otherReferences} = useMemo(\n () => separateReferences(data),\n [data]\n )\n\n useEffect(() => {\n setTranslations(translations)\n }, [setTranslations, translations])\n\n if (loading) {\n return (\n <Flex padding={4} align=\"center\" justify=\"center\">\n <Spinner />\n </Flex>\n )\n }\n\n return (\n <Stack space={4}>\n {translations && translations.length > 0 ? (\n <Text>\n This document is a language-specific version which other translations\n depend on.\n </Text>\n ) : (\n <Text>This document does not have connected translations.</Text>\n )}\n <Card border padding={3}>\n <Stack space={4}>\n <Text size={1} weight=\"semibold\">\n {translations && translations.length > 0 ? (\n <>Before this document can be deleted</>\n ) : (\n <>This document can now be deleted</>\n )}\n </Text>\n <DocumentPreview value={doc} type={doc._type} />\n {translations && translations.length > 0 ? (\n <>\n <Card borderTop />\n <Text size={1} weight=\"semibold\">\n The reference in{' '}\n {translations.length === 1\n ? `this translations document`\n : `these translations documents`}{' '}\n must be removed\n </Text>\n {translations.map((translation) => (\n <DocumentPreview\n key={translation._id}\n value={translation}\n type={translation._type}\n />\n ))}\n </>\n ) : null}\n {otherReferences && otherReferences.length > 0 ? (\n <>\n <Card borderTop />\n <Text size={1} weight=\"semibold\">\n {otherReferences.length === 1\n ? `There is an additional reference`\n : `There are additional references`}{' '}\n to this document\n </Text>\n {otherReferences.map((reference) => (\n <DocumentPreview\n key={reference._id}\n value={reference}\n type={reference._type}\n />\n ))}\n </>\n ) : null}\n </Stack>\n </Card>\n {otherReferences.length === 0 ? (\n <Text>This document has no other references.</Text>\n ) : (\n <Text>\n You may not be able to delete this document because other documents\n refer to it.\n </Text>\n )}\n </Stack>\n )\n}\n","import {Button, Grid} from '@sanity/ui'\n\ntype DeleteTranslationFooterProps = {\n translations: unknown[]\n onClose: () => void\n onProceed: () => void\n}\n\nexport default function DeleteTranslationFooter(\n props: DeleteTranslationFooterProps\n) {\n const {translations, onClose, onProceed} = props\n\n return (\n <Grid columns={2} gap={2}>\n <Button text=\"Cancel\" onClick={onClose} mode=\"ghost\" />\n <Button\n text={\n translations && translations.length > 0\n ? `Unset translation reference`\n : `Delete document`\n }\n onClick={onProceed}\n tone=\"critical\"\n />\n </Grid>\n )\n}\n","const isPromise = promise => typeof promise === 'object' && typeof promise.then === 'function';\n\nconst globalCache = [];\n\nfunction shallowEqualArrays(arrA, arrB, equal = (a, b) => a === b) {\n if (arrA === arrB) return true;\n if (!arrA || !arrB) return false;\n const len = arrA.length;\n if (arrB.length !== len) return false;\n\n for (let i = 0; i < len; i++) if (!equal(arrA[i], arrB[i])) return false;\n\n return true;\n}\n\nfunction query(fn, keys = null, preload = false, config = {}) {\n // If no keys were given, the function is the key\n if (keys === null) keys = [fn];\n\n for (const entry of globalCache) {\n // Find a match\n if (shallowEqualArrays(keys, entry.keys, entry.equal)) {\n // If we're pre-loading and the element is present, just return\n if (preload) return undefined; // If an error occurred, throw\n\n if (Object.prototype.hasOwnProperty.call(entry, 'error')) throw entry.error; // If a response was successful, return\n\n if (Object.prototype.hasOwnProperty.call(entry, 'response')) {\n if (config.lifespan && config.lifespan > 0) {\n if (entry.timeout) clearTimeout(entry.timeout);\n entry.timeout = setTimeout(entry.remove, config.lifespan);\n }\n\n return entry.response;\n } // If the promise is still unresolved, throw\n\n\n if (!preload) throw entry.promise;\n }\n } // The request is new or has changed.\n\n\n const entry = {\n keys,\n equal: config.equal,\n remove: () => {\n const index = globalCache.indexOf(entry);\n if (index !== -1) globalCache.splice(index, 1);\n },\n promise: // Execute the promise\n (isPromise(fn) ? fn : fn(...keys) // When it resolves, store its value\n ).then(response => {\n entry.response = response; // Remove the entry in time if a lifespan was given\n\n if (config.lifespan && config.lifespan > 0) {\n entry.timeout = setTimeout(entry.remove, config.lifespan);\n }\n }) // Store caught errors, they will be thrown in the render-phase to bubble into an error-bound\n .catch(error => entry.error = error)\n }; // Register the entry\n\n globalCache.push(entry); // And throw the promise, this yields control back to React\n\n if (!preload) throw entry.promise;\n return undefined;\n}\n\nconst suspend = (fn, keys, config) => query(fn, keys, false, config);\n\nconst preload = (fn, keys, config) => void query(fn, keys, true, config);\n\nconst peek = keys => {\n var _globalCache$find;\n\n return (_globalCache$find = globalCache.find(entry => shallowEqualArrays(keys, entry.keys, entry.equal))) == null ? void 0 : _globalCache$find.response;\n};\n\nconst clear = keys => {\n if (keys === undefined || keys.length === 0) globalCache.splice(0, globalCache.length);else {\n const entry = globalCache.find(entry => shallowEqualArrays(keys, entry.keys, entry.equal));\n if (entry) entry.remove();\n }\n};\n\nexport { clear, peek, preload, suspend };\n","import {useContext} from 'react'\nimport {createContext} from 'react'\nimport {type LayoutProps, useClient, useWorkspace} from 'sanity'\nimport {suspend} from 'suspend-react'\n\nimport {DEFAULT_CONFIG} from '../constants'\nimport type {PluginConfig, PluginConfigContext} from '../types'\n\nconst DocumentInternationalizationContext =\n createContext<PluginConfigContext>(DEFAULT_CONFIG)\n\nexport function useDocumentInternationalizationContext() {\n return useContext(DocumentInternationalizationContext)\n}\n\ntype DocumentInternationalizationProviderProps = LayoutProps & {\n pluginConfig: Required<PluginConfig>\n}\n\n/**\n * This Provider wraps the Studio and provides the DocumentInternationalization context to document actions and components.\n */\nexport function DocumentInternationalizationProvider(\n props: DocumentInternationalizationProviderProps\n) {\n const {pluginConfig} = props\n\n const client = useClient({apiVersion: pluginConfig.apiVersion})\n const workspace = useWorkspace()\n const supportedLanguages = Array.isArray(pluginConfig.supportedLanguages)\n ? pluginConfig.supportedLanguages\n : // eslint-disable-next-line require-await\n suspend(async () => {\n if (typeof pluginConfig.supportedLanguages === 'function') {\n return pluginConfig.supportedLanguages(client)\n }\n return pluginConfig.supportedLanguages\n }, [workspace])\n\n return (\n <DocumentInternationalizationContext.Provider\n value={{...pluginConfig, supportedLanguages}}\n >\n {props.renderDefault(props)}\n </DocumentInternationalizationContext.Provider>\n )\n}\n","import {TrashIcon} from '@sanity/icons'\nimport {type ButtonTone, useToast} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport {\n type DocumentActionComponent,\n type SanityDocument,\n useClient,\n} from 'sanity'\n\nimport DeleteTranslationDialog from '../components/DeleteTranslationDialog'\nimport DeleteTranslationFooter from '../components/DeleteTranslationFooter'\nimport {useDocumentInternationalizationContext} from '../components/DocumentInternationalizationContext'\nimport {API_VERSION, TRANSLATIONS_ARRAY_NAME} from '../constants'\n\nexport const DeleteTranslationAction: DocumentActionComponent = (props) => {\n const {id: documentId, published, draft} = props\n const doc = draft || published\n const {languageField} = useDocumentInternationalizationContext()\n\n const [isDialogOpen, setDialogOpen] = useState(false)\n const [translations, setTranslations] = useState<SanityDocument[]>([])\n const onClose = useCallback(() => setDialogOpen(false), [])\n const documentLanguage = doc ? doc[languageField] : null\n\n const toast = useToast()\n const client = useClient({apiVersion: API_VERSION})\n\n // Remove translation reference and delete document in one transaction\n const onProceed = useCallback(() => {\n const tx = client.transaction()\n let operation = 'DELETE'\n\n if (documentLanguage && translations.length > 0) {\n operation = 'UNSET'\n translations.forEach((translation) => {\n tx.patch(translation._id, (patch) =>\n patch.unset([\n `${TRANSLATIONS_ARRAY_NAME}[_key == \"${documentLanguage}\"]`,\n ])\n )\n })\n } else {\n tx.delete(documentId)\n tx.delete(`drafts.${documentId}`)\n }\n\n tx.commit()\n .then(() => {\n if (operation === 'DELETE') {\n onClose()\n }\n toast.push({\n status: 'success',\n title:\n operation === 'UNSET'\n ? 'Translation reference unset'\n : 'Document deleted',\n description:\n operation === 'UNSET' ? 'The document can now be deleted' : null,\n })\n })\n .catch((err) => {\n toast.push({\n status: 'error',\n title:\n operation === 'unset'\n ? 'Failed to unset translation reference'\n : 'Failed to delete document',\n description: err.message,\n })\n })\n }, [client, documentLanguage, translations, documentId, onClose, toast])\n\n return {\n label: `Delete translation...`,\n disabled: !doc || !documentLanguage,\n icon: TrashIcon,\n tone: 'critical' as ButtonTone,\n onHandle: () => {\n setDialogOpen(true)\n },\n dialog: isDialogOpen && {\n type: 'dialog',\n onClose,\n header: 'Delete translation',\n content: doc ? (\n <DeleteTranslationDialog\n doc={doc}\n documentId={documentId}\n setTranslations={setTranslations}\n />\n ) : null,\n footer: (\n <DeleteTranslationFooter\n onClose={onClose}\n onProceed={onProceed}\n translations={translations}\n />\n ),\n },\n }\n}\n","/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n function next() {\n while (env.stack.length) {\n var rec = env.stack.pop();\n try {\n var result = rec.dispose && rec.dispose.call(rec.value);\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n catch (e) {\n fail(e);\n }\n }\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n};\n","export function isFunction(value) {\n return typeof value === 'function';\n}\n//# sourceMappingURL=isFunction.js.map","export function createErrorClass(createImpl) {\n var _super = function (instance) {\n Error.call(instance);\n instance.stack = new Error().stack;\n };\n var ctorFunc = createImpl(_super);\n ctorFunc.prototype = Object.create(Error.prototype);\n ctorFunc.prototype.constructor = ctorFunc;\n return ctorFunc;\n}\n//# sourceMappingURL=createErrorClass.js.map","import { createErrorClass } from './createErrorClass';\nexport var UnsubscriptionError = createErrorClass(function (_super) {\n return function UnsubscriptionErrorImpl(errors) {\n _super(this);\n this.message = errors\n ? errors.length + \" errors occurred during unsubscription:\\n\" + errors.map(function (err, i) { return i + 1 + \") \" + err.toString(); }).join('\\n ')\n : '';\n this.name = 'UnsubscriptionError';\n this.errors = errors;\n };\n});\n//# sourceMappingURL=UnsubscriptionError.js.map","export function arrRemove(arr, item) {\n if (arr) {\n var index = arr.indexOf(item);\n 0 <= index && arr.splice(index, 1);\n }\n}\n//# sourceMappingURL=arrRemove.js.map","import { __read, __spreadArray, __values } from \"tslib\";\nimport { isFunction } from './util/isFunction';\nimport { UnsubscriptionError } from './util/UnsubscriptionError';\nimport { arrRemove } from './util/arrRemove';\nvar Subscription = (function () {\n function Subscription(initialTeardown) {\n this.initialTeardown = initialTeardown;\n this.closed = false;\n this._parentage = null;\n this._finalizers = null;\n }\n Subscription.prototype.unsubscribe = function () {\n var e_1, _a, e_2, _b;\n var errors;\n if (!this.closed) {\n this.closed = true;\n var _parentage = this._parentage;\n if (_parentage) {\n this._parentage = null;\n if (Array.isArray(_parentage)) {\n try {\n for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {\n var parent_1 = _parentage_1_1.value;\n parent_1.remove(this);\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);\n }\n finally { if (e_1) throw e_1.error; }\n }\n }\n else {\n _parentage.remove(this);\n }\n }\n var initialFinalizer = this.initialTeardown;\n if (isFunction(initialFinalizer)) {\n try {\n initialFinalizer();\n }\n catch (e) {\n errors = e instanceof UnsubscriptionError ? e.errors : [e];\n }\n }\n var _finalizers = this._finalizers;\n if (_finalizers) {\n this._finalizers = null;\n try {\n for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {\n var finalizer = _finalizers_1_1.value;\n try {\n execFinalizer(finalizer);\n }\n catch (err) {\n errors = errors !== null && errors !== void 0 ? errors : [];\n if (err instanceof UnsubscriptionError) {\n errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));\n }\n else {\n errors.push(err);\n }\n }\n }\n }\n catch (e_2_1) { e_2 = { error: e_2_1 }; }\n finally {\n try {\n if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);\n }\n finally { if (e_2) throw e_2.error; }\n }\n }\n if (errors) {\n throw new UnsubscriptionError(errors);\n }\n }\n };\n Subscription.prototype.add = function (teardown) {\n var _a;\n if (teardown && teardown !== this) {\n if (this.closed) {\n execFinalizer(teardown);\n }\n else {\n if (teardown instanceof Subscription) {\n if (teardown.closed || teardown._hasParent(this)) {\n return;\n }\n teardown._addParent(this);\n }\n (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);\n }\n }\n };\n Subscription.prototype._hasParent = function (parent) {\n var _parentage = this._parentage;\n return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));\n };\n Subscription.prototype._addParent = function (parent) {\n var _parentage = this._parentage;\n this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;\n };\n Subscription.prototype._removeParent = function (parent) {\n var _parentage = this._parentage;\n if (_parentage === parent) {\n this._parentage = null;\n }\n else if (Array.isArray(_parentage)) {\n arrRemove(_parentage, parent);\n }\n };\n Subscription.prototype.remove = function (teardown) {\n var _finalizers = this._finalizers;\n _finalizers && arrRemove(_finalizers, teardown);\n if (teardown instanceof Subscription) {\n teardown._removeParent(this);\n }\n };\n Subscription.EMPTY = (function () {\n var empty = new Subscription();\n empty.closed = true;\n return empty;\n })();\n return Subscription;\n}());\nexport { Subscription };\nexport var EMPTY_SUBSCRIPTION = Subscription.EMPTY;\nexport function isSubscription(value) {\n return (value instanceof Subscription ||\n (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));\n}\nfunction execFinalizer(finalizer) {\n if (isFunction(finalizer)) {\n finalizer();\n }\n else {\n finalizer.unsubscribe();\n }\n}\n//# sourceMappingURL=Subscription.js.map","export var config = {\n onUnhandledError: null,\n onStoppedNotification: null,\n Promise: undefined,\n useDeprecatedSynchronousErrorHandling: false,\n useDeprecatedNextContext: false,\n};\n//# sourceMappingURL=config.js.map","import { __read, __spreadArray } from \"tslib\";\nexport var timeoutProvider = {\n setTimeout: function (handler, timeout) {\n var args = [];\n for (var _i = 2; _i < arguments.length; _i++) {\n args[_i - 2] = arguments[_i];\n }\n var delegate = timeoutProvider.delegate;\n if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {\n return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));\n }\n return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));\n },\n clearTimeout: function (handle) {\n var delegate = timeoutProvider.delegate;\n return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);\n },\n delegate: undefined,\n};\n//# sourceMappingURL=timeoutProvider.js.map","import { config } from '../config';\nimport { timeoutProvider } from '../scheduler/timeoutProvider';\nexport function reportUnhandledError(err) {\n timeoutProvider.setTimeout(function () {\n var onUnhandledError = config.onUnhandledError;\n if (onUnhandledError) {\n onUnhandledError(err);\n }\n else {\n throw err;\n }\n });\n}\n//# sourceMappingURL=reportUnhandledError.js.map","export function noop() { }\n//# sourceMappingURL=noop.js.map","import { __extends } from \"tslib\";\nimport { isFunction } from './util/isFunction';\nimport { isSubscription, Subscription } from './Subscription';\nimport { config } from './config';\nimport { reportUnhandledError } from './util/reportUnhandledError';\nimport { noop } from './util/noop';\nimport { nextNotification, errorNotification, COMPLETE_NOTIFICATION } from './NotificationFactories';\nimport { timeoutProvider } from './scheduler/timeoutProvider';\nimport { captureError } from './util/errorContext';\nvar Subscriber = (function (_super) {\n __extends(Subscriber, _super);\n function Subscriber(destination) {\n var _this = _super.call(this) || this;\n _this.isStopped = false;\n if (destination) {\n _this.destination = destination;\n if (isSubscription(destination)) {\n destination.add(_this);\n }\n }\n else {\n _this.destination = EMPTY_OBSERVER;\n }\n return _this;\n }\n Subscriber.create = function (next, error, complete) {\n return new SafeSubscriber(next, error, complete);\n };\n Subscriber.prototype.next = function (value) {\n if (this.isStopped) {\n handleStoppedNotification(nextNotification(value), this);\n }\n else {\n this._next(value);\n }\n };\n Subscriber.prototype.error = function (err) {\n if (this.isStopped) {\n handleStoppedNotification(errorNotification(err), this);\n }\n else {\n this.isStopped = true;\n this._error(err);\n }\n };\n Subscriber.prototype.complete = function () {\n if (this.isStopped) {\n handleStoppedNotification(COMPLETE_NOTIFICATION, this);\n }\n else {\n this.isStopped = true;\n this._complete();\n }\n };\n Subscriber.prototype.unsubscribe = function () {\n if (!this.closed) {\n this.isStopped = true;\n _super.prototype.unsubscribe.call(this);\n this.destination = null;\n }\n };\n Subscriber.prototype._next = function (value) {\n this.destination.next(value);\n };\n Subscriber.prototype._error = function (err) {\n try {\n this.destination.error(err);\n }\n finally {\n this.unsubscribe();\n }\n };\n Subscriber.prototype._complete = function () {\n try {\n this.destination.complete();\n }\n finally {\n this.unsubscribe();\n }\n };\n return Subscriber;\n}(Subscription));\nexport { Subscriber };\nvar _bind = Function.prototype.bind;\nfunction bind(fn, thisArg) {\n return _bind.call(fn, thisArg);\n}\nvar ConsumerObserver = (function () {\n function ConsumerObserver(partialObserver) {\n this.partialObserver = partialObserver;\n }\n ConsumerObserver.prototype.next = function (value) {\n var partialObserver = this.partialObserver;\n if (partialObserver.next) {\n try {\n partialObserver.next(value);\n }\n catch (error) {\n handleUnhandledError(error);\n }\n }\n };\n ConsumerObserver.prototype.error = function (err) {\n var partialObserver = this.partialObserver;\n if (partialObserver.error) {\n try {\n partialObserver.error(err);\n }\n catch (error) {\n handleUnhandledError(error);\n }\n }\n else {\n handleUnhandledError(err);\n }\n };\n ConsumerObserver.prototype.complete = function () {\n var partialObserver = this.partialObserver;\n if (partialObserver.complete) {\n try {\n partialObserver.complete();\n }\n catch (error) {\n handleUnhandledError(error);\n }\n }\n };\n return ConsumerObserver;\n}());\nvar SafeSubscriber = (function (_super) {\n __extends(SafeSubscriber, _super);\n function SafeSubscriber(observerOrNext, error, complete) {\n var _this = _super.call(this) || this;\n var partialObserver;\n if (isFunction(observerOrNext) || !observerOrNext) {\n partialObserver = {\n next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),\n error: error !== null && error !== void 0 ? error : undefined,\n complete: complete !== null && complete !== void 0 ? complete : undefined,\n };\n }\n else {\n var context_1;\n if (_this && config.useDeprecatedNextContext) {\n context_1 = Object.create(observerOrNext);\n context_1.unsubscribe = function () { return _this.unsubscribe(); };\n partialObserver = {\n next: observerOrNext.next && bind(observerOrNext.next, context_1),\n error: observerOrNext.error && bind(observerOrNext.error, context_1),\n complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),\n };\n }\n else {\n partialObserver = observerOrNext;\n }\n }\n _this.destination = new ConsumerObserver(partialObserver);\n return _this;\n }\n return SafeSubscriber;\n}(Subscriber));\nexport { SafeSubscriber };\nfunction handleUnhandledError(error) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n captureError(error);\n }\n else {\n reportUnhandledError(error);\n }\n}\nfunction defaultErrorHandler(err) {\n throw err;\n}\nfunction handleStoppedNotification(notification, subscriber) {\n var onStoppedNotification = config.onStoppedNotification;\n onStoppedNotification && timeoutProvider.setTimeout(function () { return onStoppedNotification(notification, subscriber); });\n}\nexport var EMPTY_OBSERVER = {\n closed: true,\n next: noop,\n error: defaultErrorHandler,\n complete: noop,\n};\n//# sourceMappingURL=Subscriber.js.map","import { isFunction } from './isFunction';\nexport function hasLift(source) {\n return isFunction(source === null || source === void 0 ? void 0 : source.lift);\n}\nexport function operate(init) {\n return function (source) {\n if (hasLift(source)) {\n return source.lift(function (liftedSource) {\n try {\n return init(liftedSource, this);\n }\n catch (err) {\n this.error(err);\n }\n });\n }\n throw new TypeError('Unable to lift unknown Observable type');\n };\n}\n//# sourceMappingURL=lift.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {\n return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);\n}\nvar OperatorSubscriber = (function (_super) {\n __extends(OperatorSubscriber, _super);\n function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {\n var _this = _super.call(this, destination) || this;\n _this.onFinalize = onFinalize;\n _this.shouldUnsubscribe = shouldUnsubscribe;\n _this._next = onNext\n ? function (value) {\n try {\n onNext(value);\n }\n catch (err) {\n destination.error(err);\n }\n }\n : _super.prototype._next;\n _this._error = onError\n ? function (err) {\n try {\n onError(err);\n }\n catch (err) {\n destination.error(err);\n }\n finally {\n this.unsubscribe();\n }\n }\n : _super.prototype._error;\n _this._complete = onComplete\n ? function () {\n try {\n onComplete();\n }\n catch (err) {\n destination.error(err);\n }\n finally {\n this.unsubscribe();\n }\n }\n : _super.prototype._complete;\n return _this;\n }\n OperatorSubscriber.prototype.unsubscribe = function () {\n var _a;\n if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {\n var closed_1 = this.closed;\n _super.prototype.unsubscribe.call(this);\n !closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));\n }\n };\n return OperatorSubscriber;\n}(Subscriber));\nexport { OperatorSubscriber };\n//# sourceMappingURL=OperatorSubscriber.js.map","import { createErrorClass } from './createErrorClass';\nexport var EmptyError = createErrorClass(function (_super) { return function EmptyErrorImpl() {\n _super(this);\n this.name = 'EmptyError';\n this.message = 'no elements in sequence';\n}; });\n//# sourceMappingURL=EmptyError.js.map","import { EmptyError } from './util/EmptyError';\nimport { SafeSubscriber } from './Subscriber';\nexport function firstValueFrom(source, config) {\n var hasConfig = typeof config === 'object';\n return new Promise(function (resolve, reject) {\n var subscriber = new SafeSubscriber({\n next: function (value) {\n resolve(value);\n subscriber.unsubscribe();\n },\n error: reject,\n complete: function () {\n if (hasConfig) {\n resolve(config.defaultValue);\n }\n else {\n reject(new EmptyError());\n }\n },\n });\n source.subscribe(subscriber);\n });\n}\n//# sourceMappingURL=firstValueFrom.js.map","import { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function filter(predicate, thisArg) {\n return operate(function (source, subscriber) {\n var index = 0;\n source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));\n });\n}\n//# sourceMappingURL=filter.js.map","import {useListeningQuery} from 'sanity-plugin-utils'\n\nimport {METADATA_SCHEMA_NAME} from '../constants'\nimport type {Metadata} from '../types'\n\n// Using references() seemed less reliable for updating the listener\n// results than querying raw values in the array\n// AFAIK: references is _faster_ when querying with GROQ\n// const query = `*[_type == $translationSchema && references($id)]`\nconst query = `*[_type == $translationSchema && $id in translations[].value._ref]{\n _id,\n _createdAt,\n translations\n}`\n\nexport function useTranslationMetadata(id: string): {\n data: Metadata[] | null\n loading: boolean\n error: boolean | unknown | ProgressEvent\n} {\n const {data, loading, error} = useListeningQuery<Metadata[]>(query, {\n params: {id, translationSchema: METADATA_SCHEMA_NAME},\n })\n\n return {data, loading, error}\n}\n","import {defineLocaleResourceBundle} from 'sanity'\n\n/**\n * The locale namespace for the document internationalization plugin.\n *\n * @public\n */\nexport const documenti18nLocaleNamespace =\n 'document-internationalization' as const\n\n/**\n * The default locale bundle for the document internationalization plugin, which is US English.\n *\n * @internal\n */\nexport const documentInternationalizationUsEnglishLocaleBundle =\n defineLocaleResourceBundle({\n locale: 'en-US',\n namespace: documenti18nLocaleNamespace,\n resources: () => import('./resources'),\n })\n","import {CopyIcon} from '@sanity/icons'\nimport {useToast} from '@sanity/ui'\nimport {uuid} from '@sanity/uuid'\nimport {useCallback, useMemo, useState} from 'react'\nimport {filter, firstValueFrom} from 'rxjs'\nimport {\n DEFAULT_STUDIO_CLIENT_OPTIONS,\n type DocumentActionComponent,\n type Id,\n InsufficientPermissionsMessage,\n type PatchOperations,\n useClient,\n useCurrentUser,\n useDocumentOperation,\n useDocumentPairPermissions,\n useDocumentStore,\n useTranslation,\n} from 'sanity'\nimport {useRouter} from 'sanity/router'\nimport {structureLocaleNamespace} from 'sanity/structure'\n\nimport {METADATA_SCHEMA_NAME, TRANSLATIONS_ARRAY_NAME} from '../constants'\nimport {useTranslationMetadata} from '../hooks/useLanguageMetadata'\nimport {documenti18nLocaleNamespace} from '../i18n'\n\nconst DISABLED_REASON_KEY = {\n METADATA_NOT_FOUND: 'action.duplicate.disabled.missing-metadata',\n MULTIPLE_METADATA: 'action.duplicate.disabled.multiple-metadata',\n NOTHING_TO_DUPLICATE: 'action.duplicate.disabled.nothing-to-duplicate',\n NOT_READY: 'action.duplicate.disabled.not-ready',\n}\n\nexport const DuplicateWithTranslationsAction: DocumentActionComponent = ({\n id,\n type,\n onComplete,\n}) => {\n const documentStore = useDocumentStore()\n const {duplicate} = useDocumentOperation(id, type)\n const {navigateIntent} = useRouter()\n const [isDuplicating, setDuplicating] = useState(false)\n const [permissions, isPermissionsLoading] = useDocumentPairPermissions({\n id,\n type,\n permission: 'duplicate',\n })\n const {data, loading: isMetadataDocumentLoading} = useTranslationMetadata(id)\n const hasOneMetadataDocument = useMemo(() => {\n return Array.isArray(data) && data.length <= 1\n }, [data])\n const metadataDocument = Array.isArray(data) && data.length ? data[0] : null\n const client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS)\n const toast = useToast()\n const {t: s} = useTranslation(structureLocaleNamespace)\n const {t: d} = useTranslation(documenti18nLocaleNamespace)\n const currentUser = useCurrentUser()\n\n const handle = useCallback(async () => {\n setDuplicating(true)\n\n try {\n if (!metadataDocument) {\n throw new Error('Metadata document not found')\n }\n\n // 1. Duplicate the document and its localized versions\n const translations = new Map<string, Id>()\n await Promise.all(\n metadataDocument[TRANSLATIONS_ARRAY_NAME].map(async (translation) => {\n const dupeId = uuid()\n const locale = translation._key\n const docId = translation.value?._ref\n\n if (!docId) {\n throw new Error('Translation document not found')\n }\n\n const {duplicate: duplicateTranslation} = await firstValueFrom(\n documentStore.pair\n .editOperations(docId, type)\n .pipe(filter((op) => op.duplicate.disabled !== 'NOT_READY'))\n )\n\n if (duplicateTranslation.disabled) {\n throw new Error('Cannot duplicate document')\n }\n\n const duplicateTranslationSuccess = firstValueFrom(\n documentStore.pair\n .operationEvents(docId, type)\n .pipe(filter((e) => e.op === 'duplicate' && e.type === 'success'))\n )\n duplicateTranslation.execute(dupeId)\n await duplicateTranslationSuccess\n\n translations.set(locale, dupeId)\n })\n )\n\n // 2. Duplicate the metadata document\n const {duplicate: duplicateMetadata} = await firstValueFrom(\n documentStore.pair\n .editOperations(metadataDocument._id, METADATA_SCHEMA_NAME)\n .pipe(filter((op) => op.duplicate.disabled !== 'NOT_READY'))\n )\n\n if (duplicateMetadata.disabled) {\n throw new Error('Cannot duplicate document')\n }\n\n const duplicateMetadataSuccess = firstValueFrom(\n documentStore.pair\n .operationEvents(metadataDocument._id, METADATA_SCHEMA_NAME)\n .pipe(filter((e) => e.op === 'duplicate' && e.type === 'success'))\n )\n const dupeId = uuid()\n duplicateMetadata.execute(dupeId)\n await duplicateMetadataSuccess\n\n // 3. Patch the duplicated metadata document to update the references\n // TODO: use document store\n // const {patch: patchMetadata} = await firstValueFrom(\n // documentStore.pair\n // .editOperations(dupeId, METADATA_SCHEMA_NAME)\n // .pipe(filter((op) => op.patch.disabled !== 'NOT_READY'))\n // )\n\n // if (patchMetadata.disabled) {\n // throw new Error('Cannot patch document')\n // }\n\n // await firstValueFrom(\n // documentStore.pair\n // .consistencyStatus(dupeId, METADATA_SCHEMA_NAME)\n // .pipe(filter((isConsistant) => isConsistant))\n // )\n\n // const patchMetadataSuccess = firstValueFrom(\n // documentStore.pair\n // .operationEvents(dupeId, METADATA_SCHEMA_NAME)\n // .pipe(filter((e) => e.op === 'patch' && e.type === 'success'))\n // )\n\n const patch: PatchOperations = {\n set: Object.fromEntries(\n Array.from(translations.entries()).map(([locale, documentId]) => [\n `${TRANSLATIONS_ARRAY_NAME}[_key == \"${locale}\"].value._ref`,\n documentId,\n ])\n ),\n }\n\n // patchMetadata.execute([patch])\n // await patchMetadataSuccess\n await client.transaction().patch(dupeId, patch).commit()\n\n // 4. Navigate to the duplicated document\n navigateIntent('edit', {\n id: Array.from(translations.values()).at(0),\n type,\n })\n\n onComplete()\n } catch (error) {\n console.error(error)\n toast.push({\n status: 'error',\n title: 'Error duplicating document',\n description:\n error instanceof Error\n ? error.message\n : 'Failed to duplicate document',\n })\n } finally {\n setDuplicating(false)\n }\n }, [\n client,\n documentStore.pair,\n metadataDocument,\n navigateIntent,\n onComplete,\n toast,\n type,\n ])\n\n return useMemo(() => {\n if (!isPermissionsLoading && !permissions?.granted) {\n return {\n icon: CopyIcon,\n disabled: true,\n label: d('action.duplicate.label'),\n title: (\n <InsufficientPermissionsMessage\n context=\"duplicate-document\"\n currentUser={currentUser}\n />\n ),\n }\n }\n\n if (!isMetadataDocumentLoading && !metadataDocument) {\n return {\n icon: CopyIcon,\n disabled: true,\n label: d('action.duplicate.label'),\n title: d(DISABLED_REASON_KEY.METADATA_NOT_FOUND),\n }\n }\n\n if (!hasOneMetadataDocument) {\n return {\n icon: CopyIcon,\n disabled: true,\n label: d('action.duplicate.label'),\n title: d(DISABLED_REASON_KEY.MULTIPLE_METADATA),\n }\n }\n\n return {\n icon: CopyIcon,\n disabled:\n isDuplicating ||\n Boolean(duplicate.disabled) ||\n isPermissionsLoading ||\n isMetadataDocumentLoading,\n label: isDuplicating\n ? s('action.duplicate.running.label')\n : d('action.duplicate.label'),\n title: duplicate.disabled\n ? s(DISABLED_REASON_KEY[duplicate.disabled])\n : '',\n onHandle: handle,\n }\n }, [\n currentUser,\n duplicate.disabled,\n handle,\n hasOneMetadataDocument,\n isDuplicating,\n isMetadataDocumentLoading,\n isPermissionsLoading,\n metadataDocument,\n permissions?.granted,\n s,\n d,\n ])\n}\n\nDuplicateWithTranslationsAction.action = 'duplicate'\n// @ts-expect-error `displayName` is used by React DevTools\nDuplicateWithTranslationsAction.displayName = 'DuplicateWithTranslationsAction'\n","import {useCallback, useContext} from 'react'\nimport {RouterContext} from 'sanity/router'\nimport {usePaneRouter} from 'sanity/structure'\n\nexport function useOpenInNewPane(id?: string | null, type?: string) {\n const routerContext = useContext(RouterContext)\n const {routerPanesState, groupIndex} = usePaneRouter()\n\n const openInNewPane = useCallback(() => {\n if (!routerContext || !id || !type) {\n return\n }\n\n // No panes open, function might be called outside Structure\n if (!routerPanesState.length) {\n routerContext.navigateIntent('edit', {id, type})\n return\n }\n\n const panes = [...routerPanesState]\n panes.splice(groupIndex + 1, 0, [\n {\n id: id,\n params: {type},\n },\n ])\n\n const href = routerContext.resolvePathFromState({panes})\n routerContext.navigateUrl({path: href})\n }, [id, type, routerContext, routerPanesState, groupIndex])\n\n return openInNewPane\n}\n","import type {TranslationReference} from '../types'\n\nexport function createReference(\n key: string,\n ref: string,\n type: string,\n strengthenOnPublish: boolean = true\n): TranslationReference {\n return {\n _key: key,\n _type: 'internationalizedArrayReferenceValue',\n value: {\n _type: 'reference',\n _ref: ref,\n _weak: true,\n // If the user has configured weakReferences, we won't want to strengthen them\n ...(strengthenOnPublish ? {_strengthenOnPublish: {type}} : {}),\n },\n }\n}\n","import {CogIcon} from '@sanity/icons'\nimport {Box, Button, Stack, Text, Tooltip} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport {type ObjectSchemaType, useClient} from 'sanity'\n\nimport {METADATA_SCHEMA_NAME} from '../constants'\nimport {useOpenInNewPane} from '../hooks/useOpenInNewPane'\nimport {createReference} from '../utils/createReference'\nimport {useDocumentInternationalizationContext} from './DocumentInternationalizationContext'\n\ntype LanguageManageProps = {\n id?: string\n metadataId?: string | null\n schemaType: ObjectSchemaType\n documentId: string\n sourceLanguageId?: string\n}\n\nexport default function LanguageManage(props: LanguageManageProps) {\n const {id, metadataId, schemaType, documentId, sourceLanguageId} = props\n const open = useOpenInNewPane(id, METADATA_SCHEMA_NAME)\n const openCreated = useOpenInNewPane(metadataId, METADATA_SCHEMA_NAME)\n const {allowCreateMetaDoc, apiVersion, weakReferences} =\n useDocumentInternationalizationContext()\n const client = useClient({apiVersion})\n const [userHasClicked, setUserHasClicked] = useState(false)\n\n const canCreate = !id && Boolean(metadataId) && allowCreateMetaDoc\n\n const handleClick = useCallback(() => {\n if (!id && metadataId && sourceLanguageId) {\n /* Disable button while this request is pending */\n setUserHasClicked(true)\n\n // handle creation of meta document\n const transaction = client.transaction()\n\n const sourceReference = createReference(\n sourceLanguageId,\n documentId,\n schemaType.name,\n !weakReferences\n )\n const newMetadataDocument = {\n _id: metadataId,\n _type: METADATA_SCHEMA_NAME,\n schemaTypes: [schemaType.name],\n translations: [sourceReference],\n }\n\n transaction.createIfNotExists(newMetadataDocument)\n\n transaction\n .commit()\n .then(() => {\n setUserHasClicked(false)\n openCreated()\n })\n .catch((err) => {\n console.error(err)\n setUserHasClicked(false)\n })\n } else {\n open()\n }\n }, [\n id,\n metadataId,\n sourceLanguageId,\n client,\n documentId,\n schemaType.name,\n weakReferences,\n openCreated,\n open,\n ])\n\n const disabled =\n (!id && !canCreate) || (canCreate && !sourceLanguageId) || userHasClicked\n\n return (\n <Tooltip\n animate\n content={\n <Box padding={2}>\n <Text muted size={1}>\n Document has no other translations\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n disabled={Boolean(id) || canCreate}\n >\n <Stack>\n <Button\n disabled={disabled}\n mode=\"ghost\"\n text=\"Manage Translations\"\n icon={CogIcon}\n loading={userHasClicked}\n onClick={handleClick}\n />\n </Stack>\n </Tooltip>\n )\n}\n","import {extractWithPath, Mutation} from '@sanity/mutator'\nimport {\n isDocumentSchemaType,\n type ObjectSchemaType,\n type Path,\n pathToString,\n type SanityDocument,\n type SchemaType,\n} from 'sanity'\n\nexport interface DocumentMember {\n schemaType: SchemaType\n path: Path\n name: string\n value: unknown\n}\n\nexport function removeExcludedPaths(\n doc: SanityDocument | null,\n schemaType: ObjectSchemaType\n): SanityDocument | null {\n // If the supplied doc is null or the schemaType\n // isn't a document, return as is.\n if (!isDocumentSchemaType(schemaType) || !doc) {\n return doc\n }\n\n // The extractPaths function gets all the fields in the doc with\n // a value, along with their schemaTypes and paths. We'll end up\n // with an array of paths in string form which we want to exclude\n const pathsToExclude: string[] = extractPaths(doc, schemaType, [])\n // We filter for any fields which should be excluded from the document\n // duplicate action, based on the schemaType option being set.\n .filter(\n (field) =>\n field.schemaType?.options?.documentInternationalization?.exclude ===\n true\n )\n // then we return the stringified version of the path\n .map((field) => {\n return pathToString(field.path)\n })\n\n // Now we can use the Mutation class from @sanity/mutator to patch the document\n // to remove all the paths that are for one of the excluded fields. This is just\n // done locally, and the documents themselves are not patched in the Content Lake.\n const mut = new Mutation({\n mutations: [\n {\n patch: {\n id: doc._id,\n unset: pathsToExclude,\n },\n },\n ],\n })\n\n return mut.apply(doc) as SanityDocument\n}\n\nfunction extractPaths(\n doc: SanityDocument,\n schemaType: ObjectSchemaType,\n path: Path\n): DocumentMember[] {\n return schemaType.fields.reduce<DocumentMember[]>((acc, field) => {\n const fieldPath = [...path, field.name]\n const fieldSchema = field.type\n const {value} = extractWithPath(pathToString(fieldPath), doc)[0] ?? {}\n if (!value) {\n return acc\n }\n\n const thisFieldWithPath: DocumentMember = {\n path: fieldPath,\n name: field.name,\n schemaType: fieldSchema,\n value,\n }\n\n if (fieldSchema.jsonType === 'object') {\n const innerFields = extractPaths(doc, fieldSchema, fieldPath)\n\n return [...acc, thisFieldWithPath, ...innerFields]\n } else if (\n fieldSchema.jsonType === 'array' &&\n fieldSchema.of.length &&\n fieldSchema.of.some((item) => 'fields' in item)\n ) {\n const {value: arrayValue} =\n extractWithPath(pathToString(fieldPath), doc)[0] ?? {}\n\n let arrayPaths: DocumentMember[] = []\n if ((arrayValue as any)?.length) {\n for (const item of arrayValue as any[]) {\n const itemPath = [...fieldPath, {_key: item._key}]\n let itemSchema = fieldSchema.of.find((t) => t.name === item._type)\n if (!item._type) {\n itemSchema = fieldSchema.of[0]\n }\n if (item._key && itemSchema) {\n const innerFields = extractPaths(\n doc,\n itemSchema as ObjectSchemaType,\n itemPath\n )\n const arrayMember = {\n path: itemPath,\n name: item._key,\n schemaType: itemSchema,\n value: item,\n }\n arrayPaths = [...arrayPaths, arrayMember, ...innerFields]\n }\n }\n }\n\n return [...acc, thisFieldWithPath, ...arrayPaths]\n }\n\n return [...acc, thisFieldWithPath]\n }, [])\n}\n","import {AddIcon, CheckmarkIcon, SplitVerticalIcon} from '@sanity/icons'\nimport {\n Badge,\n Box,\n Button,\n Flex,\n Spinner,\n Text,\n Tooltip,\n useToast,\n} from '@sanity/ui'\nimport {uuid} from '@sanity/uuid'\nimport {useCallback, useEffect, useState} from 'react'\nimport {type ObjectSchemaType, type SanityDocument, useClient} from 'sanity'\n\nimport {METADATA_SCHEMA_NAME} from '../constants'\nimport {useOpenInNewPane} from '../hooks/useOpenInNewPane'\nimport type {\n Language,\n Metadata,\n MetadataDocument,\n TranslationReference,\n} from '../types'\nimport {createReference} from '../utils/createReference'\nimport {removeExcludedPaths} from '../utils/excludePaths'\nimport {useDocumentInternationalizationContext} from './DocumentInternationalizationContext'\n\ntype LanguageOptionProps = {\n language: Language\n schemaType: ObjectSchemaType\n documentId: string\n disabled: boolean\n current: boolean\n source: SanityDocument | null\n metadataId: string | null\n metadata?: Metadata | null\n sourceLanguageId?: string\n}\n\nexport default function LanguageOption(props: LanguageOptionProps) {\n const {\n language,\n schemaType,\n documentId,\n current,\n source,\n sourceLanguageId,\n metadata,\n metadataId,\n } = props\n /* When the user has clicked the Create button, the button should be disabled\n * to prevent double-clicks from firing onCreate twice. This creates duplicate\n * translation metadata entries, which editors will not be able to delete */\n const [userHasClicked, setUserHasClicked] = useState(false)\n const disabled =\n props.disabled ||\n userHasClicked ||\n current ||\n !source ||\n !sourceLanguageId ||\n !metadataId\n const translation: TranslationReference | undefined = metadata?.translations\n .length\n ? metadata.translations.find((t) => t._key === language.id)\n : undefined\n const {apiVersion, languageField, weakReferences, callback} =\n useDocumentInternationalizationContext()\n const client = useClient({apiVersion})\n const toast = useToast()\n\n const open = useOpenInNewPane(translation?.value?._ref, schemaType.name)\n const handleOpen = useCallback(() => open(), [open])\n\n /* Once a translation has been created, reset the userHasClicked state to false\n * so they can click on it to navigate to the translation. If a translation already\n * existed when this component was mounted, this will have no effect. */\n const hasTranslation = Boolean(translation)\n useEffect(() => {\n setUserHasClicked(false)\n }, [hasTranslation])\n\n const handleCreate = useCallback(async () => {\n if (!source) {\n throw new Error(`Cannot create translation without source document`)\n }\n\n if (!sourceLanguageId) {\n throw new Error(`Cannot create translation without source language ID`)\n }\n\n if (!metadataId) {\n throw new Error(`Cannot create translation without a metadata ID`)\n }\n /* Disable the create button while this request is pending */\n setUserHasClicked(true)\n\n const transaction = client.transaction()\n\n // 1. Duplicate source document\n const newTranslationDocumentId = uuid()\n let newTranslationDocument = {\n ...source,\n _id: `drafts.${newTranslationDocumentId}`,\n // 2. Update language of the translation\n [languageField]: language.id,\n }\n\n // Remove fields / paths we don't want to duplicate\n newTranslationDocument = removeExcludedPaths(\n newTranslationDocument,\n schemaType\n ) as SanityDocument\n\n transaction.create(newTranslationDocument)\n\n // 3. Maybe create the metadata document\n const sourceReference = createReference(\n sourceLanguageId,\n documentId,\n schemaType.name,\n !weakReferences\n )\n const newTranslationReference = createReference(\n language.id,\n newTranslationDocumentId,\n schemaType.name,\n !weakReferences\n )\n const newMetadataDocument: MetadataDocument = {\n _id: metadataId,\n _type: METADATA_SCHEMA_NAME,\n schemaTypes: [schemaType.name],\n translations: [sourceReference],\n }\n\n transaction.createIfNotExists(newMetadataDocument)\n\n // 4. Patch translation to metadata document\n // Note: If the document was only just created in the operation above\n // This patch operation will have no effect\n const metadataPatch = client\n .patch(metadataId)\n .setIfMissing({translations: [sourceReference]})\n .insert(`after`, `translations[-1]`, [newTranslationReference])\n\n transaction.patch(metadataPatch)\n\n // 5. Commit!\n transaction\n .commit()\n .then(() => {\n const metadataExisted = Boolean(metadata?._createdAt)\n\n callback?.({\n client,\n sourceLanguageId,\n sourceDocument: source,\n newDocument: newTranslationDocument,\n destinationLanguageId: language.id,\n metaDocumentId: metadataId,\n }).catch((err) => {\n toast.push({\n status: 'error',\n title: `Callback`,\n description: `Error while running callback - ${err}.`,\n })\n })\n\n return toast.push({\n status: 'success',\n title: `Created \"${language.title}\" translation`,\n description: metadataExisted\n ? `Updated Translations Metadata`\n : `Created Translations Metadata`,\n })\n })\n .catch((err) => {\n console.error(err)\n\n /* Re-enable the create button if there was an error */\n setUserHasClicked(false)\n\n return toast.push({\n status: 'error',\n title: `Error creating translation`,\n description: err.message,\n })\n })\n }, [\n client,\n documentId,\n language.id,\n language.title,\n languageField,\n metadata?._createdAt,\n metadataId,\n schemaType,\n source,\n sourceLanguageId,\n toast,\n weakReferences,\n callback,\n ])\n\n let message\n\n if (current) {\n message = `Current document`\n } else if (translation) {\n message = `Open ${language.title} translation`\n } else if (!translation) {\n message = `Create new ${language.title} translation`\n }\n\n return (\n <Tooltip\n animate\n content={\n <Box padding={2}>\n <Text muted size={1}>\n {message}\n </Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n >\n <Button\n onClick={translation ? handleOpen : handleCreate}\n mode={current && disabled ? `default` : `bleed`}\n disabled={disabled}\n >\n <Flex gap={3} align=\"center\">\n {disabled && !current ? (\n <Spinner />\n ) : (\n <Text size={2}>\n {/* eslint-disable-next-line no-nested-ternary */}\n {translation ? (\n <SplitVerticalIcon />\n ) : current ? (\n <CheckmarkIcon />\n ) : (\n <AddIcon />\n )}\n </Text>\n )}\n <Box flex={1}>\n <Text>{language.title}</Text>\n </Box>\n <Badge tone={disabled || current ? `default` : `primary`}>\n {language.id}\n </Badge>\n </Flex>\n </Button>\n </Tooltip>\n )\n}\n","import {EditIcon} from '@sanity/icons'\nimport {Badge, Box, Button, Flex, Text, useToast} from '@sanity/ui'\nimport {useCallback} from 'react'\nimport {type SanityDocument, useClient} from 'sanity'\n\nimport type {Language} from '../types'\nimport {useDocumentInternationalizationContext} from './DocumentInternationalizationContext'\n\ntype LanguagePatchProps = {\n language: Language\n source: SanityDocument | null\n disabled: boolean\n}\n\nexport default function LanguagePatch(props: LanguagePatchProps) {\n const {language, source} = props\n const {apiVersion, languageField} = useDocumentInternationalizationContext()\n const disabled = props.disabled || !source\n const client = useClient({apiVersion})\n const toast = useToast()\n\n const handleClick = useCallback(() => {\n if (!source) {\n throw new Error(`Cannot patch missing document`)\n }\n\n const currentId = source._id\n\n client\n .patch(currentId)\n .set({[languageField]: language.id})\n .commit()\n .then(() => {\n toast.push({\n title: `Set document language to ${language.title}`,\n status: `success`,\n })\n })\n .catch((err) => {\n console.error(err)\n\n return toast.push({\n title: `Failed to set document language to ${language.title}`,\n status: `error`,\n })\n })\n }, [source, client, languageField, language, toast])\n\n return (\n <Button\n mode=\"bleed\"\n onClick={handleClick}\n disabled={disabled}\n justify=\"flex-start\"\n >\n <Flex gap={3} align=\"center\">\n <Text size={2}>\n <EditIcon />\n </Text>\n <Box flex={1}>\n <Text>{language.title}</Text>\n </Box>\n <Badge>{language.id}</Badge>\n </Flex>\n </Button>\n )\n}\n","import {Box} from '@sanity/ui'\nimport {styled} from 'styled-components'\n\nexport default styled(Box)`\n max-width: 280px;\n`\n","import {Card, Flex, Text} from '@sanity/ui'\nimport type {PropsWithChildren} from 'react'\n\nimport ConstrainedBox from './ConstrainedBox'\n\nexport default function Warning({children}: PropsWithChildren) {\n return (\n <Card tone=\"caution\" padding={3}>\n <Flex justify=\"center\">\n <ConstrainedBox>\n <Text size={1} align=\"center\">\n {children}\n </Text>\n </ConstrainedBox>\n </Flex>\n </Card>\n )\n}\n","import {TranslateIcon} from '@sanity/icons'\nimport {\n Box,\n Button,\n Card,\n Popover,\n Stack,\n Text,\n TextInput,\n useClickOutside,\n} from '@sanity/ui'\nimport {uuid} from '@sanity/uuid'\nimport {type FormEvent, useCallback, useMemo, useState} from 'react'\nimport {useEditState} from 'sanity'\n\nimport {useTranslationMetadata} from '../hooks/useLanguageMetadata'\nimport type {DocumentInternationalizationMenuProps} from '../types'\nimport {useDocumentInternationalizationContext} from './DocumentInternationalizationContext'\nimport LanguageManage from './LanguageManage'\nimport LanguageOption from './LanguageOption'\nimport LanguagePatch from './LanguagePatch'\nimport Warning from './Warning'\n\nexport function DocumentInternationalizationMenu(\n props: DocumentInternationalizationMenuProps\n) {\n const {documentId} = props\n const schemaType = props.schemaType\n const {languageField, supportedLanguages} =\n useDocumentInternationalizationContext()\n\n // Search filter query\n const [query, setQuery] = useState(``)\n const handleQuery = useCallback((event: FormEvent<HTMLInputElement>) => {\n if (event.currentTarget.value) {\n setQuery(event.currentTarget.value)\n } else {\n setQuery(``)\n }\n }, [])\n\n // UI Handlers\n const [open, setOpen] = useState(false)\n const handleClick = useCallback(() => setOpen((o) => !o), [])\n const [button, setButton] = useState<HTMLElement | null>(null)\n const [popover, setPopover] = useState<HTMLElement | null>(null)\n const handleClickOutside = useCallback(() => setOpen(false), [])\n useClickOutside(handleClickOutside, [button, popover])\n\n // Get metadata from content lake\n const {data, loading, error} = useTranslationMetadata(documentId)\n const metadata = Array.isArray(data) && data.length ? data[0] : null\n\n // Optimistically set a metadata ID for a newly created metadata document\n // Cannot rely on generated metadata._id from useTranslationMetadata\n // As the document store might not have returned it before creating another translation\n const metadataId = useMemo(() => {\n if (loading) {\n return null\n }\n\n // Once created, these two values should be the same anyway\n return metadata?._id ?? uuid()\n }, [loading, metadata?._id])\n\n // Duplicate a new language version from the most recent version of this document\n const {draft, published} = useEditState(documentId, schemaType.name)\n const source = draft || published\n\n // Check for data issues\n const documentIsInOneMetadataDocument = useMemo(() => {\n return Array.isArray(data) && data.length <= 1\n }, [data])\n const sourceLanguageId = source?.[languageField] as string | undefined\n const sourceLanguageIsValid = supportedLanguages.some(\n (l) => l.id === sourceLanguageId\n )\n const allLanguagesAreValid = useMemo(() => {\n const valid = supportedLanguages.every((l) => l.id && l.title)\n if (!valid) {\n console.warn(\n `Not all languages are valid. It should be an array of objects with an \"id\" and \"title\" property. Or a function that returns an array of objects with an \"id\" and \"title\" property.`,\n supportedLanguages\n )\n }\n\n return valid\n }, [supportedLanguages])\n\n const content = (\n <Box padding={1}>\n {error ? (\n <Card tone=\"critical\" padding={1}>\n <Text>There was an error returning translations metadata</Text>\n </Card>\n ) : (\n <Stack space={1}>\n <LanguageManage\n id={metadata?._id}\n documentId={documentId}\n metadataId={metadataId}\n schemaType={schemaType}\n sourceLanguageId={sourceLanguageId}\n />\n {supportedLanguages.length > 4 ? (\n <TextInput\n onChange={handleQuery}\n value={query}\n placeholder=\"Filter languages\"\n />\n ) : null}\n {supportedLanguages.length > 0 ? (\n <>\n {/* Once metadata is loaded, there may be issues */}\n {loading ? null : (\n <>\n {/* Not all languages are valid */}\n {data && documentIsInOneMetadataDocument ? null : (\n <Warning>\n {/* TODO: Surface these documents to the user */}\n This document has been found in more than one Translations\n Metadata documents\n </Warning>\n )}\n {/* Not all languages are valid */}\n {allLanguagesAreValid ? null : (\n <Warning>\n Not all language objects are valid. See the console.\n </Warning>\n )}\n {/* Current document has no language field */}\n {sourceLanguageId ? null : (\n <Warning>\n Choose a language to apply to{' '}\n <strong>this Document</strong>\n </Warning>\n )}\n {/* Current document has an invalid language field */}\n {sourceLanguageId && !sourceLanguageIsValid ? (\n <Warning>\n Select a supported language. Current language value:{' '}\n <code>{sourceLanguageId}</code>\n </Warning>\n ) : null}\n </>\n )}\n {supportedLanguages\n .filter((language) => {\n if (query) {\n return language.title\n .toLowerCase()\n .includes(query.toLowerCase())\n }\n return true\n })\n .map((language) =>\n !loading && sourceLanguageId && sourceLanguageIsValid ? (\n // Button to duplicate this document to a new translation\n // And either create or update the metadata document\n <LanguageOption\n key={language.id}\n language={language}\n schemaType={schemaType}\n documentId={documentId}\n disabled={loading || !allLanguagesAreValid}\n current={language.id === sourceLanguageId}\n metadata={metadata}\n metadataId={metadataId}\n source={source}\n sourceLanguageId={sourceLanguageId}\n />\n ) : (\n // Button to set a language field on *this* document\n <LanguagePatch\n key={language.id}\n source={source}\n language={language}\n // Only allow language patch change to:\n // - Keys not in metadata\n // - The key of this document in the metadata\n disabled={\n (loading ||\n !allLanguagesAreValid ||\n metadata?.translations\n .filter((t) => t?.value?._ref !== documentId)\n .some((t) => t._key === language.id)) ??\n false\n }\n />\n )\n )}\n </>\n ) : null}\n </Stack>\n )}\n </Box>\n )\n\n const issueWithTranslations =\n !loading && sourceLanguageId && !sourceLanguageIsValid\n\n if (!documentId) {\n return null\n }\n\n if (!schemaType || !schemaType.name) {\n return null\n }\n\n return (\n <Popover\n animate\n constrainSize\n content={content}\n open={open}\n portal\n ref={setPopover}\n overflow=\"auto\"\n tone=\"default\"\n >\n <Button\n text=\"Translations\"\n mode=\"bleed\"\n disabled={!source}\n tone={\n !source || loading || !issueWithTranslations ? undefined : `caution`\n }\n icon={TranslateIcon}\n onClick={handleClick}\n ref={setButton}\n selected={open}\n />\n </Popover>\n )\n}\n","import {TrashIcon} from '@sanity/icons'\nimport {type ButtonTone, useToast} from '@sanity/ui'\nimport {useCallback, useMemo, useState} from 'react'\nimport {\n type DocumentActionComponent,\n type KeyedObject,\n type Reference,\n type TypedObject,\n useClient,\n} from 'sanity'\n\nimport {API_VERSION, TRANSLATIONS_ARRAY_NAME} from '../constants'\n\ntype TranslationReference = TypedObject &\n KeyedObject & {\n value: Reference\n }\n\nexport const DeleteMetadataAction: DocumentActionComponent = (props) => {\n const {id: documentId, published, draft, onComplete} = props\n const doc = draft || published\n\n const [isDialogOpen, setDialogOpen] = useState(false)\n const onClose = useCallback(() => setDialogOpen(false), [])\n const translations: TranslationReference[] = useMemo(\n () =>\n doc && Array.isArray(doc[TRANSLATIONS_ARRAY_NAME])\n ? (doc[TRANSLATIONS_ARRAY_NAME] as TranslationReference[])\n : [],\n [doc]\n )\n\n const toast = useToast()\n const client = useClient({apiVersion: API_VERSION})\n\n // Remove translation reference and delete document in one transaction\n const onProceed = useCallback(() => {\n const tx = client.transaction()\n\n tx.patch(documentId, (patch) => patch.unset([TRANSLATIONS_ARRAY_NAME]))\n\n if (translations.length > 0) {\n translations.forEach((translation) => {\n tx.delete(translation.value._ref)\n tx.delete(`drafts.${translation.value._ref}`)\n })\n }\n\n tx.delete(documentId)\n // Shouldn't exist as this document type is in liveEdit\n tx.delete(`drafts.${documentId}`)\n\n tx.commit()\n .then(() => {\n onClose()\n\n toast.push({\n status: 'success',\n title: 'Deleted document and translations',\n })\n })\n .catch((err) => {\n toast.push({\n status: 'error',\n title: 'Failed to delete document and translations',\n description: err.message,\n })\n })\n }, [client, translations, documentId, onClose, toast])\n\n return {\n label: `Delete all translations`,\n disabled: !doc || !translations.length,\n icon: TrashIcon,\n tone: 'critical' as ButtonTone,\n onHandle: () => {\n setDialogOpen(true)\n },\n dialog: isDialogOpen && {\n type: 'confirm',\n onCancel: onComplete,\n onConfirm: () => {\n onProceed()\n onComplete()\n },\n tone: 'critical' as ButtonTone,\n message:\n translations.length === 1\n ? `Delete 1 translation and this document`\n : `Delete all ${translations.length} translations and this document`,\n },\n }\n}\n","import type {DocumentBadgeDescription, DocumentBadgeProps} from 'sanity'\n\nimport {useDocumentInternationalizationContext} from '../components/DocumentInternationalizationContext'\n\nexport function LanguageBadge(\n props: DocumentBadgeProps\n): DocumentBadgeDescription | null {\n const source = props?.draft || props?.published\n const {languageField, supportedLanguages} =\n useDocumentInternationalizationContext()\n const languageId = source?.[languageField]\n\n if (!languageId) {\n return null\n }\n\n const language = Array.isArray(supportedLanguages)\n ? supportedLanguages.find((l) => l.id === languageId)\n : null\n\n // Currently we only show the language id if the supportedLanguages are async\n return {\n label: language?.id ?? String(languageId),\n title: language?.title ?? undefined,\n color: `primary`,\n }\n}\n","import {Card, Spinner} from '@sanity/ui'\nimport {useEffect, useMemo} from 'react'\nimport {Preview, useEditState, useSchema, useValidationStatus} from 'sanity'\n\ntype DocumentCheckProps = {\n id: string\n onCheckComplete: (id: string) => void\n addInvalidId: (id: string) => void\n removeInvalidId: (id: string) => void\n addDraftId: (id: string) => void\n removeDraftId: (id: string) => void\n}\n\n// Check if the document has a draft\n// Check if that draft is valid\n// Report back to parent that it can be added to bulk publish\nexport default function DocumentCheck(props: DocumentCheckProps) {\n const {\n id,\n onCheckComplete,\n addInvalidId,\n removeInvalidId,\n addDraftId,\n removeDraftId,\n } = props\n const editState = useEditState(id, ``)\n const {isValidating, validation} = useValidationStatus(id, ``)\n const schema = useSchema()\n\n const validationHasErrors = useMemo(() => {\n return (\n !isValidating &&\n validation.length > 0 &&\n validation.some((item) => item.level === 'error')\n )\n }, [isValidating, validation])\n\n useEffect(() => {\n if (validationHasErrors) {\n addInvalidId(id)\n } else {\n removeInvalidId(id)\n }\n\n if (editState.draft) {\n addDraftId(id)\n } else {\n removeDraftId(id)\n }\n\n if (!isValidating) {\n onCheckComplete(id)\n }\n }, [\n addDraftId,\n addInvalidId,\n editState.draft,\n id,\n isValidating,\n onCheckComplete,\n removeDraftId,\n removeInvalidId,\n validationHasErrors,\n ])\n\n // We only care about drafts\n if (!editState.draft) {\n return null\n }\n\n const schemaType = schema.get(editState.draft._type)\n\n return (\n <Card\n border\n padding={2}\n tone={validationHasErrors ? `critical` : `positive`}\n >\n {editState.draft && schemaType ? (\n <Preview\n layout=\"default\"\n value={editState.draft}\n schemaType={schemaType}\n />\n ) : (\n <Spinner />\n )}\n </Card>\n )\n}\n","import {Box, type ButtonTone, Text, Tooltip} from '@sanity/ui'\nimport type {ComponentType, PropsWithChildren} from 'react'\nimport {TextWithTone} from 'sanity'\n\ntype InfoIconProps = PropsWithChildren & {\n icon: ComponentType\n tone: ButtonTone\n text?: string\n}\n\nexport default function InfoIcon(props: InfoIconProps) {\n const {text, icon, tone, children} = props\n const Icon = icon\n\n return (\n <Tooltip\n animate\n portal\n content={\n children ? (\n <>{children}</>\n ) : (\n <Box padding={2}>\n <Text size={1}>{text}</Text>\n </Box>\n )\n }\n >\n <TextWithTone tone={tone} size={1}>\n <Icon />\n </TextWithTone>\n </Tooltip>\n )\n}\n","import {InfoOutlineIcon} from '@sanity/icons'\nimport {Box, Stack, Text} from '@sanity/ui'\n\nimport InfoIcon from './InfoIcon'\n\nexport default function Info() {\n return (\n <InfoIcon icon={InfoOutlineIcon} tone=\"primary\">\n <Stack padding={3} space={4} style={{maxWidth: 250}}>\n <Box>\n <Text size={1}>Bulk publishing uses the Scheduling API.</Text>\n </Box>\n <Box>\n <Text size={1}>\n Customized Document Actions in the Studio will not execute. Webhooks\n will execute.\n </Text>\n </Box>\n <Box>\n <Text size={1}>\n Validation is checked before rendering the button below, but the\n Scheduling API will not check for – or enforce – validation.\n </Text>\n </Box>\n </Stack>\n </InfoIcon>\n )\n}\n","import {Button, Card, Dialog, Inline, Stack, Text, useToast} from '@sanity/ui'\nimport {useCallback, useState} from 'react'\nimport {TextWithTone, useClient, useWorkspace} from 'sanity'\n\nimport {API_VERSION} from '../../constants'\nimport type {TranslationReference} from '../../types'\nimport DocumentCheck from './DocumentCheck'\nimport Info from './Info'\n\nexport type BulkPublishProps = {\n translations: TranslationReference[]\n}\n\n// A root-level component with UI for hitting the Publishing API\nexport default function BulkPublish(props: BulkPublishProps) {\n const {translations} = props\n const client = useClient({apiVersion: API_VERSION})\n const {projectId, dataset} = useWorkspace()\n const toast = useToast()\n const [invalidIds, setInvalidIds] = useState<string[] | null>(null)\n const [checkedIds, setCheckedIds] = useState<string[]>([])\n\n const onCheckComplete = useCallback((id: string) => {\n setCheckedIds((ids) => Array.from(new Set([...ids, id])))\n }, [])\n\n // Handle dialog\n const [open, setOpen] = useState(false)\n const onOpen = useCallback(() => setOpen(true), [])\n const onClose = useCallback(() => setOpen(false), [])\n\n const addInvalidId = useCallback((id: string) => {\n setInvalidIds((ids) => (ids ? Array.from(new Set([...ids, id])) : [id]))\n }, [])\n\n const removeInvalidId = useCallback((id: string) => {\n setInvalidIds((ids) => (ids ? ids.filter((i) => i !== id) : []))\n }, [])\n\n const [draftIds, setDraftIds] = useState<string[]>([])\n\n const addDraftId = useCallback((id: string) => {\n setDraftIds((ids) => Array.from(new Set([...ids, id])))\n }, [])\n\n const removeDraftId = useCallback((id: string) => {\n setDraftIds((ids) => ids.filter((i) => i !== id))\n }, [])\n\n const handleBulkPublish = useCallback(() => {\n const body = translations.map((translation) => ({\n documentId: translation.value._ref,\n }))\n client\n .request({\n uri: `/publish/${projectId}/${dataset}`,\n method: 'POST',\n body,\n })\n .then(() => {\n toast.push({\n status: 'success',\n title: 'Success',\n description: 'Bulk publish complete',\n })\n })\n .catch((err) => {\n console.error(err)\n toast.push({\n status: 'error',\n title: 'Error',\n description: 'Bulk publish failed',\n })\n })\n }, [translations, client, projectId, dataset, toast])\n\n const disabled =\n // Not all documents have been checked\n checkedIds.length !== translations.length ||\n // Some document(s) are invalid\n Boolean(invalidIds && invalidIds?.length > 0) ||\n // No documents are drafts\n !draftIds.length\n\n return translations?.length > 0 ? (\n <Card padding={4} border radius={2}>\n <Stack space={3}>\n <Inline space={3}>\n <Text weight=\"bold\" size={1}>\n Bulk publishing\n </Text>\n <Info />\n </Inline>\n\n <Stack>\n <Button\n onClick={onOpen}\n text=\"Prepare bulk publishing\"\n mode=\"ghost\"\n />\n </Stack>\n\n {open && (\n <Dialog\n animate\n header=\"Bulk publishing\"\n id=\"bulk-publish-dialog\"\n onClose={onClose}\n zOffset={1000}\n width={3}\n >\n <Stack space={4} padding={4}>\n {draftIds.length > 0 ? (\n <Stack space={2}>\n <Text size={1}>\n There{' '}\n {draftIds.length === 1\n ? `is 1 draft document`\n : `are ${draftIds.length} draft documents`}\n .\n </Text>\n {invalidIds && invalidIds.length > 0 ? (\n <TextWithTone tone=\"critical\" size={1}>\n {invalidIds && invalidIds.length === 1\n ? `1 draft document has`\n : `${\n invalidIds && invalidIds.length\n } draft documents have`}{' '}\n validation issues that must addressed first\n </TextWithTone>\n ) : (\n <TextWithTone tone=\"positive\" size={1}>\n All drafts are valid and can be bulk published\n </TextWithTone>\n )}\n </Stack>\n ) : null}\n\n <Stack space={1}>\n {translations\n .filter((translation) => translation?.value?._ref)\n .map((translation) => (\n <DocumentCheck\n key={translation._key}\n id={translation.value._ref}\n onCheckComplete={onCheckComplete}\n addInvalidId={addInvalidId}\n removeInvalidId={removeInvalidId}\n addDraftId={addDraftId}\n removeDraftId={removeDraftId}\n />\n ))}\n </Stack>\n {draftIds.length > 0 ? (\n <Button\n mode=\"ghost\"\n tone={\n invalidIds && invalidIds?.length > 0\n ? 'caution'\n : 'positive'\n }\n text={\n draftIds.length === 1\n ? `Publish draft document`\n : `Bulk publish ${draftIds.length} draft documents`\n }\n onClick={handleBulkPublish}\n disabled={disabled}\n />\n ) : (\n <Text muted size={1}>\n No draft documents to publish\n </Text>\n )}\n </Stack>\n </Dialog>\n )}\n </Stack>\n </Card>\n ) : null\n}\n","import {useEffect} from 'react'\nimport {PatchEvent, unset, useClient, useEditState} from 'sanity'\nimport {useDocumentPane} from 'sanity/structure'\n\nimport {API_VERSION} from '../../constants'\nimport type {TranslationReference} from '../../types'\n\ntype ReferencePatcherProps = {\n translation: TranslationReference\n documentType: string\n metadataId: string\n}\n\n// For every reference, check if it is published, and if so, strengthen the reference\nexport default function ReferencePatcher(props: ReferencePatcherProps) {\n const {translation, documentType, metadataId} = props\n const editState = useEditState(translation.value._ref, documentType)\n const client = useClient({apiVersion: API_VERSION})\n const {onChange} = useDocumentPane()\n\n useEffect(() => {\n if (\n // We have a reference\n translation.value._ref &&\n // It's still weak and not-yet-strengthened\n translation.value._weak &&\n // We also want to keep this check because maybe the user *configured* weak refs\n translation.value._strengthenOnPublish &&\n // The referenced document has just been published\n !editState.draft &&\n editState.published &&\n editState.ready\n ) {\n const referencePathBase = [\n 'translations',\n {_key: translation._key},\n 'value',\n ]\n\n onChange(\n new PatchEvent([\n unset([...referencePathBase, '_weak']),\n unset([...referencePathBase, '_strengthenOnPublish']),\n ])\n )\n }\n }, [translation, editState, metadataId, client, onChange])\n\n return null\n}\n","import type {TranslationReference} from '../../types'\nimport ReferencePatcher from './ReferencePatcher'\n\ntype OptimisticallyStrengthenProps = {\n translations: TranslationReference[]\n metadataId: string\n}\n\n// There's no good reason to leave published references as weak\n// So this component will run on every render and strengthen them\nexport default function OptimisticallyStrengthen(\n props: OptimisticallyStrengthenProps\n) {\n const {translations = [], metadataId} = props\n\n if (!translations.length) {\n return null\n }\n\n return (\n <>\n {translations.map((translation) =>\n translation.value._strengthenOnPublish?.type ? (\n <ReferencePatcher\n key={translation._key}\n translation={translation}\n documentType={translation.value._strengthenOnPublish.type}\n metadataId={metadataId}\n />\n ) : null\n )}\n </>\n )\n}\n","import {TranslateIcon} from '@sanity/icons'\nimport {\n defineField,\n defineType,\n type DocumentDefinition,\n type FieldDefinition,\n} from 'sanity'\n\nimport {METADATA_SCHEMA_NAME, TRANSLATIONS_ARRAY_NAME} from '../../constants'\n\nexport default (\n schemaTypes: string[],\n metadataFields: FieldDefinition[]\n): DocumentDefinition =>\n defineType({\n type: 'document',\n name: METADATA_SCHEMA_NAME,\n title: 'Translation metadata',\n icon: TranslateIcon,\n liveEdit: true,\n fields: [\n defineField({\n name: TRANSLATIONS_ARRAY_NAME,\n type: 'internationalizedArrayReference',\n }),\n defineField({\n name: 'schemaTypes',\n description:\n 'Optional: Used to filter the reference fields above so all translations share the same types.',\n type: 'array',\n of: [{type: 'string'}],\n options: {list: schemaTypes},\n readOnly: ({value}) => Boolean(value),\n }),\n ...metadataFields,\n ],\n preview: {\n select: {\n translations: TRANSLATIONS_ARRAY_NAME,\n documentSchemaTypes: 'schemaTypes',\n },\n prepare(selection) {\n const {translations = [], documentSchemaTypes = []} = selection\n const title =\n translations.length === 1\n ? `1 Translation`\n : `${translations.length} Translations`\n const languageKeys = translations.length\n ? translations\n .map((t: {_key: string}) => t._key.toUpperCase())\n .join(', ')\n : ``\n const subtitle = [\n languageKeys ? `(${languageKeys})` : null,\n documentSchemaTypes?.length\n ? documentSchemaTypes.map((s: string) => s).join(`, `)\n : ``,\n ]\n .filter(Boolean)\n .join(` `)\n\n return {\n title,\n subtitle,\n }\n },\n },\n })\n","import {Stack} from '@sanity/ui'\nimport {defineField, definePlugin, isSanityDocument} from 'sanity'\nimport {internationalizedArray} from 'sanity-plugin-internationalized-array'\n\nimport {DeleteMetadataAction} from './actions/DeleteMetadataAction'\nimport {LanguageBadge} from './badges'\nimport BulkPublish from './components/BulkPublish'\nimport {DocumentInternationalizationProvider} from './components/DocumentInternationalizationContext'\nimport {DocumentInternationalizationMenu} from './components/DocumentInternationalizationMenu'\nimport OptimisticallyStrengthen from './components/OptimisticallyStrengthen'\nimport {API_VERSION, DEFAULT_CONFIG, METADATA_SCHEMA_NAME} from './constants'\nimport {documentInternationalizationUsEnglishLocaleBundle} from './i18n'\nimport metadata from './schema/translation/metadata'\nimport type {PluginConfig, TranslationReference} from './types'\n\nexport const documentInternationalization = definePlugin<PluginConfig>(\n (config) => {\n const pluginConfig = {...DEFAULT_CONFIG, ...config}\n const {\n supportedLanguages,\n schemaTypes,\n languageField,\n bulkPublish,\n metadataFields,\n } = pluginConfig\n\n if (schemaTypes.length === 0) {\n throw new Error(\n 'You must specify at least one schema type on which to enable document internationalization. Update the `schemaTypes` option in the documentInternationalization() configuration.'\n )\n }\n\n return {\n name: '@sanity/document-internationalization',\n\n studio: {\n components: {\n layout: (props) =>\n DocumentInternationalizationProvider({...props, pluginConfig}),\n },\n },\n\n i18n: {\n bundles: [documentInternationalizationUsEnglishLocaleBundle],\n },\n\n // Adds:\n // - A bulk-publishing UI component to the form\n // - Will only work for projects on a compatible plan\n form: {\n components: {\n input: (props) => {\n if (\n props.id === 'root' &&\n props.schemaType.name === METADATA_SCHEMA_NAME &&\n isSanityDocument(props?.value)\n ) {\n const metadataId = props?.value?._id\n const translations =\n (props?.value?.translations as TranslationReference[]) ?? []\n const weakAndTypedTranslations = translations.filter(\n ({value}) => value?._weak && value._strengthenOnPublish\n )\n\n return (\n <Stack space={5}>\n {bulkPublish ? (\n <BulkPublish translations={translations} />\n ) : null}\n {weakAndTypedTranslations.length > 0 ? (\n <OptimisticallyStrengthen\n metadataId={metadataId}\n translations={weakAndTypedTranslations}\n />\n ) : null}\n {props.renderDefault(props)}\n </Stack>\n )\n }\n\n return props.renderDefault(props)\n },\n },\n },\n\n // Adds:\n // - The `Translations` dropdown to the editing form\n // - `Badges` to documents with a language value\n // - The `DeleteMetadataAction` action to the metadata document type\n document: {\n unstable_languageFilter: (prev, ctx) => {\n const {schemaType, documentId} = ctx\n\n return schemaTypes.includes(schemaType) && documentId\n ? [\n ...prev,\n (props) =>\n DocumentInternationalizationMenu({...props, documentId}),\n ]\n : prev\n },\n badges: (prev, {schemaType}) => {\n if (!schemaTypes.includes(schemaType)) {\n return prev\n }\n\n return [(props) => LanguageBadge(props), ...prev]\n },\n actions: (prev, {schemaType}) => {\n if (schemaType === METADATA_SCHEMA_NAME) {\n return [...prev, DeleteMetadataAction]\n }\n\n return prev\n },\n },\n\n // Adds:\n // - The `Translations metadata` document type to the schema\n schema: {\n // Create the metadata document type\n types: [metadata(schemaTypes, metadataFields)],\n\n // For every schema type this plugin is enabled on\n // Create an initial value template to set the language\n templates: (prev, {schema}) => {\n // Templates are not setup for async languages\n if (!Array.isArray(supportedLanguages)) {\n return prev\n }\n\n const parameterizedTemplates = schemaTypes.map((schemaType) => ({\n id: `${schemaType}-parameterized`,\n title: `${\n schema?.get(schemaType)?.title ?? schemaType\n }: with Language`,\n schemaType,\n parameters: [\n {name: `languageId`, title: `Language ID`, type: `string`},\n ],\n value: ({languageId}: {languageId: string}) => ({\n [languageField]: languageId,\n }),\n }))\n\n const staticTemplates = schemaTypes.flatMap((schemaType) => {\n return supportedLanguages.map((language) => ({\n id: `${schemaType}-${language.id}`,\n title: `${language.title} ${\n schema?.get(schemaType)?.title ?? schemaType\n }`,\n schemaType,\n value: {\n [languageField]: language.id,\n },\n }))\n })\n\n return [...prev, ...parameterizedTemplates, ...staticTemplates]\n },\n },\n\n // Uses:\n // - `sanity-plugin-internationalized-array` to maintain the translations array\n plugins: [\n // Translation metadata stores its references using this plugin\n // It cuts down on attribute usage and gives UI conveniences to add new translations\n internationalizedArray({\n languages: supportedLanguages,\n fieldTypes: [\n defineField(\n {\n name: 'reference',\n type: 'reference',\n to: schemaTypes.map((type) => ({type})),\n weak: pluginConfig.weakReferences,\n // Reference filters don't actually enforce validation!\n validation: (Rule) =>\n // @ts-expect-error - fix typings\n Rule.custom(async (item: TranslationReference, context) => {\n if (!item?.value?._ref || !item?._key) {\n return true\n }\n\n const client = context.getClient({apiVersion: API_VERSION})\n const valueLanguage = await client.fetch(\n `*[_id in [$ref, $draftRef]][0].${languageField}`,\n {\n ref: item.value._ref,\n draftRef: `drafts.${item.value._ref}`,\n }\n )\n\n if (valueLanguage && valueLanguage === item._key) {\n return true\n }\n\n return `Referenced document does not have the correct language value`\n }),\n options: {\n // @ts-expect-error - Update type once it knows the values of this filter\n filter: ({parent, document}) => {\n if (!parent) return null\n\n // I'm not sure in what instance there's an array of parents\n // But the Type suggests it's possible\n const parentArray = Array.isArray(parent)\n ? parent\n : [parent]\n const language = parentArray.find((p) => p._key)\n\n if (!language?._key) return null\n\n if (document.schemaTypes) {\n return {\n filter: `_type in $schemaTypes && ${languageField} == $language`,\n params: {\n schemaTypes: document.schemaTypes,\n language: language._key,\n },\n }\n }\n\n return {\n filter: `${languageField} == $language`,\n params: {language: language._key},\n }\n },\n },\n },\n {strict: false}\n ),\n ],\n }),\n ],\n }\n }\n)\n"],"names":["query","config","entry","__spreadProps","__spreadValues","d","b","Subscription","Subscriber","ConsumerObserver","SafeSubscriber","OperatorSubscriber","err","dupeId","metadata","_a"],"mappings":";;;;;;;;;;;;AASA,SAAwB,gBAAgB,OAA6B;AAGnE,QAAM,aAFS,UAAA,EAEW,IAAI,MAAM,IAAI;AACxC,SAAK,aAIE,oBAAC,SAAQ,EAAA,OAAO,MAAM,OAAO,WAAwB,CAAA,IAHlD,oBAAA,UAAA,EAAS,MAAK,YAAW,OAAM,yBAAwB;AAInE;AChBO,MAAM,uBAAuB,wBACvB,0BAA0B,gBAC1B,cAAc,cACd,iBAAsC;AAAA,EACjD,oBAAoB,CAAC;AAAA,EACrB,aAAa,CAAC;AAAA,EACd,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,gBAAgB,CAAC;AAAA,EACjB,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,UAAU;AACZ;ACXgB,SAAA,mBAAmB,OAAgC,IAGjE;AACA,QAAM,eAAiC,IACjC,kBAAoC,CAAC;AAE3C,SAAI,QAAQ,KAAK,SAAS,KACxB,KAAK,QAAQ,CAAC,QAAQ;AAChB,QAAI,UAAU,uBAChB,aAAa,KAAK,GAAG,IAErB,gBAAgB,KAAK,GAAG;AAAA,EAAA,CAE3B,GAGI,EAAC,cAAc,gBAAe;AACvC;ACRA,SAAwB,wBACtB,OACA;AACM,QAAA,EAAC,KAAK,YAAY,gBAAA,IAAmB,OAGrC,EAAC,MAAM,QAAA,IAAW;AAAA,IACtB;AAAA,IACA,EAAC,QAA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