From 1b56374a6237c8c6e3e3980f50d35262bd0454f5 Mon Sep 17 00:00:00 2001 From: Cody Olsen Date: Mon, 8 Jul 2024 18:03:01 +0200 Subject: [PATCH] feat: testing multiple experimental perf boosting strategies --- .../components/debugStyledComponents.tsx | 271 + dev/test-studio/sanity.config.ts | 2 + package.json | 4 +- .../package.bundle/src/package.bundle.ts | 12 +- packages/@repo/package.config/package.json | 3 + .../package.config/src/package.config.ts | 14 + packages/sanity/.eslintignore | 1 + packages/sanity/.gitignore | 3 + packages/sanity/package.json | 1 + packages/sanity/package.worker.ts | 26 + .../src/_internal/cli/server/getViteConfig.ts | 3 + .../formField/FormFieldBaseHeader.tsx | 34 +- .../components/formField/FormFieldSet.tsx | 5 +- .../formField/FormFieldSetLegend.tsx | 5 +- .../PortableText/object/Annotation.styles.ts | 5 +- .../members/object/fields/PrimitiveField.tsx | 29 +- .../core/hooks/useUserListWithPermissions.ts | 25 +- .../overlay/RegionsWithIntersections.tsx | 13 +- .../core/presence/overlay/StickyOverlay.tsx | 2 +- .../src/core/preview/documentPreviewStore.ts | 8 - .../sanity/src/core/preview/observeFields.ts | 17 +- .../buffered-doc/createBufferedDocument.ts | 2 + .../createObservableBufferedDocument.ts | 1 + .../document-pair/checkoutPair.test.ts | 2 +- .../document/document-pair/checkoutPair.ts | 396 +- .../checkoutPairImplementation.ts | 242 + .../document-pair/checkoutPairWorker.ts | 147 + .../document/document-pair/documentEvents.ts | 1 + .../document/document-pair/memoizedPair.ts | 1 + .../document-pair/operations/helpers.ts | 1 + .../document/document-pair/remoteSnapshots.ts | 1 + .../document/document-pair/snapshotPair.ts | 1 + .../store/_legacy/document/document-store.ts | 1 + .../store/_legacy/document/getPairListener.ts | 5 +- .../core/store/_legacy/grants/grantsStore.ts | 1 + .../_legacy/presence/useGlobalPresence.tsx | 20 +- .../panes/document/DocumentPaneProvider.tsx | 2 + packages/sanity/turbo.json | 5 + packages/sanity/web-workers/checkoutPair.mjs | 11460 ++++++++++++++++ pnpm-lock.yaml | 587 +- turbo.json | 8 +- 41 files changed, 12787 insertions(+), 580 deletions(-) create mode 100644 dev/test-studio/components/debugStyledComponents.tsx create mode 100644 packages/sanity/package.worker.ts create mode 100644 packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPairImplementation.ts create mode 100644 packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPairWorker.ts create mode 100644 packages/sanity/web-workers/checkoutPair.mjs diff --git a/dev/test-studio/components/debugStyledComponents.tsx b/dev/test-studio/components/debugStyledComponents.tsx new file mode 100644 index 00000000000..25233997bbd --- /dev/null +++ b/dev/test-studio/components/debugStyledComponents.tsx @@ -0,0 +1,271 @@ +import { + // useCallback, + useEffect, + useInsertionEffect, + // useRef, + useState, + // useSyncExternalStore, +} from 'react' +import {definePlugin, type LayoutProps} from 'sanity' +import {__PRIVATE__, StyleSheetManager} from 'styled-components' + +const IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window + +export const debugStyledComponents = definePlugin({ + name: 'debug-styled-components', + studio: { + components: { + // layout: DebugLayout, + }, + }, +}) + +// eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars +function DebugLayout(props: LayoutProps) { + const {renderDefault} = props + const [, setTick] = useState(1) + // const [onStoreChange, setOnStoreChange] = useState(() => () => {}) + // const onBufferRef = useRef(onStoreChange) + // useEffect(() => { + // onBufferRef.current = onStoreChange + // }, [onStoreChange]) + const [blazingSheet] = useState( + () => + new BlazingStyleSheet({ + // Schedule state updates when the buffer is queued + onBuffer: () => { + // console.log('onBuffer') + setTick((prev) => prev + 1) + }, + // onBuffer: () => onBufferRef.current(), + // Reconstruct default options + // https://github.com/styled-components/styled-components/blob/770d1fa2bc1a4bfe3eea1b14a0357671ba9407a4/packages/styled-components/src/sheet/Sheet.ts#L23-L26 + isServer: !IS_BROWSER, + useCSSOMInjection: true, + }), + ) + // const shouldFlush = useSyncExternalStore( + // useCallback((_onStoreChange) => { + // setOnStoreChange(() => _onStoreChange) + // return () => setOnStoreChange(() => () => {}) + // }, []), + // () => blazingSheet.shouldFlush(), + // () => true, + // ) + const [enabled, setEnabled] = useState(true) + const [flush, setFlush] = useState(true) + const [namespace, setNamespace] = useState() + const [disableCSSOMInjection, setDisableCSSOMInjection] = useState() + const [enableVendorPrefixes, setEnableVendorPrefixes] = useState() + + useEffect(() => { + // @ts-expect-error -- debug global + window.cody = { + setNamespace, + setDisableCSSOMInjection, + setEnableVendorPrefixes, + setEnabled, + toggle: () => setFlush((prev) => !prev), + } + return () => { + // @ts-expect-error -- debug global + delete window.cody + } + }, []) + + // useEffect(() => { + // console.log({ + // blazingSheet, + // namespace, + // disableCSSOMInjection, + // enableVendorPrefixes, + // enabled, + // // shouldFlush, + // }) + // }, [blazingSheet, disableCSSOMInjection, enableVendorPrefixes, enabled, namespace]) + + // Pause event emitter during render: + // https://github.com/final-form/react-final-form/issues/751#issuecomment-689431448 + blazingSheet.pauseEvents() + + // Update CSSOM + useInsertionEffect(() => { + if (flush) { + blazingSheet.flush() + } + }) + + // Check if CSSOM should update + // eslint-disable-next-line react-hooks/exhaustive-deps -- @TODO rewrite to use useState to buffer up changes that should flush + useEffect(() => { + if (flush) { + if (blazingSheet.shouldFlush()) { + // console.log('Flush in side-effect!') + setTick((prev) => prev + 1) + } + blazingSheet.resumeEvents() + } + }) + + if (!enabled) { + return renderDefault(props) + } + + return ( + + + {renderDefault(props)} + + + ) +} + +// @TODO refactor to wrap around mainSheet with a proxy that queues up insertRule and deleteRule calls +const {StyleSheet} = __PRIVATE__ + +const EMPTY_OBJECT = Object.freeze({}) as Readonly<{[key: string]: any}> + +class BlazingStyleSheet extends StyleSheet { + #buffer: ( + | {type: 'insertRules'; payload: [id: string, name: string, rules: string | string[]]} + | {type: 'clearRules'; payload: [id: string]} + )[] = [] + #flushing = false + #onBuffer: any + #paused = true + + constructor( + options: ConstructorParameters[0] & {onBuffer?: any} = EMPTY_OBJECT, + globalStyles: ConstructorParameters[1] = {}, + names?: ConstructorParameters[2], + ) { + super(options, globalStyles, names) + + if (options.onBuffer) { + this.#onBuffer = options.onBuffer + } + } + + /** + * Overriding this method is necessary, as it has a hardcoded call with the `StyleSheet` constructor + */ + override reconstructWithOptions( + options: Parameters['reconstructWithOptions']>[0], + withNames = true, + ) { + return new BlazingStyleSheet( + {onBuffer: this.#onBuffer, ...this.options, ...options}, + this.gs, + (withNames && this.names) || undefined, + ) + } + /** + * Overriding `getTag`, original implementation: https://github.com/styled-components/styled-components/blob/770d1fa2bc1a4bfe3eea1b14a0357671ba9407a4/packages/styled-components/src/sheet/Sheet.ts#L76-L79 + * + * There are two main performance bottlenecks in styled-components: + * 1. Regular styled components (the result of \`const StyledComponent = styled.div\`\`\`) updates CSS during render: + * https://github.com/styled-components/styled-components/blob/770d1fa2bc1a4bfe3eea1b14a0357671ba9407a4/packages/styled-components/src/models/StyledComponent.ts#L64-L68 + * 2. Global styled components (the result of `const GlobalStyle = createGlobalStyle``) updates CSS using \`useLayoutEffect\`: + * https://github.com/styled-components/styled-components/blob/770d1fa2bc1a4bfe3eea1b14a0357671ba9407a4/packages/styled-components/src/constructors/createGlobalStyle.ts#L52-L57 + * + * An attempt to moving to `useInsertionEffect` were made in 2022, but little activity since then: + * https://github.com/styled-components/styled-components/pull/3821 + * + * This custom version of `StyleSheet` allows us to intercept either: + * a) writes to CSSOM: https://github.com/styled-components/styled-components/blob/770d1fa2bc1a4bfe3eea1b14a0357671ba9407a4/packages/styled-components/src/sheet/Tag.ts#L34 + * b) writes to the DOM that triggers CSSOM updates: https://github.com/styled-components/styled-components/blob/770d1fa2bc1a4bfe3eea1b14a0357671ba9407a4/packages/styled-components/src/sheet/Tag.ts#L73-L75 + * Option b) is only used if disableCSSOMInjection is set to true on a parent StyleSheetManager component. + * + * By wrapping the group tag, and its internal tag models, we can intercept and buffer writes to the CSSOM, + * and flush them in a `useInsertionEffect`, allowing React to optimize them and orchestrate better. + */ + override getTag() { + if (this.tag) { + return this.tag + } + const groupedTag = super.getTag() + const {tag} = groupedTag + const proxyTag = new Proxy(tag, { + get: (target, prop, receiver) => { + if (prop === 'insertRule' || prop === 'deleteRule' || prop === 'getRule') { + // console.log('Tag.get()', prop, {target, receiver}, this.#buffer) + } + return Reflect.get(target, prop, receiver) + }, + }) + groupedTag.tag = proxyTag + // console.log('getTag() is called', {tag, groupedTag}, this, document?.querySelector('style')) + return groupedTag + } + /** + * Flush all `insertRules` and `clearRules` from the buffer, + * this should happen during a `useInsertionEffect` or similar as updating CSSOM is intensive. + */ + flush() { + try { + this.#flushing = true + while (this.#buffer.length > 0) { + const {type, payload} = this.#buffer.shift()! + switch (type) { + case 'insertRules': + this.insertRules(...payload) + break + case 'clearRules': + this.clearRules(...payload) + break + default: + throw new TypeError(`Unknown buffer type: ${type}`, {cause: {type, payload}}) + } + } + } catch (err) { + console.error('Something crashed during flushing', err) + } finally { + this.#flushing = false + } + } + shouldFlush() { + if (this.#flushing) { + throw new TypeError('Cannot flush while flushing') + } + return this.#buffer.length > 0 + } + /** + * Handle React constraint of not being allowed to call setState during render of another component (`styled` components call `insertStyles` during render, so it cannot trigger a state setter) + */ + pauseEvents() { + // console.count('pauseEvents') + this.#paused = true + } + resumeEvents() { + // console.count('resumeEvents') + this.#paused = false + } + override insertRules(id: string, name: string, rules: string | string[]): void { + if (this.#flushing) { + // console.count(`Flushing insertRules(${id}, ${name})`) + super.insertRules(id, name, rules) + } else { + // console.count(`Queueing insertRules(${id}, ${name})`) + this.#buffer.push({type: 'insertRules', payload: [id, name, rules]}) + if (!this.#paused) { + this.#onBuffer?.() + } + } + } + override clearRules(id: string): void { + if (this.#flushing) { + // console.count(`Flushing clearRules(${id})`) + super.clearRules(id) + } else { + // console.count(`Queueing clearRules(${id})`) + this.#buffer.push({type: 'clearRules', payload: [id]}) + if (!this.#paused) { + this.#onBuffer?.() + } + } + } +} diff --git a/dev/test-studio/sanity.config.ts b/dev/test-studio/sanity.config.ts index 8d3030524ad..d24ba13e304 100644 --- a/dev/test-studio/sanity.config.ts +++ b/dev/test-studio/sanity.config.ts @@ -17,6 +17,7 @@ import {imageHotspotArrayPlugin} from 'sanity-plugin-hotspot-array' import {muxInput} from 'sanity-plugin-mux-input' import {imageAssetSource} from './assetSources' +import {debugStyledComponents} from './components/debugStyledComponents' import { Annotation, Block, @@ -102,6 +103,7 @@ const sharedSettings = definePlugin({ badges: (prev, context) => (context.schemaType === 'author' ? [CustomBadge, ...prev] : prev), }, plugins: [ + debugStyledComponents(), structureTool({ icon: BookIcon, structure, diff --git a/package.json b/package.json index 4fa3771437c..6b37694918b 100644 --- a/package.json +++ b/package.json @@ -182,7 +182,9 @@ }, "overrides": { "@typescript-eslint/eslint-plugin": "$@typescript-eslint/eslint-plugin", - "@typescript-eslint/parser": "$@typescript-eslint/parser" + "@typescript-eslint/parser": "$@typescript-eslint/parser", + "@sanity/ui": "2.6.4-canary.0", + "styled-components": "npm:speedy-styled-components@6.1.12-canary.0" } }, "isSanityMonorepo": true diff --git a/packages/@repo/package.bundle/src/package.bundle.ts b/packages/@repo/package.bundle/src/package.bundle.ts index 848a9aa5db6..7fcf958e651 100644 --- a/packages/@repo/package.bundle/src/package.bundle.ts +++ b/packages/@repo/package.bundle/src/package.bundle.ts @@ -7,6 +7,7 @@ import {version} from '../package.json' export const defaultConfig: UserConfig = { appType: 'custom', define: { + '__DEV__': 'false', 'process.env.PKG_VERSION': JSON.stringify(version), 'process.env.NODE_ENV': '"production"', 'process.env': {}, @@ -19,7 +20,13 @@ export const defaultConfig: UserConfig = { formats: ['es'], }, rollupOptions: { - external: ['react', /^react-dom/, 'react/jsx-runtime', 'styled-components'], + external: [ + 'react', + /^react-dom/, + 'react/jsx-runtime', + 'styled-components', + './checkoutPairWorker.ts', + ], output: { exports: 'named', dir: 'dist', @@ -30,4 +37,7 @@ export const defaultConfig: UserConfig = { }, }, }, + worker: { + format: 'es', + }, } diff --git a/packages/@repo/package.config/package.json b/packages/@repo/package.config/package.json index 349d89e93b1..012cc9f9c06 100644 --- a/packages/@repo/package.config/package.json +++ b/packages/@repo/package.config/package.json @@ -7,5 +7,8 @@ "types": "./src/package.config.ts", "scripts": { "check:types": "tsc --noEmit --skipLibCheck src/package.config.ts" + }, + "dependencies": { + "@web/rollup-plugin-import-meta-assets": "2.2.1" } } diff --git a/packages/@repo/package.config/src/package.config.ts b/packages/@repo/package.config/src/package.config.ts index d1802051900..ec63b547c05 100644 --- a/packages/@repo/package.config/src/package.config.ts +++ b/packages/@repo/package.config/src/package.config.ts @@ -1,4 +1,6 @@ import {defineConfig} from '@sanity/pkg-utils' +// @ts-expect-error -- missing types +import {importMetaAssets} from '@web/rollup-plugin-import-meta-assets' export default defineConfig({ define: { @@ -29,6 +31,18 @@ export default defineConfig({ legacyExports: true, rollup: { optimizeLodash: true, + plugins: ([t1, t2, t3, t4, t5, t6, ...plugins]) => [ + t1, + t2, + t3, + t4, + t5, + t6, + importMetaAssets({ + include: ['**/checkoutPair.mjs', '**/checkoutPair.ts'], + }), + ...plugins, + ], }, tsconfig: 'tsconfig.lib.json', strictOptions: { diff --git a/packages/sanity/.eslintignore b/packages/sanity/.eslintignore index 58066cfc7d0..044f6fbf2f7 100644 --- a/packages/sanity/.eslintignore +++ b/packages/sanity/.eslintignore @@ -6,3 +6,4 @@ presentation.js router.js structure.js /migrate/* +/web-workers/* diff --git a/packages/sanity/.gitignore b/packages/sanity/.gitignore index 9e4ed9299f4..01b643ea4f6 100644 --- a/packages/sanity/.gitignore +++ b/packages/sanity/.gitignore @@ -30,3 +30,6 @@ /migrate.js /_internal.js /cli.js + +/web-workers/**/*.map +/web-workers/**/*.esm.js diff --git a/packages/sanity/package.json b/packages/sanity/package.json index aa1871ce9d8..3530ad6053b 100644 --- a/packages/sanity/package.json +++ b/packages/sanity/package.json @@ -127,6 +127,7 @@ "scripts": { "build": "pkg-utils build --strict --check --clean", "build:bundle": "vite build --config package.bundle.ts", + "build:web-workers": "vite build --config package.worker.ts", "check:types": "tsc --project tsconfig.lib.json", "clean": "rimraf _internal.js _singletons.js cli.js desk.js migrate.js presentation.js router.js structure.js lib", "coverage": "jest --coverage", diff --git a/packages/sanity/package.worker.ts b/packages/sanity/package.worker.ts new file mode 100644 index 00000000000..f6f24ad6b2f --- /dev/null +++ b/packages/sanity/package.worker.ts @@ -0,0 +1,26 @@ +import {defineConfig, mergeConfig} from 'vite' + +import {defaultConfig} from '../@repo/package.bundle/src/package.bundle' + +export default defineConfig(() => { + return mergeConfig(defaultConfig, { + build: { + lib: { + entry: './src/core/store/_legacy/document/document-pair/checkoutPairWorker.ts', + fileName: 'checkoutPair', + }, + rollupOptions: { + external: [], + output: { + exports: 'none', + dir: 'web-workers', + format: 'iife', + inlineDynamicImports: true, + }, + }, + }, + worker: { + format: 'iife', + }, + }) +}) diff --git a/packages/sanity/src/_internal/cli/server/getViteConfig.ts b/packages/sanity/src/_internal/cli/server/getViteConfig.ts index 7c8bcffe641..08ceaf57e5e 100644 --- a/packages/sanity/src/_internal/cli/server/getViteConfig.ts +++ b/packages/sanity/src/_internal/cli/server/getViteConfig.ts @@ -121,6 +121,9 @@ export async function getViteConfig(options: ViteOptions): Promise 'process.env.MODE': JSON.stringify(mode), ...getStudioEnvironmentVariables({prefix: 'process.env.', jsonEncode: true}), }, + worker: { + format: 'es', + }, } if (mode === 'production') { diff --git a/packages/sanity/src/core/form/components/formField/FormFieldBaseHeader.tsx b/packages/sanity/src/core/form/components/formField/FormFieldBaseHeader.tsx index 2ffe77686f2..bf40864c0bb 100644 --- a/packages/sanity/src/core/form/components/formField/FormFieldBaseHeader.tsx +++ b/packages/sanity/src/core/form/components/formField/FormFieldBaseHeader.tsx @@ -6,6 +6,7 @@ import {TooltipDelayGroupProvider} from '../../../../ui-components' import {type DocumentFieldActionNode} from '../../../config' import {FieldPresence, type FormNodePresence} from '../../../presence' import {calcAvatarStackWidth} from '../../../presence/utils' +import {resizeObserver} from '../../../util' import {FieldActionMenu} from '../../field' import {type FieldCommentsProps} from '../../types' @@ -180,38 +181,31 @@ export function FormFieldBaseHeader(props: FormFieldBaseHeaderProps) { // Determine if floating card with actions should be shown const shouldShowFloatingCard = focused || showFieldActions || hasComments - const handleSetFloatingCardElementWidth = useCallback(() => { - if (floatingCardElement) { - const {width} = floatingCardElement.getBoundingClientRect() - setFloatingCardWidth(width || 0) - } - }, [floatingCardElement]) - // When a focus or blur event occurs on the floating card, we need to recalculate its width. // This is because presence should be positioned relative to the floating card. // We need this because we don't conditionally render the floating card and rely on CSS to // show/hide it, and therefore the width calculation won't be triggered when the card is shown or hidden. + useEffect(() => { + if (!floatingCardElement) return undefined + return resizeObserver.observe(floatingCardElement, (event) => { + setFloatingCardWidth(event.borderBoxSize?.[0].inlineSize ?? 0) + }) + }, [floatingCardElement]) + const handleFocusCapture = useCallback(() => { - handleSetFloatingCardElementWidth() setFocused(true) - }, [handleSetFloatingCardElementWidth]) + }, []) const handleBlurCapture = useCallback(() => { - handleSetFloatingCardElementWidth() setFocused(false) - }, [handleSetFloatingCardElementWidth]) - - // Calculate floating card's width - useEffect(() => { - handleSetFloatingCardElementWidth() - }, [handleSetFloatingCardElementWidth, showFieldActions]) + }, []) // Calculate slot element's width useEffect(() => { - if (slotElement) { - const {width} = slotElement.getBoundingClientRect() - setSlotWidth(width || 0) - } + if (!slotElement) return undefined + return resizeObserver.observe(slotElement, (event) => { + setSlotWidth(event.borderBoxSize?.[0].inlineSize ?? 0) + }) }, [slotElement]) // Construct the slot element if slot is provided diff --git a/packages/sanity/src/core/form/components/formField/FormFieldSet.tsx b/packages/sanity/src/core/form/components/formField/FormFieldSet.tsx index 00df96598c5..e64a0f94d86 100644 --- a/packages/sanity/src/core/form/components/formField/FormFieldSet.tsx +++ b/packages/sanity/src/core/form/components/formField/FormFieldSet.tsx @@ -68,7 +68,10 @@ function getChildren(children: ReactNode | (() => ReactNode)): ReactNode { return typeof children === 'function' ? children() : children } -const Root = styled(Stack).attrs({forwardedAs: 'fieldset'})` +const Root = styled(Stack).attrs( + // @ts-expect-error - figure out why `forwardedAs` is not recognized + {forwardedAs: 'fieldset'}, +)` border: none; /* See: https://thatemil.com/blog/2015/01/03/reset-your-fieldset/ */ diff --git a/packages/sanity/src/core/form/components/formField/FormFieldSetLegend.tsx b/packages/sanity/src/core/form/components/formField/FormFieldSetLegend.tsx index 9e5c631dead..fdd995e5f8e 100644 --- a/packages/sanity/src/core/form/components/formField/FormFieldSetLegend.tsx +++ b/packages/sanity/src/core/form/components/formField/FormFieldSetLegend.tsx @@ -18,7 +18,10 @@ const Root = styled.legend` display: table; ` -const ToggleButton = styled(Flex).attrs({forwardedAs: 'button'})((props: {theme: Theme}) => { +const ToggleButton = styled(Flex).attrs( + // @ts-expect-error - figure out why `forwardedAs` is not recognized + {forwardedAs: 'button'}, +)((props: {theme: Theme}) => { const {theme} = props const {focusRing, radius} = theme.sanity const {base} = theme.sanity.color diff --git a/packages/sanity/src/core/form/inputs/PortableText/object/Annotation.styles.ts b/packages/sanity/src/core/form/inputs/PortableText/object/Annotation.styles.ts index 3e1687f568b..fbfa4944991 100644 --- a/packages/sanity/src/core/form/inputs/PortableText/object/Annotation.styles.ts +++ b/packages/sanity/src/core/form/inputs/PortableText/object/Annotation.styles.ts @@ -32,6 +32,9 @@ export const Root = styled.span<{$toneKey?: Exclude void}>() const [localValue, setLocalValue] = useState() + // const [optimisticValue, setOptimisticValue] = useState(() => ({ + // prev: member.field.value, + // next: member.field.value, + // })) const {onPathBlur, onPathFocus, onChange} = useFormCallbacks() @@ -56,6 +60,7 @@ export function PrimitiveField(props: { [onChange, member.name], ) + // @TODO perf check this chain const handleNativeChange = useCallback( (event: ChangeEvent) => { let inputValue: number | string | boolean = event.currentTarget.value @@ -80,11 +85,29 @@ export function PrimitiveField(props: { setLocalValue(hasEmptyValue ? undefined : event.currentTarget.value) } + // setOptimisticValue((state) => ({...state, next: inputValue})) onChange(PatchEvent.from(hasEmptyValue ? unset() : set(inputValue)).prefixAll(member.name)) + setLocalValue(hasEmptyValue ? '' : event.currentTarget.value) }, [member.name, member.field.schemaType, onChange], ) + // Reset local value after a timeout + useEffect(() => { + if (member.field.value === undefined || localValue === undefined || member.field.focused) { + return undefined + } + const callback = requestIdleCallback( + () => { + setLocalValue(undefined) + }, + {timeout: 5000}, + ) + return () => { + cancelIdleCallback(callback) + } + }, [localValue, member.field.focused, member.field.value]) + const validationError = useMemo( () => @@ -104,7 +127,7 @@ export function PrimitiveField(props: { 'onChange': handleNativeChange, 'value': resolveNativeNumberInputValue( member.field.schemaType, - member.field.value, + localValue ?? member.field.value, localValue, ), 'readOnly': Boolean(member.field.readOnly), @@ -114,11 +137,11 @@ export function PrimitiveField(props: { [ handleBlur, handleFocus, - handleNativeChange, member.field.id, - member.field.readOnly, member.field.schemaType, member.field.value, + member.field.readOnly, + handleNativeChange, localValue, ], ) diff --git a/packages/sanity/src/core/hooks/useUserListWithPermissions.ts b/packages/sanity/src/core/hooks/useUserListWithPermissions.ts index b3feba241be..cec38a5ecd4 100644 --- a/packages/sanity/src/core/hooks/useUserListWithPermissions.ts +++ b/packages/sanity/src/core/hooks/useUserListWithPermissions.ts @@ -2,8 +2,9 @@ import {type SanityDocument} from '@sanity/client' import {type User} from '@sanity/types' import {sortBy} from 'lodash' -import {useEffect, useMemo, useState} from 'react' -import {concat, forkJoin, map, mergeMap, type Observable, of, switchMap} from 'rxjs' +import {useMemo} from 'react' +import {useObservable} from 'react-rx' +import {forkJoin, map, mergeMap, type Observable, of, switchMap} from 'rxjs' import { type DocumentValuePermission, @@ -65,8 +66,6 @@ export function useUserListWithPermissions( const userStore = useUserStore() const client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS) - const [state, setState] = useState(INITIAL_STATE) - const list$ = useMemo(() => { // 1. Get the project members and filter out the robot users const members$: Observable = projectStore @@ -141,21 +140,5 @@ export function useUserListWithPermissions( return $alphabetical }, [client.observable, documentValue, projectStore, userStore, permission]) - useEffect(() => { - const initial$ = of(INITIAL_STATE) - const state$ = concat(initial$, list$) - - const sub = state$.subscribe({ - next: setState, - error: (error) => { - setState({data: [], error, loading: false}) - }, - }) - - return () => { - sub.unsubscribe() - } - }, [list$]) - - return state + return useObservable(list$, INITIAL_STATE) } diff --git a/packages/sanity/src/core/presence/overlay/RegionsWithIntersections.tsx b/packages/sanity/src/core/presence/overlay/RegionsWithIntersections.tsx index 13d4310e452..41d5caa067e 100644 --- a/packages/sanity/src/core/presence/overlay/RegionsWithIntersections.tsx +++ b/packages/sanity/src/core/presence/overlay/RegionsWithIntersections.tsx @@ -3,11 +3,13 @@ import { forwardRef, type ReactNode, useCallback, + useEffect, useMemo, useRef, useState, } from 'react' +import {resizeObserver} from '../../util' import { DEBUG, INTERSECTION_ELEMENT_PADDING, @@ -143,6 +145,14 @@ export const RegionsWithIntersections = forwardRef(function RegionsWithIntersect [bottom, intersections, regions, top], ) + const [overlayOffsetWidth, setOverlayOffsetWidth] = useState(0) + useEffect(() => { + if (!overlayRef.current) return undefined + return resizeObserver.observe(overlayRef.current, (event) => { + setOverlayOffsetWidth(event.borderBoxSize?.[0].inlineSize ?? 0) + }) + }, []) + return (
{children}
- {overlayRef.current && - render(regionsWithIntersectionDetails, overlayRef.current.offsetWidth)} + {overlayOffsetWidth && render(regionsWithIntersectionDetails, overlayOffsetWidth)} {regions.map((region) => { const forceWidth = region.rect.width === 0 diff --git a/packages/sanity/src/core/presence/overlay/StickyOverlay.tsx b/packages/sanity/src/core/presence/overlay/StickyOverlay.tsx index df535c66757..b2bec1c53fe 100644 --- a/packages/sanity/src/core/presence/overlay/StickyOverlay.tsx +++ b/packages/sanity/src/core/presence/overlay/StickyOverlay.tsx @@ -161,7 +161,7 @@ export function StickyOverlay(props: Props) { ) const renderCallback = useCallback( - (regionsWithIntersectionDetails: RegionWithIntersectionDetails[], containerWidth: any) => { + (regionsWithIntersectionDetails: RegionWithIntersectionDetails[], containerWidth: number) => { const grouped = group( regionsWithIntersectionDetails.filter((item) => item.region.presence.length > 0), ) diff --git a/packages/sanity/src/core/preview/documentPreviewStore.ts b/packages/sanity/src/core/preview/documentPreviewStore.ts index e715cee925d..f2581c149b5 100644 --- a/packages/sanity/src/core/preview/documentPreviewStore.ts +++ b/packages/sanity/src/core/preview/documentPreviewStore.ts @@ -64,15 +64,7 @@ export function createDocumentPreviewStore({ }: DocumentPreviewStoreOptions): DocumentPreviewStore { const versionedClient = client.withConfig({apiVersion: '1'}) - // NOTE: this is workaroudn for circumventing a circular dependency between `observePaths` and - // `observeFields`. - // eslint-disable-next-line camelcase - const __proxy_observePaths: ObservePathsFn = (value, paths, apiConfig) => { - return observePaths(value, paths, apiConfig) - } - const {observeFields} = create_preview_observeFields({ - observePaths: __proxy_observePaths, versionedClient, }) diff --git a/packages/sanity/src/core/preview/observeFields.ts b/packages/sanity/src/core/preview/observeFields.ts index b86a038da20..3e4ce186e3d 100644 --- a/packages/sanity/src/core/preview/observeFields.ts +++ b/packages/sanity/src/core/preview/observeFields.ts @@ -25,14 +25,7 @@ import { } from 'rxjs/operators' import {INCLUDE_FIELDS} from './constants' -import { - type ApiConfig, - type FieldName, - type Id, - type ObservePathsFn, - type PreviewPath, - type Selection, -} from './types' +import {type ApiConfig, type FieldName, type Id, type PreviewPath, type Selection} from './types' import {debounceCollect} from './utils/debounceCollect' import {hasEqualFields} from './utils/hasEqualFields' import {isUniqueBy} from './utils/isUniqueBy' @@ -48,11 +41,8 @@ type Cache = { [id: string]: CachedFieldObserver[] } -export function create_preview_observeFields(context: { - observePaths: ObservePathsFn - versionedClient: SanityClient -}) { - const {observePaths, versionedClient} = context +export function create_preview_observeFields(context: {versionedClient: SanityClient}) { + const {versionedClient} = context let _globalListener: any @@ -106,6 +96,7 @@ export function create_preview_observeFields(context: { function fetchAllDocumentPathsWith(client: SanityClient) { return function fetchAllDocumentPath(selections: Selection[]) { const combinedSelections = combineSelections(selections) + // @TODO perf test return client.observable .fetch(toQuery(combinedSelections), {}, {tag: 'preview.document-paths'} as any) .pipe(map((result: any) => reassemble(result, combinedSelections))) diff --git a/packages/sanity/src/core/store/_legacy/document/buffered-doc/createBufferedDocument.ts b/packages/sanity/src/core/store/_legacy/document/buffered-doc/createBufferedDocument.ts index 3300568c2bc..6ca4a577be3 100644 --- a/packages/sanity/src/core/store/_legacy/document/buffered-doc/createBufferedDocument.ts +++ b/packages/sanity/src/core/store/_legacy/document/buffered-doc/createBufferedDocument.ts @@ -47,6 +47,7 @@ export interface BufferedDocumentWrapper { } /** @internal */ +// @TODO run from worker export const createBufferedDocument = ( documentId: string, // consider naming it remoteEvent$ @@ -64,6 +65,7 @@ export const createBufferedDocument = ( remoteSnapshot$: bufferedDocument.remoteSnapshot$, commitRequest$: bufferedDocument.commitRequest$, + // @TODO make these easier to access? Worker related patch: (patches) => patches.map((patch) => ({patch: {...patch, id: documentId}})), create: (document) => ({create: prepareDoc(document)}), createIfNotExists: (document) => ({createIfNotExists: prepareDoc(document)}), diff --git a/packages/sanity/src/core/store/_legacy/document/buffered-doc/createObservableBufferedDocument.ts b/packages/sanity/src/core/store/_legacy/document/buffered-doc/createObservableBufferedDocument.ts index 431b12bab3c..7c458b371e3 100644 --- a/packages/sanity/src/core/store/_legacy/document/buffered-doc/createObservableBufferedDocument.ts +++ b/packages/sanity/src/core/store/_legacy/document/buffered-doc/createObservableBufferedDocument.ts @@ -77,6 +77,7 @@ const getDocument = (event: T): T['document'] => even /** @internal */ // This is an observable interface for BufferedDocument in an attempt // to make it easier to work with the api provided by it +// @TODO test from worker export const createObservableBufferedDocument = (listenerEvent$: Observable) => { // Incoming local actions (e.g. a request to mutate, a request to commit pending changes, etc.) const actions$ = new Subject() diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.test.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.test.ts index 0abb38c51e2..25ab1b6d208 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.test.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.test.ts @@ -3,7 +3,7 @@ import {type SanityClient} from '@sanity/client' import {merge, of} from 'rxjs' import {delay} from 'rxjs/operators' -import {checkoutPair} from './checkoutPair' +import {checkoutPairImplementation as checkoutPair} from './checkoutPairImplementation' const mockedDataRequest = jest.fn(() => of({})) const mockedActionRequest = jest.fn(() => of({})) diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.ts index 0bf28b3271c..f32cc9100f3 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.ts @@ -1,180 +1,15 @@ -import {type Action, type SanityClient} from '@sanity/client' -import {type Mutation} from '@sanity/mutator' +import {type SanityClient} from '@sanity/client' import {type SanityDocument} from '@sanity/types' -import {omit} from 'lodash' -import {EMPTY, from, merge, type Observable, Subject} from 'rxjs' -import {filter, map, mergeMap, share, take, tap} from 'rxjs/operators' - -import { - type BufferedDocumentEvent, - type CommitRequest, - createBufferedDocument, - type MutationPayload, - type RemoteSnapshotEvent, -} from '../buffered-doc' -import {getPairListener, type ListenerEvent} from '../getPairListener' -import {type IdPair, type PendingMutationsEvent, type ReconnectEvent} from '../types' - -const isMutationEventForDocId = - (id: string) => - ( - event: ListenerEvent, - ): event is Exclude => { - return event.type !== 'reconnect' && event.type !== 'pending' && event.documentId === id - } - -/** - * @hidden - * @beta */ -export type WithVersion = T & {version: 'published' | 'draft'} - -/** - * @hidden - * @beta */ -export type DocumentVersionEvent = WithVersion - -/** - * @hidden - * @beta */ -export type RemoteSnapshotVersionEvent = WithVersion - -/** - * @hidden - * @beta */ -export interface DocumentVersion { - consistency$: Observable - remoteSnapshot$: Observable - events: Observable - - patch: (patches: any[]) => MutationPayload[] - create: (document: Partial) => MutationPayload - createIfNotExists: (document: SanityDocument) => MutationPayload - createOrReplace: (document: SanityDocument) => MutationPayload - delete: () => MutationPayload - - mutate: (mutations: MutationPayload[]) => void - commit: () => void -} - -/** - * @hidden - * @beta */ -export interface Pair { - /** @internal */ - transactionsPendingEvents$: Observable - published: DocumentVersion - draft: DocumentVersion - complete: () => void -} - -function setVersion(version: 'draft' | 'published') { - return (ev: T): T & {version: 'draft' | 'published'} => ({...ev, version}) -} - -function requireId( - value: T, -): asserts value is T & {_id: string} { - if (!value._id) { - throw new Error('Expected document to have an _id') - } -} - -//if we're patching a published document directly -//then we're live editing and we should use raw mutations -//rather than actions -function isLiveEditMutation(mutationParams: Mutation['params'], publishedId: string) { - const {resultRev, ...mutation} = mutationParams - const patchTargets: string[] = mutation.mutations.flatMap((mut) => { - const mutationPayloads = Object.values(mut) - if (mutationPayloads.length > 1) { - throw new Error('Did not expect multiple mutations in the same payload') - } - return mutationPayloads[0].id || mutationPayloads[0]._id - }) - return patchTargets.every((target) => target === publishedId) -} - -function toActions(idPair: IdPair, mutationParams: Mutation['params']): Action[] { - return mutationParams.mutations.flatMap((mutations) => { - // This action is not always interoperable with the equivalent mutation. It will fail if the - // published version of the document already exists. - if (mutations.createIfNotExists) { - // ignore all createIfNotExists, as these should be covered by the actions api and only be done locally - return [] - } - if (mutations.create) { - // the actions API requires attributes._id to be set, while it's optional in the mutation API - requireId(mutations.create) - return { - actionType: 'sanity.action.document.create', - publishedId: idPair.publishedId, - attributes: mutations.create, - ifExists: 'fail', - } - } - if (mutations.patch) { - return { - actionType: 'sanity.action.document.edit', - draftId: idPair.draftId, - publishedId: idPair.publishedId, - patch: omit(mutations.patch, 'id'), - } - } - throw new Error('Cannot map mutation to action') - }) -} - -function commitActions(client: SanityClient, idPair: IdPair, mutationParams: Mutation['params']) { - if (isLiveEditMutation(mutationParams, idPair.publishedId)) { - return commitMutations(client, mutationParams) - } - - return client.observable.action(toActions(idPair, mutationParams), { - tag: 'document.commit', - transactionId: mutationParams.transactionId, - }) -} - -function commitMutations(client: SanityClient, mutationParams: Mutation['params']) { - const {resultRev, ...mutation} = mutationParams - return client.dataRequest('mutate', mutation, { - visibility: 'async', - returnDocuments: false, - tag: 'document.commit', - // This makes sure the studio doesn't crash when a draft is crated - // because someone deleted a referenced document in the target dataset - skipCrossDatasetReferenceValidation: true, - }) -} +import {distinctUntilChanged, type Observable, Subject} from 'rxjs' +import {filter, map} from 'rxjs/operators' -function submitCommitRequest( - client: SanityClient, - idPair: IdPair, - request: CommitRequest, - serverActionsEnabled: boolean, -) { - return from( - serverActionsEnabled - ? commitActions(client, idPair, request.mutation.params) - : commitMutations(client, request.mutation.params), - ).pipe( - tap({ - error: (error) => { - const isBadRequest = - 'statusCode' in error && - typeof error.statusCode === 'number' && - error.statusCode >= 400 && - error.statusCode <= 500 - if (isBadRequest) { - request.cancel(error) - } else { - request.failure(error) - } - }, - next: () => request.success(), - }), - ) -} +import {type BufferedDocumentWrapper} from '../buffered-doc/createBufferedDocument' +import {type IdPair} from '../types' +import {type Pair} from './checkoutPairImplementation' +// eslint-disable-next-line import/no-duplicates +import {type WorkerInput, type WorkerOutput} from './checkoutPairWorker' +// eslint-disable-next-line import/no-duplicates +// import CheckoutPairWorker from './checkoutPairWorker?worker' /** @internal */ export function checkoutPair( @@ -182,59 +17,190 @@ export function checkoutPair( idPair: IdPair, serverActionsEnabled: Observable, ): Pair { - const {publishedId, draftId} = idPair + const input$ = new Subject() + + // const outputConnector = new Subject() + const output$ = new Subject() + // const output$ = outputConnector + // .pipe( + // share({connector: () => outputConnector}), + // ) + // const worker = new CheckoutPairWorker() + console.log('CODY ', typeof __DEV__ === 'boolean' && __DEV__) + const worker = + typeof __DEV__ === 'boolean' && __DEV__ + ? new Worker(new URL('./checkoutPairWorker.ts', import.meta.url), {type: 'module'}) + : new Worker(new URL('../../../../../../web-workers/checkoutPair.mjs', import.meta.url), { + type: 'module', + }) + worker.onmessage = (ev: MessageEvent) => { + console.log('worker.onmessage', ev) + return output$.next(ev.data) + } + worker.onerror = (ev: ErrorEvent) => { + console.log('worker.onerror', ev) + return output$.error(ev) + } - const listenerEventsConnector = new Subject() - const listenerEvents$ = getPairListener(client, idPair).pipe( - share({connector: () => listenerEventsConnector}), - ) + const subscription = input$.subscribe((input) => { + console.log('send worker input', input) + worker.postMessage(input) + }) - const reconnect$ = listenerEvents$.pipe( - filter((ev) => ev.type === 'reconnect'), - ) as Observable + const proxy = (message: WorkerInput): void => { + console.log('worker proxy', message) + // input$.next(message) + worker.postMessage(message) + } - const draft = createBufferedDocument( - draftId, - listenerEvents$.pipe(filter(isMutationEventForDocId(draftId))), + const actionsSub = serverActionsEnabled + .pipe(distinctUntilChanged()) + .subscribe((isServerActionsEnabled) => { + console.log('worker serverActionsEnabled', {isServerActionsEnabled}) + return proxy({ + type: 'construct', + clientConfig: client.config(), + idPair, + serverActionsEnabled: isServerActionsEnabled, + }) + }) + + const transactionsPendingEvents$ = output$.pipe( + filter( + (ev): ev is Extract => + ev.type === 'transactionsPendingEvents$', + ), + map((ev) => ev.payload), ) - const published = createBufferedDocument( - publishedId, - listenerEvents$.pipe(filter(isMutationEventForDocId(publishedId))), - ) + // const worker$ = fromWorker( + // () => new CheckoutPairWorker(), + // input$, + // // ).pipe(share({connector: () => outputConnector})) + // ) + + // worker$.subscribe((event) => { + // console.log('worker event', event) + // }) + + /** + * These need to be handled as worker output: + * - transactionsPendingEvents$ + * - draft.consistency$ + * - draft.events + * - draft.remoteSnapshot$ + * - published.consistency$ + * - published.events + * - published.remoteSnapshot$ + * + * While these should be the worker input: + * - draft.commit + * - draft.create + * - draft.createIfNotExists + * - draft.createOrReplace + * - draft.delete + * - draft.mutate + * - draft.patch + * - published.commit + * - published.create + * - published.createIfNotExists + * - published.createOrReplace + * - published.delete + * - published.mutate + * - published.patch + * - complete + */ + + const shimBufferedDocumentHelpers = (documentId: string) => { + const prepare = (id: string) => (document: Partial) => { + const {_id, _rev, _updatedAt, ...rest} = document + return {_id: id, ...rest} + } - // share commit handling between draft and published - const transactionsPendingEvents$ = listenerEvents$.pipe( - filter((ev): ev is PendingMutationsEvent => ev.type === 'pending'), - ) + const prepareDoc = prepare(documentId) - const commits$ = merge(draft.commitRequest$, published.commitRequest$).pipe( - mergeMap((commitRequest) => - serverActionsEnabled.pipe( - take(1), - mergeMap((canUseServerActions) => - submitCommitRequest(client, idPair, commitRequest, canUseServerActions), - ), - ), - ), - mergeMap(() => EMPTY), - share(), - ) + const DELETE = {delete: {id: documentId}} + + return { + patch: (patches) => patches.map((patch) => ({patch: {...patch, id: documentId}})), + create: (document) => ({create: prepareDoc(document)}), + createIfNotExists: (document) => ({createIfNotExists: prepareDoc(document)}), + createOrReplace: (document) => ({createOrReplace: prepareDoc(document)}), + delete: () => DELETE, + } satisfies Pick< + BufferedDocumentWrapper, + 'patch' | 'create' | 'createIfNotExists' | 'createOrReplace' | 'delete' + > + } + const {publishedId, draftId} = idPair return { transactionsPendingEvents$, draft: { - ...draft, - events: merge(commits$, reconnect$, draft.events).pipe(map(setVersion('draft'))), - consistency$: draft.consistency$, - remoteSnapshot$: draft.remoteSnapshot$.pipe(map(setVersion('draft'))), + ...shimBufferedDocumentHelpers(draftId), + consistency$: output$.pipe( + filter( + (ev): ev is Extract => + ev.type === 'draft.consistency$', + ), + map((ev) => ev.payload), + ), + events: output$.pipe( + filter( + (ev): ev is Extract => ev.type === 'draft.events', + ), + map((ev) => ev.payload), + ), + remoteSnapshot$: output$.pipe( + filter( + (ev): ev is Extract => + ev.type === 'draft.remoteSnapshot$', + ), + map((ev) => ev.payload), + ), + commit: () => proxy({type: 'draft.commit'}), + mutate: (mutations) => proxy({type: 'draft.mutate', payload: mutations}), }, published: { - ...published, - events: merge(commits$, reconnect$, published.events).pipe(map(setVersion('published'))), - consistency$: published.consistency$, - remoteSnapshot$: published.remoteSnapshot$.pipe(map(setVersion('published'))), + ...shimBufferedDocumentHelpers(publishedId), + consistency$: output$.pipe( + filter( + (ev): ev is Extract => + ev.type === 'published.consistency$', + ), + map((ev) => ev.payload), + ), + events: output$.pipe( + filter( + (ev): ev is Extract => + ev.type === 'published.events', + ), + map((ev) => ev.payload), + ), + remoteSnapshot$: output$.pipe( + filter( + (ev): ev is Extract => + ev.type === 'published.remoteSnapshot$', + ), + map((ev) => ev.payload), + ), + commit: () => proxy({type: 'published.commit'}), + mutate: (mutations) => proxy({type: 'published.mutate', payload: mutations}), + }, + complete: () => { + console.warn('complete', 'teardown') + actionsSub.unsubscribe() + subscription.unsubscribe() + worker.terminate() + // return outputConnector.complete() }, - complete: () => listenerEventsConnector.complete(), } } + +export type { + DocumentVersion, + DocumentVersionEvent, + Pair, + RemoteSnapshotVersionEvent, + WithVersion, +} from './checkoutPairImplementation' diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPairImplementation.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPairImplementation.ts new file mode 100644 index 00000000000..cc609b5268c --- /dev/null +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPairImplementation.ts @@ -0,0 +1,242 @@ +import {type Action, type SanityClient} from '@sanity/client' +import {type Mutation} from '@sanity/mutator' +import {type SanityDocument} from '@sanity/types' +import {omit} from 'lodash' +import {EMPTY, from, merge, type Observable, Subject} from 'rxjs' +import {filter, map, mergeMap, share, take, tap} from 'rxjs/operators' + +import { + type BufferedDocumentEvent, + type CommitRequest, + createBufferedDocument, + type MutationPayload, + type RemoteSnapshotEvent, +} from '../buffered-doc' +import {getPairListener, type ListenerEvent} from '../getPairListener' +import {type IdPair, type PendingMutationsEvent, type ReconnectEvent} from '../types' + +const isMutationEventForDocId = + (id: string) => + ( + event: ListenerEvent, + ): event is Exclude => { + return event.type !== 'reconnect' && event.type !== 'pending' && event.documentId === id + } + +/** + * @hidden + * @beta */ +export type WithVersion = T & {version: 'published' | 'draft'} + +/** + * @hidden + * @beta */ +export type DocumentVersionEvent = WithVersion + +/** + * @hidden + * @beta */ +export type RemoteSnapshotVersionEvent = WithVersion + +/** + * @hidden + * @beta */ +export interface DocumentVersion { + consistency$: Observable + remoteSnapshot$: Observable + events: Observable + + patch: (patches: any[]) => MutationPayload[] + create: (document: Partial) => MutationPayload + createIfNotExists: (document: SanityDocument) => MutationPayload + createOrReplace: (document: SanityDocument) => MutationPayload + delete: () => MutationPayload + + mutate: (mutations: MutationPayload[]) => void + commit: () => void +} + +/** + * @hidden + * @beta */ +export interface Pair { + /** @internal */ + transactionsPendingEvents$: Observable + published: DocumentVersion + draft: DocumentVersion + complete: () => void +} + +function setVersion(version: 'draft' | 'published') { + return (ev: T): T & {version: 'draft' | 'published'} => ({...ev, version}) +} + +function requireId( + value: T, +): asserts value is T & {_id: string} { + if (!value._id) { + throw new Error('Expected document to have an _id') + } +} + +//if we're patching a published document directly +//then we're live editing and we should use raw mutations +//rather than actions +function isLiveEditMutation(mutationParams: Mutation['params'], publishedId: string) { + const {resultRev, ...mutation} = mutationParams + const patchTargets: string[] = mutation.mutations.flatMap((mut) => { + const mutationPayloads = Object.values(mut) + if (mutationPayloads.length > 1) { + throw new Error('Did not expect multiple mutations in the same payload') + } + return mutationPayloads[0].id || mutationPayloads[0]._id + }) + return patchTargets.every((target) => target === publishedId) +} + +function toActions(idPair: IdPair, mutationParams: Mutation['params']): Action[] { + return mutationParams.mutations.flatMap((mutations) => { + // This action is not always interoperable with the equivalent mutation. It will fail if the + // published version of the document already exists. + if (mutations.createIfNotExists) { + // ignore all createIfNotExists, as these should be covered by the actions api and only be done locally + return [] + } + if (mutations.create) { + // the actions API requires attributes._id to be set, while it's optional in the mutation API + requireId(mutations.create) + return { + actionType: 'sanity.action.document.create', + publishedId: idPair.publishedId, + attributes: mutations.create, + ifExists: 'fail', + } + } + if (mutations.patch) { + return { + actionType: 'sanity.action.document.edit', + draftId: idPair.draftId, + publishedId: idPair.publishedId, + patch: omit(mutations.patch, 'id'), + } + } + throw new Error('Cannot map mutation to action') + }) +} + +function commitActions(client: SanityClient, idPair: IdPair, mutationParams: Mutation['params']) { + if (isLiveEditMutation(mutationParams, idPair.publishedId)) { + return commitMutations(client, mutationParams) + } + + // @TODO perf investigate + return client.observable.action(toActions(idPair, mutationParams), { + tag: 'document.commit', + transactionId: mutationParams.transactionId, + }) +} + +function commitMutations(client: SanityClient, mutationParams: Mutation['params']) { + const {resultRev, ...mutation} = mutationParams + // @TODO perf investigate + return client.dataRequest('mutate', mutation, { + visibility: 'async', + returnDocuments: false, + tag: 'document.commit', + // This makes sure the studio doesn't crash when a draft is crated + // because someone deleted a referenced document in the target dataset + skipCrossDatasetReferenceValidation: true, + }) +} + +function submitCommitRequest( + client: SanityClient, + idPair: IdPair, + request: CommitRequest, + serverActionsEnabled: boolean, +) { + return from( + serverActionsEnabled + ? commitActions(client, idPair, request.mutation.params) + : commitMutations(client, request.mutation.params), + ).pipe( + tap({ + error: (error) => { + const isBadRequest = + 'statusCode' in error && + typeof error.statusCode === 'number' && + error.statusCode >= 400 && + error.statusCode <= 500 + if (isBadRequest) { + request.cancel(error) + } else { + request.failure(error) + } + }, + next: () => request.success(), + }), + ) +} + +/** @internal */ +export function checkoutPairImplementation( + client: SanityClient, + idPair: IdPair, + serverActionsEnabled: Observable, +): Pair { + const {publishedId, draftId} = idPair + + const listenerEventsConnector = new Subject() + const listenerEvents$ = getPairListener(client, idPair).pipe( + share({connector: () => listenerEventsConnector}), + ) + + const reconnect$ = listenerEvents$.pipe( + filter((ev) => ev.type === 'reconnect'), + ) as Observable + + const draft = createBufferedDocument( + draftId, + listenerEvents$.pipe(filter(isMutationEventForDocId(draftId))), + ) + + const published = createBufferedDocument( + publishedId, + listenerEvents$.pipe(filter(isMutationEventForDocId(publishedId))), + ) + + // share commit handling between draft and published + const transactionsPendingEvents$ = listenerEvents$.pipe( + filter((ev): ev is PendingMutationsEvent => ev.type === 'pending'), + ) + + const commits$ = merge(draft.commitRequest$, published.commitRequest$).pipe( + mergeMap((commitRequest) => + serverActionsEnabled.pipe( + take(1), + mergeMap((canUseServerActions) => + submitCommitRequest(client, idPair, commitRequest, canUseServerActions), + ), + ), + ), + mergeMap(() => EMPTY), + share(), + ) + + return { + transactionsPendingEvents$, + draft: { + ...draft, + events: merge(commits$, reconnect$, draft.events).pipe(map(setVersion('draft'))), + consistency$: draft.consistency$, + remoteSnapshot$: draft.remoteSnapshot$.pipe(map(setVersion('draft'))), + }, + published: { + ...published, + events: merge(commits$, reconnect$, published.events).pipe(map(setVersion('published'))), + consistency$: published.consistency$, + remoteSnapshot$: published.remoteSnapshot$.pipe(map(setVersion('published'))), + }, + complete: () => listenerEventsConnector.complete(), + } +} diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPairWorker.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPairWorker.ts new file mode 100644 index 00000000000..a81c1629b1a --- /dev/null +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPairWorker.ts @@ -0,0 +1,147 @@ +import { + createClient, + type InitializedClientConfig, + // unstable__adapter, + // unstable__environment, +} from '@sanity/client' +import {of, type Subscription} from 'rxjs' + +import {type MutationPayload} from '../buffered-doc/types' +import {type IdPair, type PendingMutationsEvent} from '../types' +import { + checkoutPairImplementation, + type DocumentVersionEvent, + type Pair, + type RemoteSnapshotVersionEvent, +} from './checkoutPairImplementation' + +let instance: Pair | null = null + +// eslint-disable-next-line @typescript-eslint/no-shadow +self.addEventListener('message', (event: MessageEvent) => { + // console.log('Message received from main thread', event.data, { + // unstable__adapter, + // unstable__environment, + // }) + if (isWorkerInput(event.data)) { + if (event.data.type === 'construct') { + if (instance) { + instance.complete() + instance = null + } + const {clientConfig, idPair, serverActionsEnabled} = event.data + const client = createClient(clientConfig) + // console.log('constructing checkout pair on main thread', { + // client, + // idPair, + // serverActionsEnabled, + // }) + instance = checkoutPairImplementation(client, idPair, of(serverActionsEnabled)) + // console.log('instance on main thread', {instance}) + + /** + * Handle forwarding events from observables + */ + const {complete: originalComplete} = instance + + const subscriptions: Subscription[] = [] + + // @TODO try batching proxy send events to see if helps batching and debouncing + subscriptions.push( + instance.transactionsPendingEvents$.subscribe((payload) => { + // console.log('transactionsPendingEvents$', payload) + proxy({type: 'transactionsPendingEvents$', payload}) + }), + instance.draft.consistency$.subscribe((payload) => { + // console.log('draft.consistency$', payload) + proxy({type: 'draft.consistency$', payload}) + }), + instance.draft.events.subscribe((payload) => { + // console.log('draft.events', payload) + proxy({type: 'draft.events', payload}) + }), + instance.draft.remoteSnapshot$.subscribe((payload) => { + // console.log('draft.remoteSnapshot$', payload) + proxy({type: 'draft.remoteSnapshot$', payload}) + }), + instance.published.consistency$.subscribe((payload) => { + // console.log('published.consistency$', payload) + proxy({type: 'published.consistency$', payload}) + }), + instance.published.events.subscribe((payload) => { + // console.log('published.events', payload) + proxy({type: 'published.events', payload}) + }), + instance.published.remoteSnapshot$.subscribe((payload) => { + // console.log('published.remoteSnapshot$', payload) + proxy({type: 'published.remoteSnapshot$', payload}) + }), + ) + + instance.complete = () => { + for (const subscription of subscriptions) { + subscription.unsubscribe() + } + subscriptions.length = 0 + originalComplete() + } + // eslint-disable-next-line no-negated-condition + } else if (!instance) { + throw new Error('Received message before instance was constructed', {cause: event}) + } else { + // console.warn('Handling event', event.data.type, event.data) + switch (event.data.type) { + case 'draft.commit': + instance.draft.commit() + break + case 'draft.mutate': + instance.draft.mutate(event.data.payload) + break + case 'published.commit': + instance.published.commit() + break + case 'published.mutate': + instance.published.mutate(event.data.payload) + break + default: + throw new TypeError(`Unknown event type: ${event.data.type}`, {cause: event}) + } + } + } +}) + +function proxy(message: WorkerOutput): void { + self.postMessage(message) +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function isWorkerInput(data: any): data is WorkerInput { + return typeof data === 'object' && data && 'type' in data && typeof data.type === 'string' +} + +/** @internal */ +export type WorkerInput = + | { + type: 'construct' + clientConfig: InitializedClientConfig + idPair: IdPair + serverActionsEnabled: boolean + } + | {type: 'draft.commit'} + | {type: 'draft.mutate'; payload: MutationPayload[]} + | {type: 'published.commit'} + | {type: 'published.mutate'; payload: MutationPayload[]} + /* request shutdown */ + | {type: 'complete'} + +/** @internal */ +export type WorkerOutput = + | {type: 'transactionsPendingEvents$'; payload: PendingMutationsEvent} + | {type: 'draft.consistency$'; payload: boolean} + | {type: 'draft.events'; payload: DocumentVersionEvent} + | {type: 'draft.remoteSnapshot$'; payload: RemoteSnapshotVersionEvent} + | {type: 'published.consistency$'; payload: boolean} + | {type: 'published.events'; payload: DocumentVersionEvent} + | {type: 'published.remoteSnapshot$'; payload: RemoteSnapshotVersionEvent} + /* shutdown complete, safe to terminate worker */ + | {type: 'completed'} diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/documentEvents.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/documentEvents.ts index 6e127a213cc..0e9a8b9daec 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/documentEvents.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/documentEvents.ts @@ -17,6 +17,7 @@ export const documentEvents = memoize( typeName: string, serverActionsEnabled: Observable, ): Observable => { + // @TODO test worker implementation here return memoizedPair(client, idPair, typeName, serverActionsEnabled).pipe( switchMap(({draft, published}) => merge(draft.events, published.events)), ) diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/memoizedPair.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/memoizedPair.ts index 6a940c01df1..b3fb9b51b6c 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/memoizedPair.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/memoizedPair.ts @@ -19,6 +19,7 @@ export const memoizedPair: ( _typeName: string, serverActionsEnabled: Observable, ): Observable => { + // @TODO test worker implementation here return new Observable((subscriber) => { const pair = checkoutPair(client, idPair, serverActionsEnabled) subscriber.next(pair) diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/operations/helpers.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/operations/helpers.ts index 4c5c970cacd..b9e68494c18 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/operations/helpers.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/operations/helpers.ts @@ -42,6 +42,7 @@ export const GUARDED: OperationsAPI = { const createEmitter = (operationName: keyof OperationsAPI, idPair: IdPair, typeName: string) => (...executeArgs: any[]) => + // @TODO this causes a blocking render loop emitOperation(operationName, idPair, typeName, executeArgs) function wrap( diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/remoteSnapshots.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/remoteSnapshots.ts index 91db8f91fde..dd6f7f5212d 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/remoteSnapshots.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/remoteSnapshots.ts @@ -16,6 +16,7 @@ export const remoteSnapshots = memoize( typeName: string, serverActionsEnabled: Observable, ): Observable => { + // @TODO test worker implementation here return memoizedPair(client, idPair, typeName, serverActionsEnabled).pipe( switchMap(({published, draft}) => merge(published.remoteSnapshot$, draft.remoteSnapshot$)), ) diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/snapshotPair.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/snapshotPair.ts index 0efc43a5461..330a38f488f 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/snapshotPair.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/snapshotPair.ts @@ -67,6 +67,7 @@ export const snapshotPair = memoize( typeName: string, serverActionsEnabled: Observable, ): Observable => { + // @TODO test worker implementation here return memoizedPair(client, idPair, typeName, serverActionsEnabled).pipe( map(({published, draft, transactionsPendingEvents$}): SnapshotPair => { return { diff --git a/packages/sanity/src/core/store/_legacy/document/document-store.ts b/packages/sanity/src/core/store/_legacy/document/document-store.ts index 64ed02d48cc..7ed48ea3780 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-store.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-store.ts @@ -114,6 +114,7 @@ export function createDocumentStore({ return { // Public API checkoutPair(idPair) { + // @TODO test worker implementation here return checkoutPair(client, idPair, serverActionsEnabled) }, initialValue(opts, context) { diff --git a/packages/sanity/src/core/store/_legacy/document/getPairListener.ts b/packages/sanity/src/core/store/_legacy/document/getPairListener.ts index aadbc5384c0..d97af20f586 100644 --- a/packages/sanity/src/core/store/_legacy/document/getPairListener.ts +++ b/packages/sanity/src/core/store/_legacy/document/getPairListener.ts @@ -2,7 +2,7 @@ import {type SanityClient} from '@sanity/client' import {type SanityDocument} from '@sanity/types' import {groupBy} from 'lodash' -import {defer, type Observable, of as observableOf, of, timer} from 'rxjs' +import {defer, type Observable, of as observableOf} from 'rxjs' import {concatMap, map, mergeMap, scan} from 'rxjs/operators' import { @@ -124,9 +124,6 @@ export function getPairListener( ), // note: this flattens the array, and in the case of an empty array, no event will be pushed downstream mergeMap((v) => v.next), - concatMap((result) => - (window as any).SLOW ? timer(10000).pipe(map(() => result)) : of(result), - ), ) function fetchInitialDocumentSnapshots(): Observable { diff --git a/packages/sanity/src/core/store/_legacy/grants/grantsStore.ts b/packages/sanity/src/core/store/_legacy/grants/grantsStore.ts index f2ffdaf812c..7cca11d967e 100644 --- a/packages/sanity/src/core/store/_legacy/grants/grantsStore.ts +++ b/packages/sanity/src/core/store/_legacy/grants/grantsStore.ts @@ -76,6 +76,7 @@ export type GrantsStoreOptions = GrantsStoreOptionsCurrentUser | GrantsStoreOpti /** @internal */ export function createGrantsStore(opts: GrantsStoreOptions): GrantsStore { + // @TODO perf test, somehow `evaluateQuery` from `groq-js` is called more often than it should be, as aresult of `matchesFilter` const {client} = opts const versionedClient = client.withConfig({apiVersion: '2021-06-07'}) const userId = 'userId' in opts ? opts.userId : opts?.currentUser?.id || null diff --git a/packages/sanity/src/core/store/_legacy/presence/useGlobalPresence.tsx b/packages/sanity/src/core/store/_legacy/presence/useGlobalPresence.tsx index 928976cfaab..7be55822b53 100644 --- a/packages/sanity/src/core/store/_legacy/presence/useGlobalPresence.tsx +++ b/packages/sanity/src/core/store/_legacy/presence/useGlobalPresence.tsx @@ -1,20 +1,22 @@ -import {useEffect, useState} from 'react' +// import {useEffect, useState} from 'react' +import {useObservable} from 'react-rx' import {usePresenceStore} from '../datastores' import {type GlobalPresence} from './types' /** @internal */ export function useGlobalPresence(): GlobalPresence[] { - const [presence, setPresence] = useState([]) + // const [presence, setPresence] = useState([]) const presenceStore = usePresenceStore() + return useObservable(presenceStore.globalPresence$, []) - useEffect(() => { - const subscription = presenceStore.globalPresence$.subscribe(setPresence) + // useEffect(() => { + // const subscription = presenceStore.globalPresence$.subscribe(setPresence) - return () => { - subscription.unsubscribe() - } - }, [presenceStore]) + // return () => { + // subscription.unsubscribe() + // } + // }, [presenceStore]) - return presence + // return presence } diff --git a/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx b/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx index 6dafff63f5d..d1fad1e6068 100644 --- a/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx +++ b/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx @@ -305,9 +305,11 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => { }) patchRef.current = (event: PatchEvent) => { + // @TODO speed up this chain patch.execute(toMutationPatches(event.patches), initialValue.value) } + // @TODO speed this up const handleChange = useCallback((event: PatchEvent) => patchRef.current(event), []) const closeInspector = useCallback( diff --git a/packages/sanity/turbo.json b/packages/sanity/turbo.json index 318165de572..164eaeb8ebd 100644 --- a/packages/sanity/turbo.json +++ b/packages/sanity/turbo.json @@ -16,6 +16,11 @@ "outputs": [ "dist/**" ] + }, + "build:web-workers": { + "outputs": [ + "web-workers/**" + ] } } } diff --git a/packages/sanity/web-workers/checkoutPair.mjs b/packages/sanity/web-workers/checkoutPair.mjs new file mode 100644 index 00000000000..df7a4a707e7 --- /dev/null +++ b/packages/sanity/web-workers/checkoutPair.mjs @@ -0,0 +1,11460 @@ +var Yw = Object.defineProperty; +var Vw = (r, e, n) => e in r ? Yw(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n; +var W = (r, e, n) => (Vw(r, typeof e != "symbol" ? e + "" : e, n), n); +const Nl = typeof navigator > "u" ? !1 : navigator.product === "ReactNative", ql = { timeout: Nl ? 6e4 : 12e4 }, Zw = function(r) { + const e = { + ...ql, + ...typeof r == "string" ? { url: r } : r + }; + if (e.timeout = Wl(e.timeout), e.query) { + const { url: n, searchParams: s } = Qw(e.url); + for (const [a, u] of Object.entries(e.query)) { + if (u !== void 0) + if (Array.isArray(u)) + for (const l of u) + s.append(a, l); + else + s.append(a, u); + const f = s.toString(); + f && (e.url = `${n}?${f}`); + } + } + return e.method = e.body && !e.method ? "POST" : (e.method || "GET").toUpperCase(), e; +}; +function Qw(r) { + const e = r.indexOf("?"); + if (e === -1) + return { url: r, searchParams: new URLSearchParams() }; + const n = r.slice(0, e), s = r.slice(e + 1); + if (!Nl) + return { url: n, searchParams: new URLSearchParams(s) }; + if (typeof decodeURIComponent != "function") + throw new Error( + "Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined" + ); + const a = new URLSearchParams(); + for (const u of s.split("&")) { + const [f, l] = u.split("="); + f && a.append(jf(f), jf(l || "")); + } + return { url: n, searchParams: a }; +} +function jf(r) { + return decodeURIComponent(r.replace(/\+/g, " ")); +} +function Wl(r) { + if (r === !1 || r === 0) + return !1; + if (r.connect || r.socket) + return r; + const e = Number(r); + return isNaN(e) ? Wl(ql.timeout) : { connect: e, socket: e }; +} +const t1 = /^https?:\/\//i, e1 = function(r) { + if (!t1.test(r.url)) + throw new Error(`"${r.url}" is not a valid URL`); +}; +function n1(r) { + return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; +} +const r1 = (r) => function(e, n, ...s) { + const a = e === "onError"; + let u = n; + for (let f = 0; f < r[e].length; f++) { + const l = r[e][f]; + if (u = l(u, ...s), a && !u) + break; + } + return u; +}; +function i1() { + const r = /* @__PURE__ */ Object.create(null); + let e = 0; + function n(a) { + const u = e++; + return r[u] = a, function() { + delete r[u]; + }; + } + function s(a) { + for (const u in r) + r[u](a); + } + return { + publish: s, + subscribe: n + }; +} +const s1 = [ + "request", + "response", + "progress", + "error", + "abort" +], zf = [ + "processOptions", + "validateOptions", + "interceptRequest", + "finalizeOptions", + "onRequest", + "onResponse", + "onError", + "onReturn", + "onHeaders" +]; +function Bl(r, e) { + const n = [], s = zf.reduce( + (u, f) => (u[f] = u[f] || [], u), + { + processOptions: [Zw], + validateOptions: [e1] + } + ); + function a(u) { + const f = (I, O, R) => { + let x = I, D = O; + if (!x) + try { + D = d("onResponse", O, R); + } catch (U) { + D = null, x = U; + } + x = x && d("onError", x, R), x ? l.error.publish(x) : D && l.response.publish(D); + }, l = s1.reduce((I, O) => (I[O] = i1(), I), {}), d = r1(s), y = d("processOptions", u); + d("validateOptions", y); + const p = { options: y, channels: l, applyMiddleware: d }; + let m; + const b = l.request.subscribe((I) => { + m = e(I, (O, R) => f(O, R, I)); + }); + l.abort.subscribe(() => { + b(), m && m.abort(); + }); + const C = d("onReturn", l, p); + return C === l && l.request.publish(p), C; + } + return a.use = function(u) { + if (!u) + throw new Error("Tried to add middleware that resolved to falsey value"); + if (typeof u == "function") + throw new Error( + "Tried to add middleware that was a function. It probably expects you to pass options to it." + ); + if (u.onReturn && s.onReturn.length > 0) + throw new Error( + "Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event" + ); + return zf.forEach((f) => { + u[f] && s[f].push(u[f]); + }), n.push(u), a; + }, a.clone = () => Bl(n, e), r.forEach(a.use), a; +} +var La = function(r) { + return r.replace(/^\s+|\s+$/g, ""); +}, o1 = function(r) { + return Object.prototype.toString.call(r) === "[object Array]"; +}, a1 = function(r) { + if (!r) + return {}; + for (var e = {}, n = La(r).split(` +`), s = 0; s < n.length; s++) { + var a = n[s], u = a.indexOf(":"), f = La(a.slice(0, u)).toLowerCase(), l = La(a.slice(u + 1)); + typeof e[f] > "u" ? e[f] = l : o1(e[f]) ? e[f].push(l) : e[f] = [e[f], l]; + } + return e; +}, u1 = /* @__PURE__ */ n1(a1), c1 = Object.defineProperty, Hl = (r) => { + throw TypeError(r); +}, f1 = (r, e, n) => e in r ? c1(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n, Ke = (r, e, n) => f1(r, typeof e != "symbol" ? e + "" : e, n), Gl = (r, e, n) => e.has(r) || Hl("Cannot " + n), Ne = (r, e, n) => (Gl(r, e, "read from private field"), n ? n.call(r) : e.get(r)), ar = (r, e, n) => e.has(r) ? Hl("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, n), Nn = (r, e, n, s) => (Gl(r, e, "write to private field"), e.set(r, n), n), Fs, Ms, Mr, Ds, qn, Us, ks; +class ja { + constructor() { + Ke(this, "onabort"), Ke(this, "onerror"), Ke(this, "onreadystatechange"), Ke(this, "ontimeout"), Ke(this, "readyState", 0), Ke(this, "response"), Ke(this, "responseText", ""), Ke(this, "responseType", ""), Ke(this, "status"), Ke(this, "statusText"), Ke(this, "withCredentials"), ar(this, Fs), ar(this, Ms), ar(this, Mr), ar(this, Ds, {}), ar(this, qn), ar(this, Us, {}), ar(this, ks); + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars -- _async is only declared for typings compatibility + open(e, n, s) { + var a; + Nn(this, Fs, e), Nn(this, Ms, n), Nn(this, Mr, ""), this.readyState = 1, (a = this.onreadystatechange) == null || a.call(this), Nn(this, qn, void 0); + } + abort() { + Ne(this, qn) && Ne(this, qn).abort(); + } + getAllResponseHeaders() { + return Ne(this, Mr); + } + setRequestHeader(e, n) { + Ne(this, Ds)[e] = n; + } + // Allow setting extra fetch init options, needed for runtimes such as Vercel Edge to set `cache` and other options in React Server Components + setInit(e, n = !0) { + Nn(this, Us, e), Nn(this, ks, n); + } + send(e) { + const n = this.responseType !== "arraybuffer", s = { + ...Ne(this, Us), + method: Ne(this, Fs), + headers: Ne(this, Ds), + body: e + }; + typeof AbortController == "function" && Ne(this, ks) && (Nn(this, qn, new AbortController()), typeof EventTarget < "u" && Ne(this, qn).signal instanceof EventTarget && (s.signal = Ne(this, qn).signal)), typeof document < "u" && (s.credentials = this.withCredentials ? "include" : "omit"), fetch(Ne(this, Ms), s).then((a) => { + var u; + return a.headers.forEach((f, l) => { + Nn(this, Mr, Ne(this, Mr) + `${l}: ${f}\r +`); + }), this.status = a.status, this.statusText = a.statusText, this.readyState = 3, (u = this.onreadystatechange) == null || u.call(this), n ? a.text() : a.arrayBuffer(); + }).then((a) => { + var u; + typeof a == "string" ? this.responseText = a : this.response = a, this.readyState = 4, (u = this.onreadystatechange) == null || u.call(this); + }).catch((a) => { + var u, f; + if (a.name === "AbortError") { + (u = this.onabort) == null || u.call(this); + return; + } + (f = this.onerror) == null || f.call(this, a); + }); + } +} +Fs = /* @__PURE__ */ new WeakMap(), Ms = /* @__PURE__ */ new WeakMap(), Mr = /* @__PURE__ */ new WeakMap(), Ds = /* @__PURE__ */ new WeakMap(), qn = /* @__PURE__ */ new WeakMap(), Us = /* @__PURE__ */ new WeakMap(), ks = /* @__PURE__ */ new WeakMap(); +const za = typeof XMLHttpRequest == "function" ? "xhr" : "fetch", l1 = za === "xhr" ? XMLHttpRequest : ja, h1 = (r, e) => { + var n; + const s = r.options, a = r.applyMiddleware("finalizeOptions", s), u = {}, f = r.applyMiddleware("interceptRequest", void 0, { + adapter: za, + context: r + }); + if (f) { + const M = setTimeout(e, 0, null, f); + return { abort: () => clearTimeout(M) }; + } + let l = new l1(); + l instanceof ja && typeof a.fetch == "object" && l.setInit(a.fetch, (n = a.useAbortSignal) != null ? n : !0); + const d = a.headers, y = a.timeout; + let p = !1, m = !1, b = !1; + if (l.onerror = (M) => { + l instanceof ja ? x( + M instanceof Error ? M : new Error(`Request error while attempting to reach is ${a.url}`, { cause: M }) + ) : x( + new Error( + `Request error while attempting to reach is ${a.url}${M.lengthComputable ? `(${M.loaded} of ${M.total} bytes transferred)` : ""}` + ) + ); + }, l.ontimeout = (M) => { + x( + new Error( + `Request timeout while attempting to reach ${a.url}${M.lengthComputable ? `(${M.loaded} of ${M.total} bytes transferred)` : ""}` + ) + ); + }, l.onabort = () => { + R(!0), p = !0; + }, l.onreadystatechange = () => { + O(), !(p || l.readyState !== 4) && l.status !== 0 && U(); + }, l.open( + a.method, + a.url, + !0 + // Always async + ), l.withCredentials = !!a.withCredentials, d && l.setRequestHeader) + for (const M in d) + d.hasOwnProperty(M) && l.setRequestHeader(M, d[M]); + return a.rawBody && (l.responseType = "arraybuffer"), r.applyMiddleware("onRequest", { options: a, adapter: za, request: l, context: r }), l.send(a.body || null), y && (u.connect = setTimeout(() => I("ETIMEDOUT"), y.connect)), { abort: C }; + function C() { + p = !0, l && l.abort(); + } + function I(M) { + b = !0, l.abort(); + const z = new Error( + M === "ESOCKETTIMEDOUT" ? `Socket timed out on request to ${a.url}` : `Connection timed out on request to ${a.url}` + ); + z.code = M, r.channels.error.publish(z); + } + function O() { + y && (R(), u.socket = setTimeout(() => I("ESOCKETTIMEDOUT"), y.socket)); + } + function R(M) { + (M || p || l.readyState >= 2 && u.connect) && clearTimeout(u.connect), u.socket && clearTimeout(u.socket); + } + function x(M) { + if (m) + return; + R(!0), m = !0, l = null; + const z = M || new Error(`Network error while attempting to reach ${a.url}`); + z.isNetworkError = !0, z.request = a, e(z); + } + function D() { + return { + body: l.response || (l.responseType === "" || l.responseType === "text" ? l.responseText : ""), + url: a.url, + method: a.method, + headers: u1(l.getAllResponseHeaders()), + statusCode: l.status, + statusMessage: l.statusText + }; + } + function U() { + if (!(p || m || b)) { + if (l.status === 0) { + x(new Error("Unknown XHR error")); + return; + } + R(), m = !0, e(null, D()); + } + } +}, d1 = (r = [], e = h1) => Bl(r, e); +var Kf = { exports: {} }, $a, Jf; +function p1() { + if (Jf) + return $a; + Jf = 1; + var r = 1e3, e = r * 60, n = e * 60, s = n * 24, a = s * 7, u = s * 365.25; + $a = function(p, m) { + m = m || {}; + var b = typeof p; + if (b === "string" && p.length > 0) + return f(p); + if (b === "number" && isFinite(p)) + return m.long ? d(p) : l(p); + throw new Error( + "val is not a non-empty string or a valid number. val=" + JSON.stringify(p) + ); + }; + function f(p) { + if (p = String(p), !(p.length > 100)) { + var m = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( + p + ); + if (m) { + var b = parseFloat(m[1]), C = (m[2] || "ms").toLowerCase(); + switch (C) { + case "years": + case "year": + case "yrs": + case "yr": + case "y": + return b * u; + case "weeks": + case "week": + case "w": + return b * a; + case "days": + case "day": + case "d": + return b * s; + case "hours": + case "hour": + case "hrs": + case "hr": + case "h": + return b * n; + case "minutes": + case "minute": + case "mins": + case "min": + case "m": + return b * e; + case "seconds": + case "second": + case "secs": + case "sec": + case "s": + return b * r; + case "milliseconds": + case "millisecond": + case "msecs": + case "msec": + case "ms": + return b; + default: + return; + } + } + } + } + function l(p) { + var m = Math.abs(p); + return m >= s ? Math.round(p / s) + "d" : m >= n ? Math.round(p / n) + "h" : m >= e ? Math.round(p / e) + "m" : m >= r ? Math.round(p / r) + "s" : p + "ms"; + } + function d(p) { + var m = Math.abs(p); + return m >= s ? y(p, m, s, "day") : m >= n ? y(p, m, n, "hour") : m >= e ? y(p, m, e, "minute") : m >= r ? y(p, m, r, "second") : p + " ms"; + } + function y(p, m, b, C) { + var I = m >= b * 1.5; + return Math.round(p / b) + " " + C + (I ? "s" : ""); + } + return $a; +} +function g1(r) { + n.debug = n, n.default = n, n.coerce = d, n.disable = u, n.enable = a, n.enabled = f, n.humanize = p1(), n.destroy = y, Object.keys(r).forEach((p) => { + n[p] = r[p]; + }), n.names = [], n.skips = [], n.formatters = {}; + function e(p) { + let m = 0; + for (let b = 0; b < p.length; b++) + m = (m << 5) - m + p.charCodeAt(b), m |= 0; + return n.colors[Math.abs(m) % n.colors.length]; + } + n.selectColor = e; + function n(p) { + let m, b = null, C, I; + function O(...R) { + if (!O.enabled) + return; + const x = O, D = Number(/* @__PURE__ */ new Date()), U = D - (m || D); + x.diff = U, x.prev = m, x.curr = D, m = D, R[0] = n.coerce(R[0]), typeof R[0] != "string" && R.unshift("%O"); + let M = 0; + R[0] = R[0].replace(/%([a-zA-Z%])/g, (z, ht) => { + if (z === "%%") + return "%"; + M++; + const _t = n.formatters[ht]; + if (typeof _t == "function") { + const xt = R[M]; + z = _t.call(x, xt), R.splice(M, 1), M--; + } + return z; + }), n.formatArgs.call(x, R), (x.log || n.log).apply(x, R); + } + return O.namespace = p, O.useColors = n.useColors(), O.color = n.selectColor(p), O.extend = s, O.destroy = n.destroy, Object.defineProperty(O, "enabled", { + enumerable: !0, + configurable: !1, + get: () => b !== null ? b : (C !== n.namespaces && (C = n.namespaces, I = n.enabled(p)), I), + set: (R) => { + b = R; + } + }), typeof n.init == "function" && n.init(O), O; + } + function s(p, m) { + const b = n(this.namespace + (typeof m > "u" ? ":" : m) + p); + return b.log = this.log, b; + } + function a(p) { + n.save(p), n.namespaces = p, n.names = [], n.skips = []; + let m; + const b = (typeof p == "string" ? p : "").split(/[\s,]+/), C = b.length; + for (m = 0; m < C; m++) + b[m] && (p = b[m].replace(/\*/g, ".*?"), p[0] === "-" ? n.skips.push(new RegExp("^" + p.slice(1) + "$")) : n.names.push(new RegExp("^" + p + "$"))); + } + function u() { + const p = [ + ...n.names.map(l), + ...n.skips.map(l).map((m) => "-" + m) + ].join(","); + return n.enable(""), p; + } + function f(p) { + if (p[p.length - 1] === "*") + return !0; + let m, b; + for (m = 0, b = n.skips.length; m < b; m++) + if (n.skips[m].test(p)) + return !1; + for (m = 0, b = n.names.length; m < b; m++) + if (n.names[m].test(p)) + return !0; + return !1; + } + function l(p) { + return p.toString().substring(2, p.toString().length - 2).replace(/\.\*\?$/, "*"); + } + function d(p) { + return p instanceof Error ? p.stack || p.message : p; + } + function y() { + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + return n.enable(n.load()), n; +} +var v1 = g1; +(function(r, e) { + e.formatArgs = s, e.save = a, e.load = u, e.useColors = n, e.storage = f(), e.destroy = /* @__PURE__ */ (() => { + let d = !1; + return () => { + d || (d = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")); + }; + })(), e.colors = [ + "#0000CC", + "#0000FF", + "#0033CC", + "#0033FF", + "#0066CC", + "#0066FF", + "#0099CC", + "#0099FF", + "#00CC00", + "#00CC33", + "#00CC66", + "#00CC99", + "#00CCCC", + "#00CCFF", + "#3300CC", + "#3300FF", + "#3333CC", + "#3333FF", + "#3366CC", + "#3366FF", + "#3399CC", + "#3399FF", + "#33CC00", + "#33CC33", + "#33CC66", + "#33CC99", + "#33CCCC", + "#33CCFF", + "#6600CC", + "#6600FF", + "#6633CC", + "#6633FF", + "#66CC00", + "#66CC33", + "#9900CC", + "#9900FF", + "#9933CC", + "#9933FF", + "#99CC00", + "#99CC33", + "#CC0000", + "#CC0033", + "#CC0066", + "#CC0099", + "#CC00CC", + "#CC00FF", + "#CC3300", + "#CC3333", + "#CC3366", + "#CC3399", + "#CC33CC", + "#CC33FF", + "#CC6600", + "#CC6633", + "#CC9900", + "#CC9933", + "#CCCC00", + "#CCCC33", + "#FF0000", + "#FF0033", + "#FF0066", + "#FF0099", + "#FF00CC", + "#FF00FF", + "#FF3300", + "#FF3333", + "#FF3366", + "#FF3399", + "#FF33CC", + "#FF33FF", + "#FF6600", + "#FF6633", + "#FF9900", + "#FF9933", + "#FFCC00", + "#FFCC33" + ]; + function n() { + return typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs) ? !0 : typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/) ? !1 : typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 + typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker + typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); + } + function s(d) { + if (d[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + d[0] + (this.useColors ? "%c " : " ") + "+" + r.exports.humanize(this.diff), !this.useColors) + return; + const y = "color: " + this.color; + d.splice(1, 0, y, "color: inherit"); + let p = 0, m = 0; + d[0].replace(/%[a-zA-Z%]/g, (b) => { + b !== "%%" && (p++, b === "%c" && (m = p)); + }), d.splice(m, 0, y); + } + e.log = console.debug || console.log || (() => { + }); + function a(d) { + try { + d ? e.storage.setItem("debug", d) : e.storage.removeItem("debug"); + } catch { + } + } + function u() { + let d; + try { + d = e.storage.getItem("debug"); + } catch { + } + return !d && typeof process < "u" && "env" in process && (d = {}.DEBUG), d; + } + function f() { + try { + return localStorage; + } catch { + } + } + r.exports = v1(e); + const { formatters: l } = r.exports; + l.j = function(d) { + try { + return JSON.stringify(d); + } catch (y) { + return "[UnexpectedJSONParseError]: " + y.message; + } + }; +})(Kf, Kf.exports); +const m1 = typeof Buffer > "u" ? () => !1 : (r) => Buffer.isBuffer(r); +/*! + * is-plain-object + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ +function Xf(r) { + return Object.prototype.toString.call(r) === "[object Object]"; +} +function y1(r) { + if (Xf(r) === !1) + return !1; + const e = r.constructor; + if (e === void 0) + return !0; + const n = e.prototype; + return !(Xf(n) === !1 || // eslint-disable-next-line no-prototype-builtins + n.hasOwnProperty("isPrototypeOf") === !1); +} +const w1 = ["boolean", "string", "number"]; +function b1() { + return { + processOptions: (r) => { + const e = r.body; + return !e || !(typeof e.pipe != "function" && !m1(e) && (w1.indexOf(typeof e) !== -1 || Array.isArray(e) || y1(e))) ? r : Object.assign({}, r, { + body: JSON.stringify(r.body), + headers: Object.assign({}, r.headers, { + "Content-Type": "application/json" + }) + }); + } + }; +} +function _1(r) { + return { + onResponse: (n) => { + const s = n.headers["content-type"] || "", a = r && r.force || s.indexOf("application/json") !== -1; + return !n.body || !s || !a ? n : Object.assign({}, n, { body: e(n.body) }); + }, + processOptions: (n) => Object.assign({}, n, { + headers: Object.assign({ Accept: "application/json" }, n.headers) + }) + }; + function e(n) { + try { + return JSON.parse(n); + } catch (s) { + throw s.message = `Failed to parsed response body as JSON: ${s.message}`, s; + } + } +} +let vi = {}; +typeof globalThis < "u" ? vi = globalThis : typeof window < "u" ? vi = window : typeof global < "u" ? vi = global : typeof self < "u" && (vi = self); +var C1 = vi; +function E1(r = {}) { + const e = ( + // eslint-disable-next-line @typescript-eslint/no-explicit-any -- @TODO consider dropping checking for a global Observable since it's not on a standards track + r.implementation || C1.Observable + ); + if (!e) + throw new Error( + "`Observable` is not available in global scope, and no implementation was passed" + ); + return { + onReturn: (n, s) => new e((a) => (n.error.subscribe((u) => a.error(u)), n.progress.subscribe( + (u) => a.next(Object.assign({ type: "progress" }, u)) + ), n.response.subscribe((u) => { + a.next(Object.assign({ type: "response" }, u)), a.complete(); + }), n.request.publish(s), () => n.abort.publish())) + }; +} +function A1() { + return { + onRequest: (r) => { + if (r.adapter !== "xhr") + return; + const e = r.request, n = r.context; + "upload" in e && "onprogress" in e.upload && (e.upload.onprogress = s("upload")), "onprogress" in e && (e.onprogress = s("download")); + function s(a) { + return (u) => { + const f = u.lengthComputable ? u.loaded / u.total * 100 : -1; + n.channels.progress.publish({ + stage: a, + percent: f, + total: u.total, + loaded: u.loaded, + lengthComputable: u.lengthComputable + }); + }; + } + } + }; +} +var x1 = Object.defineProperty, S1 = (r, e, n) => e in r ? x1(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n, Si = (r, e, n) => S1(r, typeof e != "symbol" ? e + "" : e, n); +class R1 { + constructor(e) { + Si(this, "__CANCEL__", !0), Si(this, "message"), this.message = e; + } + toString() { + return `Cancel${this.message ? `: ${this.message}` : ""}`; + } +} +const Yf = class { + constructor(r) { + if (Si(this, "promise"), Si(this, "reason"), typeof r != "function") + throw new TypeError("executor must be a function."); + let e = null; + this.promise = new Promise((n) => { + e = n; + }), r((n) => { + this.reason || (this.reason = new R1(n), e(this.reason)); + }); + } +}; +Si(Yf, "source", () => { + let r; + return { + token: new Yf((e) => { + r = e; + }), + cancel: r + }; +}); +var jl = (r, e, n) => n.method !== "GET" && n.method !== "HEAD" ? !1 : r.isNetworkError || !1; +const I1 = (r) => r !== null && typeof r == "object" && typeof r.pipe == "function"; +var O1 = (r) => { + const e = r.maxRetries || 5, n = r.retryDelay || T1, s = r.shouldRetry; + return { + onError: (a, u) => { + const f = u.options, l = f.maxRetries || e, d = f.retryDelay || n, y = f.shouldRetry || s, p = f.attemptNumber || 0; + if (I1(f.body) || !y(a, p, f) || p >= l) + return a; + const m = Object.assign({}, u, { + options: Object.assign({}, f, { attemptNumber: p + 1 }) + }); + return setTimeout(() => u.channels.request.publish(m), d(p)), null; + } + }; +}; +function T1(r) { + return 100 * Math.pow(2, r) + Math.random() * 100; +} +const ou = (r = {}) => O1({ shouldRetry: jl, ...r }); +ou.shouldRetry = jl; +var Ka = function(r, e) { + return Ka = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, s) { + n.__proto__ = s; + } || function(n, s) { + for (var a in s) + Object.prototype.hasOwnProperty.call(s, a) && (n[a] = s[a]); + }, Ka(r, e); +}; +function Jn(r, e) { + if (typeof e != "function" && e !== null) + throw new TypeError("Class extends value " + String(e) + " is not a constructor or null"); + Ka(r, e); + function n() { + this.constructor = r; + } + r.prototype = e === null ? Object.create(e) : (n.prototype = e.prototype, new n()); +} +function L1(r, e, n, s) { + function a(u) { + return u instanceof n ? u : new n(function(f) { + f(u); + }); + } + return new (n || (n = Promise))(function(u, f) { + function l(p) { + try { + y(s.next(p)); + } catch (m) { + f(m); + } + } + function d(p) { + try { + y(s.throw(p)); + } catch (m) { + f(m); + } + } + function y(p) { + p.done ? u(p.value) : a(p.value).then(l, d); + } + y((s = s.apply(r, e || [])).next()); + }); +} +function zl(r, e) { + var n = { label: 0, sent: function() { + if (u[0] & 1) + throw u[1]; + return u[1]; + }, trys: [], ops: [] }, s, a, u, f; + return f = { next: l(0), throw: l(1), return: l(2) }, typeof Symbol == "function" && (f[Symbol.iterator] = function() { + return this; + }), f; + function l(y) { + return function(p) { + return d([y, p]); + }; + } + function d(y) { + if (s) + throw new TypeError("Generator is already executing."); + for (; f && (f = 0, y[0] && (n = 0)), n; ) + try { + if (s = 1, a && (u = y[0] & 2 ? a.return : y[0] ? a.throw || ((u = a.return) && u.call(a), 0) : a.next) && !(u = u.call(a, y[1])).done) + return u; + switch (a = 0, u && (y = [y[0] & 2, u.value]), y[0]) { + case 0: + case 1: + u = y; + break; + case 4: + return n.label++, { value: y[1], done: !1 }; + case 5: + n.label++, a = y[1], y = [0]; + continue; + case 7: + y = n.ops.pop(), n.trys.pop(); + continue; + default: + if (u = n.trys, !(u = u.length > 0 && u[u.length - 1]) && (y[0] === 6 || y[0] === 2)) { + n = 0; + continue; + } + if (y[0] === 3 && (!u || y[1] > u[0] && y[1] < u[3])) { + n.label = y[1]; + break; + } + if (y[0] === 6 && n.label < u[1]) { + n.label = u[1], u = y; + break; + } + if (u && n.label < u[2]) { + n.label = u[2], n.ops.push(y); + break; + } + u[2] && n.ops.pop(), n.trys.pop(); + continue; + } + y = e.call(r, n); + } catch (p) { + y = [6, p], a = 0; + } finally { + s = u = 0; + } + if (y[0] & 5) + throw y[1]; + return { value: y[0] ? y[1] : void 0, done: !0 }; + } +} +function zr(r) { + var e = typeof Symbol == "function" && Symbol.iterator, n = e && r[e], s = 0; + if (n) + return n.call(r); + if (r && typeof r.length == "number") + return { + next: function() { + return r && s >= r.length && (r = void 0), { value: r && r[s++], done: !r }; + } + }; + throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined."); +} +function Ye(r, e) { + var n = typeof Symbol == "function" && r[Symbol.iterator]; + if (!n) + return r; + var s = n.call(r), a, u = [], f; + try { + for (; (e === void 0 || e-- > 0) && !(a = s.next()).done; ) + u.push(a.value); + } catch (l) { + f = { error: l }; + } finally { + try { + a && !a.done && (n = s.return) && n.call(s); + } finally { + if (f) + throw f.error; + } + } + return u; +} +function Ve(r, e, n) { + if (n || arguments.length === 2) + for (var s = 0, a = e.length, u; s < a; s++) + (u || !(s in e)) && (u || (u = Array.prototype.slice.call(e, 0, s)), u[s] = e[s]); + return r.concat(u || Array.prototype.slice.call(e)); +} +function Br(r) { + return this instanceof Br ? (this.v = r, this) : new Br(r); +} +function $1(r, e, n) { + if (!Symbol.asyncIterator) + throw new TypeError("Symbol.asyncIterator is not defined."); + var s = n.apply(r, e || []), a, u = []; + return a = {}, l("next"), l("throw"), l("return", f), a[Symbol.asyncIterator] = function() { + return this; + }, a; + function f(C) { + return function(I) { + return Promise.resolve(I).then(C, m); + }; + } + function l(C, I) { + s[C] && (a[C] = function(O) { + return new Promise(function(R, x) { + u.push([C, O, R, x]) > 1 || d(C, O); + }); + }, I && (a[C] = I(a[C]))); + } + function d(C, I) { + try { + y(s[C](I)); + } catch (O) { + b(u[0][3], O); + } + } + function y(C) { + C.value instanceof Br ? Promise.resolve(C.value.v).then(p, m) : b(u[0][2], C); + } + function p(C) { + d("next", C); + } + function m(C) { + d("throw", C); + } + function b(C, I) { + C(I), u.shift(), u.length && d(u[0][0], u[0][1]); + } +} +function P1(r) { + if (!Symbol.asyncIterator) + throw new TypeError("Symbol.asyncIterator is not defined."); + var e = r[Symbol.asyncIterator], n; + return e ? e.call(r) : (r = typeof zr == "function" ? zr(r) : r[Symbol.iterator](), n = {}, s("next"), s("throw"), s("return"), n[Symbol.asyncIterator] = function() { + return this; + }, n); + function s(u) { + n[u] = r[u] && function(f) { + return new Promise(function(l, d) { + f = r[u](f), a(l, d, f.done, f.value); + }); + }; + } + function a(u, f, l, d) { + Promise.resolve(d).then(function(y) { + u({ value: y, done: l }); + }, f); + } +} +function bt(r) { + return typeof r == "function"; +} +function au(r) { + var e = function(s) { + Error.call(s), s.stack = new Error().stack; + }, n = r(e); + return n.prototype = Object.create(Error.prototype), n.prototype.constructor = n, n; +} +var Pa = au(function(r) { + return function(n) { + r(this), this.message = n ? n.length + ` errors occurred during unsubscription: +` + n.map(function(s, a) { + return a + 1 + ") " + s.toString(); + }).join(` + `) : "", this.name = "UnsubscriptionError", this.errors = n; + }; +}); +function Ja(r, e) { + if (r) { + var n = r.indexOf(e); + 0 <= n && r.splice(n, 1); + } +} +var Kr = function() { + function r(e) { + this.initialTeardown = e, this.closed = !1, this._parentage = null, this._finalizers = null; + } + return r.prototype.unsubscribe = function() { + var e, n, s, a, u; + if (!this.closed) { + this.closed = !0; + var f = this._parentage; + if (f) + if (this._parentage = null, Array.isArray(f)) + try { + for (var l = zr(f), d = l.next(); !d.done; d = l.next()) { + var y = d.value; + y.remove(this); + } + } catch (O) { + e = { error: O }; + } finally { + try { + d && !d.done && (n = l.return) && n.call(l); + } finally { + if (e) + throw e.error; + } + } + else + f.remove(this); + var p = this.initialTeardown; + if (bt(p)) + try { + p(); + } catch (O) { + u = O instanceof Pa ? O.errors : [O]; + } + var m = this._finalizers; + if (m) { + this._finalizers = null; + try { + for (var b = zr(m), C = b.next(); !C.done; C = b.next()) { + var I = C.value; + try { + Vf(I); + } catch (O) { + u = u ?? [], O instanceof Pa ? u = Ve(Ve([], Ye(u)), Ye(O.errors)) : u.push(O); + } + } + } catch (O) { + s = { error: O }; + } finally { + try { + C && !C.done && (a = b.return) && a.call(b); + } finally { + if (s) + throw s.error; + } + } + } + if (u) + throw new Pa(u); + } + }, r.prototype.add = function(e) { + var n; + if (e && e !== this) + if (this.closed) + Vf(e); + else { + if (e instanceof r) { + if (e.closed || e._hasParent(this)) + return; + e._addParent(this); + } + (this._finalizers = (n = this._finalizers) !== null && n !== void 0 ? n : []).push(e); + } + }, r.prototype._hasParent = function(e) { + var n = this._parentage; + return n === e || Array.isArray(n) && n.includes(e); + }, r.prototype._addParent = function(e) { + var n = this._parentage; + this._parentage = Array.isArray(n) ? (n.push(e), n) : n ? [n, e] : e; + }, r.prototype._removeParent = function(e) { + var n = this._parentage; + n === e ? this._parentage = null : Array.isArray(n) && Ja(n, e); + }, r.prototype.remove = function(e) { + var n = this._finalizers; + n && Ja(n, e), e instanceof r && e._removeParent(this); + }, r.EMPTY = function() { + var e = new r(); + return e.closed = !0, e; + }(), r; +}(), Kl = Kr.EMPTY; +function Jl(r) { + return r instanceof Kr || r && "closed" in r && bt(r.remove) && bt(r.add) && bt(r.unsubscribe); +} +function Vf(r) { + bt(r) ? r() : r.unsubscribe(); +} +var Xl = { + onUnhandledError: null, + onStoppedNotification: null, + Promise: void 0, + useDeprecatedSynchronousErrorHandling: !1, + useDeprecatedNextContext: !1 +}, Xa = { + setTimeout: function(r, e) { + for (var n = [], s = 2; s < arguments.length; s++) + n[s - 2] = arguments[s]; + var a = Xa.delegate; + return a != null && a.setTimeout ? a.setTimeout.apply(a, Ve([r, e], Ye(n))) : setTimeout.apply(void 0, Ve([r, e], Ye(n))); + }, + clearTimeout: function(r) { + var e = Xa.delegate; + return ((e == null ? void 0 : e.clearTimeout) || clearTimeout)(r); + }, + delegate: void 0 +}; +function Yl(r) { + Xa.setTimeout(function() { + throw r; + }); +} +function Ya() { +} +function Ns(r) { + r(); +} +var uu = function(r) { + Jn(e, r); + function e(n) { + var s = r.call(this) || this; + return s.isStopped = !1, n ? (s.destination = n, Jl(n) && n.add(s)) : s.destination = U1, s; + } + return e.create = function(n, s, a) { + return new Ri(n, s, a); + }, e.prototype.next = function(n) { + this.isStopped || this._next(n); + }, e.prototype.error = function(n) { + this.isStopped || (this.isStopped = !0, this._error(n)); + }, e.prototype.complete = function() { + this.isStopped || (this.isStopped = !0, this._complete()); + }, e.prototype.unsubscribe = function() { + this.closed || (this.isStopped = !0, r.prototype.unsubscribe.call(this), this.destination = null); + }, e.prototype._next = function(n) { + this.destination.next(n); + }, e.prototype._error = function(n) { + try { + this.destination.error(n); + } finally { + this.unsubscribe(); + } + }, e.prototype._complete = function() { + try { + this.destination.complete(); + } finally { + this.unsubscribe(); + } + }, e; +}(Kr), F1 = Function.prototype.bind; +function Fa(r, e) { + return F1.call(r, e); +} +var M1 = function() { + function r(e) { + this.partialObserver = e; + } + return r.prototype.next = function(e) { + var n = this.partialObserver; + if (n.next) + try { + n.next(e); + } catch (s) { + xs(s); + } + }, r.prototype.error = function(e) { + var n = this.partialObserver; + if (n.error) + try { + n.error(e); + } catch (s) { + xs(s); + } + else + xs(e); + }, r.prototype.complete = function() { + var e = this.partialObserver; + if (e.complete) + try { + e.complete(); + } catch (n) { + xs(n); + } + }, r; +}(), Ri = function(r) { + Jn(e, r); + function e(n, s, a) { + var u = r.call(this) || this, f; + if (bt(n) || !n) + f = { + next: n ?? void 0, + error: s ?? void 0, + complete: a ?? void 0 + }; + else { + var l; + u && Xl.useDeprecatedNextContext ? (l = Object.create(n), l.unsubscribe = function() { + return u.unsubscribe(); + }, f = { + next: n.next && Fa(n.next, l), + error: n.error && Fa(n.error, l), + complete: n.complete && Fa(n.complete, l) + }) : f = n; + } + return u.destination = new M1(f), u; + } + return e; +}(uu); +function xs(r) { + Yl(r); +} +function D1(r) { + throw r; +} +var U1 = { + closed: !0, + next: Ya, + error: D1, + complete: Ya +}, cu = function() { + return typeof Symbol == "function" && Symbol.observable || "@@observable"; +}(); +function Jr(r) { + return r; +} +function k1() { + for (var r = [], e = 0; e < arguments.length; e++) + r[e] = arguments[e]; + return Vl(r); +} +function Vl(r) { + return r.length === 0 ? Jr : r.length === 1 ? r[0] : function(n) { + return r.reduce(function(s, a) { + return a(s); + }, n); + }; +} +var Mt = function() { + function r(e) { + e && (this._subscribe = e); + } + return r.prototype.lift = function(e) { + var n = new r(); + return n.source = this, n.operator = e, n; + }, r.prototype.subscribe = function(e, n, s) { + var a = this, u = q1(e) ? e : new Ri(e, n, s); + return Ns(function() { + var f = a, l = f.operator, d = f.source; + u.add(l ? l.call(u, d) : d ? a._subscribe(u) : a._trySubscribe(u)); + }), u; + }, r.prototype._trySubscribe = function(e) { + try { + return this._subscribe(e); + } catch (n) { + e.error(n); + } + }, r.prototype.forEach = function(e, n) { + var s = this; + return n = Zf(n), new n(function(a, u) { + var f = new Ri({ + next: function(l) { + try { + e(l); + } catch (d) { + u(d), f.unsubscribe(); + } + }, + error: u, + complete: a + }); + s.subscribe(f); + }); + }, r.prototype._subscribe = function(e) { + var n; + return (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(e); + }, r.prototype[cu] = function() { + return this; + }, r.prototype.pipe = function() { + for (var e = [], n = 0; n < arguments.length; n++) + e[n] = arguments[n]; + return Vl(e)(this); + }, r.prototype.toPromise = function(e) { + var n = this; + return e = Zf(e), new e(function(s, a) { + var u; + n.subscribe(function(f) { + return u = f; + }, function(f) { + return a(f); + }, function() { + return s(u); + }); + }); + }, r.create = function(e) { + return new r(e); + }, r; +}(); +function Zf(r) { + var e; + return (e = r ?? Xl.Promise) !== null && e !== void 0 ? e : Promise; +} +function N1(r) { + return r && bt(r.next) && bt(r.error) && bt(r.complete); +} +function q1(r) { + return r && r instanceof uu || N1(r) && Jl(r); +} +function Zl(r) { + return bt(r == null ? void 0 : r.lift); +} +function me(r) { + return function(e) { + if (Zl(e)) + return e.lift(function(n) { + try { + return r(n, this); + } catch (s) { + this.error(s); + } + }); + throw new TypeError("Unable to lift unknown Observable type"); + }; +} +function ve(r, e, n, s, a) { + return new W1(r, e, n, s, a); +} +var W1 = function(r) { + Jn(e, r); + function e(n, s, a, u, f, l) { + var d = r.call(this, n) || this; + return d.onFinalize = f, d.shouldUnsubscribe = l, d._next = s ? function(y) { + try { + s(y); + } catch (p) { + n.error(p); + } + } : r.prototype._next, d._error = u ? function(y) { + try { + u(y); + } catch (p) { + n.error(p); + } finally { + this.unsubscribe(); + } + } : r.prototype._error, d._complete = a ? function() { + try { + a(); + } catch (y) { + n.error(y); + } finally { + this.unsubscribe(); + } + } : r.prototype._complete, d; + } + return e.prototype.unsubscribe = function() { + var n; + if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) { + var s = this.closed; + r.prototype.unsubscribe.call(this), !s && ((n = this.onFinalize) === null || n === void 0 || n.call(this)); + } + }, e; +}(uu); +function mi() { + return me(function(r, e) { + var n = null; + r._refCount++; + var s = ve(e, void 0, void 0, void 0, function() { + if (!r || r._refCount <= 0 || 0 < --r._refCount) { + n = null; + return; + } + var a = r._connection, u = n; + n = null, a && (!u || a === u) && a.unsubscribe(), e.unsubscribe(); + }); + r.subscribe(s), s.closed || (n = r.connect()); + }); +} +var B1 = function(r) { + Jn(e, r); + function e(n, s) { + var a = r.call(this) || this; + return a.source = n, a.subjectFactory = s, a._subject = null, a._refCount = 0, a._connection = null, Zl(n) && (a.lift = n.lift), a; + } + return e.prototype._subscribe = function(n) { + return this.getSubject().subscribe(n); + }, e.prototype.getSubject = function() { + var n = this._subject; + return (!n || n.isStopped) && (this._subject = this.subjectFactory()), this._subject; + }, e.prototype._teardown = function() { + this._refCount = 0; + var n = this._connection; + this._subject = this._connection = null, n == null || n.unsubscribe(); + }, e.prototype.connect = function() { + var n = this, s = this._connection; + if (!s) { + s = this._connection = new Kr(); + var a = this.getSubject(); + s.add(this.source.subscribe(ve(a, void 0, function() { + n._teardown(), a.complete(); + }, function(u) { + n._teardown(), a.error(u); + }, function() { + return n._teardown(); + }))), s.closed && (this._connection = null, s = Kr.EMPTY); + } + return s; + }, e.prototype.refCount = function() { + return mi()(this); + }, e; +}(Mt), H1 = au(function(r) { + return function() { + r(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed"; + }; +}), Je = function(r) { + Jn(e, r); + function e() { + var n = r.call(this) || this; + return n.closed = !1, n.currentObservers = null, n.observers = [], n.isStopped = !1, n.hasError = !1, n.thrownError = null, n; + } + return e.prototype.lift = function(n) { + var s = new Qf(this, this); + return s.operator = n, s; + }, e.prototype._throwIfClosed = function() { + if (this.closed) + throw new H1(); + }, e.prototype.next = function(n) { + var s = this; + Ns(function() { + var a, u; + if (s._throwIfClosed(), !s.isStopped) { + s.currentObservers || (s.currentObservers = Array.from(s.observers)); + try { + for (var f = zr(s.currentObservers), l = f.next(); !l.done; l = f.next()) { + var d = l.value; + d.next(n); + } + } catch (y) { + a = { error: y }; + } finally { + try { + l && !l.done && (u = f.return) && u.call(f); + } finally { + if (a) + throw a.error; + } + } + } + }); + }, e.prototype.error = function(n) { + var s = this; + Ns(function() { + if (s._throwIfClosed(), !s.isStopped) { + s.hasError = s.isStopped = !0, s.thrownError = n; + for (var a = s.observers; a.length; ) + a.shift().error(n); + } + }); + }, e.prototype.complete = function() { + var n = this; + Ns(function() { + if (n._throwIfClosed(), !n.isStopped) { + n.isStopped = !0; + for (var s = n.observers; s.length; ) + s.shift().complete(); + } + }); + }, e.prototype.unsubscribe = function() { + this.isStopped = this.closed = !0, this.observers = this.currentObservers = null; + }, Object.defineProperty(e.prototype, "observed", { + get: function() { + var n; + return ((n = this.observers) === null || n === void 0 ? void 0 : n.length) > 0; + }, + enumerable: !1, + configurable: !0 + }), e.prototype._trySubscribe = function(n) { + return this._throwIfClosed(), r.prototype._trySubscribe.call(this, n); + }, e.prototype._subscribe = function(n) { + return this._throwIfClosed(), this._checkFinalizedStatuses(n), this._innerSubscribe(n); + }, e.prototype._innerSubscribe = function(n) { + var s = this, a = this, u = a.hasError, f = a.isStopped, l = a.observers; + return u || f ? Kl : (this.currentObservers = null, l.push(n), new Kr(function() { + s.currentObservers = null, Ja(l, n); + })); + }, e.prototype._checkFinalizedStatuses = function(n) { + var s = this, a = s.hasError, u = s.thrownError, f = s.isStopped; + a ? n.error(u) : f && n.complete(); + }, e.prototype.asObservable = function() { + var n = new Mt(); + return n.source = this, n; + }, e.create = function(n, s) { + return new Qf(n, s); + }, e; +}(Mt), Qf = function(r) { + Jn(e, r); + function e(n, s) { + var a = r.call(this) || this; + return a.destination = n, a.source = s, a; + } + return e.prototype.next = function(n) { + var s, a; + (a = (s = this.destination) === null || s === void 0 ? void 0 : s.next) === null || a === void 0 || a.call(s, n); + }, e.prototype.error = function(n) { + var s, a; + (a = (s = this.destination) === null || s === void 0 ? void 0 : s.error) === null || a === void 0 || a.call(s, n); + }, e.prototype.complete = function() { + var n, s; + (s = (n = this.destination) === null || n === void 0 ? void 0 : n.complete) === null || s === void 0 || s.call(n); + }, e.prototype._subscribe = function(n) { + var s, a; + return (a = (s = this.source) === null || s === void 0 ? void 0 : s.subscribe(n)) !== null && a !== void 0 ? a : Kl; + }, e; +}(Je), G1 = function(r) { + Jn(e, r); + function e(n) { + var s = r.call(this) || this; + return s._value = n, s; + } + return Object.defineProperty(e.prototype, "value", { + get: function() { + return this.getValue(); + }, + enumerable: !1, + configurable: !0 + }), e.prototype._subscribe = function(n) { + var s = r.prototype._subscribe.call(this, n); + return !s.closed && n.next(this._value), s; + }, e.prototype.getValue = function() { + var n = this, s = n.hasError, a = n.thrownError, u = n._value; + if (s) + throw a; + return this._throwIfClosed(), u; + }, e.prototype.next = function(n) { + r.prototype.next.call(this, this._value = n); + }, e; +}(Je), Ql = { + now: function() { + return (Ql.delegate || Date).now(); + }, + delegate: void 0 +}, j1 = function(r) { + Jn(e, r); + function e(n, s, a) { + n === void 0 && (n = 1 / 0), s === void 0 && (s = 1 / 0), a === void 0 && (a = Ql); + var u = r.call(this) || this; + return u._bufferSize = n, u._windowTime = s, u._timestampProvider = a, u._buffer = [], u._infiniteTimeWindow = !0, u._infiniteTimeWindow = s === 1 / 0, u._bufferSize = Math.max(1, n), u._windowTime = Math.max(1, s), u; + } + return e.prototype.next = function(n) { + var s = this, a = s.isStopped, u = s._buffer, f = s._infiniteTimeWindow, l = s._timestampProvider, d = s._windowTime; + a || (u.push(n), !f && u.push(l.now() + d)), this._trimBuffer(), r.prototype.next.call(this, n); + }, e.prototype._subscribe = function(n) { + this._throwIfClosed(), this._trimBuffer(); + for (var s = this._innerSubscribe(n), a = this, u = a._infiniteTimeWindow, f = a._buffer, l = f.slice(), d = 0; d < l.length && !n.closed; d += u ? 1 : 2) + n.next(l[d]); + return this._checkFinalizedStatuses(n), s; + }, e.prototype._trimBuffer = function() { + var n = this, s = n._bufferSize, a = n._timestampProvider, u = n._buffer, f = n._infiniteTimeWindow, l = (f ? 1 : 2) * s; + if (s < 1 / 0 && l < u.length && u.splice(0, u.length - l), !f) { + for (var d = a.now(), y = 0, p = 1; p < u.length && u[p] <= d; p += 2) + y = p; + y && u.splice(0, y + 1); + } + }, e; +}(Je), po = new Mt(function(r) { + return r.complete(); +}); +function z1(r) { + return r && bt(r.schedule); +} +function fu(r) { + return r[r.length - 1]; +} +function th(r) { + return bt(fu(r)) ? r.pop() : void 0; +} +function eh(r) { + return z1(fu(r)) ? r.pop() : void 0; +} +function K1(r, e) { + return typeof fu(r) == "number" ? r.pop() : e; +} +var nh = function(r) { + return r && typeof r.length == "number" && typeof r != "function"; +}; +function rh(r) { + return bt(r == null ? void 0 : r.then); +} +function ih(r) { + return bt(r[cu]); +} +function sh(r) { + return Symbol.asyncIterator && bt(r == null ? void 0 : r[Symbol.asyncIterator]); +} +function oh(r) { + return new TypeError("You provided " + (r !== null && typeof r == "object" ? "an invalid object" : "'" + r + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable."); +} +function J1() { + return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator; +} +var ah = J1(); +function uh(r) { + return bt(r == null ? void 0 : r[ah]); +} +function ch(r) { + return $1(this, arguments, function() { + var n, s, a, u; + return zl(this, function(f) { + switch (f.label) { + case 0: + n = r.getReader(), f.label = 1; + case 1: + f.trys.push([1, , 9, 10]), f.label = 2; + case 2: + return [4, Br(n.read())]; + case 3: + return s = f.sent(), a = s.value, u = s.done, u ? [4, Br(void 0)] : [3, 5]; + case 4: + return [2, f.sent()]; + case 5: + return [4, Br(a)]; + case 6: + return [4, f.sent()]; + case 7: + return f.sent(), [3, 2]; + case 8: + return [3, 10]; + case 9: + return n.releaseLock(), [7]; + case 10: + return [2]; + } + }); + }); +} +function fh(r) { + return bt(r == null ? void 0 : r.getReader); +} +function Qe(r) { + if (r instanceof Mt) + return r; + if (r != null) { + if (ih(r)) + return X1(r); + if (nh(r)) + return Y1(r); + if (rh(r)) + return V1(r); + if (sh(r)) + return lh(r); + if (uh(r)) + return Z1(r); + if (fh(r)) + return Q1(r); + } + throw oh(r); +} +function X1(r) { + return new Mt(function(e) { + var n = r[cu](); + if (bt(n.subscribe)) + return n.subscribe(e); + throw new TypeError("Provided object does not correctly implement Symbol.observable"); + }); +} +function Y1(r) { + return new Mt(function(e) { + for (var n = 0; n < r.length && !e.closed; n++) + e.next(r[n]); + e.complete(); + }); +} +function V1(r) { + return new Mt(function(e) { + r.then(function(n) { + e.closed || (e.next(n), e.complete()); + }, function(n) { + return e.error(n); + }).then(null, Yl); + }); +} +function Z1(r) { + return new Mt(function(e) { + var n, s; + try { + for (var a = zr(r), u = a.next(); !u.done; u = a.next()) { + var f = u.value; + if (e.next(f), e.closed) + return; + } + } catch (l) { + n = { error: l }; + } finally { + try { + u && !u.done && (s = a.return) && s.call(a); + } finally { + if (n) + throw n.error; + } + } + e.complete(); + }); +} +function lh(r) { + return new Mt(function(e) { + tb(r, e).catch(function(n) { + return e.error(n); + }); + }); +} +function Q1(r) { + return lh(ch(r)); +} +function tb(r, e) { + var n, s, a, u; + return L1(this, void 0, void 0, function() { + var f, l; + return zl(this, function(d) { + switch (d.label) { + case 0: + d.trys.push([0, 5, 6, 11]), n = P1(r), d.label = 1; + case 1: + return [4, n.next()]; + case 2: + if (s = d.sent(), !!s.done) + return [3, 4]; + if (f = s.value, e.next(f), e.closed) + return [2]; + d.label = 3; + case 3: + return [3, 1]; + case 4: + return [3, 11]; + case 5: + return l = d.sent(), a = { error: l }, [3, 11]; + case 6: + return d.trys.push([6, , 9, 10]), s && !s.done && (u = n.return) ? [4, u.call(n)] : [3, 8]; + case 7: + d.sent(), d.label = 8; + case 8: + return [3, 10]; + case 9: + if (a) + throw a.error; + return [7]; + case 10: + return [7]; + case 11: + return e.complete(), [2]; + } + }); + }); +} +function Cn(r, e, n, s, a) { + s === void 0 && (s = 0), a === void 0 && (a = !1); + var u = e.schedule(function() { + n(), a ? r.add(this.schedule(null, s)) : this.unsubscribe(); + }, s); + if (r.add(u), !a) + return u; +} +function hh(r, e) { + return e === void 0 && (e = 0), me(function(n, s) { + n.subscribe(ve(s, function(a) { + return Cn(s, r, function() { + return s.next(a); + }, e); + }, function() { + return Cn(s, r, function() { + return s.complete(); + }, e); + }, function(a) { + return Cn(s, r, function() { + return s.error(a); + }, e); + })); + }); +} +function dh(r, e) { + return e === void 0 && (e = 0), me(function(n, s) { + s.add(r.schedule(function() { + return n.subscribe(s); + }, e)); + }); +} +function eb(r, e) { + return Qe(r).pipe(dh(e), hh(e)); +} +function nb(r, e) { + return Qe(r).pipe(dh(e), hh(e)); +} +function rb(r, e) { + return new Mt(function(n) { + var s = 0; + return e.schedule(function() { + s === r.length ? n.complete() : (n.next(r[s++]), n.closed || this.schedule()); + }); + }); +} +function ib(r, e) { + return new Mt(function(n) { + var s; + return Cn(n, e, function() { + s = r[ah](), Cn(n, e, function() { + var a, u, f; + try { + a = s.next(), u = a.value, f = a.done; + } catch (l) { + n.error(l); + return; + } + f ? n.complete() : n.next(u); + }, 0, !0); + }), function() { + return bt(s == null ? void 0 : s.return) && s.return(); + }; + }); +} +function ph(r, e) { + if (!r) + throw new Error("Iterable cannot be null"); + return new Mt(function(n) { + Cn(n, e, function() { + var s = r[Symbol.asyncIterator](); + Cn(n, e, function() { + s.next().then(function(a) { + a.done ? n.complete() : n.next(a.value); + }); + }, 0, !0); + }); + }); +} +function sb(r, e) { + return ph(ch(r), e); +} +function ob(r, e) { + if (r != null) { + if (ih(r)) + return eb(r, e); + if (nh(r)) + return rb(r, e); + if (rh(r)) + return nb(r, e); + if (sh(r)) + return ph(r, e); + if (uh(r)) + return ib(r, e); + if (fh(r)) + return sb(r, e); + } + throw oh(r); +} +function Ii(r, e) { + return e ? ob(r, e) : Qe(r); +} +function gh() { + for (var r = [], e = 0; e < arguments.length; e++) + r[e] = arguments[e]; + var n = eh(r); + return Ii(r, n); +} +var ab = au(function(r) { + return function() { + r(this), this.name = "EmptyError", this.message = "no elements in sequence"; + }; +}); +function Ht(r, e) { + var n = typeof e == "object"; + return new Promise(function(s, a) { + var u = !1, f; + r.subscribe({ + next: function(l) { + f = l, u = !0; + }, + error: a, + complete: function() { + u ? s(f) : n ? s(e.defaultValue) : a(new ab()); + } + }); + }); +} +function Lt(r, e) { + return me(function(n, s) { + var a = 0; + n.subscribe(ve(s, function(u) { + s.next(r.call(e, u, a++)); + })); + }); +} +var ub = Array.isArray; +function cb(r, e) { + return ub(e) ? r.apply(void 0, Ve([], Ye(e))) : r(e); +} +function fb(r) { + return Lt(function(e) { + return cb(r, e); + }); +} +function lb(r, e, n) { + return n === void 0 && (n = Jr), function(s) { + tl(e, function() { + for (var a = r.length, u = new Array(a), f = a, l = a, d = function(p) { + tl(e, function() { + var m = Ii(r[p], e), b = !1; + m.subscribe(ve(s, function(C) { + u[p] = C, b || (b = !0, l--), l || s.next(n(u.slice())); + }, function() { + --f || s.complete(); + })); + }, s); + }, y = 0; y < a; y++) + d(y); + }, s); + }; +} +function tl(r, e, n) { + r ? Cn(n, r, e) : e(); +} +function hb(r, e, n, s, a, u, f, l) { + var d = [], y = 0, p = 0, m = !1, b = function() { + m && !d.length && !y && e.complete(); + }, C = function(O) { + return y < s ? I(O) : d.push(O); + }, I = function(O) { + u && e.next(O), y++; + var R = !1; + Qe(n(O, p++)).subscribe(ve(e, function(x) { + a == null || a(x), u ? C(x) : e.next(x); + }, function() { + R = !0; + }, void 0, function() { + if (R) + try { + y--; + for (var x = function() { + var D = d.shift(); + f ? Cn(e, f, function() { + return I(D); + }) : I(D); + }; d.length && y < s; ) + x(); + b(); + } catch (D) { + e.error(D); + } + })); + }; + return r.subscribe(ve(e, C, function() { + m = !0, b(); + })), function() { + l == null || l(); + }; +} +function on(r, e, n) { + return n === void 0 && (n = 1 / 0), bt(e) ? on(function(s, a) { + return Lt(function(u, f) { + return e(s, u, a, f); + })(Qe(r(s, a))); + }, n) : (typeof e == "number" && (n = e), me(function(s, a) { + return hb(s, a, r, n); + })); +} +function db(r) { + return r === void 0 && (r = 1 / 0), on(Jr, r); +} +function pb(r) { + return new Mt(function(e) { + Qe(r()).subscribe(e); + }); +} +function Hr() { + for (var r = [], e = 0; e < arguments.length; e++) + r[e] = arguments[e]; + var n = eh(r), s = K1(r, 1 / 0), a = r; + return a.length ? a.length === 1 ? Qe(a[0]) : db(s)(Ii(a, n)) : po; +} +var gb = Array.isArray; +function vb(r) { + return r.length === 1 && gb(r[0]) ? r[0] : r; +} +function Xe(r, e) { + return me(function(n, s) { + var a = 0; + n.subscribe(ve(s, function(u) { + return r.call(e, u, a++) && s.next(u); + })); + }); +} +function mb(r, e, n, s, a) { + return function(u, f) { + var l = n, d = e, y = 0; + u.subscribe(ve(f, function(p) { + var m = y++; + d = l ? r(d, p, m) : (l = !0, p), s && f.next(d); + }, a && function() { + l && f.next(d), f.complete(); + })); + }; +} +function vh() { + for (var r = [], e = 0; e < arguments.length; e++) + r[e] = arguments[e]; + var n = th(r); + return n ? k1(vh.apply(void 0, Ve([], Ye(r))), fb(n)) : me(function(s, a) { + lb(Ve([s], Ye(vb(r))))(a); + }); +} +function yb() { + for (var r = [], e = 0; e < arguments.length; e++) + r[e] = arguments[e]; + return vh.apply(void 0, Ve([], Ye(r))); +} +function el(r, e) { + return bt(e) ? on(r, e, 1) : on(r, 1); +} +function wb(r) { + return new Mt(function(e) { + return r.subscribe(e); + }); +} +var bb = { + connector: function() { + return new Je(); + } +}; +function _b(r, e) { + e === void 0 && (e = bb); + var n = e.connector; + return me(function(s, a) { + var u = n(); + Qe(r(wb(u))).subscribe(a), a.add(s.subscribe(u)); + }); +} +function mh(r) { + return r <= 0 ? function() { + return po; + } : me(function(e, n) { + var s = 0; + e.subscribe(ve(n, function(a) { + ++s <= r && (n.next(a), r <= s && n.complete()); + })); + }); +} +function nl(r, e) { + return e === void 0 && (e = Jr), r = r ?? Cb, me(function(n, s) { + var a, u = !0; + n.subscribe(ve(s, function(f) { + var l = e(f); + (u || !r(a, l)) && (u = !1, a = l, s.next(f)); + })); + }); +} +function Cb(r, e) { + return r === e; +} +function Eb(r, e, n) { + return n === void 0 && (n = 1 / 0), bt(e) ? on(function() { + return r; + }, e, n) : (typeof e == "number" && (n = e), on(function() { + return r; + }, n)); +} +function Ab(r, e) { + var n = bt(r) ? r : function() { + return r; + }; + return bt(e) ? _b(e, { + connector: n + }) : function(s) { + return new B1(s, n); + }; +} +function Ss(r, e, n, s) { + n && !bt(n) && (s = n); + var a = bt(n) ? n : void 0; + return function(u) { + return Ab(new j1(r, e, s), a)(u); + }; +} +function yh(r, e) { + return me(mb(r, e, arguments.length >= 2, !0)); +} +function Va(r) { + r === void 0 && (r = {}); + var e = r.connector, n = e === void 0 ? function() { + return new Je(); + } : e, s = r.resetOnError, a = s === void 0 ? !0 : s, u = r.resetOnComplete, f = u === void 0 ? !0 : u, l = r.resetOnRefCountZero, d = l === void 0 ? !0 : l; + return function(y) { + var p, m, b, C = 0, I = !1, O = !1, R = function() { + m == null || m.unsubscribe(), m = void 0; + }, x = function() { + R(), p = b = void 0, I = O = !1; + }, D = function() { + var U = p; + x(), U == null || U.unsubscribe(); + }; + return me(function(U, M) { + C++, !O && !I && R(); + var z = b = b ?? n(); + M.add(function() { + C--, C === 0 && !O && !I && (m = Ma(D, d)); + }), z.subscribe(M), !p && C > 0 && (p = new Ri({ + next: function(ht) { + return z.next(ht); + }, + error: function(ht) { + O = !0, R(), m = Ma(x, a, ht), z.error(ht); + }, + complete: function() { + I = !0, R(), m = Ma(x, f), z.complete(); + } + }), Qe(U).subscribe(p)); + })(y); + }; +} +function Ma(r, e) { + for (var n = [], s = 2; s < arguments.length; s++) + n[s - 2] = arguments[s]; + if (e === !0) { + r(); + return; + } + if (e !== !1) { + var a = new Ri({ + next: function() { + a.unsubscribe(), r(); + } + }); + return Qe(e.apply(void 0, Ve([], Ye(n)))).subscribe(a); + } +} +function Za(r, e, n) { + var s = bt(r) || e || n ? { next: r, error: e, complete: n } : r; + return s ? me(function(a, u) { + var f; + (f = s.subscribe) === null || f === void 0 || f.call(s); + var l = !0; + a.subscribe(ve(u, function(d) { + var y; + (y = s.next) === null || y === void 0 || y.call(s, d), u.next(d); + }, function() { + var d; + l = !1, (d = s.complete) === null || d === void 0 || d.call(s), u.complete(); + }, function(d) { + var y; + l = !1, (y = s.error) === null || y === void 0 || y.call(s, d), u.error(d); + }, function() { + var d, y; + l && ((d = s.unsubscribe) === null || d === void 0 || d.call(s)), (y = s.finalize) === null || y === void 0 || y.call(s); + })); + }) : Jr; +} +function rl() { + for (var r = [], e = 0; e < arguments.length; e++) + r[e] = arguments[e]; + var n = th(r); + return me(function(s, a) { + for (var u = r.length, f = new Array(u), l = r.map(function() { + return !1; + }), d = !1, y = function(m) { + Qe(r[m]).subscribe(ve(a, function(b) { + f[m] = b, !d && !l[m] && (l[m] = !0, (d = l.every(Jr)) && (l = null)); + }, Ya)); + }, p = 0; p < u; p++) + y(p); + s.subscribe(ve(a, function(m) { + if (d) { + var b = Ve([m], Ye(f)); + a.next(n ? n.apply(void 0, Ve([], Ye(b))) : b); + } + })); + }); +} +var wh = { 0: 8203, 1: 8204, 2: 8205, 3: 8290, 4: 8291, 5: 8288, 6: 65279, 7: 8289, 8: 119155, 9: 119156, a: 119157, b: 119158, c: 119159, d: 119160, e: 119161, f: 119162 }, lu = { 0: 8203, 1: 8204, 2: 8205, 3: 65279 }, xb = new Array(4).fill(String.fromCodePoint(lu[0])).join(""); +function Sb(r) { + let e = JSON.stringify(r); + return `${xb}${Array.from(e).map((n) => { + let s = n.charCodeAt(0); + if (s > 255) + throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${n} (${s})`); + return Array.from(s.toString(4).padStart(4, "0")).map((a) => String.fromCodePoint(lu[a])).join(""); + }).join("")}`; +} +function Rb(r) { + return !Number.isNaN(Number(r)) || /[a-z]/i.test(r) && !/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(r) ? !1 : !!Date.parse(r); +} +function Ib(r) { + try { + new URL(r, r.startsWith("/") ? "https://acme.com" : void 0); + } catch { + return !1; + } + return !0; +} +function Ob(r, e, n = "auto") { + return n === !0 || n === "auto" && (Rb(r) || Ib(r)) ? r : `${r}${Sb(e)}`; +} +Object.fromEntries(Object.entries(lu).map((r) => r.reverse())); +Object.fromEntries(Object.entries(wh).map((r) => r.reverse())); +var Tb = `${Object.values(wh).map((r) => `\\u{${r.toString(16)}}`).join("")}`, il = new RegExp(`[${Tb}]{4,}`, "gu"); +function Lb(r) { + var e; + return { cleaned: r.replace(il, ""), encoded: ((e = r.match(il)) == null ? void 0 : e[0]) || "" }; +} +function $b(r) { + return r && JSON.parse(Lb(JSON.stringify(r)).cleaned); +} +function Pb(r) { + return $b(r); +} +var Fb = Object.defineProperty, Mb = (r, e, n) => e in r ? Fb(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n, Gn = (r, e, n) => (Mb(r, typeof e != "symbol" ? e + "" : e, n), n); +class Db extends Error { + constructor(e) { + const n = bh(e); + super(n.message), Gn(this, "response"), Gn(this, "statusCode", 400), Gn(this, "responseBody"), Gn(this, "details"), Object.assign(this, n); + } +} +class Ub extends Error { + constructor(e) { + const n = bh(e); + super(n.message), Gn(this, "response"), Gn(this, "statusCode", 500), Gn(this, "responseBody"), Gn(this, "details"), Object.assign(this, n); + } +} +function bh(r) { + const e = r.body, n = { + response: r, + statusCode: r.statusCode, + responseBody: Wb(e, r), + message: "", + details: void 0 + }; + if (e.error && e.message) + return n.message = `${e.error} - ${e.message}`, n; + if (kb(e) || Nb(e)) { + const s = e.error.items || [], a = s.slice(0, 5).map((f) => { + var l; + return (l = f.error) == null ? void 0 : l.description; + }).filter(Boolean); + let u = a.length ? `: +- ${a.join(` +- `)}` : ""; + return s.length > 5 && (u += ` +...and ${s.length - 5} more`), n.message = `${e.error.description}${u}`, n.details = e.error, n; + } + return e.error && e.error.description ? (n.message = e.error.description, n.details = e.error, n) : (n.message = e.error || e.message || qb(r), n); +} +function kb(r) { + return Ys(r) && Ys(r.error) && r.error.type === "mutationError" && typeof r.error.description == "string"; +} +function Nb(r) { + return Ys(r) && Ys(r.error) && r.error.type === "actionError" && typeof r.error.description == "string"; +} +function Ys(r) { + return typeof r == "object" && r !== null && !Array.isArray(r); +} +function qb(r) { + const e = r.statusMessage ? ` ${r.statusMessage}` : ""; + return `${r.method}-request to ${r.url} resulted in HTTP ${r.statusCode}${e}`; +} +function Wb(r, e) { + return (e.headers["content-type"] || "").toLowerCase().indexOf("application/json") !== -1 ? JSON.stringify(r, null, 2) : r; +} +const Bb = { + onResponse: (r) => { + if (r.statusCode >= 500) + throw new Ub(r); + if (r.statusCode >= 400) + throw new Db(r); + return r; + } +}, Hb = { + onResponse: (r) => { + const e = r.headers["x-sanity-warning"]; + return (Array.isArray(e) ? e : [e]).filter(Boolean).forEach((n) => console.warn(n)), r; + } +}; +function Gb(r) { + return d1([ + ou({ shouldRetry: jb }), + ...r, + Hb, + b1(), + _1(), + A1(), + Bb, + E1({ implementation: Mt }) + ]); +} +function jb(r, e, n) { + if (n.maxRetries === 0) + return !1; + const s = n.method === "GET" || n.method === "HEAD", a = (n.uri || n.url).startsWith("/data/query"), u = r.response && (r.response.statusCode === 429 || r.response.statusCode === 502 || r.response.statusCode === 503); + return (s || a) && u ? !0 : ou.shouldRetry(r, e, n); +} +function _h(r) { + if (typeof r == "string") + return { id: r }; + if (Array.isArray(r)) + return { query: "*[_id in $ids]", params: { ids: r } }; + if (typeof r == "object" && r !== null && "query" in r && typeof r.query == "string") + return "params" in r && typeof r.params == "object" && r.params !== null ? { query: r.query, params: r.params } : { query: r.query }; + const e = [ + "* Document ID ()", + "* Array of document IDs", + "* Object containing `query`" + ].join(` +`); + throw new Error(`Unknown selection - must be one of: + +${e}`); +} +const sl = ["image", "file"], ol = ["before", "after", "replace"], Ch = (r) => { + if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(r)) + throw new Error( + "Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters" + ); +}, zb = (r) => { + if (!/^[-a-z0-9]+$/i.test(r)) + throw new Error("`projectId` can only contain only a-z, 0-9 and dashes"); +}, Kb = (r) => { + if (sl.indexOf(r) === -1) + throw new Error(`Invalid asset type: ${r}. Must be one of ${sl.join(", ")}`); +}, Ci = (r, e) => { + if (e === null || typeof e != "object" || Array.isArray(e)) + throw new Error(`${r}() takes an object of properties`); +}, Eh = (r, e) => { + if (typeof e != "string" || !/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(e) || e.includes("..")) + throw new Error(`${r}(): "${e}" is not a valid document ID`); +}, Vs = (r, e) => { + if (!e._id) + throw new Error(`${r}() requires that the document contains an ID ("_id" property)`); + Eh(r, e._id); +}, Jb = (r, e, n) => { + const s = "insert(at, selector, items)"; + if (ol.indexOf(r) === -1) { + const a = ol.map((u) => `"${u}"`).join(", "); + throw new Error(`${s} takes an "at"-argument which is one of: ${a}`); + } + if (typeof e != "string") + throw new Error(`${s} takes a "selector"-argument which must be a string`); + if (!Array.isArray(n)) + throw new Error(`${s} takes an "items"-argument which must be an array`); +}, Ah = (r) => { + if (!r.dataset) + throw new Error("`dataset` must be provided to perform queries"); + return r.dataset || ""; +}, xh = (r) => { + if (typeof r != "string" || !/^[a-z0-9._-]{1,75}$/i.test(r)) + throw new Error( + "Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long." + ); + return r; +}; +var Xb = Object.defineProperty, Yb = (r, e, n) => e in r ? Xb(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n, al = (r, e, n) => (Yb(r, typeof e != "symbol" ? e + "" : e, n), n), Sh = (r, e, n) => { + if (!e.has(r)) + throw TypeError("Cannot " + n); +}, Gr = (r, e, n) => (Sh(r, e, "read from private field"), n ? n.call(r) : e.get(r)), Rh = (r, e, n) => { + if (e.has(r)) + throw TypeError("Cannot add the same private member more than once"); + e instanceof WeakSet ? e.add(r) : e.set(r, n); +}, Ih = (r, e, n, s) => (Sh(r, e, "write to private field"), e.set(r, n), n); +class Oh { + constructor(e, n = {}) { + al(this, "selection"), al(this, "operations"), this.selection = e, this.operations = n; + } + /** + * Sets the given attributes to the document. Does NOT merge objects. + * The operation is added to the current patch, ready to be commited by `commit()` + * + * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\} + */ + set(e) { + return this._assign("set", e); + } + /** + * Sets the given attributes to the document if they are not currently set. Does NOT merge objects. + * The operation is added to the current patch, ready to be commited by `commit()` + * + * @param attrs - Attributes to set. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "value"\} + */ + setIfMissing(e) { + return this._assign("setIfMissing", e); + } + /** + * Performs a "diff-match-patch" operation on the string attributes provided. + * The operation is added to the current patch, ready to be commited by `commit()` + * + * @param attrs - Attributes to perform operation on. To set a deep attribute, use JSONMatch, eg: \{"nested.prop": "dmp"\} + */ + diffMatchPatch(e) { + return Ci("diffMatchPatch", e), this._assign("diffMatchPatch", e); + } + /** + * Unsets the attribute paths provided. + * The operation is added to the current patch, ready to be commited by `commit()` + * + * @param attrs - Attribute paths to unset. + */ + unset(e) { + if (!Array.isArray(e)) + throw new Error("unset(attrs) takes an array of attributes to unset, non-array given"); + return this.operations = Object.assign({}, this.operations, { unset: e }), this; + } + /** + * Increment a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist. + * + * @param attrs - Object of attribute paths to increment, values representing the number to increment by. + */ + inc(e) { + return this._assign("inc", e); + } + /** + * Decrement a numeric value. Each entry in the argument is either an attribute or a JSON path. The value may be a positive or negative integer or floating-point value. The operation will fail if target value is not a numeric value, or doesn't exist. + * + * @param attrs - Object of attribute paths to decrement, values representing the number to decrement by. + */ + dec(e) { + return this._assign("dec", e); + } + /** + * Provides methods for modifying arrays, by inserting, appending and replacing elements via a JSONPath expression. + * + * @param at - Location to insert at, relative to the given selector, or 'replace' the matched path + * @param selector - JSONPath expression, eg `comments[-1]` or `blocks[_key=="abc123"]` + * @param items - Array of items to insert/replace + */ + insert(e, n, s) { + return Jb(e, n, s), this._assign("insert", { [e]: n, items: s }); + } + /** + * Append the given items to the array at the given JSONPath + * + * @param selector - Attribute/path to append to, eg `comments` or `person.hobbies` + * @param items - Array of items to append to the array + */ + append(e, n) { + return this.insert("after", `${e}[-1]`, n); + } + /** + * Prepend the given items to the array at the given JSONPath + * + * @param selector - Attribute/path to prepend to, eg `comments` or `person.hobbies` + * @param items - Array of items to prepend to the array + */ + prepend(e, n) { + return this.insert("before", `${e}[0]`, n); + } + /** + * Change the contents of an array by removing existing elements and/or adding new elements. + * + * @param selector - Attribute or JSONPath expression for array + * @param start - Index at which to start changing the array (with origin 0). If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end of the array (with origin -1) and will be set to 0 if absolute value is greater than the length of the array.x + * @param deleteCount - An integer indicating the number of old array elements to remove. + * @param items - The elements to add to the array, beginning at the start index. If you don't specify any elements, splice() will only remove elements from the array. + */ + splice(e, n, s, a) { + const u = typeof s > "u" || s === -1, f = n < 0 ? n - 1 : n, l = u ? -1 : Math.max(0, n + s), d = f < 0 && l >= 0 ? "" : l, y = `${e}[${f}:${d}]`; + return this.insert("replace", y, a || []); + } + /** + * Adds a revision clause, preventing the document from being patched if the `_rev` property does not match the given value + * + * @param rev - Revision to lock the patch to + */ + ifRevisionId(e) { + return this.operations.ifRevisionID = e, this; + } + /** + * Return a plain JSON representation of the patch + */ + serialize() { + return { ..._h(this.selection), ...this.operations }; + } + /** + * Return a plain JSON representation of the patch + */ + toJSON() { + return this.serialize(); + } + /** + * Clears the patch of all operations + */ + reset() { + return this.operations = {}, this; + } + _assign(e, n, s = !0) { + return Ci(e, n), this.operations = Object.assign({}, this.operations, { + [e]: Object.assign({}, s && this.operations[e] || {}, n) + }), this; + } + _set(e, n) { + return this._assign(e, n, !1); + } +} +var Dr; +const Vb = class Th extends Oh { + constructor(e, n, s) { + super(e, n), Rh(this, Dr, void 0), Ih(this, Dr, s); + } + /** + * Clones the patch + */ + clone() { + return new Th(this.selection, { ...this.operations }, Gr(this, Dr)); + } + commit(e) { + if (!Gr(this, Dr)) + throw new Error( + "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method" + ); + const n = typeof this.selection == "string", s = Object.assign({ returnFirst: n, returnDocuments: !0 }, e); + return Gr(this, Dr).mutate({ patch: this.serialize() }, s); + } +}; +Dr = /* @__PURE__ */ new WeakMap(); +let Ei = Vb; +var Ur; +const Zb = class Lh extends Oh { + constructor(e, n, s) { + super(e, n), Rh(this, Ur, void 0), Ih(this, Ur, s); + } + /** + * Clones the patch + */ + clone() { + return new Lh(this.selection, { ...this.operations }, Gr(this, Ur)); + } + commit(e) { + if (!Gr(this, Ur)) + throw new Error( + "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method" + ); + const n = typeof this.selection == "string", s = Object.assign({ returnFirst: n, returnDocuments: !0 }, e); + return Gr(this, Ur).mutate({ patch: this.serialize() }, s); + } +}; +Ur = /* @__PURE__ */ new WeakMap(); +let Ai = Zb; +var Qb = Object.defineProperty, t_ = (r, e, n) => e in r ? Qb(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n, ul = (r, e, n) => (t_(r, typeof e != "symbol" ? e + "" : e, n), n), $h = (r, e, n) => { + if (!e.has(r)) + throw TypeError("Cannot " + n); +}, jn = (r, e, n) => ($h(r, e, "read from private field"), n ? n.call(r) : e.get(r)), Ph = (r, e, n) => { + if (e.has(r)) + throw TypeError("Cannot add the same private member more than once"); + e instanceof WeakSet ? e.add(r) : e.set(r, n); +}, Fh = (r, e, n, s) => ($h(r, e, "write to private field"), e.set(r, n), n); +const Mh = { returnDocuments: !1 }; +class Dh { + constructor(e = [], n) { + ul(this, "operations"), ul(this, "trxId"), this.operations = e, this.trxId = n; + } + /** + * Creates a new Sanity document. If `_id` is provided and already exists, the mutation will fail. If no `_id` is given, one will automatically be generated by the database. + * The operation is added to the current transaction, ready to be commited by `commit()` + * + * @param doc - Document to create. Requires a `_type` property. + */ + create(e) { + return Ci("create", e), this._add({ create: e }); + } + /** + * Creates a new Sanity document. If a document with the same `_id` already exists, the create operation will be ignored. + * The operation is added to the current transaction, ready to be commited by `commit()` + * + * @param doc - Document to create if it does not already exist. Requires `_id` and `_type` properties. + */ + createIfNotExists(e) { + const n = "createIfNotExists"; + return Ci(n, e), Vs(n, e), this._add({ [n]: e }); + } + /** + * Creates a new Sanity document, or replaces an existing one if the same `_id` is already used. + * The operation is added to the current transaction, ready to be commited by `commit()` + * + * @param doc - Document to create or replace. Requires `_id` and `_type` properties. + */ + createOrReplace(e) { + const n = "createOrReplace"; + return Ci(n, e), Vs(n, e), this._add({ [n]: e }); + } + /** + * Deletes the document with the given document ID + * The operation is added to the current transaction, ready to be commited by `commit()` + * + * @param documentId - Document ID to delete + */ + delete(e) { + return Eh("delete", e), this._add({ delete: { id: e } }); + } + transactionId(e) { + return e ? (this.trxId = e, this) : this.trxId; + } + /** + * Return a plain JSON representation of the transaction + */ + serialize() { + return [...this.operations]; + } + /** + * Return a plain JSON representation of the transaction + */ + toJSON() { + return this.serialize(); + } + /** + * Clears the transaction of all operations + */ + reset() { + return this.operations = [], this; + } + _add(e) { + return this.operations.push(e), this; + } +} +var cr; +const e_ = class Uh extends Dh { + constructor(e, n, s) { + super(e, s), Ph(this, cr, void 0), Fh(this, cr, n); + } + /** + * Clones the transaction + */ + clone() { + return new Uh([...this.operations], jn(this, cr), this.trxId); + } + commit(e) { + if (!jn(this, cr)) + throw new Error( + "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method" + ); + return jn(this, cr).mutate( + this.serialize(), + Object.assign({ transactionId: this.trxId }, Mh, e || {}) + ); + } + patch(e, n) { + const s = typeof n == "function"; + if (typeof e != "string" && e instanceof Ai) + return this._add({ patch: e.serialize() }); + if (s) { + const a = n(new Ai(e, {}, jn(this, cr))); + if (!(a instanceof Ai)) + throw new Error("function passed to `patch()` must return the patch"); + return this._add({ patch: a.serialize() }); + } + return this._add({ patch: { id: e, ...n } }); + } +}; +cr = /* @__PURE__ */ new WeakMap(); +let kh = e_; +var fr; +const n_ = class Nh extends Dh { + constructor(e, n, s) { + super(e, s), Ph(this, fr, void 0), Fh(this, fr, n); + } + /** + * Clones the transaction + */ + clone() { + return new Nh([...this.operations], jn(this, fr), this.trxId); + } + commit(e) { + if (!jn(this, fr)) + throw new Error( + "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method" + ); + return jn(this, fr).mutate( + this.serialize(), + Object.assign({ transactionId: this.trxId }, Mh, e || {}) + ); + } + patch(e, n) { + const s = typeof n == "function"; + if (typeof e != "string" && e instanceof Ei) + return this._add({ patch: e.serialize() }); + if (s) { + const a = n(new Ei(e, {}, jn(this, fr))); + if (!(a instanceof Ei)) + throw new Error("function passed to `patch()` must return the patch"); + return this._add({ patch: a.serialize() }); + } + return this._add({ patch: { id: e, ...n } }); + } +}; +fr = /* @__PURE__ */ new WeakMap(); +let qh = n_; +const r_ = "https://www.sanity.io/help/"; +function hu(r) { + return r_ + r; +} +function i_(r) { + let e = !1, n; + return (...s) => (e || (n = r(...s), e = !0), n); +} +const Oi = (r) => ( + // eslint-disable-next-line no-console + i_((...e) => console.warn(r.join(" "), ...e)) +), s_ = Oi([ + "Because you set `withCredentials` to true, we will override your `useCdn`", + "setting to be false since (cookie-based) credentials are never set on the CDN" +]), o_ = Oi([ + "Since you haven't set a value for `useCdn`, we will deliver content using our", + "global, edge-cached API-CDN. If you wish to have content delivered faster, set", + "`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API." +]), a_ = Oi([ + "The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.", + "The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning." +]), u_ = Oi([ + "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.", + `See ${hu( + "js-client-browser-token" + )} for more information and how to hide this warning.` +]), c_ = Oi([ + "Using the Sanity client without specifying an API version is deprecated.", + `See ${hu("js-client-api-version")}` +]), f_ = "apicdn.sanity.io", xi = { + apiHost: "https://api.sanity.io", + apiVersion: "1", + useProjectHostname: !0, + stega: { enabled: !1 } +}, l_ = ["localhost", "127.0.0.1", "0.0.0.0"], h_ = (r) => l_.indexOf(r) !== -1; +function d_(r) { + if (r === "1" || r === "X") + return; + const e = new Date(r); + if (!(/^\d{4}-\d{2}-\d{2}$/.test(r) && e instanceof Date && e.getTime() > 0)) + throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`"); +} +const Wh = function(r) { + switch (r) { + case "previewDrafts": + case "published": + case "raw": + return; + default: + throw new TypeError( + "Invalid API perspective string, expected `published`, `previewDrafts` or `raw`" + ); + } +}, Bh = (r, e) => { + const n = { + ...e, + ...r, + stega: { + ...typeof e.stega == "boolean" ? { enabled: e.stega } : e.stega || xi.stega, + ...typeof r.stega == "boolean" ? { enabled: r.stega } : r.stega || {} + } + }; + n.apiVersion || c_(); + const s = { + ...xi, + ...n + }, a = s.useProjectHostname; + if (typeof Promise > "u") { + const m = hu("js-client-promise-polyfill"); + throw new Error(`No native Promise-implementation found, polyfill needed - see ${m}`); + } + if (a && !s.projectId) + throw new Error("Configuration must contain `projectId`"); + if (typeof s.perspective == "string" && Wh(s.perspective), "encodeSourceMap" in s) + throw new Error( + "It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client'. Did you mean 'stega.enabled'?" + ); + if ("encodeSourceMapAtPath" in s) + throw new Error( + "It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client'. Did you mean 'stega.filter'?" + ); + if (typeof s.stega.enabled != "boolean") + throw new Error(`stega.enabled must be a boolean, received ${s.stega.enabled}`); + if (s.stega.enabled && s.stega.studioUrl === void 0) + throw new Error("stega.studioUrl must be defined when stega.enabled is true"); + if (s.stega.enabled && typeof s.stega.studioUrl != "string" && typeof s.stega.studioUrl != "function") + throw new Error( + `stega.studioUrl must be a string or a function, received ${s.stega.studioUrl}` + ); + const u = typeof window < "u" && window.location && window.location.hostname, f = u && h_(window.location.hostname); + u && f && s.token && s.ignoreBrowserTokenWarning !== !0 ? u_() : typeof s.useCdn > "u" && o_(), a && zb(s.projectId), s.dataset && Ch(s.dataset), "requestTagPrefix" in s && (s.requestTagPrefix = s.requestTagPrefix ? xh(s.requestTagPrefix).replace(/\.+$/, "") : void 0), s.apiVersion = `${s.apiVersion}`.replace(/^v/, ""), s.isDefaultApi = s.apiHost === xi.apiHost, s.useCdn === !0 && s.withCredentials && s_(), s.useCdn = s.useCdn !== !1 && !s.withCredentials, d_(s.apiVersion); + const l = s.apiHost.split("://", 2), d = l[0], y = l[1], p = s.isDefaultApi ? f_ : y; + return s.useProjectHostname ? (s.url = `${d}://${s.projectId}.${y}/v${s.apiVersion}`, s.cdnUrl = `${d}://${s.projectId}.${p}/v${s.apiVersion}`) : (s.url = `${s.apiHost}/v${s.apiVersion}`, s.cdnUrl = s.url), s; +}, p_ = "X-Sanity-Project-ID"; +function g_(r, e = {}) { + const n = {}, s = e.token || r.token; + s && (n.Authorization = `Bearer ${s}`), !e.useGlobalApi && !r.useProjectHostname && r.projectId && (n[p_] = r.projectId); + const a = !!(typeof e.withCredentials > "u" ? r.token || r.withCredentials : e.withCredentials), u = typeof e.timeout > "u" ? r.timeout : e.timeout; + return Object.assign({}, e, { + headers: Object.assign({}, n, e.headers || {}), + timeout: typeof u > "u" ? 5 * 60 * 1e3 : u, + proxy: e.proxy || r.proxy, + json: !0, + withCredentials: a, + fetch: typeof e.fetch == "object" && typeof r.fetch == "object" ? { ...r.fetch, ...e.fetch } : e.fetch || r.fetch + }); +} +const Hh = ({ + query: r, + params: e = {}, + options: n = {} +}) => { + const s = new URLSearchParams(), { tag: a, returnQuery: u, ...f } = n; + a && s.append("tag", a), s.append("query", r); + for (const [l, d] of Object.entries(e)) + s.append(`$${l}`, JSON.stringify(d)); + for (const [l, d] of Object.entries(f)) + d && s.append(l, `${d}`); + return u === !1 && s.append("returnQuery", "false"), `?${s}`; +}, v_ = (r, e) => r === !1 ? void 0 : typeof r > "u" ? e : r, m_ = (r = {}) => ({ + dryRun: r.dryRun, + returnIds: !0, + returnDocuments: v_(r.returnDocuments, !0), + visibility: r.visibility || "sync", + autoGenerateArrayKeys: r.autoGenerateArrayKeys, + skipCrossDatasetReferenceValidation: r.skipCrossDatasetReferenceValidation +}), du = (r) => r.type === "response", y_ = (r) => r.body, w_ = (r, e) => r.reduce((n, s) => (n[e(s)] = s, n), /* @__PURE__ */ Object.create(null)), b_ = 11264; +function Gh(r, e, n, s, a = {}, u = {}) { + const f = "stega" in u ? { + ...n || {}, + ...typeof u.stega == "boolean" ? { enabled: u.stega } : u.stega || {} + } : n, l = f.enabled ? Pb(a) : a, d = u.filterResponse === !1 ? (I) => I : (I) => I.result, { cache: y, next: p, ...m } = { + // Opt out of setting a `signal` on an internal `fetch` if one isn't provided. + // This is necessary in React Server Components to avoid opting out of Request Memoization. + useAbortSignal: typeof u.signal < "u", + // Set `resultSourceMap' when stega is enabled, as it's required for encoding. + resultSourceMap: f.enabled ? "withKeyArraySelector" : u.resultSourceMap, + ...u, + // Default to not returning the query, unless `filterResponse` is `false`, + // or `returnQuery` is explicitly set. `true` is the default in Content Lake, so skip if truthy + returnQuery: u.filterResponse === !1 && u.returnQuery !== !1 + }, b = typeof y < "u" || typeof p < "u" ? { ...m, fetch: { cache: y, next: p } } : m, C = Xr(r, e, "query", { query: s, params: l }, b); + return f.enabled ? C.pipe( + yb( + Ii( + Promise.resolve().then(() => qE).then(function(I) { + return I.stegaEncodeSourceMap$1; + }).then( + ({ stegaEncodeSourceMap: I }) => I + ) + ) + ), + Lt( + ([I, O]) => { + const R = O(I.result, I.resultSourceMap, f); + return d({ ...I, result: R }); + } + ) + ) : C.pipe(Lt(d)); +} +function jh(r, e, n, s = {}) { + const a = { uri: mr(r, "doc", n), json: !0, tag: s.tag }; + return Ti(r, e, a).pipe( + Xe(du), + Lt((u) => u.body.documents && u.body.documents[0]) + ); +} +function zh(r, e, n, s = {}) { + const a = { uri: mr(r, "doc", n.join(",")), json: !0, tag: s.tag }; + return Ti(r, e, a).pipe( + Xe(du), + Lt((u) => { + const f = w_(u.body.documents || [], (l) => l._id); + return n.map((l) => f[l] || null); + }) + ); +} +function Kh(r, e, n, s) { + return Vs("createIfNotExists", n), go(r, e, n, "createIfNotExists", s); +} +function Jh(r, e, n, s) { + return Vs("createOrReplace", n), go(r, e, n, "createOrReplace", s); +} +function Xh(r, e, n, s) { + return Xr( + r, + e, + "mutate", + { mutations: [{ delete: _h(n) }] }, + s + ); +} +function Yh(r, e, n, s) { + let a; + n instanceof Ai || n instanceof Ei ? a = { patch: n.serialize() } : n instanceof kh || n instanceof qh ? a = n.serialize() : a = n; + const u = Array.isArray(a) ? a : [a], f = s && s.transactionId || void 0; + return Xr(r, e, "mutate", { mutations: u, transactionId: f }, s); +} +function Vh(r, e, n, s) { + const a = Array.isArray(n) ? n : [n], u = s && s.transactionId || void 0, f = s && s.skipCrossDatasetReferenceValidation || void 0, l = s && s.dryRun || void 0; + return Xr( + r, + e, + "actions", + { actions: a, transactionId: u, skipCrossDatasetReferenceValidation: f, dryRun: l }, + s + ); +} +function Xr(r, e, n, s, a = {}) { + const u = n === "mutate", f = n === "actions", l = n === "query", d = u || f ? "" : Hh(s), y = !u && !f && d.length < b_, p = y ? d : "", m = a.returnFirst, { timeout: b, token: C, tag: I, headers: O, returnQuery: R, lastLiveEventId: x } = a, D = mr(r, n, p), U = { + method: y ? "GET" : "POST", + uri: D, + json: !0, + body: y ? void 0 : s, + query: u && m_(a), + timeout: b, + headers: O, + token: C, + tag: I, + returnQuery: R, + perspective: a.perspective, + resultSourceMap: a.resultSourceMap, + lastLiveEventId: Array.isArray(x) ? x[0] : x, + canUseCdn: l, + signal: a.signal, + fetch: a.fetch, + useAbortSignal: a.useAbortSignal, + useCdn: a.useCdn + }; + return Ti(r, e, U).pipe( + Xe(du), + Lt(y_), + Lt((M) => { + if (!u) + return M; + const z = M.results || []; + if (a.returnDocuments) + return m ? z[0] && z[0].document : z.map((xt) => xt.document); + const ht = m ? "documentId" : "documentIds", _t = m ? z[0] && z[0].id : z.map((xt) => xt.id); + return { + transactionId: M.transactionId, + results: z, + [ht]: _t + }; + }) + ); +} +function go(r, e, n, s, a = {}) { + const u = { [s]: n }, f = Object.assign({ returnFirst: !0, returnDocuments: !0 }, a); + return Xr(r, e, "mutate", { mutations: [u] }, f); +} +function Ti(r, e, n) { + var s, a; + const u = n.url || n.uri, f = r.config(), l = typeof n.canUseCdn > "u" ? ["GET", "HEAD"].indexOf(n.method || "GET") >= 0 && u.indexOf("/data/") === 0 : n.canUseCdn; + let d = ((s = n.useCdn) != null ? s : f.useCdn) && l; + const y = n.tag && f.requestTagPrefix ? [f.requestTagPrefix, n.tag].join(".") : n.tag || f.requestTagPrefix; + if (y && n.tag !== null && (n.query = { tag: xh(y), ...n.query }), ["GET", "HEAD", "POST"].indexOf(n.method || "GET") >= 0 && u.indexOf("/data/query/") === 0) { + const b = (a = n.resultSourceMap) != null ? a : f.resultSourceMap; + b !== void 0 && b !== !1 && (n.query = { resultSourceMap: b, ...n.query }); + const C = n.perspective || f.perspective; + typeof C == "string" && C !== "raw" && (Wh(C), n.query = { perspective: C, ...n.query }, C === "previewDrafts" && d && (d = !1, a_())), n.lastLiveEventId && (n.query = { ...n.query, lastLiveEventId: n.lastLiveEventId }), n.returnQuery === !1 && (n.query = { returnQuery: "false", ...n.query }); + } + const p = g_( + f, + Object.assign({}, n, { + url: pu(r, u, d) + }) + ), m = new Mt( + (b) => e(p, f.requester).subscribe(b) + ); + return n.signal ? m.pipe(__(n.signal)) : m; +} +function Ze(r, e, n) { + return Ti(r, e, n).pipe( + Xe((s) => s.type === "response"), + Lt((s) => s.body) + ); +} +function mr(r, e, n) { + const s = r.config(), a = Ah(s), u = `/${e}/${a}`; + return `/data${n ? `${u}/${n}` : u}`.replace(/\/($|\?)/, "$1"); +} +function pu(r, e, n = !1) { + const { url: s, cdnUrl: a } = r.config(); + return `${n ? a : s}/${e.replace(/^\//, "")}`; +} +function __(r) { + return (e) => new Mt((n) => { + const s = () => n.error(E_(r)); + if (r && r.aborted) { + s(); + return; + } + const a = e.subscribe(n); + return r.addEventListener("abort", s), () => { + r.removeEventListener("abort", s), a.unsubscribe(); + }; + }); +} +const C_ = !!globalThis.DOMException; +function E_(r) { + var e, n; + if (C_) + return new DOMException((e = r == null ? void 0 : r.reason) != null ? e : "The operation was aborted.", "AbortError"); + const s = new Error((n = r == null ? void 0 : r.reason) != null ? n : "The operation was aborted."); + return s.name = "AbortError", s; +} +var Zh = (r, e, n) => { + if (!e.has(r)) + throw TypeError("Cannot " + n); +}, Zs = (r, e, n) => (Zh(r, e, "read from private field"), n ? n.call(r) : e.get(r)), Qs = (r, e, n) => { + if (e.has(r)) + throw TypeError("Cannot add the same private member more than once"); + e instanceof WeakSet ? e.add(r) : e.set(r, n); +}, to = (r, e, n, s) => (Zh(r, e, "write to private field"), e.set(r, n), n), qs, Ws; +class A_ { + constructor(e, n) { + Qs(this, qs, void 0), Qs(this, Ws, void 0), to(this, qs, e), to(this, Ws, n); + } + upload(e, n, s) { + return Qh(Zs(this, qs), Zs(this, Ws), e, n, s); + } +} +qs = /* @__PURE__ */ new WeakMap(), Ws = /* @__PURE__ */ new WeakMap(); +var Bs, Hs; +class x_ { + constructor(e, n) { + Qs(this, Bs, void 0), Qs(this, Hs, void 0), to(this, Bs, e), to(this, Hs, n); + } + upload(e, n, s) { + const a = Qh(Zs(this, Bs), Zs(this, Hs), e, n, s); + return Ht( + a.pipe( + Xe((u) => u.type === "response"), + Lt( + (u) => u.body.document + ) + ) + ); + } +} +Bs = /* @__PURE__ */ new WeakMap(), Hs = /* @__PURE__ */ new WeakMap(); +function Qh(r, e, n, s, a = {}) { + Kb(n); + let u = a.extract || void 0; + u && !u.length && (u = ["none"]); + const f = Ah(r.config()), l = n === "image" ? "images" : "files", d = S_(a, s), { tag: y, label: p, title: m, description: b, creditLine: C, filename: I, source: O } = d, R = { + label: p, + title: m, + description: b, + filename: I, + meta: u, + creditLine: C + }; + return O && (R.sourceId = O.id, R.sourceName = O.name, R.sourceUrl = O.url), Ti(r, e, { + tag: y, + method: "POST", + timeout: d.timeout || 0, + uri: `/assets/${l}/${f}`, + headers: d.contentType ? { "Content-Type": d.contentType } : {}, + query: R, + body: s + }); +} +function S_(r, e) { + return typeof File > "u" || !(e instanceof File) ? r : Object.assign( + { + filename: r.preserveFilename === !1 ? void 0 : e.name, + contentType: e.type + }, + r + ); +} +var R_ = (r, e) => Object.keys(e).concat(Object.keys(r)).reduce((n, s) => (n[s] = typeof r[s] > "u" ? e[s] : r[s], n), {}); +const I_ = (r, e) => e.reduce((n, s) => (typeof r[s] > "u" || (n[s] = r[s]), n), {}), O_ = 14800, T_ = [ + "includePreviousRevision", + "includeResult", + "visibility", + "effectFormat", + "tag" +], L_ = { + includeResult: !0 +}; +function td(r, e, n = {}) { + const { url: s, token: a, withCredentials: u, requestTagPrefix: f } = this.config(), l = n.tag && f ? [f, n.tag].join(".") : n.tag, d = { ...R_(n, L_), tag: l }, y = I_(d, T_), p = Hh({ query: r, params: e, options: { tag: l, ...y } }), m = `${s}${mr(this, "listen", p)}`; + if (m.length > O_) + return new Mt((O) => O.error(new Error("Query too large for listener"))); + const b = d.events ? d.events : ["mutation"], C = b.indexOf("reconnect") !== -1, I = {}; + return (a || u) && (I.withCredentials = !0), a && (I.headers = { + Authorization: `Bearer ${a}` + }), new Mt((O) => { + let R, x, D = !1, U = !1; + un(); + function M() { + D || (Te(), !D && R.readyState === R.CLOSED && (xt(), clearTimeout(x), x = setTimeout(un, 100))); + } + function z(zt) { + O.error($_(zt)); + } + function ht(zt) { + const Qt = ed(zt); + return Qt instanceof Error ? O.error(Qt) : O.next(Qt); + } + function _t() { + D = !0, xt(), O.complete(); + } + function xt() { + R && (R.removeEventListener("error", M), R.removeEventListener("channelError", z), R.removeEventListener("disconnect", _t), b.forEach((zt) => R.removeEventListener(zt, ht)), R.close()); + } + function Te() { + C && O.next({ type: "reconnect" }); + } + async function qe() { + const { default: zt } = await Promise.resolve().then(() => Id); + if (U) + return; + const Qt = new zt(m, I); + return Qt.addEventListener("error", M), Qt.addEventListener("channelError", z), Qt.addEventListener("disconnect", _t), b.forEach((yr) => Qt.addEventListener(yr, ht)), Qt; + } + function un() { + qe().then((zt) => { + zt && (R = zt, U && xt()); + }).catch((zt) => { + O.error(zt), We(); + }); + } + function We() { + D = !0, xt(), U = !0; + } + return We; + }); +} +function ed(r) { + try { + const e = r.data && JSON.parse(r.data) || {}; + return Object.assign({ type: r.type }, e); + } catch (e) { + return e; + } +} +function $_(r) { + if (r instanceof Error) + return r; + const e = ed(r); + return e instanceof Error ? e : new Error(P_(e)); +} +function P_(r) { + return r.error ? r.error.description ? r.error.description : typeof r.error == "string" ? r.error : JSON.stringify(r.error, null, 2) : r.message || "Unknown listener error"; +} +var nd = (r, e, n) => { + if (!e.has(r)) + throw TypeError("Cannot " + n); +}, Da = (r, e, n) => (nd(r, e, "read from private field"), n ? n.call(r) : e.get(r)), F_ = (r, e, n) => { + if (e.has(r)) + throw TypeError("Cannot add the same private member more than once"); + e instanceof WeakSet ? e.add(r) : e.set(r, n); +}, M_ = (r, e, n, s) => (nd(r, e, "write to private field"), e.set(r, n), n); +const cl = "2021-03-26"; +var kr; +class rd { + constructor(e) { + F_(this, kr, void 0), M_(this, kr, e); + } + /** + * Requires `apiVersion` to be `2021-03-26` or later. + */ + events() { + const e = Da(this, kr).config().apiVersion.replace(/^v/, ""); + if (e !== "X" && e < cl) + throw new Error( + `The live events API requires API version ${cl} or later. The current API version is ${e}. Please update your API version to use this feature.` + ); + const n = mr(Da(this, kr), "live/events"), s = new URL(Da(this, kr).getUrl(n, !1)), a = ["restart", "message"]; + return new Mt((u) => { + let f, l, d = !1, y = !1; + I(); + function p(R) { + if (!d) { + if ("data" in R) { + const x = fl(R); + u.error(new Error(x.message, { cause: x })); + } + f.readyState === f.CLOSED && (b(), clearTimeout(l), l = setTimeout(I, 100)); + } + } + function m(R) { + const x = fl(R); + return x instanceof Error ? u.error(x) : u.next(x); + } + function b() { + if (f) { + f.removeEventListener("error", p); + for (const R of a) + f.removeEventListener(R, m); + f.close(); + } + } + async function C() { + const R = typeof EventSource > "u" ? (await Promise.resolve().then(() => Id)).default : EventSource; + if (y) + return; + const x = new R(s.toString()); + x.addEventListener("error", p); + for (const D of a) + x.addEventListener(D, m); + return x; + } + function I() { + C().then((R) => { + R && (f = R, y && b()); + }).catch((R) => { + u.error(R), O(); + }); + } + function O() { + d = !0, b(), y = !0; + } + return O; + }); + } +} +kr = /* @__PURE__ */ new WeakMap(); +function fl(r) { + try { + const e = r.data && JSON.parse(r.data) || {}; + return { type: r.type, id: r.lastEventId, ...e }; + } catch (e) { + return e; + } +} +var id = (r, e, n) => { + if (!e.has(r)) + throw TypeError("Cannot " + n); +}, ie = (r, e, n) => (id(r, e, "read from private field"), n ? n.call(r) : e.get(r)), eo = (r, e, n) => { + if (e.has(r)) + throw TypeError("Cannot add the same private member more than once"); + e instanceof WeakSet ? e.add(r) : e.set(r, n); +}, no = (r, e, n, s) => (id(r, e, "write to private field"), e.set(r, n), n), lr, hr; +class D_ { + constructor(e, n) { + eo(this, lr, void 0), eo(this, hr, void 0), no(this, lr, e), no(this, hr, n); + } + /** + * Create a new dataset with the given name + * + * @param name - Name of the dataset to create + * @param options - Options for the dataset + */ + create(e, n) { + return jr(ie(this, lr), ie(this, hr), "PUT", e, n); + } + /** + * Edit a dataset with the given name + * + * @param name - Name of the dataset to edit + * @param options - New options for the dataset + */ + edit(e, n) { + return jr(ie(this, lr), ie(this, hr), "PATCH", e, n); + } + /** + * Delete a dataset with the given name + * + * @param name - Name of the dataset to delete + */ + delete(e) { + return jr(ie(this, lr), ie(this, hr), "DELETE", e); + } + /** + * Fetch a list of datasets for the configured project + */ + list() { + return Ze(ie(this, lr), ie(this, hr), { + uri: "/datasets", + tag: null + }); + } +} +lr = /* @__PURE__ */ new WeakMap(), hr = /* @__PURE__ */ new WeakMap(); +var dr, pr; +class U_ { + constructor(e, n) { + eo(this, dr, void 0), eo(this, pr, void 0), no(this, dr, e), no(this, pr, n); + } + /** + * Create a new dataset with the given name + * + * @param name - Name of the dataset to create + * @param options - Options for the dataset + */ + create(e, n) { + return Ht( + jr(ie(this, dr), ie(this, pr), "PUT", e, n) + ); + } + /** + * Edit a dataset with the given name + * + * @param name - Name of the dataset to edit + * @param options - New options for the dataset + */ + edit(e, n) { + return Ht( + jr(ie(this, dr), ie(this, pr), "PATCH", e, n) + ); + } + /** + * Delete a dataset with the given name + * + * @param name - Name of the dataset to delete + */ + delete(e) { + return Ht(jr(ie(this, dr), ie(this, pr), "DELETE", e)); + } + /** + * Fetch a list of datasets for the configured project + */ + list() { + return Ht( + Ze(ie(this, dr), ie(this, pr), { uri: "/datasets", tag: null }) + ); + } +} +dr = /* @__PURE__ */ new WeakMap(), pr = /* @__PURE__ */ new WeakMap(); +function jr(r, e, n, s, a) { + return Ch(s), Ze(r, e, { + method: n, + uri: `/datasets/${s}`, + body: a, + tag: null + }); +} +var sd = (r, e, n) => { + if (!e.has(r)) + throw TypeError("Cannot " + n); +}, zn = (r, e, n) => (sd(r, e, "read from private field"), n ? n.call(r) : e.get(r)), ro = (r, e, n) => { + if (e.has(r)) + throw TypeError("Cannot add the same private member more than once"); + e instanceof WeakSet ? e.add(r) : e.set(r, n); +}, io = (r, e, n, s) => (sd(r, e, "write to private field"), e.set(r, n), n), yi, wi; +class k_ { + constructor(e, n) { + ro(this, yi, void 0), ro(this, wi, void 0), io(this, yi, e), io(this, wi, n); + } + list(e) { + const n = (e == null ? void 0 : e.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects"; + return Ze(zn(this, yi), zn(this, wi), { uri: n }); + } + /** + * Fetch a project by project ID + * + * @param projectId - ID of the project to fetch + */ + getById(e) { + return Ze(zn(this, yi), zn(this, wi), { uri: `/projects/${e}` }); + } +} +yi = /* @__PURE__ */ new WeakMap(), wi = /* @__PURE__ */ new WeakMap(); +var bi, _i; +class N_ { + constructor(e, n) { + ro(this, bi, void 0), ro(this, _i, void 0), io(this, bi, e), io(this, _i, n); + } + list(e) { + const n = (e == null ? void 0 : e.includeMembers) === !1 ? "/projects?includeMembers=false" : "/projects"; + return Ht(Ze(zn(this, bi), zn(this, _i), { uri: n })); + } + /** + * Fetch a project by project ID + * + * @param projectId - ID of the project to fetch + */ + getById(e) { + return Ht( + Ze(zn(this, bi), zn(this, _i), { uri: `/projects/${e}` }) + ); + } +} +bi = /* @__PURE__ */ new WeakMap(), _i = /* @__PURE__ */ new WeakMap(); +var od = (r, e, n) => { + if (!e.has(r)) + throw TypeError("Cannot " + n); +}, so = (r, e, n) => (od(r, e, "read from private field"), n ? n.call(r) : e.get(r)), oo = (r, e, n) => { + if (e.has(r)) + throw TypeError("Cannot add the same private member more than once"); + e instanceof WeakSet ? e.add(r) : e.set(r, n); +}, ao = (r, e, n, s) => (od(r, e, "write to private field"), e.set(r, n), n), Gs, js; +class q_ { + constructor(e, n) { + oo(this, Gs, void 0), oo(this, js, void 0), ao(this, Gs, e), ao(this, js, n); + } + /** + * Fetch a user by user ID + * + * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned. + */ + getById(e) { + return Ze( + so(this, Gs), + so(this, js), + { uri: `/users/${e}` } + ); + } +} +Gs = /* @__PURE__ */ new WeakMap(), js = /* @__PURE__ */ new WeakMap(); +var zs, Ks; +class W_ { + constructor(e, n) { + oo(this, zs, void 0), oo(this, Ks, void 0), ao(this, zs, e), ao(this, Ks, n); + } + /** + * Fetch a user by user ID + * + * @param id - User ID of the user to fetch. If `me` is provided, a minimal response including the users role is returned. + */ + getById(e) { + return Ht( + Ze(so(this, zs), so(this, Ks), { + uri: `/users/${e}` + }) + ); + } +} +zs = /* @__PURE__ */ new WeakMap(), Ks = /* @__PURE__ */ new WeakMap(); +var B_ = Object.defineProperty, H_ = (r, e, n) => e in r ? B_(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n, Ie = (r, e, n) => (H_(r, typeof e != "symbol" ? e + "" : e, n), n), ad = (r, e, n) => { + if (!e.has(r)) + throw TypeError("Cannot " + n); +}, et = (r, e, n) => (ad(r, e, "read from private field"), n ? n.call(r) : e.get(r)), uo = (r, e, n) => { + if (e.has(r)) + throw TypeError("Cannot add the same private member more than once"); + e instanceof WeakSet ? e.add(r) : e.set(r, n); +}, co = (r, e, n, s) => (ad(r, e, "write to private field"), e.set(r, n), n), Wn, Bt; +const G_ = class Qa { + constructor(e, n = xi) { + Ie(this, "assets"), Ie(this, "datasets"), Ie(this, "live"), Ie(this, "projects"), Ie(this, "users"), uo(this, Wn, void 0), uo(this, Bt, void 0), Ie(this, "listen", td), this.config(n), co(this, Bt, e), this.assets = new A_(this, et(this, Bt)), this.datasets = new D_(this, et(this, Bt)), this.live = new rd(this), this.projects = new k_(this, et(this, Bt)), this.users = new q_(this, et(this, Bt)); + } + /** + * Clone the client - returns a new instance + */ + clone() { + return new Qa(et(this, Bt), this.config()); + } + config(e) { + if (e === void 0) + return { ...et(this, Wn) }; + if (et(this, Wn) && et(this, Wn).allowReconfigure === !1) + throw new Error( + "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client" + ); + return co(this, Wn, Bh(e, et(this, Wn) || {})), this; + } + /** + * Clone the client with a new (partial) configuration. + * + * @param newConfig - New client configuration properties, shallowly merged with existing configuration + */ + withConfig(e) { + const n = this.config(); + return new Qa(et(this, Bt), { + ...n, + ...e, + stega: { + ...n.stega || {}, + ...typeof (e == null ? void 0 : e.stega) == "boolean" ? { enabled: e.stega } : (e == null ? void 0 : e.stega) || {} + } + }); + } + fetch(e, n, s) { + return Gh( + this, + et(this, Bt), + et(this, Wn).stega, + e, + n, + s + ); + } + /** + * Fetch a single document with the given ID. + * + * @param id - Document ID to fetch + * @param options - Request options + */ + getDocument(e, n) { + return jh(this, et(this, Bt), e, n); + } + /** + * Fetch multiple documents in one request. + * Should be used sparingly - performing a query is usually a better option. + * The order/position of documents is preserved based on the original array of IDs. + * If any of the documents are missing, they will be replaced by a `null` entry in the returned array + * + * @param ids - Document IDs to fetch + * @param options - Request options + */ + getDocuments(e, n) { + return zh(this, et(this, Bt), e, n); + } + create(e, n) { + return go(this, et(this, Bt), e, "create", n); + } + createIfNotExists(e, n) { + return Kh(this, et(this, Bt), e, n); + } + createOrReplace(e, n) { + return Jh(this, et(this, Bt), e, n); + } + delete(e, n) { + return Xh(this, et(this, Bt), e, n); + } + mutate(e, n) { + return Yh(this, et(this, Bt), e, n); + } + /** + * Create a new buildable patch of operations to perform + * + * @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch + * @param operations - Optional object of patch operations to initialize the patch instance with + * @returns Patch instance - call `.commit()` to perform the operations defined + */ + patch(e, n) { + return new Ei(e, n, this); + } + /** + * Create a new transaction of mutations + * + * @param operations - Optional array of mutation operations to initialize the transaction instance with + */ + transaction(e) { + return new qh(e, this); + } + /** + * Perform action operations against the configured dataset + * + * @param operations - Action operation(s) to execute + * @param options - Action options + */ + action(e, n) { + return Vh(this, et(this, Bt), e, n); + } + /** + * Perform an HTTP request against the Sanity API + * + * @param options - Request options + */ + request(e) { + return Ze(this, et(this, Bt), e); + } + /** + * Get a Sanity API URL for the URI provided + * + * @param uri - URI/path to build URL for + * @param canUseCdn - Whether or not to allow using the API CDN for this route + */ + getUrl(e, n) { + return pu(this, e, n); + } + /** + * Get a Sanity API URL for the data operation and path provided + * + * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar) + * @param path - Path to append after the operation + */ + getDataUrl(e, n) { + return mr(this, e, n); + } +}; +Wn = /* @__PURE__ */ new WeakMap(), Bt = /* @__PURE__ */ new WeakMap(); +let j_ = G_; +var Bn, Ut; +const z_ = class tu { + constructor(e, n = xi) { + Ie(this, "assets"), Ie(this, "datasets"), Ie(this, "live"), Ie(this, "projects"), Ie(this, "users"), Ie(this, "observable"), uo(this, Bn, void 0), uo(this, Ut, void 0), Ie(this, "listen", td), this.config(n), co(this, Ut, e), this.assets = new x_(this, et(this, Ut)), this.datasets = new U_(this, et(this, Ut)), this.live = new rd(this), this.projects = new N_(this, et(this, Ut)), this.users = new W_(this, et(this, Ut)), this.observable = new j_(e, n); + } + /** + * Clone the client - returns a new instance + */ + clone() { + return new tu(et(this, Ut), this.config()); + } + config(e) { + if (e === void 0) + return { ...et(this, Bn) }; + if (et(this, Bn) && et(this, Bn).allowReconfigure === !1) + throw new Error( + "Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client" + ); + return this.observable && this.observable.config(e), co(this, Bn, Bh(e, et(this, Bn) || {})), this; + } + /** + * Clone the client with a new (partial) configuration. + * + * @param newConfig - New client configuration properties, shallowly merged with existing configuration + */ + withConfig(e) { + const n = this.config(); + return new tu(et(this, Ut), { + ...n, + ...e, + stega: { + ...n.stega || {}, + ...typeof (e == null ? void 0 : e.stega) == "boolean" ? { enabled: e.stega } : (e == null ? void 0 : e.stega) || {} + } + }); + } + fetch(e, n, s) { + return Ht( + Gh( + this, + et(this, Ut), + et(this, Bn).stega, + e, + n, + s + ) + ); + } + /** + * Fetch a single document with the given ID. + * + * @param id - Document ID to fetch + * @param options - Request options + */ + getDocument(e, n) { + return Ht(jh(this, et(this, Ut), e, n)); + } + /** + * Fetch multiple documents in one request. + * Should be used sparingly - performing a query is usually a better option. + * The order/position of documents is preserved based on the original array of IDs. + * If any of the documents are missing, they will be replaced by a `null` entry in the returned array + * + * @param ids - Document IDs to fetch + * @param options - Request options + */ + getDocuments(e, n) { + return Ht(zh(this, et(this, Ut), e, n)); + } + create(e, n) { + return Ht( + go(this, et(this, Ut), e, "create", n) + ); + } + createIfNotExists(e, n) { + return Ht( + Kh(this, et(this, Ut), e, n) + ); + } + createOrReplace(e, n) { + return Ht( + Jh(this, et(this, Ut), e, n) + ); + } + delete(e, n) { + return Ht(Xh(this, et(this, Ut), e, n)); + } + mutate(e, n) { + return Ht(Yh(this, et(this, Ut), e, n)); + } + /** + * Create a new buildable patch of operations to perform + * + * @param selection - Document ID, an array of document IDs, or an object with `query` and optional `params`, defining which document(s) to patch + * @param operations - Optional object of patch operations to initialize the patch instance with + * @returns Patch instance - call `.commit()` to perform the operations defined + */ + patch(e, n) { + return new Ai(e, n, this); + } + /** + * Create a new transaction of mutations + * + * @param operations - Optional array of mutation operations to initialize the transaction instance with + */ + transaction(e) { + return new kh(e, this); + } + /** + * Perform action operations against the configured dataset + * Returns a promise that resolves to the transaction result + * + * @param operations - Action operation(s) to execute + * @param options - Action options + */ + action(e, n) { + return Ht(Vh(this, et(this, Ut), e, n)); + } + /** + * Perform a request against the Sanity API + * NOTE: Only use this for Sanity API endpoints, not for your own APIs! + * + * @param options - Request options + * @returns Promise resolving to the response body + */ + request(e) { + return Ht(Ze(this, et(this, Ut), e)); + } + /** + * Perform an HTTP request a `/data` sub-endpoint + * NOTE: Considered internal, thus marked as deprecated. Use `request` instead. + * + * @deprecated - Use `request()` or your own HTTP library instead + * @param endpoint - Endpoint to hit (mutate, query etc) + * @param body - Request body + * @param options - Request options + * @internal + */ + dataRequest(e, n, s) { + return Ht(Xr(this, et(this, Ut), e, n, s)); + } + /** + * Get a Sanity API URL for the URI provided + * + * @param uri - URI/path to build URL for + * @param canUseCdn - Whether or not to allow using the API CDN for this route + */ + getUrl(e, n) { + return pu(this, e, n); + } + /** + * Get a Sanity API URL for the data operation and path provided + * + * @param operation - Data operation (eg `query`, `mutate`, `listen` or similar) + * @param path - Path to append after the operation + */ + getDataUrl(e, n) { + return mr(this, e, n); + } +}; +Bn = /* @__PURE__ */ new WeakMap(), Ut = /* @__PURE__ */ new WeakMap(); +let K_ = z_; +function J_(r, e) { + const n = Gb(r); + return { requester: n, createClient: (s) => new e( + (a, u) => (u || n)({ + maxRedirects: 0, + maxRetries: s.maxRetries, + retryDelay: s.retryDelay, + ...a + }), + s + ) }; +} +var X_ = []; +const Y_ = J_(X_, K_), V_ = Y_.createClient; +var Nr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function ud(r) { + return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; +} +var fo = { exports: {} }; +/** + * @license + * Lodash + * Copyright OpenJS Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ +fo.exports; +(function(r, e) { + (function() { + var n, s = "4.17.21", a = 200, u = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", f = "Expected a function", l = "Invalid `variable` option passed into `_.template`", d = "__lodash_hash_undefined__", y = 500, p = "__lodash_placeholder__", m = 1, b = 2, C = 4, I = 1, O = 2, R = 1, x = 2, D = 4, U = 8, M = 16, z = 32, ht = 64, _t = 128, xt = 256, Te = 512, qe = 30, un = "...", We = 800, zt = 16, Qt = 1, yr = 2, Yr = 3, te = 1 / 0, se = 9007199254740991, Yn = 17976931348623157e292, En = 0 / 0, kt = 4294967295, Vr = kt - 1, $i = kt >>> 1, wo = [ + ["ary", _t], + ["bind", R], + ["bindKey", x], + ["curry", U], + ["curryRight", M], + ["flip", Te], + ["partial", z], + ["partialRight", ht], + ["rearg", xt] + ], An = "[object Arguments]", wr = "[object Array]", bo = "[object AsyncFunction]", cn = "[object Boolean]", fn = "[object Date]", xn = "[object DOMException]", ee = "[object Error]", br = "[object Function]", Pi = "[object GeneratorFunction]", ye = "[object Map]", Sn = "[object Number]", L = "[object Null]", k = "[object Object]", H = "[object Promise]", N = "[object Proxy]", Y = "[object RegExp]", G = "[object Set]", Q = "[object String]", mt = "[object Symbol]", at = "[object Undefined]", ft = "[object WeakMap]", yt = "[object WeakSet]", V = "[object ArrayBuffer]", pt = "[object DataView]", we = "[object Float32Array]", ln = "[object Float64Array]", Kt = "[object Int8Array]", Nt = "[object Int16Array]", oe = "[object Int32Array]", tn = "[object Uint8Array]", Rn = "[object Uint8ClampedArray]", be = "[object Uint16Array]", In = "[object Uint32Array]", Jt = /\b__p \+= '';/g, Zr = /\b(__p \+=) '' \+/g, hn = /(__e\(.*?\)|\b__t\)) \+\n'';/g, Fi = /&(?:amp|lt|gt|quot|#39);/g, Mi = /[&<>"']/g, Di = RegExp(Fi.source), Qr = RegExp(Mi.source), Vn = /<%-([\s\S]+?)%>/g, Dt = /<%([\s\S]+?)%>/g, Ot = /<%=([\s\S]+?)%>/g, ae = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, ue = /^\w*$/, Xt = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, $t = /[\\^$.*+?()[\]{}|]/g, Be = RegExp($t.source), _e = /^\s+/, On = /\s/, Od = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, Td = /\{\n\/\* \[wrapped with (.+)\] \*/, Ld = /,? & /, $d = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, Pd = /[()=,{}\[\]\/\s]/, Fd = /\\(\\)?/g, Md = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g, yu = /\w*$/, Dd = /^[-+]0x[0-9a-f]+$/i, Ud = /^0b[01]+$/i, kd = /^\[object .+?Constructor\]$/, Nd = /^0o[0-7]+$/i, qd = /^(?:0|[1-9]\d*)$/, Wd = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Ui = /($^)/, Bd = /['\n\r\u2028\u2029\\]/g, ki = "\\ud800-\\udfff", Hd = "\\u0300-\\u036f", Gd = "\\ufe20-\\ufe2f", jd = "\\u20d0-\\u20ff", wu = Hd + Gd + jd, bu = "\\u2700-\\u27bf", _u = "a-z\\xdf-\\xf6\\xf8-\\xff", zd = "\\xac\\xb1\\xd7\\xf7", Kd = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Jd = "\\u2000-\\u206f", Xd = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", Cu = "A-Z\\xc0-\\xd6\\xd8-\\xde", Eu = "\\ufe0e\\ufe0f", Au = zd + Kd + Jd + Xd, _o = "['’]", Yd = "[" + ki + "]", xu = "[" + Au + "]", Ni = "[" + wu + "]", Su = "\\d+", Vd = "[" + bu + "]", Ru = "[" + _u + "]", Iu = "[^" + ki + Au + Su + bu + _u + Cu + "]", Co = "\\ud83c[\\udffb-\\udfff]", Zd = "(?:" + Ni + "|" + Co + ")", Ou = "[^" + ki + "]", Eo = "(?:\\ud83c[\\udde6-\\uddff]){2}", Ao = "[\\ud800-\\udbff][\\udc00-\\udfff]", _r = "[" + Cu + "]", Tu = "\\u200d", Lu = "(?:" + Ru + "|" + Iu + ")", Qd = "(?:" + _r + "|" + Iu + ")", $u = "(?:" + _o + "(?:d|ll|m|re|s|t|ve))?", Pu = "(?:" + _o + "(?:D|LL|M|RE|S|T|VE))?", Fu = Zd + "?", Mu = "[" + Eu + "]?", tp = "(?:" + Tu + "(?:" + [Ou, Eo, Ao].join("|") + ")" + Mu + Fu + ")*", ep = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", np = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", Du = Mu + Fu + tp, rp = "(?:" + [Vd, Eo, Ao].join("|") + ")" + Du, ip = "(?:" + [Ou + Ni + "?", Ni, Eo, Ao, Yd].join("|") + ")", sp = RegExp(_o, "g"), op = RegExp(Ni, "g"), xo = RegExp(Co + "(?=" + Co + ")|" + ip + Du, "g"), ap = RegExp([ + _r + "?" + Ru + "+" + $u + "(?=" + [xu, _r, "$"].join("|") + ")", + Qd + "+" + Pu + "(?=" + [xu, _r + Lu, "$"].join("|") + ")", + _r + "?" + Lu + "+" + $u, + _r + "+" + Pu, + np, + ep, + Su, + rp + ].join("|"), "g"), up = RegExp("[" + Tu + ki + wu + Eu + "]"), cp = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/, fp = [ + "Array", + "Buffer", + "DataView", + "Date", + "Error", + "Float32Array", + "Float64Array", + "Function", + "Int8Array", + "Int16Array", + "Int32Array", + "Map", + "Math", + "Object", + "Promise", + "RegExp", + "Set", + "String", + "Symbol", + "TypeError", + "Uint8Array", + "Uint8ClampedArray", + "Uint16Array", + "Uint32Array", + "WeakMap", + "_", + "clearTimeout", + "isFinite", + "parseInt", + "setTimeout" + ], lp = -1, At = {}; + At[we] = At[ln] = At[Kt] = At[Nt] = At[oe] = At[tn] = At[Rn] = At[be] = At[In] = !0, At[An] = At[wr] = At[V] = At[cn] = At[pt] = At[fn] = At[ee] = At[br] = At[ye] = At[Sn] = At[k] = At[Y] = At[G] = At[Q] = At[ft] = !1; + var Ct = {}; + Ct[An] = Ct[wr] = Ct[V] = Ct[pt] = Ct[cn] = Ct[fn] = Ct[we] = Ct[ln] = Ct[Kt] = Ct[Nt] = Ct[oe] = Ct[ye] = Ct[Sn] = Ct[k] = Ct[Y] = Ct[G] = Ct[Q] = Ct[mt] = Ct[tn] = Ct[Rn] = Ct[be] = Ct[In] = !0, Ct[ee] = Ct[br] = Ct[ft] = !1; + var hp = { + // Latin-1 Supplement block. + À: "A", + Á: "A", + Â: "A", + Ã: "A", + Ä: "A", + Å: "A", + à: "a", + á: "a", + â: "a", + ã: "a", + ä: "a", + å: "a", + Ç: "C", + ç: "c", + Ð: "D", + ð: "d", + È: "E", + É: "E", + Ê: "E", + Ë: "E", + è: "e", + é: "e", + ê: "e", + ë: "e", + Ì: "I", + Í: "I", + Î: "I", + Ï: "I", + ì: "i", + í: "i", + î: "i", + ï: "i", + Ñ: "N", + ñ: "n", + Ò: "O", + Ó: "O", + Ô: "O", + Õ: "O", + Ö: "O", + Ø: "O", + ò: "o", + ó: "o", + ô: "o", + õ: "o", + ö: "o", + ø: "o", + Ù: "U", + Ú: "U", + Û: "U", + Ü: "U", + ù: "u", + ú: "u", + û: "u", + ü: "u", + Ý: "Y", + ý: "y", + ÿ: "y", + Æ: "Ae", + æ: "ae", + Þ: "Th", + þ: "th", + ß: "ss", + // Latin Extended-A block. + Ā: "A", + Ă: "A", + Ą: "A", + ā: "a", + ă: "a", + ą: "a", + Ć: "C", + Ĉ: "C", + Ċ: "C", + Č: "C", + ć: "c", + ĉ: "c", + ċ: "c", + č: "c", + Ď: "D", + Đ: "D", + ď: "d", + đ: "d", + Ē: "E", + Ĕ: "E", + Ė: "E", + Ę: "E", + Ě: "E", + ē: "e", + ĕ: "e", + ė: "e", + ę: "e", + ě: "e", + Ĝ: "G", + Ğ: "G", + Ġ: "G", + Ģ: "G", + ĝ: "g", + ğ: "g", + ġ: "g", + ģ: "g", + Ĥ: "H", + Ħ: "H", + ĥ: "h", + ħ: "h", + Ĩ: "I", + Ī: "I", + Ĭ: "I", + Į: "I", + İ: "I", + ĩ: "i", + ī: "i", + ĭ: "i", + į: "i", + ı: "i", + Ĵ: "J", + ĵ: "j", + Ķ: "K", + ķ: "k", + ĸ: "k", + Ĺ: "L", + Ļ: "L", + Ľ: "L", + Ŀ: "L", + Ł: "L", + ĺ: "l", + ļ: "l", + ľ: "l", + ŀ: "l", + ł: "l", + Ń: "N", + Ņ: "N", + Ň: "N", + Ŋ: "N", + ń: "n", + ņ: "n", + ň: "n", + ŋ: "n", + Ō: "O", + Ŏ: "O", + Ő: "O", + ō: "o", + ŏ: "o", + ő: "o", + Ŕ: "R", + Ŗ: "R", + Ř: "R", + ŕ: "r", + ŗ: "r", + ř: "r", + Ś: "S", + Ŝ: "S", + Ş: "S", + Š: "S", + ś: "s", + ŝ: "s", + ş: "s", + š: "s", + Ţ: "T", + Ť: "T", + Ŧ: "T", + ţ: "t", + ť: "t", + ŧ: "t", + Ũ: "U", + Ū: "U", + Ŭ: "U", + Ů: "U", + Ű: "U", + Ų: "U", + ũ: "u", + ū: "u", + ŭ: "u", + ů: "u", + ű: "u", + ų: "u", + Ŵ: "W", + ŵ: "w", + Ŷ: "Y", + ŷ: "y", + Ÿ: "Y", + Ź: "Z", + Ż: "Z", + Ž: "Z", + ź: "z", + ż: "z", + ž: "z", + IJ: "IJ", + ij: "ij", + Œ: "Oe", + œ: "oe", + ʼn: "'n", + ſ: "s" + }, dp = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'" + }, pp = { + "&": "&", + "<": "<", + ">": ">", + """: '"', + "'": "'" + }, gp = { + "\\": "\\", + "'": "'", + "\n": "n", + "\r": "r", + "\u2028": "u2028", + "\u2029": "u2029" + }, vp = parseFloat, mp = parseInt, Uu = typeof Nr == "object" && Nr && Nr.Object === Object && Nr, yp = typeof self == "object" && self && self.Object === Object && self, Yt = Uu || yp || Function("return this")(), So = e && !e.nodeType && e, Zn = So && !0 && r && !r.nodeType && r, ku = Zn && Zn.exports === So, Ro = ku && Uu.process, Le = function() { + try { + var E = Zn && Zn.require && Zn.require("util").types; + return E || Ro && Ro.binding && Ro.binding("util"); + } catch { + } + }(), Nu = Le && Le.isArrayBuffer, qu = Le && Le.isDate, Wu = Le && Le.isMap, Bu = Le && Le.isRegExp, Hu = Le && Le.isSet, Gu = Le && Le.isTypedArray; + function Ce(E, T, S) { + switch (S.length) { + case 0: + return E.call(T); + case 1: + return E.call(T, S[0]); + case 2: + return E.call(T, S[0], S[1]); + case 3: + return E.call(T, S[0], S[1], S[2]); + } + return E.apply(T, S); + } + function wp(E, T, S, B) { + for (var Z = -1, dt = E == null ? 0 : E.length; ++Z < dt; ) { + var qt = E[Z]; + T(B, qt, S(qt), E); + } + return B; + } + function $e(E, T) { + for (var S = -1, B = E == null ? 0 : E.length; ++S < B && T(E[S], S, E) !== !1; ) + ; + return E; + } + function bp(E, T) { + for (var S = E == null ? 0 : E.length; S-- && T(E[S], S, E) !== !1; ) + ; + return E; + } + function ju(E, T) { + for (var S = -1, B = E == null ? 0 : E.length; ++S < B; ) + if (!T(E[S], S, E)) + return !1; + return !0; + } + function Tn(E, T) { + for (var S = -1, B = E == null ? 0 : E.length, Z = 0, dt = []; ++S < B; ) { + var qt = E[S]; + T(qt, S, E) && (dt[Z++] = qt); + } + return dt; + } + function qi(E, T) { + var S = E == null ? 0 : E.length; + return !!S && Cr(E, T, 0) > -1; + } + function Io(E, T, S) { + for (var B = -1, Z = E == null ? 0 : E.length; ++B < Z; ) + if (S(T, E[B])) + return !0; + return !1; + } + function St(E, T) { + for (var S = -1, B = E == null ? 0 : E.length, Z = Array(B); ++S < B; ) + Z[S] = T(E[S], S, E); + return Z; + } + function Ln(E, T) { + for (var S = -1, B = T.length, Z = E.length; ++S < B; ) + E[Z + S] = T[S]; + return E; + } + function Oo(E, T, S, B) { + var Z = -1, dt = E == null ? 0 : E.length; + for (B && dt && (S = E[++Z]); ++Z < dt; ) + S = T(S, E[Z], Z, E); + return S; + } + function _p(E, T, S, B) { + var Z = E == null ? 0 : E.length; + for (B && Z && (S = E[--Z]); Z--; ) + S = T(S, E[Z], Z, E); + return S; + } + function To(E, T) { + for (var S = -1, B = E == null ? 0 : E.length; ++S < B; ) + if (T(E[S], S, E)) + return !0; + return !1; + } + var Cp = Lo("length"); + function Ep(E) { + return E.split(""); + } + function Ap(E) { + return E.match($d) || []; + } + function zu(E, T, S) { + var B; + return S(E, function(Z, dt, qt) { + if (T(Z, dt, qt)) + return B = dt, !1; + }), B; + } + function Wi(E, T, S, B) { + for (var Z = E.length, dt = S + (B ? 1 : -1); B ? dt-- : ++dt < Z; ) + if (T(E[dt], dt, E)) + return dt; + return -1; + } + function Cr(E, T, S) { + return T === T ? Dp(E, T, S) : Wi(E, Ku, S); + } + function xp(E, T, S, B) { + for (var Z = S - 1, dt = E.length; ++Z < dt; ) + if (B(E[Z], T)) + return Z; + return -1; + } + function Ku(E) { + return E !== E; + } + function Ju(E, T) { + var S = E == null ? 0 : E.length; + return S ? Po(E, T) / S : En; + } + function Lo(E) { + return function(T) { + return T == null ? n : T[E]; + }; + } + function $o(E) { + return function(T) { + return E == null ? n : E[T]; + }; + } + function Xu(E, T, S, B, Z) { + return Z(E, function(dt, qt, wt) { + S = B ? (B = !1, dt) : T(S, dt, qt, wt); + }), S; + } + function Sp(E, T) { + var S = E.length; + for (E.sort(T); S--; ) + E[S] = E[S].value; + return E; + } + function Po(E, T) { + for (var S, B = -1, Z = E.length; ++B < Z; ) { + var dt = T(E[B]); + dt !== n && (S = S === n ? dt : S + dt); + } + return S; + } + function Fo(E, T) { + for (var S = -1, B = Array(E); ++S < E; ) + B[S] = T(S); + return B; + } + function Rp(E, T) { + return St(T, function(S) { + return [S, E[S]]; + }); + } + function Yu(E) { + return E && E.slice(0, tc(E) + 1).replace(_e, ""); + } + function Ee(E) { + return function(T) { + return E(T); + }; + } + function Mo(E, T) { + return St(T, function(S) { + return E[S]; + }); + } + function ti(E, T) { + return E.has(T); + } + function Vu(E, T) { + for (var S = -1, B = E.length; ++S < B && Cr(T, E[S], 0) > -1; ) + ; + return S; + } + function Zu(E, T) { + for (var S = E.length; S-- && Cr(T, E[S], 0) > -1; ) + ; + return S; + } + function Ip(E, T) { + for (var S = E.length, B = 0; S--; ) + E[S] === T && ++B; + return B; + } + var Op = $o(hp), Tp = $o(dp); + function Lp(E) { + return "\\" + gp[E]; + } + function $p(E, T) { + return E == null ? n : E[T]; + } + function Er(E) { + return up.test(E); + } + function Pp(E) { + return cp.test(E); + } + function Fp(E) { + for (var T, S = []; !(T = E.next()).done; ) + S.push(T.value); + return S; + } + function Do(E) { + var T = -1, S = Array(E.size); + return E.forEach(function(B, Z) { + S[++T] = [Z, B]; + }), S; + } + function Qu(E, T) { + return function(S) { + return E(T(S)); + }; + } + function $n(E, T) { + for (var S = -1, B = E.length, Z = 0, dt = []; ++S < B; ) { + var qt = E[S]; + (qt === T || qt === p) && (E[S] = p, dt[Z++] = S); + } + return dt; + } + function Bi(E) { + var T = -1, S = Array(E.size); + return E.forEach(function(B) { + S[++T] = B; + }), S; + } + function Mp(E) { + var T = -1, S = Array(E.size); + return E.forEach(function(B) { + S[++T] = [B, B]; + }), S; + } + function Dp(E, T, S) { + for (var B = S - 1, Z = E.length; ++B < Z; ) + if (E[B] === T) + return B; + return -1; + } + function Up(E, T, S) { + for (var B = S + 1; B--; ) + if (E[B] === T) + return B; + return B; + } + function Ar(E) { + return Er(E) ? Np(E) : Cp(E); + } + function He(E) { + return Er(E) ? qp(E) : Ep(E); + } + function tc(E) { + for (var T = E.length; T-- && On.test(E.charAt(T)); ) + ; + return T; + } + var kp = $o(pp); + function Np(E) { + for (var T = xo.lastIndex = 0; xo.test(E); ) + ++T; + return T; + } + function qp(E) { + return E.match(xo) || []; + } + function Wp(E) { + return E.match(ap) || []; + } + var Bp = function E(T) { + T = T == null ? Yt : xr.defaults(Yt.Object(), T, xr.pick(Yt, fp)); + var S = T.Array, B = T.Date, Z = T.Error, dt = T.Function, qt = T.Math, wt = T.Object, Uo = T.RegExp, Hp = T.String, Pe = T.TypeError, Hi = S.prototype, Gp = dt.prototype, Sr = wt.prototype, Gi = T["__core-js_shared__"], ji = Gp.toString, vt = Sr.hasOwnProperty, jp = 0, ec = function() { + var t = /[^.]+$/.exec(Gi && Gi.keys && Gi.keys.IE_PROTO || ""); + return t ? "Symbol(src)_1." + t : ""; + }(), zi = Sr.toString, zp = ji.call(wt), Kp = Yt._, Jp = Uo( + "^" + ji.call(vt).replace($t, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" + ), Ki = ku ? T.Buffer : n, Pn = T.Symbol, Ji = T.Uint8Array, nc = Ki ? Ki.allocUnsafe : n, Xi = Qu(wt.getPrototypeOf, wt), rc = wt.create, ic = Sr.propertyIsEnumerable, Yi = Hi.splice, sc = Pn ? Pn.isConcatSpreadable : n, ei = Pn ? Pn.iterator : n, Qn = Pn ? Pn.toStringTag : n, Vi = function() { + try { + var t = ir(wt, "defineProperty"); + return t({}, "", {}), t; + } catch { + } + }(), Xp = T.clearTimeout !== Yt.clearTimeout && T.clearTimeout, Yp = B && B.now !== Yt.Date.now && B.now, Vp = T.setTimeout !== Yt.setTimeout && T.setTimeout, Zi = qt.ceil, Qi = qt.floor, ko = wt.getOwnPropertySymbols, Zp = Ki ? Ki.isBuffer : n, oc = T.isFinite, Qp = Hi.join, tg = Qu(wt.keys, wt), Wt = qt.max, ne = qt.min, eg = B.now, ng = T.parseInt, ac = qt.random, rg = Hi.reverse, No = ir(T, "DataView"), ni = ir(T, "Map"), qo = ir(T, "Promise"), Rr = ir(T, "Set"), ri = ir(T, "WeakMap"), ii = ir(wt, "create"), ts = ri && new ri(), Ir = {}, ig = sr(No), sg = sr(ni), og = sr(qo), ag = sr(Rr), ug = sr(ri), es = Pn ? Pn.prototype : n, si = es ? es.valueOf : n, uc = es ? es.toString : n; + function g(t) { + if (Tt(t) && !tt(t) && !(t instanceof ut)) { + if (t instanceof Fe) + return t; + if (vt.call(t, "__wrapped__")) + return ff(t); + } + return new Fe(t); + } + var Or = function() { + function t() { + } + return function(i) { + if (!It(i)) + return {}; + if (rc) + return rc(i); + t.prototype = i; + var o = new t(); + return t.prototype = n, o; + }; + }(); + function ns() { + } + function Fe(t, i) { + this.__wrapped__ = t, this.__actions__ = [], this.__chain__ = !!i, this.__index__ = 0, this.__values__ = n; + } + g.templateSettings = { + /** + * Used to detect `data` property values to be HTML-escaped. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + escape: Vn, + /** + * Used to detect code to be evaluated. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + evaluate: Dt, + /** + * Used to detect `data` property values to inject. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + interpolate: Ot, + /** + * Used to reference the data object in the template text. + * + * @memberOf _.templateSettings + * @type {string} + */ + variable: "", + /** + * Used to import variables into the compiled template. + * + * @memberOf _.templateSettings + * @type {Object} + */ + imports: { + /** + * A reference to the `lodash` function. + * + * @memberOf _.templateSettings.imports + * @type {Function} + */ + _: g + } + }, g.prototype = ns.prototype, g.prototype.constructor = g, Fe.prototype = Or(ns.prototype), Fe.prototype.constructor = Fe; + function ut(t) { + this.__wrapped__ = t, this.__actions__ = [], this.__dir__ = 1, this.__filtered__ = !1, this.__iteratees__ = [], this.__takeCount__ = kt, this.__views__ = []; + } + function cg() { + var t = new ut(this.__wrapped__); + return t.__actions__ = he(this.__actions__), t.__dir__ = this.__dir__, t.__filtered__ = this.__filtered__, t.__iteratees__ = he(this.__iteratees__), t.__takeCount__ = this.__takeCount__, t.__views__ = he(this.__views__), t; + } + function fg() { + if (this.__filtered__) { + var t = new ut(this); + t.__dir__ = -1, t.__filtered__ = !0; + } else + t = this.clone(), t.__dir__ *= -1; + return t; + } + function lg() { + var t = this.__wrapped__.value(), i = this.__dir__, o = tt(t), c = i < 0, h = o ? t.length : 0, v = E0(0, h, this.__views__), w = v.start, _ = v.end, A = _ - w, $ = c ? _ : w - 1, P = this.__iteratees__, F = P.length, q = 0, j = ne(A, this.__takeCount__); + if (!o || !c && h == A && j == A) + return $c(t, this.__actions__); + var J = []; + t: + for (; A-- && q < j; ) { + $ += i; + for (var rt = -1, X = t[$]; ++rt < F; ) { + var ot = P[rt], lt = ot.iteratee, Se = ot.type, le = lt(X); + if (Se == yr) + X = le; + else if (!le) { + if (Se == Qt) + continue t; + break t; + } + } + J[q++] = X; + } + return J; + } + ut.prototype = Or(ns.prototype), ut.prototype.constructor = ut; + function tr(t) { + var i = -1, o = t == null ? 0 : t.length; + for (this.clear(); ++i < o; ) { + var c = t[i]; + this.set(c[0], c[1]); + } + } + function hg() { + this.__data__ = ii ? ii(null) : {}, this.size = 0; + } + function dg(t) { + var i = this.has(t) && delete this.__data__[t]; + return this.size -= i ? 1 : 0, i; + } + function pg(t) { + var i = this.__data__; + if (ii) { + var o = i[t]; + return o === d ? n : o; + } + return vt.call(i, t) ? i[t] : n; + } + function gg(t) { + var i = this.__data__; + return ii ? i[t] !== n : vt.call(i, t); + } + function vg(t, i) { + var o = this.__data__; + return this.size += this.has(t) ? 0 : 1, o[t] = ii && i === n ? d : i, this; + } + tr.prototype.clear = hg, tr.prototype.delete = dg, tr.prototype.get = pg, tr.prototype.has = gg, tr.prototype.set = vg; + function dn(t) { + var i = -1, o = t == null ? 0 : t.length; + for (this.clear(); ++i < o; ) { + var c = t[i]; + this.set(c[0], c[1]); + } + } + function mg() { + this.__data__ = [], this.size = 0; + } + function yg(t) { + var i = this.__data__, o = rs(i, t); + if (o < 0) + return !1; + var c = i.length - 1; + return o == c ? i.pop() : Yi.call(i, o, 1), --this.size, !0; + } + function wg(t) { + var i = this.__data__, o = rs(i, t); + return o < 0 ? n : i[o][1]; + } + function bg(t) { + return rs(this.__data__, t) > -1; + } + function _g(t, i) { + var o = this.__data__, c = rs(o, t); + return c < 0 ? (++this.size, o.push([t, i])) : o[c][1] = i, this; + } + dn.prototype.clear = mg, dn.prototype.delete = yg, dn.prototype.get = wg, dn.prototype.has = bg, dn.prototype.set = _g; + function pn(t) { + var i = -1, o = t == null ? 0 : t.length; + for (this.clear(); ++i < o; ) { + var c = t[i]; + this.set(c[0], c[1]); + } + } + function Cg() { + this.size = 0, this.__data__ = { + hash: new tr(), + map: new (ni || dn)(), + string: new tr() + }; + } + function Eg(t) { + var i = gs(this, t).delete(t); + return this.size -= i ? 1 : 0, i; + } + function Ag(t) { + return gs(this, t).get(t); + } + function xg(t) { + return gs(this, t).has(t); + } + function Sg(t, i) { + var o = gs(this, t), c = o.size; + return o.set(t, i), this.size += o.size == c ? 0 : 1, this; + } + pn.prototype.clear = Cg, pn.prototype.delete = Eg, pn.prototype.get = Ag, pn.prototype.has = xg, pn.prototype.set = Sg; + function er(t) { + var i = -1, o = t == null ? 0 : t.length; + for (this.__data__ = new pn(); ++i < o; ) + this.add(t[i]); + } + function Rg(t) { + return this.__data__.set(t, d), this; + } + function Ig(t) { + return this.__data__.has(t); + } + er.prototype.add = er.prototype.push = Rg, er.prototype.has = Ig; + function Ge(t) { + var i = this.__data__ = new dn(t); + this.size = i.size; + } + function Og() { + this.__data__ = new dn(), this.size = 0; + } + function Tg(t) { + var i = this.__data__, o = i.delete(t); + return this.size = i.size, o; + } + function Lg(t) { + return this.__data__.get(t); + } + function $g(t) { + return this.__data__.has(t); + } + function Pg(t, i) { + var o = this.__data__; + if (o instanceof dn) { + var c = o.__data__; + if (!ni || c.length < a - 1) + return c.push([t, i]), this.size = ++o.size, this; + o = this.__data__ = new pn(c); + } + return o.set(t, i), this.size = o.size, this; + } + Ge.prototype.clear = Og, Ge.prototype.delete = Tg, Ge.prototype.get = Lg, Ge.prototype.has = $g, Ge.prototype.set = Pg; + function cc(t, i) { + var o = tt(t), c = !o && or(t), h = !o && !c && kn(t), v = !o && !c && !h && Pr(t), w = o || c || h || v, _ = w ? Fo(t.length, Hp) : [], A = _.length; + for (var $ in t) + (i || vt.call(t, $)) && !(w && // Safari 9 has enumerable `arguments.length` in strict mode. + ($ == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. + h && ($ == "offset" || $ == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. + v && ($ == "buffer" || $ == "byteLength" || $ == "byteOffset") || // Skip index properties. + yn($, A))) && _.push($); + return _; + } + function fc(t) { + var i = t.length; + return i ? t[Vo(0, i - 1)] : n; + } + function Fg(t, i) { + return vs(he(t), nr(i, 0, t.length)); + } + function Mg(t) { + return vs(he(t)); + } + function Wo(t, i, o) { + (o !== n && !je(t[i], o) || o === n && !(i in t)) && gn(t, i, o); + } + function oi(t, i, o) { + var c = t[i]; + (!(vt.call(t, i) && je(c, o)) || o === n && !(i in t)) && gn(t, i, o); + } + function rs(t, i) { + for (var o = t.length; o--; ) + if (je(t[o][0], i)) + return o; + return -1; + } + function Dg(t, i, o, c) { + return Fn(t, function(h, v, w) { + i(c, h, o(h), w); + }), c; + } + function lc(t, i) { + return t && nn(i, Gt(i), t); + } + function Ug(t, i) { + return t && nn(i, pe(i), t); + } + function gn(t, i, o) { + i == "__proto__" && Vi ? Vi(t, i, { + configurable: !0, + enumerable: !0, + value: o, + writable: !0 + }) : t[i] = o; + } + function Bo(t, i) { + for (var o = -1, c = i.length, h = S(c), v = t == null; ++o < c; ) + h[o] = v ? n : Ca(t, i[o]); + return h; + } + function nr(t, i, o) { + return t === t && (o !== n && (t = t <= o ? t : o), i !== n && (t = t >= i ? t : i)), t; + } + function Me(t, i, o, c, h, v) { + var w, _ = i & m, A = i & b, $ = i & C; + if (o && (w = h ? o(t, c, h, v) : o(t)), w !== n) + return w; + if (!It(t)) + return t; + var P = tt(t); + if (P) { + if (w = x0(t), !_) + return he(t, w); + } else { + var F = re(t), q = F == br || F == Pi; + if (kn(t)) + return Mc(t, _); + if (F == k || F == An || q && !h) { + if (w = A || q ? {} : tf(t), !_) + return A ? p0(t, Ug(w, t)) : d0(t, lc(w, t)); + } else { + if (!Ct[F]) + return h ? t : {}; + w = S0(t, F, _); + } + } + v || (v = new Ge()); + var j = v.get(t); + if (j) + return j; + v.set(t, w), Tf(t) ? t.forEach(function(X) { + w.add(Me(X, i, o, X, t, v)); + }) : If(t) && t.forEach(function(X, ot) { + w.set(ot, Me(X, i, o, ot, t, v)); + }); + var J = $ ? A ? ua : aa : A ? pe : Gt, rt = P ? n : J(t); + return $e(rt || t, function(X, ot) { + rt && (ot = X, X = t[ot]), oi(w, ot, Me(X, i, o, ot, t, v)); + }), w; + } + function kg(t) { + var i = Gt(t); + return function(o) { + return hc(o, t, i); + }; + } + function hc(t, i, o) { + var c = o.length; + if (t == null) + return !c; + for (t = wt(t); c--; ) { + var h = o[c], v = i[h], w = t[h]; + if (w === n && !(h in t) || !v(w)) + return !1; + } + return !0; + } + function dc(t, i, o) { + if (typeof t != "function") + throw new Pe(f); + return di(function() { + t.apply(n, o); + }, i); + } + function ai(t, i, o, c) { + var h = -1, v = qi, w = !0, _ = t.length, A = [], $ = i.length; + if (!_) + return A; + o && (i = St(i, Ee(o))), c ? (v = Io, w = !1) : i.length >= a && (v = ti, w = !1, i = new er(i)); + t: + for (; ++h < _; ) { + var P = t[h], F = o == null ? P : o(P); + if (P = c || P !== 0 ? P : 0, w && F === F) { + for (var q = $; q--; ) + if (i[q] === F) + continue t; + A.push(P); + } else + v(i, F, c) || A.push(P); + } + return A; + } + var Fn = qc(en), pc = qc(Go, !0); + function Ng(t, i) { + var o = !0; + return Fn(t, function(c, h, v) { + return o = !!i(c, h, v), o; + }), o; + } + function is(t, i, o) { + for (var c = -1, h = t.length; ++c < h; ) { + var v = t[c], w = i(v); + if (w != null && (_ === n ? w === w && !xe(w) : o(w, _))) + var _ = w, A = v; + } + return A; + } + function qg(t, i, o, c) { + var h = t.length; + for (o = nt(o), o < 0 && (o = -o > h ? 0 : h + o), c = c === n || c > h ? h : nt(c), c < 0 && (c += h), c = o > c ? 0 : $f(c); o < c; ) + t[o++] = i; + return t; + } + function gc(t, i) { + var o = []; + return Fn(t, function(c, h, v) { + i(c, h, v) && o.push(c); + }), o; + } + function Vt(t, i, o, c, h) { + var v = -1, w = t.length; + for (o || (o = I0), h || (h = []); ++v < w; ) { + var _ = t[v]; + i > 0 && o(_) ? i > 1 ? Vt(_, i - 1, o, c, h) : Ln(h, _) : c || (h[h.length] = _); + } + return h; + } + var Ho = Wc(), vc = Wc(!0); + function en(t, i) { + return t && Ho(t, i, Gt); + } + function Go(t, i) { + return t && vc(t, i, Gt); + } + function ss(t, i) { + return Tn(i, function(o) { + return wn(t[o]); + }); + } + function rr(t, i) { + i = Dn(i, t); + for (var o = 0, c = i.length; t != null && o < c; ) + t = t[rn(i[o++])]; + return o && o == c ? t : n; + } + function mc(t, i, o) { + var c = i(t); + return tt(t) ? c : Ln(c, o(t)); + } + function ce(t) { + return t == null ? t === n ? at : L : Qn && Qn in wt(t) ? C0(t) : M0(t); + } + function jo(t, i) { + return t > i; + } + function Wg(t, i) { + return t != null && vt.call(t, i); + } + function Bg(t, i) { + return t != null && i in wt(t); + } + function Hg(t, i, o) { + return t >= ne(i, o) && t < Wt(i, o); + } + function zo(t, i, o) { + for (var c = o ? Io : qi, h = t[0].length, v = t.length, w = v, _ = S(v), A = 1 / 0, $ = []; w--; ) { + var P = t[w]; + w && i && (P = St(P, Ee(i))), A = ne(P.length, A), _[w] = !o && (i || h >= 120 && P.length >= 120) ? new er(w && P) : n; + } + P = t[0]; + var F = -1, q = _[0]; + t: + for (; ++F < h && $.length < A; ) { + var j = P[F], J = i ? i(j) : j; + if (j = o || j !== 0 ? j : 0, !(q ? ti(q, J) : c($, J, o))) { + for (w = v; --w; ) { + var rt = _[w]; + if (!(rt ? ti(rt, J) : c(t[w], J, o))) + continue t; + } + q && q.push(J), $.push(j); + } + } + return $; + } + function Gg(t, i, o, c) { + return en(t, function(h, v, w) { + i(c, o(h), v, w); + }), c; + } + function ui(t, i, o) { + i = Dn(i, t), t = sf(t, i); + var c = t == null ? t : t[rn(Ue(i))]; + return c == null ? n : Ce(c, t, o); + } + function yc(t) { + return Tt(t) && ce(t) == An; + } + function jg(t) { + return Tt(t) && ce(t) == V; + } + function zg(t) { + return Tt(t) && ce(t) == fn; + } + function ci(t, i, o, c, h) { + return t === i ? !0 : t == null || i == null || !Tt(t) && !Tt(i) ? t !== t && i !== i : Kg(t, i, o, c, ci, h); + } + function Kg(t, i, o, c, h, v) { + var w = tt(t), _ = tt(i), A = w ? wr : re(t), $ = _ ? wr : re(i); + A = A == An ? k : A, $ = $ == An ? k : $; + var P = A == k, F = $ == k, q = A == $; + if (q && kn(t)) { + if (!kn(i)) + return !1; + w = !0, P = !1; + } + if (q && !P) + return v || (v = new Ge()), w || Pr(t) ? Vc(t, i, o, c, h, v) : b0(t, i, A, o, c, h, v); + if (!(o & I)) { + var j = P && vt.call(t, "__wrapped__"), J = F && vt.call(i, "__wrapped__"); + if (j || J) { + var rt = j ? t.value() : t, X = J ? i.value() : i; + return v || (v = new Ge()), h(rt, X, o, c, v); + } + } + return q ? (v || (v = new Ge()), _0(t, i, o, c, h, v)) : !1; + } + function Jg(t) { + return Tt(t) && re(t) == ye; + } + function Ko(t, i, o, c) { + var h = o.length, v = h, w = !c; + if (t == null) + return !v; + for (t = wt(t); h--; ) { + var _ = o[h]; + if (w && _[2] ? _[1] !== t[_[0]] : !(_[0] in t)) + return !1; + } + for (; ++h < v; ) { + _ = o[h]; + var A = _[0], $ = t[A], P = _[1]; + if (w && _[2]) { + if ($ === n && !(A in t)) + return !1; + } else { + var F = new Ge(); + if (c) + var q = c($, P, A, t, i, F); + if (!(q === n ? ci(P, $, I | O, c, F) : q)) + return !1; + } + } + return !0; + } + function wc(t) { + if (!It(t) || T0(t)) + return !1; + var i = wn(t) ? Jp : kd; + return i.test(sr(t)); + } + function Xg(t) { + return Tt(t) && ce(t) == Y; + } + function Yg(t) { + return Tt(t) && re(t) == G; + } + function Vg(t) { + return Tt(t) && Cs(t.length) && !!At[ce(t)]; + } + function bc(t) { + return typeof t == "function" ? t : t == null ? ge : typeof t == "object" ? tt(t) ? Ec(t[0], t[1]) : Cc(t) : Hf(t); + } + function Jo(t) { + if (!hi(t)) + return tg(t); + var i = []; + for (var o in wt(t)) + vt.call(t, o) && o != "constructor" && i.push(o); + return i; + } + function Zg(t) { + if (!It(t)) + return F0(t); + var i = hi(t), o = []; + for (var c in t) + c == "constructor" && (i || !vt.call(t, c)) || o.push(c); + return o; + } + function Xo(t, i) { + return t < i; + } + function _c(t, i) { + var o = -1, c = de(t) ? S(t.length) : []; + return Fn(t, function(h, v, w) { + c[++o] = i(h, v, w); + }), c; + } + function Cc(t) { + var i = fa(t); + return i.length == 1 && i[0][2] ? nf(i[0][0], i[0][1]) : function(o) { + return o === t || Ko(o, t, i); + }; + } + function Ec(t, i) { + return ha(t) && ef(i) ? nf(rn(t), i) : function(o) { + var c = Ca(o, t); + return c === n && c === i ? Ea(o, t) : ci(i, c, I | O); + }; + } + function os(t, i, o, c, h) { + t !== i && Ho(i, function(v, w) { + if (h || (h = new Ge()), It(v)) + Qg(t, i, w, o, os, c, h); + else { + var _ = c ? c(pa(t, w), v, w + "", t, i, h) : n; + _ === n && (_ = v), Wo(t, w, _); + } + }, pe); + } + function Qg(t, i, o, c, h, v, w) { + var _ = pa(t, o), A = pa(i, o), $ = w.get(A); + if ($) { + Wo(t, o, $); + return; + } + var P = v ? v(_, A, o + "", t, i, w) : n, F = P === n; + if (F) { + var q = tt(A), j = !q && kn(A), J = !q && !j && Pr(A); + P = A, q || j || J ? tt(_) ? P = _ : Pt(_) ? P = he(_) : j ? (F = !1, P = Mc(A, !0)) : J ? (F = !1, P = Dc(A, !0)) : P = [] : pi(A) || or(A) ? (P = _, or(_) ? P = Pf(_) : (!It(_) || wn(_)) && (P = tf(A))) : F = !1; + } + F && (w.set(A, P), h(P, A, c, v, w), w.delete(A)), Wo(t, o, P); + } + function Ac(t, i) { + var o = t.length; + if (o) + return i += i < 0 ? o : 0, yn(i, o) ? t[i] : n; + } + function xc(t, i, o) { + i.length ? i = St(i, function(v) { + return tt(v) ? function(w) { + return rr(w, v.length === 1 ? v[0] : v); + } : v; + }) : i = [ge]; + var c = -1; + i = St(i, Ee(K())); + var h = _c(t, function(v, w, _) { + var A = St(i, function($) { + return $(v); + }); + return { criteria: A, index: ++c, value: v }; + }); + return Sp(h, function(v, w) { + return h0(v, w, o); + }); + } + function t0(t, i) { + return Sc(t, i, function(o, c) { + return Ea(t, c); + }); + } + function Sc(t, i, o) { + for (var c = -1, h = i.length, v = {}; ++c < h; ) { + var w = i[c], _ = rr(t, w); + o(_, w) && fi(v, Dn(w, t), _); + } + return v; + } + function e0(t) { + return function(i) { + return rr(i, t); + }; + } + function Yo(t, i, o, c) { + var h = c ? xp : Cr, v = -1, w = i.length, _ = t; + for (t === i && (i = he(i)), o && (_ = St(t, Ee(o))); ++v < w; ) + for (var A = 0, $ = i[v], P = o ? o($) : $; (A = h(_, P, A, c)) > -1; ) + _ !== t && Yi.call(_, A, 1), Yi.call(t, A, 1); + return t; + } + function Rc(t, i) { + for (var o = t ? i.length : 0, c = o - 1; o--; ) { + var h = i[o]; + if (o == c || h !== v) { + var v = h; + yn(h) ? Yi.call(t, h, 1) : ta(t, h); + } + } + return t; + } + function Vo(t, i) { + return t + Qi(ac() * (i - t + 1)); + } + function n0(t, i, o, c) { + for (var h = -1, v = Wt(Zi((i - t) / (o || 1)), 0), w = S(v); v--; ) + w[c ? v : ++h] = t, t += o; + return w; + } + function Zo(t, i) { + var o = ""; + if (!t || i < 1 || i > se) + return o; + do + i % 2 && (o += t), i = Qi(i / 2), i && (t += t); + while (i); + return o; + } + function st(t, i) { + return ga(rf(t, i, ge), t + ""); + } + function r0(t) { + return fc(Fr(t)); + } + function i0(t, i) { + var o = Fr(t); + return vs(o, nr(i, 0, o.length)); + } + function fi(t, i, o, c) { + if (!It(t)) + return t; + i = Dn(i, t); + for (var h = -1, v = i.length, w = v - 1, _ = t; _ != null && ++h < v; ) { + var A = rn(i[h]), $ = o; + if (A === "__proto__" || A === "constructor" || A === "prototype") + return t; + if (h != w) { + var P = _[A]; + $ = c ? c(P, A, _) : n, $ === n && ($ = It(P) ? P : yn(i[h + 1]) ? [] : {}); + } + oi(_, A, $), _ = _[A]; + } + return t; + } + var Ic = ts ? function(t, i) { + return ts.set(t, i), t; + } : ge, s0 = Vi ? function(t, i) { + return Vi(t, "toString", { + configurable: !0, + enumerable: !1, + value: xa(i), + writable: !0 + }); + } : ge; + function o0(t) { + return vs(Fr(t)); + } + function De(t, i, o) { + var c = -1, h = t.length; + i < 0 && (i = -i > h ? 0 : h + i), o = o > h ? h : o, o < 0 && (o += h), h = i > o ? 0 : o - i >>> 0, i >>>= 0; + for (var v = S(h); ++c < h; ) + v[c] = t[c + i]; + return v; + } + function a0(t, i) { + var o; + return Fn(t, function(c, h, v) { + return o = i(c, h, v), !o; + }), !!o; + } + function as(t, i, o) { + var c = 0, h = t == null ? c : t.length; + if (typeof i == "number" && i === i && h <= $i) { + for (; c < h; ) { + var v = c + h >>> 1, w = t[v]; + w !== null && !xe(w) && (o ? w <= i : w < i) ? c = v + 1 : h = v; + } + return h; + } + return Qo(t, i, ge, o); + } + function Qo(t, i, o, c) { + var h = 0, v = t == null ? 0 : t.length; + if (v === 0) + return 0; + i = o(i); + for (var w = i !== i, _ = i === null, A = xe(i), $ = i === n; h < v; ) { + var P = Qi((h + v) / 2), F = o(t[P]), q = F !== n, j = F === null, J = F === F, rt = xe(F); + if (w) + var X = c || J; + else + $ ? X = J && (c || q) : _ ? X = J && q && (c || !j) : A ? X = J && q && !j && (c || !rt) : j || rt ? X = !1 : X = c ? F <= i : F < i; + X ? h = P + 1 : v = P; + } + return ne(v, Vr); + } + function Oc(t, i) { + for (var o = -1, c = t.length, h = 0, v = []; ++o < c; ) { + var w = t[o], _ = i ? i(w) : w; + if (!o || !je(_, A)) { + var A = _; + v[h++] = w === 0 ? 0 : w; + } + } + return v; + } + function Tc(t) { + return typeof t == "number" ? t : xe(t) ? En : +t; + } + function Ae(t) { + if (typeof t == "string") + return t; + if (tt(t)) + return St(t, Ae) + ""; + if (xe(t)) + return uc ? uc.call(t) : ""; + var i = t + ""; + return i == "0" && 1 / t == -te ? "-0" : i; + } + function Mn(t, i, o) { + var c = -1, h = qi, v = t.length, w = !0, _ = [], A = _; + if (o) + w = !1, h = Io; + else if (v >= a) { + var $ = i ? null : y0(t); + if ($) + return Bi($); + w = !1, h = ti, A = new er(); + } else + A = i ? [] : _; + t: + for (; ++c < v; ) { + var P = t[c], F = i ? i(P) : P; + if (P = o || P !== 0 ? P : 0, w && F === F) { + for (var q = A.length; q--; ) + if (A[q] === F) + continue t; + i && A.push(F), _.push(P); + } else + h(A, F, o) || (A !== _ && A.push(F), _.push(P)); + } + return _; + } + function ta(t, i) { + return i = Dn(i, t), t = sf(t, i), t == null || delete t[rn(Ue(i))]; + } + function Lc(t, i, o, c) { + return fi(t, i, o(rr(t, i)), c); + } + function us(t, i, o, c) { + for (var h = t.length, v = c ? h : -1; (c ? v-- : ++v < h) && i(t[v], v, t); ) + ; + return o ? De(t, c ? 0 : v, c ? v + 1 : h) : De(t, c ? v + 1 : 0, c ? h : v); + } + function $c(t, i) { + var o = t; + return o instanceof ut && (o = o.value()), Oo(i, function(c, h) { + return h.func.apply(h.thisArg, Ln([c], h.args)); + }, o); + } + function ea(t, i, o) { + var c = t.length; + if (c < 2) + return c ? Mn(t[0]) : []; + for (var h = -1, v = S(c); ++h < c; ) + for (var w = t[h], _ = -1; ++_ < c; ) + _ != h && (v[h] = ai(v[h] || w, t[_], i, o)); + return Mn(Vt(v, 1), i, o); + } + function Pc(t, i, o) { + for (var c = -1, h = t.length, v = i.length, w = {}; ++c < h; ) { + var _ = c < v ? i[c] : n; + o(w, t[c], _); + } + return w; + } + function na(t) { + return Pt(t) ? t : []; + } + function ra(t) { + return typeof t == "function" ? t : ge; + } + function Dn(t, i) { + return tt(t) ? t : ha(t, i) ? [t] : cf(gt(t)); + } + var u0 = st; + function Un(t, i, o) { + var c = t.length; + return o = o === n ? c : o, !i && o >= c ? t : De(t, i, o); + } + var Fc = Xp || function(t) { + return Yt.clearTimeout(t); + }; + function Mc(t, i) { + if (i) + return t.slice(); + var o = t.length, c = nc ? nc(o) : new t.constructor(o); + return t.copy(c), c; + } + function ia(t) { + var i = new t.constructor(t.byteLength); + return new Ji(i).set(new Ji(t)), i; + } + function c0(t, i) { + var o = i ? ia(t.buffer) : t.buffer; + return new t.constructor(o, t.byteOffset, t.byteLength); + } + function f0(t) { + var i = new t.constructor(t.source, yu.exec(t)); + return i.lastIndex = t.lastIndex, i; + } + function l0(t) { + return si ? wt(si.call(t)) : {}; + } + function Dc(t, i) { + var o = i ? ia(t.buffer) : t.buffer; + return new t.constructor(o, t.byteOffset, t.length); + } + function Uc(t, i) { + if (t !== i) { + var o = t !== n, c = t === null, h = t === t, v = xe(t), w = i !== n, _ = i === null, A = i === i, $ = xe(i); + if (!_ && !$ && !v && t > i || v && w && A && !_ && !$ || c && w && A || !o && A || !h) + return 1; + if (!c && !v && !$ && t < i || $ && o && h && !c && !v || _ && o && h || !w && h || !A) + return -1; + } + return 0; + } + function h0(t, i, o) { + for (var c = -1, h = t.criteria, v = i.criteria, w = h.length, _ = o.length; ++c < w; ) { + var A = Uc(h[c], v[c]); + if (A) { + if (c >= _) + return A; + var $ = o[c]; + return A * ($ == "desc" ? -1 : 1); + } + } + return t.index - i.index; + } + function kc(t, i, o, c) { + for (var h = -1, v = t.length, w = o.length, _ = -1, A = i.length, $ = Wt(v - w, 0), P = S(A + $), F = !c; ++_ < A; ) + P[_] = i[_]; + for (; ++h < w; ) + (F || h < v) && (P[o[h]] = t[h]); + for (; $--; ) + P[_++] = t[h++]; + return P; + } + function Nc(t, i, o, c) { + for (var h = -1, v = t.length, w = -1, _ = o.length, A = -1, $ = i.length, P = Wt(v - _, 0), F = S(P + $), q = !c; ++h < P; ) + F[h] = t[h]; + for (var j = h; ++A < $; ) + F[j + A] = i[A]; + for (; ++w < _; ) + (q || h < v) && (F[j + o[w]] = t[h++]); + return F; + } + function he(t, i) { + var o = -1, c = t.length; + for (i || (i = S(c)); ++o < c; ) + i[o] = t[o]; + return i; + } + function nn(t, i, o, c) { + var h = !o; + o || (o = {}); + for (var v = -1, w = i.length; ++v < w; ) { + var _ = i[v], A = c ? c(o[_], t[_], _, o, t) : n; + A === n && (A = t[_]), h ? gn(o, _, A) : oi(o, _, A); + } + return o; + } + function d0(t, i) { + return nn(t, la(t), i); + } + function p0(t, i) { + return nn(t, Zc(t), i); + } + function cs(t, i) { + return function(o, c) { + var h = tt(o) ? wp : Dg, v = i ? i() : {}; + return h(o, t, K(c, 2), v); + }; + } + function Tr(t) { + return st(function(i, o) { + var c = -1, h = o.length, v = h > 1 ? o[h - 1] : n, w = h > 2 ? o[2] : n; + for (v = t.length > 3 && typeof v == "function" ? (h--, v) : n, w && fe(o[0], o[1], w) && (v = h < 3 ? n : v, h = 1), i = wt(i); ++c < h; ) { + var _ = o[c]; + _ && t(i, _, c, v); + } + return i; + }); + } + function qc(t, i) { + return function(o, c) { + if (o == null) + return o; + if (!de(o)) + return t(o, c); + for (var h = o.length, v = i ? h : -1, w = wt(o); (i ? v-- : ++v < h) && c(w[v], v, w) !== !1; ) + ; + return o; + }; + } + function Wc(t) { + return function(i, o, c) { + for (var h = -1, v = wt(i), w = c(i), _ = w.length; _--; ) { + var A = w[t ? _ : ++h]; + if (o(v[A], A, v) === !1) + break; + } + return i; + }; + } + function g0(t, i, o) { + var c = i & R, h = li(t); + function v() { + var w = this && this !== Yt && this instanceof v ? h : t; + return w.apply(c ? o : this, arguments); + } + return v; + } + function Bc(t) { + return function(i) { + i = gt(i); + var o = Er(i) ? He(i) : n, c = o ? o[0] : i.charAt(0), h = o ? Un(o, 1).join("") : i.slice(1); + return c[t]() + h; + }; + } + function Lr(t) { + return function(i) { + return Oo(Wf(qf(i).replace(sp, "")), t, ""); + }; + } + function li(t) { + return function() { + var i = arguments; + switch (i.length) { + case 0: + return new t(); + case 1: + return new t(i[0]); + case 2: + return new t(i[0], i[1]); + case 3: + return new t(i[0], i[1], i[2]); + case 4: + return new t(i[0], i[1], i[2], i[3]); + case 5: + return new t(i[0], i[1], i[2], i[3], i[4]); + case 6: + return new t(i[0], i[1], i[2], i[3], i[4], i[5]); + case 7: + return new t(i[0], i[1], i[2], i[3], i[4], i[5], i[6]); + } + var o = Or(t.prototype), c = t.apply(o, i); + return It(c) ? c : o; + }; + } + function v0(t, i, o) { + var c = li(t); + function h() { + for (var v = arguments.length, w = S(v), _ = v, A = $r(h); _--; ) + w[_] = arguments[_]; + var $ = v < 3 && w[0] !== A && w[v - 1] !== A ? [] : $n(w, A); + if (v -= $.length, v < o) + return Kc( + t, + i, + fs, + h.placeholder, + n, + w, + $, + n, + n, + o - v + ); + var P = this && this !== Yt && this instanceof h ? c : t; + return Ce(P, this, w); + } + return h; + } + function Hc(t) { + return function(i, o, c) { + var h = wt(i); + if (!de(i)) { + var v = K(o, 3); + i = Gt(i), o = function(_) { + return v(h[_], _, h); + }; + } + var w = t(i, o, c); + return w > -1 ? h[v ? i[w] : w] : n; + }; + } + function Gc(t) { + return mn(function(i) { + var o = i.length, c = o, h = Fe.prototype.thru; + for (t && i.reverse(); c--; ) { + var v = i[c]; + if (typeof v != "function") + throw new Pe(f); + if (h && !w && ps(v) == "wrapper") + var w = new Fe([], !0); + } + for (c = w ? c : o; ++c < o; ) { + v = i[c]; + var _ = ps(v), A = _ == "wrapper" ? ca(v) : n; + A && da(A[0]) && A[1] == (_t | U | z | xt) && !A[4].length && A[9] == 1 ? w = w[ps(A[0])].apply(w, A[3]) : w = v.length == 1 && da(v) ? w[_]() : w.thru(v); + } + return function() { + var $ = arguments, P = $[0]; + if (w && $.length == 1 && tt(P)) + return w.plant(P).value(); + for (var F = 0, q = o ? i[F].apply(this, $) : P; ++F < o; ) + q = i[F].call(this, q); + return q; + }; + }); + } + function fs(t, i, o, c, h, v, w, _, A, $) { + var P = i & _t, F = i & R, q = i & x, j = i & (U | M), J = i & Te, rt = q ? n : li(t); + function X() { + for (var ot = arguments.length, lt = S(ot), Se = ot; Se--; ) + lt[Se] = arguments[Se]; + if (j) + var le = $r(X), Re = Ip(lt, le); + if (c && (lt = kc(lt, c, h, j)), v && (lt = Nc(lt, v, w, j)), ot -= Re, j && ot < $) { + var Ft = $n(lt, le); + return Kc( + t, + i, + fs, + X.placeholder, + o, + lt, + Ft, + _, + A, + $ - ot + ); + } + var ze = F ? o : this, _n = q ? ze[t] : t; + return ot = lt.length, _ ? lt = D0(lt, _) : J && ot > 1 && lt.reverse(), P && A < ot && (lt.length = A), this && this !== Yt && this instanceof X && (_n = rt || li(_n)), _n.apply(ze, lt); + } + return X; + } + function jc(t, i) { + return function(o, c) { + return Gg(o, t, i(c), {}); + }; + } + function ls(t, i) { + return function(o, c) { + var h; + if (o === n && c === n) + return i; + if (o !== n && (h = o), c !== n) { + if (h === n) + return c; + typeof o == "string" || typeof c == "string" ? (o = Ae(o), c = Ae(c)) : (o = Tc(o), c = Tc(c)), h = t(o, c); + } + return h; + }; + } + function sa(t) { + return mn(function(i) { + return i = St(i, Ee(K())), st(function(o) { + var c = this; + return t(i, function(h) { + return Ce(h, c, o); + }); + }); + }); + } + function hs(t, i) { + i = i === n ? " " : Ae(i); + var o = i.length; + if (o < 2) + return o ? Zo(i, t) : i; + var c = Zo(i, Zi(t / Ar(i))); + return Er(i) ? Un(He(c), 0, t).join("") : c.slice(0, t); + } + function m0(t, i, o, c) { + var h = i & R, v = li(t); + function w() { + for (var _ = -1, A = arguments.length, $ = -1, P = c.length, F = S(P + A), q = this && this !== Yt && this instanceof w ? v : t; ++$ < P; ) + F[$] = c[$]; + for (; A--; ) + F[$++] = arguments[++_]; + return Ce(q, h ? o : this, F); + } + return w; + } + function zc(t) { + return function(i, o, c) { + return c && typeof c != "number" && fe(i, o, c) && (o = c = n), i = bn(i), o === n ? (o = i, i = 0) : o = bn(o), c = c === n ? i < o ? 1 : -1 : bn(c), n0(i, o, c, t); + }; + } + function ds(t) { + return function(i, o) { + return typeof i == "string" && typeof o == "string" || (i = ke(i), o = ke(o)), t(i, o); + }; + } + function Kc(t, i, o, c, h, v, w, _, A, $) { + var P = i & U, F = P ? w : n, q = P ? n : w, j = P ? v : n, J = P ? n : v; + i |= P ? z : ht, i &= ~(P ? ht : z), i & D || (i &= ~(R | x)); + var rt = [ + t, + i, + h, + j, + F, + J, + q, + _, + A, + $ + ], X = o.apply(n, rt); + return da(t) && of(X, rt), X.placeholder = c, af(X, t, i); + } + function oa(t) { + var i = qt[t]; + return function(o, c) { + if (o = ke(o), c = c == null ? 0 : ne(nt(c), 292), c && oc(o)) { + var h = (gt(o) + "e").split("e"), v = i(h[0] + "e" + (+h[1] + c)); + return h = (gt(v) + "e").split("e"), +(h[0] + "e" + (+h[1] - c)); + } + return i(o); + }; + } + var y0 = Rr && 1 / Bi(new Rr([, -0]))[1] == te ? function(t) { + return new Rr(t); + } : Ia; + function Jc(t) { + return function(i) { + var o = re(i); + return o == ye ? Do(i) : o == G ? Mp(i) : Rp(i, t(i)); + }; + } + function vn(t, i, o, c, h, v, w, _) { + var A = i & x; + if (!A && typeof t != "function") + throw new Pe(f); + var $ = c ? c.length : 0; + if ($ || (i &= ~(z | ht), c = h = n), w = w === n ? w : Wt(nt(w), 0), _ = _ === n ? _ : nt(_), $ -= h ? h.length : 0, i & ht) { + var P = c, F = h; + c = h = n; + } + var q = A ? n : ca(t), j = [ + t, + i, + o, + c, + h, + P, + F, + v, + w, + _ + ]; + if (q && P0(j, q), t = j[0], i = j[1], o = j[2], c = j[3], h = j[4], _ = j[9] = j[9] === n ? A ? 0 : t.length : Wt(j[9] - $, 0), !_ && i & (U | M) && (i &= ~(U | M)), !i || i == R) + var J = g0(t, i, o); + else + i == U || i == M ? J = v0(t, i, _) : (i == z || i == (R | z)) && !h.length ? J = m0(t, i, o, c) : J = fs.apply(n, j); + var rt = q ? Ic : of; + return af(rt(J, j), t, i); + } + function Xc(t, i, o, c) { + return t === n || je(t, Sr[o]) && !vt.call(c, o) ? i : t; + } + function Yc(t, i, o, c, h, v) { + return It(t) && It(i) && (v.set(i, t), os(t, i, n, Yc, v), v.delete(i)), t; + } + function w0(t) { + return pi(t) ? n : t; + } + function Vc(t, i, o, c, h, v) { + var w = o & I, _ = t.length, A = i.length; + if (_ != A && !(w && A > _)) + return !1; + var $ = v.get(t), P = v.get(i); + if ($ && P) + return $ == i && P == t; + var F = -1, q = !0, j = o & O ? new er() : n; + for (v.set(t, i), v.set(i, t); ++F < _; ) { + var J = t[F], rt = i[F]; + if (c) + var X = w ? c(rt, J, F, i, t, v) : c(J, rt, F, t, i, v); + if (X !== n) { + if (X) + continue; + q = !1; + break; + } + if (j) { + if (!To(i, function(ot, lt) { + if (!ti(j, lt) && (J === ot || h(J, ot, o, c, v))) + return j.push(lt); + })) { + q = !1; + break; + } + } else if (!(J === rt || h(J, rt, o, c, v))) { + q = !1; + break; + } + } + return v.delete(t), v.delete(i), q; + } + function b0(t, i, o, c, h, v, w) { + switch (o) { + case pt: + if (t.byteLength != i.byteLength || t.byteOffset != i.byteOffset) + return !1; + t = t.buffer, i = i.buffer; + case V: + return !(t.byteLength != i.byteLength || !v(new Ji(t), new Ji(i))); + case cn: + case fn: + case Sn: + return je(+t, +i); + case ee: + return t.name == i.name && t.message == i.message; + case Y: + case Q: + return t == i + ""; + case ye: + var _ = Do; + case G: + var A = c & I; + if (_ || (_ = Bi), t.size != i.size && !A) + return !1; + var $ = w.get(t); + if ($) + return $ == i; + c |= O, w.set(t, i); + var P = Vc(_(t), _(i), c, h, v, w); + return w.delete(t), P; + case mt: + if (si) + return si.call(t) == si.call(i); + } + return !1; + } + function _0(t, i, o, c, h, v) { + var w = o & I, _ = aa(t), A = _.length, $ = aa(i), P = $.length; + if (A != P && !w) + return !1; + for (var F = A; F--; ) { + var q = _[F]; + if (!(w ? q in i : vt.call(i, q))) + return !1; + } + var j = v.get(t), J = v.get(i); + if (j && J) + return j == i && J == t; + var rt = !0; + v.set(t, i), v.set(i, t); + for (var X = w; ++F < A; ) { + q = _[F]; + var ot = t[q], lt = i[q]; + if (c) + var Se = w ? c(lt, ot, q, i, t, v) : c(ot, lt, q, t, i, v); + if (!(Se === n ? ot === lt || h(ot, lt, o, c, v) : Se)) { + rt = !1; + break; + } + X || (X = q == "constructor"); + } + if (rt && !X) { + var le = t.constructor, Re = i.constructor; + le != Re && "constructor" in t && "constructor" in i && !(typeof le == "function" && le instanceof le && typeof Re == "function" && Re instanceof Re) && (rt = !1); + } + return v.delete(t), v.delete(i), rt; + } + function mn(t) { + return ga(rf(t, n, df), t + ""); + } + function aa(t) { + return mc(t, Gt, la); + } + function ua(t) { + return mc(t, pe, Zc); + } + var ca = ts ? function(t) { + return ts.get(t); + } : Ia; + function ps(t) { + for (var i = t.name + "", o = Ir[i], c = vt.call(Ir, i) ? o.length : 0; c--; ) { + var h = o[c], v = h.func; + if (v == null || v == t) + return h.name; + } + return i; + } + function $r(t) { + var i = vt.call(g, "placeholder") ? g : t; + return i.placeholder; + } + function K() { + var t = g.iteratee || Sa; + return t = t === Sa ? bc : t, arguments.length ? t(arguments[0], arguments[1]) : t; + } + function gs(t, i) { + var o = t.__data__; + return O0(i) ? o[typeof i == "string" ? "string" : "hash"] : o.map; + } + function fa(t) { + for (var i = Gt(t), o = i.length; o--; ) { + var c = i[o], h = t[c]; + i[o] = [c, h, ef(h)]; + } + return i; + } + function ir(t, i) { + var o = $p(t, i); + return wc(o) ? o : n; + } + function C0(t) { + var i = vt.call(t, Qn), o = t[Qn]; + try { + t[Qn] = n; + var c = !0; + } catch { + } + var h = zi.call(t); + return c && (i ? t[Qn] = o : delete t[Qn]), h; + } + var la = ko ? function(t) { + return t == null ? [] : (t = wt(t), Tn(ko(t), function(i) { + return ic.call(t, i); + })); + } : Oa, Zc = ko ? function(t) { + for (var i = []; t; ) + Ln(i, la(t)), t = Xi(t); + return i; + } : Oa, re = ce; + (No && re(new No(new ArrayBuffer(1))) != pt || ni && re(new ni()) != ye || qo && re(qo.resolve()) != H || Rr && re(new Rr()) != G || ri && re(new ri()) != ft) && (re = function(t) { + var i = ce(t), o = i == k ? t.constructor : n, c = o ? sr(o) : ""; + if (c) + switch (c) { + case ig: + return pt; + case sg: + return ye; + case og: + return H; + case ag: + return G; + case ug: + return ft; + } + return i; + }); + function E0(t, i, o) { + for (var c = -1, h = o.length; ++c < h; ) { + var v = o[c], w = v.size; + switch (v.type) { + case "drop": + t += w; + break; + case "dropRight": + i -= w; + break; + case "take": + i = ne(i, t + w); + break; + case "takeRight": + t = Wt(t, i - w); + break; + } + } + return { start: t, end: i }; + } + function A0(t) { + var i = t.match(Td); + return i ? i[1].split(Ld) : []; + } + function Qc(t, i, o) { + i = Dn(i, t); + for (var c = -1, h = i.length, v = !1; ++c < h; ) { + var w = rn(i[c]); + if (!(v = t != null && o(t, w))) + break; + t = t[w]; + } + return v || ++c != h ? v : (h = t == null ? 0 : t.length, !!h && Cs(h) && yn(w, h) && (tt(t) || or(t))); + } + function x0(t) { + var i = t.length, o = new t.constructor(i); + return i && typeof t[0] == "string" && vt.call(t, "index") && (o.index = t.index, o.input = t.input), o; + } + function tf(t) { + return typeof t.constructor == "function" && !hi(t) ? Or(Xi(t)) : {}; + } + function S0(t, i, o) { + var c = t.constructor; + switch (i) { + case V: + return ia(t); + case cn: + case fn: + return new c(+t); + case pt: + return c0(t, o); + case we: + case ln: + case Kt: + case Nt: + case oe: + case tn: + case Rn: + case be: + case In: + return Dc(t, o); + case ye: + return new c(); + case Sn: + case Q: + return new c(t); + case Y: + return f0(t); + case G: + return new c(); + case mt: + return l0(t); + } + } + function R0(t, i) { + var o = i.length; + if (!o) + return t; + var c = o - 1; + return i[c] = (o > 1 ? "& " : "") + i[c], i = i.join(o > 2 ? ", " : " "), t.replace(Od, `{ +/* [wrapped with ` + i + `] */ +`); + } + function I0(t) { + return tt(t) || or(t) || !!(sc && t && t[sc]); + } + function yn(t, i) { + var o = typeof t; + return i = i ?? se, !!i && (o == "number" || o != "symbol" && qd.test(t)) && t > -1 && t % 1 == 0 && t < i; + } + function fe(t, i, o) { + if (!It(o)) + return !1; + var c = typeof i; + return (c == "number" ? de(o) && yn(i, o.length) : c == "string" && i in o) ? je(o[i], t) : !1; + } + function ha(t, i) { + if (tt(t)) + return !1; + var o = typeof t; + return o == "number" || o == "symbol" || o == "boolean" || t == null || xe(t) ? !0 : ue.test(t) || !ae.test(t) || i != null && t in wt(i); + } + function O0(t) { + var i = typeof t; + return i == "string" || i == "number" || i == "symbol" || i == "boolean" ? t !== "__proto__" : t === null; + } + function da(t) { + var i = ps(t), o = g[i]; + if (typeof o != "function" || !(i in ut.prototype)) + return !1; + if (t === o) + return !0; + var c = ca(o); + return !!c && t === c[0]; + } + function T0(t) { + return !!ec && ec in t; + } + var L0 = Gi ? wn : Ta; + function hi(t) { + var i = t && t.constructor, o = typeof i == "function" && i.prototype || Sr; + return t === o; + } + function ef(t) { + return t === t && !It(t); + } + function nf(t, i) { + return function(o) { + return o == null ? !1 : o[t] === i && (i !== n || t in wt(o)); + }; + } + function $0(t) { + var i = bs(t, function(c) { + return o.size === y && o.clear(), c; + }), o = i.cache; + return i; + } + function P0(t, i) { + var o = t[1], c = i[1], h = o | c, v = h < (R | x | _t), w = c == _t && o == U || c == _t && o == xt && t[7].length <= i[8] || c == (_t | xt) && i[7].length <= i[8] && o == U; + if (!(v || w)) + return t; + c & R && (t[2] = i[2], h |= o & R ? 0 : D); + var _ = i[3]; + if (_) { + var A = t[3]; + t[3] = A ? kc(A, _, i[4]) : _, t[4] = A ? $n(t[3], p) : i[4]; + } + return _ = i[5], _ && (A = t[5], t[5] = A ? Nc(A, _, i[6]) : _, t[6] = A ? $n(t[5], p) : i[6]), _ = i[7], _ && (t[7] = _), c & _t && (t[8] = t[8] == null ? i[8] : ne(t[8], i[8])), t[9] == null && (t[9] = i[9]), t[0] = i[0], t[1] = h, t; + } + function F0(t) { + var i = []; + if (t != null) + for (var o in wt(t)) + i.push(o); + return i; + } + function M0(t) { + return zi.call(t); + } + function rf(t, i, o) { + return i = Wt(i === n ? t.length - 1 : i, 0), function() { + for (var c = arguments, h = -1, v = Wt(c.length - i, 0), w = S(v); ++h < v; ) + w[h] = c[i + h]; + h = -1; + for (var _ = S(i + 1); ++h < i; ) + _[h] = c[h]; + return _[i] = o(w), Ce(t, this, _); + }; + } + function sf(t, i) { + return i.length < 2 ? t : rr(t, De(i, 0, -1)); + } + function D0(t, i) { + for (var o = t.length, c = ne(i.length, o), h = he(t); c--; ) { + var v = i[c]; + t[c] = yn(v, o) ? h[v] : n; + } + return t; + } + function pa(t, i) { + if (!(i === "constructor" && typeof t[i] == "function") && i != "__proto__") + return t[i]; + } + var of = uf(Ic), di = Vp || function(t, i) { + return Yt.setTimeout(t, i); + }, ga = uf(s0); + function af(t, i, o) { + var c = i + ""; + return ga(t, R0(c, U0(A0(c), o))); + } + function uf(t) { + var i = 0, o = 0; + return function() { + var c = eg(), h = zt - (c - o); + if (o = c, h > 0) { + if (++i >= We) + return arguments[0]; + } else + i = 0; + return t.apply(n, arguments); + }; + } + function vs(t, i) { + var o = -1, c = t.length, h = c - 1; + for (i = i === n ? c : i; ++o < i; ) { + var v = Vo(o, h), w = t[v]; + t[v] = t[o], t[o] = w; + } + return t.length = i, t; + } + var cf = $0(function(t) { + var i = []; + return t.charCodeAt(0) === 46 && i.push(""), t.replace(Xt, function(o, c, h, v) { + i.push(h ? v.replace(Fd, "$1") : c || o); + }), i; + }); + function rn(t) { + if (typeof t == "string" || xe(t)) + return t; + var i = t + ""; + return i == "0" && 1 / t == -te ? "-0" : i; + } + function sr(t) { + if (t != null) { + try { + return ji.call(t); + } catch { + } + try { + return t + ""; + } catch { + } + } + return ""; + } + function U0(t, i) { + return $e(wo, function(o) { + var c = "_." + o[0]; + i & o[1] && !qi(t, c) && t.push(c); + }), t.sort(); + } + function ff(t) { + if (t instanceof ut) + return t.clone(); + var i = new Fe(t.__wrapped__, t.__chain__); + return i.__actions__ = he(t.__actions__), i.__index__ = t.__index__, i.__values__ = t.__values__, i; + } + function k0(t, i, o) { + (o ? fe(t, i, o) : i === n) ? i = 1 : i = Wt(nt(i), 0); + var c = t == null ? 0 : t.length; + if (!c || i < 1) + return []; + for (var h = 0, v = 0, w = S(Zi(c / i)); h < c; ) + w[v++] = De(t, h, h += i); + return w; + } + function N0(t) { + for (var i = -1, o = t == null ? 0 : t.length, c = 0, h = []; ++i < o; ) { + var v = t[i]; + v && (h[c++] = v); + } + return h; + } + function q0() { + var t = arguments.length; + if (!t) + return []; + for (var i = S(t - 1), o = arguments[0], c = t; c--; ) + i[c - 1] = arguments[c]; + return Ln(tt(o) ? he(o) : [o], Vt(i, 1)); + } + var W0 = st(function(t, i) { + return Pt(t) ? ai(t, Vt(i, 1, Pt, !0)) : []; + }), B0 = st(function(t, i) { + var o = Ue(i); + return Pt(o) && (o = n), Pt(t) ? ai(t, Vt(i, 1, Pt, !0), K(o, 2)) : []; + }), H0 = st(function(t, i) { + var o = Ue(i); + return Pt(o) && (o = n), Pt(t) ? ai(t, Vt(i, 1, Pt, !0), n, o) : []; + }); + function G0(t, i, o) { + var c = t == null ? 0 : t.length; + return c ? (i = o || i === n ? 1 : nt(i), De(t, i < 0 ? 0 : i, c)) : []; + } + function j0(t, i, o) { + var c = t == null ? 0 : t.length; + return c ? (i = o || i === n ? 1 : nt(i), i = c - i, De(t, 0, i < 0 ? 0 : i)) : []; + } + function z0(t, i) { + return t && t.length ? us(t, K(i, 3), !0, !0) : []; + } + function K0(t, i) { + return t && t.length ? us(t, K(i, 3), !0) : []; + } + function J0(t, i, o, c) { + var h = t == null ? 0 : t.length; + return h ? (o && typeof o != "number" && fe(t, i, o) && (o = 0, c = h), qg(t, i, o, c)) : []; + } + function lf(t, i, o) { + var c = t == null ? 0 : t.length; + if (!c) + return -1; + var h = o == null ? 0 : nt(o); + return h < 0 && (h = Wt(c + h, 0)), Wi(t, K(i, 3), h); + } + function hf(t, i, o) { + var c = t == null ? 0 : t.length; + if (!c) + return -1; + var h = c - 1; + return o !== n && (h = nt(o), h = o < 0 ? Wt(c + h, 0) : ne(h, c - 1)), Wi(t, K(i, 3), h, !0); + } + function df(t) { + var i = t == null ? 0 : t.length; + return i ? Vt(t, 1) : []; + } + function X0(t) { + var i = t == null ? 0 : t.length; + return i ? Vt(t, te) : []; + } + function Y0(t, i) { + var o = t == null ? 0 : t.length; + return o ? (i = i === n ? 1 : nt(i), Vt(t, i)) : []; + } + function V0(t) { + for (var i = -1, o = t == null ? 0 : t.length, c = {}; ++i < o; ) { + var h = t[i]; + c[h[0]] = h[1]; + } + return c; + } + function pf(t) { + return t && t.length ? t[0] : n; + } + function Z0(t, i, o) { + var c = t == null ? 0 : t.length; + if (!c) + return -1; + var h = o == null ? 0 : nt(o); + return h < 0 && (h = Wt(c + h, 0)), Cr(t, i, h); + } + function Q0(t) { + var i = t == null ? 0 : t.length; + return i ? De(t, 0, -1) : []; + } + var tv = st(function(t) { + var i = St(t, na); + return i.length && i[0] === t[0] ? zo(i) : []; + }), ev = st(function(t) { + var i = Ue(t), o = St(t, na); + return i === Ue(o) ? i = n : o.pop(), o.length && o[0] === t[0] ? zo(o, K(i, 2)) : []; + }), nv = st(function(t) { + var i = Ue(t), o = St(t, na); + return i = typeof i == "function" ? i : n, i && o.pop(), o.length && o[0] === t[0] ? zo(o, n, i) : []; + }); + function rv(t, i) { + return t == null ? "" : Qp.call(t, i); + } + function Ue(t) { + var i = t == null ? 0 : t.length; + return i ? t[i - 1] : n; + } + function iv(t, i, o) { + var c = t == null ? 0 : t.length; + if (!c) + return -1; + var h = c; + return o !== n && (h = nt(o), h = h < 0 ? Wt(c + h, 0) : ne(h, c - 1)), i === i ? Up(t, i, h) : Wi(t, Ku, h, !0); + } + function sv(t, i) { + return t && t.length ? Ac(t, nt(i)) : n; + } + var ov = st(gf); + function gf(t, i) { + return t && t.length && i && i.length ? Yo(t, i) : t; + } + function av(t, i, o) { + return t && t.length && i && i.length ? Yo(t, i, K(o, 2)) : t; + } + function uv(t, i, o) { + return t && t.length && i && i.length ? Yo(t, i, n, o) : t; + } + var cv = mn(function(t, i) { + var o = t == null ? 0 : t.length, c = Bo(t, i); + return Rc(t, St(i, function(h) { + return yn(h, o) ? +h : h; + }).sort(Uc)), c; + }); + function fv(t, i) { + var o = []; + if (!(t && t.length)) + return o; + var c = -1, h = [], v = t.length; + for (i = K(i, 3); ++c < v; ) { + var w = t[c]; + i(w, c, t) && (o.push(w), h.push(c)); + } + return Rc(t, h), o; + } + function va(t) { + return t == null ? t : rg.call(t); + } + function lv(t, i, o) { + var c = t == null ? 0 : t.length; + return c ? (o && typeof o != "number" && fe(t, i, o) ? (i = 0, o = c) : (i = i == null ? 0 : nt(i), o = o === n ? c : nt(o)), De(t, i, o)) : []; + } + function hv(t, i) { + return as(t, i); + } + function dv(t, i, o) { + return Qo(t, i, K(o, 2)); + } + function pv(t, i) { + var o = t == null ? 0 : t.length; + if (o) { + var c = as(t, i); + if (c < o && je(t[c], i)) + return c; + } + return -1; + } + function gv(t, i) { + return as(t, i, !0); + } + function vv(t, i, o) { + return Qo(t, i, K(o, 2), !0); + } + function mv(t, i) { + var o = t == null ? 0 : t.length; + if (o) { + var c = as(t, i, !0) - 1; + if (je(t[c], i)) + return c; + } + return -1; + } + function yv(t) { + return t && t.length ? Oc(t) : []; + } + function wv(t, i) { + return t && t.length ? Oc(t, K(i, 2)) : []; + } + function bv(t) { + var i = t == null ? 0 : t.length; + return i ? De(t, 1, i) : []; + } + function _v(t, i, o) { + return t && t.length ? (i = o || i === n ? 1 : nt(i), De(t, 0, i < 0 ? 0 : i)) : []; + } + function Cv(t, i, o) { + var c = t == null ? 0 : t.length; + return c ? (i = o || i === n ? 1 : nt(i), i = c - i, De(t, i < 0 ? 0 : i, c)) : []; + } + function Ev(t, i) { + return t && t.length ? us(t, K(i, 3), !1, !0) : []; + } + function Av(t, i) { + return t && t.length ? us(t, K(i, 3)) : []; + } + var xv = st(function(t) { + return Mn(Vt(t, 1, Pt, !0)); + }), Sv = st(function(t) { + var i = Ue(t); + return Pt(i) && (i = n), Mn(Vt(t, 1, Pt, !0), K(i, 2)); + }), Rv = st(function(t) { + var i = Ue(t); + return i = typeof i == "function" ? i : n, Mn(Vt(t, 1, Pt, !0), n, i); + }); + function Iv(t) { + return t && t.length ? Mn(t) : []; + } + function Ov(t, i) { + return t && t.length ? Mn(t, K(i, 2)) : []; + } + function Tv(t, i) { + return i = typeof i == "function" ? i : n, t && t.length ? Mn(t, n, i) : []; + } + function ma(t) { + if (!(t && t.length)) + return []; + var i = 0; + return t = Tn(t, function(o) { + if (Pt(o)) + return i = Wt(o.length, i), !0; + }), Fo(i, function(o) { + return St(t, Lo(o)); + }); + } + function vf(t, i) { + if (!(t && t.length)) + return []; + var o = ma(t); + return i == null ? o : St(o, function(c) { + return Ce(i, n, c); + }); + } + var Lv = st(function(t, i) { + return Pt(t) ? ai(t, i) : []; + }), $v = st(function(t) { + return ea(Tn(t, Pt)); + }), Pv = st(function(t) { + var i = Ue(t); + return Pt(i) && (i = n), ea(Tn(t, Pt), K(i, 2)); + }), Fv = st(function(t) { + var i = Ue(t); + return i = typeof i == "function" ? i : n, ea(Tn(t, Pt), n, i); + }), Mv = st(ma); + function Dv(t, i) { + return Pc(t || [], i || [], oi); + } + function Uv(t, i) { + return Pc(t || [], i || [], fi); + } + var kv = st(function(t) { + var i = t.length, o = i > 1 ? t[i - 1] : n; + return o = typeof o == "function" ? (t.pop(), o) : n, vf(t, o); + }); + function mf(t) { + var i = g(t); + return i.__chain__ = !0, i; + } + function Nv(t, i) { + return i(t), t; + } + function ms(t, i) { + return i(t); + } + var qv = mn(function(t) { + var i = t.length, o = i ? t[0] : 0, c = this.__wrapped__, h = function(v) { + return Bo(v, t); + }; + return i > 1 || this.__actions__.length || !(c instanceof ut) || !yn(o) ? this.thru(h) : (c = c.slice(o, +o + (i ? 1 : 0)), c.__actions__.push({ + func: ms, + args: [h], + thisArg: n + }), new Fe(c, this.__chain__).thru(function(v) { + return i && !v.length && v.push(n), v; + })); + }); + function Wv() { + return mf(this); + } + function Bv() { + return new Fe(this.value(), this.__chain__); + } + function Hv() { + this.__values__ === n && (this.__values__ = Lf(this.value())); + var t = this.__index__ >= this.__values__.length, i = t ? n : this.__values__[this.__index__++]; + return { done: t, value: i }; + } + function Gv() { + return this; + } + function jv(t) { + for (var i, o = this; o instanceof ns; ) { + var c = ff(o); + c.__index__ = 0, c.__values__ = n, i ? h.__wrapped__ = c : i = c; + var h = c; + o = o.__wrapped__; + } + return h.__wrapped__ = t, i; + } + function zv() { + var t = this.__wrapped__; + if (t instanceof ut) { + var i = t; + return this.__actions__.length && (i = new ut(this)), i = i.reverse(), i.__actions__.push({ + func: ms, + args: [va], + thisArg: n + }), new Fe(i, this.__chain__); + } + return this.thru(va); + } + function Kv() { + return $c(this.__wrapped__, this.__actions__); + } + var Jv = cs(function(t, i, o) { + vt.call(t, o) ? ++t[o] : gn(t, o, 1); + }); + function Xv(t, i, o) { + var c = tt(t) ? ju : Ng; + return o && fe(t, i, o) && (i = n), c(t, K(i, 3)); + } + function Yv(t, i) { + var o = tt(t) ? Tn : gc; + return o(t, K(i, 3)); + } + var Vv = Hc(lf), Zv = Hc(hf); + function Qv(t, i) { + return Vt(ys(t, i), 1); + } + function tm(t, i) { + return Vt(ys(t, i), te); + } + function em(t, i, o) { + return o = o === n ? 1 : nt(o), Vt(ys(t, i), o); + } + function yf(t, i) { + var o = tt(t) ? $e : Fn; + return o(t, K(i, 3)); + } + function wf(t, i) { + var o = tt(t) ? bp : pc; + return o(t, K(i, 3)); + } + var nm = cs(function(t, i, o) { + vt.call(t, o) ? t[o].push(i) : gn(t, o, [i]); + }); + function rm(t, i, o, c) { + t = de(t) ? t : Fr(t), o = o && !c ? nt(o) : 0; + var h = t.length; + return o < 0 && (o = Wt(h + o, 0)), Es(t) ? o <= h && t.indexOf(i, o) > -1 : !!h && Cr(t, i, o) > -1; + } + var im = st(function(t, i, o) { + var c = -1, h = typeof i == "function", v = de(t) ? S(t.length) : []; + return Fn(t, function(w) { + v[++c] = h ? Ce(i, w, o) : ui(w, i, o); + }), v; + }), sm = cs(function(t, i, o) { + gn(t, o, i); + }); + function ys(t, i) { + var o = tt(t) ? St : _c; + return o(t, K(i, 3)); + } + function om(t, i, o, c) { + return t == null ? [] : (tt(i) || (i = i == null ? [] : [i]), o = c ? n : o, tt(o) || (o = o == null ? [] : [o]), xc(t, i, o)); + } + var am = cs(function(t, i, o) { + t[o ? 0 : 1].push(i); + }, function() { + return [[], []]; + }); + function um(t, i, o) { + var c = tt(t) ? Oo : Xu, h = arguments.length < 3; + return c(t, K(i, 4), o, h, Fn); + } + function cm(t, i, o) { + var c = tt(t) ? _p : Xu, h = arguments.length < 3; + return c(t, K(i, 4), o, h, pc); + } + function fm(t, i) { + var o = tt(t) ? Tn : gc; + return o(t, _s(K(i, 3))); + } + function lm(t) { + var i = tt(t) ? fc : r0; + return i(t); + } + function hm(t, i, o) { + (o ? fe(t, i, o) : i === n) ? i = 1 : i = nt(i); + var c = tt(t) ? Fg : i0; + return c(t, i); + } + function dm(t) { + var i = tt(t) ? Mg : o0; + return i(t); + } + function pm(t) { + if (t == null) + return 0; + if (de(t)) + return Es(t) ? Ar(t) : t.length; + var i = re(t); + return i == ye || i == G ? t.size : Jo(t).length; + } + function gm(t, i, o) { + var c = tt(t) ? To : a0; + return o && fe(t, i, o) && (i = n), c(t, K(i, 3)); + } + var vm = st(function(t, i) { + if (t == null) + return []; + var o = i.length; + return o > 1 && fe(t, i[0], i[1]) ? i = [] : o > 2 && fe(i[0], i[1], i[2]) && (i = [i[0]]), xc(t, Vt(i, 1), []); + }), ws = Yp || function() { + return Yt.Date.now(); + }; + function mm(t, i) { + if (typeof i != "function") + throw new Pe(f); + return t = nt(t), function() { + if (--t < 1) + return i.apply(this, arguments); + }; + } + function bf(t, i, o) { + return i = o ? n : i, i = t && i == null ? t.length : i, vn(t, _t, n, n, n, n, i); + } + function _f(t, i) { + var o; + if (typeof i != "function") + throw new Pe(f); + return t = nt(t), function() { + return --t > 0 && (o = i.apply(this, arguments)), t <= 1 && (i = n), o; + }; + } + var ya = st(function(t, i, o) { + var c = R; + if (o.length) { + var h = $n(o, $r(ya)); + c |= z; + } + return vn(t, c, i, o, h); + }), Cf = st(function(t, i, o) { + var c = R | x; + if (o.length) { + var h = $n(o, $r(Cf)); + c |= z; + } + return vn(i, c, t, o, h); + }); + function Ef(t, i, o) { + i = o ? n : i; + var c = vn(t, U, n, n, n, n, n, i); + return c.placeholder = Ef.placeholder, c; + } + function Af(t, i, o) { + i = o ? n : i; + var c = vn(t, M, n, n, n, n, n, i); + return c.placeholder = Af.placeholder, c; + } + function xf(t, i, o) { + var c, h, v, w, _, A, $ = 0, P = !1, F = !1, q = !0; + if (typeof t != "function") + throw new Pe(f); + i = ke(i) || 0, It(o) && (P = !!o.leading, F = "maxWait" in o, v = F ? Wt(ke(o.maxWait) || 0, i) : v, q = "trailing" in o ? !!o.trailing : q); + function j(Ft) { + var ze = c, _n = h; + return c = h = n, $ = Ft, w = t.apply(_n, ze), w; + } + function J(Ft) { + return $ = Ft, _ = di(ot, i), P ? j(Ft) : w; + } + function rt(Ft) { + var ze = Ft - A, _n = Ft - $, Gf = i - ze; + return F ? ne(Gf, v - _n) : Gf; + } + function X(Ft) { + var ze = Ft - A, _n = Ft - $; + return A === n || ze >= i || ze < 0 || F && _n >= v; + } + function ot() { + var Ft = ws(); + if (X(Ft)) + return lt(Ft); + _ = di(ot, rt(Ft)); + } + function lt(Ft) { + return _ = n, q && c ? j(Ft) : (c = h = n, w); + } + function Se() { + _ !== n && Fc(_), $ = 0, c = A = h = _ = n; + } + function le() { + return _ === n ? w : lt(ws()); + } + function Re() { + var Ft = ws(), ze = X(Ft); + if (c = arguments, h = this, A = Ft, ze) { + if (_ === n) + return J(A); + if (F) + return Fc(_), _ = di(ot, i), j(A); + } + return _ === n && (_ = di(ot, i)), w; + } + return Re.cancel = Se, Re.flush = le, Re; + } + var ym = st(function(t, i) { + return dc(t, 1, i); + }), wm = st(function(t, i, o) { + return dc(t, ke(i) || 0, o); + }); + function bm(t) { + return vn(t, Te); + } + function bs(t, i) { + if (typeof t != "function" || i != null && typeof i != "function") + throw new Pe(f); + var o = function() { + var c = arguments, h = i ? i.apply(this, c) : c[0], v = o.cache; + if (v.has(h)) + return v.get(h); + var w = t.apply(this, c); + return o.cache = v.set(h, w) || v, w; + }; + return o.cache = new (bs.Cache || pn)(), o; + } + bs.Cache = pn; + function _s(t) { + if (typeof t != "function") + throw new Pe(f); + return function() { + var i = arguments; + switch (i.length) { + case 0: + return !t.call(this); + case 1: + return !t.call(this, i[0]); + case 2: + return !t.call(this, i[0], i[1]); + case 3: + return !t.call(this, i[0], i[1], i[2]); + } + return !t.apply(this, i); + }; + } + function _m(t) { + return _f(2, t); + } + var Cm = u0(function(t, i) { + i = i.length == 1 && tt(i[0]) ? St(i[0], Ee(K())) : St(Vt(i, 1), Ee(K())); + var o = i.length; + return st(function(c) { + for (var h = -1, v = ne(c.length, o); ++h < v; ) + c[h] = i[h].call(this, c[h]); + return Ce(t, this, c); + }); + }), wa = st(function(t, i) { + var o = $n(i, $r(wa)); + return vn(t, z, n, i, o); + }), Sf = st(function(t, i) { + var o = $n(i, $r(Sf)); + return vn(t, ht, n, i, o); + }), Em = mn(function(t, i) { + return vn(t, xt, n, n, n, i); + }); + function Am(t, i) { + if (typeof t != "function") + throw new Pe(f); + return i = i === n ? i : nt(i), st(t, i); + } + function xm(t, i) { + if (typeof t != "function") + throw new Pe(f); + return i = i == null ? 0 : Wt(nt(i), 0), st(function(o) { + var c = o[i], h = Un(o, 0, i); + return c && Ln(h, c), Ce(t, this, h); + }); + } + function Sm(t, i, o) { + var c = !0, h = !0; + if (typeof t != "function") + throw new Pe(f); + return It(o) && (c = "leading" in o ? !!o.leading : c, h = "trailing" in o ? !!o.trailing : h), xf(t, i, { + leading: c, + maxWait: i, + trailing: h + }); + } + function Rm(t) { + return bf(t, 1); + } + function Im(t, i) { + return wa(ra(i), t); + } + function Om() { + if (!arguments.length) + return []; + var t = arguments[0]; + return tt(t) ? t : [t]; + } + function Tm(t) { + return Me(t, C); + } + function Lm(t, i) { + return i = typeof i == "function" ? i : n, Me(t, C, i); + } + function $m(t) { + return Me(t, m | C); + } + function Pm(t, i) { + return i = typeof i == "function" ? i : n, Me(t, m | C, i); + } + function Fm(t, i) { + return i == null || hc(t, i, Gt(i)); + } + function je(t, i) { + return t === i || t !== t && i !== i; + } + var Mm = ds(jo), Dm = ds(function(t, i) { + return t >= i; + }), or = yc(function() { + return arguments; + }()) ? yc : function(t) { + return Tt(t) && vt.call(t, "callee") && !ic.call(t, "callee"); + }, tt = S.isArray, Um = Nu ? Ee(Nu) : jg; + function de(t) { + return t != null && Cs(t.length) && !wn(t); + } + function Pt(t) { + return Tt(t) && de(t); + } + function km(t) { + return t === !0 || t === !1 || Tt(t) && ce(t) == cn; + } + var kn = Zp || Ta, Nm = qu ? Ee(qu) : zg; + function qm(t) { + return Tt(t) && t.nodeType === 1 && !pi(t); + } + function Wm(t) { + if (t == null) + return !0; + if (de(t) && (tt(t) || typeof t == "string" || typeof t.splice == "function" || kn(t) || Pr(t) || or(t))) + return !t.length; + var i = re(t); + if (i == ye || i == G) + return !t.size; + if (hi(t)) + return !Jo(t).length; + for (var o in t) + if (vt.call(t, o)) + return !1; + return !0; + } + function Bm(t, i) { + return ci(t, i); + } + function Hm(t, i, o) { + o = typeof o == "function" ? o : n; + var c = o ? o(t, i) : n; + return c === n ? ci(t, i, n, o) : !!c; + } + function ba(t) { + if (!Tt(t)) + return !1; + var i = ce(t); + return i == ee || i == xn || typeof t.message == "string" && typeof t.name == "string" && !pi(t); + } + function Gm(t) { + return typeof t == "number" && oc(t); + } + function wn(t) { + if (!It(t)) + return !1; + var i = ce(t); + return i == br || i == Pi || i == bo || i == N; + } + function Rf(t) { + return typeof t == "number" && t == nt(t); + } + function Cs(t) { + return typeof t == "number" && t > -1 && t % 1 == 0 && t <= se; + } + function It(t) { + var i = typeof t; + return t != null && (i == "object" || i == "function"); + } + function Tt(t) { + return t != null && typeof t == "object"; + } + var If = Wu ? Ee(Wu) : Jg; + function jm(t, i) { + return t === i || Ko(t, i, fa(i)); + } + function zm(t, i, o) { + return o = typeof o == "function" ? o : n, Ko(t, i, fa(i), o); + } + function Km(t) { + return Of(t) && t != +t; + } + function Jm(t) { + if (L0(t)) + throw new Z(u); + return wc(t); + } + function Xm(t) { + return t === null; + } + function Ym(t) { + return t == null; + } + function Of(t) { + return typeof t == "number" || Tt(t) && ce(t) == Sn; + } + function pi(t) { + if (!Tt(t) || ce(t) != k) + return !1; + var i = Xi(t); + if (i === null) + return !0; + var o = vt.call(i, "constructor") && i.constructor; + return typeof o == "function" && o instanceof o && ji.call(o) == zp; + } + var _a = Bu ? Ee(Bu) : Xg; + function Vm(t) { + return Rf(t) && t >= -se && t <= se; + } + var Tf = Hu ? Ee(Hu) : Yg; + function Es(t) { + return typeof t == "string" || !tt(t) && Tt(t) && ce(t) == Q; + } + function xe(t) { + return typeof t == "symbol" || Tt(t) && ce(t) == mt; + } + var Pr = Gu ? Ee(Gu) : Vg; + function Zm(t) { + return t === n; + } + function Qm(t) { + return Tt(t) && re(t) == ft; + } + function ty(t) { + return Tt(t) && ce(t) == yt; + } + var ey = ds(Xo), ny = ds(function(t, i) { + return t <= i; + }); + function Lf(t) { + if (!t) + return []; + if (de(t)) + return Es(t) ? He(t) : he(t); + if (ei && t[ei]) + return Fp(t[ei]()); + var i = re(t), o = i == ye ? Do : i == G ? Bi : Fr; + return o(t); + } + function bn(t) { + if (!t) + return t === 0 ? t : 0; + if (t = ke(t), t === te || t === -te) { + var i = t < 0 ? -1 : 1; + return i * Yn; + } + return t === t ? t : 0; + } + function nt(t) { + var i = bn(t), o = i % 1; + return i === i ? o ? i - o : i : 0; + } + function $f(t) { + return t ? nr(nt(t), 0, kt) : 0; + } + function ke(t) { + if (typeof t == "number") + return t; + if (xe(t)) + return En; + if (It(t)) { + var i = typeof t.valueOf == "function" ? t.valueOf() : t; + t = It(i) ? i + "" : i; + } + if (typeof t != "string") + return t === 0 ? t : +t; + t = Yu(t); + var o = Ud.test(t); + return o || Nd.test(t) ? mp(t.slice(2), o ? 2 : 8) : Dd.test(t) ? En : +t; + } + function Pf(t) { + return nn(t, pe(t)); + } + function ry(t) { + return t ? nr(nt(t), -se, se) : t === 0 ? t : 0; + } + function gt(t) { + return t == null ? "" : Ae(t); + } + var iy = Tr(function(t, i) { + if (hi(i) || de(i)) { + nn(i, Gt(i), t); + return; + } + for (var o in i) + vt.call(i, o) && oi(t, o, i[o]); + }), Ff = Tr(function(t, i) { + nn(i, pe(i), t); + }), As = Tr(function(t, i, o, c) { + nn(i, pe(i), t, c); + }), sy = Tr(function(t, i, o, c) { + nn(i, Gt(i), t, c); + }), oy = mn(Bo); + function ay(t, i) { + var o = Or(t); + return i == null ? o : lc(o, i); + } + var uy = st(function(t, i) { + t = wt(t); + var o = -1, c = i.length, h = c > 2 ? i[2] : n; + for (h && fe(i[0], i[1], h) && (c = 1); ++o < c; ) + for (var v = i[o], w = pe(v), _ = -1, A = w.length; ++_ < A; ) { + var $ = w[_], P = t[$]; + (P === n || je(P, Sr[$]) && !vt.call(t, $)) && (t[$] = v[$]); + } + return t; + }), cy = st(function(t) { + return t.push(n, Yc), Ce(Mf, n, t); + }); + function fy(t, i) { + return zu(t, K(i, 3), en); + } + function ly(t, i) { + return zu(t, K(i, 3), Go); + } + function hy(t, i) { + return t == null ? t : Ho(t, K(i, 3), pe); + } + function dy(t, i) { + return t == null ? t : vc(t, K(i, 3), pe); + } + function py(t, i) { + return t && en(t, K(i, 3)); + } + function gy(t, i) { + return t && Go(t, K(i, 3)); + } + function vy(t) { + return t == null ? [] : ss(t, Gt(t)); + } + function my(t) { + return t == null ? [] : ss(t, pe(t)); + } + function Ca(t, i, o) { + var c = t == null ? n : rr(t, i); + return c === n ? o : c; + } + function yy(t, i) { + return t != null && Qc(t, i, Wg); + } + function Ea(t, i) { + return t != null && Qc(t, i, Bg); + } + var wy = jc(function(t, i, o) { + i != null && typeof i.toString != "function" && (i = zi.call(i)), t[i] = o; + }, xa(ge)), by = jc(function(t, i, o) { + i != null && typeof i.toString != "function" && (i = zi.call(i)), vt.call(t, i) ? t[i].push(o) : t[i] = [o]; + }, K), _y = st(ui); + function Gt(t) { + return de(t) ? cc(t) : Jo(t); + } + function pe(t) { + return de(t) ? cc(t, !0) : Zg(t); + } + function Cy(t, i) { + var o = {}; + return i = K(i, 3), en(t, function(c, h, v) { + gn(o, i(c, h, v), c); + }), o; + } + function Ey(t, i) { + var o = {}; + return i = K(i, 3), en(t, function(c, h, v) { + gn(o, h, i(c, h, v)); + }), o; + } + var Ay = Tr(function(t, i, o) { + os(t, i, o); + }), Mf = Tr(function(t, i, o, c) { + os(t, i, o, c); + }), xy = mn(function(t, i) { + var o = {}; + if (t == null) + return o; + var c = !1; + i = St(i, function(v) { + return v = Dn(v, t), c || (c = v.length > 1), v; + }), nn(t, ua(t), o), c && (o = Me(o, m | b | C, w0)); + for (var h = i.length; h--; ) + ta(o, i[h]); + return o; + }); + function Sy(t, i) { + return Df(t, _s(K(i))); + } + var Ry = mn(function(t, i) { + return t == null ? {} : t0(t, i); + }); + function Df(t, i) { + if (t == null) + return {}; + var o = St(ua(t), function(c) { + return [c]; + }); + return i = K(i), Sc(t, o, function(c, h) { + return i(c, h[0]); + }); + } + function Iy(t, i, o) { + i = Dn(i, t); + var c = -1, h = i.length; + for (h || (h = 1, t = n); ++c < h; ) { + var v = t == null ? n : t[rn(i[c])]; + v === n && (c = h, v = o), t = wn(v) ? v.call(t) : v; + } + return t; + } + function Oy(t, i, o) { + return t == null ? t : fi(t, i, o); + } + function Ty(t, i, o, c) { + return c = typeof c == "function" ? c : n, t == null ? t : fi(t, i, o, c); + } + var Uf = Jc(Gt), kf = Jc(pe); + function Ly(t, i, o) { + var c = tt(t), h = c || kn(t) || Pr(t); + if (i = K(i, 4), o == null) { + var v = t && t.constructor; + h ? o = c ? new v() : [] : It(t) ? o = wn(v) ? Or(Xi(t)) : {} : o = {}; + } + return (h ? $e : en)(t, function(w, _, A) { + return i(o, w, _, A); + }), o; + } + function $y(t, i) { + return t == null ? !0 : ta(t, i); + } + function Py(t, i, o) { + return t == null ? t : Lc(t, i, ra(o)); + } + function Fy(t, i, o, c) { + return c = typeof c == "function" ? c : n, t == null ? t : Lc(t, i, ra(o), c); + } + function Fr(t) { + return t == null ? [] : Mo(t, Gt(t)); + } + function My(t) { + return t == null ? [] : Mo(t, pe(t)); + } + function Dy(t, i, o) { + return o === n && (o = i, i = n), o !== n && (o = ke(o), o = o === o ? o : 0), i !== n && (i = ke(i), i = i === i ? i : 0), nr(ke(t), i, o); + } + function Uy(t, i, o) { + return i = bn(i), o === n ? (o = i, i = 0) : o = bn(o), t = ke(t), Hg(t, i, o); + } + function ky(t, i, o) { + if (o && typeof o != "boolean" && fe(t, i, o) && (i = o = n), o === n && (typeof i == "boolean" ? (o = i, i = n) : typeof t == "boolean" && (o = t, t = n)), t === n && i === n ? (t = 0, i = 1) : (t = bn(t), i === n ? (i = t, t = 0) : i = bn(i)), t > i) { + var c = t; + t = i, i = c; + } + if (o || t % 1 || i % 1) { + var h = ac(); + return ne(t + h * (i - t + vp("1e-" + ((h + "").length - 1))), i); + } + return Vo(t, i); + } + var Ny = Lr(function(t, i, o) { + return i = i.toLowerCase(), t + (o ? Nf(i) : i); + }); + function Nf(t) { + return Aa(gt(t).toLowerCase()); + } + function qf(t) { + return t = gt(t), t && t.replace(Wd, Op).replace(op, ""); + } + function qy(t, i, o) { + t = gt(t), i = Ae(i); + var c = t.length; + o = o === n ? c : nr(nt(o), 0, c); + var h = o; + return o -= i.length, o >= 0 && t.slice(o, h) == i; + } + function Wy(t) { + return t = gt(t), t && Qr.test(t) ? t.replace(Mi, Tp) : t; + } + function By(t) { + return t = gt(t), t && Be.test(t) ? t.replace($t, "\\$&") : t; + } + var Hy = Lr(function(t, i, o) { + return t + (o ? "-" : "") + i.toLowerCase(); + }), Gy = Lr(function(t, i, o) { + return t + (o ? " " : "") + i.toLowerCase(); + }), jy = Bc("toLowerCase"); + function zy(t, i, o) { + t = gt(t), i = nt(i); + var c = i ? Ar(t) : 0; + if (!i || c >= i) + return t; + var h = (i - c) / 2; + return hs(Qi(h), o) + t + hs(Zi(h), o); + } + function Ky(t, i, o) { + t = gt(t), i = nt(i); + var c = i ? Ar(t) : 0; + return i && c < i ? t + hs(i - c, o) : t; + } + function Jy(t, i, o) { + t = gt(t), i = nt(i); + var c = i ? Ar(t) : 0; + return i && c < i ? hs(i - c, o) + t : t; + } + function Xy(t, i, o) { + return o || i == null ? i = 0 : i && (i = +i), ng(gt(t).replace(_e, ""), i || 0); + } + function Yy(t, i, o) { + return (o ? fe(t, i, o) : i === n) ? i = 1 : i = nt(i), Zo(gt(t), i); + } + function Vy() { + var t = arguments, i = gt(t[0]); + return t.length < 3 ? i : i.replace(t[1], t[2]); + } + var Zy = Lr(function(t, i, o) { + return t + (o ? "_" : "") + i.toLowerCase(); + }); + function Qy(t, i, o) { + return o && typeof o != "number" && fe(t, i, o) && (i = o = n), o = o === n ? kt : o >>> 0, o ? (t = gt(t), t && (typeof i == "string" || i != null && !_a(i)) && (i = Ae(i), !i && Er(t)) ? Un(He(t), 0, o) : t.split(i, o)) : []; + } + var tw = Lr(function(t, i, o) { + return t + (o ? " " : "") + Aa(i); + }); + function ew(t, i, o) { + return t = gt(t), o = o == null ? 0 : nr(nt(o), 0, t.length), i = Ae(i), t.slice(o, o + i.length) == i; + } + function nw(t, i, o) { + var c = g.templateSettings; + o && fe(t, i, o) && (i = n), t = gt(t), i = As({}, i, c, Xc); + var h = As({}, i.imports, c.imports, Xc), v = Gt(h), w = Mo(h, v), _, A, $ = 0, P = i.interpolate || Ui, F = "__p += '", q = Uo( + (i.escape || Ui).source + "|" + P.source + "|" + (P === Ot ? Md : Ui).source + "|" + (i.evaluate || Ui).source + "|$", + "g" + ), j = "//# sourceURL=" + (vt.call(i, "sourceURL") ? (i.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++lp + "]") + ` +`; + t.replace(q, function(X, ot, lt, Se, le, Re) { + return lt || (lt = Se), F += t.slice($, Re).replace(Bd, Lp), ot && (_ = !0, F += `' + +__e(` + ot + `) + +'`), le && (A = !0, F += `'; +` + le + `; +__p += '`), lt && (F += `' + +((__t = (` + lt + `)) == null ? '' : __t) + +'`), $ = Re + X.length, X; + }), F += `'; +`; + var J = vt.call(i, "variable") && i.variable; + if (!J) + F = `with (obj) { +` + F + ` +} +`; + else if (Pd.test(J)) + throw new Z(l); + F = (A ? F.replace(Jt, "") : F).replace(Zr, "$1").replace(hn, "$1;"), F = "function(" + (J || "obj") + `) { +` + (J ? "" : `obj || (obj = {}); +`) + "var __t, __p = ''" + (_ ? ", __e = _.escape" : "") + (A ? `, __j = Array.prototype.join; +function print() { __p += __j.call(arguments, '') } +` : `; +`) + F + `return __p +}`; + var rt = Bf(function() { + return dt(v, j + "return " + F).apply(n, w); + }); + if (rt.source = F, ba(rt)) + throw rt; + return rt; + } + function rw(t) { + return gt(t).toLowerCase(); + } + function iw(t) { + return gt(t).toUpperCase(); + } + function sw(t, i, o) { + if (t = gt(t), t && (o || i === n)) + return Yu(t); + if (!t || !(i = Ae(i))) + return t; + var c = He(t), h = He(i), v = Vu(c, h), w = Zu(c, h) + 1; + return Un(c, v, w).join(""); + } + function ow(t, i, o) { + if (t = gt(t), t && (o || i === n)) + return t.slice(0, tc(t) + 1); + if (!t || !(i = Ae(i))) + return t; + var c = He(t), h = Zu(c, He(i)) + 1; + return Un(c, 0, h).join(""); + } + function aw(t, i, o) { + if (t = gt(t), t && (o || i === n)) + return t.replace(_e, ""); + if (!t || !(i = Ae(i))) + return t; + var c = He(t), h = Vu(c, He(i)); + return Un(c, h).join(""); + } + function uw(t, i) { + var o = qe, c = un; + if (It(i)) { + var h = "separator" in i ? i.separator : h; + o = "length" in i ? nt(i.length) : o, c = "omission" in i ? Ae(i.omission) : c; + } + t = gt(t); + var v = t.length; + if (Er(t)) { + var w = He(t); + v = w.length; + } + if (o >= v) + return t; + var _ = o - Ar(c); + if (_ < 1) + return c; + var A = w ? Un(w, 0, _).join("") : t.slice(0, _); + if (h === n) + return A + c; + if (w && (_ += A.length - _), _a(h)) { + if (t.slice(_).search(h)) { + var $, P = A; + for (h.global || (h = Uo(h.source, gt(yu.exec(h)) + "g")), h.lastIndex = 0; $ = h.exec(P); ) + var F = $.index; + A = A.slice(0, F === n ? _ : F); + } + } else if (t.indexOf(Ae(h), _) != _) { + var q = A.lastIndexOf(h); + q > -1 && (A = A.slice(0, q)); + } + return A + c; + } + function cw(t) { + return t = gt(t), t && Di.test(t) ? t.replace(Fi, kp) : t; + } + var fw = Lr(function(t, i, o) { + return t + (o ? " " : "") + i.toUpperCase(); + }), Aa = Bc("toUpperCase"); + function Wf(t, i, o) { + return t = gt(t), i = o ? n : i, i === n ? Pp(t) ? Wp(t) : Ap(t) : t.match(i) || []; + } + var Bf = st(function(t, i) { + try { + return Ce(t, n, i); + } catch (o) { + return ba(o) ? o : new Z(o); + } + }), lw = mn(function(t, i) { + return $e(i, function(o) { + o = rn(o), gn(t, o, ya(t[o], t)); + }), t; + }); + function hw(t) { + var i = t == null ? 0 : t.length, o = K(); + return t = i ? St(t, function(c) { + if (typeof c[1] != "function") + throw new Pe(f); + return [o(c[0]), c[1]]; + }) : [], st(function(c) { + for (var h = -1; ++h < i; ) { + var v = t[h]; + if (Ce(v[0], this, c)) + return Ce(v[1], this, c); + } + }); + } + function dw(t) { + return kg(Me(t, m)); + } + function xa(t) { + return function() { + return t; + }; + } + function pw(t, i) { + return t == null || t !== t ? i : t; + } + var gw = Gc(), vw = Gc(!0); + function ge(t) { + return t; + } + function Sa(t) { + return bc(typeof t == "function" ? t : Me(t, m)); + } + function mw(t) { + return Cc(Me(t, m)); + } + function yw(t, i) { + return Ec(t, Me(i, m)); + } + var ww = st(function(t, i) { + return function(o) { + return ui(o, t, i); + }; + }), bw = st(function(t, i) { + return function(o) { + return ui(t, o, i); + }; + }); + function Ra(t, i, o) { + var c = Gt(i), h = ss(i, c); + o == null && !(It(i) && (h.length || !c.length)) && (o = i, i = t, t = this, h = ss(i, Gt(i))); + var v = !(It(o) && "chain" in o) || !!o.chain, w = wn(t); + return $e(h, function(_) { + var A = i[_]; + t[_] = A, w && (t.prototype[_] = function() { + var $ = this.__chain__; + if (v || $) { + var P = t(this.__wrapped__), F = P.__actions__ = he(this.__actions__); + return F.push({ func: A, args: arguments, thisArg: t }), P.__chain__ = $, P; + } + return A.apply(t, Ln([this.value()], arguments)); + }); + }), t; + } + function _w() { + return Yt._ === this && (Yt._ = Kp), this; + } + function Ia() { + } + function Cw(t) { + return t = nt(t), st(function(i) { + return Ac(i, t); + }); + } + var Ew = sa(St), Aw = sa(ju), xw = sa(To); + function Hf(t) { + return ha(t) ? Lo(rn(t)) : e0(t); + } + function Sw(t) { + return function(i) { + return t == null ? n : rr(t, i); + }; + } + var Rw = zc(), Iw = zc(!0); + function Oa() { + return []; + } + function Ta() { + return !1; + } + function Ow() { + return {}; + } + function Tw() { + return ""; + } + function Lw() { + return !0; + } + function $w(t, i) { + if (t = nt(t), t < 1 || t > se) + return []; + var o = kt, c = ne(t, kt); + i = K(i), t -= kt; + for (var h = Fo(c, i); ++o < t; ) + i(o); + return h; + } + function Pw(t) { + return tt(t) ? St(t, rn) : xe(t) ? [t] : he(cf(gt(t))); + } + function Fw(t) { + var i = ++jp; + return gt(t) + i; + } + var Mw = ls(function(t, i) { + return t + i; + }, 0), Dw = oa("ceil"), Uw = ls(function(t, i) { + return t / i; + }, 1), kw = oa("floor"); + function Nw(t) { + return t && t.length ? is(t, ge, jo) : n; + } + function qw(t, i) { + return t && t.length ? is(t, K(i, 2), jo) : n; + } + function Ww(t) { + return Ju(t, ge); + } + function Bw(t, i) { + return Ju(t, K(i, 2)); + } + function Hw(t) { + return t && t.length ? is(t, ge, Xo) : n; + } + function Gw(t, i) { + return t && t.length ? is(t, K(i, 2), Xo) : n; + } + var jw = ls(function(t, i) { + return t * i; + }, 1), zw = oa("round"), Kw = ls(function(t, i) { + return t - i; + }, 0); + function Jw(t) { + return t && t.length ? Po(t, ge) : 0; + } + function Xw(t, i) { + return t && t.length ? Po(t, K(i, 2)) : 0; + } + return g.after = mm, g.ary = bf, g.assign = iy, g.assignIn = Ff, g.assignInWith = As, g.assignWith = sy, g.at = oy, g.before = _f, g.bind = ya, g.bindAll = lw, g.bindKey = Cf, g.castArray = Om, g.chain = mf, g.chunk = k0, g.compact = N0, g.concat = q0, g.cond = hw, g.conforms = dw, g.constant = xa, g.countBy = Jv, g.create = ay, g.curry = Ef, g.curryRight = Af, g.debounce = xf, g.defaults = uy, g.defaultsDeep = cy, g.defer = ym, g.delay = wm, g.difference = W0, g.differenceBy = B0, g.differenceWith = H0, g.drop = G0, g.dropRight = j0, g.dropRightWhile = z0, g.dropWhile = K0, g.fill = J0, g.filter = Yv, g.flatMap = Qv, g.flatMapDeep = tm, g.flatMapDepth = em, g.flatten = df, g.flattenDeep = X0, g.flattenDepth = Y0, g.flip = bm, g.flow = gw, g.flowRight = vw, g.fromPairs = V0, g.functions = vy, g.functionsIn = my, g.groupBy = nm, g.initial = Q0, g.intersection = tv, g.intersectionBy = ev, g.intersectionWith = nv, g.invert = wy, g.invertBy = by, g.invokeMap = im, g.iteratee = Sa, g.keyBy = sm, g.keys = Gt, g.keysIn = pe, g.map = ys, g.mapKeys = Cy, g.mapValues = Ey, g.matches = mw, g.matchesProperty = yw, g.memoize = bs, g.merge = Ay, g.mergeWith = Mf, g.method = ww, g.methodOf = bw, g.mixin = Ra, g.negate = _s, g.nthArg = Cw, g.omit = xy, g.omitBy = Sy, g.once = _m, g.orderBy = om, g.over = Ew, g.overArgs = Cm, g.overEvery = Aw, g.overSome = xw, g.partial = wa, g.partialRight = Sf, g.partition = am, g.pick = Ry, g.pickBy = Df, g.property = Hf, g.propertyOf = Sw, g.pull = ov, g.pullAll = gf, g.pullAllBy = av, g.pullAllWith = uv, g.pullAt = cv, g.range = Rw, g.rangeRight = Iw, g.rearg = Em, g.reject = fm, g.remove = fv, g.rest = Am, g.reverse = va, g.sampleSize = hm, g.set = Oy, g.setWith = Ty, g.shuffle = dm, g.slice = lv, g.sortBy = vm, g.sortedUniq = yv, g.sortedUniqBy = wv, g.split = Qy, g.spread = xm, g.tail = bv, g.take = _v, g.takeRight = Cv, g.takeRightWhile = Ev, g.takeWhile = Av, g.tap = Nv, g.throttle = Sm, g.thru = ms, g.toArray = Lf, g.toPairs = Uf, g.toPairsIn = kf, g.toPath = Pw, g.toPlainObject = Pf, g.transform = Ly, g.unary = Rm, g.union = xv, g.unionBy = Sv, g.unionWith = Rv, g.uniq = Iv, g.uniqBy = Ov, g.uniqWith = Tv, g.unset = $y, g.unzip = ma, g.unzipWith = vf, g.update = Py, g.updateWith = Fy, g.values = Fr, g.valuesIn = My, g.without = Lv, g.words = Wf, g.wrap = Im, g.xor = $v, g.xorBy = Pv, g.xorWith = Fv, g.zip = Mv, g.zipObject = Dv, g.zipObjectDeep = Uv, g.zipWith = kv, g.entries = Uf, g.entriesIn = kf, g.extend = Ff, g.extendWith = As, Ra(g, g), g.add = Mw, g.attempt = Bf, g.camelCase = Ny, g.capitalize = Nf, g.ceil = Dw, g.clamp = Dy, g.clone = Tm, g.cloneDeep = $m, g.cloneDeepWith = Pm, g.cloneWith = Lm, g.conformsTo = Fm, g.deburr = qf, g.defaultTo = pw, g.divide = Uw, g.endsWith = qy, g.eq = je, g.escape = Wy, g.escapeRegExp = By, g.every = Xv, g.find = Vv, g.findIndex = lf, g.findKey = fy, g.findLast = Zv, g.findLastIndex = hf, g.findLastKey = ly, g.floor = kw, g.forEach = yf, g.forEachRight = wf, g.forIn = hy, g.forInRight = dy, g.forOwn = py, g.forOwnRight = gy, g.get = Ca, g.gt = Mm, g.gte = Dm, g.has = yy, g.hasIn = Ea, g.head = pf, g.identity = ge, g.includes = rm, g.indexOf = Z0, g.inRange = Uy, g.invoke = _y, g.isArguments = or, g.isArray = tt, g.isArrayBuffer = Um, g.isArrayLike = de, g.isArrayLikeObject = Pt, g.isBoolean = km, g.isBuffer = kn, g.isDate = Nm, g.isElement = qm, g.isEmpty = Wm, g.isEqual = Bm, g.isEqualWith = Hm, g.isError = ba, g.isFinite = Gm, g.isFunction = wn, g.isInteger = Rf, g.isLength = Cs, g.isMap = If, g.isMatch = jm, g.isMatchWith = zm, g.isNaN = Km, g.isNative = Jm, g.isNil = Ym, g.isNull = Xm, g.isNumber = Of, g.isObject = It, g.isObjectLike = Tt, g.isPlainObject = pi, g.isRegExp = _a, g.isSafeInteger = Vm, g.isSet = Tf, g.isString = Es, g.isSymbol = xe, g.isTypedArray = Pr, g.isUndefined = Zm, g.isWeakMap = Qm, g.isWeakSet = ty, g.join = rv, g.kebabCase = Hy, g.last = Ue, g.lastIndexOf = iv, g.lowerCase = Gy, g.lowerFirst = jy, g.lt = ey, g.lte = ny, g.max = Nw, g.maxBy = qw, g.mean = Ww, g.meanBy = Bw, g.min = Hw, g.minBy = Gw, g.stubArray = Oa, g.stubFalse = Ta, g.stubObject = Ow, g.stubString = Tw, g.stubTrue = Lw, g.multiply = jw, g.nth = sv, g.noConflict = _w, g.noop = Ia, g.now = ws, g.pad = zy, g.padEnd = Ky, g.padStart = Jy, g.parseInt = Xy, g.random = ky, g.reduce = um, g.reduceRight = cm, g.repeat = Yy, g.replace = Vy, g.result = Iy, g.round = zw, g.runInContext = E, g.sample = lm, g.size = pm, g.snakeCase = Zy, g.some = gm, g.sortedIndex = hv, g.sortedIndexBy = dv, g.sortedIndexOf = pv, g.sortedLastIndex = gv, g.sortedLastIndexBy = vv, g.sortedLastIndexOf = mv, g.startCase = tw, g.startsWith = ew, g.subtract = Kw, g.sum = Jw, g.sumBy = Xw, g.template = nw, g.times = $w, g.toFinite = bn, g.toInteger = nt, g.toLength = $f, g.toLower = rw, g.toNumber = ke, g.toSafeInteger = ry, g.toString = gt, g.toUpper = iw, g.trim = sw, g.trimEnd = ow, g.trimStart = aw, g.truncate = uw, g.unescape = cw, g.uniqueId = Fw, g.upperCase = fw, g.upperFirst = Aa, g.each = yf, g.eachRight = wf, g.first = pf, Ra(g, function() { + var t = {}; + return en(g, function(i, o) { + vt.call(g.prototype, o) || (t[o] = i); + }), t; + }(), { chain: !1 }), g.VERSION = s, $e(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(t) { + g[t].placeholder = g; + }), $e(["drop", "take"], function(t, i) { + ut.prototype[t] = function(o) { + o = o === n ? 1 : Wt(nt(o), 0); + var c = this.__filtered__ && !i ? new ut(this) : this.clone(); + return c.__filtered__ ? c.__takeCount__ = ne(o, c.__takeCount__) : c.__views__.push({ + size: ne(o, kt), + type: t + (c.__dir__ < 0 ? "Right" : "") + }), c; + }, ut.prototype[t + "Right"] = function(o) { + return this.reverse()[t](o).reverse(); + }; + }), $e(["filter", "map", "takeWhile"], function(t, i) { + var o = i + 1, c = o == Qt || o == Yr; + ut.prototype[t] = function(h) { + var v = this.clone(); + return v.__iteratees__.push({ + iteratee: K(h, 3), + type: o + }), v.__filtered__ = v.__filtered__ || c, v; + }; + }), $e(["head", "last"], function(t, i) { + var o = "take" + (i ? "Right" : ""); + ut.prototype[t] = function() { + return this[o](1).value()[0]; + }; + }), $e(["initial", "tail"], function(t, i) { + var o = "drop" + (i ? "" : "Right"); + ut.prototype[t] = function() { + return this.__filtered__ ? new ut(this) : this[o](1); + }; + }), ut.prototype.compact = function() { + return this.filter(ge); + }, ut.prototype.find = function(t) { + return this.filter(t).head(); + }, ut.prototype.findLast = function(t) { + return this.reverse().find(t); + }, ut.prototype.invokeMap = st(function(t, i) { + return typeof t == "function" ? new ut(this) : this.map(function(o) { + return ui(o, t, i); + }); + }), ut.prototype.reject = function(t) { + return this.filter(_s(K(t))); + }, ut.prototype.slice = function(t, i) { + t = nt(t); + var o = this; + return o.__filtered__ && (t > 0 || i < 0) ? new ut(o) : (t < 0 ? o = o.takeRight(-t) : t && (o = o.drop(t)), i !== n && (i = nt(i), o = i < 0 ? o.dropRight(-i) : o.take(i - t)), o); + }, ut.prototype.takeRightWhile = function(t) { + return this.reverse().takeWhile(t).reverse(); + }, ut.prototype.toArray = function() { + return this.take(kt); + }, en(ut.prototype, function(t, i) { + var o = /^(?:filter|find|map|reject)|While$/.test(i), c = /^(?:head|last)$/.test(i), h = g[c ? "take" + (i == "last" ? "Right" : "") : i], v = c || /^find/.test(i); + h && (g.prototype[i] = function() { + var w = this.__wrapped__, _ = c ? [1] : arguments, A = w instanceof ut, $ = _[0], P = A || tt(w), F = function(ot) { + var lt = h.apply(g, Ln([ot], _)); + return c && q ? lt[0] : lt; + }; + P && o && typeof $ == "function" && $.length != 1 && (A = P = !1); + var q = this.__chain__, j = !!this.__actions__.length, J = v && !q, rt = A && !j; + if (!v && P) { + w = rt ? w : new ut(this); + var X = t.apply(w, _); + return X.__actions__.push({ func: ms, args: [F], thisArg: n }), new Fe(X, q); + } + return J && rt ? t.apply(this, _) : (X = this.thru(F), J ? c ? X.value()[0] : X.value() : X); + }); + }), $e(["pop", "push", "shift", "sort", "splice", "unshift"], function(t) { + var i = Hi[t], o = /^(?:push|sort|unshift)$/.test(t) ? "tap" : "thru", c = /^(?:pop|shift)$/.test(t); + g.prototype[t] = function() { + var h = arguments; + if (c && !this.__chain__) { + var v = this.value(); + return i.apply(tt(v) ? v : [], h); + } + return this[o](function(w) { + return i.apply(tt(w) ? w : [], h); + }); + }; + }), en(ut.prototype, function(t, i) { + var o = g[i]; + if (o) { + var c = o.name + ""; + vt.call(Ir, c) || (Ir[c] = []), Ir[c].push({ name: i, func: o }); + } + }), Ir[fs(n, x).name] = [{ + name: "wrapper", + func: n + }], ut.prototype.clone = cg, ut.prototype.reverse = fg, ut.prototype.value = lg, g.prototype.at = qv, g.prototype.chain = Wv, g.prototype.commit = Bv, g.prototype.next = Hv, g.prototype.plant = jv, g.prototype.reverse = zv, g.prototype.toJSON = g.prototype.valueOf = g.prototype.value = Kv, g.prototype.first = g.prototype.head, ei && (g.prototype[ei] = Gv), g; + }, xr = Bp(); + Zn ? ((Zn.exports = xr)._ = xr, So._ = xr) : Yt._ = xr; + }).call(Nr); +})(fo, fo.exports); +var Xn = fo.exports, eu = { exports: {} }, Ua, ll; +function Z_() { + if (ll) + return Ua; + ll = 1; + var r = 1e3, e = r * 60, n = e * 60, s = n * 24, a = s * 7, u = s * 365.25; + Ua = function(p, m) { + m = m || {}; + var b = typeof p; + if (b === "string" && p.length > 0) + return f(p); + if (b === "number" && isFinite(p)) + return m.long ? d(p) : l(p); + throw new Error( + "val is not a non-empty string or a valid number. val=" + JSON.stringify(p) + ); + }; + function f(p) { + if (p = String(p), !(p.length > 100)) { + var m = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( + p + ); + if (m) { + var b = parseFloat(m[1]), C = (m[2] || "ms").toLowerCase(); + switch (C) { + case "years": + case "year": + case "yrs": + case "yr": + case "y": + return b * u; + case "weeks": + case "week": + case "w": + return b * a; + case "days": + case "day": + case "d": + return b * s; + case "hours": + case "hour": + case "hrs": + case "hr": + case "h": + return b * n; + case "minutes": + case "minute": + case "mins": + case "min": + case "m": + return b * e; + case "seconds": + case "second": + case "secs": + case "sec": + case "s": + return b * r; + case "milliseconds": + case "millisecond": + case "msecs": + case "msec": + case "ms": + return b; + default: + return; + } + } + } + } + function l(p) { + var m = Math.abs(p); + return m >= s ? Math.round(p / s) + "d" : m >= n ? Math.round(p / n) + "h" : m >= e ? Math.round(p / e) + "m" : m >= r ? Math.round(p / r) + "s" : p + "ms"; + } + function d(p) { + var m = Math.abs(p); + return m >= s ? y(p, m, s, "day") : m >= n ? y(p, m, n, "hour") : m >= e ? y(p, m, e, "minute") : m >= r ? y(p, m, r, "second") : p + " ms"; + } + function y(p, m, b, C) { + var I = m >= b * 1.5; + return Math.round(p / b) + " " + C + (I ? "s" : ""); + } + return Ua; +} +function Q_(r) { + n.debug = n, n.default = n, n.coerce = d, n.disable = u, n.enable = a, n.enabled = f, n.humanize = Z_(), n.destroy = y, Object.keys(r).forEach((p) => { + n[p] = r[p]; + }), n.names = [], n.skips = [], n.formatters = {}; + function e(p) { + let m = 0; + for (let b = 0; b < p.length; b++) + m = (m << 5) - m + p.charCodeAt(b), m |= 0; + return n.colors[Math.abs(m) % n.colors.length]; + } + n.selectColor = e; + function n(p) { + let m, b = null, C, I; + function O(...R) { + if (!O.enabled) + return; + const x = O, D = Number(/* @__PURE__ */ new Date()), U = D - (m || D); + x.diff = U, x.prev = m, x.curr = D, m = D, R[0] = n.coerce(R[0]), typeof R[0] != "string" && R.unshift("%O"); + let M = 0; + R[0] = R[0].replace(/%([a-zA-Z%])/g, (ht, _t) => { + if (ht === "%%") + return "%"; + M++; + const xt = n.formatters[_t]; + if (typeof xt == "function") { + const Te = R[M]; + ht = xt.call(x, Te), R.splice(M, 1), M--; + } + return ht; + }), n.formatArgs.call(x, R), (x.log || n.log).apply(x, R); + } + return O.namespace = p, O.useColors = n.useColors(), O.color = n.selectColor(p), O.extend = s, O.destroy = n.destroy, Object.defineProperty(O, "enabled", { + enumerable: !0, + configurable: !1, + get: () => b !== null ? b : (C !== n.namespaces && (C = n.namespaces, I = n.enabled(p)), I), + set: (R) => { + b = R; + } + }), typeof n.init == "function" && n.init(O), O; + } + function s(p, m) { + const b = n(this.namespace + (typeof m > "u" ? ":" : m) + p); + return b.log = this.log, b; + } + function a(p) { + n.save(p), n.namespaces = p, n.names = [], n.skips = []; + let m; + const b = (typeof p == "string" ? p : "").split(/[\s,]+/), C = b.length; + for (m = 0; m < C; m++) + b[m] && (p = b[m].replace(/\*/g, ".*?"), p[0] === "-" ? n.skips.push(new RegExp("^" + p.slice(1) + "$")) : n.names.push(new RegExp("^" + p + "$"))); + } + function u() { + const p = [ + ...n.names.map(l), + ...n.skips.map(l).map((m) => "-" + m) + ].join(","); + return n.enable(""), p; + } + function f(p) { + if (p[p.length - 1] === "*") + return !0; + let m, b; + for (m = 0, b = n.skips.length; m < b; m++) + if (n.skips[m].test(p)) + return !1; + for (m = 0, b = n.names.length; m < b; m++) + if (n.names[m].test(p)) + return !0; + return !1; + } + function l(p) { + return p.toString().substring(2, p.toString().length - 2).replace(/\.\*\?$/, "*"); + } + function d(p) { + return p instanceof Error ? p.stack || p.message : p; + } + function y() { + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + return n.enable(n.load()), n; +} +var tC = Q_; +(function(r, e) { + e.formatArgs = s, e.save = a, e.load = u, e.useColors = n, e.storage = f(), e.destroy = (() => { + let d = !1; + return () => { + d || (d = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")); + }; + })(), e.colors = [ + "#0000CC", + "#0000FF", + "#0033CC", + "#0033FF", + "#0066CC", + "#0066FF", + "#0099CC", + "#0099FF", + "#00CC00", + "#00CC33", + "#00CC66", + "#00CC99", + "#00CCCC", + "#00CCFF", + "#3300CC", + "#3300FF", + "#3333CC", + "#3333FF", + "#3366CC", + "#3366FF", + "#3399CC", + "#3399FF", + "#33CC00", + "#33CC33", + "#33CC66", + "#33CC99", + "#33CCCC", + "#33CCFF", + "#6600CC", + "#6600FF", + "#6633CC", + "#6633FF", + "#66CC00", + "#66CC33", + "#9900CC", + "#9900FF", + "#9933CC", + "#9933FF", + "#99CC00", + "#99CC33", + "#CC0000", + "#CC0033", + "#CC0066", + "#CC0099", + "#CC00CC", + "#CC00FF", + "#CC3300", + "#CC3333", + "#CC3366", + "#CC3399", + "#CC33CC", + "#CC33FF", + "#CC6600", + "#CC6633", + "#CC9900", + "#CC9933", + "#CCCC00", + "#CCCC33", + "#FF0000", + "#FF0033", + "#FF0066", + "#FF0099", + "#FF00CC", + "#FF00FF", + "#FF3300", + "#FF3333", + "#FF3366", + "#FF3399", + "#FF33CC", + "#FF33FF", + "#FF6600", + "#FF6633", + "#FF9900", + "#FF9933", + "#FFCC00", + "#FFCC33" + ]; + function n() { + return typeof window < "u" && window.process && (window.process.type === "renderer" || window.process.__nwjs) ? !0 : typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/) ? !1 : typeof document < "u" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 + typeof window < "u" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker + typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); + } + function s(d) { + if (d[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + d[0] + (this.useColors ? "%c " : " ") + "+" + r.exports.humanize(this.diff), !this.useColors) + return; + const y = "color: " + this.color; + d.splice(1, 0, y, "color: inherit"); + let p = 0, m = 0; + d[0].replace(/%[a-zA-Z%]/g, (b) => { + b !== "%%" && (p++, b === "%c" && (m = p)); + }), d.splice(m, 0, y); + } + e.log = console.debug || console.log || (() => { + }); + function a(d) { + try { + d ? e.storage.setItem("debug", d) : e.storage.removeItem("debug"); + } catch { + } + } + function u() { + let d; + try { + d = e.storage.getItem("debug"); + } catch { + } + return !d && typeof process < "u" && "env" in process && (d = {}.DEBUG), d; + } + function f() { + try { + return localStorage; + } catch { + } + } + r.exports = tC(e); + const { formatters: l } = r.exports; + l.j = function(d) { + try { + return JSON.stringify(d); + } catch (y) { + return "[UnexpectedJSONParseError]: " + y.message; + } + }; +})(eu, eu.exports); +var eC = eu.exports; +const nC = /* @__PURE__ */ ud(eC), ct = nC("mutator-document"); +class sn { + constructor(e, n) { + W(this, "_value"); + W(this, "path"); + this._value = e, this.path = n || []; + } + containerType() { + return Array.isArray(this._value) ? "array" : this._value !== null && typeof this._value == "object" ? "object" : "primitive"; + } + // Common reader, supported by all containers + get() { + return this._value; + } + // Array reader + length() { + if (!Array.isArray(this._value)) + throw new Error("Won't return length of non-indexable _value"); + return this._value.length; + } + getIndex(e) { + return Array.isArray(this._value) ? e >= this.length() ? null : new sn(this._value[e], this.path.concat(e)) : !1; + } + // Object reader + hasAttribute(e) { + return gi(this._value) ? this._value.hasOwnProperty(e) : !1; + } + attributeKeys() { + return gi(this._value) ? Object.keys(this._value) : []; + } + getAttribute(e) { + if (!gi(this._value)) + throw new Error("getAttribute only applies to plain objects"); + return this.hasAttribute(e) ? new sn(this._value[e], this.path.concat(e)) : null; + } + // Common writer, supported by all containers + set(e) { + return e === this._value ? this : new sn(e, this.path); + } + // array writer interface + setIndex(e, n) { + if (!Array.isArray(this._value)) + throw new Error("setIndex only applies to arrays"); + if (Object.is(n, this._value[e])) + return this; + const s = this._value.slice(); + return s[e] = n, new sn(s, this.path); + } + setIndexAccessor(e, n) { + return this.setIndex(e, n.get()); + } + unsetIndices(e) { + if (!Array.isArray(this._value)) + throw new Error("unsetIndices only applies to arrays"); + const n = this._value.length, s = []; + for (let a = 0; a < n; a++) + e.indexOf(a) === -1 && s.push(this._value[a]); + return new sn(s, this.path); + } + insertItemsAt(e, n) { + if (!Array.isArray(this._value)) + throw new Error("insertItemsAt only applies to arrays"); + let s; + return this._value.length === 0 && e === 0 ? s = n : s = this._value.slice(0, e).concat(n).concat(this._value.slice(e)), new sn(s, this.path); + } + // Object writer interface + setAttribute(e, n) { + if (!gi(this._value)) + throw new Error("Unable to set attribute of non-object container"); + if (Object.is(n, this._value[e])) + return this; + const s = Object.assign({}, this._value, { [e]: n }); + return new sn(s, this.path); + } + setAttributeAccessor(e, n) { + return this.setAttribute(e, n.get()); + } + unsetAttribute(e) { + if (!gi(this._value)) + throw new Error("Unable to unset attribute of non-object container"); + const n = Object.assign({}, this._value); + return delete n[e], new sn(n, this.path); + } +} +function gi(r) { + return r !== null && typeof r == "object"; +} +function Js(r) { + return r !== null && typeof r == "object"; +} +const rC = /^[a-z_$]+/; +function iC(r) { + let e = ""; + return r.forEach((n, s) => { + e += sC(n, s === 0); + }), e; +} +function sC(r, e) { + if (typeof r == "number") + return `[${r}]`; + if (Js(r)) { + const n = r; + return Object.keys(r).map((s) => oC(n[s]) ? `[${s}=="${n[s]}"]` : "").join(""); + } + return typeof r == "string" && rC.test(r) ? e ? r : `.${r}` : `['${r}']`; +} +function oC(r) { + switch (typeof r) { + case "number": + case "string": + case "boolean": + return !0; + default: + return !1; + } +} +function aC(r) { + const [e, n] = cd(r); + if (!e) + throw new Error("Head cannot be null"); + return cC(e, n); +} +function cd(r) { + if (r.type !== "path") + return [r, null]; + const e = r.nodes; + return e.length === 0 ? [null, null] : e.length === 1 ? [e[0], null] : [e[0], { type: "path", nodes: e.slice(1) }]; +} +function uC(r, e) { + if (!r && !e) + return null; + const n = r ? r.nodes : [], s = e ? e.nodes : []; + return { + type: "path", + nodes: n.concat(s) + }; +} +function cC(r, e) { + return r.type !== "union" ? [[r, e]] : r.nodes.map((n) => { + if (n.type === "path") { + const [s, a] = cd(n); + return [s, uC(a, e)]; + } + return [n, e]; + }); +} +const fC = /[0-9]/, ka = /^[a-zA-Z0-9_]$/, lC = /^[a-zA-Z_]$/, fd = { + // NOTE: These are compared against in order of definition, + // thus '==' must come before '=', '>=' before '>', etc. + operator: ["..", ".", ",", ":", "?"], + comparator: [">=", "<=", "<", ">", "==", "!="], + keyword: ["$", "@"], + boolean: ["true", "false"], + paren: ["[", "]"] +}, hC = Object.keys(fd); +class dC { + constructor(e) { + W(this, "source"); + W(this, "i"); + W(this, "length"); + W(this, "tokenizers"); + this.source = e, this.length = e.length, this.i = 0, this.tokenizers = [ + this.tokenizeSymbol, + this.tokenizeIdentifier, + this.tokenizeNumber, + this.tokenizeQuoted + ].map((n) => n.bind(this)); + } + tokenize() { + const e = []; + for (; !this.EOF(); ) { + this.chompWhitespace(); + let n = null; + if (!this.tokenizers.some((a) => (n = a(), !!n)) || !n) + throw new Error(`Invalid tokens in jsonpath '${this.source}' @ ${this.i}`); + e.push(n); + } + return e; + } + takeWhile(e) { + const n = this.i; + let s = ""; + for (; !this.EOF(); ) { + const a = e(this.source[this.i]); + if (a === null) + break; + s += a, this.i++; + } + return this.i === n ? null : s; + } + EOF() { + return this.i >= this.length; + } + peek() { + return this.EOF() ? null : this.source[this.i]; + } + consume(e) { + if (this.i + e.length > this.length) + throw new Error(`Expected ${e} at end of jsonpath`); + if (e === this.source.slice(this.i, this.i + e.length)) + this.i += e.length; + else + throw new Error(`Expected "${e}", but source contained "${this.source.slice()}`); + } + // Tries to match the upcoming bit of string with the provided string. If it matches, returns + // the string, then advances the read pointer to the next bit. If not, returns null and nothing + // happens. + tryConsume(e) { + if (this.i + e.length > this.length) + return null; + if (e === this.source.slice(this.i, this.i + e.length)) { + if (e[0].match(ka) && this.length > this.i + e.length) { + const n = this.source[this.i + e.length]; + if (n && n.match(ka)) + return null; + } + return this.i += e.length, e; + } + return null; + } + chompWhitespace() { + this.takeWhile((e) => e === " " ? "" : null); + } + tokenizeQuoted() { + const e = this.peek(); + if (e === "'" || e === '"') { + this.consume(e); + let n = !1; + const s = this.takeWhile((a) => n ? (n = !1, a) : a === "\\" ? (n = !0, "") : a != e ? a : null); + return this.consume(e), { + type: "quoted", + value: s, + quote: e === '"' ? "double" : "single" + }; + } + return null; + } + tokenizeIdentifier() { + let e = !0; + const n = this.takeWhile((s) => e ? (e = !1, s.match(lC) ? s : null) : s.match(ka) ? s : null); + return n !== null ? { + type: "identifier", + name: n + } : null; + } + tokenizeNumber() { + const e = this.i; + let n = !1, s = !1, a = !1; + this.peek() === "-" && (a = !0, this.consume("-")); + const u = this.takeWhile((f) => f === "." && !n && s ? (n = !0, f) : (s = !0, f.match(fC) ? f : null)); + return u !== null ? { + type: "number", + value: a ? -u : +u, + raw: a ? `-${u}` : u + } : (this.i = e, null); + } + tokenizeSymbol() { + for (const e of hC) { + const s = fd[e].find((a) => this.tryConsume(a)); + if (s) + return { + type: e, + symbol: s + }; + } + return null; + } +} +function pC(r) { + return new dC(r).tokenize(); +} +class gC { + constructor(e) { + W(this, "tokens"); + W(this, "length"); + W(this, "i"); + this.tokens = pC(e), this.length = this.tokens.length, this.i = 0; + } + parse() { + return this.parsePath(); + } + EOF() { + return this.i >= this.length; + } + // Look at upcoming token + peek() { + return this.EOF() ? null : this.tokens[this.i]; + } + consume() { + const e = this.peek(); + return this.i += 1, e; + } + // Return next token if it matches the pattern + probe(e) { + const n = this.peek(); + if (!n) + return null; + const s = n; + return Object.keys(e).every((u) => u in n && e[u] === s[u]) ? n : null; + } + // Return and consume next token if it matches the pattern + match(e) { + return this.probe(e) ? this.consume() : null; + } + parseAttribute() { + const e = this.match({ type: "identifier" }); + if (e && e.type === "identifier") + return { + type: "attribute", + name: e.name + }; + const n = this.match({ type: "quoted", quote: "single" }); + return n && n.type === "quoted" ? { + type: "attribute", + name: n.value || "" + } : null; + } + parseAlias() { + return this.match({ type: "keyword", symbol: "@" }) || this.match({ type: "keyword", symbol: "$" }) ? { + type: "alias", + target: "self" + } : null; + } + parseNumber() { + const e = this.match({ type: "number" }); + return e && e.type === "number" ? { + type: "number", + value: e.value + } : null; + } + parseNumberValue() { + const e = this.parseNumber(); + return e ? e.value : null; + } + parseSliceSelector() { + const e = this.i, n = this.parseNumberValue(); + if (!this.match({ type: "operator", symbol: ":" })) + return n === null ? (this.i = e, null) : { type: "index", value: n }; + const a = { + type: "range", + start: n, + end: this.parseNumberValue() + }; + return this.match({ type: "operator", symbol: ":" }) && (a.step = this.parseNumberValue()), a.start === null && a.end === null ? (this.i = e, null) : a; + } + parseValueReference() { + return this.parseAttribute() || this.parseSliceSelector(); + } + parseLiteralValue() { + const e = this.match({ type: "quoted", quote: "double" }); + if (e && e.type === "quoted") + return { + type: "string", + value: e.value || "" + }; + const n = this.match({ type: "boolean" }); + return n && n.type === "boolean" ? { + type: "boolean", + value: n.symbol === "true" + } : this.parseNumber(); + } + // TODO: Reorder constraints so that literal value is always on rhs, and variable is always + // on lhs. + parseFilterExpression() { + const e = this.i, n = this.parseAttribute() || this.parseAlias(); + if (!n) + return null; + if (this.match({ type: "operator", symbol: "?" })) + return { + type: "constraint", + operator: "?", + lhs: n + }; + const s = this.match({ type: "comparator" }); + if (!s || s.type !== "comparator") + return this.i = e, null; + const a = n, u = this.parseLiteralValue(); + if (!u) + throw new Error(`Operator ${s.symbol} needs a literal value at the right hand side`); + return { + type: "constraint", + operator: s.symbol, + lhs: a, + rhs: u + }; + } + parseExpression() { + return this.parseFilterExpression() || this.parseValueReference(); + } + parseUnion() { + if (!this.match({ type: "paren", symbol: "[" })) + return null; + const e = []; + let n = this.parseFilterExpression() || this.parsePath() || this.parseValueReference(); + for (; n && (e.push(n), !this.match({ type: "paren", symbol: "]" })); ) { + if (!this.match({ type: "operator", symbol: "," })) + throw new Error("Expected ]"); + if (n = this.parseFilterExpression() || this.parsePath() || this.parseValueReference(), !n) + throw new Error("Expected expression following ','"); + } + return { + type: "union", + nodes: e + }; + } + parseRecursive() { + if (!this.match({ type: "operator", symbol: ".." })) + return null; + const e = this.parsePath(); + if (!e) + throw new Error("Expected path following '..' operator"); + return { + type: "recursive", + term: e + }; + } + parsePath() { + const e = [], n = this.parseAttribute() || this.parseUnion() || this.parseRecursive(); + if (!n) + return null; + for (e.push(n); !this.EOF(); ) + if (this.match({ type: "operator", symbol: "." })) { + const s = this.parseAttribute(); + if (!s) + throw new Error("Expected attribute name following '."); + e.push(s); + continue; + } else if (this.probe({ type: "paren", symbol: "[" })) { + const s = this.parseUnion(); + if (!s) + throw new Error("Expected union following '['"); + e.push(s); + } else { + const s = this.parseRecursive(); + s && e.push(s); + break; + } + return e.length === 1 ? e[0] : { + type: "path", + nodes: e + }; + } +} +function ld(r) { + const e = new gC(r).parse(); + if (!e) + throw new Error(`Failed to parse JSON path "${r}"`); + return e; +} +function hd(r) { + return qr(r, !1); +} +function qr(r, e) { + switch (r.type) { + case "attribute": + return r.name; + case "alias": + return r.target === "self" ? "@" : "$"; + case "number": + return `${r.value}`; + case "range": { + const n = []; + return e || n.push("["), r.start && n.push(`${r.start}`), n.push(":"), r.end && n.push(`${r.end}`), r.step && n.push(`:${r.step}`), e || n.push("]"), n.join(""); + } + case "index": + return e ? `${r.value}` : `[${r.value}]`; + case "constraint": { + const n = r.rhs ? ` ${qr(r.rhs, !1)}` : "", s = `${qr(r.lhs, !1)} ${r.operator}${n}`; + return e ? s : `[${s}]`; + } + case "string": + return JSON.stringify(r.value); + case "path": { + const n = [], s = r.nodes.slice(); + for (; s.length > 0; ) { + const a = s.shift(); + a && n.push(hd(a)); + const u = s[0]; + u && qr(u, !1)[0] !== "[" && n.push("."); + } + return n.join(""); + } + case "union": + return `[${r.nodes.map((n) => qr(n, !0)).join(",")}]`; + default: + throw new Error(`Unknown node type ${r.type}`); + case "recursive": + return `..${qr(r.term, !1)}`; + } +} +class Oe { + constructor(e) { + W(this, "expr"); + if (!e) + throw new Error("Attempted to create Expression from null-value"); + if ("expr" in e ? this.expr = e.expr : this.expr = e, !("type" in this.expr)) + throw new Error("Attempt to create Expression for expression with no type"); + } + isPath() { + return this.expr.type === "path"; + } + isUnion() { + return this.expr.type === "union"; + } + isCollection() { + return this.isPath() || this.isUnion(); + } + isConstraint() { + return this.expr.type === "constraint"; + } + isRecursive() { + return this.expr.type === "recursive"; + } + isExistenceConstraint() { + return this.expr.type === "constraint" && this.expr.operator === "?"; + } + isIndex() { + return this.expr.type === "index"; + } + isRange() { + return this.expr.type === "range"; + } + expandRange(e) { + const n = () => { + if (!e) + throw new Error("expandRange() required a probe that was not passed"); + return e.length(); + }; + let s = "start" in this.expr && this.expr.start || 0; + s = Na(s, e); + let a = "end" in this.expr && this.expr.end || n(); + a = Na(a, e); + const u = "step" in this.expr && this.expr.step || 1; + return { start: s, end: a, step: u }; + } + isAttributeReference() { + return this.expr.type === "attribute"; + } + // Is a range or index -> something referencing indexes + isIndexReference() { + return this.isIndex() || this.isRange(); + } + name() { + return "name" in this.expr ? this.expr.name : ""; + } + isSelfReference() { + return this.expr.type === "alias" && this.expr.target === "self"; + } + constraintTargetIsSelf() { + return this.expr.type === "constraint" && this.expr.lhs.type === "alias" && this.expr.lhs.target === "self"; + } + constraintTargetIsAttribute() { + return this.expr.type === "constraint" && this.expr.lhs.type === "attribute"; + } + testConstraint(e) { + const n = this.expr; + if (n.type === "constraint" && n.lhs.type === "alias" && n.lhs.target === "self") { + if (e.containerType() !== "primitive") + return !1; + if (n.type === "constraint" && n.operator === "?") + return !0; + const f = e.get(), l = n.rhs && "value" in n.rhs ? n.rhs.value : void 0; + return hl(f, n.operator, l); + } + if (n.type !== "constraint") + return !1; + const s = n.lhs; + if (!s) + throw new Error("No LHS of expression"); + if (s.type !== "attribute") + throw new Error(`Constraint target ${s.type} not supported`); + if (e.containerType() !== "object") + return !1; + const a = e.getAttribute(s.name); + if (a == null || a.containerType() !== "primitive") + return !1; + if (this.isExistenceConstraint()) + return !0; + const u = n.rhs && "value" in n.rhs ? n.rhs.value : void 0; + return hl(a.get(), n.operator, u); + } + pathNodes() { + return this.expr.type === "path" ? this.expr.nodes : [this.expr]; + } + prepend(e) { + return e ? new Oe({ + type: "path", + nodes: e.pathNodes().concat(this.pathNodes()) + }) : this; + } + concat(e) { + return e ? e.prepend(this) : this; + } + descend() { + return aC(this.expr).map((e) => { + const [n, s] = e; + return { + head: n ? new Oe(n) : null, + tail: s ? new Oe(s) : null + }; + }); + } + unwrapRecursive() { + if (this.expr.type !== "recursive") + throw new Error(`Attempt to unwrap recursive on type ${this.expr.type}`); + return new Oe(this.expr.term); + } + toIndicies(e) { + if (this.expr.type !== "index" && this.expr.type !== "range") + throw new Error("Node cannot be converted to indexes"); + if (this.expr.type === "index") + return [Na(this.expr.value, e)]; + const n = [], s = this.expandRange(e); + let { start: a, end: u } = s; + s.step < 0 && ([a, u] = [u, a]); + for (let f = a; f < u; f++) + n.push(f); + return n; + } + toFieldReferences() { + if (this.isIndexReference()) + return this.toIndicies(); + if (this.expr.type === "attribute") + return [this.expr.name]; + throw new Error(`Can't convert ${this.expr.type} to field references`); + } + toString() { + return hd(this.expr); + } + static fromPath(e) { + const n = ld(e); + if (!n) + throw new Error(`Failed to parse path "${e}"`); + return new Oe(n); + } + static attributeReference(e) { + return new Oe({ + type: "attribute", + name: e + }); + } + static indexReference(e) { + return new Oe({ + type: "index", + value: e + }); + } +} +function hl(r, e, n) { + switch (e) { + case ">": + return r > n; + case ">=": + return r >= n; + case "<": + return r < n; + case "<=": + return r <= n; + case "==": + return r === n; + case "!=": + return r !== n; + default: + throw new Error(`Unsupported binary operator ${e}`); + } +} +function Na(r, e) { + if (r >= 0) + return r; + if (!e) + throw new Error("interpretNegativeIndex() must have a probe when < 0"); + return r + e.length(); +} +class Wr { + constructor(e, n) { + W(this, "head"); + W(this, "tail"); + this.head = e, this.tail = n; + } + // Iterate this descender once processing any constraints that are + // resolvable on the current value. Returns an array of new descenders + // that are guaranteed to be without constraints in the head + iterate(e) { + let n = [this]; + if (this.head && this.head.isConstraint()) { + let s = !0; + for (; s; ) + n = Xn.flatten( + n.map((a) => a.iterateConstraints(e)) + ), s = n.some((a) => a.head && a.head.isConstraint()); + } + return n; + } + isRecursive() { + return !!(this.head && this.head.isRecursive()); + } + hasArrived() { + return this.head === null && this.tail === null; + } + extractRecursives() { + if (this.head && this.head.isRecursive()) { + const e = this.head.unwrapRecursive(); + return new Wr(null, e.concat(this.tail)).descend(); + } + return []; + } + iterateConstraints(e) { + const n = this.head; + if (n === null || !n.isConstraint()) + return [this]; + const s = []; + if (e.containerType() === "primitive" && n.constraintTargetIsSelf()) + return n.testConstraint(e) && s.push(...this.descend()), s; + if (e.containerType() === "array") { + const a = e.length(); + for (let u = 0; u < a; u++) { + const f = e.getIndex(u); + f && n.testConstraint(f) && s.push(new Wr(new Oe({ type: "index", value: u }), this.tail)); + } + return s; + } + return e.containerType() === "object" ? n.constraintTargetIsSelf() ? [] : n.testConstraint(e) ? this.descend() : s : s; + } + descend() { + return this.tail ? this.tail.descend().map((e) => new Wr(e.head, e.tail)) : [new Wr(null, null)]; + } + toString() { + const e = ["<"]; + return this.head && e.push(this.head.toString()), e.push("|"), this.tail && e.push(this.tail.toString()), e.push(">"), e.join(""); + } +} +class gr { + constructor(e, n) { + W(this, "active"); + W(this, "recursives"); + W(this, "payload"); + this.active = e || [], n ? (this.recursives = n.recursives, this.payload = n.payload) : this.recursives = [], this.extractRecursives(); + } + setPayload(e) { + return this.payload = e, this; + } + // Moves any recursive descenders onto the recursive track, removing them from + // the active set + extractRecursives() { + this.active = this.active.filter((e) => e.isRecursive() ? (this.recursives.push(...e.extractRecursives()), !1) : !0); + } + // Find recursives that are relevant now and should be considered part of the active set + activeRecursives(e) { + return this.recursives.filter((n) => { + const s = n.head; + return s ? s.isConstraint() || e.containerType() === "array" && s.isIndexReference() ? !0 : e.containerType() === "object" ? s.isAttributeReference() && e.hasAttribute(s.name()) : !1 : !1; + }); + } + match(e) { + return this.iterate(e).extractMatches(e); + } + iterate(e) { + const n = []; + return this.active.concat(this.activeRecursives(e)).forEach((s) => { + n.push(...s.iterate(e)); + }), new gr(n, this); + } + // Returns true if any of the descenders in the active or recursive set + // consider the current state a final destination + isDestination() { + return this.active.some((e) => e.hasArrived()); + } + hasRecursives() { + return this.recursives.length > 0; + } + // Returns any payload delivieries and leads that needs to be followed to complete + // the process. + extractMatches(e) { + const n = [], s = []; + if (this.active.forEach((a) => { + if (a.hasArrived()) { + s.push( + new Oe({ + type: "alias", + target: "self" + }) + ); + return; + } + const u = a.head; + if (u && !(e.containerType() === "array" && !u.isIndexReference()) && !(e.containerType() === "object" && !u.isAttributeReference())) + if (a.tail) { + const f = new gr(a.descend(), this); + u.toFieldReferences().forEach(() => { + n.push({ + target: u, + matcher: f + }); + }); + } else + s.push(u); + }), this.hasRecursives()) { + const a = new gr([], this); + if (e.containerType() === "array") { + const u = e.length(); + for (let f = 0; f < u; f++) + n.push({ + target: Oe.indexReference(f), + matcher: a + }); + } else + e.containerType() === "object" && e.attributeKeys().forEach((u) => { + n.push({ + target: Oe.attributeReference(u), + matcher: a + }); + }); + } + return s.length > 0 ? { leads: n, delivery: { targets: s, payload: this.payload } } : { leads: n }; + } + static fromPath(e) { + const n = ld(e); + if (!n) + throw new Error(`Failed to parse path from "${e}"`); + const s = new Wr(null, new Oe(n)); + return new gr(s.descend()); + } +} +class lo { + constructor(e, n) { + W(this, "_value"); + W(this, "path"); + this._value = e, this.path = n || []; + } + containerType() { + return Array.isArray(this._value) ? "array" : this._value !== null && typeof this._value == "object" ? "object" : "primitive"; + } + length() { + if (!Array.isArray(this._value)) + throw new Error("Won't return length of non-indexable _value"); + return this._value.length; + } + getIndex(e) { + return Array.isArray(this._value) ? e >= this.length() ? null : new lo(this._value[e], this.path.concat(e)) : !1; + } + hasAttribute(e) { + return Js(this._value) ? this._value.hasOwnProperty(e) : !1; + } + attributeKeys() { + return Js(this._value) ? Object.keys(this._value) : []; + } + getAttribute(e) { + if (!Js(this._value)) + throw new Error("getAttribute only applies to plain objects"); + return this.hasAttribute(e) ? new lo(this._value[e], this.path.concat(e)) : null; + } + get() { + return this._value; + } +} +function vC(r, e) { + const n = [], s = gr.fromPath(r).setPayload(function(f) { + n.push(...f); + }), a = new lo(e); + return dd(s, a), n; +} +function dd(r, e) { + const { leads: n, delivery: s } = r.match(e); + n.forEach((a) => { + dl(a.target, e).forEach((u) => { + dd(a.matcher, u); + }); + }), s && s.targets.forEach((a) => { + typeof s.payload == "function" && s.payload(dl(a, e)); + }); +} +function dl(r, e) { + const n = []; + if (r.isIndexReference()) + r.toIndicies(e).forEach((s) => { + n.push(e.getIndex(s)); + }); + else if (r.isAttributeReference()) + n.push(e.getAttribute(r.name())); + else if (r.isSelfReference()) + n.push(e); + else + throw new Error(`Unable to derive accessor for target ${r.toString()}`); + return Xn.compact(n); +} +function mC(r, e) { + return vC(r, e).map((s) => ({ path: s.path, value: s.get() })); +} +function yC(r) { + const e = r.charCodeAt(0); + return e >= 55296 && e <= 56319; +} +function nu(r) { + const e = r.charCodeAt(0); + return e >= 56320 && e <= 57343; +} +function Li(r) { + const [e, n] = r; + return [e, n]; +} +function pl(r, e) { + let n = r, s = e; + const a = n.length, u = s.length; + if (a === 0 || u === 0) + return 0; + a > u ? n = n.substring(a - u) : a < u && (s = s.substring(0, a)); + const f = Math.min(a, u); + if (n === s) + return f; + let l = 0, d = 1; + for (let y = 0; y !== -1; ) { + const p = n.substring(f - d); + if (y = s.indexOf(p), y === -1) + return l; + d += y, (y === 0 || n.substring(f - d) === s.substring(0, d)) && (l = d, d++); + } + return l; +} +function gu(r, e) { + if (!r || !e || r[0] !== e[0]) + return 0; + let n = 0, s = Math.min(r.length, e.length), a = s, u = 0; + for (; n < a; ) + r.substring(u, a) === e.substring(u, a) ? (n = a, u = n) : s = a, a = Math.floor((s - n) / 2 + n); + return a; +} +function vo(r, e) { + if (!r || !e || r[r.length - 1] !== e[e.length - 1]) + return 0; + let n = 0, s = Math.min(r.length, e.length), a = s, u = 0; + for (; n < a; ) + r.substring(r.length - a, r.length - u) === e.substring(e.length - a, e.length - u) ? (n = a, u = n) : s = a, a = Math.floor((s - n) / 2 + n); + return a; +} +function pd(r) { + let e = r.map((m) => Li(m)), n = !1; + const s = []; + let a = 0, u = null, f = 0, l = 0, d = 0, y = 0, p = 0; + for (; f < e.length; ) + e[f][0] === it ? (s[a++] = f, l = y, d = p, y = 0, p = 0, u = e[f][1]) : (e[f][0] === Rt ? y += e[f][1].length : p += e[f][1].length, u && u.length <= Math.max(l, d) && u.length <= Math.max(y, p) && (e.splice(s[a - 1], 0, [Et, u]), e[s[a - 1] + 1][0] = Rt, a--, a--, f = a > 0 ? s[a - 1] : -1, l = 0, d = 0, y = 0, p = 0, u = null, n = !0)), f++; + for (n && (e = mo(e)), e = gd(e), f = 1; f < e.length; ) { + if (e[f - 1][0] === Et && e[f][0] === Rt) { + const m = e[f - 1][1], b = e[f][1], C = pl(m, b), I = pl(b, m); + C >= I ? (C >= m.length / 2 || C >= b.length / 2) && (e.splice(f, 0, [it, b.substring(0, C)]), e[f - 1][1] = m.substring(0, m.length - C), e[f + 1][1] = b.substring(C), f++) : (I >= m.length / 2 || I >= b.length / 2) && (e.splice(f, 0, [it, m.substring(0, I)]), e[f - 1][0] = Rt, e[f - 1][1] = b.substring(0, b.length - I), e[f + 1][0] = Et, e[f + 1][1] = m.substring(I), f++), f++; + } + f++; + } + return e; +} +const gl = /[^a-zA-Z0-9]/, vl = /\s/, ml = /[\r\n]/, wC = /\n\r?\n$/, bC = /^\r?\n\r?\n/; +function gd(r) { + const e = r.map((a) => Li(a)); + function n(a, u) { + if (!a || !u) + return 6; + const f = a.charAt(a.length - 1), l = u.charAt(0), d = f.match(gl), y = l.match(gl), p = d && f.match(vl), m = y && l.match(vl), b = p && f.match(ml), C = m && l.match(ml), I = b && a.match(wC), O = C && u.match(bC); + return I || O ? 5 : b || C ? 4 : d && !p && m ? 3 : p || m ? 2 : d || y ? 1 : 0; + } + let s = 1; + for (; s < e.length - 1; ) { + if (e[s - 1][0] === it && e[s + 1][0] === it) { + let a = e[s - 1][1], u = e[s][1], f = e[s + 1][1]; + const l = vo(a, u); + if (l) { + const b = u.substring(u.length - l); + a = a.substring(0, a.length - l), u = b + u.substring(0, u.length - l), f = b + f; + } + let d = a, y = u, p = f, m = n(a, u) + n(u, f); + for (; u.charAt(0) === f.charAt(0); ) { + a += u.charAt(0), u = u.substring(1) + f.charAt(0), f = f.substring(1); + const b = n(a, u) + n(u, f); + b >= m && (m = b, d = a, y = u, p = f); + } + e[s - 1][1] !== d && (d ? e[s - 1][1] = d : (e.splice(s - 1, 1), s--), e[s][1] = y, p ? e[s + 1][1] = p : (e.splice(s + 1, 1), s--)); + } + s++; + } + return e; +} +function mo(r) { + let e = r.map((y) => Li(y)); + e.push([it, ""]); + let n = 0, s = 0, a = 0, u = "", f = "", l; + for (; n < e.length; ) + switch (e[n][0]) { + case Rt: + a++, f += e[n][1], n++; + break; + case Et: + s++, u += e[n][1], n++; + break; + case it: + s + a > 1 ? (s !== 0 && a !== 0 && (l = gu(f, u), l !== 0 && (n - s - a > 0 && e[n - s - a - 1][0] === it ? e[n - s - a - 1][1] += f.substring(0, l) : (e.splice(0, 0, [it, f.substring(0, l)]), n++), f = f.substring(l), u = u.substring(l)), l = vo(f, u), l !== 0 && (e[n][1] = f.substring(f.length - l) + e[n][1], f = f.substring(0, f.length - l), u = u.substring(0, u.length - l))), n -= s + a, e.splice(n, s + a), u.length && (e.splice(n, 0, [Et, u]), n++), f.length && (e.splice(n, 0, [Rt, f]), n++), n++) : n !== 0 && e[n - 1][0] === it ? (e[n - 1][1] += e[n][1], e.splice(n, 1)) : n++, a = 0, s = 0, u = "", f = ""; + break; + default: + throw new Error("Unknown diff operation"); + } + e[e.length - 1][1] === "" && e.pop(); + let d = !1; + for (n = 1; n < e.length - 1; ) + e[n - 1][0] === it && e[n + 1][0] === it && (e[n][1].substring(e[n][1].length - e[n - 1][1].length) === e[n - 1][1] ? (e[n][1] = e[n - 1][1] + e[n][1].substring(0, e[n][1].length - e[n - 1][1].length), e[n + 1][1] = e[n - 1][1] + e[n + 1][1], e.splice(n - 1, 1), d = !0) : e[n][1].substring(0, e[n + 1][1].length) === e[n + 1][1] && (e[n - 1][1] += e[n + 1][1], e[n][1] = e[n][1].substring(e[n + 1][1].length) + e[n + 1][1], e.splice(n + 1, 1), d = !0)), n++; + return d && (e = mo(e)), e; +} +function _C() { + for (var r = arguments.length, e = new Array(r), n = 0; n < r; n++) + e[n] = arguments[n]; + return e.reduce((s, a) => s + (a ? 1 : 0), 0); +} +function CC(r) { + let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 4, n = r.map((b) => Li(b)), s = !1; + const a = []; + let u = 0, f = null, l = 0, d = !1, y = !1, p = !1, m = !1; + for (; l < n.length; ) + n[l][0] === it ? (n[l][1].length < e && (p || m) ? (a[u++] = l, d = p, y = m, f = n[l][1]) : (u = 0, f = null), p = !1, m = !1) : (n[l][0] === Et ? m = !0 : p = !0, f && (d && y && p && m || f.length < e / 2 && _C(d, y, p, m) === 3) && (n.splice(a[u - 1], 0, [Et, f]), n[a[u - 1] + 1][0] = Rt, u--, f = null, d && y ? (p = !0, m = !0, u = 0) : (u--, l = u > 0 ? a[u - 1] : -1, p = !1, m = !1), s = !0)), l++; + return s && (n = mo(n)), n; +} +function EC(r, e, n) { + const s = r.length, a = e.length, u = Math.ceil((s + a) / 2), f = u, l = 2 * u, d = new Array(l), y = new Array(l); + for (let R = 0; R < l; R++) + d[R] = -1, y[R] = -1; + d[f + 1] = 0, y[f + 1] = 0; + const p = s - a, m = p % 2 !== 0; + let b = 0, C = 0, I = 0, O = 0; + for (let R = 0; R < u && !(Date.now() > n); R++) { + for (let x = -R + b; x <= R - C; x += 2) { + const D = f + x; + let U; + x === -R || x !== R && d[D - 1] < d[D + 1] ? U = d[D + 1] : U = d[D - 1] + 1; + let M = U - x; + for (; U < s && M < a && r.charAt(U) === e.charAt(M); ) + U++, M++; + if (d[D] = U, U > s) + C += 2; + else if (M > a) + b += 2; + else if (m) { + const z = f + p - x; + if (z >= 0 && z < l && y[z] !== -1) { + const ht = s - y[z]; + if (U >= ht) + return yl(r, e, U, M, n); + } + } + } + for (let x = -R + I; x <= R - O; x += 2) { + const D = f + x; + let U; + x === -R || x !== R && y[D - 1] < y[D + 1] ? U = y[D + 1] : U = y[D - 1] + 1; + let M = U - x; + for (; U < s && M < a && r.charAt(s - U - 1) === e.charAt(a - M - 1); ) + U++, M++; + if (y[D] = U, U > s) + O += 2; + else if (M > a) + I += 2; + else if (!m) { + const z = f + p - x; + if (z >= 0 && z < l && d[z] !== -1) { + const ht = d[z], _t = f + ht - z; + if (U = s - U, ht >= U) + return yl(r, e, ht, _t, n); + } + } + } + } + return [[Et, r], [Rt, e]]; +} +function yl(r, e, n, s, a) { + const u = r.substring(0, n), f = e.substring(0, s), l = r.substring(n), d = e.substring(s), y = vr(u, f, { + checkLines: !1, + deadline: a + }), p = vr(l, d, { + checkLines: !1, + deadline: a + }); + return y.concat(p); +} +function AC(r, e) { + if ((arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1) <= 0) + return null; + const s = r.length > e.length ? r : e, a = r.length > e.length ? e : r; + if (s.length < 4 || a.length * 2 < s.length) + return null; + const u = wl(s, a, Math.ceil(s.length / 4)), f = wl(s, a, Math.ceil(s.length / 2)); + let l; + if (u && f) + l = u[4].length > f[4].length ? u : f; + else { + if (!u && !f) + return null; + f ? u || (l = f) : l = u; + } + if (!l) + throw new Error("Unable to find a half match."); + let d, y, p, m; + r.length > e.length ? (d = l[0], y = l[1], p = l[2], m = l[3]) : (p = l[0], m = l[1], d = l[2], y = l[3]); + const b = l[4]; + return [d, y, p, m, b]; +} +function wl(r, e, n) { + const s = r.slice(n, n + Math.floor(r.length / 4)); + let a = -1, u = "", f, l, d, y; + for (; (a = e.indexOf(s, a + 1)) !== -1; ) { + const p = gu(r.slice(n), e.slice(a)), m = vo(r.slice(0, n), e.slice(0, a)); + u.length < m + p && (u = e.slice(a - m, a) + e.slice(a, a + p), f = r.slice(0, n - m), l = r.slice(n + p), d = e.slice(0, a - m), y = e.slice(a + p)); + } + return u.length * 2 >= r.length ? [f || "", l || "", d || "", y || "", u || ""] : null; +} +function xC(r, e) { + for (let n = 0; n < r.length; n++) { + const s = r[n][1], a = []; + for (let u = 0; u < s.length; u++) + a[u] = e[s.charCodeAt(u)]; + r[n][1] = a.join(""); + } +} +function SC(r, e) { + const n = [], s = {}; + n[0] = ""; + function a(d) { + let y = "", p = 0, m = -1, b = n.length; + for (; m < d.length - 1; ) { + m = d.indexOf(` +`, p), m === -1 && (m = d.length - 1); + let C = d.slice(p, m + 1); + (s.hasOwnProperty ? s.hasOwnProperty(C) : s[C] !== void 0) ? y += String.fromCharCode(s[C]) : (b === u && (C = d.slice(p), m = d.length), y += String.fromCharCode(b), s[C] = b, n[b++] = C), p = m + 1; + } + return y; + } + let u = 4e4; + const f = a(r); + u = 65535; + const l = a(e); + return { + chars1: f, + chars2: l, + lineArray: n + }; +} +function RC(r, e, n) { + let s = r, a = e; + const u = SC(s, a); + s = u.chars1, a = u.chars2; + const f = u.lineArray; + let l = vr(s, a, { + checkLines: !1, + deadline: n.deadline + }); + xC(l, f), l = pd(l), l.push([it, ""]); + let d = 0, y = 0, p = 0, m = "", b = ""; + for (; d < l.length; ) { + switch (l[d][0]) { + case Rt: + p++, b += l[d][1]; + break; + case Et: + y++, m += l[d][1]; + break; + case it: + if (y >= 1 && p >= 1) { + l.splice(d - y - p, y + p), d = d - y - p; + const C = vr(m, b, { + checkLines: !1, + deadline: n.deadline + }); + for (let I = C.length - 1; I >= 0; I--) + l.splice(d, 0, C[I]); + d += C.length; + } + p = 0, y = 0, m = "", b = ""; + break; + default: + throw new Error("Unknown diff operation."); + } + d++; + } + return l.pop(), l; +} +function IC(r, e, n) { + let s; + if (!r) + return [[Rt, e]]; + if (!e) + return [[Et, r]]; + const a = r.length > e.length ? r : e, u = r.length > e.length ? e : r, f = a.indexOf(u); + if (f !== -1) + return s = [[Rt, a.substring(0, f)], [it, u], [Rt, a.substring(f + u.length)]], r.length > e.length && (s[0][0] = Et, s[2][0] = Et), s; + if (u.length === 1) + return [[Et, r], [Rt, e]]; + const l = AC(r, e); + if (l) { + const d = l[0], y = l[1], p = l[2], m = l[3], b = l[4], C = vr(d, p, n), I = vr(y, m, n); + return C.concat([[it, b]], I); + } + return n.checkLines && r.length > 100 && e.length > 100 ? RC(r, e, n) : EC(r, e, n.deadline); +} +const Et = -1, Rt = 1, it = 0; +function vd(r, e, n) { + if (r === null || e === null) + throw new Error("Null input. (diff)"); + const s = vr(r, e, TC(n || {})); + return $C(s), s; +} +function vr(r, e, n) { + let s = r, a = e; + if (s === a) + return s ? [[it, s]] : []; + let u = gu(s, a); + const f = s.substring(0, u); + s = s.substring(u), a = a.substring(u), u = vo(s, a); + const l = s.substring(s.length - u); + s = s.substring(0, s.length - u), a = a.substring(0, a.length - u); + let d = IC(s, a, n); + return f && d.unshift([it, f]), l && d.push([it, l]), d = mo(d), d; +} +function OC(r) { + let e = 1; + return typeof r < "u" && (e = r <= 0 ? Number.MAX_VALUE : r), Date.now() + e * 1e3; +} +function TC(r) { + return { + checkLines: !0, + deadline: OC(r.timeout || 1), + ...r + }; +} +function Rs(r, e, n) { + return n === 1 ? r + e : e + r; +} +function Is(r, e) { + return e === 1 ? [r.substring(0, r.length - 1), r[r.length - 1]] : [r.substring(1), r[0]]; +} +function LC(r, e, n, s) { + return s === 1 ? r[e][1][r[e][1].length - 1] === r[n][1][r[n][1].length - 1] : r[e][1][0] === r[n][1][0]; +} +function bl(r, e, n) { + const s = n === 1 ? -1 : 1; + let a = null, u = null, f = e + n; + for (; f >= 0 && f < r.length && (a === null || u === null); f += n) { + const [y, p] = r[f]; + if (p.length !== 0) { + if (y === Rt) { + a === null && (a = f); + continue; + } else if (y === Et) { + u === null && (u = f); + continue; + } else if (y === it) { + if (a === null && u === null) { + const [m, b] = Is(r[e][1], n); + r[e][1] = m, r[f][1] = Rs(r[f][1], b, s); + return; + } + break; + } + } + } + if (a !== null && u !== null && LC(r, a, u, n)) { + const [y, p] = Is(r[a][1], s), [m] = Is(r[u][1], s); + r[a][1] = y, r[u][1] = m, r[e][1] = Rs(r[e][1], p, n); + return; + } + const [l, d] = Is(r[e][1], n); + r[e][1] = l, a === null ? (r.splice(f, 0, [Rt, d]), u !== null && u >= f && u++) : r[a][1] = Rs(r[a][1], d, s), u === null ? r.splice(f, 0, [Et, d]) : r[u][1] = Rs(r[u][1], d, s); +} +function $C(r) { + for (let e = 0; e < r.length; e++) { + const [n, s] = r[e]; + if (s.length === 0) + continue; + const a = s[0], u = s[s.length - 1]; + yC(u) && n === it && bl(r, e, 1), nu(a) && n === it && bl(r, e, -1); + } + for (let e = 0; e < r.length; e++) + r[e][1].length === 0 && r.splice(e, 1); +} +const PC = { + /** + * At what point is no match declared (0.0 = perfection, 1.0 = very loose). + */ + threshold: 0.5, + /** + * How far to search for a match (0 = exact location, 1000+ = broad match). + * A match this many characters away from the expected location will add + * 1.0 to the score (0.0 is a perfect match). + */ + distance: 1e3 +}; +function FC(r) { + return { + ...PC, + ...r + }; +} +const MC = 32; +function DC(r, e, n) { + let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; + if (e.length > MC) + throw new Error("Pattern too long for this browser."); + const a = FC(s), u = UC(e); + function f(I, O) { + const R = I / e.length, x = Math.abs(n - O); + return a.distance ? R + x / a.distance : x ? 1 : R; + } + let l = a.threshold, d = r.indexOf(e, n); + d !== -1 && (l = Math.min(f(0, d), l), d = r.lastIndexOf(e, n + e.length), d !== -1 && (l = Math.min(f(0, d), l))); + const y = 1 << e.length - 1; + d = -1; + let p, m, b = e.length + r.length, C = []; + for (let I = 0; I < e.length; I++) { + for (p = 0, m = b; p < m; ) + f(I, n + m) <= l ? p = m : b = m, m = Math.floor((b - p) / 2 + p); + b = m; + let O = Math.max(1, n - m + 1); + const R = Math.min(n + m, r.length) + e.length, x = new Array(R + 2); + x[R + 1] = (1 << I) - 1; + for (let D = R; D >= O; D--) { + const U = u[r.charAt(D - 1)]; + if (I === 0 ? x[D] = (x[D + 1] << 1 | 1) & U : x[D] = (x[D + 1] << 1 | 1) & U | ((C[D + 1] | C[D]) << 1 | 1) | C[D + 1], x[D] & y) { + const M = f(I, D - 1); + if (M <= l) + if (l = M, d = D - 1, d > n) + O = Math.max(1, 2 * n - d); + else + break; + } + } + if (f(I + 1, n) > l) + break; + C = x; + } + return d; +} +function UC(r) { + const e = {}; + for (let n = 0; n < r.length; n++) + e[r.charAt(n)] = 0; + for (let n = 0; n < r.length; n++) + e[r.charAt(n)] |= 1 << r.length - n - 1; + return e; +} +function qa(r, e, n) { + if (r === null || e === null || n === null) + throw new Error("Null input. (match())"); + const s = Math.max(0, Math.min(n, r.length)); + if (r === e) + return 0; + if (r.length) { + if (r.substring(s, s + e.length) === e) + return s; + } else + return -1; + return DC(r, e, s); +} +function ho(r, e) { + return { + diffs: [], + start1: r, + start2: e, + utf8Start1: r, + utf8Start2: e, + length1: 0, + length2: 0, + utf8Length1: 0, + utf8Length2: 0 + }; +} +function vu(r) { + const e = []; + for (let n = 0; n < r.length; n++) + r[n][0] !== Rt && (e[n] = r[n][1]); + return e.join(""); +} +function md(r) { + const e = []; + for (let n = 0; n < r.length; n++) + r[n][0] !== Et && (e[n] = r[n][1]); + return e.join(""); +} +function Kn(r) { + let e = 0; + for (let n = 0; n < r.length; n++) { + const s = r.codePointAt(n); + if (typeof s > "u") + throw new Error("Failed to get codepoint"); + e += yd(s); + } + return e; +} +function kC(r, e) { + let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, s = 0, a = 0; + function u(l) { + for (; s < l; ) { + const d = e.codePointAt(a); + if (typeof d > "u") + return a; + s += yd(d), d > 65535 ? a += 2 : a += 1; + } + if (!n.allowExceedingIndices && s !== l) + throw new Error("Failed to determine byte offset"); + return a; + } + const f = []; + for (const l of r) + f.push({ + diffs: l.diffs.map((d) => Li(d)), + start1: u(l.start1), + start2: u(l.start2), + utf8Start1: l.utf8Start1, + utf8Start2: l.utf8Start2, + length1: l.length1, + length2: l.length2, + utf8Length1: l.utf8Length1, + utf8Length2: l.utf8Length2 + }); + return f; +} +function yd(r) { + return r <= 127 ? 1 : r <= 2047 ? 2 : r <= 65535 ? 3 : 4; +} +const Hn = 32, mu = 4, NC = { + margin: 4 +}; +function Wa() { + let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; + return { + ...NC, + ...r + }; +} +function qC(r, e, n) { + if (typeof r == "string" && typeof e == "string") { + let s = vd(r, e, { + checkLines: !0 + }); + return s.length > 2 && (s = pd(s), s = CC(s)), Ba(r, s, Wa(n)); + } + if (r && Array.isArray(r) && typeof e > "u") + return Ba(vu(r), r, Wa(n)); + if (typeof r == "string" && e && Array.isArray(e)) + return Ba(r, e, Wa(n)); + throw new Error("Unknown call format to make()"); +} +function Ba(r, e, n) { + if (e.length === 0) + return []; + const s = []; + let a = ho(0, 0), u = 0, f = 0, l = 0, d = 0, y = 0, p = r, m = r; + for (let b = 0; b < e.length; b++) { + const C = e[b], [I, O] = C, R = O.length, x = Kn(O); + switch (!u && I !== it && (a.start1 = f, a.start2 = l, a.utf8Start1 = d, a.utf8Start2 = y), I) { + case Rt: + a.diffs[u++] = C, a.length2 += R, a.utf8Length2 += x, m = m.substring(0, l) + O + m.substring(l); + break; + case Et: + a.length1 += R, a.utf8Length1 += x, a.diffs[u++] = C, m = m.substring(0, l) + m.substring(l + R); + break; + case it: + R <= 2 * n.margin && u && e.length !== b + 1 ? (a.diffs[u++] = C, a.length1 += R, a.length2 += R, a.utf8Length1 += x, a.utf8Length2 += x) : R >= 2 * n.margin && u && (_l(a, p, n), s.push(a), a = ho(-1, -1), u = 0, p = m, f = l, d = y); + break; + default: + throw new Error("Unknown diff type"); + } + I !== Rt && (f += R, d += x), I !== Et && (l += R, y += x); + } + return u && (_l(a, p, n), s.push(a)), s; +} +function _l(r, e, n) { + if (e.length === 0) + return; + let s = e.substring(r.start2, r.start2 + r.length1), a = 0; + for (; e.indexOf(s) !== e.lastIndexOf(s) && s.length < Hn - n.margin - n.margin; ) + a += n.margin, s = e.substring(r.start2 - a, r.start2 + r.length1 + a); + a += n.margin; + let u = r.start2 - a; + u >= 1 && nu(e[u]) && u--; + const f = e.substring(u, r.start2); + f && r.diffs.unshift([it, f]); + const l = f.length, d = Kn(f); + let y = r.start2 + r.length1 + a; + y < e.length && nu(e[y]) && y++; + const p = e.substring(r.start2 + r.length1, y); + p && r.diffs.push([it, p]); + const m = p.length, b = Kn(p); + r.start1 -= l, r.start2 -= l, r.utf8Start1 -= d, r.utf8Start2 -= d, r.length1 += l + m, r.length2 += l + m, r.utf8Length1 += d + b, r.utf8Length2 += d + b; +} +function WC(r) { + let e = 0, n = 0, s = 0; + for (let a = 0; a < r.length; a++) { + const u = r[a][0], f = r[a][1]; + switch (u) { + case Rt: + n += f.length; + break; + case Et: + s += f.length; + break; + case it: + e += Math.max(n, s), n = 0, s = 0; + break; + default: + throw new Error("Unknown diff operation."); + } + } + return e += Math.max(n, s), e; +} +function Cl(r, e) { + let n = 0, s = 0, a = 0, u = 0, f; + for (f = 0; f < r.length && (r[f][0] !== Rt && (n += r[f][1].length), r[f][0] !== Et && (s += r[f][1].length), !(n > e)); f++) + a = n, u = s; + return r.length !== f && r[f][0] === Et ? u : u + (e - a); +} +function BC(r) { + const n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : mu; + let s = ""; + for (let f = 1; f <= n; f++) + s += String.fromCharCode(f); + for (const f of r) + f.start1 += n, f.start2 += n, f.utf8Start1 += n, f.utf8Start2 += n; + let a = r[0], u = a.diffs; + if (u.length === 0 || u[0][0] !== it) + u.unshift([it, s]), a.start1 -= n, a.start2 -= n, a.utf8Start1 -= n, a.utf8Start2 -= n, a.length1 += n, a.length2 += n, a.utf8Length1 += n, a.utf8Length2 += n; + else if (n > u[0][1].length) { + const f = u[0][1].length, l = n - f; + u[0][1] = s.substring(f) + u[0][1], a.start1 -= l, a.start2 -= l, a.utf8Start1 -= l, a.utf8Start2 -= l, a.length1 += l, a.length2 += l, a.utf8Length1 += l, a.utf8Length2 += l; + } + if (a = r[r.length - 1], u = a.diffs, u.length === 0 || u[u.length - 1][0] !== it) + u.push([it, s]), a.length1 += n, a.length2 += n, a.utf8Length1 += n, a.utf8Length2 += n; + else if (n > u[u.length - 1][1].length) { + const f = n - u[u.length - 1][1].length; + u[u.length - 1][1] += s.substring(0, f), a.length1 += f, a.length2 += f, a.utf8Length1 += f, a.utf8Length2 += f; + } + return s; +} +function HC(r) { + let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : mu; + const n = Hn; + for (let s = 0; s < r.length; s++) { + if (r[s].length1 <= n) + continue; + const a = r[s]; + r.splice(s--, 1); + let u = a.start1, f = a.start2, l = ""; + for (; a.diffs.length !== 0; ) { + const d = ho(u - l.length, f - l.length); + let y = !0; + if (l !== "") { + const b = Kn(l); + d.length1 = l.length, d.utf8Length1 = b, d.length2 = l.length, d.utf8Length2 = b, d.diffs.push([it, l]); + } + for (; a.diffs.length !== 0 && d.length1 < n - e; ) { + const b = a.diffs[0][0]; + let C = a.diffs[0][1], I = Kn(C); + if (b === Rt) { + d.length2 += C.length, d.utf8Length2 += I, f += C.length; + const O = a.diffs.shift(); + O && d.diffs.push(O), y = !1; + } else + b === Et && d.diffs.length === 1 && d.diffs[0][0] === it && C.length > 2 * n ? (d.length1 += C.length, d.utf8Length1 += I, u += C.length, y = !1, d.diffs.push([b, C]), a.diffs.shift()) : (C = C.substring(0, n - d.length1 - e), I = Kn(C), d.length1 += C.length, d.utf8Length1 += I, u += C.length, b === it ? (d.length2 += C.length, d.utf8Length2 += I, f += C.length) : y = !1, d.diffs.push([b, C]), C === a.diffs[0][1] ? a.diffs.shift() : a.diffs[0][1] = a.diffs[0][1].substring(C.length)); + } + l = md(d.diffs), l = l.substring(l.length - e); + const p = vu(a.diffs).substring(0, e), m = Kn(p); + p !== "" && (d.length1 += p.length, d.length2 += p.length, d.utf8Length1 += m, d.utf8Length2 += m, d.diffs.length !== 0 && d.diffs[d.diffs.length - 1][0] === it ? d.diffs[d.diffs.length - 1][1] += p : d.diffs.push([it, p])), y || r.splice(++s, 0, d); + } + } +} +function GC(r, e) { + let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; + if (typeof r == "string") + throw new Error("Patches must be an array - pass the patch to `parsePatch()` first"); + let s = e; + if (r.length === 0) + return [s, []]; + const a = kC(r, s, { + allowExceedingIndices: n.allowExceedingIndices + }), u = n.margin || mu, f = n.deleteThreshold || 0.4, l = BC(a, u); + s = l + s + l, HC(a, u); + let d = 0; + const y = []; + for (let p = 0; p < a.length; p++) { + const m = a[p].start2 + d, b = vu(a[p].diffs); + let C, I = -1; + if (b.length > Hn ? (C = qa(s, b.substring(0, Hn), m), C !== -1 && (I = qa(s, b.substring(b.length - Hn), m + b.length - Hn), (I === -1 || C >= I) && (C = -1))) : C = qa(s, b, m), C === -1) + y[p] = !1, d -= a[p].length2 - a[p].length1; + else { + y[p] = !0, d = C - m; + let O; + if (I === -1 ? O = s.substring(C, C + b.length) : O = s.substring(C, I + Hn), b === O) + s = s.substring(0, C) + md(a[p].diffs) + s.substring(C + b.length); + else { + let R = vd(b, O, { + checkLines: !1 + }); + if (b.length > Hn && WC(R) / b.length > f) + y[p] = !1; + else { + R = gd(R); + let x = 0, D = 0; + for (let U = 0; U < a[p].diffs.length; U++) { + const M = a[p].diffs[U]; + M[0] !== it && (D = Cl(R, x)), M[0] === Rt ? s = s.substring(0, C + D) + M[1] + s.substring(C + D) : M[0] === Et && (s = s.substring(0, C + D) + s.substring(C + Cl(R, x + M[1].length))), M[0] !== Et && (x += M[1].length); + } + } + } + } + } + return s = s.substring(l.length, s.length - l.length), [s, y]; +} +function jC(r) { + return r.map(zC).join(""); +} +function zC(r) { + const { + utf8Length1: e, + utf8Length2: n, + utf8Start1: s, + utf8Start2: a, + diffs: u + } = r; + let f; + e === 0 ? f = "".concat(s, ",0") : e === 1 ? f = "".concat(s + 1) : f = "".concat(s + 1, ",").concat(e); + let l; + n === 0 ? l = "".concat(a, ",0") : n === 1 ? l = "".concat(a + 1) : l = "".concat(a + 1, ",").concat(n); + const d = ["@@ -".concat(f, " +").concat(l, ` @@ +`)]; + let y; + for (let p = 0; p < u.length; p++) { + switch (u[p][0]) { + case Rt: + y = "+"; + break; + case Et: + y = "-"; + break; + case it: + y = " "; + break; + default: + throw new Error("Unknown patch operation."); + } + d[p + 1] = "".concat(y + encodeURI(u[p][1]), ` +`); + } + return d.join("").replace(/%20/g, " "); +} +const KC = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/; +function JC(r) { + if (!r) + return []; + const e = [], n = r.split(` +`); + let s = 0; + for (; s < n.length; ) { + const a = n[s].match(KC); + if (!a) + throw new Error("Invalid patch string: ".concat(n[s])); + const u = ho(Os(a[1]), Os(a[3])); + for (e.push(u), a[2] === "" ? (u.start1--, u.utf8Start1--, u.length1 = 1, u.utf8Length1 = 1) : a[2] === "0" ? (u.length1 = 0, u.utf8Length1 = 0) : (u.start1--, u.utf8Start1--, u.utf8Length1 = Os(a[2]), u.length1 = u.utf8Length1), a[4] === "" ? (u.start2--, u.utf8Start2--, u.length2 = 1, u.utf8Length2 = 1) : a[4] === "0" ? (u.length2 = 0, u.utf8Length2 = 0) : (u.start2--, u.utf8Start2--, u.utf8Length2 = Os(a[4]), u.length2 = u.utf8Length2), s++; s < n.length; ) { + const f = n[s], l = f.charAt(0); + if (l === "@") + break; + if (l === "") { + s++; + continue; + } + let d; + try { + d = decodeURI(f.slice(1)); + } catch { + throw new Error("Illegal escape in parse: ".concat(f)); + } + const y = Kn(d) - d.length; + if (l === "-") + u.diffs.push([Et, d]), u.length1 -= y; + else if (l === "+") + u.diffs.push([Rt, d]), u.length2 -= y; + else if (l === " ") + u.diffs.push([it, d]), u.length1 -= y, u.length2 -= y; + else + throw new Error('Invalid patch mode "'.concat(l, '" in: ').concat(d)); + s++; + } + } + return e; +} +function Os(r) { + return parseInt(r, 10); +} +function El(r, e) { + if (typeof e != "string") + return e; + const [n] = GC(r, e, { allowExceedingIndices: !0 }); + return n; +} +class XC { + constructor(e, n, s) { + W(this, "path"); + W(this, "dmpPatch"); + W(this, "id"); + this.id = e, this.path = n, this.dmpPatch = JC(s); + } + apply(e, n) { + let s = n; + if (s.containerType() === "primitive") + return s; + for (const a of e) { + if (a.isIndexReference()) { + for (const u of a.toIndicies(n)) { + const f = s.getIndex(u); + if (!f) + continue; + const l = f.get(), d = El(this.dmpPatch, l); + s = s.setIndex(u, d); + } + continue; + } + if (a.isAttributeReference() && s.hasAttribute(a.name())) { + const u = s.getAttribute(a.name()); + if (!u) + continue; + const f = u.get(), l = El(this.dmpPatch, f); + s = s.setAttribute(a.name(), l); + continue; + } + throw new Error(`Unable to apply diffMatchPatch to target ${a.toString()}`); + } + return s; + } +} +function Al(r, e) { + return typeof r != "number" || !Number.isFinite(r) ? r : r + e; +} +class xl { + constructor(e, n, s) { + W(this, "path"); + W(this, "value"); + W(this, "id"); + this.path = n, this.value = s, this.id = e; + } + apply(e, n) { + let s = n; + if (s.containerType() === "primitive") + return s; + for (const a of e) { + if (a.isIndexReference()) { + for (const u of a.toIndicies(n)) { + const f = s.getIndex(u); + if (!f) + continue; + const l = f.get(); + s = s.setIndex(u, Al(l, this.value)); + } + continue; + } + if (a.isAttributeReference()) { + const u = s.getAttribute(a.name()); + if (!u) + continue; + const f = u.get(); + s = s.setAttribute(a.name(), Al(f, this.value)); + continue; + } + throw new Error(`Unable to apply to target ${a.toString()}`); + } + return s; + } +} +function yo(r, e) { + const n = []; + return r.forEach((s) => { + s.isIndexReference() && n.push(...s.toIndicies(e)); + }), n.sort(); +} +class YC { + constructor(e, n, s, a) { + W(this, "location"); + W(this, "path"); + W(this, "items"); + W(this, "id"); + this.id = e, this.location = n, this.path = s, this.items = a; + } + apply(e, n) { + let s = n; + if (n.containerType() !== "array") + throw new Error("Attempt to apply insert patch to non-array value"); + switch (this.location) { + case "before": { + const a = VC(e, n); + s = s.insertItemsAt(a, this.items); + break; + } + case "after": { + const a = ZC(e, n); + s = s.insertItemsAt(a + 1, this.items); + break; + } + case "replace": { + const a = yo(e, n); + s = s.unsetIndices(a), s = s.insertItemsAt(a[0], this.items); + break; + } + default: + throw new Error(`Unsupported location atm: ${this.location}`); + } + return s; + } +} +function VC(r, e) { + let n = Xn.min(yo(r, e)) || 0; + return r.forEach((s) => { + if (s.isRange()) { + const { start: a } = s.expandRange(); + a < n && (n = a); + } + }), n; +} +function ZC(r, e) { + let n = Xn.max(yo(r, e)) || 0; + return r.forEach((s) => { + if (s.isRange()) { + const { end: a } = s.expandRange(); + a > n && (n = a); + } + }), n; +} +class wd { + constructor(e, n, s) { + W(this, "id"); + W(this, "path"); + W(this, "value"); + this.id = e, this.path = n, this.value = s; + } + apply(e, n) { + let s = n; + return e.forEach((a) => { + if (!a.isIndexReference()) + if (a.isAttributeReference()) + s.containerType() === "primitive" ? s = s.set({ [a.name()]: this.value }) : s.hasAttribute(a.name()) || (s = n.setAttribute(a.name(), this.value)); + else + throw new Error(`Unable to apply to target ${a.toString()}`); + }), s; + } +} +class bd { + constructor(e, n, s) { + W(this, "id"); + W(this, "path"); + W(this, "value"); + this.id = e, this.path = n, this.value = s; + } + apply(e, n) { + let s = n; + return e.forEach((a) => { + if (a.isSelfReference()) + s = s.set(this.value); + else if (a.isIndexReference()) + a.toIndicies(n).forEach((u) => { + s = s.setIndex(u, this.value); + }); + else if (a.isAttributeReference()) + s.containerType() === "primitive" ? s = s.set({ [a.name()]: this.value }) : s = s.setAttribute(a.name(), this.value); + else + throw new Error(`Unable to apply to target ${a.toString()}`); + }), s; + } +} +class QC { + constructor(e, n) { + W(this, "id"); + W(this, "path"); + W(this, "value"); + this.id = e, this.path = n; + } + // eslint-disable-next-line class-methods-use-this + apply(e, n) { + let s = n; + switch (n.containerType()) { + case "array": + s = s.unsetIndices(yo(e, n)); + break; + case "object": + e.forEach((a) => { + s = s.unsetAttribute(a.name()); + }); + break; + default: + throw new Error( + "Target value is neither indexable or an object. This error should potentially just be silently ignored?" + ); + } + return s; + } +} +function _d(r) { + const e = []; + if (Array.isArray(r)) + return r.reduce((y, p) => y.concat(_d(p)), e); + const { set: n, setIfMissing: s, unset: a, diffMatchPatch: u, inc: f, dec: l, insert: d } = r; + if (s && Object.keys(s).forEach((y) => { + e.push(new wd(r.id, y, s[y])); + }), n && Object.keys(n).forEach((y) => { + e.push(new bd(r.id, y, n[y])); + }), a && a.forEach((y) => { + e.push(new QC(r.id, y)); + }), u && Object.keys(u).forEach((y) => { + e.push(new XC(r.id, y, u[y])); + }), f && Object.keys(f).forEach((y) => { + e.push(new xl(r.id, y, f[y])); + }), l && Object.keys(l).forEach((y) => { + e.push(new xl(r.id, y, -l[y])); + }), d) { + let y, p; + const m = d; + if ("before" in m) + y = "before", p = m.before; + else if ("after" in m) + y = "after", p = m.after; + else if ("replace" in m) + y = "replace", p = m.replace; + else + throw new Error("Invalid insert patch"); + e.push(new YC(r.id, y, p, m.items)); + } + return e; +} +class tE { + constructor(e) { + W(this, "patches"); + this.patches = _d(e); + } + apply(e) { + const n = new sn(e); + return this.applyViaAccessor(n).get(); + } + // If you want to use your own accessor implementation, you can use this method + // to invoke the patcher. Since all subsequent accessors for children of this accessor + // are obtained through the methods in the accessors, you retain full control of the + // implementation throguhgout the application. Have a look in ImmutableAccessor + // to see an example of how accessors are implemented. + applyViaAccessor(e) { + let n = e; + const s = e.getAttribute("_id"); + if (!s) + throw new Error("Cannot apply patch to document with no _id"); + const a = s.get(); + for (const u of this.patches) { + if (u.id !== a) + continue; + const f = gr.fromPath(u.path).setPayload(u); + n = ru(f, n); + } + return n; + } +} +function ru(r, e) { + const n = r.payload instanceof bd || r.payload instanceof wd; + let s = e; + const { leads: a, delivery: u } = r.match(e); + return a.forEach((f) => { + if (f.target.isIndexReference()) + f.target.toIndicies().forEach((l) => { + const d = s.getIndex(l); + if (!d) + throw new Error("Index out of bounds"); + s = s.setIndexAccessor(l, ru(f.matcher, d)); + }); + else if (f.target.isAttributeReference()) { + n && s.containerType() === "primitive" && (s = s.set({})); + let l = s.getAttribute(f.target.name()); + if (!l && n && (s = s.setAttribute(f.target.name(), {}), l = s.getAttribute(f.target.name())), !l) + return; + const d = ru(f.matcher, l); + l !== d && (s = s.setAttributeAccessor(f.target.name(), d)); + } else + throw new Error(`Unable to handle target ${f.target.toString()}`); + }), u && eE(u.payload) && (s = u.payload.apply(u.targets, s)), s; +} +function eE(r) { + return !!(r && typeof r == "object" && r !== null && "apply" in r && typeof r.apply == "function"); +} +var Ts, nE = new Uint8Array(16); +function rE() { + if (!Ts && (Ts = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), !Ts)) + throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported"); + return Ts(nE); +} +const iE = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; +function sE(r) { + return typeof r == "string" && iE.test(r); +} +var Zt = []; +for (var Ha = 0; Ha < 256; ++Ha) + Zt.push((Ha + 256).toString(16).substr(1)); +function oE(r) { + var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, n = (Zt[r[e + 0]] + Zt[r[e + 1]] + Zt[r[e + 2]] + Zt[r[e + 3]] + "-" + Zt[r[e + 4]] + Zt[r[e + 5]] + "-" + Zt[r[e + 6]] + Zt[r[e + 7]] + "-" + Zt[r[e + 8]] + Zt[r[e + 9]] + "-" + Zt[r[e + 10]] + Zt[r[e + 11]] + Zt[r[e + 12]] + Zt[r[e + 13]] + Zt[r[e + 14]] + Zt[r[e + 15]]).toLowerCase(); + if (!sE(n)) + throw TypeError("Stringified UUID is invalid"); + return n; +} +function aE(r, e, n) { + r = r || {}; + var s = r.random || (r.rng || rE)(); + if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, e) { + n = n || 0; + for (var a = 0; a < 16; ++a) + e[n + a] = s[a]; + return e; + } + return oE(s); +} +const uE = aE; +class an { + constructor(e) { + W(this, "params"); + W(this, "compiled"); + W(this, "_appliesToMissingDocument"); + this.params = e; + } + get transactionId() { + return this.params.transactionId; + } + get transition() { + return this.params.transition; + } + get identity() { + return this.params.identity; + } + get previousRev() { + return this.params.previousRev; + } + get resultRev() { + return this.params.resultRev; + } + get mutations() { + return this.params.mutations; + } + get timestamp() { + if (typeof this.params.timestamp == "string") + return new Date(this.params.timestamp); + } + get effects() { + return this.params.effects; + } + assignRandomTransactionId() { + this.params.transactionId = uE(), this.params.resultRev = this.params.transactionId; + } + appliesToMissingDocument() { + if (typeof this._appliesToMissingDocument < "u") + return this._appliesToMissingDocument; + const e = this.mutations[0]; + return e ? this._appliesToMissingDocument = !!(e.create || e.createIfNotExists || e.createOrReplace) : this._appliesToMissingDocument = !0, this._appliesToMissingDocument; + } + // Compiles all mutations into a handy function + compile() { + const e = []; + this.mutations.forEach((a) => { + if (a.create) { + const u = a.create || {}; + e.push((f) => f || Object.assign(u, { + _createdAt: u._createdAt || this.params.timestamp + })); + return; + } + if (a.createIfNotExists) { + const u = a.createIfNotExists || {}; + e.push( + (f) => f === null ? Object.assign(u, { + _createdAt: u._createdAt || this.params.timestamp + }) : f + ); + return; + } + if (a.createOrReplace) { + const u = a.createOrReplace || {}; + e.push( + () => Object.assign(u, { + _createdAt: u._createdAt || this.params.timestamp + }) + ); + return; + } + if (a.delete) { + e.push(() => null); + return; + } + if (a.patch) { + if ("query" in a.patch) + return; + const u = new tE(a.patch); + e.push((f) => u.apply(f)); + return; + } + throw new Error(`Unsupported mutation ${JSON.stringify(a, null, 2)}`); + }), typeof this.params.timestamp == "string" && e.push((a) => a ? Object.assign(a, { _updatedAt: this.params.timestamp }) : null); + const n = this.previousRev, s = this.resultRev || this.transactionId; + this.compiled = (a) => { + if (n && a && n !== a._rev) + throw new Error( + `Previous revision for this mutation was ${n}, but the document revision is ${a._rev}` + ); + let u = a; + for (const f of e) + u = f(u); + return u && s && (u === a && (u = Object.assign({}, a)), u._rev = s), u; + }; + } + apply(e) { + ct("Applying mutation %O to document %O", this.mutations, e), this.compiled || this.compile(); + const n = this.compiled(e); + return ct(" => %O", n), n; + } + static applyAll(e, n) { + return n.reduce((s, a) => a.apply(s), e); + } + // Given a number of yet-to-be-committed mutation objects, collects them into one big mutation + // any metadata like transactionId is ignored and must be submitted by the client. It is assumed + // that all mutations are on the same document. + // TOOO: Optimize mutations, eliminating mutations that overwrite themselves! + static squash(e, n) { + const s = n.reduce( + (a, u) => a.concat(...u.mutations), + [] + ); + return new an({ mutations: s }); + } +} +class cE { + constructor(e) { + /** + * Incoming patches from the server waiting to be applied to HEAD + */ + W(this, "incoming", []); + /** + * Patches we know has been subitted to the server, but has not been seen yet in the return channel + * so we can't be sure about the ordering yet (someone else might have slipped something between them) + */ + W(this, "submitted", []); + /** + * Pending mutations + */ + W(this, "pending", []); + /** + * Our model of the document according to the incoming patches from the server + */ + W(this, "HEAD"); + /** + * Our optimistic model of what the document will probably look like as soon as all our patches + * have been processed. Updated every time we stage a new mutation, but also might revert back + * to previous states if our mutations fail, or could change if unexpected mutations arrive + * between our own. The `onRebase` callback will be called when EDGE changes in this manner. + */ + W(this, "EDGE"); + /** + * Called with the EDGE document when that document changes for a reason other than us staging + * a new patch or receiving a mutation from the server while our EDGE is in sync with HEAD: + * I.e. when EDGE changes because the order of mutations has changed in relation to our + * optimistic predictions. + */ + W(this, "onRebase"); + /** + * Called when we receive a patch in the normal order of things, but the mutation is not ours + */ + W(this, "onMutation"); + /** + * Called when consistency state changes with the boolean value of the current consistency state + */ + W(this, "onConsistencyChanged"); + /** + * Called whenever a new incoming mutation comes in. These are always ordered correctly. + */ + W(this, "onRemoteMutation"); + /** + * We are consistent when there are no unresolved mutations of our own, and no un-applicable + * incoming mutations. When this has been going on for too long, and there has been a while + * since we staged a new mutation, it is time to reset your state. + */ + W(this, "inconsistentAt", null); + /** + * The last time we staged a patch of our own. If we have been inconsistent for a while, but it + * hasn't been long since we staged a new mutation, the reason is probably just because the user + * is typing or something. + * + * Should be used as a guard against resetting state for inconsistency reasons. + */ + W(this, "lastStagedAt", null); + this.reset(e), this.HEAD = e, this.EDGE = e; + } + // Reset the state of the Document, used to recover from unsavory states by reloading the document + reset(e) { + this.incoming = [], this.submitted = [], this.pending = [], this.inconsistentAt = null, this.HEAD = e, this.EDGE = e, this.considerIncoming(), this.updateConsistencyFlag(); + } + // Call when a mutation arrives from Sanity + arrive(e) { + this.incoming.push(e), this.considerIncoming(), this.updateConsistencyFlag(); + } + // Call to signal that we are submitting a mutation. Returns a callback object with a + // success and failure handler that must be called according to the outcome of our + // submission. + stage(e, n) { + if (!e.transactionId) + throw new Error("Mutations _must_ have transactionId when submitted"); + this.lastStagedAt = /* @__PURE__ */ new Date(), ct("Staging mutation %s (pushed to pending)", e.transactionId), this.pending.push(e), this.EDGE = e.apply(this.EDGE), this.onMutation && !n && this.onMutation({ + mutation: e, + document: this.EDGE, + remote: !1 + }); + const s = e.transactionId; + return this.updateConsistencyFlag(), { + success: () => { + this.pendingSuccessfullySubmitted(s), this.updateConsistencyFlag(); + }, + failure: () => { + this.pendingFailed(s), this.updateConsistencyFlag(); + } + }; + } + // Call to check if everything is nice and quiet and there are no unresolved mutations. + // Means this model thinks both HEAD and EDGE is up to date with what the server sees. + isConsistent() { + return !this.inconsistentAt; + } + // Private + // Attempts to apply any resolvable incoming patches to HEAD. Will keep patching as long as there + // are applicable patches to be applied + considerIncoming() { + let e = !1, n; + const s = []; + if (this.HEAD && this.HEAD._updatedAt) { + const u = new Date(this.HEAD._updatedAt); + this.incoming.find((f) => f.timestamp && f.timestamp < u) && (this.incoming = this.incoming.filter((f) => f.timestamp && f.timestamp < u)); + } + let a = 0; + do { + if (this.HEAD) { + const u = this.HEAD; + n = u._rev ? this.incoming.find((f) => f.previousRev === u._rev) : void 0; + } else + n = this.incoming.find((u) => u.appliesToMissingDocument()); + if (n) { + const u = this.applyIncoming(n); + if (e = e || u, e && s.push(n), a++ > 10) + throw new Error( + `Mutator stuck flushing incoming mutations. Probably stuck here: ${JSON.stringify( + n + )}` + ); + } + } while (n); + this.incoming.length > 0 && ct.enabled && ct( + "Unable to apply mutations %s", + this.incoming.map((u) => u.transactionId).join(", ") + ), e && this.rebase(s); + } + // check current consistency state, update flag and invoke callback if needed + updateConsistencyFlag() { + const e = this.isConsistent(), n = this.pending.length === 0 && this.submitted.length === 0 && this.incoming.length === 0; + n ? this.inconsistentAt = null : this.inconsistentAt || (this.inconsistentAt = /* @__PURE__ */ new Date()), e != n && this.onConsistencyChanged && (ct(n ? "Buffered document is inconsistent" : "Buffered document is consistent"), this.onConsistencyChanged(n)); + } + // apply an incoming patch that has been prequalified as the next in line for this document + applyIncoming(e) { + if (!e) + return !1; + if (!e.transactionId) + throw new Error("Received incoming mutation without a transaction ID"); + if (ct( + "Applying mutation %s -> %s to rev %s", + e.previousRev, + e.resultRev, + this.HEAD && this.HEAD._rev + ), this.HEAD = e.apply(this.HEAD), this.onRemoteMutation && this.onRemoteMutation(e), this.incoming = this.incoming.filter((n) => n.transactionId !== e.transactionId), this.hasUnresolvedMutations()) { + const n = this.consumeUnresolved(e.transactionId); + return ct.enabled && (ct( + `Incoming mutation ${e.transactionId} appeared while there were pending or submitted local mutations` + ), ct(`Submitted txnIds: ${this.submitted.map((s) => s.transactionId).join(", ")}`), ct(`Pending txnIds: ${this.pending.map((s) => s.transactionId).join(", ")}`), ct("needRebase === %s", n)), n; + } + return ct( + "Remote mutation %s arrived w/o any pending or submitted local mutations", + e.transactionId + ), this.EDGE = this.HEAD, this.onMutation && this.onMutation({ + mutation: e, + document: this.EDGE, + remote: !0 + }), !1; + } + /** + * Returns true if there are unresolved mutations between HEAD and EDGE, meaning we have + * mutations that are still waiting to be either submitted, or to be confirmed by the server. + * + * @returns true if there are unresolved mutations between HEAD and EDGE, false otherwise + */ + hasUnresolvedMutations() { + return this.submitted.length > 0 || this.pending.length > 0; + } + /** + * When an incoming mutation is applied to HEAD, this is called to remove the mutation from + * the unresolved state. If the newly applied patch is the next upcoming unresolved mutation, + * no rebase is needed, but we might have the wrong idea about the ordering of mutations, so in + * that case we are given the flag `needRebase` to tell us that this mutation arrived out of + * order in terms of our optimistic version, so a rebase is needed. + * + * @param txnId - Transaction ID of the remote mutation + * @returns true if rebase is needed, false otherwise + */ + consumeUnresolved(e) { + if (this.submitted.length === 0 && this.pending.length === 0) + return !1; + if (this.submitted.length !== 0) { + if (this.submitted[0].transactionId === e) + return ct( + "Remote mutation %s matches upcoming submitted mutation, consumed from 'submitted' buffer", + e + ), this.submitted.shift(), !1; + } else if (this.pending.length > 0 && this.pending[0].transactionId === e) + return ct( + "Remote mutation %s matches upcoming pending mutation, consumed from 'pending' buffer", + e + ), this.pending.shift(), !1; + return ct( + "The mutation was not the upcoming mutation, scrubbing. Pending: %d, Submitted: %d", + this.pending.length, + this.submitted.length + ), this.submitted = this.submitted.filter((n) => n.transactionId !== e), this.pending = this.pending.filter((n) => n.transactionId !== e), ct("After scrubbing: Pending: %d, Submitted: %d", this.pending.length, this.submitted.length), !0; + } + pendingSuccessfullySubmitted(e) { + if (this.pending.length === 0) + return; + const n = this.pending[0]; + if (n.transactionId === e) { + this.pending.shift(), this.submitted.push(n); + return; + } + let s; + const a = []; + this.pending.forEach((u) => { + if (u.transactionId === e) { + s = u; + return; + } + a.push(u); + }), s && this.submitted.push(s), this.pending = a, this.rebase([]); + } + pendingFailed(e) { + this.pending = this.pending.filter((n) => n.transactionId !== e), this.rebase([]); + } + rebase(e) { + const n = this.EDGE; + this.EDGE = an.applyAll(this.HEAD, this.submitted.concat(this.pending)), n !== null && this.EDGE !== null && (n._rev = this.EDGE._rev), !Xn.isEqual(this.EDGE, n) && this.onRebase && this.onRebase(this.EDGE, e, this.pending); + } +} +class Ls { + constructor(e) { + /** + * The document forming the basis of this squash + */ + W(this, "BASIS"); + /** + * The document after the out-Mutation has been applied, but before the staged + * operations are committed. + */ + W(this, "PRESTAGE"); + /** + * setOperations contain the latest set operation by path. If the set-operations are + * updating strings to new strings, they are rewritten as diffMatchPatch operations, + * any new set operations on the same paths overwrites any older set operations. + * Only set-operations assigning plain values to plain values gets optimized like this. + */ + W(this, "setOperations"); + /** + * `documentPresent` is true whenever we know that the document must be present due + * to preceeding mutations. `false` implies that it may or may not already exist. + */ + W(this, "documentPresent"); + /** + * The operations in the out-Mutation are not able to be optimized any further + */ + W(this, "out", []); + /** + * Staged mutation operations + */ + W(this, "staged"); + e ? ct("Reset mutation buffer to rev %s", e._rev) : ct("Reset mutation buffer state to document being deleted"), this.staged = [], this.setOperations = {}, this.documentPresent = !1, this.BASIS = e, this.PRESTAGE = e; + } + add(e) { + e.mutations.forEach((n) => this.addOperation(n)); + } + hasChanges() { + return this.out.length > 0 || Object.keys(this.setOperations).length > 0; + } + /** + * Extracts the mutations in this buffer. + * After this is done, the buffer lifecycle is over and the client should + * create an new one with the new, updated BASIS. + * + * @param txnId - Transaction ID + * @returns A `Mutation` instance if we had outgoing mutations pending, null otherwise + */ + purge(e) { + this.stashStagedOperations(); + let n = null; + return this.out.length > 0 && (ct("Purged mutation buffer"), n = new an({ + mutations: this.out, + resultRev: e, + transactionId: e + })), this.out = [], this.documentPresent = !1, n; + } + addOperation(e) { + var n; + if (e.patch && e.patch.set && "id" in e.patch && e.patch.id === ((n = this.PRESTAGE) == null ? void 0 : n._id) && Object.keys(e.patch).length === 2) { + const s = e.patch.set, a = {}; + for (const u of Object.keys(s)) + s.hasOwnProperty(u) && (this.optimiseSetOperation(u, s[u]) || (a[u] = s[u])); + Object.keys(a).length > 0 && (ct("Unoptimizable set-operation detected, purging optimization buffer"), this.staged.push({ patch: { id: this.PRESTAGE._id, set: a } }), this.stashStagedOperations()); + return; + } + if (e.createIfNotExists && this.PRESTAGE && e.createIfNotExists._id === this.PRESTAGE._id) { + this.documentPresent || (this.staged.push(e), this.documentPresent = !0, this.stashStagedOperations()); + return; + } + ct("Unoptimizable mutation detected, purging optimization buffer"), this.staged.push(e), this.stashStagedOperations(); + } + /** + * Attempt to perform one single set operation in an optimised manner, return value + * reflects whether or not the operation could be performed. + + * @param path - The JSONPath to the set operation in question + * @param nextValue - The value to be set + * @returns True of optimized, false otherwise + */ + optimiseSetOperation(e, n) { + if (typeof n == "object") + return !1; + const s = mC(e, this.PRESTAGE); + if (s.length !== 1) + return !1; + const a = s[0]; + if (typeof a.value == "object" || !this.PRESTAGE) + return !1; + let u = null; + if (a.value === n) + u = null; + else if (typeof a.value == "string" && typeof n == "string") + try { + const l = jC(qC(a.value, n)); + u = { patch: { id: this.PRESTAGE._id, diffMatchPatch: { [e]: l } } }; + } catch { + return !1; + } + else + u = { patch: { id: this.PRESTAGE._id, set: { [e]: n } } }; + const f = iC(a.path); + return u ? this.setOperations[f] = u : delete this.setOperations[f], !0; + } + stashStagedOperations() { + const e = []; + Object.keys(this.setOperations).forEach((n) => { + const s = this.setOperations[n]; + s && e.push(s); + }), e.push(...this.staged), e.length > 0 && (this.PRESTAGE = new an({ mutations: e }).apply(this.PRESTAGE), this.staged = [], this.setOperations = {}), this.out.push(...e); + } + /** + * Rebases given the new base-document + * + * @param newBasis - New base document to rebase on + * @returns New "edge" document with buffered changes integrated + */ + rebase(e) { + return this.stashStagedOperations(), e === null ? (this.out = [], this.BASIS = e, this.PRESTAGE = e, this.documentPresent = !1) : (this.BASIS = e, this.out ? this.PRESTAGE = new an({ mutations: this.out }).apply(this.BASIS) : this.PRESTAGE = this.BASIS), this.PRESTAGE; + } +} +const fE = 1e3 * 60; +class lE { + constructor(e, { resolve: n, reject: s }) { + W(this, "mutations"); + W(this, "tries"); + W(this, "resolve"); + W(this, "reject"); + this.mutations = e, this.tries = 0, this.resolve = n, this.reject = s; + } + apply(e) { + return an.applyAll(e, this.mutations); + } + squash(e) { + const n = an.squash(e, this.mutations); + return n.assignRandomTransactionId(), n; + } +} +const Sl = (r, e) => r.concat(e.mutations); +class hE { + constructor(e) { + W(this, "mutations"); + /** + * The Document we are wrapping + */ + W(this, "document"); + /** + * The Document with local changes applied + */ + W(this, "LOCAL"); + /** + * Commits that are waiting to be delivered to the server + */ + W(this, "commits"); + /** + * Local mutations that are not scheduled to be committed yet + */ + W(this, "buffer"); + /** + * Assignable event handler for when the buffered document applies a mutation + */ + W(this, "onMutation"); + /** + * Assignable event handler for when a remote mutation happened + */ + W(this, "onRemoteMutation"); + /** + * Assignable event handler for when the buffered document rebased + */ + W(this, "onRebase"); + /** + * Assignable event handler for when the document is deleted + */ + W(this, "onDelete"); + /** + * Assignable event handler for when the state of consistency changed + */ + W(this, "onConsistencyChanged"); + /** + * Assignable event handler for when the buffered document should commit changes + */ + W(this, "commitHandler"); + /** + * Whether or not we are currently commiting + */ + W(this, "committerRunning", !1); + this.buffer = new Ls(e), this.document = new cE(e), this.document.onMutation = (n) => this.handleDocMutation(n), this.document.onRemoteMutation = (n) => this.onRemoteMutation && this.onRemoteMutation(n), this.document.onRebase = (n, s, a) => this.handleDocRebase(n, s, a), this.document.onConsistencyChanged = (n) => this.handleDocConsistencyChanged(n), this.LOCAL = e, this.mutations = [], this.commits = []; + } + // Used to reset the state of the local document model. If the model has been inconsistent + // for too long, it has probably missed a notification, and should reload the document from the server + reset(e) { + e ? ct("Document state reset to revision %s", e._rev) : ct("Document state reset to being deleted"), this.document.reset(e), this.rebase([], []), this.handleDocConsistencyChanged(this.document.isConsistent()); + } + // Add a change to the buffer + add(e) { + this.onConsistencyChanged && this.onConsistencyChanged(!1), ct("Staged local mutation"), this.buffer.add(e); + const n = this.LOCAL; + this.LOCAL = e.apply(this.LOCAL), this.onMutation && n !== this.LOCAL && (ct("onMutation fired"), this.onMutation({ + mutation: e, + document: this.LOCAL, + remote: !1 + }), this.LOCAL === null && this.onDelete && this.onDelete(this.LOCAL)); + } + // Call when a mutation arrives from Sanity + arrive(e) { + if (ct("Remote mutation arrived %s -> %s", e.previousRev, e.resultRev), e.previousRev === e.resultRev) + throw new Error( + `Mutation ${e.transactionId} has previousRev === resultRev (${e.previousRev})` + ); + return this.document.arrive(e); + } + // Submit all mutations in the buffer to be committed + commit() { + return new Promise((e, n) => { + if (!this.buffer.hasChanges()) { + e(); + return; + } + ct("Committing local changes"); + const s = this.buffer.purge(); + this.commits.push(new lE(s ? [s] : [], { resolve: e, reject: n })), this.buffer = new Ls(this.LOCAL), this.performCommits(); + }); + } + // Starts the committer that will try to committ all staged commits to the database + // by calling the commitHandler. Will keep running until all commits are successfully + // committed. + performCommits() { + if (!this.commitHandler) + throw new Error("No commitHandler configured for this BufferedDocument"); + this.committerRunning || this._cycleCommitter(); + } + // TODO: Error handling, right now retries after every error + _cycleCommitter() { + const e = this.commits.shift(); + if (!e) { + this.committerRunning = !1; + return; + } + this.committerRunning = !0; + const n = e.squash(this.LOCAL), s = this.document.stage(n, !0), a = { + success: () => { + ct("Commit succeeded"), s.success(), e.resolve(), this._cycleCommitter(); + }, + failure: () => { + ct("Commit failed"), e.tries += 1, this.LOCAL !== null && this.commits.unshift(e), s.failure(), e.tries < 200 && setTimeout(() => this._cycleCommitter(), Math.min(e.tries * 1e3, fE)); + }, + cancel: (u) => { + this.commits.forEach((f) => f.reject(u)), this.commits = [], this.reset(this.document.HEAD), this.buffer = new Ls(this.LOCAL), this.committerRunning = !1; + } + }; + ct("Posting commit"), this.commitHandler && this.commitHandler({ + mutation: n, + success: a.success, + failure: a.failure, + cancel: a.cancel + }); + } + handleDocRebase(e, n, s) { + this.rebase(n, s); + } + handleDocumentDeleted() { + ct("Document deleted"), this.LOCAL !== null && this.onDelete && this.onDelete(this.LOCAL), this.commits = [], this.mutations = []; + } + handleDocMutation(e) { + if (this.commits.length === 0 && !this.buffer.hasChanges()) { + ct("Document mutated from remote with no local changes"), this.LOCAL = this.document.EDGE, this.buffer = new Ls(this.LOCAL), this.onMutation && this.onMutation(e); + return; + } + ct("Document mutated from remote with local changes"), this.document.EDGE === null && this.handleDocumentDeleted(), this.rebase([e.mutation], []); + } + rebase(e, n) { + ct("Rebasing document"), this.document.EDGE === null && this.handleDocumentDeleted(); + const s = this.LOCAL; + this.LOCAL = this.commits.reduce((u, f) => f.apply(u), this.document.EDGE), this.LOCAL = this.buffer.rebase(this.LOCAL), s !== null && this.LOCAL !== null && (s._rev = this.LOCAL._rev), !Xn.isEqual(this.LOCAL, s) && this.onRebase && this.onRebase( + this.LOCAL, + e.reduce(Sl, []), + n.reduce(Sl, []) + ); + } + handleDocConsistencyChanged(e) { + if (!this.onConsistencyChanged) + return; + const n = this.commits.length > 0 || this.buffer.hasChanges(); + e && !n && this.onConsistencyChanged(!0), e || this.onConsistencyChanged(!1); + } +} +const Rl = (r) => { + const e = r.LOCAL, n = r.document.HEAD; + return e && { + ...e, + _type: (n || e)._type, + _rev: (n || e)._rev, + _updatedAt: (/* @__PURE__ */ new Date()).toISOString() + }; +}, Il = (r) => ({ type: "snapshot", document: r }), Ol = (r) => r.document, dE = (r) => { + const e = new Je(), n = new G1(!0), s = new Je(), a = new Je(), u = new Je(), f = new Je(), l = (x) => { + const D = new hE(x); + return D.onMutation = ({ mutation: U, remote: M }) => { + s.next({ + type: "mutation", + document: Rl(D), + mutations: U.mutations, + origin: M ? "remote" : "local" + }); + }, D.onRemoteMutation = (U) => { + u.next({ + type: "remoteMutation", + head: D.document.HEAD, + transactionId: U.transactionId, + timestamp: U.timestamp, + author: U.identity, + effects: U.effects + }); + }, D.onRebase = (U, M, z) => { + a.next({ + type: "rebase", + document: U, + remoteMutations: M, + localMutations: z + }); + }, D.onConsistencyChanged = (U) => { + n.next(U); + }, D.commitHandler = (U) => f.next(U), D; + }, d = r.pipe( + yh((x, D) => D.type === "snapshot" ? (x && x.commit(), l(D.document || null)) : x === null ? (console.warn( + 'Ignoring event of type "%s" since buffered document has not yet been set up with snapshot', + D.type + ), null) : x, null), + Xe( + (x) => x !== null + ), + nl(), + Ss(1), + mi() + ), y = r.pipe( + Xe((x) => x.type === "mutation"), + rl(d), + Lt(([x, D]) => (D.arrive(new an(x)), Rl(D))) + ), p = e.pipe( + rl(d), + Za(([x, D]) => { + x.type === "mutation" && D.add(new an({ mutations: x.mutations })), x.type === "commit" && D.commit(); + }), + // We subscribe to this only for the side effects + Eb(po), + Va() + ), m = (x) => e.next(x), b = (x) => m({ type: "mutation", mutations: x }), C = (x) => b([x]), I = () => { + d.pipe( + mh(1), + Za((x) => x.commit()) + ).subscribe(); + }, O = Hr( + d.pipe(Lt((x) => x.LOCAL)), + s.pipe(Lt(Ol)), + a.pipe(Lt(Ol)), + y + ).pipe(Lt(Il), Ss(1), mi()), R = Hr( + d.pipe( + Lt((x) => x.document.HEAD), + Lt(Il) + ), + u + ).pipe(Ss(1), mi()); + return { + updates$: Hr(O, p, s, a), + consistency$: n.pipe(nl(), Ss(1), mi()), + remoteSnapshot$: R, + commitRequest$: f, + addMutation: C, + addMutations: b, + commit: I + }; +}, pE = (r) => (e) => { + const { _id: n, _rev: s, _updatedAt: a, ...u } = e; + return { _id: r, ...u }; +}, Tl = (r, e) => { + const n = dE(e), s = pE(r), a = { delete: { id: r } }; + return { + events: n.updates$, + consistency$: n.consistency$, + remoteSnapshot$: n.remoteSnapshot$, + commitRequest$: n.commitRequest$, + // @TODO make these easier to access? Worker related + patch: (u) => u.map((f) => ({ patch: { ...f, id: r } })), + create: (u) => ({ create: s(u) }), + createIfNotExists: (u) => ({ createIfNotExists: s(u) }), + createOrReplace: (u) => ({ createOrReplace: s(u) }), + delete: () => a, + mutate: (u) => n.addMutations(u), + commit: () => n.commit() + }; +}, gE = { type: "pending", phase: "begin" }, vE = { type: "pending", phase: "end" }; +function mE(r) { + return r.type === "mutation"; +} +function yE(r) { + return r.transactionTotalEvents > 1; +} +function wE(r) { + const e = Xn.groupBy( + r.filter((n) => n.type === "mutation"), + (n) => n.transactionId + ); + return Object.values(e).every( + (n) => n.length === n[0].transactionTotalEvents + ); +} +function bE(r, e, n = {}) { + const { publishedId: s, draftId: a } = e; + return pb( + () => r.observable.listen( + "*[_id == $publishedId || _id == $draftId]", + { + publishedId: s, + draftId: a + }, + { + includeResult: !1, + events: ["welcome", "mutation", "reconnect"], + effectFormat: "mendoza", + tag: n.tag || "document.pair-listener" + } + ) + ).pipe( + el( + (f) => f.type === "welcome" ? u().pipe( + el((l) => [ + Ll(a, l.draft), + Ll(s, l.published) + ]) + ) : gh(f) + ), + yh( + (f, l) => { + if (!mE(l)) + return { next: [l], buffer: [] }; + const d = f.buffer.length > 0, y = yE(l); + if (!y && !d) + return { next: [l], buffer: [] }; + if (!y) + return { next: [], buffer: f.buffer.concat(l) }; + const p = f.buffer.concat(l); + return wE(p) ? { next: p.concat(vE), buffer: [] } : { next: p.length === 1 ? [gE] : [], buffer: p }; + }, + { next: [], buffer: [] } + ), + // note: this flattens the array, and in the case of an empty array, no event will be pushed downstream + on((f) => f.next) + ); + function u() { + return r.observable.getDocuments([a, s], { tag: "document.snapshots" }).pipe( + Lt(([f, l]) => ({ + draft: f, + published: l + })) + ); + } +} +function Ll(r, e) { + return { + type: "snapshot", + documentId: r, + document: e + }; +} +const $l = (r) => (e) => e.type !== "reconnect" && e.type !== "pending" && e.documentId === r; +function $s(r) { + return (e) => ({ ...e, version: r }); +} +function _E(r) { + if (!r._id) + throw new Error("Expected document to have an _id"); +} +function CE(r, e) { + const { resultRev: n, ...s } = r; + return s.mutations.flatMap((u) => { + const f = Object.values(u); + if (f.length > 1) + throw new Error("Did not expect multiple mutations in the same payload"); + return f[0].id || f[0]._id; + }).every((u) => u === e); +} +function EE(r, e) { + return e.mutations.flatMap((n) => { + if (n.createIfNotExists) + return []; + if (n.create) + return _E(n.create), { + actionType: "sanity.action.document.create", + publishedId: r.publishedId, + attributes: n.create, + ifExists: "fail" + }; + if (n.patch) + return { + actionType: "sanity.action.document.edit", + draftId: r.draftId, + publishedId: r.publishedId, + patch: Xn.omit(n.patch, "id") + }; + throw new Error("Cannot map mutation to action"); + }); +} +function AE(r, e, n) { + return CE(n, e.publishedId) ? Cd(r, n) : r.observable.action(EE(e, n), { + tag: "document.commit", + transactionId: n.transactionId + }); +} +function Cd(r, e) { + const { resultRev: n, ...s } = e; + return r.dataRequest("mutate", s, { + visibility: "async", + returnDocuments: !1, + tag: "document.commit", + // This makes sure the studio doesn't crash when a draft is crated + // because someone deleted a referenced document in the target dataset + skipCrossDatasetReferenceValidation: !0 + }); +} +function xE(r, e, n, s) { + return Ii( + s ? AE(r, e, n.mutation.params) : Cd(r, n.mutation.params) + ).pipe( + Za({ + error: (a) => { + "statusCode" in a && typeof a.statusCode == "number" && a.statusCode >= 400 && a.statusCode <= 500 ? n.cancel(a) : n.failure(a); + }, + next: () => n.success() + }) + ); +} +function SE(r, e, n) { + const { publishedId: s, draftId: a } = e, u = new Je(), f = bE(r, e).pipe( + Va({ connector: () => u }) + ), l = f.pipe( + Xe((b) => b.type === "reconnect") + ), d = Tl( + a, + f.pipe(Xe($l(a))) + ), y = Tl( + s, + f.pipe(Xe($l(s))) + ), p = f.pipe( + Xe((b) => b.type === "pending") + ), m = Hr(d.commitRequest$, y.commitRequest$).pipe( + on( + (b) => n.pipe( + mh(1), + on( + (C) => xE(r, e, b, C) + ) + ) + ), + on(() => po), + Va() + ); + return { + transactionsPendingEvents$: p, + draft: { + ...d, + events: Hr(m, l, d.events).pipe(Lt($s("draft"))), + consistency$: d.consistency$, + remoteSnapshot$: d.remoteSnapshot$.pipe(Lt($s("draft"))) + }, + published: { + ...y, + events: Hr(m, l, y.events).pipe(Lt($s("published"))), + consistency$: y.consistency$, + remoteSnapshot$: y.remoteSnapshot$.pipe(Lt($s("published"))) + }, + complete: () => u.complete() + }; +} +let jt = null; +self.addEventListener("message", (r) => { + if (RE(r.data)) + if (r.data.type === "construct") { + jt && (jt.complete(), jt = null); + const { clientConfig: e, idPair: n, serverActionsEnabled: s } = r.data, a = V_(e); + jt = SE(a, n, gh(s)); + const { complete: u } = jt, f = []; + f.push( + jt.transactionsPendingEvents$.subscribe((l) => { + ur({ type: "transactionsPendingEvents$", payload: l }); + }), + jt.draft.consistency$.subscribe((l) => { + ur({ type: "draft.consistency$", payload: l }); + }), + jt.draft.events.subscribe((l) => { + ur({ type: "draft.events", payload: l }); + }), + jt.draft.remoteSnapshot$.subscribe((l) => { + ur({ type: "draft.remoteSnapshot$", payload: l }); + }), + jt.published.consistency$.subscribe((l) => { + ur({ type: "published.consistency$", payload: l }); + }), + jt.published.events.subscribe((l) => { + ur({ type: "published.events", payload: l }); + }), + jt.published.remoteSnapshot$.subscribe((l) => { + ur({ type: "published.remoteSnapshot$", payload: l }); + }) + ), jt.complete = () => { + for (const l of f) + l.unsubscribe(); + f.length = 0, u(); + }; + } else if (jt) + switch (r.data.type) { + case "draft.commit": + jt.draft.commit(); + break; + case "draft.mutate": + jt.draft.mutate(r.data.payload); + break; + case "published.commit": + jt.published.commit(); + break; + case "published.mutate": + jt.published.mutate(r.data.payload); + break; + default: + throw new TypeError(`Unknown event type: ${r.data.type}`, { cause: r }); + } + else + throw new Error("Received message before instance was constructed", { cause: r }); +}); +function ur(r) { + self.postMessage(r); +} +function RE(r) { + return typeof r == "object" && r && "type" in r && typeof r.type == "string"; +} +const Ed = /_key\s*==\s*['"](.*)['"]/; +function IE(r) { + return typeof r == "string" ? Ed.test(r.trim()) : typeof r == "object" && "_key" in r; +} +function Ad(r) { + if (!Array.isArray(r)) + throw new Error("Path is not an array"); + return r.reduce((e, n, s) => { + const a = typeof n; + if (a === "number") + return `${e}[${n}]`; + if (a === "string") + return `${e}${s === 0 ? "" : "."}${n}`; + if (IE(n) && n._key) + return `${e}[_key=="${n._key}"]`; + if (Array.isArray(n)) { + const [u, f] = n; + return `${e}[${u}:${f}]`; + } + throw new Error(`Unsupported path segment \`${JSON.stringify(n)}\``); + }, ""); +} +const Pl = { + "\f": "\\f", + "\n": "\\n", + "\r": "\\r", + " ": "\\t", + "'": "\\'", + "\\": "\\\\" +}, Fl = { + "\\f": "\f", + "\\n": ` +`, + "\\r": "\r", + "\\t": " ", + "\\'": "'", + "\\\\": "\\" +}; +function OE(r) { + return `$${r.map((e) => typeof e == "string" ? `['${e.replace(/[\f\n\r\t'\\]/g, (n) => Pl[n])}']` : typeof e == "number" ? `[${e}]` : e._key !== "" ? `[?(@._key=='${e._key.replace(/['\\]/g, (n) => Pl[n])}')]` : `[${e._index}]`).join("")}`; +} +function Ml(r) { + const e = [], n = /\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g; + let s; + for (; (s = n.exec(r)) !== null; ) { + if (s[1] !== void 0) { + const a = s[1].replace(/\\(\\|f|n|r|t|')/g, (u) => Fl[u]); + e.push(a); + continue; + } + if (s[2] !== void 0) { + e.push(parseInt(s[2], 10)); + continue; + } + if (s[3] !== void 0) { + const a = s[3].replace(/\\(\\')/g, (u) => Fl[u]); + e.push({ + _key: a, + _index: -1 + }); + continue; + } + } + return e; +} +function xd(r) { + return r.map((e) => { + if (typeof e == "string" || typeof e == "number") + return e; + if (e._key !== "") + return { _key: e._key }; + if (e._index !== -1) + return e._index; + throw new Error(`invalid segment:${JSON.stringify(e)}`); + }); +} +function TE(r) { + return r.map((e) => { + if (typeof e == "string" || typeof e == "number") + return e; + if (e._index !== -1) + return e._index; + throw new Error(`invalid segment:${JSON.stringify(e)}`); + }); +} +function LE(r, e) { + if (!(e != null && e.mappings)) + return; + const n = OE(TE(r)); + if (e.mappings[n] !== void 0) + return { + mapping: e.mappings[n], + matchedPath: n, + pathSuffix: "" + }; + const s = Object.entries(e.mappings).filter(([l]) => n.startsWith(l)).sort(([l], [d]) => d.length - l.length); + if (s.length == 0) + return; + const [a, u] = s[0], f = n.substring(a.length); + return { mapping: u, matchedPath: a, pathSuffix: f }; +} +function $E(r) { + return r !== null && Array.isArray(r); +} +function Dl(r) { + return typeof r == "object" && r !== null; +} +function Xs(r, e, n = []) { + return $E(r) ? r.map((s, a) => { + if (Dl(s)) { + const u = s._key; + if (typeof u == "string") + return Xs(s, e, n.concat({ _key: u, _index: a })); + } + return Xs(s, e, n.concat(a)); + }) : Dl(r) ? Object.fromEntries( + Object.entries(r).map(([s, a]) => [s, Xs(a, e, n.concat(s))]) + ) : e(r, n); +} +function Sd(r, e, n) { + return Xs(r, (s, a) => { + if (typeof s != "string") + return s; + const u = LE(a, e); + if (!u) + return s; + const { mapping: f, matchedPath: l } = u; + if (f.type !== "value" || f.source.type !== "documentValue") + return s; + const d = e.documents[f.source.document], y = e.paths[f.source.path], p = Ml(l), m = Ml(y).concat(a.slice(p.length)); + return n({ + sourcePath: m, + sourceDocument: d, + resultPath: a, + value: s + }); + }); +} +const iu = "drafts."; +function PE(r) { + return r.startsWith(iu) ? r.slice(iu.length) : r; +} +function FE(r) { + const { + baseUrl: e, + workspace: n = "default", + tool: s = "default", + id: a, + type: u, + path: f, + projectId: l, + dataset: d + } = r; + if (!e) + throw new Error("baseUrl is required"); + if (!f) + throw new Error("path is required"); + if (!a) + throw new Error("id is required"); + if (e !== "/" && e.endsWith("/")) + throw new Error("baseUrl must not end with a slash"); + const y = n === "default" ? void 0 : n, p = s === "default" ? void 0 : s, m = PE(a), b = Array.isArray(f) ? Ad(xd(f)) : f, C = new URLSearchParams({ + baseUrl: e, + id: m, + type: u, + path: b + }); + y && C.set("workspace", y), p && C.set("tool", p), l && C.set("projectId", l), d && C.set("dataset", d), a.startsWith(iu) && C.set("isDraft", ""); + const I = [e === "/" ? "" : e]; + y && I.push(y); + const O = [ + "mode=presentation", + `id=${m}`, + `type=${u}`, + `path=${encodeURIComponent(b)}` + ]; + return p && O.push(`tool=${p}`), I.push("intent", "edit", `${O.join(";")}?${C}`), I.join("/"); +} +function ME(r) { + let e = typeof r == "string" ? r : r.baseUrl; + return e !== "/" && (e = e.replace(/\/$/, "")), typeof r == "string" ? { baseUrl: e } : { ...r, baseUrl: e }; +} +const Ga = ({ sourcePath: r, resultPath: e, value: n }) => { + if (UE(n) || kE(n)) + return !1; + const s = r.at(-1); + return !(r.at(-2) === "slug" && s === "current" || typeof s == "string" && s.startsWith("_") || typeof s == "number" && r.at(-2) === "marks" || s === "href" && typeof r.at(-2) == "number" && r.at(-3) === "markDefs" || s === "style" || s === "listItem" || r.some( + (a) => a === "meta" || a === "metadata" || a === "openGraph" || a === "seo" + ) || Ul(r) || Ul(e) || typeof s == "string" && DE.has(s)); +}, DE = /* @__PURE__ */ new Set([ + "color", + "colour", + "currency", + "email", + "format", + "gid", + "hex", + "href", + "hsl", + "hsla", + "icon", + "id", + "index", + "key", + "language", + "layout", + "link", + "linkAction", + "locale", + "lqip", + "page", + "path", + "ref", + "rgb", + "rgba", + "route", + "secret", + "slug", + "status", + "tag", + "template", + "theme", + "type", + "unit", + "url", + "username", + "variant", + "website" +]); +function UE(r) { + return /^\d{4}-\d{2}-\d{2}/.test(r) ? !!Date.parse(r) : !1; +} +function kE(r) { + try { + new URL(r, r.startsWith("/") ? "https://acme.com" : void 0); + } catch { + return !1; + } + return !0; +} +function Ul(r) { + return r.some((e) => typeof e == "string" && e.match(/type/i) !== null); +} +const Ps = 20; +function Rd(r, e, n) { + var s, a, u, f, l, d, y, p, m; + const { filter: b, logger: C, enabled: I } = n; + if (!I) { + const x = "config.enabled must be true, don't call this function otherwise"; + throw (s = C == null ? void 0 : C.error) == null || s.call(C, `[@sanity/client]: ${x}`, { result: r, resultSourceMap: e, config: n }), new TypeError(x); + } + if (!e) + return (a = C == null ? void 0 : C.error) == null || a.call(C, "[@sanity/client]: Missing Content Source Map from response body", { + result: r, + resultSourceMap: e, + config: n + }), r; + if (!n.studioUrl) { + const x = "config.studioUrl must be defined"; + throw (u = C == null ? void 0 : C.error) == null || u.call(C, `[@sanity/client]: ${x}`, { result: r, resultSourceMap: e, config: n }), new TypeError(x); + } + const O = { + encoded: [], + skipped: [] + }, R = Sd( + r, + e, + ({ sourcePath: x, sourceDocument: D, resultPath: U, value: M }) => { + if ((typeof b == "function" ? b({ sourcePath: x, resultPath: U, filterDefault: Ga, sourceDocument: D, value: M }) : Ga({ sourcePath: x, resultPath: U, filterDefault: Ga, sourceDocument: D, value: M })) === !1) + return C && O.skipped.push({ + path: kl(x), + value: `${M.slice(0, Ps)}${M.length > Ps ? "..." : ""}`, + length: M.length + }), M; + C && O.encoded.push({ + path: kl(x), + value: `${M.slice(0, Ps)}${M.length > Ps ? "..." : ""}`, + length: M.length + }); + const { baseUrl: z, workspace: ht, tool: _t } = ME( + typeof n.studioUrl == "function" ? n.studioUrl(D) : n.studioUrl + ); + if (!z) + return M; + const { _id: xt, _type: Te, _projectId: qe, _dataset: un } = D; + return Ob( + M, + { + origin: "sanity.io", + href: FE({ + baseUrl: z, + workspace: ht, + tool: _t, + id: xt, + type: Te, + path: x, + ...!n.omitCrossDatasetReferenceData && { dataset: un, projectId: qe } + }) + }, + // We use custom logic to determine if we should skip encoding + !1 + ); + } + ); + if (C) { + const x = O.skipped.length, D = O.encoded.length; + if ((x || D) && ((f = (C == null ? void 0 : C.groupCollapsed) || C.log) == null || f("[@sanity/client]: Encoding source map into result"), (l = C.log) == null || l.call( + C, + `[@sanity/client]: Paths encoded: ${O.encoded.length}, skipped: ${O.skipped.length}` + )), O.encoded.length > 0 && ((d = C == null ? void 0 : C.log) == null || d.call(C, "[@sanity/client]: Table of encoded paths"), (y = (C == null ? void 0 : C.table) || C.log) == null || y(O.encoded)), O.skipped.length > 0) { + const U = /* @__PURE__ */ new Set(); + for (const { path: M } of O.skipped) + U.add(M.replace(Ed, "0").replace(/\[\d+\]/g, "[]")); + (p = C == null ? void 0 : C.log) == null || p.call(C, "[@sanity/client]: List of skipped paths", [...U.values()]); + } + (x || D) && ((m = C == null ? void 0 : C.groupEnd) == null || m.call(C)); + } + return R; +} +function kl(r) { + return Ad(xd(r)); +} +var NE = /* @__PURE__ */ Object.freeze({ + __proto__: null, + stegaEncodeSourceMap: Rd +}); +const qE = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + encodeIntoResult: Sd, + stegaEncodeSourceMap: Rd, + stegaEncodeSourceMap$1: NE +}, Symbol.toStringTag, { value: "Module" })); +var su = { exports: {} }; +/** @license + * eventsource.js + * Available under MIT License (MIT) + * https://github.com/Yaffle/EventSource/ + */ +(function(r, e) { + (function(n) { + var s = n.setTimeout, a = n.clearTimeout, u = n.XMLHttpRequest, f = n.XDomainRequest, l = n.ActiveXObject, d = n.EventSource, y = n.document, p = n.Promise, m = n.fetch, b = n.Response, C = n.TextDecoder, I = n.TextEncoder, O = n.AbortController; + if (typeof window < "u" && typeof y < "u" && !("readyState" in y) && y.body == null && (y.readyState = "loading", window.addEventListener("load", function(L) { + y.readyState = "complete"; + }, !1)), u == null && l != null && (u = function() { + return new l("Microsoft.XMLHTTP"); + }), Object.create == null && (Object.create = function(L) { + function k() { + } + return k.prototype = L, new k(); + }), Date.now || (Date.now = function() { + return (/* @__PURE__ */ new Date()).getTime(); + }), O == null) { + var R = m; + m = function(L, k) { + var H = k.signal; + return R(L, { headers: k.headers, credentials: k.credentials, cache: k.cache }).then(function(N) { + var Y = N.body.getReader(); + return H._reader = Y, H._aborted && H._reader.cancel(), { + status: N.status, + statusText: N.statusText, + headers: N.headers, + body: { + getReader: function() { + return Y; + } + } + }; + }); + }, O = function() { + this.signal = { + _reader: null, + _aborted: !1 + }, this.abort = function() { + this.signal._reader != null && this.signal._reader.cancel(), this.signal._aborted = !0; + }; + }; + } + function x() { + this.bitsNeeded = 0, this.codePoint = 0; + } + x.prototype.decode = function(L) { + function k(ft, yt, V) { + if (V === 1) + return ft >= 128 >> yt && ft << yt <= 2047; + if (V === 2) + return ft >= 2048 >> yt && ft << yt <= 55295 || ft >= 57344 >> yt && ft << yt <= 65535; + if (V === 3) + return ft >= 65536 >> yt && ft << yt <= 1114111; + throw new Error(); + } + function H(ft, yt) { + if (ft === 6 * 1) + return yt >> 6 > 15 ? 3 : yt > 31 ? 2 : 1; + if (ft === 6 * 2) + return yt > 15 ? 3 : 2; + if (ft === 6 * 3) + return 3; + throw new Error(); + } + for (var N = 65533, Y = "", G = this.bitsNeeded, Q = this.codePoint, mt = 0; mt < L.length; mt += 1) { + var at = L[mt]; + G !== 0 && (at < 128 || at > 191 || !k(Q << 6 | at & 63, G - 6, H(G, Q))) && (G = 0, Q = N, Y += String.fromCharCode(Q)), G === 0 ? (at >= 0 && at <= 127 ? (G = 0, Q = at) : at >= 192 && at <= 223 ? (G = 6 * 1, Q = at & 31) : at >= 224 && at <= 239 ? (G = 6 * 2, Q = at & 15) : at >= 240 && at <= 247 ? (G = 6 * 3, Q = at & 7) : (G = 0, Q = N), G !== 0 && !k(Q, G, H(G, Q)) && (G = 0, Q = N)) : (G -= 6, Q = Q << 6 | at & 63), G === 0 && (Q <= 65535 ? Y += String.fromCharCode(Q) : (Y += String.fromCharCode(55296 + (Q - 65535 - 1 >> 10)), Y += String.fromCharCode(56320 + (Q - 65535 - 1 & 1023)))); + } + return this.bitsNeeded = G, this.codePoint = Q, Y; + }; + var D = function() { + try { + return new C().decode(new I().encode("test"), { stream: !0 }) === "test"; + } catch (L) { + console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + L); + } + return !1; + }; + (C == null || I == null || !D()) && (C = x); + var U = function() { + }; + function M(L) { + this.withCredentials = !1, this.readyState = 0, this.status = 0, this.statusText = "", this.responseText = "", this.onprogress = U, this.onload = U, this.onerror = U, this.onreadystatechange = U, this._contentType = "", this._xhr = L, this._sendTimeout = 0, this._abort = U; + } + M.prototype.open = function(L, k) { + this._abort(!0); + var H = this, N = this._xhr, Y = 1, G = 0; + this._abort = function(V) { + H._sendTimeout !== 0 && (a(H._sendTimeout), H._sendTimeout = 0), (Y === 1 || Y === 2 || Y === 3) && (Y = 4, N.onload = U, N.onerror = U, N.onabort = U, N.onprogress = U, N.onreadystatechange = U, N.abort(), G !== 0 && (a(G), G = 0), V || (H.readyState = 4, H.onabort(null), H.onreadystatechange())), Y = 0; + }; + var Q = function() { + if (Y === 1) { + var V = 0, pt = "", we = void 0; + if ("contentType" in N) + V = 200, pt = "OK", we = N.contentType; + else + try { + V = N.status, pt = N.statusText, we = N.getResponseHeader("Content-Type"); + } catch { + V = 0, pt = "", we = void 0; + } + V !== 0 && (Y = 2, H.readyState = 2, H.status = V, H.statusText = pt, H._contentType = we, H.onreadystatechange()); + } + }, mt = function() { + if (Q(), Y === 2 || Y === 3) { + Y = 3; + var V = ""; + try { + V = N.responseText; + } catch { + } + H.readyState = 3, H.responseText = V, H.onprogress(); + } + }, at = function(V, pt) { + if ((pt == null || pt.preventDefault == null) && (pt = { + preventDefault: U + }), mt(), Y === 1 || Y === 2 || Y === 3) { + if (Y = 4, G !== 0 && (a(G), G = 0), H.readyState = 4, V === "load") + H.onload(pt); + else if (V === "error") + H.onerror(pt); + else if (V === "abort") + H.onabort(pt); + else + throw new TypeError(); + H.onreadystatechange(); + } + }, ft = function(V) { + N != null && (N.readyState === 4 ? (!("onload" in N) || !("onerror" in N) || !("onabort" in N)) && at(N.responseText === "" ? "error" : "load", V) : N.readyState === 3 ? "onprogress" in N || mt() : N.readyState === 2 && Q()); + }, yt = function() { + G = s(function() { + yt(); + }, 500), N.readyState === 3 && mt(); + }; + "onload" in N && (N.onload = function(V) { + at("load", V); + }), "onerror" in N && (N.onerror = function(V) { + at("error", V); + }), "onabort" in N && (N.onabort = function(V) { + at("abort", V); + }), "onprogress" in N && (N.onprogress = mt), "onreadystatechange" in N && (N.onreadystatechange = function(V) { + ft(V); + }), ("contentType" in N || !("ontimeout" in u.prototype)) && (k += (k.indexOf("?") === -1 ? "?" : "&") + "padding=true"), N.open(L, k, !0), "readyState" in N && (G = s(function() { + yt(); + }, 0)); + }, M.prototype.abort = function() { + this._abort(!1); + }, M.prototype.getResponseHeader = function(L) { + return this._contentType; + }, M.prototype.setRequestHeader = function(L, k) { + var H = this._xhr; + "setRequestHeader" in H && H.setRequestHeader(L, k); + }, M.prototype.getAllResponseHeaders = function() { + return this._xhr.getAllResponseHeaders != null && this._xhr.getAllResponseHeaders() || ""; + }, M.prototype.send = function() { + if ((!("ontimeout" in u.prototype) || !("sendAsBinary" in u.prototype) && !("mozAnon" in u.prototype)) && y != null && y.readyState != null && y.readyState !== "complete") { + var L = this; + L._sendTimeout = s(function() { + L._sendTimeout = 0, L.send(); + }, 4); + return; + } + var k = this._xhr; + "withCredentials" in k && (k.withCredentials = this.withCredentials); + try { + k.send(void 0); + } catch (H) { + throw H; + } + }; + function z(L) { + return L.replace(/[A-Z]/g, function(k) { + return String.fromCharCode(k.charCodeAt(0) + 32); + }); + } + function ht(L) { + for (var k = /* @__PURE__ */ Object.create(null), H = L.split(`\r +`), N = 0; N < H.length; N += 1) { + var Y = H[N], G = Y.split(": "), Q = G.shift(), mt = G.join(": "); + k[z(Q)] = mt; + } + this._map = k; + } + ht.prototype.get = function(L) { + return this._map[z(L)]; + }, u != null && u.HEADERS_RECEIVED == null && (u.HEADERS_RECEIVED = 2); + function _t() { + } + _t.prototype.open = function(L, k, H, N, Y, G, Q) { + L.open("GET", Y); + var mt = 0; + L.onprogress = function() { + var ft = L.responseText, yt = ft.slice(mt); + mt += yt.length, H(yt); + }, L.onerror = function(ft) { + ft.preventDefault(), N(new Error("NetworkError")); + }, L.onload = function() { + N(null); + }, L.onabort = function() { + N(null); + }, L.onreadystatechange = function() { + if (L.readyState === u.HEADERS_RECEIVED) { + var ft = L.status, yt = L.statusText, V = L.getResponseHeader("Content-Type"), pt = L.getAllResponseHeaders(); + k(ft, yt, V, new ht(pt)); + } + }, L.withCredentials = G; + for (var at in Q) + Object.prototype.hasOwnProperty.call(Q, at) && L.setRequestHeader(at, Q[at]); + return L.send(), L; + }; + function xt(L) { + this._headers = L; + } + xt.prototype.get = function(L) { + return this._headers.get(L); + }; + function Te() { + } + Te.prototype.open = function(L, k, H, N, Y, G, Q) { + var mt = null, at = new O(), ft = at.signal, yt = new C(); + return m(Y, { + headers: Q, + credentials: G ? "include" : "same-origin", + signal: ft, + cache: "no-store" + }).then(function(V) { + return mt = V.body.getReader(), k(V.status, V.statusText, V.headers.get("Content-Type"), new xt(V.headers)), new p(function(pt, we) { + var ln = function() { + mt.read().then(function(Kt) { + if (Kt.done) + pt(void 0); + else { + var Nt = yt.decode(Kt.value, { stream: !0 }); + H(Nt), ln(); + } + }).catch(function(Kt) { + we(Kt); + }); + }; + ln(); + }); + }).catch(function(V) { + if (V.name !== "AbortError") + return V; + }).then(function(V) { + N(V); + }), { + abort: function() { + mt != null && mt.cancel(), at.abort(); + } + }; + }; + function qe() { + this._listeners = /* @__PURE__ */ Object.create(null); + } + function un(L) { + s(function() { + throw L; + }, 0); + } + qe.prototype.dispatchEvent = function(L) { + L.target = this; + var k = this._listeners[L.type]; + if (k != null) + for (var H = k.length, N = 0; N < H; N += 1) { + var Y = k[N]; + try { + typeof Y.handleEvent == "function" ? Y.handleEvent(L) : Y.call(this, L); + } catch (G) { + un(G); + } + } + }, qe.prototype.addEventListener = function(L, k) { + L = String(L); + var H = this._listeners, N = H[L]; + N == null && (N = [], H[L] = N); + for (var Y = !1, G = 0; G < N.length; G += 1) + N[G] === k && (Y = !0); + Y || N.push(k); + }, qe.prototype.removeEventListener = function(L, k) { + L = String(L); + var H = this._listeners, N = H[L]; + if (N != null) { + for (var Y = [], G = 0; G < N.length; G += 1) + N[G] !== k && Y.push(N[G]); + Y.length === 0 ? delete H[L] : H[L] = Y; + } + }; + function We(L) { + this.type = L, this.target = void 0; + } + function zt(L, k) { + We.call(this, L), this.data = k.data, this.lastEventId = k.lastEventId; + } + zt.prototype = Object.create(We.prototype); + function Qt(L, k) { + We.call(this, L), this.status = k.status, this.statusText = k.statusText, this.headers = k.headers; + } + Qt.prototype = Object.create(We.prototype); + function yr(L, k) { + We.call(this, L), this.error = k.error; + } + yr.prototype = Object.create(We.prototype); + var Yr = -1, te = 0, se = 1, Yn = 2, En = -1, kt = 0, Vr = 1, $i = 2, wo = 3, An = /^text\/event\-stream(;.*)?$/i, wr = 1e3, bo = 18e6, cn = function(L, k) { + var H = L == null ? k : parseInt(L, 10); + return H !== H && (H = k), fn(H); + }, fn = function(L) { + return Math.min(Math.max(L, wr), bo); + }, xn = function(L, k, H) { + try { + typeof k == "function" && k.call(L, H); + } catch (N) { + un(N); + } + }; + function ee(L, k) { + qe.call(this), k = k || {}, this.onopen = void 0, this.onmessage = void 0, this.onerror = void 0, this.url = void 0, this.readyState = void 0, this.withCredentials = void 0, this.headers = void 0, this._close = void 0, ye(this, L, k); + } + function br() { + return u != null && "withCredentials" in u.prototype || f == null ? new u() : new f(); + } + var Pi = m != null && b != null && "body" in b.prototype; + function ye(L, k, H) { + k = String(k); + var N = !!H.withCredentials, Y = H.lastEventIdQueryParameterName || "lastEventId", G = fn(1e3), Q = cn(H.heartbeatTimeout, 45e3), mt = "", at = G, ft = !1, yt = 0, V = H.headers || {}, pt = H.Transport, we = Pi && pt == null ? void 0 : new M(pt != null ? new pt() : br()), ln = pt != null && typeof pt != "string" ? new pt() : we == null ? new Te() : new _t(), Kt = void 0, Nt = 0, oe = Yr, tn = "", Rn = "", be = "", In = "", Jt = kt, Zr = 0, hn = 0, Fi = function(Dt, Ot, ae, ue) { + if (oe === te) + if (Dt === 200 && ae != null && An.test(ae)) { + oe = se, ft = Date.now(), at = G, L.readyState = se; + var Xt = new Qt("open", { + status: Dt, + statusText: Ot, + headers: ue + }); + L.dispatchEvent(Xt), xn(L, L.onopen, Xt); + } else { + var $t = ""; + Dt !== 200 ? (Ot && (Ot = Ot.replace(/\s+/g, " ")), $t = "EventSource's response has a status " + Dt + " " + Ot + " that is not 200. Aborting the connection.") : $t = "EventSource's response has a Content-Type specifying an unsupported type: " + (ae == null ? "-" : ae.replace(/\s+/g, " ")) + ". Aborting the connection.", Qr(); + var Xt = new Qt("error", { + status: Dt, + statusText: Ot, + headers: ue + }); + L.dispatchEvent(Xt), xn(L, L.onerror, Xt), console.error($t); + } + }, Mi = function(Dt) { + if (oe === se) { + for (var Ot = -1, ae = 0; ae < Dt.length; ae += 1) { + var ue = Dt.charCodeAt(ae); + (ue === ` +`.charCodeAt(0) || ue === "\r".charCodeAt(0)) && (Ot = ae); + } + var Xt = (Ot !== -1 ? In : "") + Dt.slice(0, Ot + 1); + In = (Ot === -1 ? In : "") + Dt.slice(Ot + 1), Dt !== "" && (ft = Date.now(), yt += Dt.length); + for (var $t = 0; $t < Xt.length; $t += 1) { + var ue = Xt.charCodeAt($t); + if (Jt === En && ue === ` +`.charCodeAt(0)) + Jt = kt; + else if (Jt === En && (Jt = kt), ue === "\r".charCodeAt(0) || ue === ` +`.charCodeAt(0)) { + if (Jt !== kt) { + Jt === Vr && (hn = $t + 1); + var Be = Xt.slice(Zr, hn - 1), _e = Xt.slice(hn + (hn < $t && Xt.charCodeAt(hn) === " ".charCodeAt(0) ? 1 : 0), $t); + Be === "data" ? (tn += ` +`, tn += _e) : Be === "id" ? Rn = _e : Be === "event" ? be = _e : Be === "retry" ? (G = cn(_e, G), at = G) : Be === "heartbeatTimeout" && (Q = cn(_e, Q), Nt !== 0 && (a(Nt), Nt = s(function() { + Vn(); + }, Q))); + } + if (Jt === kt) { + if (tn !== "") { + mt = Rn, be === "" && (be = "message"); + var On = new zt(be, { + data: tn.slice(1), + lastEventId: Rn + }); + if (L.dispatchEvent(On), be === "open" ? xn(L, L.onopen, On) : be === "message" ? xn(L, L.onmessage, On) : be === "error" && xn(L, L.onerror, On), oe === Yn) + return; + } + tn = "", be = ""; + } + Jt = ue === "\r".charCodeAt(0) ? En : kt; + } else + Jt === kt && (Zr = $t, Jt = Vr), Jt === Vr ? ue === ":".charCodeAt(0) && (hn = $t + 1, Jt = $i) : Jt === $i && (Jt = wo); + } + } + }, Di = function(Dt) { + if (oe === se || oe === te) { + oe = Yr, Nt !== 0 && (a(Nt), Nt = 0), Nt = s(function() { + Vn(); + }, at), at = fn(Math.min(G * 16, at * 2)), L.readyState = te; + var Ot = new yr("error", { error: Dt }); + L.dispatchEvent(Ot), xn(L, L.onerror, Ot), Dt != null && console.error(Dt); + } + }, Qr = function() { + oe = Yn, Kt != null && (Kt.abort(), Kt = void 0), Nt !== 0 && (a(Nt), Nt = 0), L.readyState = Yn; + }, Vn = function() { + if (Nt = 0, oe !== Yr) { + if (!ft && Kt != null) + Di(new Error("No activity within " + Q + " milliseconds. " + (oe === te ? "No response received." : yt + " chars received.") + " Reconnecting.")), Kt != null && (Kt.abort(), Kt = void 0); + else { + var Dt = Math.max((ft || Date.now()) + Q - Date.now(), 1); + ft = !1, Nt = s(function() { + Vn(); + }, Dt); + } + return; + } + ft = !1, yt = 0, Nt = s(function() { + Vn(); + }, Q), oe = te, tn = "", be = "", Rn = mt, In = "", Zr = 0, hn = 0, Jt = kt; + var Ot = k; + if (k.slice(0, 5) !== "data:" && k.slice(0, 5) !== "blob:" && mt !== "") { + var ae = k.indexOf("?"); + Ot = ae === -1 ? k : k.slice(0, ae + 1) + k.slice(ae + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function(_e, On) { + return On === Y ? "" : _e; + }), Ot += (k.indexOf("?") === -1 ? "?" : "&") + Y + "=" + encodeURIComponent(mt); + } + var ue = L.withCredentials, Xt = {}; + Xt.Accept = "text/event-stream"; + var $t = L.headers; + if ($t != null) + for (var Be in $t) + Object.prototype.hasOwnProperty.call($t, Be) && (Xt[Be] = $t[Be]); + try { + Kt = ln.open(we, Fi, Mi, Di, Ot, ue, Xt); + } catch (_e) { + throw Qr(), _e; + } + }; + L.url = k, L.readyState = te, L.withCredentials = N, L.headers = V, L._close = Qr, Vn(); + } + ee.prototype = Object.create(qe.prototype), ee.prototype.CONNECTING = te, ee.prototype.OPEN = se, ee.prototype.CLOSED = Yn, ee.prototype.close = function() { + this._close(); + }, ee.CONNECTING = te, ee.OPEN = se, ee.CLOSED = Yn, ee.prototype.withCredentials = void 0; + var Sn = d; + u != null && (d == null || !("withCredentials" in d.prototype)) && (Sn = ee), function(L) { + { + var k = L(e); + k !== void 0 && (r.exports = k); + } + }(function(L) { + L.EventSourcePolyfill = ee, L.NativeEventSource = d, L.EventSource = Sn; + }); + })(typeof globalThis > "u" ? typeof window < "u" ? window : typeof self < "u" ? self : Nr : globalThis); +})(su, su.exports); +var WE = su.exports, BE = WE.EventSourcePolyfill; +const HE = /* @__PURE__ */ ud(BE), Id = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + default: HE +}, Symbol.toStringTag, { value: "Module" })); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 19e6506c59b..d7966a2f107 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,6 +7,8 @@ settings: overrides: '@typescript-eslint/eslint-plugin': ^7.11.0 '@typescript-eslint/parser': ^7.11.0 + '@sanity/ui': 2.6.4-canary.0 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 importers: @@ -66,7 +68,7 @@ importers: version: 0.0.1-alpha.1 '@sanity/tsdoc': specifier: 1.0.83 - version: 1.0.83(@types/node@18.19.31)(debug@4.3.5)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 1.0.83(@types/node@18.19.31)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) '@sanity/uuid': specifier: ^3.0.2 version: 3.0.2 @@ -75,7 +77,7 @@ importers: version: 7.2.0 '@types/lodash': specifier: ^4.14.149 - version: 4.17.0 + version: 4.17.6 '@types/node': specifier: ^18.19.8 version: 18.19.31 @@ -241,8 +243,8 @@ importers: specifier: ^3.3.0 version: 3.3.0(react@18.3.1) '@sanity/ui': - specifier: ^2.6.3 - version: 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + specifier: 2.6.4-canary.0 + version: 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) react: specifier: ^18.3.1 version: 18.3.1 @@ -253,14 +255,14 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) dev/embedded-studio: dependencies: '@sanity/ui': - specifier: ^2.6.3 - version: 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + specifier: 2.6.4-canary.0 + version: 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) react: specifier: ^18.3.1 version: 18.3.1 @@ -271,8 +273,8 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) devDependencies: '@types/react': specifier: ^18.3.3 @@ -308,8 +310,8 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.8 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) dev/starter-next-studio: dependencies: @@ -326,8 +328,8 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) dev/starter-studio: dependencies: @@ -341,8 +343,8 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) dev/strict-studio: dependencies: @@ -356,20 +358,20 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) dev/studio-e2e-testing: dependencies: '@sanity/google-maps-input': specifier: ^4.0.0 - version: 4.0.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 4.0.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) '@sanity/icons': specifier: ^3.3.0 version: 3.3.0(react@18.3.1) '@sanity/ui': - specifier: ^2.6.3 - version: 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + specifier: 2.6.4-canary.0 + version: 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sanity/vision': specifier: 3.49.0 version: link:../../packages/@sanity/vision @@ -384,13 +386,13 @@ importers: version: link:../../packages/sanity sanity-plugin-mux-input: specifier: ^2.2.1 - version: 2.3.6(@types/react@18.3.3)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 2.3.6(@types/react@18.3.3)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) sanity-test-studio: specifier: workspace:* version: link:../test-studio styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) dev/test-next-studio: dependencies: @@ -419,8 +421,8 @@ importers: specifier: workspace:* version: link:../test-studio styled-components: - specifier: ^6.1.11 - version: 6.1.11(react-dom@19.0.0-rc-38e3b23483-20240529)(react@19.0.0-rc-38e3b23483-20240529) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@19.0.0-rc-38e3b23483-20240529)(react@19.0.0-rc-38e3b23483-20240529) typescript: specifier: 5.5.3 version: 5.5.3 @@ -429,7 +431,7 @@ importers: dependencies: '@portabletext/editor': specifier: ^1.0.8 - version: 1.0.8(@sanity/block-tools@packages+@sanity+block-tools)(@sanity/schema@packages+@sanity+schema)(@sanity/types@packages+@sanity+types)(@sanity/util@packages+@sanity+util)(react-dom@18.3.1)(react@18.3.1)(rxjs@7.8.1)(styled-components@6.1.11) + version: 1.0.8(@sanity/block-tools@packages+@sanity+block-tools)(@sanity/schema@packages+@sanity+schema)(@sanity/types@packages+@sanity+types)(@sanity/util@packages+@sanity+util)(react-dom@18.3.1)(react@18.3.1)(rxjs@7.8.1)(speedy-styled-components@6.1.12-canary.0) '@portabletext/react': specifier: ^3.0.0 version: 3.1.0(react@18.3.1) @@ -444,7 +446,7 @@ importers: version: 8.16.8(react-dom@18.3.1)(react@18.3.1)(three@0.166.1) '@sanity/assist': specifier: ^3.0.2 - version: 3.0.4(@sanity/mutator@packages+@sanity+mutator)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 3.0.4(@sanity/mutator@packages+@sanity+mutator)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) '@sanity/block-tools': specifier: 3.49.0 version: link:../../packages/@sanity/block-tools @@ -456,7 +458,7 @@ importers: version: 3.0.6 '@sanity/google-maps-input': specifier: ^4.0.0 - version: 4.0.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 4.0.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) '@sanity/icons': specifier: ^3.3.0 version: 3.3.0(react@18.3.1) @@ -492,16 +494,16 @@ importers: version: 1.10.4(@sanity/client@6.20.2)(react@18.3.1) '@sanity/tsdoc': specifier: 1.0.83 - version: 1.0.83(@types/node@18.19.31)(debug@4.3.5)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 1.0.83(@types/node@18.19.31)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) '@sanity/types': specifier: workspace:* version: link:../../packages/@sanity/types '@sanity/ui': - specifier: ^2.6.3 - version: 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + specifier: 2.6.4-canary.0 + version: 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sanity/ui-workshop': specifier: ^1.0.0 - version: 1.2.11(@sanity/icons@3.3.0)(@sanity/ui@2.6.3)(@types/node@18.19.31)(react-dom@18.3.1)(react@18.3.1)(styled-components@6.1.11) + version: 1.2.11(@sanity/icons@3.3.0)(@sanity/ui@2.6.4-canary.0)(@types/node@18.19.31)(react-dom@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sanity/util': specifier: workspace:* version: link:../../packages/@sanity/util @@ -546,7 +548,7 @@ importers: version: 4.3.1 qs: specifier: ^6.10.2 - version: 6.12.3 + version: 6.12.2 react: specifier: ^18.3.1 version: 18.3.1 @@ -567,13 +569,13 @@ importers: version: link:../../packages/sanity sanity-plugin-hotspot-array: specifier: ^2.0.0 - version: 2.0.0(@sanity/ui@2.6.3)(react-dom@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 2.0.0(@sanity/ui@2.6.4-canary.0)(react-dom@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) sanity-plugin-mux-input: specifier: ^2.2.1 - version: 2.3.6(@types/react@18.3.3)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 2.3.6(@types/react@18.3.3)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) styled-components: - specifier: ^6.1.11 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) three: specifier: ^0.166.0 version: 0.166.1 @@ -597,8 +599,8 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) examples/clean-studio: dependencies: @@ -612,8 +614,8 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) examples/ecommerce-studio: dependencies: @@ -621,8 +623,8 @@ importers: specifier: 3.49.0 version: link:../../packages/@sanity/cli '@sanity/ui': - specifier: ^2.6.3 - version: 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + specifier: 2.6.4-canary.0 + version: 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) react: specifier: ^18.3.1 version: 18.3.1 @@ -636,14 +638,14 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) examples/movies-studio: dependencies: '@sanity/google-maps-input': specifier: ^4.0.0 - version: 4.0.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 4.0.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) react: specifier: ^18.3.1 version: 18.3.1 @@ -654,12 +656,16 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) packages/@repo/package.bundle: {} - packages/@repo/package.config: {} + packages/@repo/package.config: + dependencies: + '@web/rollup-plugin-import-meta-assets': + specifier: 2.2.1 + version: 2.2.1(rollup@4.18.0) packages/@repo/test-exports: dependencies: @@ -735,7 +741,7 @@ importers: version: 20.0.1 '@types/lodash': specifier: ^4.14.149 - version: 4.17.0 + version: 4.17.6 '@types/react': specifier: ^18.3.3 version: 18.3.3 @@ -844,7 +850,7 @@ importers: version: 6.5.0 '@types/lodash': specifier: ^4.14.149 - version: 4.17.0 + version: 4.17.6 '@types/minimist': specifier: ^1.2.5 version: 1.2.5 @@ -1127,7 +1133,7 @@ importers: version: 4.1.12 '@types/lodash': specifier: ^4.14.149 - version: 4.17.0 + version: 4.17.6 rimraf: specifier: ^3.0.2 version: 3.0.2 @@ -1198,7 +1204,7 @@ importers: version: link:../../@repo/package.config '@sanity/insert-menu': specifier: 1.0.7 - version: 1.0.7(@sanity/types@packages+@sanity+types)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + version: 1.0.7(@sanity/types@packages+@sanity+types)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) rimraf: specifier: ^3.0.2 version: 3.0.2 @@ -1276,8 +1282,8 @@ importers: specifier: ^3.3.0 version: 3.3.0(react@18.3.1) '@sanity/ui': - specifier: ^2.6.3 - version: 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + specifier: 2.6.4-canary.0 + version: 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@uiw/react-codemirror': specifier: ^4.11.4 version: 4.21.25(@babel/runtime@7.24.7)(@codemirror/autocomplete@6.17.0)(@codemirror/language@6.10.2)(@codemirror/lint@6.8.1)(@codemirror/search@6.5.6)(@codemirror/state@6.4.1)(@codemirror/theme-one-dark@6.1.2)(@codemirror/view@6.28.4)(codemirror@6.0.1)(react-dom@18.3.1)(react@18.3.1) @@ -1332,7 +1338,7 @@ importers: version: link:../util '@types/lodash': specifier: ^4.14.149 - version: 4.17.0 + version: 4.17.6 react: specifier: ^18.3.1 version: 18.3.1 @@ -1340,8 +1346,8 @@ importers: specifier: workspace:* version: link:../../sanity styled-components: - specifier: ^6.1.11 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) packages/create-sanity: dependencies: @@ -1377,7 +1383,7 @@ importers: version: 3.4.0 '@portabletext/editor': specifier: ^1.0.8 - version: 1.0.8(@sanity/block-tools@packages+@sanity+block-tools)(@sanity/schema@packages+@sanity+schema)(@sanity/types@packages+@sanity+types)(@sanity/util@packages+@sanity+util)(react-dom@18.3.1)(react@18.3.1)(rxjs@7.8.1)(styled-components@6.1.11) + version: 1.0.8(@sanity/block-tools@packages+@sanity+block-tools)(@sanity/schema@packages+@sanity+schema)(@sanity/types@packages+@sanity+types)(@sanity/util@packages+@sanity+util)(react-dom@18.3.1)(react@18.3.1)(rxjs@7.8.1)(speedy-styled-components@6.1.12-canary.0) '@portabletext/react': specifier: ^3.0.0 version: 3.1.0(react@18.3.1) @@ -1425,7 +1431,7 @@ importers: version: 3.37.5 '@sanity/insert-menu': specifier: 1.0.7 - version: 1.0.7(@sanity/types@packages+@sanity+types)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + version: 1.0.7(@sanity/types@packages+@sanity+types)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sanity/logos': specifier: ^2.1.4 version: 2.1.12(@sanity/color@3.0.6)(react@18.3.1) @@ -1437,7 +1443,7 @@ importers: version: link:../@sanity/mutator '@sanity/presentation': specifier: 1.16.2 - version: 1.16.2(@sanity/client@6.20.2)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + version: 1.16.2(@sanity/client@6.20.2)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sanity/schema': specifier: 3.49.0 version: link:../@sanity/schema @@ -1448,8 +1454,8 @@ importers: specifier: 3.49.0 version: link:../@sanity/types '@sanity/ui': - specifier: ^2.6.3 - version: 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + specifier: 2.6.4-canary.0 + version: 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sanity/util': specifier: 3.49.0 version: link:../@sanity/util @@ -1729,10 +1735,10 @@ importers: version: 6.9.3(@types/node@18.19.31)(debug@4.3.5)(typescript@5.4.5) '@sanity/tsdoc': specifier: 1.0.83 - version: 1.0.83(@types/node@18.19.31)(debug@4.3.5)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11) + version: 1.0.83(@types/node@18.19.31)(debug@4.3.5)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0) '@sanity/ui-workshop': specifier: ^1.2.11 - version: 1.2.11(@sanity/icons@3.3.0)(@sanity/ui@2.6.3)(@types/node@18.19.31)(react-dom@18.3.1)(react@18.3.1)(styled-components@6.1.11) + version: 1.2.11(@sanity/icons@3.3.0)(@sanity/ui@2.6.4-canary.0)(@types/node@18.19.31)(react-dom@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sentry/types': specifier: ^8.12.0 version: 8.12.0 @@ -1765,7 +1771,7 @@ importers: version: 20.0.1 '@types/lodash': specifier: ^4.14.149 - version: 4.17.0 + version: 4.17.6 '@types/log-symbols': specifier: ^2.0.0 version: 2.0.0 @@ -1812,8 +1818,8 @@ importers: specifier: ^10.6.2 version: 10.6.2(rxjs@7.8.1) styled-components: - specifier: ^6.1.11 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) swr: specifier: 2.2.5 version: 2.2.5(react@18.3.1) @@ -1827,8 +1833,8 @@ importers: specifier: ^18.3.0 version: 18.3.1(react@18.3.1) styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) packages/sanity/fixtures/examples/prj-with-react-19: dependencies: @@ -1839,8 +1845,8 @@ importers: specifier: 19.0.0-rc-f994737d14-20240522 version: 19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522) styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@19.0.0-rc-f994737d14-20240522)(react@19.0.0-rc-f994737d14-20240522) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@19.0.0-rc-f994737d14-20240522)(react@19.0.0-rc-f994737d14-20240522) packages/sanity/fixtures/examples/prj-with-styled-components-5: dependencies: @@ -1851,8 +1857,8 @@ importers: specifier: ^18.3.0 version: 18.3.1(react@18.3.1) styled-components: - specifier: ^5.3.0 - version: 5.3.11(@babel/core@7.24.7)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) perf/studio: dependencies: @@ -1866,8 +1872,8 @@ importers: specifier: workspace:* version: link:../../packages/sanity styled-components: - specifier: ^6.1.0 - version: 6.1.11(react-dom@18.3.1)(react@18.3.1) + specifier: npm:speedy-styled-components@6.1.12-canary.0 + version: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) perf/tests: dependencies: @@ -1904,7 +1910,7 @@ importers: version: 29.7.0 '@types/lodash': specifier: ^4.14.149 - version: 4.17.0 + version: 4.17.6 '@types/node': specifier: ^18.15.3 version: 18.19.31 @@ -2128,16 +2134,6 @@ packages: transitivePeerDependencies: - supports-color - /@babel/helper-module-imports@7.24.7(supports-color@5.5.0): - resolution: {integrity: sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/traverse': 7.24.7(supports-color@5.5.0) - '@babel/types': 7.24.7 - transitivePeerDependencies: - - supports-color - dev: false - /@babel/helper-module-transforms@7.24.7(@babel/core@7.24.7): resolution: {integrity: sha512-1fuJEwIrp+97rM4RWdO+qrRsZlAeL1lQJoPqtCYWv0NL115XM93hIH4CSRln2w52SqvmY5hqdtauB6QFCDiZNQ==} engines: {node: '>=6.9.0'} @@ -3287,24 +3283,6 @@ packages: transitivePeerDependencies: - supports-color - /@babel/traverse@7.24.7(supports-color@5.5.0): - resolution: {integrity: sha512-yb65Ed5S/QAcewNPh0nZczy9JdYXkkAbIsEo+P7BE7yO3txAY30Y/oPa3QkQ5It3xVG2kpKMg9MsdxZaO31uKA==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/code-frame': 7.24.7 - '@babel/generator': 7.24.7 - '@babel/helper-environment-visitor': 7.24.7 - '@babel/helper-function-name': 7.24.7 - '@babel/helper-hoist-variables': 7.24.7 - '@babel/helper-split-export-declaration': 7.24.7 - '@babel/parser': 7.24.7 - '@babel/types': 7.24.7 - debug: 4.3.5(supports-color@5.5.0) - globals: 11.12.0 - transitivePeerDependencies: - - supports-color - dev: false - /@babel/types@7.24.7: resolution: {integrity: sha512-XEFXSlxiG5td2EJRe8vOmRbaXVgfcBlszKujvVmWIK/UpywWljQCfzAv3RQCGujWQ1RD4YYWEAqDXfuJiy8f5Q==} engines: {node: '>=6.9.0'} @@ -3498,14 +3476,6 @@ packages: /@emotion/memoize@0.8.1: resolution: {integrity: sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==} - /@emotion/stylis@0.8.5: - resolution: {integrity: sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ==} - dev: false - - /@emotion/unitless@0.7.5: - resolution: {integrity: sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==} - dev: false - /@emotion/unitless@0.8.1: resolution: {integrity: sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==} @@ -4298,6 +4268,17 @@ packages: '@floating-ui/core': 1.6.0 '@floating-ui/utils': 0.2.1 + /@floating-ui/react-dom@2.1.0(react-dom@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-lNzj5EQmEKn5FFKc04+zasr09h/uX8RtJRNj5gUXsSQIXHVWTVh+hVAg1vOMCexkX8EgvemMvIFpQfkosnVNyA==} + peerDependencies: + react: '*' + react-dom: '*' + dependencies: + '@floating-ui/dom': 1.6.3 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + dev: false + /@floating-ui/react-dom@2.1.1(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-4h84MJt3CHrtG18mGsXuLCHMrug49d7DFkU0RMIyshRveBeyV2hmV/pDaF2Uxtu8kgq5r46llp5E5FQiR0K2Yg==} peerDependencies: @@ -5809,7 +5790,7 @@ packages: '@pnpm/network.ca-file': 1.0.2 config-chain: 1.1.13 - /@portabletext/editor@1.0.8(@sanity/block-tools@packages+@sanity+block-tools)(@sanity/schema@packages+@sanity+schema)(@sanity/types@packages+@sanity+types)(@sanity/util@packages+@sanity+util)(react-dom@18.3.1)(react@18.3.1)(rxjs@7.8.1)(styled-components@6.1.11): + /@portabletext/editor@1.0.8(@sanity/block-tools@packages+@sanity+block-tools)(@sanity/schema@packages+@sanity+schema)(@sanity/types@packages+@sanity+types)(@sanity/util@packages+@sanity+util)(react-dom@18.3.1)(react@18.3.1)(rxjs@7.8.1)(speedy-styled-components@6.1.12-canary.0): resolution: {integrity: sha512-iSCkdsVpMrfwFmxBfb1acbUVPuS13hkwuIS5uR7blt/fFysy+j+IxhH7tJdJt18PISKlWw+1zPfHGz/LoEdrgw==} engines: {node: '>=18'} peerDependencies: @@ -5819,7 +5800,7 @@ packages: '@sanity/util': ^3.47.1 react: '*' rxjs: ^7 - styled-components: ^6.1 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 dependencies: '@portabletext/patches': 1.0.2 '@sanity/block-tools': link:packages/@sanity/block-tools @@ -5833,7 +5814,7 @@ packages: rxjs: 7.8.1 slate: 0.100.0 slate-react: 0.101.0(react-dom@18.3.1)(react@18.3.1)(slate@0.100.0) - styled-components: 6.1.11(react-dom@18.3.1)(react@18.3.1) + styled-components: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) transitivePeerDependencies: - react-dom - supports-color @@ -5973,7 +5954,7 @@ packages: optional: true dependencies: '@babel/runtime': 7.24.7 - '@floating-ui/react-dom': 2.1.1(react-dom@18.3.1)(react@18.3.1) + '@floating-ui/react-dom': 2.1.0(react-dom@18.3.1)(react@18.3.1) '@radix-ui/react-arrow': 1.0.3(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1) '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.3.3)(react@18.3.1) '@radix-ui/react-context': 1.0.1(@types/react@18.3.3)(react@18.3.1) @@ -6447,6 +6428,23 @@ packages: magic-string: 0.30.9 rollup: 4.18.0 + /@rollup/plugin-dynamic-import-vars@2.1.2(rollup@4.18.0): + resolution: {integrity: sha512-4lr2oXxs9hcxtGGaK8s0i9evfjzDrAs7ngw28TqruWKTEm0+U4Eljb+F6HXGYdFv8xRojQlrQwV7M/yxeh3yzQ==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@4.18.0) + astring: 1.8.6 + estree-walker: 2.0.2 + fast-glob: 3.3.2 + magic-string: 0.30.9 + rollup: 4.18.0 + dev: false + /@rollup/plugin-json@6.1.0(rollup@4.18.0): resolution: {integrity: sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==} engines: {node: '>=14.0.0'} @@ -6698,19 +6696,19 @@ packages: engines: {node: '>=10'} dev: false - /@sanity/assist@3.0.4(@sanity/mutator@packages+@sanity+mutator)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11): + /@sanity/assist@3.0.4(@sanity/mutator@packages+@sanity+mutator)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0): resolution: {integrity: sha512-2UBznX9EjDwptMjby9x2zNQUoSR3sdgRSpD+AcnfTcnzjBytLTEnXxHr9hWzfRfPO4EDrr8UuxVaRTzHjnRb4Q==} engines: {node: '>=14'} peerDependencies: '@sanity/mutator': ^3.36.4 react: '*' sanity: ^3.36.4 - styled-components: ^6.1 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 dependencies: '@sanity/icons': 2.11.8(react@18.3.1) '@sanity/incompatible-plugin': 1.0.4(react-dom@18.3.1)(react@18.3.1) '@sanity/mutator': link:packages/@sanity/mutator - '@sanity/ui': 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + '@sanity/ui': 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) date-fns: 3.6.0 lodash: 4.17.21 lodash-es: 4.17.21 @@ -6719,7 +6717,7 @@ packages: rxjs: 7.8.1 rxjs-exhaustmap-with-trailing: 2.1.1(rxjs@7.8.1) sanity: link:packages/sanity - styled-components: 6.1.11(react-dom@18.3.1)(react@18.3.1) + styled-components: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) transitivePeerDependencies: - react-dom - react-is @@ -6851,21 +6849,21 @@ packages: /@sanity/generate-help-url@3.0.0: resolution: {integrity: sha512-wtMYcV5GIDIhVyF/jjmdwq1GdlK07dRL40XMns73VbrFI7FteRltxv48bhYVZPcLkRXb0SHjpDS/icj9/yzbVA==} - /@sanity/google-maps-input@4.0.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11): + /@sanity/google-maps-input@4.0.1(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0): resolution: {integrity: sha512-lYxK1Jfb2Xk3lVVcK/MUdK562qAC3LfSatjbvpDTP4LNwQ1NVvvgwsS2QGiGSQvgSXxGPOaiS40MSMb26X1Vhg==} engines: {node: '>=14'} peerDependencies: react: '*' sanity: ^3.19.0 - styled-components: ^6.1 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 dependencies: '@sanity/icons': 2.11.8(react@18.3.1) '@sanity/incompatible-plugin': 1.0.4(react-dom@18.3.1)(react@18.3.1) - '@sanity/ui': 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + '@sanity/ui': 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) lodash: 4.17.21 react: 18.3.1 sanity: link:packages/sanity - styled-components: 6.1.11(react-dom@18.3.1)(react@18.3.1) + styled-components: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) transitivePeerDependencies: - react-dom - react-is @@ -6943,7 +6941,7 @@ packages: react-dom: 18.3.1(react@18.3.1) dev: false - /@sanity/insert-menu@1.0.7(@sanity/types@packages+@sanity+types)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11): + /@sanity/insert-menu@1.0.7(@sanity/types@packages+@sanity+types)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0): resolution: {integrity: sha512-KQTRl3T4nQSFDP2FEM85UBTaGdOEJVechSqChSmUohAoMiizRtLGP2CpeK8OMP0jE8Bjshs3Af+5LZ0NY7SVsA==} engines: {node: '>=18.0.0'} peerDependencies: @@ -6954,7 +6952,7 @@ packages: dependencies: '@sanity/icons': 3.3.0(react@18.3.1) '@sanity/types': link:packages/@sanity/types - '@sanity/ui': 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + '@sanity/ui': 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) lodash.startcase: 4.4.0 react: 18.3.1 react-dom: 18.3.1(react@18.3.1) @@ -7137,7 +7135,7 @@ packages: - supports-color dev: true - /@sanity/presentation@1.16.2(@sanity/client@6.20.2)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11): + /@sanity/presentation@1.16.2(@sanity/client@6.20.2)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0): resolution: {integrity: sha512-mEMHpMNPLG8C5qyNmKir9/I3p9gvC7joYbRdwe0HxGVmFHU28aKhkEFCDJrDwp/Bm5Z7ps8fF1wi5mCt5cBymQ==} engines: {node: '>=16.14'} peerDependencies: @@ -7146,7 +7144,7 @@ packages: '@sanity/client': 6.20.2(debug@4.3.5) '@sanity/icons': 3.3.0(react@18.3.1) '@sanity/preview-url-secret': 1.6.18(@sanity/client@6.20.2) - '@sanity/ui': 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + '@sanity/ui': 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sanity/uuid': 3.0.2 '@types/lodash.isequal': 4.5.8 fast-deep-equal: 3.1.3 @@ -7220,7 +7218,7 @@ packages: - debug dev: true - /@sanity/tsdoc@1.0.83(@types/node@18.19.31)(debug@4.3.5)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11): + /@sanity/tsdoc@1.0.83(@types/node@18.19.31)(debug@4.3.5)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0): resolution: {integrity: sha512-nIywYVkn6uwxuKOIzowLQM1/26Wq19OT4MMUBrUjjHsAutU9MyGfX7M5rM4rhfbP351N48dHvYCNpMYOWSadjg==} engines: {node: '>=14.0.0'} hasBin: true @@ -7228,7 +7226,7 @@ packages: react: '*' react-dom: '*' sanity: ^3 - styled-components: ^5.2 || ^6 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 dependencies: '@microsoft/api-extractor': 7.47.0(@types/node@18.19.31) '@microsoft/api-extractor-model': 7.29.2(@types/node@18.19.31) @@ -7240,7 +7238,7 @@ packages: '@sanity/color': 3.0.6 '@sanity/icons': 3.3.0(react@18.3.1) '@sanity/pkg-utils': 6.10.2(@types/node@18.19.31)(debug@4.3.5)(typescript@5.5.3) - '@sanity/ui': 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + '@sanity/ui': 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@types/cpx': 1.5.5 '@vitejs/plugin-react': 4.3.1(vite@5.3.3) cac: 6.7.14 @@ -7263,7 +7261,68 @@ packages: react-refractor: 2.2.0(react@18.3.1) sanity: link:packages/sanity slugify: 1.6.6 - styled-components: 6.1.11(react-dom@18.3.1)(react@18.3.1) + styled-components: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) + tmp: 0.2.3 + typescript: 5.5.3 + vite: 5.3.3(@types/node@18.19.31) + transitivePeerDependencies: + - '@types/babel__core' + - '@types/node' + - debug + - less + - lightningcss + - react-is + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /@sanity/tsdoc@1.0.83(@types/node@18.19.31)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0): + resolution: {integrity: sha512-nIywYVkn6uwxuKOIzowLQM1/26Wq19OT4MMUBrUjjHsAutU9MyGfX7M5rM4rhfbP351N48dHvYCNpMYOWSadjg==} + engines: {node: '>=14.0.0'} + hasBin: true + peerDependencies: + react: '*' + react-dom: '*' + sanity: ^3 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 + dependencies: + '@microsoft/api-extractor': 7.47.0(@types/node@18.19.31) + '@microsoft/api-extractor-model': 7.29.2(@types/node@18.19.31) + '@microsoft/tsdoc': 0.15.0 + '@microsoft/tsdoc-config': 0.17.0 + '@portabletext/react': 3.1.0(react@18.3.1) + '@portabletext/toolkit': 2.0.15 + '@sanity/client': 6.20.2(debug@4.3.5) + '@sanity/color': 3.0.6 + '@sanity/icons': 3.3.0(react@18.3.1) + '@sanity/pkg-utils': 6.10.2(@types/node@18.19.31)(debug@4.3.5)(typescript@5.5.3) + '@sanity/ui': 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) + '@types/cpx': 1.5.5 + '@vitejs/plugin-react': 4.3.1(vite@5.3.3) + cac: 6.7.14 + chalk: 4.1.2 + chokidar: 3.6.0 + cors: 2.8.5 + dotenv-flow: 3.3.0 + esbuild: 0.23.0 + esbuild-register: 3.5.0(esbuild@0.23.0) + express: 4.19.2 + globby: 11.1.0 + groq: 3.49.0 + groq-js: 1.10.0 + history: 5.3.0 + jsonc-parser: 3.3.1 + mkdirp: 1.0.4 + pkg-up: 3.1.0 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + react-refractor: 2.2.0(react@18.3.1) + sanity: link:packages/sanity + slugify: 1.6.6 + styled-components: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) tmp: 0.2.3 typescript: 5.5.3 vite: 5.3.3(@types/node@18.19.31) @@ -7298,18 +7357,18 @@ packages: - debug dev: false - /@sanity/ui-workshop@1.2.11(@sanity/icons@3.3.0)(@sanity/ui@2.6.3)(@types/node@18.19.31)(react-dom@18.3.1)(react@18.3.1)(styled-components@6.1.11): + /@sanity/ui-workshop@1.2.11(@sanity/icons@3.3.0)(@sanity/ui@2.6.4-canary.0)(@types/node@18.19.31)(react-dom@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0): resolution: {integrity: sha512-vzj7upIF7wq2W1HEA0D5VSkR8axaH4Rt07yNTAaas7CLgjSE9r2d+Gnkrq4FIbIuN1GYhhCD+D3/s60GaZrpQw==} hasBin: true peerDependencies: '@sanity/icons': ^2 - '@sanity/ui': ^1 + '@sanity/ui': 2.6.4-canary.0 react: '*' react-dom: '*' - styled-components: ^5.2 || ^6 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 dependencies: '@sanity/icons': 3.3.0(react@18.3.1) - '@sanity/ui': 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + '@sanity/ui': 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@vitejs/plugin-react': 4.3.1(vite@4.5.3) axe-core: 4.9.0 cac: 6.7.14 @@ -7325,7 +7384,7 @@ packages: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) segmented-property: 3.0.3 - styled-components: 6.1.11(react-dom@18.3.1)(react@18.3.1) + styled-components: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) vite: 4.5.3(@types/node@18.19.31) transitivePeerDependencies: - '@types/node' @@ -7337,14 +7396,14 @@ packages: - supports-color - terser - /@sanity/ui@2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11): - resolution: {integrity: sha512-qyNaIlfRvLQ21Z4+PP61qZ/Rjbk2UqqC/YTS9AmeRvetL9WEuUYFbMrprdKzAAUcWOqabBZVLjrU9F01nDEtmw==} + /@sanity/ui@2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0): + resolution: {integrity: sha512-txPWpsLs87Gi/OpKcXvd+iYWSZaAFLHU0Hs8/9WfNb3VzsCqQNaCYbCW0uAx5iMJwrhPbPDJK3gBElGNL74/KA==} engines: {node: '>=14.0.0'} peerDependencies: react: '*' react-dom: '*' react-is: '*' - styled-components: ^5.2 || ^6 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 dependencies: '@floating-ui/react-dom': 2.1.1(react-dom@18.3.1)(react@18.3.1) '@sanity/color': 3.0.6 @@ -7355,7 +7414,7 @@ packages: react-dom: 18.3.1(react@18.3.1) react-is: 18.3.1 react-refractor: 2.2.0(react@18.3.1) - styled-components: 6.1.11(react-dom@18.3.1)(react@18.3.1) + styled-components: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) /@sanity/util@3.37.2(debug@4.3.5): resolution: {integrity: sha512-hq0eLjyV2iaOm9ivtPw12YTQ4QsE3jnV/Ui0zhclEhu8Go5JiaEhFt2+WM2lLGRH6qcSA414QbsCNCcyhJL6rA==} @@ -7960,17 +8019,17 @@ packages: /@types/lodash-es@4.17.12: resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==} dependencies: - '@types/lodash': 4.17.0 + '@types/lodash': 4.17.6 dev: false /@types/lodash.isequal@4.5.8: resolution: {integrity: sha512-uput6pg4E/tj2LGxCZo9+y27JNyB2OZuuI/T5F+ylVDYuqICLG2/ktjxx0v6GvVntAf8TvEzeQLcV0ffRirXuA==} dependencies: - '@types/lodash': 4.17.0 + '@types/lodash': 4.17.6 dev: false - /@types/lodash@4.17.0: - resolution: {integrity: sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==} + /@types/lodash@4.17.6: + resolution: {integrity: sha512-OpXEVoCKSS3lQqjx9GGGOapBeuW5eUboYHRlHP9urXPX25IKZ6AnP5ZRxtVf63iieUbsHxLn8NQ5Nlftc6yzAA==} /@types/log-symbols@2.0.0: resolution: {integrity: sha512-YJhbp0sz3egFFKl3BcCNPQKzuGFOP4PACcsifhK6ROGnJUW9ViYLuLybQ9GQZm7Zejy3tkGuiXYMq3GiyGkU4g==} @@ -8642,6 +8701,19 @@ packages: resolution: {integrity: sha512-er8kaywRTjBTlaBgYynd3Fe/OPUfL3GuRMJOyWRlZ3V7EX4A6pryXTf42FL1ZXjOkDPz+/exAUe03kmb02MLOA==} dev: true + /@web/rollup-plugin-import-meta-assets@2.2.1(rollup@4.18.0): + resolution: {integrity: sha512-nG7nUQqSJWdl63pBTmnIElJuFi2V1x9eVje19BJuFvfz266jSmZtX3m30ncb7fOJxQt3/ge+FVL8tuNI9+63dQ==} + engines: {node: '>=18.0.0'} + dependencies: + '@rollup/plugin-dynamic-import-vars': 2.1.2(rollup@4.18.0) + '@rollup/pluginutils': 5.1.0(rollup@4.18.0) + estree-walker: 2.0.2 + globby: 13.2.2 + magic-string: 0.30.9 + transitivePeerDependencies: + - rollup + dev: false + /@yarnpkg/lockfile@1.1.0: resolution: {integrity: sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==} dev: true @@ -9093,6 +9165,11 @@ packages: engines: {node: '>=8'} dev: true + /astring@1.8.6: + resolution: {integrity: sha512-ISvCdHdlTDlH5IpxQJIex7BWBywFWgjJSVdwst+/iQCoEYnyOaQ95+X1JGshuBjGp6nxKUy1jMgE3zPqN7fQdg==} + hasBin: true + dev: false + /async-each@1.0.6: resolution: {integrity: sha512-c646jH1avxr+aVpndVMeAfYw7wAa6idufrlN3LPA4PmKS0QEGp6PIC9nwz0WQkkvBGAMEki3pFdtxaF39J9vvg==} dev: true @@ -9247,22 +9324,6 @@ packages: zod: 3.23.8 zod-validation-error: 2.1.0(zod@3.23.8) - /babel-plugin-styled-components@2.1.4(@babel/core@7.24.7)(styled-components@5.3.11)(supports-color@5.5.0): - resolution: {integrity: sha512-Xgp9g+A/cG47sUyRwwYxGM4bR/jDRg5N6it/8+HxCnbT5XNKSKDT9xm4oag/osgqjC2It/vH0yXsomOG6k558g==} - peerDependencies: - styled-components: '>= 2' - dependencies: - '@babel/helper-annotate-as-pure': 7.24.7 - '@babel/helper-module-imports': 7.24.7(supports-color@5.5.0) - '@babel/plugin-syntax-jsx': 7.24.7(@babel/core@7.24.7) - lodash: 4.17.21 - picomatch: 2.3.1 - styled-components: 5.3.11(@babel/core@7.24.7)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1) - transitivePeerDependencies: - - '@babel/core' - - supports-color - dev: false - /babel-preset-current-node-syntax@1.0.1(@babel/core@7.24.7): resolution: {integrity: sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==} peerDependencies: @@ -10551,19 +10612,6 @@ packages: ms: 2.1.3 dev: true - /debug@4.3.5(supports-color@5.5.0): - resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - dependencies: - ms: 2.1.2 - supports-color: 5.5.0 - dev: false - /debug@4.3.5(supports-color@9.4.0): resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} engines: {node: '>=6.0'} @@ -12936,7 +12984,6 @@ packages: ignore: 5.3.1 merge2: 1.4.1 slash: 4.0.0 - dev: true /globrex@0.1.2: resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} @@ -13347,8 +13394,8 @@ packages: resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==} dev: false - /immer@10.0.4: - resolution: {integrity: sha512-cuBuGK40P/sk5IzWa9QPUaAdvPHjkk1c+xYsd9oZw+YQQEV+10G0P5uMpGctZZKnyQ+ibRO08bD25nWLmYi2pw==} + /immer@10.1.1: + resolution: {integrity: sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==} dev: false /import-fresh@3.3.0: @@ -17210,8 +17257,8 @@ packages: dependencies: side-channel: 1.0.6 - /qs@6.12.3: - resolution: {integrity: sha512-AWJm14H1vVaO/iNZ4/hO+HyaTehuy9nRqVdkTqlJt0HWvBiBIEXFmb4C0DGeYo3Xes9rrEW+TxHsaigCbN5ICQ==} + /qs@6.12.2: + resolution: {integrity: sha512-x+NLUpx9SYrcwXtX7ob1gnkSems4i/mGZX5SlYxwIau6RrUSODO89TR/XDGGpn5RPWSYIB+aSfuSlV5+CmbTBg==} engines: {node: '>=0.6'} dependencies: side-channel: 1.0.6 @@ -17459,6 +17506,17 @@ packages: resolution: {integrity: sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==} engines: {node: '>=0.10.0'} + /react-rx@3.0.0(react@18.3.1)(rxjs@7.8.1): + resolution: {integrity: sha512-hu2h9ggCAOHkM/Xs+AcsF4nCp95+TyLMSiwXbQjrqitGFuNiZ4PeAC1Y9Fc1YiZrSIF+l6HKi5xuE8Sn384EoQ==} + peerDependencies: + react: '*' + rxjs: ^7 + dependencies: + observable-callback: 1.0.3(rxjs@7.8.1) + react: 18.3.1 + rxjs: 7.8.1 + dev: false + /react-rx@3.1.1(react@18.3.1)(rxjs@7.8.1): resolution: {integrity: sha512-vfNUuBQc7q6+RkeOBWQHT2/GyFP9uxULfmPlQWAHaDJw1vZykfsDpzVu2gFMPUd5PVEebT9XPRIOYXa7MOoUdQ==} peerDependencies: @@ -18074,56 +18132,56 @@ packages: '@sanity/diff-match-patch': 3.1.1 dev: false - /sanity-plugin-hotspot-array@2.0.0(@sanity/ui@2.6.3)(react-dom@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11): + /sanity-plugin-hotspot-array@2.0.0(@sanity/ui@2.6.4-canary.0)(react-dom@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0): resolution: {integrity: sha512-y+FP4JgRaIKO17cBMyzCCVcxwl3fh7DXEp99QlvZSWUFi3NJJg2ZXFIXc2Om66HNkprfH2ORzEmEZMuDShtlTg==} engines: {node: '>=18'} peerDependencies: - '@sanity/ui': ^2.0.0 + '@sanity/ui': 2.6.4-canary.0 react: '*' sanity: ^3.0.0 - styled-components: ^6.1 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 dependencies: '@sanity/asset-utils': 1.3.0 '@sanity/image-url': 1.0.2 '@sanity/incompatible-plugin': 1.0.4(react-dom@18.3.1)(react@18.3.1) - '@sanity/ui': 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + '@sanity/ui': 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sanity/util': 3.49.0 '@types/lodash-es': 4.17.12 framer-motion: 11.0.8(react-dom@18.3.1)(react@18.3.1) lodash-es: 4.17.21 react: 18.3.1 sanity: link:packages/sanity - styled-components: 6.1.11(react-dom@18.3.1)(react@18.3.1) + styled-components: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) transitivePeerDependencies: - debug - react-dom dev: false - /sanity-plugin-mux-input@2.3.6(@types/react@18.3.3)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(styled-components@6.1.11): + /sanity-plugin-mux-input@2.3.6(@types/react@18.3.3)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(sanity@packages+sanity)(speedy-styled-components@6.1.12-canary.0): resolution: {integrity: sha512-qBiQE6VuVgJ42mfWbw+9T6UVsr5VyRZvs41Qew32XSb0vPlP19yb3eI2Vxxv5ENNTyhaXD5CxMQZOsv+OFADDA==} engines: {node: '>=18'} peerDependencies: react: '*' react-is: '*' sanity: ^3.42.0 - styled-components: ^5 || ^6 + styled-components: npm:speedy-styled-components@6.1.12-canary.0 dependencies: '@mux/mux-player-react': 2.7.0(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1) '@mux/upchunk': 3.4.0 '@sanity/icons': 3.3.0(react@18.3.1) '@sanity/incompatible-plugin': 1.0.4(react-dom@18.3.1)(react@18.3.1) - '@sanity/ui': 2.6.3(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(styled-components@6.1.11) + '@sanity/ui': 2.6.4-canary.0(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1)(speedy-styled-components@6.1.12-canary.0) '@sanity/uuid': 3.0.2 iso-639-1: 3.1.2 jsonwebtoken-esm: 1.0.5 lodash: 4.17.21 react: 18.3.1 react-is: 18.3.1 - react-rx: 3.1.1(react@18.3.1)(rxjs@7.8.1) + react-rx: 3.0.0(react@18.3.1)(rxjs@7.8.1) rxjs: 7.8.1 sanity: link:packages/sanity scroll-into-view-if-needed: 3.1.0 - styled-components: 6.1.11(react-dom@18.3.1)(react@18.3.1) + styled-components: /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1) suspend-react: 0.1.3(react@18.3.1) swr: 2.2.5(react@18.3.1) type-fest: 4.20.1 @@ -18417,7 +18475,7 @@ packages: dependencies: '@juggle/resize-observer': 3.4.0 '@types/is-hotkey': 0.1.10 - '@types/lodash': 4.17.0 + '@types/lodash': 4.17.6 direction: 1.0.4 is-hotkey: 0.2.0 is-plain-object: 5.0.0 @@ -18432,7 +18490,7 @@ packages: /slate@0.100.0: resolution: {integrity: sha512-cK+xwLBrbQof4rEfTzgC8loBWsDFEXq8nOBY7QahwY59Zq4bsBNcwiMw2VIzTv+WGNsmyHp4eAk/HJbz2aAUkQ==} dependencies: - immer: 10.0.4 + immer: 10.1.1 is-plain-object: 5.0.0 tiny-warning: 1.0.3 dev: false @@ -18621,6 +18679,65 @@ packages: /speedometer@1.0.0: resolution: {integrity: sha512-lgxErLl/7A5+vgIIXsh9MbeukOaCb2axgQ+bKCdIE+ibNT4XNYGNCR1qFEGq6F+YDASXK3Fh/c5FgtZchFolxw==} + /speedy-styled-components@6.1.12-canary.0(react-dom@18.3.1)(react@18.3.1): + resolution: {integrity: sha512-cyZW8M4v9cPKs4xRclK8CfIlOUj77UhGw8Oc7DSN6cY6gkI47HlmetiZZ+RQbpWq2ozfETMDXD1ZjpR/NMQPng==} + engines: {node: '>= 16'} + peerDependencies: + react: '*' + react-dom: '*' + dependencies: + '@emotion/is-prop-valid': 1.2.2 + '@emotion/unitless': 0.8.1 + '@types/stylis': 4.2.5 + css-to-react-native: 3.2.0 + csstype: 3.1.3 + postcss: 8.4.38 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + shallowequal: 1.1.0 + stylis: 4.3.2 + tslib: 2.6.2 + + /speedy-styled-components@6.1.12-canary.0(react-dom@19.0.0-rc-38e3b23483-20240529)(react@19.0.0-rc-38e3b23483-20240529): + resolution: {integrity: sha512-cyZW8M4v9cPKs4xRclK8CfIlOUj77UhGw8Oc7DSN6cY6gkI47HlmetiZZ+RQbpWq2ozfETMDXD1ZjpR/NMQPng==} + engines: {node: '>= 16'} + peerDependencies: + react: '*' + react-dom: '*' + dependencies: + '@emotion/is-prop-valid': 1.2.2 + '@emotion/unitless': 0.8.1 + '@types/stylis': 4.2.5 + css-to-react-native: 3.2.0 + csstype: 3.1.3 + postcss: 8.4.38 + react: 19.0.0-rc-38e3b23483-20240529 + react-dom: 19.0.0-rc-38e3b23483-20240529(react@19.0.0-rc-38e3b23483-20240529) + shallowequal: 1.1.0 + stylis: 4.3.2 + tslib: 2.6.2 + dev: false + + /speedy-styled-components@6.1.12-canary.0(react-dom@19.0.0-rc-f994737d14-20240522)(react@19.0.0-rc-f994737d14-20240522): + resolution: {integrity: sha512-cyZW8M4v9cPKs4xRclK8CfIlOUj77UhGw8Oc7DSN6cY6gkI47HlmetiZZ+RQbpWq2ozfETMDXD1ZjpR/NMQPng==} + engines: {node: '>= 16'} + peerDependencies: + react: '*' + react-dom: '*' + dependencies: + '@emotion/is-prop-valid': 1.2.2 + '@emotion/unitless': 0.8.1 + '@types/stylis': 4.2.5 + css-to-react-native: 3.2.0 + csstype: 3.1.3 + postcss: 8.4.38 + react: 19.0.0-rc-f994737d14-20240522 + react-dom: 19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522) + shallowequal: 1.1.0 + stylis: 4.3.2 + tslib: 2.6.2 + dev: false + /split-string@3.1.0: resolution: {integrity: sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==} engines: {node: '>=0.10.0'} @@ -18921,90 +19038,6 @@ packages: resolution: {integrity: sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==} dev: false - /styled-components@5.3.11(@babel/core@7.24.7)(react-dom@18.3.1)(react-is@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw==} - engines: {node: '>=10'} - peerDependencies: - react: '*' - react-dom: '*' - react-is: '*' - dependencies: - '@babel/helper-module-imports': 7.24.7(supports-color@5.5.0) - '@babel/traverse': 7.24.7(supports-color@5.5.0) - '@emotion/is-prop-valid': 1.2.2 - '@emotion/stylis': 0.8.5 - '@emotion/unitless': 0.7.5 - babel-plugin-styled-components: 2.1.4(@babel/core@7.24.7)(styled-components@5.3.11)(supports-color@5.5.0) - css-to-react-native: 3.2.0 - hoist-non-react-statics: 3.3.2 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - react-is: 18.3.1 - shallowequal: 1.1.0 - supports-color: 5.5.0 - transitivePeerDependencies: - - '@babel/core' - dev: false - - /styled-components@6.1.11(react-dom@18.3.1)(react@18.3.1): - resolution: {integrity: sha512-Ui0jXPzbp1phYij90h12ksljKGqF8ncGx+pjrNPsSPhbUUjWT2tD1FwGo2LF6USCnbrsIhNngDfodhxbegfEOA==} - engines: {node: '>= 16'} - peerDependencies: - react: '*' - react-dom: '*' - dependencies: - '@emotion/is-prop-valid': 1.2.2 - '@emotion/unitless': 0.8.1 - '@types/stylis': 4.2.5 - css-to-react-native: 3.2.0 - csstype: 3.1.3 - postcss: 8.4.38 - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - shallowequal: 1.1.0 - stylis: 4.3.2 - tslib: 2.6.2 - - /styled-components@6.1.11(react-dom@19.0.0-rc-38e3b23483-20240529)(react@19.0.0-rc-38e3b23483-20240529): - resolution: {integrity: sha512-Ui0jXPzbp1phYij90h12ksljKGqF8ncGx+pjrNPsSPhbUUjWT2tD1FwGo2LF6USCnbrsIhNngDfodhxbegfEOA==} - engines: {node: '>= 16'} - peerDependencies: - react: '*' - react-dom: '*' - dependencies: - '@emotion/is-prop-valid': 1.2.2 - '@emotion/unitless': 0.8.1 - '@types/stylis': 4.2.5 - css-to-react-native: 3.2.0 - csstype: 3.1.3 - postcss: 8.4.38 - react: 19.0.0-rc-38e3b23483-20240529 - react-dom: 19.0.0-rc-38e3b23483-20240529(react@19.0.0-rc-38e3b23483-20240529) - shallowequal: 1.1.0 - stylis: 4.3.2 - tslib: 2.6.2 - dev: false - - /styled-components@6.1.11(react-dom@19.0.0-rc-f994737d14-20240522)(react@19.0.0-rc-f994737d14-20240522): - resolution: {integrity: sha512-Ui0jXPzbp1phYij90h12ksljKGqF8ncGx+pjrNPsSPhbUUjWT2tD1FwGo2LF6USCnbrsIhNngDfodhxbegfEOA==} - engines: {node: '>= 16'} - peerDependencies: - react: '*' - react-dom: '*' - dependencies: - '@emotion/is-prop-valid': 1.2.2 - '@emotion/unitless': 0.8.1 - '@types/stylis': 4.2.5 - css-to-react-native: 3.2.0 - csstype: 3.1.3 - postcss: 8.4.38 - react: 19.0.0-rc-f994737d14-20240522 - react-dom: 19.0.0-rc-f994737d14-20240522(react@19.0.0-rc-f994737d14-20240522) - shallowequal: 1.1.0 - stylis: 4.3.2 - tslib: 2.6.2 - dev: false - /styled-jsx@5.1.1(@babel/core@7.24.7)(react@18.3.1): resolution: {integrity: sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==} engines: {node: '>= 12.0.0'} diff --git a/turbo.json b/turbo.json index 758a808e7ed..d7568c6d718 100644 --- a/turbo.json +++ b/turbo.json @@ -35,7 +35,7 @@ "*.js" ], "dependsOn": [ - "^build" + "^build", "build:web-workers" ], "outputLogs": "new-only" }, @@ -48,6 +48,12 @@ ], "outputLogs": "new-only" }, + "build:web-workers": { + "outputs": [ + "web-workers/**" + ], + "outputLogs": "new-only" + }, "check:types": { "outputs": [], "dependsOn": [