diff --git a/hosting/couchdb/Dockerfile b/hosting/couchdb/Dockerfile
index f83df7038b..36abc2dd19 100644
--- a/hosting/couchdb/Dockerfile
+++ b/hosting/couchdb/Dockerfile
@@ -1,4 +1,101 @@
-FROM couchdb:3.2.1
+# Modified from https://github.com/apache/couchdb-docker/blob/main/3.3.3/Dockerfile
+#
+# Everything in this `base` image is adapted from the official `couchdb` image's
+# Dockerfile. Only modifications related to upgrading from Debian bullseye to
+# bookworm have been included. The `runner` image contains Budibase's
+# customisations to the image, e.g. adding Clouseau.
+FROM node:20-slim AS base
+
+# Add CouchDB user account to make sure the IDs are assigned consistently
+RUN groupadd -g 5984 -r couchdb && useradd -u 5984 -d /opt/couchdb -g couchdb couchdb
+
+# be sure GPG and apt-transport-https are available and functional
+RUN set -ex; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends \
+ apt-transport-https \
+ ca-certificates \
+ dirmngr \
+ gnupg \
+ ; \
+ rm -rf /var/lib/apt/lists/*
+
+# grab tini for signal handling and zombie reaping
+# see https://github.com/apache/couchdb-docker/pull/28#discussion_r141112407
+RUN set -eux; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends tini; \
+ rm -rf /var/lib/apt/lists/*; \
+ tini --version
+
+# http://docs.couchdb.org/en/latest/install/unix.html#installing-the-apache-couchdb-packages
+ENV GPG_COUCH_KEY \
+# gpg: rsa8192 205-01-19 The Apache Software Foundation (Package repository signing key)
+ 390EF70BB1EA12B2773962950EE62FB37A00258D
+RUN set -eux; \
+ apt-get update; \
+ apt-get install -y curl; \
+ export GNUPGHOME="$(mktemp -d)"; \
+ curl -fL -o keys.asc https://couchdb.apache.org/repo/keys.asc; \
+ gpg --batch --import keys.asc; \
+ gpg --batch --export "${GPG_COUCH_KEY}" > /usr/share/keyrings/couchdb-archive-keyring.gpg; \
+ command -v gpgconf && gpgconf --kill all || :; \
+ rm -rf "$GNUPGHOME"; \
+ apt-key list; \
+ apt purge -y --autoremove curl; \
+ rm -rf /var/lib/apt/lists/*
+
+ENV COUCHDB_VERSION 3.3.3
+
+RUN . /etc/os-release; \
+ echo "deb [signed-by=/usr/share/keyrings/couchdb-archive-keyring.gpg] https://apache.jfrog.io/artifactory/couchdb-deb/ ${VERSION_CODENAME} main" | \
+ tee /etc/apt/sources.list.d/couchdb.list >/dev/null
+
+# https://github.com/apache/couchdb-pkg/blob/master/debian/README.Debian
+RUN set -eux; \
+ apt-get update; \
+ \
+ echo "couchdb couchdb/mode select none" | debconf-set-selections; \
+# we DO want recommends this time
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages \
+ couchdb="$COUCHDB_VERSION"~bookworm \
+ ; \
+# Undo symlinks to /var/log and /var/lib
+ rmdir /var/lib/couchdb /var/log/couchdb; \
+ rm /opt/couchdb/data /opt/couchdb/var/log; \
+ mkdir -p /opt/couchdb/data /opt/couchdb/var/log; \
+ chown couchdb:couchdb /opt/couchdb/data /opt/couchdb/var/log; \
+ chmod 777 /opt/couchdb/data /opt/couchdb/var/log; \
+# Remove file that sets logging to a file
+ rm /opt/couchdb/etc/default.d/10-filelog.ini; \
+# Check we own everything in /opt/couchdb. Matches the command in dockerfile_entrypoint.sh
+ find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +; \
+# Setup directories and permissions for config. Technically these could be 555 and 444 respectively
+# but we keep them as 755 and 644 for consistency with CouchDB defaults and the dockerfile_entrypoint.sh.
+ find /opt/couchdb/etc -type d ! -perm 0755 -exec chmod -f 0755 '{}' +; \
+ find /opt/couchdb/etc -type f ! -perm 0644 -exec chmod -f 0644 '{}' +; \
+# only local.d needs to be writable for the docker_entrypoint.sh
+ chmod -f 0777 /opt/couchdb/etc/local.d; \
+# apt clean-up
+ rm -rf /var/lib/apt/lists/*;
+
+# Add configuration
+COPY --chown=couchdb:couchdb couch/10-docker-default.ini /opt/couchdb/etc/default.d/
+# COPY --chown=couchdb:couchdb vm.args /opt/couchdb/etc/
+
+COPY docker-entrypoint.sh /usr/local/bin
+RUN ln -s usr/local/bin/docker-entrypoint.sh /docker-entrypoint.sh # backwards compat
+ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
+
+VOLUME /opt/couchdb/data
+
+# 5984: Main CouchDB endpoint
+# 4369: Erlang portmap daemon (epmd)
+# 9100: CouchDB cluster communication port
+EXPOSE 5984 4369 9100
+CMD ["/opt/couchdb/bin/couchdb"]
+
+FROM base as runner
ENV COUCHDB_USER admin
ENV COUCHDB_PASSWORD admin
@@ -6,9 +103,9 @@ EXPOSE 5984
RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common wget unzip curl && \
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add - && \
- apt-add-repository 'deb http://security.debian.org/debian-security bullseye-security/updates main' && \
+ apt-add-repository 'deb http://security.debian.org/debian-security bookworm-security/updates main' && \
apt-add-repository 'deb http://archive.debian.org/debian stretch-backports main' && \
- apt-add-repository 'deb https://packages.adoptium.net/artifactory/deb bullseye main' && \
+ apt-add-repository 'deb https://packages.adoptium.net/artifactory/deb bookworm main' && \
apt-get update && apt-get install -y --no-install-recommends temurin-8-jdk && \
rm -rf /var/lib/apt/lists/
diff --git a/hosting/couchdb/clouseau/clouseau.ini b/hosting/couchdb/clouseau/clouseau.ini
index 578a5acafa..014fb854f3 100644
--- a/hosting/couchdb/clouseau/clouseau.ini
+++ b/hosting/couchdb/clouseau/clouseau.ini
@@ -4,7 +4,7 @@
name=clouseau@127.0.0.1
; set this to the same distributed Erlang cookie used by the CouchDB nodes
-cookie=monster
+cookie=COUCHDB_ERLANG_COOKIE
; the path where you would like to store the search index files
dir=DATA_DIR/search
diff --git a/hosting/couchdb/couch/10-docker-default.ini b/hosting/couchdb/couch/10-docker-default.ini
new file mode 100644
index 0000000000..1aa633cbfc
--- /dev/null
+++ b/hosting/couchdb/couch/10-docker-default.ini
@@ -0,0 +1,8 @@
+; CouchDB Configuration Settings
+
+; Custom settings should be made in this file. They will override settings
+; in default.ini, but unlike changes made to default.ini, this file won't be
+; overwritten on server upgrade.
+
+[chttpd]
+bind_address = any
diff --git a/hosting/couchdb/couch/vm.args b/hosting/couchdb/couch/vm.args
index e9e4416863..11845dd6d4 100644
--- a/hosting/couchdb/couch/vm.args
+++ b/hosting/couchdb/couch/vm.args
@@ -12,7 +12,7 @@
# erlang cookie for clouseau security
-name couchdb@127.0.0.1
--setcookie monster
+-setcookie COUCHDB_ERLANG_COOKIE
# Ensure that the Erlang VM listens on a known port
-kernel inet_dist_listen_min 9100
diff --git a/hosting/couchdb/docker-entrypoint.sh b/hosting/couchdb/docker-entrypoint.sh
new file mode 100755
index 0000000000..bd709b7b73
--- /dev/null
+++ b/hosting/couchdb/docker-entrypoint.sh
@@ -0,0 +1,122 @@
+#!/bin/bash
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+set -e
+
+# first arg is `-something` or `+something`
+if [ "${1#-}" != "$1" ] || [ "${1#+}" != "$1" ]; then
+ set -- /opt/couchdb/bin/couchdb "$@"
+fi
+
+# first arg is the bare word `couchdb`
+if [ "$1" = 'couchdb' ]; then
+ shift
+ set -- /opt/couchdb/bin/couchdb "$@"
+fi
+
+if [ "$1" = '/opt/couchdb/bin/couchdb' ]; then
+ # this is where runtime configuration changes will be written.
+ # we need to explicitly touch it here in case /opt/couchdb/etc has
+ # been mounted as an external volume, in which case it won't exist.
+ # If running as the couchdb user (i.e. container starts as root),
+ # write permissions will be granted below.
+ touch /opt/couchdb/etc/local.d/docker.ini
+
+ # if user is root, assume running under the couchdb user (default)
+ # and ensure it is able to access files and directories that may be mounted externally
+ if [ "$(id -u)" = '0' ]; then
+ # Check that we own everything in /opt/couchdb and fix if necessary. We also
+ # add the `-f` flag in all the following invocations because there may be
+ # cases where some of these ownership and permissions issues are non-fatal
+ # (e.g. a config file owned by root with o+r is actually fine), and we don't
+ # to be too aggressive about crashing here ...
+ find /opt/couchdb \! \( -user couchdb -group couchdb \) -exec chown -f couchdb:couchdb '{}' +
+
+ # Ensure that data files have the correct permissions. We were previously
+ # preventing any access to these files outside of couchdb:couchdb, but it
+ # turns out that CouchDB itself does not set such restrictive permissions
+ # when it creates the files. The approach taken here ensures that the
+ # contents of the datadir have the same permissions as they had when they
+ # were initially created. This should minimize any startup delay.
+ find /opt/couchdb/data -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
+ find /opt/couchdb/data -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
+
+ # Do the same thing for configuration files and directories. Technically
+ # CouchDB only needs read access to the configuration files as all online
+ # changes will be applied to the "docker.ini" file below, but we set 644
+ # for the sake of consistency.
+ find /opt/couchdb/etc -type d ! -perm 0755 -exec chmod -f 0755 '{}' +
+ find /opt/couchdb/etc -type f ! -perm 0644 -exec chmod -f 0644 '{}' +
+ fi
+
+ if [ ! -z "$NODENAME" ] && ! grep "couchdb@" /opt/couchdb/etc/vm.args; then
+ echo "-name couchdb@$NODENAME" >> /opt/couchdb/etc/vm.args
+ fi
+
+ if [ "$COUCHDB_USER" ] && [ "$COUCHDB_PASSWORD" ]; then
+ # Create admin only if not already present
+ if ! grep -Pzoqr "\[admins\]\n$COUCHDB_USER =" /opt/couchdb/etc/local.d/*.ini /opt/couchdb/etc/local.ini; then
+ printf "\n[admins]\n%s = %s\n" "$COUCHDB_USER" "$COUCHDB_PASSWORD" >> /opt/couchdb/etc/local.d/docker.ini
+ fi
+ fi
+
+ if [ "$COUCHDB_SECRET" ]; then
+ # Set secret only if not already present
+ if ! grep -Pzoqr "\[chttpd_auth\]\nsecret =" /opt/couchdb/etc/local.d/*.ini /opt/couchdb/etc/local.ini; then
+ printf "\n[chttpd_auth]\nsecret = %s\n" "$COUCHDB_SECRET" >> /opt/couchdb/etc/local.d/docker.ini
+ fi
+ fi
+
+ if [ "$COUCHDB_ERLANG_COOKIE" ]; then
+ cookieFile='/opt/couchdb/.erlang.cookie'
+ if [ -e "$cookieFile" ]; then
+ if [ "$(cat "$cookieFile" 2>/dev/null)" != "$COUCHDB_ERLANG_COOKIE" ]; then
+ echo >&2
+ echo >&2 "warning: $cookieFile contents do not match COUCHDB_ERLANG_COOKIE"
+ echo >&2
+ fi
+ else
+ echo "$COUCHDB_ERLANG_COOKIE" > "$cookieFile"
+ fi
+ chown couchdb:couchdb "$cookieFile"
+ chmod 600 "$cookieFile"
+ fi
+
+ if [ "$(id -u)" = '0' ]; then
+ chown -f couchdb:couchdb /opt/couchdb/etc/local.d/docker.ini || true
+ fi
+
+ # if we don't find an [admins] section followed by a non-comment, display a warning
+ if ! grep -Pzoqr '\[admins\]\n[^;]\w+' /opt/couchdb/etc/default.d/*.ini /opt/couchdb/etc/local.d/*.ini /opt/couchdb/etc/local.ini; then
+ # The - option suppresses leading tabs but *not* spaces. :)
+ cat >&2 <<-'EOWARN'
+*************************************************************
+ERROR: CouchDB 3.0+ will no longer run in "Admin Party"
+ mode. You *MUST* specify an admin user and
+ password, either via your own .ini file mapped
+ into the container at /opt/couchdb/etc/local.ini
+ or inside /opt/couchdb/etc/local.d, or with
+ "-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password"
+ to set it via "docker run".
+*************************************************************
+EOWARN
+ exit 1
+ fi
+
+ if [ "$(id -u)" = '0' ]; then
+ export HOME=$(echo ~couchdb)
+ exec setpriv --reuid=couchdb --regid=couchdb --clear-groups "$@"
+ fi
+fi
+
+exec "$@"
\ No newline at end of file
diff --git a/hosting/couchdb/runner.sh b/hosting/couchdb/runner.sh
index 9f6a853ca7..aaadee6b43 100644
--- a/hosting/couchdb/runner.sh
+++ b/hosting/couchdb/runner.sh
@@ -1,6 +1,7 @@
#!/bin/bash
DATA_DIR=${DATA_DIR:-/data}
+COUCHDB_ERLANG_COOKIE=${COUCHDB_ERLANG_COOKIE:-B9CFC32C-3458-4A86-8448-B3C753991CA7}
mkdir -p ${DATA_DIR}
mkdir -p ${DATA_DIR}/couch/{dbs,views}
@@ -60,6 +61,9 @@ else
sed -i "s#DATA_DIR#/data#g" /opt/couchdb/etc/local.ini
fi
+sed -i "s#COUCHDB_ERLANG_COOKIE#${COUCHDB_ERLANG_COOKIE}#g" /opt/couchdb/etc/vm.args
+sed -i "s#COUCHDB_ERLANG_COOKIE#${COUCHDB_ERLANG_COOKIE}#g" /opt/clouseau/clouseau.ini
+
# Start Clouseau. Budibase won't function correctly without Clouseau running, it
# powers the search API endpoints which are used to do all sorts, including
# populating app grids.
diff --git a/hosting/single/Dockerfile b/hosting/single/Dockerfile
index f9044cd124..ee98b0729d 100644
--- a/hosting/single/Dockerfile
+++ b/hosting/single/Dockerfile
@@ -3,7 +3,6 @@ FROM node:20-slim as build
# install node-gyp dependencies
RUN apt-get update && apt-get install -y --no-install-recommends g++ make python3 jq
-
# copy and install dependencies
WORKDIR /app
COPY package.json .
@@ -39,10 +38,9 @@ COPY packages/worker/pm2.config.js packages/worker/pm2.config.js
COPY packages/string-templates packages/string-templates
-FROM budibase/couchdb as runner
+FROM budibase/couchdb:v3.3.3 as runner
ARG TARGETARCH
ENV TARGETARCH $TARGETARCH
-ENV NODE_MAJOR 20
#TARGETBUILD can be set to single (for single docker image) or aas (for azure app service)
# e.g. docker build --build-arg TARGETBUILD=aas ....
ARG TARGETBUILD=single
@@ -60,10 +58,8 @@ RUN apt install -y software-properties-common apt-transport-https ca-certificate
&& apt install postgresql-client-15 -y \
&& apt remove software-properties-common apt-transport-https gpg -y
-# install other dependencies, nodejs, oracle requirements, jdk8, redis, nginx
-WORKDIR /nodejs
-COPY scripts/install-node.sh ./install.sh
-RUN chmod +x install.sh && ./install.sh
+# We use pm2 in order to run multiple node processes in a single container
+RUN npm install --global pm2
# setup nginx
COPY hosting/single/nginx/nginx.conf /etc/nginx
diff --git a/hosting/single/runner.sh b/hosting/single/runner.sh
index 886da4c916..3126eedfb1 100644
--- a/hosting/single/runner.sh
+++ b/hosting/single/runner.sh
@@ -97,10 +97,12 @@ fi
sleep 10
pushd app
-pm2 start -l /dev/stdout --name app "yarn run:docker"
+pm2 start --name app "yarn run:docker"
popd
pushd worker
-pm2 start -l /dev/stdout --name worker "yarn run:docker"
+pm2 start --name worker "yarn run:docker"
popd
echo "end of runner.sh, sleeping ..."
+
+tail -f $HOME/.pm2/logs/*.log
sleep infinity
diff --git a/lerna.json b/lerna.json
index 62068e25a8..843d64fe67 100644
--- a/lerna.json
+++ b/lerna.json
@@ -1,5 +1,5 @@
{
- "version": "2.19.6",
+ "version": "2.20.6",
"npmClient": "yarn",
"packages": [
"packages/*",
diff --git a/packages/bbui/src/Layout/Page.svelte b/packages/bbui/src/Layout/Page.svelte
index 57c264231b..2169a12459 100644
--- a/packages/bbui/src/Layout/Page.svelte
+++ b/packages/bbui/src/Layout/Page.svelte
@@ -43,6 +43,7 @@
flex-direction: row;
justify-content: flex-start;
align-items: stretch;
+ overflow-y: scroll !important;
flex: 1 1 auto;
overflow-x: hidden;
}
diff --git a/packages/bbui/src/Typography/Body.svelte b/packages/bbui/src/Typography/Body.svelte
index 71b4dca248..2123eeee95 100644
--- a/packages/bbui/src/Typography/Body.svelte
+++ b/packages/bbui/src/Typography/Body.svelte
@@ -20,3 +20,9 @@
>
+
+
diff --git a/packages/bbui/src/Typography/Heading.svelte b/packages/bbui/src/Typography/Heading.svelte
index c0d0571143..50522fffc3 100644
--- a/packages/bbui/src/Typography/Heading.svelte
+++ b/packages/bbui/src/Typography/Heading.svelte
@@ -21,4 +21,8 @@
h1 {
font-family: var(--font-accent);
}
+
+ h1 {
+ text-wrap: balance;
+ }
diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte
index 4c458a5627..1ace6c0f00 100644
--- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte
+++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte
@@ -130,6 +130,7 @@
flex-grow: 1;
padding: 23px 23px 80px;
box-sizing: border-box;
+ overflow-x: hidden;
}
.header.scrolling {
diff --git a/packages/builder/src/components/design/settings/controls/GridColumnConfiguration/FieldSetting.svelte b/packages/builder/src/components/design/settings/controls/GridColumnConfiguration/FieldSetting.svelte
index 3f2afbfe8d..668f2f7d59 100644
--- a/packages/builder/src/components/design/settings/controls/GridColumnConfiguration/FieldSetting.svelte
+++ b/packages/builder/src/components/design/settings/controls/GridColumnConfiguration/FieldSetting.svelte
@@ -1,15 +1,25 @@
@@ -42,7 +45,7 @@
on:change
>
-
+
{item.field}
diff --git a/packages/builder/src/pages/builder/app/[application]/data/new.svelte b/packages/builder/src/pages/builder/app/[application]/data/new.svelte
index c07a9f563d..20efd3667b 100644
--- a/packages/builder/src/pages/builder/app/[application]/data/new.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/data/new.svelte
@@ -77,7 +77,7 @@
internalTableModal.show({ promptUpload: true })}
- title="Upload data"
+ title="Upload CSV / JSON"
description="Non-relational"
{disabled}
>
diff --git a/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte b/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte
index b12efd6f03..59a791538a 100644
--- a/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte
+++ b/packages/builder/src/pages/builder/portal/_components/UpgradeButton.svelte
@@ -10,7 +10,7 @@
{#if $admin.cloud && $auth?.user?.accountPortalAccess}
{
window.open($admin.accountPortalUrl + "/portal/upgrade", "_blank")
@@ -21,7 +21,7 @@
{:else if !$admin.cloud && sdk.users.isAdmin($auth.user)}
$goto("/builder/portal/account/upgrade")}
on:click
>
diff --git a/packages/builder/src/pages/builder/portal/settings/diagnostics.svelte b/packages/builder/src/pages/builder/portal/settings/diagnostics.svelte
index 3442d39a68..8cc35903e1 100644
--- a/packages/builder/src/pages/builder/portal/settings/diagnostics.svelte
+++ b/packages/builder/src/pages/builder/portal/settings/diagnostics.svelte
@@ -49,10 +49,13 @@
{#if sdk.users.isAdmin($auth.user) && diagnosticInfo}
-
+
Diagnostics
- Please include this diagnostic information in support requests and github issues
- by clicking the button on the top right to copy to clipboard.
+
+ Please include this diagnostic information in support requests and
+ github issues by clicking the button on the top right to copy to
+ clipboard.
+
diff --git a/packages/builder/src/stores/builder/queries.js b/packages/builder/src/stores/builder/queries.js
index 7f5f83a792..32e8501452 100644
--- a/packages/builder/src/stores/builder/queries.js
+++ b/packages/builder/src/stores/builder/queries.js
@@ -75,17 +75,7 @@ export function createQueriesStore() {
}
const preview = async query => {
- const parameters = query.parameters.reduce(
- (acc, next) => ({
- ...acc,
- [next.name]: next.default,
- }),
- {}
- )
- const result = await API.previewQuery({
- ...query,
- parameters,
- })
+ const result = await API.previewQuery(query)
// Assume all the fields are strings and create a basic schema from the
// unique fields returned by the server
const schema = {}
diff --git a/packages/client/manifest.json b/packages/client/manifest.json
index 7faf7a02e2..43b75ebe26 100644
--- a/packages/client/manifest.json
+++ b/packages/client/manifest.json
@@ -89,13 +89,13 @@
{
"label": "Column",
"value": "column",
- "barIcon": "ViewColumn",
+ "barIcon": "TableSelectColumn",
"barTitle": "Column layout"
},
{
"label": "Row",
"value": "row",
- "barIcon": "ViewRow",
+ "barIcon": "TableSelectRow",
"barTitle": "Row layout"
}
],
@@ -298,13 +298,13 @@
{
"label": "Column",
"value": "column",
- "barIcon": "ViewColumn",
+ "barIcon": "TableSelectColumn",
"barTitle": "Column layout"
},
{
"label": "Row",
"value": "row",
- "barIcon": "ViewRow",
+ "barIcon": "TableSelectRow",
"barTitle": "Row layout"
}
],
@@ -460,6 +460,10 @@
"label": "Variant",
"key": "type",
"options": [
+ {
+ "label": "Action",
+ "value": "cta"
+ },
{
"label": "Primary",
"value": "primary"
@@ -468,10 +472,6 @@
"label": "Secondary",
"value": "secondary"
},
- {
- "label": "Action",
- "value": "cta"
- },
{
"label": "Warning",
"value": "warning"
@@ -481,7 +481,7 @@
"value": "overBackground"
}
],
- "defaultValue": "primary"
+ "defaultValue": "cta"
},
{
"type": "select",
@@ -602,13 +602,13 @@
{
"label": "Column",
"value": "column",
- "barIcon": "ViewColumn",
+ "barIcon": "TableSelectColumn",
"barTitle": "Column layout"
},
{
"label": "Row",
"value": "row",
- "barIcon": "ViewRow",
+ "barIcon": "TableSelectRow",
"barTitle": "Row layout"
}
],
@@ -5917,13 +5917,13 @@
{
"label": "Column",
"value": "column",
- "barIcon": "ViewRow",
+ "barIcon": "TableSelectColumn",
"barTitle": "Column layout"
},
{
"label": "Row",
"value": "row",
- "barIcon": "ViewColumn",
+ "barIcon": "TableSelectRow",
"barTitle": "Row layout"
}
],
diff --git a/packages/client/src/components/app/Button.svelte b/packages/client/src/components/app/Button.svelte
index a074986342..361e64a983 100644
--- a/packages/client/src/components/app/Button.svelte
+++ b/packages/client/src/components/app/Button.svelte
@@ -11,7 +11,7 @@
export let text = ""
export let onClick
export let size = "M"
- export let type = "primary"
+ export let type = "cta"
export let quiet = false
// For internal use only for now - not defined in the manifest
diff --git a/packages/pro b/packages/pro
index 336bf2184c..60e47a8249 160000
--- a/packages/pro
+++ b/packages/pro
@@ -1 +1 @@
-Subproject commit 336bf2184cf632fdc2bffbad5628e8b15dd381bd
+Subproject commit 60e47a8249fd6291a6bc20fe3fe6776b11938fa1
diff --git a/packages/server/package.json b/packages/server/package.json
index e600e36bd3..79daf1ba4b 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -13,8 +13,8 @@
"build": "node ./scripts/build.js",
"postbuild": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client && copyfiles -f ../../yarn.lock ./dist/",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
- "build:isolated-vm-lib:string-templates": "esbuild --minify --bundle src/jsRunner/bundles/index-helpers.ts --outfile=src/jsRunner/bundles/index-helpers.ivm.bundle.js --platform=node --format=esm --external:handlebars",
- "build:isolated-vm-lib:bson": "esbuild --minify --bundle src/jsRunner/bundles/bsonPackage.ts --outfile=src/jsRunner/bundles/bson.ivm.bundle.js --platform=node --format=esm",
+ "build:isolated-vm-lib:string-templates": "esbuild --minify --bundle src/jsRunner/bundles/index-helpers.ts --outfile=src/jsRunner/bundles/index-helpers.ivm.bundle.js --platform=node --format=iife --external:handlebars --global-name=helpers",
+ "build:isolated-vm-lib:bson": "esbuild --minify --bundle src/jsRunner/bundles/bsonPackage.ts --outfile=src/jsRunner/bundles/bson.ivm.bundle.js --platform=node --format=iife --global-name=bson",
"build:isolated-vm-libs": "yarn build:isolated-vm-lib:string-templates && yarn build:isolated-vm-lib:bson",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"debug": "yarn build && node --expose-gc --inspect=9222 dist/index.js",
@@ -114,7 +114,6 @@
"undici-types": "^6.0.1",
"uuid": "^8.3.2",
"validate.js": "0.13.1",
- "vm2": "^3.9.19",
"worker-farm": "1.7.0",
"xml2js": "0.5.0"
},
diff --git a/packages/server/src/api/controllers/query/index.ts b/packages/server/src/api/controllers/query/index.ts
index 89330f3216..768c921150 100644
--- a/packages/server/src/api/controllers/query/index.ts
+++ b/packages/server/src/api/controllers/query/index.ts
@@ -20,6 +20,7 @@ import {
type ExecuteQueryRequest,
type ExecuteQueryResponse,
type Row,
+ QueryParameter,
} from "@budibase/types"
import { ValidQueryNameRegex, utils as JsonUtils } from "@budibase/shared-core"
@@ -118,6 +119,21 @@ function getAuthConfig(ctx: UserCtx) {
return authConfigCtx
}
+function enrichParameters(
+ queryParameters: QueryParameter[],
+ requestParameters: { [key: string]: string } = {}
+): {
+ [key: string]: string
+} {
+ // make sure parameters are fully enriched with defaults
+ for (let parameter of queryParameters) {
+ if (!requestParameters[parameter.name]) {
+ requestParameters[parameter.name] = parameter.default
+ }
+ }
+ return requestParameters
+}
+
export async function preview(ctx: UserCtx) {
const { datasource, envVars } = await sdk.datasources.getWithEnvVars(
ctx.request.body.datasourceId
@@ -142,6 +158,68 @@ export async function preview(ctx: UserCtx) {
const authConfigCtx: any = getAuthConfig(ctx)
+ function getFieldMetadata(field: any, key: string): QuerySchema {
+ const makeQuerySchema = (
+ type: FieldType,
+ name: string,
+ subtype?: string
+ ): QuerySchema => ({
+ type,
+ name,
+ subtype,
+ })
+ // Because custom queries have no fixed schema, we dynamically determine the schema,
+ // however types cannot be determined from null. We have no 'unknown' type, so we default to string.
+ let type = typeof field,
+ fieldMetadata = makeQuerySchema(FieldType.STRING, key)
+ if (field != null)
+ switch (type) {
+ case "boolean":
+ fieldMetadata = makeQuerySchema(FieldType.BOOLEAN, key)
+ break
+ case "object":
+ if (field instanceof Date) {
+ fieldMetadata = makeQuerySchema(FieldType.DATETIME, key)
+ } else if (Array.isArray(field)) {
+ if (field.some(item => JsonUtils.hasSchema(item))) {
+ fieldMetadata = makeQuerySchema(
+ FieldType.JSON,
+ key,
+ JsonFieldSubType.ARRAY
+ )
+ } else {
+ fieldMetadata = makeQuerySchema(FieldType.ARRAY, key)
+ }
+ } else {
+ fieldMetadata = makeQuerySchema(FieldType.JSON, key)
+ }
+ break
+ case "number":
+ fieldMetadata = makeQuerySchema(FieldType.NUMBER, key)
+ break
+ }
+ return fieldMetadata
+ }
+
+ function buildNestedSchema(
+ nestedSchemaFields: {
+ [key: string]: Record
+ },
+ key: string,
+ fieldArray: any[]
+ ) {
+ let schema: { [key: string]: any } = {}
+ // build the schema by aggregating all row objects in the array
+ for (const item of fieldArray) {
+ if (JsonUtils.hasSchema(item)) {
+ for (const [key, value] of Object.entries(item)) {
+ schema[key] = getFieldMetadata(value, key)
+ }
+ }
+ }
+ nestedSchemaFields[key] = schema
+ }
+
function getSchemaFields(
rows: any[],
keys: string[]
@@ -155,51 +233,16 @@ export async function preview(ctx: UserCtx) {
const nestedSchemaFields: {
[key: string]: Record
} = {}
- const makeQuerySchema = (
- type: FieldType,
- name: string,
- subtype?: string
- ): QuerySchema => ({
- type,
- name,
- subtype,
- })
if (rows?.length > 0) {
- for (let key of [...new Set(keys)] as string[]) {
- const field = rows[0][key]
- let type = typeof field,
- fieldMetadata = makeQuerySchema(FieldType.STRING, key)
- if (field)
- switch (type) {
- case "boolean":
- fieldMetadata = makeQuerySchema(FieldType.BOOLEAN, key)
- break
- case "object":
- if (field instanceof Date) {
- fieldMetadata = makeQuerySchema(FieldType.DATETIME, key)
- } else if (Array.isArray(field)) {
- if (JsonUtils.hasSchema(field[0])) {
- fieldMetadata = makeQuerySchema(
- FieldType.JSON,
- key,
- JsonFieldSubType.ARRAY
- )
- } else {
- fieldMetadata = makeQuerySchema(FieldType.ARRAY, key)
- }
- nestedSchemaFields[key] = getSchemaFields(
- field,
- Object.keys(field[0])
- ).previewSchema
- } else {
- fieldMetadata = makeQuerySchema(FieldType.JSON, key)
- }
- break
- case "number":
- fieldMetadata = makeQuerySchema(FieldType.NUMBER, key)
- break
- }
+ for (let key of new Set(keys)) {
+ const fieldMetadata = getFieldMetadata(rows[0][key], key)
previewSchema[key] = fieldMetadata
+ if (
+ fieldMetadata.type === FieldType.JSON &&
+ fieldMetadata.subtype === JsonFieldSubType.ARRAY
+ ) {
+ buildNestedSchema(nestedSchemaFields, key, rows[0][key])
+ }
}
}
return { previewSchema, nestedSchemaFields }
@@ -211,7 +254,7 @@ export async function preview(ctx: UserCtx) {
datasource,
queryVerb,
fields,
- parameters,
+ parameters: enrichParameters(parameters),
transformer,
queryId,
schema,
@@ -266,15 +309,6 @@ async function execute(
if (!opts.isAutomation) {
authConfigCtx = getAuthConfig(ctx)
}
- const enrichedParameters = ctx.request.body.parameters || {}
- // make sure parameters are fully enriched with defaults
- if (query && query.parameters) {
- for (let parameter of query.parameters) {
- if (!enrichedParameters[parameter.name]) {
- enrichedParameters[parameter.name] = parameter.default
- }
- }
- }
// call the relevant CRUD method on the integration class
try {
@@ -284,7 +318,10 @@ async function execute(
queryVerb: query.queryVerb,
fields: query.fields,
pagination: ctx.request.body.pagination,
- parameters: enrichedParameters,
+ parameters: enrichParameters(
+ query.parameters,
+ ctx.request.body.parameters
+ ),
transformer: query.transformer,
queryId: ctx.params.queryId,
// have to pass down to the thread runner - can't put into context now
diff --git a/packages/server/src/api/controllers/query/validation.ts b/packages/server/src/api/controllers/query/validation.ts
index 339035c945..7d4958f1e6 100644
--- a/packages/server/src/api/controllers/query/validation.ts
+++ b/packages/server/src/api/controllers/query/validation.ts
@@ -3,11 +3,10 @@ import Joi from "joi"
const OPTIONAL_STRING = Joi.string().optional().allow(null).allow("")
-export function queryValidation() {
- return Joi.object({
- _id: Joi.string(),
- _rev: Joi.string(),
- name: Joi.string().required(),
+function baseQueryValidation() {
+ return {
+ _id: OPTIONAL_STRING,
+ _rev: OPTIONAL_STRING,
fields: Joi.object().required(),
datasourceId: Joi.string().required(),
readable: Joi.boolean(),
@@ -17,11 +16,19 @@ export function queryValidation() {
default: Joi.string().allow(""),
})
),
- queryVerb: Joi.string().allow().required(),
+ queryVerb: Joi.string().required(),
extra: Joi.object().optional(),
schema: Joi.object({}).required().unknown(true),
transformer: OPTIONAL_STRING,
flags: Joi.object().optional(),
+ queryId: OPTIONAL_STRING,
+ }
+}
+
+export function queryValidation() {
+ return Joi.object({
+ ...baseQueryValidation(),
+ name: Joi.string().required(),
}).unknown(true)
}
@@ -32,19 +39,10 @@ export function generateQueryValidation() {
export function generateQueryPreviewValidation() {
// prettier-ignore
- return auth.joiValidator.body(Joi.object({
- _id: OPTIONAL_STRING,
- _rev: OPTIONAL_STRING,
- readable: Joi.boolean().optional(),
- fields: Joi.object().required(),
- queryVerb: Joi.string().required(),
- name: OPTIONAL_STRING,
- flags: Joi.object().optional(),
- schema: Joi.object().optional(),
- extra: Joi.object().optional(),
- datasourceId: Joi.string().required(),
- transformer: OPTIONAL_STRING,
- parameters: Joi.object({}).required().unknown(true),
- queryId: OPTIONAL_STRING,
- }).unknown(true))
+ return auth.joiValidator.body(
+ Joi.object({
+ ...baseQueryValidation(),
+ name: OPTIONAL_STRING,
+ }).unknown(true)
+ )
}
diff --git a/packages/server/src/api/controllers/script.ts b/packages/server/src/api/controllers/script.ts
index d5b99d0733..93e1ad7df9 100644
--- a/packages/server/src/api/controllers/script.ts
+++ b/packages/server/src/api/controllers/script.ts
@@ -1,10 +1,13 @@
-import ScriptRunner from "../../utilities/scriptRunner"
import { Ctx } from "@budibase/types"
+import { IsolatedVM } from "../../jsRunner/vm"
export async function execute(ctx: Ctx) {
const { script, context } = ctx.request.body
- const runner = new ScriptRunner(script, context)
- ctx.body = runner.execute()
+ const vm = new IsolatedVM()
+ const result = vm.withContext(context, () =>
+ vm.execute(`(function(){\n${script}\n})();`)
+ )
+ ctx.body = result
}
export async function save(ctx: Ctx) {
diff --git a/packages/server/src/api/routes/query.ts b/packages/server/src/api/routes/query.ts
index fd9c51da4d..eb857d0637 100644
--- a/packages/server/src/api/routes/query.ts
+++ b/packages/server/src/api/routes/query.ts
@@ -8,8 +8,8 @@ import {
paramResource,
} from "../../middleware/resourceId"
import {
- generateQueryPreviewValidation,
generateQueryValidation,
+ generateQueryPreviewValidation,
} from "../controllers/query/validation"
const { BUILDER, PermissionType, PermissionLevel } = permissions
diff --git a/packages/server/src/api/routes/tests/backup.spec.ts b/packages/server/src/api/routes/tests/backup.spec.ts
index d12b5e1507..acfac783db 100644
--- a/packages/server/src/api/routes/tests/backup.spec.ts
+++ b/packages/server/src/api/routes/tests/backup.spec.ts
@@ -8,7 +8,6 @@ import { mocks } from "@budibase/backend-core/tests"
mocks.licenses.useBackups()
describe("/backups", () => {
- let request = setup.getRequest()
let config = setup.getConfig()
afterAll(setup.afterAll)
@@ -59,10 +58,8 @@ describe("/backups", () => {
await config.createScreen()
const exportRes = await config.api.backup.createBackup(appId)
expect(exportRes.backupId).toBeDefined()
- const importRes = await config.api.backup.importBackup(
- appId,
- exportRes.backupId
- )
+ await config.api.backup.waitForBackupToComplete(appId, exportRes.backupId)
+ await config.api.backup.importBackup(appId, exportRes.backupId)
})
})
diff --git a/packages/server/src/api/routes/tests/datasource.spec.ts b/packages/server/src/api/routes/tests/datasource.spec.ts
index 73bb5056ce..41229b0a2a 100644
--- a/packages/server/src/api/routes/tests/datasource.spec.ts
+++ b/packages/server/src/api/routes/tests/datasource.spec.ts
@@ -7,6 +7,7 @@ import sdk from "../../../sdk"
import tk from "timekeeper"
import { mocks } from "@budibase/backend-core/tests"
+import { QueryPreview } from "@budibase/types"
tk.freeze(mocks.date.MOCK_DATE)
@@ -63,14 +64,17 @@ describe("/datasources", () => {
datasource: any,
fields: { path: string; queryString: string }
) {
- return config.previewQuery(
- request,
- config,
- datasource,
+ const queryPreview: QueryPreview = {
fields,
- undefined,
- ""
- )
+ datasourceId: datasource._id,
+ parameters: [],
+ transformer: null,
+ queryVerb: "read",
+ name: datasource.name,
+ schema: {},
+ readable: true,
+ }
+ return config.api.query.previewQuery(queryPreview)
}
it("should invalidate changed or removed variables", async () => {
diff --git a/packages/server/src/api/routes/tests/environmentVariables.spec.ts b/packages/server/src/api/routes/tests/environmentVariables.spec.ts
index aacf89ea6d..22114a1da3 100644
--- a/packages/server/src/api/routes/tests/environmentVariables.spec.ts
+++ b/packages/server/src/api/routes/tests/environmentVariables.spec.ts
@@ -14,6 +14,7 @@ jest.mock("pg", () => {
import * as setup from "./utilities"
import { mocks } from "@budibase/backend-core/tests"
import { env, events } from "@budibase/backend-core"
+import { QueryPreview } from "@budibase/types"
const structures = setup.structures
@@ -120,16 +121,19 @@ describe("/api/env/variables", () => {
.expect(200)
expect(response.body.datasource._id).toBeDefined()
- const query = {
+ const queryPreview: QueryPreview = {
datasourceId: response.body.datasource._id,
- parameters: {},
+ parameters: [],
fields: {},
queryVerb: "read",
name: response.body.datasource.name,
+ transformer: null,
+ schema: {},
+ readable: true,
}
const res = await request
.post(`/api/queries/preview`)
- .send(query)
+ .send(queryPreview)
.set(config.defaultHeaders())
.expect("Content-Type", /json/)
.expect(200)
@@ -139,7 +143,7 @@ describe("/api/env/variables", () => {
delete response.body.datasource.config
expect(events.query.previewed).toBeCalledWith(
response.body.datasource,
- query
+ queryPreview
)
expect(pg.Client).toHaveBeenCalledWith({ password: "test", ssl: undefined })
})
diff --git a/packages/server/src/api/routes/tests/queries/query.seq.spec.ts b/packages/server/src/api/routes/tests/queries/query.seq.spec.ts
index ba41ba3d16..52d35fa782 100644
--- a/packages/server/src/api/routes/tests/queries/query.seq.spec.ts
+++ b/packages/server/src/api/routes/tests/queries/query.seq.spec.ts
@@ -1,5 +1,7 @@
import tk from "timekeeper"
+const pg = require("pg")
+
// Mock out postgres for this
jest.mock("pg")
jest.mock("node-fetch")
@@ -22,7 +24,13 @@ import { checkCacheForDynamicVariable } from "../../../../threads/utils"
const { basicQuery, basicDatasource } = setup.structures
import { events, db as dbCore } from "@budibase/backend-core"
-import { Datasource, Query, SourceName } from "@budibase/types"
+import {
+ Datasource,
+ Query,
+ SourceName,
+ QueryPreview,
+ QueryParameter,
+} from "@budibase/types"
tk.freeze(Date.now())
@@ -218,28 +226,26 @@ describe("/queries", () => {
describe("preview", () => {
it("should be able to preview the query", async () => {
- const query = {
+ const queryPreview: QueryPreview = {
datasourceId: datasource._id,
- parameters: {},
- fields: {},
queryVerb: "read",
- name: datasource.name,
+ fields: {},
+ parameters: [],
+ transformer: "return data",
+ name: datasource.name!,
+ schema: {},
+ readable: true,
}
- const res = await request
- .post(`/api/queries/preview`)
- .send(query)
- .set(config.defaultHeaders())
- .expect("Content-Type", /json/)
- .expect(200)
+ const responseBody = await config.api.query.previewQuery(queryPreview)
// these responses come from the mock
- expect(res.body.schema).toEqual({
+ expect(responseBody.schema).toEqual({
a: { type: "string", name: "a" },
b: { type: "number", name: "b" },
})
- expect(res.body.rows.length).toEqual(1)
+ expect(responseBody.rows.length).toEqual(1)
expect(events.query.previewed).toBeCalledTimes(1)
delete datasource.config
- expect(events.query.previewed).toBeCalledWith(datasource, query)
+ expect(events.query.previewed).toBeCalledWith(datasource, queryPreview)
})
it("should apply authorization to endpoint", async () => {
@@ -249,6 +255,128 @@ describe("/queries", () => {
url: `/api/queries/preview`,
})
})
+
+ it("should not error when trying to generate a nested schema for an empty array", async () => {
+ const queryPreview: QueryPreview = {
+ datasourceId: datasource._id,
+ parameters: [],
+ fields: {},
+ queryVerb: "read",
+ name: datasource.name!,
+ transformer: "return data",
+ schema: {},
+ readable: true,
+ }
+ const rows = [
+ {
+ contacts: [],
+ },
+ ]
+ pg.queryMock.mockImplementation(() => ({
+ rows,
+ }))
+
+ const responseBody = await config.api.query.previewQuery(queryPreview)
+ expect(responseBody).toEqual({
+ nestedSchemaFields: {},
+ rows,
+ schema: {
+ contacts: { type: "array", name: "contacts" },
+ },
+ })
+ expect(responseBody.rows.length).toEqual(1)
+ delete datasource.config
+ })
+
+ it("should generate a nested schema based on all the nested items", async () => {
+ const queryPreview: QueryPreview = {
+ datasourceId: datasource._id,
+ parameters: [],
+ fields: {},
+ queryVerb: "read",
+ name: datasource.name!,
+ transformer: "return data",
+ schema: {},
+ readable: true,
+ }
+ const rows = [
+ {
+ contacts: [
+ {
+ address: "123 Lane",
+ },
+ {
+ address: "456 Drive",
+ },
+ {
+ postcode: "BT1 12N",
+ lat: 54.59,
+ long: -5.92,
+ },
+ {
+ city: "Belfast",
+ },
+ {
+ address: "789 Avenue",
+ phoneNumber: "0800-999-5555",
+ },
+ {
+ name: "Name",
+ isActive: false,
+ },
+ ],
+ },
+ ]
+ pg.queryMock.mockImplementation(() => ({
+ rows,
+ }))
+
+ const responseBody = await config.api.query.previewQuery(queryPreview)
+ expect(responseBody).toEqual({
+ nestedSchemaFields: {
+ contacts: {
+ address: {
+ type: "string",
+ name: "address",
+ },
+ postcode: {
+ type: "string",
+ name: "postcode",
+ },
+ lat: {
+ type: "number",
+ name: "lat",
+ },
+ long: {
+ type: "number",
+ name: "long",
+ },
+ city: {
+ type: "string",
+ name: "city",
+ },
+ phoneNumber: {
+ type: "string",
+ name: "phoneNumber",
+ },
+ name: {
+ type: "string",
+ name: "name",
+ },
+ isActive: {
+ type: "boolean",
+ name: "isActive",
+ },
+ },
+ },
+ rows,
+ schema: {
+ contacts: { type: "json", name: "contacts", subtype: "array" },
+ },
+ })
+ expect(responseBody.rows.length).toEqual(1)
+ delete datasource.config
+ })
})
describe("execute", () => {
@@ -283,7 +411,17 @@ describe("/queries", () => {
describe("variables", () => {
async function preview(datasource: Datasource, fields: any) {
- return config.previewQuery(request, config, datasource, fields, undefined)
+ const queryPreview: QueryPreview = {
+ datasourceId: datasource._id!,
+ parameters: [],
+ fields,
+ queryVerb: "read",
+ name: datasource.name!,
+ transformer: "return data",
+ schema: {},
+ readable: true,
+ }
+ return await config.api.query.previewQuery(queryPreview)
}
it("should work with static variables", async () => {
@@ -293,31 +431,31 @@ describe("/queries", () => {
variable2: "1",
},
})
- const res = await preview(datasource, {
+ const responseBody = await preview(datasource, {
path: "www.{{ variable }}.com",
queryString: "test={{ variable2 }}",
})
// these responses come from the mock
- expect(res.body.schema).toEqual({
+ expect(responseBody.schema).toEqual({
opts: { type: "json", name: "opts" },
url: { type: "string", name: "url" },
value: { type: "string", name: "value" },
})
- expect(res.body.rows[0].url).toEqual("http://www.google.com?test=1")
+ expect(responseBody.rows[0].url).toEqual("http://www.google.com?test=1")
})
it("should work with dynamic variables", async () => {
const { datasource } = await config.dynamicVariableDatasource()
- const res = await preview(datasource, {
+ const responseBody = await preview(datasource, {
path: "www.google.com",
queryString: "test={{ variable3 }}",
})
- expect(res.body.schema).toEqual({
+ expect(responseBody.schema).toEqual({
opts: { type: "json", name: "opts" },
url: { type: "string", name: "url" },
value: { type: "string", name: "value" },
})
- expect(res.body.rows[0].url).toContain("doctype%20html")
+ expect(responseBody.rows[0].url).toContain("doctype%20html")
})
it("check that it automatically retries on fail with cached dynamics", async () => {
@@ -331,16 +469,16 @@ describe("/queries", () => {
// check its in cache
const contents = await checkCacheForDynamicVariable(base._id, "variable3")
expect(contents.rows.length).toEqual(1)
- const res = await preview(datasource, {
+ const responseBody = await preview(datasource, {
path: "www.failonce.com",
queryString: "test={{ variable3 }}",
})
- expect(res.body.schema).toEqual({
+ expect(responseBody.schema).toEqual({
fails: { type: "number", name: "fails" },
opts: { type: "json", name: "opts" },
url: { type: "string", name: "url" },
})
- expect(res.body.rows[0].fails).toEqual(1)
+ expect(responseBody.rows[0].fails).toEqual(1)
})
it("deletes variables when linked query is deleted", async () => {
@@ -371,24 +509,37 @@ describe("/queries", () => {
async function previewGet(
datasource: Datasource,
fields: any,
- params: any
+ params: QueryParameter[]
) {
- return config.previewQuery(request, config, datasource, fields, params)
+ const queryPreview: QueryPreview = {
+ datasourceId: datasource._id!,
+ parameters: params,
+ fields,
+ queryVerb: "read",
+ name: datasource.name!,
+ transformer: "return data",
+ schema: {},
+ readable: true,
+ }
+ return await config.api.query.previewQuery(queryPreview)
}
async function previewPost(
datasource: Datasource,
fields: any,
- params: any
+ params: QueryParameter[]
) {
- return config.previewQuery(
- request,
- config,
- datasource,
+ const queryPreview: QueryPreview = {
+ datasourceId: datasource._id!,
+ parameters: params,
fields,
- params,
- "create"
- )
+ queryVerb: "create",
+ name: datasource.name!,
+ transformer: null,
+ schema: {},
+ readable: false,
+ }
+ return await config.api.query.previewQuery(queryPreview)
}
it("should parse global and query level header mappings", async () => {
@@ -400,7 +551,7 @@ describe("/queries", () => {
emailHdr: "{{[user].[email]}}",
},
})
- const res = await previewGet(
+ const responseBody = await previewGet(
datasource,
{
path: "www.google.com",
@@ -410,17 +561,17 @@ describe("/queries", () => {
secondHdr: "1234",
},
},
- undefined
+ []
)
- const parsedRequest = JSON.parse(res.body.extra.raw)
+ const parsedRequest = JSON.parse(responseBody.extra.raw)
expect(parsedRequest.opts.headers).toEqual({
test: "headerVal",
emailHdr: userDetails.email,
queryHdr: userDetails.firstName,
secondHdr: "1234",
})
- expect(res.body.rows[0].url).toEqual(
+ expect(responseBody.rows[0].url).toEqual(
"http://www.google.com?email=" + userDetails.email.replace("@", "%40")
)
})
@@ -430,21 +581,21 @@ describe("/queries", () => {
const datasource = await config.restDatasource()
- const res = await previewGet(
+ const responseBody = await previewGet(
datasource,
{
path: "www.google.com",
queryString:
"test={{myEmail}}&testName={{myName}}&testParam={{testParam}}",
},
- {
- myEmail: "{{[user].[email]}}",
- myName: "{{[user].[firstName]}}",
- testParam: "1234",
- }
+ [
+ { name: "myEmail", default: "{{[user].[email]}}" },
+ { name: "myName", default: "{{[user].[firstName]}}" },
+ { name: "testParam", default: "1234" },
+ ]
)
- expect(res.body.rows[0].url).toEqual(
+ expect(responseBody.rows[0].url).toEqual(
"http://www.google.com?test=" +
userDetails.email.replace("@", "%40") +
"&testName=" +
@@ -457,7 +608,7 @@ describe("/queries", () => {
const userDetails = config.getUserDetails()
const datasource = await config.restDatasource()
- const res = await previewPost(
+ const responseBody = await previewPost(
datasource,
{
path: "www.google.com",
@@ -466,16 +617,14 @@ describe("/queries", () => {
"This is plain text and this is my email: {{[user].[email]}}. This is a test param: {{testParam}}",
bodyType: "text",
},
- {
- testParam: "1234",
- }
+ [{ name: "testParam", default: "1234" }]
)
- const parsedRequest = JSON.parse(res.body.extra.raw)
+ const parsedRequest = JSON.parse(responseBody.extra.raw)
expect(parsedRequest.opts.body).toEqual(
`This is plain text and this is my email: ${userDetails.email}. This is a test param: 1234`
)
- expect(res.body.rows[0].url).toEqual(
+ expect(responseBody.rows[0].url).toEqual(
"http://www.google.com?testParam=1234"
)
})
@@ -484,7 +633,7 @@ describe("/queries", () => {
const userDetails = config.getUserDetails()
const datasource = await config.restDatasource()
- const res = await previewPost(
+ const responseBody = await previewPost(
datasource,
{
path: "www.google.com",
@@ -493,16 +642,16 @@ describe("/queries", () => {
'{"email":"{{[user].[email]}}","queryCode":{{testParam}},"userRef":"{{userRef}}"}',
bodyType: "json",
},
- {
- testParam: "1234",
- userRef: "{{[user].[firstName]}}",
- }
+ [
+ { name: "testParam", default: "1234" },
+ { name: "userRef", default: "{{[user].[firstName]}}" },
+ ]
)
- const parsedRequest = JSON.parse(res.body.extra.raw)
+ const parsedRequest = JSON.parse(responseBody.extra.raw)
const test = `{"email":"${userDetails.email}","queryCode":1234,"userRef":"${userDetails.firstName}"}`
expect(parsedRequest.opts.body).toEqual(test)
- expect(res.body.rows[0].url).toEqual(
+ expect(responseBody.rows[0].url).toEqual(
"http://www.google.com?testParam=1234"
)
})
@@ -511,7 +660,7 @@ describe("/queries", () => {
const userDetails = config.getUserDetails()
const datasource = await config.restDatasource()
- const res = await previewPost(
+ const responseBody = await previewPost(
datasource,
{
path: "www.google.com",
@@ -521,17 +670,17 @@ describe("/queries", () => {
"[{{userId}}] testing ",
bodyType: "xml",
},
- {
- testParam: "1234",
- userId: "{{[user].[firstName]}}",
- }
+ [
+ { name: "testParam", default: "1234" },
+ { name: "userId", default: "{{[user].[firstName]}}" },
+ ]
)
- const parsedRequest = JSON.parse(res.body.extra.raw)
+ const parsedRequest = JSON.parse(responseBody.extra.raw)
const test = ` ${userDetails.email} 1234
[${userDetails.firstName}] testing `
expect(parsedRequest.opts.body).toEqual(test)
- expect(res.body.rows[0].url).toEqual(
+ expect(responseBody.rows[0].url).toEqual(
"http://www.google.com?testParam=1234"
)
})
@@ -540,7 +689,7 @@ describe("/queries", () => {
const userDetails = config.getUserDetails()
const datasource = await config.restDatasource()
- const res = await previewPost(
+ const responseBody = await previewPost(
datasource,
{
path: "www.google.com",
@@ -549,13 +698,13 @@ describe("/queries", () => {
'{"email":"{{[user].[email]}}","queryCode":{{testParam}},"userRef":"{{userRef}}"}',
bodyType: "form",
},
- {
- testParam: "1234",
- userRef: "{{[user].[firstName]}}",
- }
+ [
+ { name: "testParam", default: "1234" },
+ { name: "userRef", default: "{{[user].[firstName]}}" },
+ ]
)
- const parsedRequest = JSON.parse(res.body.extra.raw)
+ const parsedRequest = JSON.parse(responseBody.extra.raw)
const emailData = parsedRequest.opts.body._streams[1]
expect(emailData).toEqual(userDetails.email)
@@ -566,7 +715,7 @@ describe("/queries", () => {
const userRef = parsedRequest.opts.body._streams[7]
expect(userRef).toEqual(userDetails.firstName)
- expect(res.body.rows[0].url).toEqual(
+ expect(responseBody.rows[0].url).toEqual(
"http://www.google.com?testParam=1234"
)
})
@@ -575,7 +724,7 @@ describe("/queries", () => {
const userDetails = config.getUserDetails()
const datasource = await config.restDatasource()
- const res = await previewPost(
+ const responseBody = await previewPost(
datasource,
{
path: "www.google.com",
@@ -584,12 +733,12 @@ describe("/queries", () => {
'{"email":"{{[user].[email]}}","queryCode":{{testParam}},"userRef":"{{userRef}}"}',
bodyType: "encoded",
},
- {
- testParam: "1234",
- userRef: "{{[user].[firstName]}}",
- }
+ [
+ { name: "testParam", default: "1234" },
+ { name: "userRef", default: "{{[user].[firstName]}}" },
+ ]
)
- const parsedRequest = JSON.parse(res.body.extra.raw)
+ const parsedRequest = JSON.parse(responseBody.extra.raw)
expect(parsedRequest.opts.body.email).toEqual(userDetails.email)
expect(parsedRequest.opts.body.queryCode).toEqual("1234")
diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts
index 10dac3c0ea..239da36351 100644
--- a/packages/server/src/api/routes/tests/row.spec.ts
+++ b/packages/server/src/api/routes/tests/row.spec.ts
@@ -2135,5 +2135,48 @@ describe.each([
}
)
})
+
+ it("should not carry over context between formulas", async () => {
+ const js = Buffer.from(`return $("[text]");`).toString("base64")
+ const table = await config.createTable({
+ name: "table",
+ type: "table",
+ schema: {
+ text: {
+ name: "text",
+ type: FieldType.STRING,
+ },
+ formula: {
+ name: "formula",
+ type: FieldType.FORMULA,
+ formula: `{{ js "${js}"}}`,
+ formulaType: FormulaType.DYNAMIC,
+ },
+ },
+ })
+
+ for (let i = 0; i < 10; i++) {
+ await config.api.row.save(table._id!, { text: `foo${i}` })
+ }
+
+ const { rows } = await config.api.row.search(table._id!)
+ expect(rows).toHaveLength(10)
+
+ const formulaValues = rows.map(r => r.formula)
+ expect(formulaValues).toEqual(
+ expect.arrayContaining([
+ "foo0",
+ "foo1",
+ "foo2",
+ "foo3",
+ "foo4",
+ "foo5",
+ "foo6",
+ "foo7",
+ "foo8",
+ "foo9",
+ ])
+ )
+ })
})
})
diff --git a/packages/server/src/api/routes/tests/table.spec.ts b/packages/server/src/api/routes/tests/table.spec.ts
index c8cb3ef21b..ce119e56f0 100644
--- a/packages/server/src/api/routes/tests/table.spec.ts
+++ b/packages/server/src/api/routes/tests/table.spec.ts
@@ -368,10 +368,12 @@ describe("/tables", () => {
.set(config.defaultHeaders())
.expect("Content-Type", /json/)
.expect(200)
- const fetchedTable = res.body[0]
- expect(fetchedTable.name).toEqual(testTable.name)
- expect(fetchedTable.type).toEqual("table")
- expect(fetchedTable.sourceType).toEqual("internal")
+
+ const table = res.body.find((t: Table) => t._id === testTable._id)
+ expect(table).toBeDefined()
+ expect(table.name).toEqual(testTable.name)
+ expect(table.type).toEqual("table")
+ expect(table.sourceType).toEqual("internal")
})
it("should apply authorization to endpoint", async () => {
diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts
index f6f1780030..4e84422dec 100644
--- a/packages/server/src/app.ts
+++ b/packages/server/src/app.ts
@@ -26,6 +26,7 @@ async function start() {
start().catch(err => {
console.error(`Failed server startup - ${err.message}`)
+ throw err
})
export function getServer() {
diff --git a/packages/server/src/environment.ts b/packages/server/src/environment.ts
index 20142776b8..f304ce4eb2 100644
--- a/packages/server/src/environment.ts
+++ b/packages/server/src/environment.ts
@@ -23,7 +23,7 @@ const DEFAULTS = {
AUTOMATION_THREAD_TIMEOUT: 12000,
AUTOMATION_SYNC_TIMEOUT: 120000,
AUTOMATION_MAX_ITERATIONS: 200,
- JS_PER_EXECUTION_TIME_LIMIT_MS: 1000,
+ JS_PER_EXECUTION_TIME_LIMIT_MS: 1500,
TEMPLATE_REPOSITORY: "app",
PLUGINS_DIR: "/plugins",
FORKED_PROCESS_NAME: "main",
@@ -113,6 +113,7 @@ const environment = {
process.env[key] = value
// @ts-ignore
environment[key] = value
+ cleanVariables()
},
isTest: coreEnv.isTest,
isJest: coreEnv.isJest,
@@ -128,18 +129,22 @@ const environment = {
},
}
-// clean up any environment variable edge cases
-for (let [key, value] of Object.entries(environment)) {
- // handle the edge case of "0" to disable an environment variable
- if (value === "0") {
- // @ts-ignore
- environment[key] = 0
- }
- // handle the edge case of "false" to disable an environment variable
- if (value === "false") {
- // @ts-ignore
- environment[key] = 0
+function cleanVariables() {
+ // clean up any environment variable edge cases
+ for (let [key, value] of Object.entries(environment)) {
+ // handle the edge case of "0" to disable an environment variable
+ if (value === "0") {
+ // @ts-ignore
+ environment[key] = 0
+ }
+ // handle the edge case of "false" to disable an environment variable
+ if (value === "false") {
+ // @ts-ignore
+ environment[key] = 0
+ }
}
}
+cleanVariables()
+
export default environment
diff --git a/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js b/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js
index b23efa87d1..5c49ce78e6 100644
--- a/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js
+++ b/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js
@@ -1,7 +1,7 @@
-function kt(e){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e))}function Lt(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}function qt(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function Rt(e){return Object.prototype.toString.call(e)==="[object Map]"}function Zt(e){return Object.prototype.toString.call(e)==="[object Date]"}function j(e,t){return JSON.stringify(e,(n,s)=>typeof s=="bigint"?{$numberLong:`${s}`}:Rt(s)?Object.fromEntries(s):s)}function Kt(e){if(e!=null&&typeof e=="object"&&"stylize"in e&&typeof e.stylize=="function")return e.stylize}var mt=6,Dt=2147483647,jt=-2147483648,zt=Math.pow(2,63)-1,Ft=-Math.pow(2,63),Gt=Math.pow(2,53),Xt=-Math.pow(2,53),wt=1,Qt=2,vt=3,te=4,ee=5,ne=6,se=7,re=8,ie=9,oe=10,pt=11,fe=12,le=13,ce=14,he=15,St=16,ae=17,ge=18,ue=19,ye=255,me=127;var ct=4,cn=Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127}),o=class extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(t,n){super(t,n)}static isBSONError(t){return t!=null&&typeof t=="object"&&"bsonError"in t&&t.bsonError===!0&&"name"in t&&"message"in t&&"stack"in t}},yt=class extends o{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${mt}.x.x`)}},ht=class extends o{get name(){return"BSONRuntimeError"}constructor(t){super(t)}},we=128,pe=192,Se=224,Ne=240,Be=248,Oe=192,be=224,Ee=240,Te=128;function Mt(e,t,n){let s=0;for(let r=t;r20)return null;if(s===1&&e[t]<128)return String.fromCharCode(e[t]);if(s===2&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(s===3&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);let r=[];for(let i=t;i127)return null;r.push(u)}return String.fromCharCode(...r)}function Ie(e){return C.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}var de=await(async()=>{try{return(await import("crypto")).randomBytes}catch{return Ie}})(),C={toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return Buffer.from(e);throw new o(`Cannot create Buffer from ${String(e)}`)},allocate(e){return Buffer.alloc(e)},equals(e,t){return C.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},toBase64(e){return C.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return C.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return C.toLocalBufferType(e).toString("hex")},fromUTF8(e){return Buffer.from(e,"utf8")},toUTF8(e,t,n,s){let r=n-t<=20?xt(e,t,n):null;if(r!=null)return r;let i=C.toLocalBufferType(e).toString("utf8",t,n);if(s){for(let u=0;uMath.floor(Math.random()*256)))}var _e=(()=>{let{crypto:e}=globalThis;if(e!=null&&typeof e.getRandomValues=="function")return t=>e.getRandomValues(X.allocate(t));if($e()){let{console:t}=globalThis;t?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return Ae})(),Nt=/(\d|[a-f])/i,X={toLocalBufferType(e){let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="Uint8Array")return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return new Uint8Array(e);throw new o(`Cannot make a Uint8Array from ${String(e)}`)},allocate(e){if(typeof e!="number")throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;nt.charCodeAt(0))},toBase64(e){return btoa(X.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,t=>t.charCodeAt(0)&255)},toISO88591(e){return Array.from(Uint16Array.from(e),t=>String.fromCharCode(t)).join("")},fromHex(e){let t=e.length%2===0?e:e.slice(0,e.length-1),n=[];for(let s=0;st.toString(16).padStart(2,"0")).join("")},fromUTF8(e){return new TextEncoder().encode(e)},toUTF8(e,t,n,s){let r=n-t<=20?xt(e,t,n):null;if(r!=null)return r;if(s)try{return new TextDecoder("utf8",{fatal:s}).decode(e.slice(t,n))}catch(i){throw new o("Invalid UTF-8 string in BSON document",{cause:i})}return new TextDecoder("utf8",{fatal:s}).decode(e.slice(t,n))},utf8ByteLength(e){return X.fromUTF8(e).byteLength},encodeUTF8Into(e,t,n){let s=X.fromUTF8(t);return e.set(s,n),s.byteLength},randomBytes:_e},Ue=typeof Buffer=="function"&&Buffer.prototype?._isBuffer!==!0,h=Ue?C:X,Q=class extends DataView{static fromUint8Array(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}},D=class{get[Symbol.for("@@mdb.bson.version")](){return mt}[Symbol.for("nodejs.util.inspect.custom")](t,n,s){return this.inspect(t,n,s)}},_=class e extends D{get _bsontype(){return"Binary"}constructor(t,n){if(super(),t!=null&&typeof t=="string"&&!ArrayBuffer.isView(t)&&!kt(t)&&!Array.isArray(t))throw new o("Binary can only be constructed from Uint8Array or number[]");this.sub_type=n??e.BSON_BINARY_SUBTYPE_DEFAULT,t==null?(this.buffer=h.allocate(e.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?h.fromNumberArray(t):h.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if(typeof t=="string"&&t.length!==1)throw new o("only accepts single character String");if(typeof t!="number"&&t.length!==1)throw new o("only accepts single character Uint8Array or Array");let n;if(typeof t=="string"?n=t.charCodeAt(0):typeof t=="number"?n=t:n=t[0],n<0||n>255)throw new o("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=n;else{let s=h.allocate(e.BUFFER_SIZE+this.buffer.length);s.set(this.buffer,0),this.buffer=s,this.buffer[this.position++]=n}}write(t,n){if(n=typeof n=="number"?n:this.position,this.buffer.byteLengththis.position?n+t.length:this.position;else if(typeof t=="string")throw new o("input cannot be string")}read(t,n){return n=n&&n>0?n:this.position,this.buffer.slice(t,t+n)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return h.toBase64(this.buffer)}toString(t){return t==="hex"?h.toHex(this.buffer):t==="base64"?h.toBase64(this.buffer):t==="utf8"||t==="utf-8"?h.toUTF8(this.buffer,0,this.buffer.byteLength,!1):h.toUTF8(this.buffer,0,this.buffer.byteLength,!1)}toExtendedJSON(t){t=t||{};let n=h.toBase64(this.buffer),s=Number(this.sub_type).toString(16);return t.legacy?{$binary:n,$type:s.length===1?"0"+s:s}:{$binary:{base64:n,subType:s.length===1?"0"+s:s}}}toUUID(){if(this.sub_type===e.SUBTYPE_UUID)return new W(this.buffer.slice(0,this.position));throw new o(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${e.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,n){return new e(h.fromHex(t),n)}static createFromBase64(t,n){return new e(h.fromBase64(t),n)}static fromExtendedJSON(t,n){n=n||{};let s,r;if("$binary"in t?n.legacy&&typeof t.$binary=="string"&&"$type"in t?(r=t.$type?parseInt(t.$type,16):0,s=h.fromBase64(t.$binary)):typeof t.$binary!="string"&&(r=t.$binary.subType?parseInt(t.$binary.subType,16):0,s=h.fromBase64(t.$binary.base64)):"$uuid"in t&&(r=4,s=W.bytesFromString(t.$uuid)),!s)throw new o(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return r===ct?new W(s):new e(s,r)}inspect(t,n,s){s??=j;let r=h.toBase64(this.buffer.subarray(0,this.position)),i=s(r,n),u=s(this.sub_type,n);return`Binary.createFromBase64(${i}, ${u})`}};_.BSON_BINARY_SUBTYPE_DEFAULT=0;_.BUFFER_SIZE=256;_.SUBTYPE_DEFAULT=0;_.SUBTYPE_FUNCTION=1;_.SUBTYPE_BYTE_ARRAY=2;_.SUBTYPE_UUID_OLD=3;_.SUBTYPE_UUID=4;_.SUBTYPE_MD5=5;_.SUBTYPE_ENCRYPTED=6;_.SUBTYPE_COLUMN=7;_.SUBTYPE_USER_DEFINED=128;var gt=16,Le=/^[0-9A-F]{32}$/i,Re=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,W=class e extends _{constructor(t){let n;if(t==null)n=e.generate();else if(t instanceof e)n=h.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&t.byteLength===gt)n=h.toLocalBufferType(t);else if(typeof t=="string")n=e.bytesFromString(t);else throw new o("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");super(n,ct)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[h.toHex(this.buffer.subarray(0,4)),h.toHex(this.buffer.subarray(4,6)),h.toHex(this.buffer.subarray(6,8)),h.toHex(this.buffer.subarray(8,10)),h.toHex(this.buffer.subarray(10,16))].join("-"):h.toHex(this.buffer)}toString(t){return t==="hex"?h.toHex(this.id):t==="base64"?h.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof e)return h.equals(t.id,this.id);try{return h.equals(new e(t).id,this.id)}catch{return!1}}toBinary(){return new _(this.id,_.SUBTYPE_UUID)}static generate(){let t=h.randomBytes(gt);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,t}static isValid(t){return t?typeof t=="string"?e.isValidUUIDString(t):Lt(t)?t.byteLength===gt:t._bsontype==="Binary"&&t.sub_type===this.SUBTYPE_UUID&&t.buffer.byteLength===16:!1}static createFromHexString(t){let n=e.bytesFromString(t);return new e(n)}static createFromBase64(t){return new e(h.fromBase64(t))}static bytesFromString(t){if(!e.isValidUUIDString(t))throw new o("UUID string representation must be 32 hex digits or canonical hyphenated representation");return h.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return Le.test(t)||Re.test(t)}inspect(t,n,s){return s??=j,`new UUID(${s(this.toHexString(),n)})`}},Y=class e extends D{get _bsontype(){return"Code"}constructor(t,n){super(),this.code=t.toString(),this.scope=n??null}toJSON(){return this.scope!=null?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(t){return new e(t.$code,t.$scope)}inspect(t,n,s){s??=j;let r=s(this.code,n),i=r.includes(`
-`);this.scope!=null&&(r+=`,${i?`
-`:" "}${s(this.scope,n)}`);let u=i&&this.scope===null;return`new Code(${i?`
-`:""}${r}${u?`
-`:""})`}};function Ht(e){return e!=null&&typeof e=="object"&&"$id"in e&&e.$id!=null&&"$ref"in e&&typeof e.$ref=="string"&&(!("$db"in e)||"$db"in e&&typeof e.$db=="string")}var P=class e extends D{get _bsontype(){return"DBRef"}constructor(t,n,s,r){super();let i=t.split(".");i.length===2&&(s=i.shift(),t=i.shift()),this.collection=t,this.oid=n,this.db=s,this.fields=r||{}}get namespace(){return this.collection}set namespace(t){this.collection=t}toJSON(){let t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(t.$db=this.db),t}toExtendedJSON(t){t=t||{};let n={$ref:this.collection,$id:this.oid};return t.legacy||(this.db&&(n.$db=this.db),n=Object.assign(n,this.fields)),n}static fromExtendedJSON(t){let n=Object.assign({},t);return delete n.$ref,delete n.$id,delete n.$db,new e(t.$ref,t.$id,t.$db,n)}inspect(t,n,s){s??=j;let r=[s(this.namespace,n),s(this.oid,n),...this.db?[s(this.db,n)]:[],...Object.keys(this.fields).length>0?[s(this.fields,n)]:[]];return r[1]=s===j?`new ObjectId(${r[1]})`:r[1],`new DBRef(${r.join(", ")})`}},z;try{z=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}var Bt=65536,De=1<<24,G=Bt*Bt,Jt=G*G,Ot=Jt/2,bt={},Et={},je=20,ze=/^(\+?0|(\+|-)?[1-9][0-9]*)$/,f=class e extends D{get _bsontype(){return"Long"}get __isLong__(){return!0}constructor(t=0,n,s){super(),typeof t=="bigint"?Object.assign(this,e.fromBigInt(t,!!n)):typeof t=="string"?Object.assign(this,e.fromString(t,!!n)):(this.low=t|0,this.high=n|0,this.unsigned=!!s)}static fromBits(t,n,s){return new e(t,n,s)}static fromInt(t,n){let s,r,i;return n?(t>>>=0,(i=0<=t&&t<256)&&(r=Et[t],r)?r:(s=e.fromBits(t,(t|0)<0?-1:0,!0),i&&(Et[t]=s),s)):(t|=0,(i=-128<=t&&t<128)&&(r=bt[t],r)?r:(s=e.fromBits(t,t<0?-1:0,!1),i&&(bt[t]=s),s))}static fromNumber(t,n){if(isNaN(t))return n?e.UZERO:e.ZERO;if(n){if(t<0)return e.UZERO;if(t>=Jt)return e.MAX_UNSIGNED_VALUE}else{if(t<=-Ot)return e.MIN_VALUE;if(t+1>=Ot)return e.MAX_VALUE}return t<0?e.fromNumber(-t,n).neg():e.fromBits(t%G|0,t/G|0,n)}static fromBigInt(t,n){return e.fromString(t.toString(),n)}static fromString(t,n,s){if(t.length===0)throw new o("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e.ZERO;if(typeof n=="number"?(s=n,n=!1):n=!!n,s=s||10,s<2||360)throw new o("interior hyphen");if(r===0)return e.fromString(t.substring(1),n,s).neg();let i=e.fromNumber(Math.pow(s,8)),u=e.ZERO;for(let a=0;a>>16,s=this.high&65535,r=this.low>>>16,i=this.low&65535,u=t.high>>>16,a=t.high&65535,I=t.low>>>16,S=t.low&65535,w=0,m=0,O=0,d=0;return d+=i+S,O+=d>>>16,d&=65535,O+=r+I,m+=O>>>16,O&=65535,m+=s+a,w+=m>>>16,m&=65535,w+=n+u,w&=65535,e.fromBits(O<<16|d,w<<16|m,this.unsigned)}and(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)}compare(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;let n=this.isNegative(),s=t.isNegative();return n&&!s?-1:!n&&s?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1}comp(t){return this.compare(t)}divide(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw new o("division by zero");if(z){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;let i=(this.unsigned?z.div_u:z.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(i,z.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;let n,s,r;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;r=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(n=this.shr(1).div(t).shl(1),n.eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(s=this.sub(t.mul(n)),r=n.add(s.div(t)),r));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=e.ZERO}for(s=this;s.gte(t);){n=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));let i=Math.ceil(Math.log(n)/Math.LN2),u=i<=48?1:Math.pow(2,i-48),a=e.fromNumber(n),I=a.mul(t);for(;I.isNegative()||I.gt(s);)n-=u,a=e.fromNumber(n,this.unsigned),I=a.mul(t);a.isZero()&&(a=e.ONE),r=r.add(a),s=s.sub(I)}return r}div(t){return this.divide(t)}equals(t){return e.isLong(t)||(t=e.fromValue(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low}eq(t){return this.equals(t)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();let t=this.high!==0?this.high:this.low,n;for(n=31;n>0&&!(t&1<0}gt(t){return this.greaterThan(t)}greaterThanOrEqual(t){return this.comp(t)>=0}gte(t){return this.greaterThanOrEqual(t)}ge(t){return this.greaterThanOrEqual(t)}isEven(){return(this.low&1)===0}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return(this.low&1)===1}isPositive(){return this.unsigned||this.high>=0}isZero(){return this.high===0&&this.low===0}lessThan(t){return this.comp(t)<0}lt(t){return this.lessThan(t)}lessThanOrEqual(t){return this.comp(t)<=0}lte(t){return this.lessThanOrEqual(t)}modulo(t){if(e.isLong(t)||(t=e.fromValue(t)),z){let n=(this.unsigned?z.rem_u:z.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,z.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))}mod(t){return this.modulo(t)}rem(t){return this.modulo(t)}multiply(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),z){let x=z.mul(this.low,this.high,t.low,t.high);return e.fromBits(x,z.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);let n=this.high>>>16,s=this.high&65535,r=this.low>>>16,i=this.low&65535,u=t.high>>>16,a=t.high&65535,I=t.low>>>16,S=t.low&65535,w=0,m=0,O=0,d=0;return d+=i*S,O+=d>>>16,d&=65535,O+=r*S,m+=O>>>16,O&=65535,O+=i*I,m+=O>>>16,O&=65535,m+=s*S,w+=m>>>16,m&=65535,m+=r*I,w+=m>>>16,m&=65535,m+=i*a,w+=m>>>16,m&=65535,w+=n*S+s*I+r*a+i*u,w&=65535,e.fromBits(O<<16|d,w<<16|m,this.unsigned)}mul(t){return this.multiply(t)}negate(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)}neg(){return this.negate()}not(){return e.fromBits(~this.low,~this.high,this.unsigned)}notEquals(t){return!this.equals(t)}neq(t){return this.notEquals(t)}ne(t){return this.notEquals(t)}or(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)}shiftLeft(t){return e.isLong(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?e.fromBits(this.low<>>32-t,this.unsigned):e.fromBits(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)}shr(t){return this.shiftRight(t)}shiftRightUnsigned(t){if(e.isLong(t)&&(t=t.toInt()),t&=63,t===0)return this;{let n=this.high;if(t<32){let s=this.low;return e.fromBits(s>>>t|n<<32-t,n>>>t,this.unsigned)}else return t===32?e.fromBits(n,0,this.unsigned):e.fromBits(n>>>t-32,0,this.unsigned)}}shr_u(t){return this.shiftRightUnsigned(t)}shru(t){return this.shiftRightUnsigned(t)}subtract(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())}sub(t){return this.subtract(t)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*G+(this.low>>>0):this.high*G+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(t){return t?this.toBytesLE():this.toBytesBE()}toBytesLE(){let t=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]}toBytesBE(){let t=this.high,n=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,n>>>24,n>>>16&255,n>>>8&255,n&255]}toSigned(){return this.unsigned?e.fromBits(this.low,this.high,!1):this}toString(t){if(t=t||10,t<2||36>>0).toString(t);if(s=i,s.isZero())return a+r;for(;a.length<6;)a="0"+a;r=""+a+r}}toUnsigned(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)}xor(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)}eqz(){return this.isZero()}le(t){return this.lessThanOrEqual(t)}toExtendedJSON(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(t,n){let{useBigInt64:s=!1,relaxed:r=!0}={...n};if(t.$numberLong.length>je)throw new o("$numberLong string is too long");if(!ze.test(t.$numberLong))throw new o(`$numberLong string "${t.$numberLong}" is in an invalid format`);if(s){let u=BigInt(t.$numberLong);return BigInt.asIntN(64,u)}let i=e.fromString(t.$numberLong);return r?i.toNumber():i}inspect(t,n,s){s??=j;let r=s(this.toString(),n),i=this.unsigned?`, ${s(this.unsigned,n)}`:"";return`new Long(${r}${i})`}};f.TWO_PWR_24=f.fromInt(De);f.MAX_UNSIGNED_VALUE=f.fromBits(-1,-1,!0);f.ZERO=f.fromInt(0);f.UZERO=f.fromInt(0,!0);f.ONE=f.fromInt(1);f.UONE=f.fromInt(1,!0);f.NEG_ONE=f.fromInt(-1);f.MAX_VALUE=f.fromBits(-1,2147483647,!1);f.MIN_VALUE=f.fromBits(0,-2147483648,!1);var Fe=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Me=/^(\+|-)?(Infinity|inf)$/i,xe=/^(\+|-)?NaN$/i,K=6111,nt=-6176,Tt=6176,It=34,ut=h.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),dt=h.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),$t=h.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),He=/^([-+])?(\d+)?$/,Je=31,At=16383,Ce=30,Pe=31;function _t(e){return!isNaN(parseInt(e,10))}function Ve(e){let t=f.fromNumber(1e9),n=f.fromNumber(0);if(!e.parts[0]&&!e.parts[1]&&!e.parts[2]&&!e.parts[3])return{quotient:e,rem:n};for(let s=0;s<=3;s++)n=n.shiftLeft(32),n=n.add(new f(e.parts[s],0)),e.parts[s]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function We(e,t){if(!e&&!t)return{high:f.fromNumber(0),low:f.fromNumber(0)};let n=e.shiftRightUnsigned(32),s=new f(e.getLowBits(),0),r=t.shiftRightUnsigned(32),i=new f(t.getLowBits(),0),u=n.multiply(r),a=n.multiply(i),I=s.multiply(r),S=s.multiply(i);return u=u.add(a.shiftRightUnsigned(32)),a=new f(a.getLowBits(),0).add(I).add(S.shiftRightUnsigned(32)),u=u.add(a.shiftRightUnsigned(32)),S=a.shiftLeft(32).add(new f(S.getLowBits(),0)),{high:u,low:S}}function Ye(e,t){let n=e.high>>>0,s=t.high>>>0;if(n>>0,i=t.low>>>0;if(r=7e3)throw new o(""+t+" not a valid Decimal128 string");let U=t.match(Fe),ft=t.match(Me),N=t.match(xe);if(!U&&!ft&&!N||t.length===0)throw new o(""+t+" not a valid Decimal128 string");if(U){let c=U[2],l=U[4],p=U[5],B=U[6];l&&B===void 0&&M(t,"missing exponent power"),l&&c===void 0&&M(t,"missing exponent base"),l===void 0&&(p||B)&&M(t,"missing e before exponent")}if((t[g]==="+"||t[g]==="-")&&(r=!0,s=t[g++]==="-"),!_t(t[g])&&t[g]!=="."){if(t[g]==="i"||t[g]==="I")return new e(s?dt:$t);if(t[g]==="N")return new e(ut)}for(;_t(t[g])||t[g]===".";){if(t[g]==="."){i&&M(t,"contains multiple periods"),i=!0,g=g+1;continue}d$+16384?$=nt:$=$-w;$>K;){if(E=E+1,E>=It){if(a===0){$=K;break}M(t,"overflow")}$=$-1}if(n.allowRounding){for(;$=5&&(p=1,l===5)){p=O[E]%2===1?1:0;for(let B=m+E+2;B=0&&++O[B]>9;B--)if(O[B]=0,B===0)if($>8&255,A[g++]=b.low.low>>16&255,A[g++]=b.low.low>>24&255,A[g++]=b.low.high&255,A[g++]=b.low.high>>8&255,A[g++]=b.low.high>>16&255,A[g++]=b.low.high>>24&255,A[g++]=b.high.low&255,A[g++]=b.high.low>>8&255,A[g++]=b.high.low>>16&255,A[g++]=b.high.low>>24&255,A[g++]=b.high.high&255,A[g++]=b.high.high>>8&255,A[g++]=b.high.high>>16&255,A[g++]=b.high.high>>24&255,new e(A)}toString(){let t,n=0,s=new Array(36);for(let g=0;g>26&Je;if(L>>3===3){if(L===Ce)return w.join("")+"Infinity";if(L===Pe)return"NaN";t=E>>15&At,u=8+(E>>14&1)}else u=E>>14&7,t=E>>17&At;let T=t-Tt;if(a.parts[0]=(E&16383)+((u&15)<<14),a.parts[1]=x,a.parts[2]=d,a.parts[3]=O,a.parts[0]===0&&a.parts[1]===0&&a.parts[2]===0&&a.parts[3]===0)i=!0;else for(S=3;S>=0;S--){let g=0,U=Ve(a);if(a=U.quotient,g=U.rem.low,!!g)for(I=8;I>=0;I--)s[S*9+I]=g%10,g=Math.floor(g/10)}if(i)n=1,s[r]=0;else for(n=36;!s[r];)n=n-1,r=r+1;let F=n-1+T;if(F>=34||F<=-7||T>0){if(n>34)return w.push("0"),T>0?w.push(`E+${T}`):T<0&&w.push(`E${T}`),w.join("");w.push(`${s[r++]}`),n=n-1,n&&w.push(".");for(let g=0;g0?w.push(`+${F}`):w.push(`${F}`)}else if(T>=0)for(let g=0;g0)for(let U=0;U>8&255,s[9]=n>>16&255,s}toString(t){return t==="base64"?h.toBase64(this.id):t==="hex"?this.toHexString():this.toHexString()}toJSON(){return this.toHexString()}static is(t){return t!=null&&typeof t=="object"&&"_bsontype"in t&&t._bsontype==="ObjectId"}equals(t){if(t==null)return!1;if(e.is(t))return this[H][11]===t[H][11]&&h.equals(this[H],t[H]);if(typeof t=="string")return t.toLowerCase()===this.toHexString();if(typeof t=="object"&&typeof t.toHexString=="function"){let n=t.toHexString(),s=this.toHexString();return typeof n=="string"&&n.toLowerCase()===s}return!1}getTimestamp(){let t=new Date,n=Q.fromUint8Array(this.id).getUint32(0,!1);return t.setTime(Math.floor(n)*1e3),t}static createPk(){return new e}static createFromTime(t){let n=h.fromNumberArray([0,0,0,0,0,0,0,0,0,0,0,0]);return Q.fromUint8Array(n).setUint32(0,t,!1),new e(n)}static createFromHexString(t){if(t?.length!==24)throw new o("hex string must be 24 characters");return new e(h.fromHex(t))}static createFromBase64(t){if(t?.length!==16)throw new o("base64 string must be 16 characters");return new e(h.fromBase64(t))}static isValid(t){if(t==null)return!1;try{return new e(t),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(t){return new e(t.$oid)}inspect(t,n,s){return s??=j,`new ObjectId(${s(this.toHexString(),n)})`}};k.index=Math.floor(Math.random()*16777215);function qe(e){return e.split("").sort().join("")}var q=class e extends D{get _bsontype(){return"BSONRegExp"}constructor(t,n){if(super(),this.pattern=t,this.options=qe(n??""),this.pattern.indexOf("\0")!==-1)throw new o(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(this.options.indexOf("\0")!==-1)throw new o(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let s=0;sa);s??=j;let i=r(s(this.pattern),"regexp"),u=r(s(this.options),"regexp");return`new BSONRegExp(${i}, ${u})`}},ot=class e extends D{get _bsontype(){return"BSONSymbol"}constructor(t){super(),this.value=t}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(t){return new e(t.$symbol)}inspect(t,n,s){return s??=j,`new BSONSymbol(${s(this.value,n)})`}},Ze=f,et=class e extends Ze{get _bsontype(){return"Timestamp"}constructor(t){if(t==null)super(0,0,!0);else if(typeof t=="bigint")super(t,!0);else if(f.isLong(t))super(t.low,t.high,!0);else if(typeof t=="object"&&"t"in t&&"i"in t){if(typeof t.t!="number"&&(typeof t.t!="object"||t.t._bsontype!=="Int32"))throw new o("Timestamp constructed from { t, i } must provide t as a number");if(typeof t.i!="number"&&(typeof t.i!="object"||t.i._bsontype!=="Int32"))throw new o("Timestamp constructed from { t, i } must provide i as a number");let n=Number(t.t),s=Number(t.i);if(n<0||Number.isNaN(n))throw new o("Timestamp constructed from { t, i } must provide a positive t");if(s<0||Number.isNaN(s))throw new o("Timestamp constructed from { t, i } must provide a positive i");if(n>4294967295)throw new o("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(s>4294967295)throw new o("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(s,n,!0)}else throw new o("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }")}toJSON(){return{$timestamp:this.toString()}}static fromInt(t){return new e(f.fromInt(t,!0))}static fromNumber(t){return new e(f.fromNumber(t,!0))}static fromBits(t,n){return new e({i:t,t:n})}static fromString(t,n){return new e(f.fromString(t,!0,n))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(t){let n=f.isLong(t.$timestamp.i)?t.$timestamp.i.getLowBitsUnsigned():t.$timestamp.i,s=f.isLong(t.$timestamp.t)?t.$timestamp.t.getLowBitsUnsigned():t.$timestamp.t;return new e({t:s,i:n})}inspect(t,n,s){s??=j;let r=s(this.high>>>0,n),i=s(this.low>>>0,n);return`new Timestamp({ t: ${r}, i: ${i} })`}};et.MAX_VALUE=f.MAX_UNSIGNED_VALUE;var Ke=f.fromNumber(Gt),Ge=f.fromNumber(Xt);function Xe(e,t,n){t=t??{};let s=t&&t.index?t.index:0,r=e[s]|e[s+1]<<8|e[s+2]<<16|e[s+3]<<24;if(r<5)throw new o(`bson size must be >= 5, is ${r}`);if(t.allowObjectSmallerThanBufferSize&&e.length= bson size ${r}`);if(!t.allowObjectSmallerThanBufferSize&&e.length!==r)throw new o(`buffer length ${e.length} must === bson size ${r}`);if(r+s>e.byteLength)throw new o(`(bson size ${r} + options.index ${s} must be <= buffer length ${e.byteLength})`);if(e[s+r-1]!==0)throw new o("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return lt(e,s,t,n)}var Qe=/^\$ref$|^\$id$|^\$db$/;function lt(e,t,n,s=!1){let r=n.fieldsAsRaw==null?null:n.fieldsAsRaw,i=n.raw==null?!1:n.raw,u=typeof n.bsonRegExp=="boolean"?n.bsonRegExp:!1,a=n.promoteBuffers??!1,I=n.promoteLongs??!0,S=n.promoteValues??!0,w=n.useBigInt64??!1;if(w&&!S)throw new o("Must either request bigint or Long for int64 deserialization");if(w&&!I)throw new o("Must either request bigint or Long for int64 deserialization");let m=n.validation==null?{utf8:!0}:n.validation,O=!0,d,x=new Set,E=m.utf8;if(typeof E=="boolean")d=E;else{O=!1;let N=Object.keys(E).map(function(y){return E[y]});if(N.length===0)throw new o("UTF-8 validation setting cannot be empty");if(typeof N[0]!="boolean")throw new o("Invalid UTF-8 validation option, must specify boolean values");if(d=N[0],!N.every(y=>y===d))throw new o("Invalid UTF-8 validation option - keys must be all true or all false")}if(!O)for(let N of Object.keys(E))x.add(N);let $=t;if(e.length<5)throw new o("corrupt bson message < 5 bytes long");let L=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(L<5||L>e.length)throw new o("corrupt bson message");let T=s?[]:{},F=0,g=!1,U=s?!1:null,ft=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;!g;){let N=e[t++];if(N===0)break;let y=t;for(;e[y]!==0&&y=e.byteLength)throw new o("Bad BSON Document: illegal CString");let b=s?F++:h.toUTF8(e,t,y,!1),A=!0;O||x.has(b)?A=d:A=!d,U!==!1&&b[0]==="$"&&(U=Qe.test(b));let c;if(t=y+1,N===Qt){let l=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(l<=0||l>e.length-t||e[t+l-1]!==0)throw new o("bad string length in bson");c=h.toUTF8(e,t,t+l-1,A),t=t+l}else if(N===se){let l=h.allocate(12);l.set(e.subarray(t,t+12)),c=new k(l),t=t+12}else if(N===St&&S===!1)c=new tt(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(N===St)c=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(N===wt&&S===!1)c=new v(ft.getFloat64(t,!0)),t=t+8;else if(N===wt)c=ft.getFloat64(t,!0),t=t+8;else if(N===ie){let l=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,p=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;c=new Date(new f(l,p).toNumber())}else if(N===re){if(e[t]!==0&&e[t]!==1)throw new o("illegal boolean type value");c=e[t++]===1}else if(N===vt){let l=t,p=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(p<=0||p>e.length-t)throw new o("bad embedded document length in bson");if(i)c=e.slice(t,t+p);else{let B=n;O||(B={...n,validation:{utf8:A}}),c=lt(e,l,B,!1)}t=t+p}else if(N===te){let l=t,p=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,B=n,R=t+p;if(r&&r[b]&&(B={...n,raw:!0}),O||(B={...B,validation:{utf8:A}}),c=lt(e,l,B,!0),t=t+p,e[t-1]!==0)throw new o("invalid array terminator byte");if(t!==R)throw new o("corrupted array bson")}else if(N===ne)c=void 0;else if(N===oe)c=null;else if(N===ge){let l=Q.fromUint8Array(e.subarray(t,t+8)),p=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,B=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,R=new f(p,B);w?c=l.getBigInt64(0,!0):I&&S===!0?c=R.lessThanOrEqual(Ke)&&R.greaterThanOrEqual(Ge)?R.toNumber():R:c=R}else if(N===ue){let l=h.allocate(16);l.set(e.subarray(t,t+16),0),t=t+16,c=new st(l)}else if(N===ee){let l=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,p=l,B=e[t++];if(l<0)throw new o("Negative binary type element size found");if(l>e.byteLength)throw new o("Binary type size larger than document size");if(e.slice!=null){if(B===_.SUBTYPE_BYTE_ARRAY){if(l=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,l<0)throw new o("Negative binary type element size found for subtype 0x02");if(l>p-4)throw new o("Binary type with subtype 0x02 contains too long binary size");if(lp-4)throw new o("Binary type with subtype 0x02 contains too long binary size");if(l=e.length)throw new o("Bad BSON Document: illegal CString");let l=h.toUTF8(e,t,y,!1);for(t=y+1,y=t;e[y]!==0&&y=e.length)throw new o("Bad BSON Document: illegal CString");let p=h.toUTF8(e,t,y,!1);t=y+1;let B=new Array(p.length);for(y=0;y=e.length)throw new o("Bad BSON Document: illegal CString");let l=h.toUTF8(e,t,y,!1);for(t=y+1,y=t;e[y]!==0&&y=e.length)throw new o("Bad BSON Document: illegal CString");let p=h.toUTF8(e,t,y,!1);t=y+1,c=new q(l,p)}else if(N===ce){let l=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(l<=0||l>e.length-t||e[t+l-1]!==0)throw new o("bad string length in bson");let p=h.toUTF8(e,t,t+l-1,A);c=S?p:new ot(p),t=t+l}else if(N===ae){let l=e[t++]+e[t++]*256+e[t++]*65536+e[t++]*16777216,p=e[t++]+e[t++]*256+e[t++]*65536+e[t++]*(1<<24);c=new et({i:l,t:p})}else if(N===ye)c=new it;else if(N===me)c=new rt;else if(N===le){let l=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(l<=0||l>e.length-t||e[t+l-1]!==0)throw new o("bad string length in bson");let p=h.toUTF8(e,t,t+l-1,A);c=new Y(p),t=t+l}else if(N===he){let l=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(l<4+4+4+1)throw new o("code_w_scope total size shorter minimum expected length");let p=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(p<=0||p>e.length-t||e[t+p-1]!==0)throw new o("bad string length in bson");let B=h.toUTF8(e,t,t+p-1,A);t=t+p;let R=t,at=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,Yt=lt(e,R,n,!1);if(t=t+at,l<4+4+at+p)throw new o("code_w_scope total size is too short, truncating scope");if(l>4+4+at+p)throw new o("code_w_scope total size is too long, clips outer document");c=new Y(B,Yt)}else if(N===fe){let l=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(l<=0||l>e.length-t||e[t+l-1]!==0)throw new o("bad string length in bson");if(m!=null&&m.utf8&&!Mt(e,t,t+l-1))throw new o("Invalid UTF-8 string in BSON document");let p=h.toUTF8(e,t,t+l-1,!1);t=t+l;let B=h.allocate(12);B.set(e.subarray(t,t+12),0);let R=new k(B);t=t+12,c=new P(p,R)}else throw new o(`Detected unknown BSON type ${N.toString(16)} for fieldname "${b}"`);b==="__proto__"?Object.defineProperty(T,b,{value:c,writable:!0,enumerable:!0,configurable:!0}):T[b]=c}if(L!==t-$)throw s?new o("corrupt array bson"):new o("corrupt object bson");if(!U)return T;if(Ht(T)){let N=Object.assign({},T);return delete N.$ref,delete N.$id,delete N.$db,new P(T.$ref,T.$id,T.$db,N)}return T}var Ct=new DataView(new ArrayBuffer(8),0,8),hn=new Uint8Array(Ct.buffer,0,4),an=new Uint8Array(Ct.buffer,0,8);function ve(e){return e!=null&&typeof e=="object"&&"_bsontype"in e&&typeof e._bsontype=="string"}var tn={$oid:k,$binary:_,$uuid:_,$symbol:ot,$numberInt:tt,$numberDecimal:st,$numberDouble:v,$numberLong:f,$minKey:it,$maxKey:rt,$regex:q,$regularExpression:q,$timestamp:et};function Pt(e,t={}){if(typeof e=="number"){let s=e<=Dt&&e>=jt,r=e<=zt&&e>=Ft;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&&!Object.is(e,-0)){if(s)return new tt(e);if(r)return t.useBigInt64?BigInt(e):f.fromNumber(e)}return new v(e)}if(e==null||typeof e!="object")return e;if(e.$undefined)return null;let n=Object.keys(e).filter(s=>s.startsWith("$")&&e[s]!=null);for(let s=0;su.startsWith("$")),i=!0;if(r.forEach(u=>{["$ref","$id","$db"].indexOf(u)===-1&&(i=!1)}),i)return P.fromExtendedJSON(s)}return e}function en(e,t){return e.map((n,s)=>{t.seenObjects.push({propertyName:`index ${s}`,obj:null});try{return J(n,t)}finally{t.seenObjects.pop()}})}function Ut(e){let t=e.toISOString();return e.getUTCMilliseconds()!==0?t:t.slice(0,-5)+"Z"}function J(e,t){if(e instanceof Map||Rt(e)){let n=Object.create(null);for(let[s,r]of e){if(typeof s!="string")throw new o("Can only serialize maps with string keys");n[s]=r}return J(n,t)}if((typeof e=="object"||typeof e=="function")&&e!==null){let n=t.seenObjects.findIndex(s=>s.obj===e);if(n!==-1){let s=t.seenObjects.map(w=>w.propertyName),r=s.slice(0,n).map(w=>`${w} -> `).join(""),i=s[n],u=" -> "+s.slice(n+1,s.length-1).map(w=>`${w} -> `).join(""),a=s[s.length-1],I=" ".repeat(r.length+i.length/2),S="-".repeat(u.length+(i.length+a.length)/2-1);throw new o(`Converting circular structure to EJSON:
- ${r}${i}${u}${a}
- ${I}\\${S}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return en(e,t);if(e===void 0)return null;if(e instanceof Date||Zt(e)){let n=e.getTime(),s=n>-1&&n<2534023188e5;return t.legacy?t.relaxed&&s?{$date:e.getTime()}:{$date:Ut(e)}:t.relaxed&&s?{$date:Ut(e)}:{$date:{$numberLong:e.getTime().toString()}}}if(typeof e=="number"&&(!t.relaxed||!isFinite(e))){if(Number.isInteger(e)&&!Object.is(e,-0)){if(e>=jt&&e<=Dt)return{$numberInt:e.toString()};if(e>=Ft&&e<=zt)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if(typeof e=="bigint")return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||qt(e)){let n=e.flags;if(n===void 0){let r=e.toString().match(/[gimuy]*$/);r&&(n=r[0])}return new q(e.source,n).toExtendedJSON(t)}return e!=null&&typeof e=="object"?sn(e,t):e}var nn={Binary:e=>new _(e.value(),e.sub_type),Code:e=>new Y(e.code,e.scope),DBRef:e=>new P(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new st(e.bytes),Double:e=>new v(e.value),Int32:e=>new tt(e.value),Long:e=>f.fromBits(e.low!=null?e.low:e.low_,e.low!=null?e.high:e.high_,e.low!=null?e.unsigned:e.unsigned_),MaxKey:()=>new rt,MinKey:()=>new it,ObjectId:e=>new k(e),BSONRegExp:e=>new q(e.pattern,e.options),BSONSymbol:e=>new ot(e.value),Timestamp:e=>et.fromBits(e.low,e.high)};function sn(e,t){if(e==null||typeof e!="object")throw new o("not an object instance");let n=e._bsontype;if(typeof n>"u"){let s={};for(let r of Object.keys(e)){t.seenObjects.push({propertyName:r,obj:null});try{let i=J(e[r],t);r==="__proto__"?Object.defineProperty(s,r,{value:i,writable:!0,enumerable:!0,configurable:!0}):s[r]=i}finally{t.seenObjects.pop()}}return s}else{if(e!=null&&typeof e=="object"&&typeof e._bsontype=="string"&&e[Symbol.for("@@mdb.bson.version")]!==mt)throw new yt;if(ve(e)){let s=e;if(typeof s.toExtendedJSON!="function"){let r=nn[e._bsontype];if(!r)throw new o("Unrecognized or invalid _bsontype: "+e._bsontype);s=r(s)}return n==="Code"&&s.scope?s=new Y(s.code,J(s.scope,t)):n==="DBRef"&&s.oid&&(s=new P(J(s.collection,t),J(s.oid,t),J(s.db,t),J(s.fields,t))),s.toExtendedJSON(t)}else throw new o("_bsontype must be a string, but was: "+typeof n)}}function Vt(e,t){let n={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,(s,r)=>{if(s.indexOf("\0")!==-1)throw new o(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(s)}`);return Pt(r,n)})}function Wt(e,t,n,s){n!=null&&typeof n=="object"&&(s=n,n=0),t!=null&&typeof t=="object"&&!Array.isArray(t)&&(s=t,t=void 0,n=0);let r=Object.assign({relaxed:!0,legacy:!1},s,{seenObjects:[{propertyName:"(root)",obj:null}]}),i=J(e,r);return JSON.stringify(i,t,n)}function rn(e,t){return t=t||{},JSON.parse(Wt(e,t))}function on(e,t){return t=t||{},Vt(JSON.stringify(e),t)}var Z=Object.create(null);Z.parse=Vt;Z.stringify=Wt;Z.serialize=rn;Z.deserialize=on;Object.freeze(Z);var fn=1024*1024*17,gn=h.allocate(fn);function ln(e,t={}){return Xe(h.toLocalBufferType(e),t)}var mn=Z.deserialize;export{ln as deserialize,mn as toJson};
+"use strict";var bson=(()=>{var Ut=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var tn=Object.getOwnPropertyNames;var en=Object.prototype.hasOwnProperty;var nn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,s)=>(typeof require<"u"?require:t)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var sn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),rn=(e,t)=>{for(var s in t)Ut(e,s,{get:t[s],enumerable:!0})},on=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of tn(t))!en.call(e,r)&&r!==s&&Ut(e,r,{get:()=>t[r],enumerable:!(n=ve(t,r))||n.enumerable});return e};var fn=e=>on(Ut({},"__esModule",{value:!0}),e);var oe=sn(U=>{"use strict";function vt(e){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e))}function tt(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}function lt(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function te(e){return Object.prototype.toString.call(e)==="[object Map]"}function ct(e){return Object.prototype.toString.call(e)==="[object Date]"}function F(e,t){return JSON.stringify(e,(s,n)=>typeof n=="bigint"?{$numberLong:`${n}`}:te(n)?Object.fromEntries(n):n)}function ln(e){if(e!=null&&typeof e=="object"&&"stylize"in e&&typeof e.stylize=="function")return e.stylize}var et=6,At=2147483647,$t=-2147483648,Oe=Math.pow(2,63)-1,be=-Math.pow(2,63),Ee=Math.pow(2,53),Te=-Math.pow(2,53),bt=1,Ie=2,ee=3,de=4,ne=5,cn=6,Ae=7,$e=8,_e=9,se=10,Et=11,hn=12,re=13,Ue=14,Le=15,at=16,Re=17,ie=18,De=19,je=255,ze=127,an=0,Tt=4,Fe=Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127}),a=class extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(t,s){super(t,s)}static isBSONError(t){return t!=null&&typeof t=="object"&&"bsonError"in t&&t.bsonError===!0&&"name"in t&&"message"in t&&"stack"in t}},P=class extends a{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${et}.x.x`)}},yt=class extends a{get name(){return"BSONRuntimeError"}constructor(t){super(t)}},gn=128,un=192,yn=224,mn=240,wn=248,pn=192,Sn=224,Nn=240,Bn=128;function Me(e,t,s){let n=0;for(let r=t;r20)return null;if(n===1&&e[t]<128)return String.fromCharCode(e[t]);if(n===2&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(n===3&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);let r=[];for(let o=t;o127)return null;r.push(c)}return String.fromCharCode(...r)}function On(e){return Z.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}var bn=(()=>{try{return nn("crypto").randomBytes}catch{return On}})(),Z={toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return Buffer.from(e);throw new a(`Cannot create Buffer from ${String(e)}`)},allocate(e){return Buffer.alloc(e)},equals(e,t){return Z.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},toBase64(e){return Z.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return Z.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return Z.toLocalBufferType(e).toString("hex")},fromUTF8(e){return Buffer.from(e,"utf8")},toUTF8(e,t,s,n){let r=s-t<=20?xe(e,t,s):null;if(r!=null)return r;let o=Z.toLocalBufferType(e).toString("utf8",t,s);if(n){for(let c=0;cMath.floor(Math.random()*256)))}var In=(()=>{let{crypto:e}=globalThis;if(e!=null&&typeof e.getRandomValues=="function")return t=>e.getRandomValues(gt.allocate(t));if(En()){let{console:t}=globalThis;t?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return Tn})(),fe=/(\d|[a-f])/i,gt={toLocalBufferType(e){let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="Uint8Array")return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return new Uint8Array(e);throw new a(`Cannot make a Uint8Array from ${String(e)}`)},allocate(e){if(typeof e!="number")throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let s=0;st.charCodeAt(0))},toBase64(e){return btoa(gt.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,t=>t.charCodeAt(0)&255)},toISO88591(e){return Array.from(Uint16Array.from(e),t=>String.fromCharCode(t)).join("")},fromHex(e){let t=e.length%2===0?e:e.slice(0,e.length-1),s=[];for(let n=0;nt.toString(16).padStart(2,"0")).join("")},fromUTF8(e){return new TextEncoder().encode(e)},toUTF8(e,t,s,n){let r=s-t<=20?xe(e,t,s):null;if(r!=null)return r;if(n)try{return new TextDecoder("utf8",{fatal:n}).decode(e.slice(t,s))}catch(o){throw new a("Invalid UTF-8 string in BSON document",{cause:o})}return new TextDecoder("utf8",{fatal:n}).decode(e.slice(t,s))},utf8ByteLength(e){return gt.fromUTF8(e).byteLength},encodeUTF8Into(e,t,s){let n=gt.fromUTF8(t);return e.set(n,s),n.byteLength},randomBytes:In},dn=typeof Buffer=="function"&&Buffer.prototype?._isBuffer!==!0,l=dn?Z:gt,ut=class extends DataView{static fromUint8Array(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}},j=class{get[Symbol.for("@@mdb.bson.version")](){return et}[Symbol.for("nodejs.util.inspect.custom")](t,s,n){return this.inspect(t,s,n)}},_=class e extends j{get _bsontype(){return"Binary"}constructor(t,s){if(super(),t!=null&&typeof t=="string"&&!ArrayBuffer.isView(t)&&!vt(t)&&!Array.isArray(t))throw new a("Binary can only be constructed from Uint8Array or number[]");this.sub_type=s??e.BSON_BINARY_SUBTYPE_DEFAULT,t==null?(this.buffer=l.allocate(e.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?l.fromNumberArray(t):l.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if(typeof t=="string"&&t.length!==1)throw new a("only accepts single character String");if(typeof t!="number"&&t.length!==1)throw new a("only accepts single character Uint8Array or Array");let s;if(typeof t=="string"?s=t.charCodeAt(0):typeof t=="number"?s=t:s=t[0],s<0||s>255)throw new a("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=s;else{let n=l.allocate(e.BUFFER_SIZE+this.buffer.length);n.set(this.buffer,0),this.buffer=n,this.buffer[this.position++]=s}}write(t,s){if(s=typeof s=="number"?s:this.position,this.buffer.byteLengththis.position?s+t.length:this.position;else if(typeof t=="string")throw new a("input cannot be string")}read(t,s){return s=s&&s>0?s:this.position,this.buffer.slice(t,t+s)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return l.toBase64(this.buffer)}toString(t){return t==="hex"?l.toHex(this.buffer):t==="base64"?l.toBase64(this.buffer):t==="utf8"||t==="utf-8"?l.toUTF8(this.buffer,0,this.buffer.byteLength,!1):l.toUTF8(this.buffer,0,this.buffer.byteLength,!1)}toExtendedJSON(t){t=t||{};let s=l.toBase64(this.buffer),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:s,$type:n.length===1?"0"+n:n}:{$binary:{base64:s,subType:n.length===1?"0"+n:n}}}toUUID(){if(this.sub_type===e.SUBTYPE_UUID)return new W(this.buffer.slice(0,this.position));throw new a(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${e.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,s){return new e(l.fromHex(t),s)}static createFromBase64(t,s){return new e(l.fromBase64(t),s)}static fromExtendedJSON(t,s){s=s||{};let n,r;if("$binary"in t?s.legacy&&typeof t.$binary=="string"&&"$type"in t?(r=t.$type?parseInt(t.$type,16):0,n=l.fromBase64(t.$binary)):typeof t.$binary!="string"&&(r=t.$binary.subType?parseInt(t.$binary.subType,16):0,n=l.fromBase64(t.$binary.base64)):"$uuid"in t&&(r=4,n=W.bytesFromString(t.$uuid)),!n)throw new a(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return r===Tt?new W(n):new e(n,r)}inspect(t,s,n){n??=F;let r=l.toBase64(this.buffer.subarray(0,this.position)),o=n(r,s),c=n(this.sub_type,s);return`Binary.createFromBase64(${o}, ${c})`}};_.BSON_BINARY_SUBTYPE_DEFAULT=0;_.BUFFER_SIZE=256;_.SUBTYPE_DEFAULT=0;_.SUBTYPE_FUNCTION=1;_.SUBTYPE_BYTE_ARRAY=2;_.SUBTYPE_UUID_OLD=3;_.SUBTYPE_UUID=4;_.SUBTYPE_MD5=5;_.SUBTYPE_ENCRYPTED=6;_.SUBTYPE_COLUMN=7;_.SUBTYPE_USER_DEFINED=128;var Lt=16,An=/^[0-9A-F]{32}$/i,$n=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,W=class e extends _{constructor(t){let s;if(t==null)s=e.generate();else if(t instanceof e)s=l.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&t.byteLength===Lt)s=l.toLocalBufferType(t);else if(typeof t=="string")s=e.bytesFromString(t);else throw new a("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");super(s,Tt)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[l.toHex(this.buffer.subarray(0,4)),l.toHex(this.buffer.subarray(4,6)),l.toHex(this.buffer.subarray(6,8)),l.toHex(this.buffer.subarray(8,10)),l.toHex(this.buffer.subarray(10,16))].join("-"):l.toHex(this.buffer)}toString(t){return t==="hex"?l.toHex(this.id):t==="base64"?l.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof e)return l.equals(t.id,this.id);try{return l.equals(new e(t).id,this.id)}catch{return!1}}toBinary(){return new _(this.id,_.SUBTYPE_UUID)}static generate(){let t=l.randomBytes(Lt);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,t}static isValid(t){return t?typeof t=="string"?e.isValidUUIDString(t):tt(t)?t.byteLength===Lt:t._bsontype==="Binary"&&t.sub_type===this.SUBTYPE_UUID&&t.buffer.byteLength===16:!1}static createFromHexString(t){let s=e.bytesFromString(t);return new e(s)}static createFromBase64(t){return new e(l.fromBase64(t))}static bytesFromString(t){if(!e.isValidUUIDString(t))throw new a("UUID string representation must be 32 hex digits or canonical hyphenated representation");return l.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return An.test(t)||$n.test(t)}inspect(t,s,n){return n??=F,`new UUID(${n(this.toHexString(),s)})`}},Y=class e extends j{get _bsontype(){return"Code"}constructor(t,s){super(),this.code=t.toString(),this.scope=s??null}toJSON(){return this.scope!=null?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(t){return new e(t.$code,t.$scope)}inspect(t,s,n){n??=F;let r=n(this.code,s),o=r.includes(`
+`);this.scope!=null&&(r+=`,${o?`
+`:" "}${n(this.scope,s)}`);let c=o&&this.scope===null;return`new Code(${o?`
+`:""}${r}${c?`
+`:""})`}};function Je(e){return e!=null&&typeof e=="object"&&"$id"in e&&e.$id!=null&&"$ref"in e&&typeof e.$ref=="string"&&(!("$db"in e)||"$db"in e&&typeof e.$db=="string")}var C=class e extends j{get _bsontype(){return"DBRef"}constructor(t,s,n,r){super();let o=t.split(".");o.length===2&&(n=o.shift(),t=o.shift()),this.collection=t,this.oid=s,this.db=n,this.fields=r||{}}get namespace(){return this.collection}set namespace(t){this.collection=t}toJSON(){let t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(t.$db=this.db),t}toExtendedJSON(t){t=t||{};let s={$ref:this.collection,$id:this.oid};return t.legacy||(this.db&&(s.$db=this.db),s=Object.assign(s,this.fields)),s}static fromExtendedJSON(t){let s=Object.assign({},t);return delete s.$ref,delete s.$id,delete s.$db,new e(t.$ref,t.$id,t.$db,s)}inspect(t,s,n){n??=F;let r=[n(this.namespace,s),n(this.oid,s),...this.db?[n(this.db,s)]:[],...Object.keys(this.fields).length>0?[n(this.fields,s)]:[]];return r[1]=n===F?`new ObjectId(${r[1]})`:r[1],`new DBRef(${r.join(", ")})`}},M;try{M=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}var le=65536,_n=1<<24,ht=le*le,Ce=ht*ht,ce=Ce/2,he={},ae={},Un=20,Ln=/^(\+?0|(\+|-)?[1-9][0-9]*)$/,y=class e extends j{get _bsontype(){return"Long"}get __isLong__(){return!0}constructor(t=0,s,n){super(),typeof t=="bigint"?Object.assign(this,e.fromBigInt(t,!!s)):typeof t=="string"?Object.assign(this,e.fromString(t,!!s)):(this.low=t|0,this.high=s|0,this.unsigned=!!n)}static fromBits(t,s,n){return new e(t,s,n)}static fromInt(t,s){let n,r,o;return s?(t>>>=0,(o=0<=t&&t<256)&&(r=ae[t],r)?r:(n=e.fromBits(t,(t|0)<0?-1:0,!0),o&&(ae[t]=n),n)):(t|=0,(o=-128<=t&&t<128)&&(r=he[t],r)?r:(n=e.fromBits(t,t<0?-1:0,!1),o&&(he[t]=n),n))}static fromNumber(t,s){if(isNaN(t))return s?e.UZERO:e.ZERO;if(s){if(t<0)return e.UZERO;if(t>=Ce)return e.MAX_UNSIGNED_VALUE}else{if(t<=-ce)return e.MIN_VALUE;if(t+1>=ce)return e.MAX_VALUE}return t<0?e.fromNumber(-t,s).neg():e.fromBits(t%ht|0,t/ht|0,s)}static fromBigInt(t,s){return e.fromString(t.toString(),s)}static fromString(t,s,n){if(t.length===0)throw new a("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e.ZERO;if(typeof s=="number"?(n=s,s=!1):s=!!s,n=n||10,n<2||360)throw new a("interior hyphen");if(r===0)return e.fromString(t.substring(1),s,n).neg();let o=e.fromNumber(Math.pow(n,8)),c=e.ZERO;for(let g=0;g>>16,n=this.high&65535,r=this.low>>>16,o=this.low&65535,c=t.high>>>16,g=t.high&65535,i=t.low>>>16,S=t.low&65535,u=0,f=0,h=0,N=0;return N+=o+S,h+=N>>>16,N&=65535,h+=r+i,f+=h>>>16,h&=65535,f+=n+g,u+=f>>>16,f&=65535,u+=s+c,u&=65535,e.fromBits(h<<16|N,u<<16|f,this.unsigned)}and(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)}compare(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;let s=this.isNegative(),n=t.isNegative();return s&&!n?-1:!s&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1}comp(t){return this.compare(t)}divide(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw new a("division by zero");if(M){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;let o=(this.unsigned?M.div_u:M.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(o,M.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;let s,n,r;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;r=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(s=this.shr(1).div(t).shl(1),s.eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(n=this.sub(t.mul(s)),r=s.add(n.div(t)),r));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=e.ZERO}for(n=this;n.gte(t);){s=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));let o=Math.ceil(Math.log(s)/Math.LN2),c=o<=48?1:Math.pow(2,o-48),g=e.fromNumber(s),i=g.mul(t);for(;i.isNegative()||i.gt(n);)s-=c,g=e.fromNumber(s,this.unsigned),i=g.mul(t);g.isZero()&&(g=e.ONE),r=r.add(g),n=n.sub(i)}return r}div(t){return this.divide(t)}equals(t){return e.isLong(t)||(t=e.fromValue(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low}eq(t){return this.equals(t)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();let t=this.high!==0?this.high:this.low,s;for(s=31;s>0&&!(t&1<0}gt(t){return this.greaterThan(t)}greaterThanOrEqual(t){return this.comp(t)>=0}gte(t){return this.greaterThanOrEqual(t)}ge(t){return this.greaterThanOrEqual(t)}isEven(){return(this.low&1)===0}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return(this.low&1)===1}isPositive(){return this.unsigned||this.high>=0}isZero(){return this.high===0&&this.low===0}lessThan(t){return this.comp(t)<0}lt(t){return this.lessThan(t)}lessThanOrEqual(t){return this.comp(t)<=0}lte(t){return this.lessThanOrEqual(t)}modulo(t){if(e.isLong(t)||(t=e.fromValue(t)),M){let s=(this.unsigned?M.rem_u:M.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(s,M.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))}mod(t){return this.modulo(t)}rem(t){return this.modulo(t)}multiply(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),M){let p=M.mul(this.low,this.high,t.low,t.high);return e.fromBits(p,M.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);let s=this.high>>>16,n=this.high&65535,r=this.low>>>16,o=this.low&65535,c=t.high>>>16,g=t.high&65535,i=t.low>>>16,S=t.low&65535,u=0,f=0,h=0,N=0;return N+=o*S,h+=N>>>16,N&=65535,h+=r*S,f+=h>>>16,h&=65535,h+=o*i,f+=h>>>16,h&=65535,f+=n*S,u+=f>>>16,f&=65535,f+=r*i,u+=f>>>16,f&=65535,f+=o*g,u+=f>>>16,f&=65535,u+=s*S+n*i+r*g+o*c,u&=65535,e.fromBits(h<<16|N,u<<16|f,this.unsigned)}mul(t){return this.multiply(t)}negate(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)}neg(){return this.negate()}not(){return e.fromBits(~this.low,~this.high,this.unsigned)}notEquals(t){return!this.equals(t)}neq(t){return this.notEquals(t)}ne(t){return this.notEquals(t)}or(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)}shiftLeft(t){return e.isLong(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?e.fromBits(this.low<>>32-t,this.unsigned):e.fromBits(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)}shr(t){return this.shiftRight(t)}shiftRightUnsigned(t){if(e.isLong(t)&&(t=t.toInt()),t&=63,t===0)return this;{let s=this.high;if(t<32){let n=this.low;return e.fromBits(n>>>t|s<<32-t,s>>>t,this.unsigned)}else return t===32?e.fromBits(s,0,this.unsigned):e.fromBits(s>>>t-32,0,this.unsigned)}}shr_u(t){return this.shiftRightUnsigned(t)}shru(t){return this.shiftRightUnsigned(t)}subtract(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())}sub(t){return this.subtract(t)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*ht+(this.low>>>0):this.high*ht+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(t){return t?this.toBytesLE():this.toBytesBE()}toBytesLE(){let t=this.high,s=this.low;return[s&255,s>>>8&255,s>>>16&255,s>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]}toBytesBE(){let t=this.high,s=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,s>>>24,s>>>16&255,s>>>8&255,s&255]}toSigned(){return this.unsigned?e.fromBits(this.low,this.high,!1):this}toString(t){if(t=t||10,t<2||36>>0).toString(t);if(n=o,n.isZero())return g+r;for(;g.length<6;)g="0"+g;r=""+g+r}}toUnsigned(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)}xor(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)}eqz(){return this.isZero()}le(t){return this.lessThanOrEqual(t)}toExtendedJSON(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(t,s){let{useBigInt64:n=!1,relaxed:r=!0}={...s};if(t.$numberLong.length>Un)throw new a("$numberLong string is too long");if(!Ln.test(t.$numberLong))throw new a(`$numberLong string "${t.$numberLong}" is in an invalid format`);if(n){let c=BigInt(t.$numberLong);return BigInt.asIntN(64,c)}let o=e.fromString(t.$numberLong);return r?o.toNumber():o}inspect(t,s,n){n??=F;let r=n(this.toString(),s),o=this.unsigned?`, ${n(this.unsigned,s)}`:"";return`new Long(${r}${o})`}};y.TWO_PWR_24=y.fromInt(_n);y.MAX_UNSIGNED_VALUE=y.fromBits(-1,-1,!0);y.ZERO=y.fromInt(0);y.UZERO=y.fromInt(0,!0);y.ONE=y.fromInt(1);y.UONE=y.fromInt(1,!0);y.NEG_ONE=y.fromInt(-1);y.MAX_VALUE=y.fromBits(-1,2147483647,!1);y.MIN_VALUE=y.fromBits(0,-2147483648,!1);var Rn=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Dn=/^(\+|-)?(Infinity|inf)$/i,jn=/^(\+|-)?NaN$/i,ft=6111,wt=-6176,ge=6176,ue=34,Rt=l.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),ye=l.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),me=l.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),zn=/^([-+])?(\d+)?$/,Fn=31,we=16383,Mn=30,xn=31;function pe(e){return!isNaN(parseInt(e,10))}function Jn(e){let t=y.fromNumber(1e9),s=y.fromNumber(0);if(!e.parts[0]&&!e.parts[1]&&!e.parts[2]&&!e.parts[3])return{quotient:e,rem:s};for(let n=0;n<=3;n++)s=s.shiftLeft(32),s=s.add(new y(e.parts[n],0)),e.parts[n]=s.div(t).low,s=s.modulo(t);return{quotient:e,rem:s}}function Cn(e,t){if(!e&&!t)return{high:y.fromNumber(0),low:y.fromNumber(0)};let s=e.shiftRightUnsigned(32),n=new y(e.getLowBits(),0),r=t.shiftRightUnsigned(32),o=new y(t.getLowBits(),0),c=s.multiply(r),g=s.multiply(o),i=n.multiply(r),S=n.multiply(o);return c=c.add(g.shiftRightUnsigned(32)),g=new y(g.getLowBits(),0).add(i).add(S.shiftRightUnsigned(32)),c=c.add(g.shiftRightUnsigned(32)),S=g.shiftLeft(32).add(new y(S.getLowBits(),0)),{high:c,low:S}}function Hn(e,t){let s=e.high>>>0,n=t.high>>>0;if(s>>0,o=t.low>>>0;if(r=7e3)throw new a(""+t+" not a valid Decimal128 string");let R=t.match(Rn),Nt=t.match(Dn),T=t.match(jn);if(!R&&!Nt&&!T||t.length===0)throw new a(""+t+" not a valid Decimal128 string");if(R){let w=R[2],m=R[4],b=R[5],I=R[6];m&&I===void 0&&J(t,"missing exponent power"),m&&w===void 0&&J(t,"missing exponent base"),m===void 0&&(b||I)&&J(t,"missing e before exponent")}if((t[B]==="+"||t[B]==="-")&&(r=!0,n=t[B++]==="-"),!pe(t[B])&&t[B]!=="."){if(t[B]==="i"||t[B]==="I")return new e(n?ye:me);if(t[B]==="N")return new e(Rt)}for(;pe(t[B])||t[B]===".";){if(t[B]==="."){o&&J(t,"contains multiple periods"),o=!0,B=B+1;continue}N$+16384?$=wt:$=$-u;$>ft;){if(E=E+1,E>=ue){if(g===0){$=ft;break}J(t,"overflow")}$=$-1}if(s.allowRounding){for(;$=5&&(b=1,m===5)){b=h[E]%2===1?1:0;for(let I=f+E+2;I=0&&++h[I]>9;I--)if(h[I]=0,I===0)if($>8&255,L[B++]=d.low.low>>16&255,L[B++]=d.low.low>>24&255,L[B++]=d.low.high&255,L[B++]=d.low.high>>8&255,L[B++]=d.low.high>>16&255,L[B++]=d.low.high>>24&255,L[B++]=d.high.low&255,L[B++]=d.high.low>>8&255,L[B++]=d.high.low>>16&255,L[B++]=d.high.low>>24&255,L[B++]=d.high.high&255,L[B++]=d.high.high>>8&255,L[B++]=d.high.high>>16&255,L[B++]=d.high.high>>24&255,new e(L)}toString(){let t,s=0,n=new Array(36);for(let B=0;B>26&Fn;if(D>>3===3){if(D===Mn)return u.join("")+"Infinity";if(D===xn)return"NaN";t=E>>15&we,c=8+(E>>14&1)}else c=E>>14&7,t=E>>17&we;let A=t-ge;if(g.parts[0]=(E&16383)+((c&15)<<14),g.parts[1]=p,g.parts[2]=N,g.parts[3]=h,g.parts[0]===0&&g.parts[1]===0&&g.parts[2]===0&&g.parts[3]===0)o=!0;else for(S=3;S>=0;S--){let B=0,R=Jn(g);if(g=R.quotient,B=R.rem.low,!!B)for(i=8;i>=0;i--)n[S*9+i]=B%10,B=Math.floor(B/10)}if(o)s=1,n[r]=0;else for(s=36;!n[r];)s=s-1,r=r+1;let x=s-1+A;if(x>=34||x<=-7||A>0){if(s>34)return u.push("0"),A>0?u.push(`E+${A}`):A<0&&u.push(`E${A}`),u.join("");u.push(`${n[r++]}`),s=s-1,s&&u.push(".");for(let B=0;B0?u.push(`+${x}`):u.push(`${x}`)}else if(A>=0)for(let B=0;B0)for(let R=0;R>8&255,n[9]=s>>16&255,n}toString(t){return t==="base64"?l.toBase64(this.id):t==="hex"?this.toHexString():this.toHexString()}toJSON(){return this.toHexString()}static is(t){return t!=null&&typeof t=="object"&&"_bsontype"in t&&t._bsontype==="ObjectId"}equals(t){if(t==null)return!1;if(e.is(t))return this[H][11]===t[H][11]&&l.equals(this[H],t[H]);if(typeof t=="string")return t.toLowerCase()===this.toHexString();if(typeof t=="object"&&typeof t.toHexString=="function"){let s=t.toHexString(),n=this.toHexString();return typeof s=="string"&&s.toLowerCase()===n}return!1}getTimestamp(){let t=new Date,s=ut.fromUint8Array(this.id).getUint32(0,!1);return t.setTime(Math.floor(s)*1e3),t}static createPk(){return new e}static createFromTime(t){let s=l.fromNumberArray([0,0,0,0,0,0,0,0,0,0,0,0]);return ut.fromUint8Array(s).setUint32(0,t,!1),new e(s)}static createFromHexString(t){if(t?.length!==24)throw new a("hex string must be 24 characters");return new e(l.fromHex(t))}static createFromBase64(t){if(t?.length!==16)throw new a("base64 string must be 16 characters");return new e(l.fromBase64(t))}static isValid(t){if(t==null)return!1;try{return new e(t),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(t){return new e(t.$oid)}inspect(t,s,n){return n??=F,`new ObjectId(${n(this.toHexString(),s)})`}};k.index=Math.floor(Math.random()*16777215);function Bt(e,t,s){let n=5;if(Array.isArray(e))for(let r=0;r=Te&&t<=Ee&&t>=$t&&t<=At?(e!=null?l.utf8ByteLength(e)+1:0)+(4+1):(e!=null?l.utf8ByteLength(e)+1:0)+(8+1);case"undefined":return n||!r?(e!=null?l.utf8ByteLength(e)+1:0)+1:0;case"boolean":return(e!=null?l.utf8ByteLength(e)+1:0)+(1+1);case"object":if(t!=null&&typeof t._bsontype=="string"&&t[Symbol.for("@@mdb.bson.version")]!==et)throw new P;if(t==null||t._bsontype==="MinKey"||t._bsontype==="MaxKey")return(e!=null?l.utf8ByteLength(e)+1:0)+1;if(t._bsontype==="ObjectId")return(e!=null?l.utf8ByteLength(e)+1:0)+(12+1);if(t instanceof Date||ct(t))return(e!=null?l.utf8ByteLength(e)+1:0)+(8+1);if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer||vt(t))return(e!=null?l.utf8ByteLength(e)+1:0)+(1+4+1)+t.byteLength;if(t._bsontype==="Long"||t._bsontype==="Double"||t._bsontype==="Timestamp")return(e!=null?l.utf8ByteLength(e)+1:0)+(8+1);if(t._bsontype==="Decimal128")return(e!=null?l.utf8ByteLength(e)+1:0)+(16+1);if(t._bsontype==="Code")return t.scope!=null&&Object.keys(t.scope).length>0?(e!=null?l.utf8ByteLength(e)+1:0)+1+4+4+l.utf8ByteLength(t.code.toString())+1+Bt(t.scope,s,r):(e!=null?l.utf8ByteLength(e)+1:0)+1+4+l.utf8ByteLength(t.code.toString())+1;if(t._bsontype==="Binary"){let o=t;return o.sub_type===_.SUBTYPE_BYTE_ARRAY?(e!=null?l.utf8ByteLength(e)+1:0)+(o.position+1+4+1+4):(e!=null?l.utf8ByteLength(e)+1:0)+(o.position+1+4+1)}else{if(t._bsontype==="Symbol")return(e!=null?l.utf8ByteLength(e)+1:0)+l.utf8ByteLength(t.value)+4+1+1;if(t._bsontype==="DBRef"){let o=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return t.db!=null&&(o.$db=t.db),(e!=null?l.utf8ByteLength(e)+1:0)+1+Bt(o,s,r)}else return t instanceof RegExp||lt(t)?(e!=null?l.utf8ByteLength(e)+1:0)+1+l.utf8ByteLength(t.source)+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:t._bsontype==="BSONRegExp"?(e!=null?l.utf8ByteLength(e)+1:0)+1+l.utf8ByteLength(t.pattern)+1+l.utf8ByteLength(t.options)+1:(e!=null?l.utf8ByteLength(e)+1:0)+Bt(t,s,r)+1}case"function":if(s)return(e!=null?l.utf8ByteLength(e)+1:0)+1+4+l.utf8ByteLength(t.toString())+1}return 0}function Pn(e){return e.split("").sort().join("")}var q=class e extends j{get _bsontype(){return"BSONRegExp"}constructor(t,s){if(super(),this.pattern=t,this.options=Pn(s??""),this.pattern.indexOf("\0")!==-1)throw new a(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(this.options.indexOf("\0")!==-1)throw new a(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let n=0;ng);n??=F;let o=r(n(this.pattern),"regexp"),c=r(n(this.options),"regexp");return`new BSONRegExp(${o}, ${c})`}},it=class e extends j{get _bsontype(){return"BSONSymbol"}constructor(t){super(),this.value=t}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(t){return new e(t.$symbol)}inspect(t,s,n){return n??=F,`new BSONSymbol(${n(this.value,s)})`}},Wn=y,Q=class e extends Wn{get _bsontype(){return"Timestamp"}constructor(t){if(t==null)super(0,0,!0);else if(typeof t=="bigint")super(t,!0);else if(y.isLong(t))super(t.low,t.high,!0);else if(typeof t=="object"&&"t"in t&&"i"in t){if(typeof t.t!="number"&&(typeof t.t!="object"||t.t._bsontype!=="Int32"))throw new a("Timestamp constructed from { t, i } must provide t as a number");if(typeof t.i!="number"&&(typeof t.i!="object"||t.i._bsontype!=="Int32"))throw new a("Timestamp constructed from { t, i } must provide i as a number");let s=Number(t.t),n=Number(t.i);if(s<0||Number.isNaN(s))throw new a("Timestamp constructed from { t, i } must provide a positive t");if(n<0||Number.isNaN(n))throw new a("Timestamp constructed from { t, i } must provide a positive i");if(s>4294967295)throw new a("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(n>4294967295)throw new a("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(n,s,!0)}else throw new a("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }")}toJSON(){return{$timestamp:this.toString()}}static fromInt(t){return new e(y.fromInt(t,!0))}static fromNumber(t){return new e(y.fromNumber(t,!0))}static fromBits(t,s){return new e({i:t,t:s})}static fromString(t,s){return new e(y.fromString(t,!0,s))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(t){let s=y.isLong(t.$timestamp.i)?t.$timestamp.i.getLowBitsUnsigned():t.$timestamp.i,n=y.isLong(t.$timestamp.t)?t.$timestamp.t.getLowBitsUnsigned():t.$timestamp.t;return new e({t:n,i:s})}inspect(t,s,n){n??=F;let r=n(this.high>>>0,s),o=n(this.low>>>0,s);return`new Timestamp({ t: ${r}, i: ${o} })`}};Q.MAX_VALUE=y.MAX_UNSIGNED_VALUE;var Yn=y.fromNumber(Ee),kn=y.fromNumber(Te);function He(e,t,s){t=t??{};let n=t&&t.index?t.index:0,r=e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24;if(r<5)throw new a(`bson size must be >= 5, is ${r}`);if(t.allowObjectSmallerThanBufferSize&&e.length= bson size ${r}`);if(!t.allowObjectSmallerThanBufferSize&&e.length!==r)throw new a(`buffer length ${e.length} must === bson size ${r}`);if(r+n>e.byteLength)throw new a(`(bson size ${r} + options.index ${n} must be <= buffer length ${e.byteLength})`);if(e[n+r-1]!==0)throw new a("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return Ot(e,n,t,s)}var qn=/^\$ref$|^\$id$|^\$db$/;function Ot(e,t,s,n=!1){let r=s.fieldsAsRaw==null?null:s.fieldsAsRaw,o=s.raw==null?!1:s.raw,c=typeof s.bsonRegExp=="boolean"?s.bsonRegExp:!1,g=s.promoteBuffers??!1,i=s.promoteLongs??!0,S=s.promoteValues??!0,u=s.useBigInt64??!1;if(u&&!S)throw new a("Must either request bigint or Long for int64 deserialization");if(u&&!i)throw new a("Must either request bigint or Long for int64 deserialization");let f=s.validation==null?{utf8:!0}:s.validation,h=!0,N,p=new Set,E=f.utf8;if(typeof E=="boolean")N=E;else{h=!1;let T=Object.keys(E).map(function(O){return E[O]});if(T.length===0)throw new a("UTF-8 validation setting cannot be empty");if(typeof T[0]!="boolean")throw new a("Invalid UTF-8 validation option, must specify boolean values");if(N=T[0],!T.every(O=>O===N))throw new a("Invalid UTF-8 validation option - keys must be all true or all false")}if(!h)for(let T of Object.keys(E))p.add(T);let $=t;if(e.length<5)throw new a("corrupt bson message < 5 bytes long");let D=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(D<5||D>e.length)throw new a("corrupt bson message");let A=n?[]:{},x=0,B=!1,R=n?!1:null,Nt=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;!B;){let T=e[t++];if(T===0)break;let O=t;for(;e[O]!==0&&O=e.byteLength)throw new a("Bad BSON Document: illegal CString");let d=n?x++:l.toUTF8(e,t,O,!1),L=!0;h||p.has(d)?L=N:L=!N,R!==!1&&d[0]==="$"&&(R=qn.test(d));let w;if(t=O+1,T===Ie){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");w=l.toUTF8(e,t,t+m-1,L),t=t+m}else if(T===Ae){let m=l.allocate(12);m.set(e.subarray(t,t+12)),w=new k(m),t=t+12}else if(T===at&&S===!1)w=new X(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(T===at)w=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(T===bt&&S===!1)w=new G(Nt.getFloat64(t,!0)),t=t+8;else if(T===bt)w=Nt.getFloat64(t,!0),t=t+8;else if(T===_e){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;w=new Date(new y(m,b).toNumber())}else if(T===$e){if(e[t]!==0&&e[t]!==1)throw new a("illegal boolean type value");w=e[t++]===1}else if(T===ee){let m=t,b=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(b<=0||b>e.length-t)throw new a("bad embedded document length in bson");if(o)w=e.slice(t,t+b);else{let I=s;h||(I={...s,validation:{utf8:L}}),w=Ot(e,m,I,!1)}t=t+b}else if(T===de){let m=t,b=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,I=s,z=t+b;if(r&&r[d]&&(I={...s,raw:!0}),h||(I={...I,validation:{utf8:L}}),w=Ot(e,m,I,!0),t=t+b,e[t-1]!==0)throw new a("invalid array terminator byte");if(t!==z)throw new a("corrupted array bson")}else if(T===cn)w=void 0;else if(T===se)w=null;else if(T===ie){let m=ut.fromUint8Array(e.subarray(t,t+8)),b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,I=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,z=new y(b,I);u?w=m.getBigInt64(0,!0):i&&S===!0?w=z.lessThanOrEqual(Yn)&&z.greaterThanOrEqual(kn)?z.toNumber():z:w=z}else if(T===De){let m=l.allocate(16);m.set(e.subarray(t,t+16),0),t=t+16,w=new nt(m)}else if(T===ne){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,b=m,I=e[t++];if(m<0)throw new a("Negative binary type element size found");if(m>e.byteLength)throw new a("Binary type size larger than document size");if(e.slice!=null){if(I===_.SUBTYPE_BYTE_ARRAY){if(m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,m<0)throw new a("Negative binary type element size found for subtype 0x02");if(m>b-4)throw new a("Binary type with subtype 0x02 contains too long binary size");if(mb-4)throw new a("Binary type with subtype 0x02 contains too long binary size");if(m=e.length)throw new a("Bad BSON Document: illegal CString");let m=l.toUTF8(e,t,O,!1);for(t=O+1,O=t;e[O]!==0&&O=e.length)throw new a("Bad BSON Document: illegal CString");let b=l.toUTF8(e,t,O,!1);t=O+1;let I=new Array(b.length);for(O=0;O=e.length)throw new a("Bad BSON Document: illegal CString");let m=l.toUTF8(e,t,O,!1);for(t=O+1,O=t;e[O]!==0&&O=e.length)throw new a("Bad BSON Document: illegal CString");let b=l.toUTF8(e,t,O,!1);t=O+1,w=new q(m,b)}else if(T===Ue){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");let b=l.toUTF8(e,t,t+m-1,L);w=S?b:new it(b),t=t+m}else if(T===Re){let m=e[t++]+e[t++]*256+e[t++]*65536+e[t++]*16777216,b=e[t++]+e[t++]*256+e[t++]*65536+e[t++]*(1<<24);w=new Q({i:m,t:b})}else if(T===je)w=new rt;else if(T===ze)w=new st;else if(T===re){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");let b=l.toUTF8(e,t,t+m-1,L);w=new Y(b),t=t+m}else if(T===Le){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<4+4+4+1)throw new a("code_w_scope total size shorter minimum expected length");let b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(b<=0||b>e.length-t||e[t+b-1]!==0)throw new a("bad string length in bson");let I=l.toUTF8(e,t,t+b-1,L);t=t+b;let z=t,_t=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,Qe=Ot(e,z,s,!1);if(t=t+_t,m<4+4+_t+b)throw new a("code_w_scope total size is too short, truncating scope");if(m>4+4+_t+b)throw new a("code_w_scope total size is too long, clips outer document");w=new Y(I,Qe)}else if(T===hn){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");if(f!=null&&f.utf8&&!Me(e,t,t+m-1))throw new a("Invalid UTF-8 string in BSON document");let b=l.toUTF8(e,t,t+m-1,!1);t=t+m;let I=l.allocate(12);I.set(e.subarray(t,t+12),0);let z=new k(I);t=t+12,w=new C(b,z)}else throw new a(`Detected unknown BSON type ${T.toString(16)} for fieldname "${d}"`);d==="__proto__"?Object.defineProperty(A,d,{value:w,writable:!0,enumerable:!0,configurable:!0}):A[d]=w}if(D!==t-$)throw n?new a("corrupt array bson"):new a("corrupt object bson");if(!R)return A;if(Je(A)){let T=Object.assign({},A);return delete T.$ref,delete T.$id,delete T.$db,new C(A.$ref,A.$id,A.$db,T)}return A}var It=/\x00/,Ne=new Set(["$db","$ref","$id","$clusterTime"]);function Dt(e,t,s,n){e[n++]=Ie;let r=l.encodeUTF8Into(e,t,n);n=n+r+1,e[n-1]=0;let o=l.encodeUTF8Into(e,s,n+4);return e[n+3]=o+1>>24&255,e[n+2]=o+1>>16&255,e[n+1]=o+1>>8&255,e[n]=o+1&255,n=n+4+o,e[n++]=0,n}var mt=new DataView(new ArrayBuffer(8),0,8),Zn=new Uint8Array(mt.buffer,0,4),dt=new Uint8Array(mt.buffer,0,8);function jt(e,t,s,n){let o=!Object.is(s,-0)&&Number.isSafeInteger(s)&&s<=At&&s>=$t?at:bt;o===at?mt.setInt32(0,s,!0):mt.setFloat64(0,s,!0);let c=o===at?Zn:dt;e[n++]=o;let g=l.encodeUTF8Into(e,t,n);return n=n+g,e[n++]=0,e.set(c,n),n+=c.byteLength,n}function zt(e,t,s,n){e[n++]=ie;let r=l.encodeUTF8Into(e,t,n);return n+=r,e[n++]=0,mt.setBigInt64(0,s,!0),e.set(dt,n),n+=dt.byteLength,n}function pt(e,t,s,n){e[n++]=se;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,n}function Ft(e,t,s,n){e[n++]=$e;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,e[n++]=s?1:0,n}function Mt(e,t,s,n){e[n++]=_e;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=y.fromNumber(s.getTime()),c=o.getLowBits(),g=o.getHighBits();return e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255,e[n++]=g&255,e[n++]=g>>8&255,e[n++]=g>>16&255,e[n++]=g>>24&255,n}function xt(e,t,s,n){e[n++]=Et;let r=l.encodeUTF8Into(e,t,n);if(n=n+r,e[n++]=0,s.source&&s.source.match(It)!=null)throw new a("value "+s.source+" must not contain null bytes");return n=n+l.encodeUTF8Into(e,s.source,n),e[n++]=0,s.ignoreCase&&(e[n++]=105),s.global&&(e[n++]=115),s.multiline&&(e[n++]=109),e[n++]=0,n}function Jt(e,t,s,n){e[n++]=Et;let r=l.encodeUTF8Into(e,t,n);if(n=n+r,e[n++]=0,s.pattern.match(It)!=null)throw new a("pattern "+s.pattern+" must not contain null bytes");n=n+l.encodeUTF8Into(e,s.pattern,n),e[n++]=0;let o=s.options.split("").sort().join("");return n=n+l.encodeUTF8Into(e,o,n),e[n++]=0,n}function Ct(e,t,s,n){s===null?e[n++]=se:s._bsontype==="MinKey"?e[n++]=je:e[n++]=ze;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,n}function Ht(e,t,s,n){e[n++]=Ae;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.id;if(tt(o))for(let c=0;c<12;c++)e[n++]=o[c];else throw new a("object ["+JSON.stringify(s)+"] is not a valid ObjectId");return n}function Vt(e,t,s,n){e[n++]=ne;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.length;return e[n++]=o&255,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=an,e.set(s,n),n=n+o,n}function Pt(e,t,s,n,r,o,c,g,i){if(i.has(s))throw new a("Cannot convert circular structure to BSON");i.add(s),e[n++]=Array.isArray(s)?de:ee;let S=l.encodeUTF8Into(e,t,n);n=n+S,e[n++]=0;let u=St(e,s,r,n,o+1,c,g,i);return i.delete(s),u}function Wt(e,t,s,n){e[n++]=De;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,e.set(s.bytes.subarray(0,16),n),n+16}function Yt(e,t,s,n){e[n++]=s._bsontype==="Long"?ie:Re;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.getLowBits(),c=s.getHighBits();return e[n++]=o&255,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255,n}function kt(e,t,s,n){s=s.valueOf(),e[n++]=at;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,e[n++]=s&255,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,n}function qt(e,t,s,n){e[n++]=bt;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,mt.setFloat64(0,s.value,!0),e.set(dt,n),n=n+8,n}function Zt(e,t,s,n){e[n++]=re;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.toString(),c=l.encodeUTF8Into(e,o,n+4)+1;return e[n]=c&255,e[n+1]=c>>8&255,e[n+2]=c>>16&255,e[n+3]=c>>24&255,n=n+4+c-1,e[n++]=0,n}function Kt(e,t,s,n,r=!1,o=0,c=!1,g=!0,i){if(s.scope&&typeof s.scope=="object"){e[n++]=Le;let S=l.encodeUTF8Into(e,t,n);n=n+S,e[n++]=0;let u=n,f=s.code;n=n+4;let h=l.encodeUTF8Into(e,f,n+4)+1;e[n]=h&255,e[n+1]=h>>8&255,e[n+2]=h>>16&255,e[n+3]=h>>24&255,e[n+4+h-1]=0,n=n+h+4;let N=St(e,s.scope,r,n,o+1,c,g,i);n=N-1;let p=N-u;e[u++]=p&255,e[u++]=p>>8&255,e[u++]=p>>16&255,e[u++]=p>>24&255,e[n++]=0}else{e[n++]=re;let S=l.encodeUTF8Into(e,t,n);n=n+S,e[n++]=0;let u=s.code.toString(),f=l.encodeUTF8Into(e,u,n+4)+1;e[n]=f&255,e[n+1]=f>>8&255,e[n+2]=f>>16&255,e[n+3]=f>>24&255,n=n+4+f-1,e[n++]=0}return n}function Gt(e,t,s,n){e[n++]=ne;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.buffer,c=s.position;return s.sub_type===_.SUBTYPE_BYTE_ARRAY&&(c=c+4),e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255,e[n++]=s.sub_type,s.sub_type===_.SUBTYPE_BYTE_ARRAY&&(c=c-4,e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255),e.set(o,n),n=n+s.position,n}function Xt(e,t,s,n){e[n++]=Ue;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=l.encodeUTF8Into(e,s.value,n+4)+1;return e[n]=o&255,e[n+1]=o>>8&255,e[n+2]=o>>16&255,e[n+3]=o>>24&255,n=n+4+o-1,e[n++]=0,n}function Qt(e,t,s,n,r,o,c){e[n++]=ee;let g=l.encodeUTF8Into(e,t,n);n=n+g,e[n++]=0;let i=n,S={$ref:s.collection||s.namespace,$id:s.oid};s.db!=null&&(S.$db=s.db),S=Object.assign(S,s.fields);let u=St(e,S,!1,n,r+1,o,!0,c),f=u-i;return e[i++]=f&255,e[i++]=f>>8&255,e[i++]=f>>16&255,e[i++]=f>>24&255,u}function St(e,t,s,n,r,o,c,g){if(g==null){if(t==null)return e[0]=5,e[1]=0,e[2]=0,e[3]=0,e[4]=0,5;if(Array.isArray(t))throw new a("serialize does not support an array as the root input");if(typeof t!="object")throw new a("serialize does not support non-object as the root input");if("_bsontype"in t&&typeof t._bsontype=="string")throw new a("BSON types cannot be serialized as a document");if(ct(t)||lt(t)||tt(t)||vt(t))throw new a("date, regexp, typedarray, and arraybuffer cannot be BSON documents");g=new Set}g.add(t);let i=n+4;if(Array.isArray(t))for(let u=0;u>8&255,e[n++]=S>>16&255,e[n++]=S>>24&255,i}function Kn(e){return e!=null&&typeof e=="object"&&"_bsontype"in e&&typeof e._bsontype=="string"}var Gn={$oid:k,$binary:_,$uuid:_,$symbol:it,$numberInt:X,$numberDecimal:nt,$numberDouble:G,$numberLong:y,$minKey:rt,$maxKey:st,$regex:q,$regularExpression:q,$timestamp:Q};function Ve(e,t={}){if(typeof e=="number"){let n=e<=At&&e>=$t,r=e<=Oe&&e>=be;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&&!Object.is(e,-0)){if(n)return new X(e);if(r)return t.useBigInt64?BigInt(e):y.fromNumber(e)}return new G(e)}if(e==null||typeof e!="object")return e;if(e.$undefined)return null;let s=Object.keys(e).filter(n=>n.startsWith("$")&&e[n]!=null);for(let n=0;nc.startsWith("$")),o=!0;if(r.forEach(c=>{["$ref","$id","$db"].indexOf(c)===-1&&(o=!1)}),o)return C.fromExtendedJSON(n)}return e}function Xn(e,t){return e.map((s,n)=>{t.seenObjects.push({propertyName:`index ${n}`,obj:null});try{return V(s,t)}finally{t.seenObjects.pop()}})}function Be(e){let t=e.toISOString();return e.getUTCMilliseconds()!==0?t:t.slice(0,-5)+"Z"}function V(e,t){if(e instanceof Map||te(e)){let s=Object.create(null);for(let[n,r]of e){if(typeof n!="string")throw new a("Can only serialize maps with string keys");s[n]=r}return V(s,t)}if((typeof e=="object"||typeof e=="function")&&e!==null){let s=t.seenObjects.findIndex(n=>n.obj===e);if(s!==-1){let n=t.seenObjects.map(u=>u.propertyName),r=n.slice(0,s).map(u=>`${u} -> `).join(""),o=n[s],c=" -> "+n.slice(s+1,n.length-1).map(u=>`${u} -> `).join(""),g=n[n.length-1],i=" ".repeat(r.length+o.length/2),S="-".repeat(c.length+(o.length+g.length)/2-1);throw new a(`Converting circular structure to EJSON:
+ ${r}${o}${c}${g}
+ ${i}\\${S}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return Xn(e,t);if(e===void 0)return null;if(e instanceof Date||ct(e)){let s=e.getTime(),n=s>-1&&s<2534023188e5;return t.legacy?t.relaxed&&n?{$date:e.getTime()}:{$date:Be(e)}:t.relaxed&&n?{$date:Be(e)}:{$date:{$numberLong:e.getTime().toString()}}}if(typeof e=="number"&&(!t.relaxed||!isFinite(e))){if(Number.isInteger(e)&&!Object.is(e,-0)){if(e>=$t&&e<=At)return{$numberInt:e.toString()};if(e>=be&&e<=Oe)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if(typeof e=="bigint")return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||lt(e)){let s=e.flags;if(s===void 0){let r=e.toString().match(/[gimuy]*$/);r&&(s=r[0])}return new q(e.source,s).toExtendedJSON(t)}return e!=null&&typeof e=="object"?vn(e,t):e}var Qn={Binary:e=>new _(e.value(),e.sub_type),Code:e=>new Y(e.code,e.scope),DBRef:e=>new C(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new nt(e.bytes),Double:e=>new G(e.value),Int32:e=>new X(e.value),Long:e=>y.fromBits(e.low!=null?e.low:e.low_,e.low!=null?e.high:e.high_,e.low!=null?e.unsigned:e.unsigned_),MaxKey:()=>new st,MinKey:()=>new rt,ObjectId:e=>new k(e),BSONRegExp:e=>new q(e.pattern,e.options),BSONSymbol:e=>new it(e.value),Timestamp:e=>Q.fromBits(e.low,e.high)};function vn(e,t){if(e==null||typeof e!="object")throw new a("not an object instance");let s=e._bsontype;if(typeof s>"u"){let n={};for(let r of Object.keys(e)){t.seenObjects.push({propertyName:r,obj:null});try{let o=V(e[r],t);r==="__proto__"?Object.defineProperty(n,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):n[r]=o}finally{t.seenObjects.pop()}}return n}else{if(e!=null&&typeof e=="object"&&typeof e._bsontype=="string"&&e[Symbol.for("@@mdb.bson.version")]!==et)throw new P;if(Kn(e)){let n=e;if(typeof n.toExtendedJSON!="function"){let r=Qn[e._bsontype];if(!r)throw new a("Unrecognized or invalid _bsontype: "+e._bsontype);n=r(n)}return s==="Code"&&n.scope?n=new Y(n.code,V(n.scope,t)):s==="DBRef"&&n.oid&&(n=new C(V(n.collection,t),V(n.oid,t),V(n.db,t),V(n.fields,t))),n.toExtendedJSON(t)}else throw new a("_bsontype must be a string, but was: "+typeof s)}}function Pe(e,t){let s={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,(n,r)=>{if(n.indexOf("\0")!==-1)throw new a(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(n)}`);return Ve(r,s)})}function We(e,t,s,n){s!=null&&typeof s=="object"&&(n=s,s=0),t!=null&&typeof t=="object"&&!Array.isArray(t)&&(n=t,t=void 0,s=0);let r=Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}),o=V(e,r);return JSON.stringify(o,t,s)}function ts(e,t){return t=t||{},JSON.parse(We(e,t))}function es(e,t){return t=t||{},Pe(JSON.stringify(e),t)}var ot=Object.create(null);ot.parse=Pe;ot.stringify=We;ot.serialize=ts;ot.deserialize=es;Object.freeze(ot);var Ye=1024*1024*17,K=l.allocate(Ye);function ke(e){K.lengthss,toJson:()=>rs});var ss=oe().deserialize,rs=oe().EJSON.deserialize;return fn(is);})();
diff --git a/packages/server/src/jsRunner/bundles/bsonPackage.ts b/packages/server/src/jsRunner/bundles/bsonPackage.ts
index b2e9016879..600b18e4c8 100644
--- a/packages/server/src/jsRunner/bundles/bsonPackage.ts
+++ b/packages/server/src/jsRunner/bundles/bsonPackage.ts
@@ -1,4 +1,2 @@
-import { EJSON } from "bson"
-
-export { deserialize } from "bson"
-export const toJson = EJSON.deserialize
+export const deserialize = require("bson").deserialize
+export const toJson = require("bson").EJSON.deserialize
diff --git a/packages/server/src/jsRunner/bundles/index-helpers.ivm.bundle.js b/packages/server/src/jsRunner/bundles/index-helpers.ivm.bundle.js
index 706625b757..ff8d7265c6 100644
--- a/packages/server/src/jsRunner/bundles/index-helpers.ivm.bundle.js
+++ b/packages/server/src/jsRunner/bundles/index-helpers.ivm.bundle.js
@@ -1,4 +1,4 @@
-var De=Object.defineProperty;var un=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var fn=Object.prototype.hasOwnProperty;var Ue=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Z=(e,t)=>()=>(e&&(t=e(e=0)),t);var U=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),on=(e,t)=>{for(var r in t)De(e,r,{get:t[r],enumerable:!0})},an=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sn(t))!fn.call(e,i)&&i!==r&&De(e,i,{get:()=>t[i],enumerable:!(n=un(t,i))||n.enumerable});return e};var cn=e=>an(De({},"__esModule",{value:!0}),e);var gt=U((Te,qe)=>{(function(e,t){typeof Te=="object"&&typeof qe<"u"?qe.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs=t()})(Te,function(){"use strict";var e=1e3,t=6e4,r=36e5,n="millisecond",i="second",u="minute",s="hour",f="day",w="week",g="month",l="quarter",x="year",v="date",a="Invalid Date",T=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,E=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,I={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var h=["th","st","nd","rd"],c=$%100;return"["+$+(h[(c-20)%10]||h[c]||h[0])+"]"}},Y=function($,h,c){var b=String($);return!b||b.length>=h?$:""+Array(h+1-b.length).join(c)+$},F={s:Y,z:function($){var h=-$.utcOffset(),c=Math.abs(h),b=Math.floor(c/60),d=c%60;return(h<=0?"+":"-")+Y(b,2,"0")+":"+Y(d,2,"0")},m:function $(h,c){if(h.date()1)return $(j[0])}else{var _=h.name;S[_]=h,d=_}return!b&&d&&(q=d),d||!b&&q},N=function($,h){if(o($))return $.clone();var c=typeof h=="object"?h:{};return c.date=$,c.args=arguments,new B(c)},O=F;O.l=D,O.i=o,O.w=function($,h){return N($,{locale:h.$L,utc:h.$u,x:h.$x,$offset:h.$offset})};var B=function(){function $(c){this.$L=D(c.locale,null,!0),this.parse(c),this.$x=this.$x||c.x||{},this[p]=!0}var h=$.prototype;return h.parse=function(c){this.$d=function(b){var d=b.date,M=b.utc;if(d===null)return new Date(NaN);if(O.u(d))return new Date;if(d instanceof Date)return new Date(d);if(typeof d=="string"&&!/Z$/i.test(d)){var j=d.match(T);if(j){var _=j[2]-1||0,H=(j[7]||"0").substring(0,3);return M?new Date(Date.UTC(j[1],_,j[3]||1,j[4]||0,j[5]||0,j[6]||0,H)):new Date(j[1],_,j[3]||1,j[4]||0,j[5]||0,j[6]||0,H)}}return new Date(d)}(c),this.init()},h.init=function(){var c=this.$d;this.$y=c.getFullYear(),this.$M=c.getMonth(),this.$D=c.getDate(),this.$W=c.getDay(),this.$H=c.getHours(),this.$m=c.getMinutes(),this.$s=c.getSeconds(),this.$ms=c.getMilliseconds()},h.$utils=function(){return O},h.isValid=function(){return this.$d.toString()!==a},h.isSame=function(c,b){var d=N(c);return this.startOf(b)<=d&&d<=this.endOf(b)},h.isAfter=function(c,b){return N(c){(function(e,t){typeof Ye=="object"&&typeof Ce<"u"?Ce.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_duration=t()})(Ye,function(){"use strict";var e,t,r=1e3,n=6e4,i=36e5,u=864e5,s=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f=31536e6,w=2628e6,g=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,l={years:f,months:w,days:u,hours:i,minutes:n,seconds:r,milliseconds:1,weeks:6048e5},x=function(S){return S instanceof F},v=function(S,p,o){return new F(S,o,p.$l)},a=function(S){return t.p(S)+"s"},T=function(S){return S<0},E=function(S){return T(S)?Math.ceil(S):Math.floor(S)},I=function(S){return Math.abs(S)},Y=function(S,p){return S?T(S)?{negative:!0,format:""+I(S)+p}:{negative:!1,format:""+S+p}:{negative:!1,format:""}},F=function(){function S(o,D,N){var O=this;if(this.$d={},this.$l=N,o===void 0&&(this.$ms=0,this.parseFromMilliseconds()),D)return v(o*l[a(D)],this);if(typeof o=="number")return this.$ms=o,this.parseFromMilliseconds(),this;if(typeof o=="object")return Object.keys(o).forEach(function($){O.$d[a($)]=o[$]}),this.calMilliseconds(),this;if(typeof o=="string"){var B=o.match(g);if(B){var J=B.slice(2).map(function($){return $!=null?Number($):0});return this.$d.years=J[0],this.$d.months=J[1],this.$d.weeks=J[2],this.$d.days=J[3],this.$d.hours=J[4],this.$d.minutes=J[5],this.$d.seconds=J[6],this.calMilliseconds(),this}}return this}var p=S.prototype;return p.calMilliseconds=function(){var o=this;this.$ms=Object.keys(this.$d).reduce(function(D,N){return D+(o.$d[N]||0)*l[N]},0)},p.parseFromMilliseconds=function(){var o=this.$ms;this.$d.years=E(o/f),o%=f,this.$d.months=E(o/w),o%=w,this.$d.days=E(o/u),o%=u,this.$d.hours=E(o/i),o%=i,this.$d.minutes=E(o/n),o%=n,this.$d.seconds=E(o/r),o%=r,this.$d.milliseconds=o},p.toISOString=function(){var o=Y(this.$d.years,"Y"),D=Y(this.$d.months,"M"),N=+this.$d.days||0;this.$d.weeks&&(N+=7*this.$d.weeks);var O=Y(N,"D"),B=Y(this.$d.hours,"H"),J=Y(this.$d.minutes,"M"),$=this.$d.seconds||0;this.$d.milliseconds&&($+=this.$d.milliseconds/1e3,$=Math.round(1e3*$)/1e3);var h=Y($,"S"),c=o.negative||D.negative||O.negative||B.negative||J.negative||h.negative,b=B.format||J.format||h.format?"T":"",d=(c?"-":"")+"P"+o.format+D.format+O.format+b+B.format+J.format+h.format;return d==="P"||d==="-P"?"P0D":d},p.toJSON=function(){return this.toISOString()},p.format=function(o){var D=o||"YYYY-MM-DDTHH:mm:ss",N={Y:this.$d.years,YY:t.s(this.$d.years,2,"0"),YYYY:t.s(this.$d.years,4,"0"),M:this.$d.months,MM:t.s(this.$d.months,2,"0"),D:this.$d.days,DD:t.s(this.$d.days,2,"0"),H:this.$d.hours,HH:t.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:t.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:t.s(this.$d.seconds,2,"0"),SSS:t.s(this.$d.milliseconds,3,"0")};return D.replace(s,function(O,B){return B||String(N[O])})},p.as=function(o){return this.$ms/l[a(o)]},p.get=function(o){var D=this.$ms,N=a(o);return N==="milliseconds"?D%=1e3:D=N==="weeks"?E(D/l[N]):this.$d[N],D||0},p.add=function(o,D,N){var O;return O=D?o*l[a(D)]:x(o)?o.$ms:v(o,this).$ms,v(this.$ms+O*(N?-1:1),this)},p.subtract=function(o,D){return this.add(o,D,!0)},p.locale=function(o){var D=this.clone();return D.$l=o,D},p.clone=function(){return v(this.$ms,this)},p.humanize=function(o){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!o)},p.valueOf=function(){return this.asMilliseconds()},p.milliseconds=function(){return this.get("milliseconds")},p.asMilliseconds=function(){return this.as("milliseconds")},p.seconds=function(){return this.get("seconds")},p.asSeconds=function(){return this.as("seconds")},p.minutes=function(){return this.get("minutes")},p.asMinutes=function(){return this.as("minutes")},p.hours=function(){return this.get("hours")},p.asHours=function(){return this.as("hours")},p.days=function(){return this.get("days")},p.asDays=function(){return this.as("days")},p.weeks=function(){return this.get("weeks")},p.asWeeks=function(){return this.as("weeks")},p.months=function(){return this.get("months")},p.asMonths=function(){return this.as("months")},p.years=function(){return this.get("years")},p.asYears=function(){return this.as("years")},S}(),q=function(S,p,o){return S.add(p.years()*o,"y").add(p.months()*o,"M").add(p.days()*o,"d").add(p.hours()*o,"h").add(p.minutes()*o,"m").add(p.seconds()*o,"s").add(p.milliseconds()*o,"ms")};return function(S,p,o){e=o,t=o().$utils(),o.duration=function(O,B){var J=o.locale();return v(O,{$l:J},B)},o.isDuration=x;var D=p.prototype.add,N=p.prototype.subtract;p.prototype.add=function(O,B){return x(O)?q(this,O,1):D.bind(this)(O,B)},p.prototype.subtract=function(O,B){return x(O)?q(this,O,-1):N.bind(this)(O,B)}}})});var vt=U((Ee,Ie)=>{(function(e,t){typeof Ee=="object"&&typeof Ie<"u"?Ie.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_advancedFormat=t()})(Ee,function(){"use strict";return function(e,t){var r=t.prototype,n=r.format;r.format=function(i){var u=this,s=this.$locale();if(!this.isValid())return n.bind(this)(i);var f=this.$utils(),w=(i||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(g){switch(g){case"Q":return Math.ceil((u.$M+1)/3);case"Do":return s.ordinal(u.$D);case"gggg":return u.weekYear();case"GGGG":return u.isoWeekYear();case"wo":return s.ordinal(u.week(),"W");case"w":case"ww":return f.s(u.week(),g==="w"?1:2,"0");case"W":case"WW":return f.s(u.isoWeek(),g==="W"?1:2,"0");case"k":case"kk":return f.s(String(u.$H===0?24:u.$H),g==="k"?1:2,"0");case"X":return Math.floor(u.$d.getTime()/1e3);case"x":return u.$d.getTime();case"z":return"["+u.offsetName()+"]";case"zzz":return"["+u.offsetName("long")+"]";default:return g}});return n.bind(this)(w)}}})});var $t=U((_e,We)=>{(function(e,t){typeof _e=="object"&&typeof We<"u"?We.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_isoWeek=t()})(_e,function(){"use strict";var e="day";return function(t,r,n){var i=function(f){return f.add(4-f.isoWeekday(),e)},u=r.prototype;u.isoWeekYear=function(){return i(this).year()},u.isoWeek=function(f){if(!this.$utils().u(f))return this.add(7*(f-this.isoWeek()),e);var w,g,l,x,v=i(this),a=(w=this.isoWeekYear(),g=this.$u,l=(g?n.utc:n)().year(w).startOf("year"),x=4-l.isoWeekday(),l.isoWeekday()>4&&(x+=7),l.add(x,e));return v.diff(a,"week")+1},u.isoWeekday=function(f){return this.$utils().u(f)?this.day()||7:this.day(this.day()%7?f:f-7)};var s=u.startOf;u.startOf=function(f,w){var g=this.$utils(),l=!!g.u(w)||w;return g.p(f)==="isoweek"?l?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):s.bind(this)(f,w)}}})});var bt=U((Fe,He)=>{(function(e,t){typeof Fe=="object"&&typeof He<"u"?He.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_weekYear=t()})(Fe,function(){"use strict";return function(e,t){t.prototype.weekYear=function(){var r=this.month(),n=this.week(),i=this.year();return n===1&&r===11?i+1:r===0&&n>=52?i-1:i}}})});var wt=U((Be,Le)=>{(function(e,t){typeof Be=="object"&&typeof Le<"u"?Le.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_weekOfYear=t()})(Be,function(){"use strict";var e="week",t="year";return function(r,n,i){var u=n.prototype;u.week=function(s){if(s===void 0&&(s=null),s!==null)return this.add(7*(s-this.week()),"day");var f=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var w=i(this).startOf(t).add(1,t).date(f),g=i(this).endOf(e);if(w.isBefore(g))return 1}var l=i(this).startOf(t).date(f).startOf(e).subtract(1,"millisecond"),x=this.diff(l,e,!0);return x<0?i(this).startOf("week").week():Math.ceil(x)},u.weeks=function(s){return s===void 0&&(s=null),this.week(s)}}})});var Ot=U((ze,Pe)=>{(function(e,t){typeof ze=="object"&&typeof Pe<"u"?Pe.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_relativeTime=t()})(ze,function(){"use strict";return function(e,t,r){e=e||{};var n=t.prototype,i={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function u(f,w,g,l){return n.fromToBase(f,w,g,l)}r.en.relativeTime=i,n.fromToBase=function(f,w,g,l,x){for(var v,a,T,E=g.$locale().relativeTime||i,I=e.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],Y=I.length,F=0;F0,S<=q.r||!q.r){S<=1&&F>0&&(q=I[F-1]);var p=E[q.l];x&&(S=x(""+S)),a=typeof p=="string"?p.replace("%d",S):p(S,w,q.l,T);break}}if(w)return a;var o=T?E.future:E.past;return typeof o=="function"?o(a):o.replace("%s",a)},n.to=function(f,w){return u(f,w,this,!0)},n.from=function(f,w){return u(f,w,this)};var s=function(f){return f.$u?r.utc():r()};n.toNow=function(f){return this.to(s(this),f)},n.fromNow=function(f){return this.from(s(this),f)}}})});var xt=U((Re,Je)=>{(function(e,t){typeof Re=="object"&&typeof Je<"u"?Je.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_utc=t()})(Re,function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(n,i,u){var s=i.prototype;u.utc=function(a){var T={date:a,utc:!0,args:arguments};return new i(T)},s.utc=function(a){var T=u(this.toDate(),{locale:this.$L,utc:!0});return a?T.add(this.utcOffset(),e):T},s.local=function(){return u(this.toDate(),{locale:this.$L,utc:!1})};var f=s.parse;s.parse=function(a){a.utc&&(this.$u=!0),this.$utils().u(a.$offset)||(this.$offset=a.$offset),f.call(this,a)};var w=s.init;s.init=function(){if(this.$u){var a=this.$d;this.$y=a.getUTCFullYear(),this.$M=a.getUTCMonth(),this.$D=a.getUTCDate(),this.$W=a.getUTCDay(),this.$H=a.getUTCHours(),this.$m=a.getUTCMinutes(),this.$s=a.getUTCSeconds(),this.$ms=a.getUTCMilliseconds()}else w.call(this)};var g=s.utcOffset;s.utcOffset=function(a,T){var E=this.$utils().u;if(E(a))return this.$u?0:E(this.$offset)?g.call(this):this.$offset;if(typeof a=="string"&&(a=function(q){q===void 0&&(q="");var S=q.match(t);if(!S)return null;var p=(""+S[0]).match(r)||["-",0,0],o=p[0],D=60*+p[1]+ +p[2];return D===0?0:o==="+"?D:-D}(a),a===null))return this;var I=Math.abs(a)<=16?60*a:a,Y=this;if(T)return Y.$offset=I,Y.$u=a===0,Y;if(a!==0){var F=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(Y=this.local().add(I+F,e)).$offset=I,Y.$x.$localOffset=F}else Y=this.utc();return Y};var l=s.format;s.format=function(a){var T=a||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,T)},s.valueOf=function(){var a=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*a},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var x=s.toDate;s.toDate=function(a){return a==="s"&&this.$offset?u(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():x.call(this)};var v=s.diff;s.diff=function(a,T,E){if(a&&this.$u===a.$u)return v.call(this,a,T,E);var I=this.local(),Y=u(a).local();return v.call(I,Y,T,E)}}})});var St=U((Ge,Ze)=>{(function(e,t){typeof Ge=="object"&&typeof Ze<"u"?Ze.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_timezone=t()})(Ge,function(){"use strict";var e={year:0,month:1,day:2,hour:3,minute:4,second:5},t={};return function(r,n,i){var u,s=function(l,x,v){v===void 0&&(v={});var a=new Date(l),T=function(E,I){I===void 0&&(I={});var Y=I.timeZoneName||"short",F=E+"|"+Y,q=t[F];return q||(q=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:E,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:Y}),t[F]=q),q}(x,v);return T.formatToParts(a)},f=function(l,x){for(var v=s(l,x),a=[],T=0;T=0&&(a[F]=parseInt(Y,10))}var q=a[3],S=q===24?0:q,p=a[0]+"-"+a[1]+"-"+a[2]+" "+S+":"+a[4]+":"+a[5]+":000",o=+l;return(i.utc(p).valueOf()-(o-=o%1e3))/6e4},w=n.prototype;w.tz=function(l,x){l===void 0&&(l=u);var v=this.utcOffset(),a=this.toDate(),T=a.toLocaleString("en-US",{timeZone:l}),E=Math.round((a-new Date(T))/1e3/60),I=i(T,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(a.getTimezoneOffset()/15)-E,!0);if(x){var Y=I.utcOffset();I=I.add(v-Y,"minute")}return I.$x.$timezone=l,I},w.offsetName=function(l){var x=this.$x.$timezone||i.tz.guess(),v=s(this.valueOf(),x,{timeZoneName:l}).find(function(a){return a.type.toLowerCase()==="timezonename"});return v&&v.value};var g=w.startOf;w.startOf=function(l,x){if(!this.$x||!this.$x.$timezone)return g.call(this,l,x);var v=i(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return g.call(v,l,x).tz(this.$x.$timezone,!0)},i.tz=function(l,x,v){var a=v&&x,T=v||x||u,E=f(+i(),T);if(typeof l!="string")return i(l).tz(T);var I=function(S,p,o){var D=S-60*p*1e3,N=f(D,o);if(p===N)return[D,p];var O=f(D-=60*(N-p)*1e3,o);return N===O?[D,N]:[S-60*Math.min(N,O)*1e3,Math.max(N,O)]}(i.utc(l,a).valueOf(),E,T),Y=I[0],F=I[1],q=i(Y).utcOffset(F);return q.$x.$timezone=T,q},i.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},i.tz.setDefault=function(l){u=l}}})});var Mt=U((ji,Ke)=>{var X=gt();X.extend(yt());X.extend(vt());X.extend($t());X.extend(bt());X.extend(wt());X.extend(Ot());X.extend(xt());X.extend(St());function fe(e){return typeof e=="object"&&typeof e.hash=="object"}function Ve(e){return typeof e=="object"&&typeof e.options=="object"&&typeof e.app=="object"}function Qe(e,t,r){if(fe(e))return Qe({},t,e);if(fe(t))return Qe(e,r,t);let n=Ve(e)?e.context:{};r=r||{},fe(r)||(t=Object.assign({},t,r)),fe(r)&&r.hash.root===!0&&(t=Object.assign({},r.data.root,t));let i=Object.assign({},n,t,r.hash);return Ve(e)||(i=Object.assign({},e,i)),Ve(e)&&e.view&&e.view.data&&(i=Object.assign({},i,e.view.data)),i}function Xe(e,t,r){return fe(t)&&(r=t,t=null),fe(e)&&(r=e,t=null,e=null),{str:e,pattern:t,options:r}}function Nt(e,t,r){let n=Xe(e,t,r),i={lang:"en",date:new Date(n.str)},u=Qe(this,i,{});X.locale(u.lang||u.language)}Ke.exports.date=(e,t,r)=>{let n=Xe(e,t,r);if(n.str==null&&n.pattern==null)return X.locale("en"),X().format("MMMM DD, YYYY");Nt(n.str,n.pattern,n.options);let i=X(new Date(n.str));return typeof n.options=="string"?i=n.options.toLowerCase()==="utc"?i.utc():i.tz(n.options):i=i.tz(X.tz.guess()),n.pattern===""?i.toISOString():i.format(n.pattern)};Ke.exports.duration=(e,t,r)=>{let n=Xe(e,t);Nt(n.str,n.pattern);let i=X.duration(n.str,n.pattern);return r&&!fe(r)?i.format(r):i.humanize()}});var et=U((Ai,At)=>{At.exports=function(e){return e!=null&&(jt(e)||ln(e)||!!e._isBuffer)};function jt(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function ln(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&jt(e.slice(0,0))}});var Dt=U((ki,kt)=>{var dn=et(),hn=Object.prototype.toString;kt.exports=function(t){if(typeof t>"u")return"undefined";if(t===null)return"null";if(t===!0||t===!1||t instanceof Boolean)return"boolean";if(typeof t=="string"||t instanceof String)return"string";if(typeof t=="number"||t instanceof Number)return"number";if(typeof t=="function"||t instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(t))return"array";if(t instanceof RegExp)return"regexp";if(t instanceof Date)return"date";var r=hn.call(t);return r==="[object RegExp]"?"regexp":r==="[object Date]"?"date":r==="[object Arguments]"?"arguments":r==="[object Error]"?"error":dn(t)?"buffer":r==="[object Set]"?"set":r==="[object WeakSet]"?"weakset":r==="[object Map]"?"map":r==="[object WeakMap]"?"weakmap":r==="[object Symbol]"?"symbol":r==="[object Int8Array]"?"int8array":r==="[object Uint8Array]"?"uint8array":r==="[object Uint8ClampedArray]"?"uint8clampedarray":r==="[object Int16Array]"?"int16array":r==="[object Uint16Array]"?"uint16array":r==="[object Int32Array]"?"int32array":r==="[object Uint32Array]"?"uint32array":r==="[object Float32Array]"?"float32array":r==="[object Float64Array]"?"float64array":"object"}});var Yt=U((Di,qt)=>{"use strict";var Ut=Dt(),Tt={arguments:"an arguments object",array:"an array",boolean:"a boolean",buffer:"a buffer",date:"a date",error:"an error",float32array:"a float32array",float64array:"a float64array",function:"a function",int16array:"an int16array",int32array:"an int32array",int8array:"an int8array",map:"a Map",null:"null",number:"a number",object:"an object",regexp:"a regular expression",set:"a Set",string:"a string",symbol:"a symbol",uint16array:"an uint16array",uint32array:"an uint32array",uint8array:"an uint8array",uint8clampedarray:"an uint8clampedarray",undefined:"undefined",weakmap:"a WeakMap",weakset:"a WeakSet"};function tt(e){return Tt[Ut(e)]}tt.types=Tt;tt.typeOf=Ut;qt.exports=tt});var xe=U((Ui,Et)=>{var pn=Object.prototype.toString;Et.exports=function(t){if(t===void 0)return"undefined";if(t===null)return"null";var r=typeof t;if(r==="boolean")return"boolean";if(r==="string")return"string";if(r==="number")return"number";if(r==="symbol")return"symbol";if(r==="function")return $n(t)?"generatorfunction":"function";if(mn(t))return"array";if(On(t))return"buffer";if(wn(t))return"arguments";if(yn(t))return"date";if(gn(t))return"error";if(vn(t))return"regexp";switch(Ct(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(bn(t))return"generator";switch(r=pn.call(t),r){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function Ct(e){return typeof e.constructor=="function"?e.constructor.name:null}function mn(e){return Array.isArray?Array.isArray(e):e instanceof Array}function gn(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function yn(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function vn(e){return e instanceof RegExp?!0:typeof e.flags=="string"&&typeof e.ignoreCase=="boolean"&&typeof e.multiline=="boolean"&&typeof e.global=="boolean"}function $n(e,t){return Ct(e)==="GeneratorFunction"}function bn(e){return typeof e.throw=="function"&&typeof e.return=="function"&&typeof e.next=="function"}function wn(e){try{if(typeof e.length=="number"&&typeof e.callee=="function")return!0}catch(t){if(t.message.indexOf("callee")!==-1)return!0}return!1}function On(e){return e.constructor&&typeof e.constructor.isBuffer=="function"?e.constructor.isBuffer(e):!1}});var ee=U((Wt,Ft)=>{"use strict";var xn=Ue("util"),It=Yt(),Sn=xe(),m=Wt=Ft.exports;m.extend=_t;m.indexOf=Dn;m.escapeExpression=Un;m.isEmpty=Cn;m.createFrame=Tn;m.blockParams=qn;m.appendContextPath=Yn;var Nn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},Mn=/[&<>"'`=]/g,jn=/[&<>"'`=]/;function An(e){return Nn[e]}function _t(e){for(var t=1;t{"use strict";var En=ee();he.contains=function(e,t,r){return e==null||t==null||isNaN(e.length)?!1:e.indexOf(t,r)!==-1};he.chop=function(e){if(typeof e!="string")return"";var t=/^[-_.\W\s]+|[-_.\W\s]+$/g;return e.trim().replace(t,"")};he.changecase=function(e,t){if(typeof e!="string")return"";if(e.length===1)return e.toLowerCase();e=he.chop(e).toLowerCase(),typeof t!="function"&&(t=En.identity);var r=/[-_.\W\s]+(\w|$)/g;return e.replace(r,function(n,i){return t(i)})};he.random=function(e,t){return e+Math.floor(Math.random()*(t-e+1))}});var Bt=U((qi,Ht)=>{"use strict";var In=Se(),V=Ht.exports;V.abs=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.abs(e)};V.add=function(e,t){return!isNaN(e)&&!isNaN(t)?Number(e)+Number(t):typeof e=="string"&&typeof t=="string"?e+t:""};V.avg=function(){let e=[].concat.apply([],arguments);return e.pop(),V.sum(e)/e.length};V.ceil=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.ceil(e)};V.divide=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)/Number(t)};V.floor=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.floor(e)};V.minus=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)-Number(t)};V.modulo=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)%Number(t)};V.multiply=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)*Number(t)};V.plus=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)+Number(t)};V.random=function(e,t){if(isNaN(e))throw new TypeError("expected minimum to be a number");if(isNaN(t))throw new TypeError("expected maximum to be a number");return In.random(e,t)};V.remainder=function(e,t){return e%t};V.round=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.round(e)};V.subtract=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)-Number(t)};V.sum=function(){for(var e=[].concat.apply([],arguments),t=e.length,r=0;t--;)isNaN(e[t])||(r+=Number(e[t]));return r}});var zt=U((Yi,Lt)=>{"use strict";Lt.exports=function(t){return t!=null&&typeof t=="object"&&Array.isArray(t)===!1}});var Ne=U((Ci,Gt)=>{var Jt=zt();Gt.exports=function(e,t,r){if(Jt(r)||(r={default:r}),!Rt(e))return typeof r.default<"u"?r.default:e;typeof t=="number"&&(t=String(t));let n=Array.isArray(t),i=typeof t=="string",u=r.separator||".",s=r.joinChar||(typeof u=="string"?u:".");if(!i&&!n)return e;if(i&&t in e)return it(t,e,r)?e[t]:r.default;let f=n?t:_n(t,u,r),w=f.length,g=0;do{let l=f[g];for(typeof l=="number"&&(l=String(l));l&&l.slice(-1)==="\\";)l=Pt([l.slice(0,-1),f[++g]||""],s,r);if(l in e){if(!it(l,e,r))return r.default;e=e[l]}else{let x=!1,v=g+1;for(;v{"use strict";Zt.exports=function(t){if(typeof t!="object")throw new TypeError("createFrame expects data to be an object");var r=Object.assign({},t);if(r._parent=t,r.extend=function(s){Object.assign(this,s)},arguments.length>1)for(var n=[].slice.call(arguments,1),i=n.length,u=-1;++u{"use strict";var y=ee(),C=Vt.exports,oe=Ne(),Wn=ut();C.after=function(e,t){return y.isUndefined(e)?"":(e=y.result(e),Array.isArray(e)?e.slice(t):"")};C.arrayify=function(e){return y.isUndefined(e)?[]:e?Array.isArray(e)?e:[e]:[]};C.before=function(e,t){return y.isUndefined(e)?"":(e=y.result(e),Array.isArray(e)?e.slice(0,t-1):"")};C.eachIndex=function(e,t){var r="";if(y.isUndefined(e))return"";if(e=y.result(e),Array.isArray(e))for(var n=0;n0){for(var s=0;s-1,this,r):"")};C.isArray=function(e){return Array.isArray(e)};C.itemAt=function(e,t){if(y.isUndefined(e))return null;if(e=y.result(e),Array.isArray(e)){if(t=isNaN(t)?0:+t,t<0)return e[e.length+t];if(ti[t]>u[t]?1:-1)}return""};C.withAfter=function(e,t,r){if(y.isUndefined(e))return"";if(e=y.result(e),Array.isArray(e)){e=e.slice(t);for(var n="",i=0;i0){for(var i=[],u=0;u0&&u%t===0&&(n+=r.fn(i),i=[]),i.push(e[u]);n+=r.fn(i)}return n};C.withLast=function(e,t,r){if(y.isUndefined(e))return"";if(e=y.result(e),Array.isArray(e)){if(y.isUndefined(t)||(t=parseFloat(y.result(t))),y.isUndefined(t))return r=t,r.fn(e[e.length-1]);e=e.slice(-t);for(var n=e.length,i=-1,u="";++ig?1:w{"use strict";var Qt=ee(),te=Xt.exports;te.bytes=function(e,t,r){if(e==null||isNaN(e)&&(e=e.length,!e))return"0 B";isNaN(t)&&(t=2);var n=["B","kB","MB","GB","TB","PB","EB","ZB","YB"];t=Math.pow(10,t),e=Number(e);for(var i=n.length-1;i-->=0;){var u=Math.pow(10,i*3);if(u<=e+1){e=Math.round(e*t/u)/t,e+=" "+n[i];break}}return e};te.addCommas=function(e){return e.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")};te.phoneNumber=function(e){return e=e.toString(),"("+e.substr(0,3)+") "+e.substr(3,3)+"-"+e.substr(6,4)};te.toAbbr=function(e,t){isNaN(e)&&(e=0),Qt.isUndefined(t)&&(t=2),e=Number(e),t=Math.pow(10,t);for(var r=["k","m","b","t","q"],n=r.length-1;n>=0;){var i=Math.pow(10,(n+1)*3);if(i<=e+1){e=Math.round(e*t/i)/t,e+=r[n];break}n--}return e};te.toExponential=function(e,t){return isNaN(e)&&(e=0),Qt.isUndefined(t)&&(t=0),Number(e).toExponential(t)};te.toFixed=function(e,t){return isNaN(e)&&(e=0),isNaN(t)&&(t=0),Number(e).toFixed(t)};te.toFloat=function(e){return parseFloat(e)};te.toInt=function(e){return parseInt(e,10)};te.toPrecision=function(e,t){return isNaN(e)&&(e=0),isNaN(t)&&(t=1),Number(e).toPrecision(t)}});var tr=U((Wi,er)=>{"use strict";var st=Ue("url"),ge=ee(),Fn=Ue("querystring"),ae=er.exports;ae.encodeURI=function(e){if(ge.isString(e))return encodeURIComponent(e)};ae.escape=function(e){if(ge.isString(e))return Fn.escape(e)};ae.decodeURI=function(e){if(ge.isString(e))return decodeURIComponent(e)};ae.urlResolve=function(e,t){return st.resolve(e,t)};ae.urlParse=function(e){return st.parse(e)};ae.stripQuerystring=function(e){if(ge.isString(e))return e.split("?")[0]};ae.stripProtocol=function(e){if(ge.isString(e)){var t=st.parse(e);return t.protocol="",t.format()}}});var ir=U((rr,nr)=>{"use strict";var z=ee(),ce=Se(),A=nr.exports;A.append=function(e,t){return typeof e=="string"&&typeof t=="string"?e+t:e};A.camelcase=function(e){return typeof e!="string"?"":ce.changecase(e,function(t){return t.toUpperCase()})};A.capitalize=function(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)};A.capitalizeAll=function(e){if(typeof e!="string")return"";if(z.isString(e))return e.replace(/\w\S*/g,function(t){return A.capitalize(t)})};A.center=function(e,t){if(typeof e!="string")return"";for(var r="",n=0;n-1;)i++,n+=r;return i};A.pascalcase=function(e){return typeof e!="string"?"":(e=ce.changecase(e,function(t){return t.toUpperCase()}),e.charAt(0).toUpperCase()+e.slice(1))};A.pathcase=function(e){return typeof e!="string"?"":ce.changecase(e,function(t){return"/"+t})};A.plusify=function(e,t){return typeof e!="string"?"":(z.isString(t)||(t=" "),e.split(t).join("+"))};A.prepend=function(e,t){return typeof e=="string"&&typeof t=="string"?t+e:e};A.raw=function(e){var t=e.fn(),r=z.options(this,e);if(r.escape!==!1)for(var n=0;(n=t.indexOf("{{",n))!==-1;)t[n-1]!=="\\"&&(t=t.slice(0,n)+"\\"+t.slice(n)),n+=3;return t};A.remove=function(e,t){return typeof e!="string"?"":z.isString(t)?e.split(t).join(""):e};A.removeFirst=function(e,t){return typeof e!="string"?"":z.isString(t)?e.replace(t,""):e};A.replace=function(e,t,r){return typeof e!="string"?"":z.isString(t)?(z.isString(r)||(r=""),e.split(t).join(r)):e};A.replaceFirst=function(e,t,r){return typeof e!="string"?"":z.isString(t)?(z.isString(r)||(r=""),e.replace(t,r)):e};A.reverse=Me().reverse;A.sentence=function(e){return typeof e!="string"?"":e.replace(/((?:\S[^\.\?\!]*)[\.\?\!]*)/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()})};A.snakecase=function(e){return typeof e!="string"?"":ce.changecase(e,function(t){return"_"+t})};A.split=function(e,t){return typeof e!="string"?"":(z.isString(t)||(t=","),e.split(t))};A.startsWith=function(e,t,r){var n=[].slice.call(arguments);return r=n.pop(),z.isString(t)&&t.indexOf(e)===0?r.fn(this):typeof r.inverse=="function"?r.inverse(this):""};A.titleize=function(e){if(typeof e!="string")return"";for(var t=e.replace(/[- _]+/g," "),r=t.split(" "),n=r.length,i=[],u=0;n--;){var s=r[u++];i.push(rr.capitalize(s))}return i.join(" ")};A.trim=function(e){return typeof e=="string"?e.trim():""};A.trimLeft=function(e){if(z.isString(e))return e.replace(/^\s+/,"")};A.trimRight=function(e){if(z.isString(e))return e.replace(/\s+$/,"")};A.truncate=function(e,t,r){if(z.isString(e))return typeof r!="string"&&(r=""),e.length>t?e.slice(0,t-r.length)+r:e};A.truncateWords=function(e,t,r){if(z.isString(e)&&!isNaN(t)){typeof r!="string"&&(r="\u2026");var n=Number(t),i=e.split(/[ \t]/);if(n>=i.length)return e;i=i.slice(0,n);var u=i.join(" ").trim();return u+r}};A.upcase=function(){return A.uppercase.apply(this,arguments)};A.uppercase=function(e){return z.isObject(e)&&e.fn?e.fn(this).toUpperCase():typeof e!="string"?"":e.toUpperCase()}});var sr=U((Fi,ur)=>{"use strict";var Hn=xe();ur.exports=function e(t){switch(Hn(t)){case"boolean":case"date":case"function":case"null":case"number":return!0;case"undefined":return!1;case"regexp":return t.source!=="(?:)"&&t.source!=="";case"buffer":return t.toString()!=="";case"error":return t.message!=="";case"string":case"arguments":return t.length!==0;case"file":case"map":case"set":return t.size!==0;case"array":case"object":for(let r of Object.keys(t))if(e(t[r]))return!0;return!1;default:return!0}}});var or=U((Hi,fr)=>{"use strict";var Bn=Ne(),Ln=sr();fr.exports=function(e,t,r){return zn(e)&&(typeof t=="string"||Array.isArray(t))?Ln(Bn(e,t,r)):!1};function zn(e){return e!=null&&(typeof e=="object"||typeof e=="function"||Array.isArray(e))}});var cr=U((Bi,ar)=>{"use strict";function ft(e,t){if(!e)return!0;let r=t||ft.keywords;Array.isArray(r)||(r=[r]);let n=typeof e=="string"?e.toLowerCase():null;for(let i of r)if(i===e||i===n)return!0;return!1}ft.keywords=["0","false","nada","nil","nay","nah","negative","no","none","nope","nul","null","nix","nyet","uh-uh","veto","zero"];ar.exports=ft});var dr=U((Li,lr)=>{"use strict";lr.exports=function(t){let r=Math.abs(t);if(isNaN(r))throw new TypeError("expected a number");if(!Number.isInteger(r))throw new Error("expected an integer");if(!Number.isSafeInteger(r))throw new Error("value exceeds maximum safe integer");return r%2===1}});var gr=U((zi,mr)=>{"use strict";var Pn=or(),k=ee(),Rn=Se(),hr=cr(),pr=dr(),W=mr.exports;W.and=function(){for(var e=arguments.length-1,t=arguments[e],r=!0,n=0;n":i=e>r;break;case"<=":i=e<=r;break;case">=":i=e>=r;break;case"typeof":i=typeof e===r;break;default:throw new Error("helper {{compare}}: invalid operator: `"+t+"`")}return k.value(i,this,n)};W.contains=function(e,t,r,n){typeof r=="object"&&(n=r,r=void 0);var i=Rn.contains(e,t,r);return k.value(i,this,n)};W.default=function(){for(var e=0;et,this,r)};W.gte=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e>=t,this,r)};W.has=function(e,t,r){return k.isOptions(e)&&(r=e,t=null,e=null),k.isOptions(t)&&(r=t,t=null),e===null?k.value(!1,this,r):arguments.length===2?k.value(Pn(this,e),this,r):(Array.isArray(e)||k.isString(e))&&k.isString(t)&&e.indexOf(t)>-1?k.fn(!0,this,r):k.isObject(e)&&k.isString(t)&&t in e?k.fn(!0,this,r):k.inverse(!1,this,r)};W.isFalsey=function(e,t){return k.value(hr(e),this,t)};W.isTruthy=function(e,t){return k.value(!hr(e),this,t)};W.ifEven=function(e,t){return k.value(!pr(e),this,t)};W.ifNth=function(e,t,r){var n=!isNaN(e)&&!isNaN(t)&&t%e===0;return k.value(n,this,r)};W.ifOdd=function(e,t){return k.value(pr(e),this,t)};W.is=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e==t,this,r)};W.isnt=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e!=t,this,r)};W.lt=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e=t,this,r)};W.unlessGteq=function(e,t,r){return k.isOptions(t)&&(r=t,t=r.hash.compare),k.value(et,this,r)}});var vr=U((Pi,yr)=>{var Jn=et(),Gn=Object.prototype.toString;yr.exports=function(t){if(typeof t>"u")return"undefined";if(t===null)return"null";if(t===!0||t===!1||t instanceof Boolean)return"boolean";if(typeof t=="string"||t instanceof String)return"string";if(typeof t=="number"||t instanceof Number)return"number";if(typeof t=="function"||t instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(t))return"array";if(t instanceof RegExp)return"regexp";if(t instanceof Date)return"date";var r=Gn.call(t);return r==="[object RegExp]"?"regexp":r==="[object Date]"?"date":r==="[object Arguments]"?"arguments":r==="[object Error]"?"error":Jn(t)?"buffer":r==="[object Set]"?"set":r==="[object WeakSet]"?"weakset":r==="[object Map]"?"map":r==="[object WeakMap]"?"weakmap":r==="[object Symbol]"?"symbol":r==="[object Int8Array]"?"int8array":r==="[object Uint8Array]"?"uint8array":r==="[object Uint8ClampedArray]"?"uint8clampedarray":r==="[object Int16Array]"?"int16array":r==="[object Uint16Array]"?"uint16array":r==="[object Int32Array]"?"int32array":r==="[object Uint32Array]"?"uint32array":r==="[object Float32Array]"?"float32array":r==="[object Float64Array]"?"float64array":"object"}});var br=U((Ri,$r)=>{"use strict";var Zn=vr();$r.exports=function(t){var r=Zn(t);if(r!=="number"&&r!=="string")return!1;var n=+t;return n-n+1>=0&&t!==""}});var Or=U((Ji,wr)=>{"use strict";var Vn=br();wr.exports=function(t,r){if(!r)return t;if(!t)return{};for(var n=String(r).split(/[[.\]]/).filter(Boolean),i=n[n.length-1],u={};r=n.shift();)if(t=t[r],!t)return{};return Vn(i)?[t]:(u[i]=t,u)}});var Mr=U((Gi,Nr)=>{"use strict";var Qn=Object.hasOwnProperty,ye=ee(),Xn=Me(),P=Nr.exports,Kn=Ne(),xr=Or(),Sr=ut();P.extend=function(){var e=[].slice.call(arguments),t={};ye.isOptions(e[e.length-1])&&(t=e.pop().hash,e.push(t));for(var r={},n=0;n{"use strict";var ei=ee(),jr=Ar.exports,ti=xe();jr.toRegex=function(e,t,r){var n=ei.options({},t,r);return new RegExp(e,n.flags)};jr.test=function(e,t){if(typeof e!="string")return!1;if(ti(t)!=="regexp")throw new TypeError("expected a regular expression");return t.test(e)}});import ri from"crypto";function ve(){return je>Ae.length-16&&(ri.randomFillSync(Ae),je=0),Ae.slice(je,je+=16)}var Ae,je,ot=Z(()=>{Ae=new Uint8Array(256),je=Ae.length});var Dr,Ur=Z(()=>{Dr=/^(?:[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 ni(e){return typeof e=="string"&&Dr.test(e)}var ne,$e=Z(()=>{Ur();ne=ni});function le(e,t=0){return R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]}function ii(e,t=0){let r=le(e,t);if(!ne(r))throw TypeError("Stringified UUID is invalid");return r}var R,Tr,be=Z(()=>{$e();R=[];for(let e=0;e<256;++e)R.push((e+256).toString(16).slice(1));Tr=ii});function ui(e,t,r){let n=t&&r||0,i=t||new Array(16);e=e||{};let u=e.node||qr,s=e.clockseq!==void 0?e.clockseq:at;if(u==null||s==null){let v=e.random||(e.rng||ve)();u==null&&(u=qr=[v[0]|1,v[1],v[2],v[3],v[4],v[5]]),s==null&&(s=at=(v[6]<<8|v[7])&16383)}let f=e.msecs!==void 0?e.msecs:Date.now(),w=e.nsecs!==void 0?e.nsecs:lt+1,g=f-ct+(w-lt)/1e4;if(g<0&&e.clockseq===void 0&&(s=s+1&16383),(g<0||f>ct)&&e.nsecs===void 0&&(w=0),w>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ct=f,lt=w,at=s,f+=122192928e5;let l=((f&268435455)*1e4+w)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=l&255;let x=f/4294967296*1e4&268435455;i[n++]=x>>>8&255,i[n++]=x&255,i[n++]=x>>>24&15|16,i[n++]=x>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(let v=0;v<6;++v)i[n+v]=u[v];return t||le(i)}var qr,at,ct,lt,Yr,Cr=Z(()=>{ot();be();ct=0,lt=0;Yr=ui});function si(e){if(!ne(e))throw TypeError("Invalid UUID");let t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var ke,dt=Z(()=>{$e();ke=si});function fi(e){e=unescape(encodeURIComponent(e));let t=[];for(let r=0;r{be();dt();oi="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ai="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});import ci from"crypto";function li(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),ci.createHash("md5").update(e).digest()}var Er,Ir=Z(()=>{Er=li});var di,_r,Wr=Z(()=>{ht();Ir();di=we("v3",48,Er),_r=di});import hi from"crypto";var pt,Fr=Z(()=>{pt={randomUUID:hi.randomUUID}});function pi(e,t,r){if(pt.randomUUID&&!t&&!e)return pt.randomUUID();e=e||{};let n=e.random||(e.rng||ve)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return le(n)}var Hr,Br=Z(()=>{Fr();ot();be();Hr=pi});import mi from"crypto";function gi(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),mi.createHash("sha1").update(e).digest()}var Lr,zr=Z(()=>{Lr=gi});var yi,Pr,Rr=Z(()=>{ht();zr();yi=we("v5",80,Lr),Pr=yi});var Jr,Gr=Z(()=>{Jr="00000000-0000-0000-0000-000000000000"});function vi(e){if(!ne(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var Zr,Vr=Z(()=>{$e();Zr=vi});var Qr={};on(Qr,{NIL:()=>Jr,parse:()=>ke,stringify:()=>Tr,v1:()=>Yr,v3:()=>_r,v4:()=>Hr,v5:()=>Pr,validate:()=>ne,version:()=>Zr});var Xr=Z(()=>{Cr();Wr();Br();Rr();Gr();Vr();$e();be();dt()});var en=U((Wu,Kr)=>{var $i=(Xr(),cn(Qr)),bi=Kr.exports;bi.uuid=function(){return $i.v4()}});var nn=U((Fu,mt)=>{var{date:wi,duration:Oi}=Mt(),xi={math:Bt(),array:Me(),number:Kt(),url:tr(),string:ir(),comparison:gr(),object:Mr(),regex:kr(),uuid:en()},rn=["sortBy"];mt.exports.helpersToRemoveForJs=rn;var tn={date:wi,duration:Oi},ie;mt.exports.getJsHelperList=()=>{if(ie)return ie;ie={};for(let e of Object.values(xi))for(let[t,r]of Object.entries(e))ie[t]=(...n)=>r(...n,{});for(let e of Object.keys(tn))ie[e]=tn[e];for(let e of rn)delete ie[e];return Object.freeze(ie),ie}});var{getJsHelperList:Si}=nn(),Ni=Si(),Hu={...Ni,stripProtocol:helpersStripProtocol};export{Hu as default};
+"use strict";var helpers=(()=>{var hn=Object.create;var Se=Object.defineProperty;var pn=Object.getOwnPropertyDescriptor;var mn=Object.getOwnPropertyNames;var gn=Object.getPrototypeOf,yn=Object.prototype.hasOwnProperty;var fe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Z=(e,t)=>()=>(e&&(t=e(e=0)),t);var U=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yt=(e,t)=>{for(var r in t)Se(e,r,{get:t[r],enumerable:!0})},vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of mn(t))!yn.call(e,i)&&i!==r&&Se(e,i,{get:()=>t[i],enumerable:!(n=pn(t,i))||n.enumerable});return e};var Ne=(e,t,r)=>(r=e!=null?hn(gn(e)):{},vt(t||!e||!e.__esModule?Se(r,"default",{value:e,enumerable:!0}):r,e)),$t=e=>vt(Se({},"__esModule",{value:!0}),e);var bt=U((qe,Ye)=>{(function(e,t){typeof qe=="object"&&typeof Ye<"u"?Ye.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs=t()})(qe,function(){"use strict";var e=1e3,t=6e4,r=36e5,n="millisecond",i="second",u="minute",s="hour",f="day",w="week",g="month",l="quarter",x="year",v="date",a="Invalid Date",T=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,E=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,I={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function($){var h=["th","st","nd","rd"],c=$%100;return"["+$+(h[(c-20)%10]||h[c]||h[0])+"]"}},Y=function($,h,c){var b=String($);return!b||b.length>=h?$:""+Array(h+1-b.length).join(c)+$},F={s:Y,z:function($){var h=-$.utcOffset(),c=Math.abs(h),b=Math.floor(c/60),d=c%60;return(h<=0?"+":"-")+Y(b,2,"0")+":"+Y(d,2,"0")},m:function $(h,c){if(h.date()1)return $(j[0])}else{var _=h.name;S[_]=h,d=_}return!b&&d&&(q=d),d||!b&&q},N=function($,h){if(o($))return $.clone();var c=typeof h=="object"?h:{};return c.date=$,c.args=arguments,new B(c)},O=F;O.l=D,O.i=o,O.w=function($,h){return N($,{locale:h.$L,utc:h.$u,x:h.$x,$offset:h.$offset})};var B=function(){function $(c){this.$L=D(c.locale,null,!0),this.parse(c),this.$x=this.$x||c.x||{},this[p]=!0}var h=$.prototype;return h.parse=function(c){this.$d=function(b){var d=b.date,M=b.utc;if(d===null)return new Date(NaN);if(O.u(d))return new Date;if(d instanceof Date)return new Date(d);if(typeof d=="string"&&!/Z$/i.test(d)){var j=d.match(T);if(j){var _=j[2]-1||0,H=(j[7]||"0").substring(0,3);return M?new Date(Date.UTC(j[1],_,j[3]||1,j[4]||0,j[5]||0,j[6]||0,H)):new Date(j[1],_,j[3]||1,j[4]||0,j[5]||0,j[6]||0,H)}}return new Date(d)}(c),this.init()},h.init=function(){var c=this.$d;this.$y=c.getFullYear(),this.$M=c.getMonth(),this.$D=c.getDate(),this.$W=c.getDay(),this.$H=c.getHours(),this.$m=c.getMinutes(),this.$s=c.getSeconds(),this.$ms=c.getMilliseconds()},h.$utils=function(){return O},h.isValid=function(){return this.$d.toString()!==a},h.isSame=function(c,b){var d=N(c);return this.startOf(b)<=d&&d<=this.endOf(b)},h.isAfter=function(c,b){return N(c){(function(e,t){typeof Ce=="object"&&typeof Ee<"u"?Ee.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_duration=t()})(Ce,function(){"use strict";var e,t,r=1e3,n=6e4,i=36e5,u=864e5,s=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f=31536e6,w=2628e6,g=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,l={years:f,months:w,days:u,hours:i,minutes:n,seconds:r,milliseconds:1,weeks:6048e5},x=function(S){return S instanceof F},v=function(S,p,o){return new F(S,o,p.$l)},a=function(S){return t.p(S)+"s"},T=function(S){return S<0},E=function(S){return T(S)?Math.ceil(S):Math.floor(S)},I=function(S){return Math.abs(S)},Y=function(S,p){return S?T(S)?{negative:!0,format:""+I(S)+p}:{negative:!1,format:""+S+p}:{negative:!1,format:""}},F=function(){function S(o,D,N){var O=this;if(this.$d={},this.$l=N,o===void 0&&(this.$ms=0,this.parseFromMilliseconds()),D)return v(o*l[a(D)],this);if(typeof o=="number")return this.$ms=o,this.parseFromMilliseconds(),this;if(typeof o=="object")return Object.keys(o).forEach(function($){O.$d[a($)]=o[$]}),this.calMilliseconds(),this;if(typeof o=="string"){var B=o.match(g);if(B){var J=B.slice(2).map(function($){return $!=null?Number($):0});return this.$d.years=J[0],this.$d.months=J[1],this.$d.weeks=J[2],this.$d.days=J[3],this.$d.hours=J[4],this.$d.minutes=J[5],this.$d.seconds=J[6],this.calMilliseconds(),this}}return this}var p=S.prototype;return p.calMilliseconds=function(){var o=this;this.$ms=Object.keys(this.$d).reduce(function(D,N){return D+(o.$d[N]||0)*l[N]},0)},p.parseFromMilliseconds=function(){var o=this.$ms;this.$d.years=E(o/f),o%=f,this.$d.months=E(o/w),o%=w,this.$d.days=E(o/u),o%=u,this.$d.hours=E(o/i),o%=i,this.$d.minutes=E(o/n),o%=n,this.$d.seconds=E(o/r),o%=r,this.$d.milliseconds=o},p.toISOString=function(){var o=Y(this.$d.years,"Y"),D=Y(this.$d.months,"M"),N=+this.$d.days||0;this.$d.weeks&&(N+=7*this.$d.weeks);var O=Y(N,"D"),B=Y(this.$d.hours,"H"),J=Y(this.$d.minutes,"M"),$=this.$d.seconds||0;this.$d.milliseconds&&($+=this.$d.milliseconds/1e3,$=Math.round(1e3*$)/1e3);var h=Y($,"S"),c=o.negative||D.negative||O.negative||B.negative||J.negative||h.negative,b=B.format||J.format||h.format?"T":"",d=(c?"-":"")+"P"+o.format+D.format+O.format+b+B.format+J.format+h.format;return d==="P"||d==="-P"?"P0D":d},p.toJSON=function(){return this.toISOString()},p.format=function(o){var D=o||"YYYY-MM-DDTHH:mm:ss",N={Y:this.$d.years,YY:t.s(this.$d.years,2,"0"),YYYY:t.s(this.$d.years,4,"0"),M:this.$d.months,MM:t.s(this.$d.months,2,"0"),D:this.$d.days,DD:t.s(this.$d.days,2,"0"),H:this.$d.hours,HH:t.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:t.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:t.s(this.$d.seconds,2,"0"),SSS:t.s(this.$d.milliseconds,3,"0")};return D.replace(s,function(O,B){return B||String(N[O])})},p.as=function(o){return this.$ms/l[a(o)]},p.get=function(o){var D=this.$ms,N=a(o);return N==="milliseconds"?D%=1e3:D=N==="weeks"?E(D/l[N]):this.$d[N],D||0},p.add=function(o,D,N){var O;return O=D?o*l[a(D)]:x(o)?o.$ms:v(o,this).$ms,v(this.$ms+O*(N?-1:1),this)},p.subtract=function(o,D){return this.add(o,D,!0)},p.locale=function(o){var D=this.clone();return D.$l=o,D},p.clone=function(){return v(this.$ms,this)},p.humanize=function(o){return e().add(this.$ms,"ms").locale(this.$l).fromNow(!o)},p.valueOf=function(){return this.asMilliseconds()},p.milliseconds=function(){return this.get("milliseconds")},p.asMilliseconds=function(){return this.as("milliseconds")},p.seconds=function(){return this.get("seconds")},p.asSeconds=function(){return this.as("seconds")},p.minutes=function(){return this.get("minutes")},p.asMinutes=function(){return this.as("minutes")},p.hours=function(){return this.get("hours")},p.asHours=function(){return this.as("hours")},p.days=function(){return this.get("days")},p.asDays=function(){return this.as("days")},p.weeks=function(){return this.get("weeks")},p.asWeeks=function(){return this.as("weeks")},p.months=function(){return this.get("months")},p.asMonths=function(){return this.as("months")},p.years=function(){return this.get("years")},p.asYears=function(){return this.as("years")},S}(),q=function(S,p,o){return S.add(p.years()*o,"y").add(p.months()*o,"M").add(p.days()*o,"d").add(p.hours()*o,"h").add(p.minutes()*o,"m").add(p.seconds()*o,"s").add(p.milliseconds()*o,"ms")};return function(S,p,o){e=o,t=o().$utils(),o.duration=function(O,B){var J=o.locale();return v(O,{$l:J},B)},o.isDuration=x;var D=p.prototype.add,N=p.prototype.subtract;p.prototype.add=function(O,B){return x(O)?q(this,O,1):D.bind(this)(O,B)},p.prototype.subtract=function(O,B){return x(O)?q(this,O,-1):N.bind(this)(O,B)}}})});var Ot=U((Ie,_e)=>{(function(e,t){typeof Ie=="object"&&typeof _e<"u"?_e.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_advancedFormat=t()})(Ie,function(){"use strict";return function(e,t){var r=t.prototype,n=r.format;r.format=function(i){var u=this,s=this.$locale();if(!this.isValid())return n.bind(this)(i);var f=this.$utils(),w=(i||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(g){switch(g){case"Q":return Math.ceil((u.$M+1)/3);case"Do":return s.ordinal(u.$D);case"gggg":return u.weekYear();case"GGGG":return u.isoWeekYear();case"wo":return s.ordinal(u.week(),"W");case"w":case"ww":return f.s(u.week(),g==="w"?1:2,"0");case"W":case"WW":return f.s(u.isoWeek(),g==="W"?1:2,"0");case"k":case"kk":return f.s(String(u.$H===0?24:u.$H),g==="k"?1:2,"0");case"X":return Math.floor(u.$d.getTime()/1e3);case"x":return u.$d.getTime();case"z":return"["+u.offsetName()+"]";case"zzz":return"["+u.offsetName("long")+"]";default:return g}});return n.bind(this)(w)}}})});var xt=U((We,Fe)=>{(function(e,t){typeof We=="object"&&typeof Fe<"u"?Fe.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_isoWeek=t()})(We,function(){"use strict";var e="day";return function(t,r,n){var i=function(f){return f.add(4-f.isoWeekday(),e)},u=r.prototype;u.isoWeekYear=function(){return i(this).year()},u.isoWeek=function(f){if(!this.$utils().u(f))return this.add(7*(f-this.isoWeek()),e);var w,g,l,x,v=i(this),a=(w=this.isoWeekYear(),g=this.$u,l=(g?n.utc:n)().year(w).startOf("year"),x=4-l.isoWeekday(),l.isoWeekday()>4&&(x+=7),l.add(x,e));return v.diff(a,"week")+1},u.isoWeekday=function(f){return this.$utils().u(f)?this.day()||7:this.day(this.day()%7?f:f-7)};var s=u.startOf;u.startOf=function(f,w){var g=this.$utils(),l=!!g.u(w)||w;return g.p(f)==="isoweek"?l?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):s.bind(this)(f,w)}}})});var St=U((He,Be)=>{(function(e,t){typeof He=="object"&&typeof Be<"u"?Be.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_weekYear=t()})(He,function(){"use strict";return function(e,t){t.prototype.weekYear=function(){var r=this.month(),n=this.week(),i=this.year();return n===1&&r===11?i+1:r===0&&n>=52?i-1:i}}})});var Nt=U((Le,ze)=>{(function(e,t){typeof Le=="object"&&typeof ze<"u"?ze.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_weekOfYear=t()})(Le,function(){"use strict";var e="week",t="year";return function(r,n,i){var u=n.prototype;u.week=function(s){if(s===void 0&&(s=null),s!==null)return this.add(7*(s-this.week()),"day");var f=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var w=i(this).startOf(t).add(1,t).date(f),g=i(this).endOf(e);if(w.isBefore(g))return 1}var l=i(this).startOf(t).date(f).startOf(e).subtract(1,"millisecond"),x=this.diff(l,e,!0);return x<0?i(this).startOf("week").week():Math.ceil(x)},u.weeks=function(s){return s===void 0&&(s=null),this.week(s)}}})});var Mt=U((Pe,Re)=>{(function(e,t){typeof Pe=="object"&&typeof Re<"u"?Re.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_relativeTime=t()})(Pe,function(){"use strict";return function(e,t,r){e=e||{};var n=t.prototype,i={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function u(f,w,g,l){return n.fromToBase(f,w,g,l)}r.en.relativeTime=i,n.fromToBase=function(f,w,g,l,x){for(var v,a,T,E=g.$locale().relativeTime||i,I=e.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],Y=I.length,F=0;F0,S<=q.r||!q.r){S<=1&&F>0&&(q=I[F-1]);var p=E[q.l];x&&(S=x(""+S)),a=typeof p=="string"?p.replace("%d",S):p(S,w,q.l,T);break}}if(w)return a;var o=T?E.future:E.past;return typeof o=="function"?o(a):o.replace("%s",a)},n.to=function(f,w){return u(f,w,this,!0)},n.from=function(f,w){return u(f,w,this)};var s=function(f){return f.$u?r.utc():r()};n.toNow=function(f){return this.to(s(this),f)},n.fromNow=function(f){return this.from(s(this),f)}}})});var jt=U((Je,Ge)=>{(function(e,t){typeof Je=="object"&&typeof Ge<"u"?Ge.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_utc=t()})(Je,function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(n,i,u){var s=i.prototype;u.utc=function(a){var T={date:a,utc:!0,args:arguments};return new i(T)},s.utc=function(a){var T=u(this.toDate(),{locale:this.$L,utc:!0});return a?T.add(this.utcOffset(),e):T},s.local=function(){return u(this.toDate(),{locale:this.$L,utc:!1})};var f=s.parse;s.parse=function(a){a.utc&&(this.$u=!0),this.$utils().u(a.$offset)||(this.$offset=a.$offset),f.call(this,a)};var w=s.init;s.init=function(){if(this.$u){var a=this.$d;this.$y=a.getUTCFullYear(),this.$M=a.getUTCMonth(),this.$D=a.getUTCDate(),this.$W=a.getUTCDay(),this.$H=a.getUTCHours(),this.$m=a.getUTCMinutes(),this.$s=a.getUTCSeconds(),this.$ms=a.getUTCMilliseconds()}else w.call(this)};var g=s.utcOffset;s.utcOffset=function(a,T){var E=this.$utils().u;if(E(a))return this.$u?0:E(this.$offset)?g.call(this):this.$offset;if(typeof a=="string"&&(a=function(q){q===void 0&&(q="");var S=q.match(t);if(!S)return null;var p=(""+S[0]).match(r)||["-",0,0],o=p[0],D=60*+p[1]+ +p[2];return D===0?0:o==="+"?D:-D}(a),a===null))return this;var I=Math.abs(a)<=16?60*a:a,Y=this;if(T)return Y.$offset=I,Y.$u=a===0,Y;if(a!==0){var F=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(Y=this.local().add(I+F,e)).$offset=I,Y.$x.$localOffset=F}else Y=this.utc();return Y};var l=s.format;s.format=function(a){var T=a||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,T)},s.valueOf=function(){var a=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*a},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var x=s.toDate;s.toDate=function(a){return a==="s"&&this.$offset?u(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():x.call(this)};var v=s.diff;s.diff=function(a,T,E){if(a&&this.$u===a.$u)return v.call(this,a,T,E);var I=this.local(),Y=u(a).local();return v.call(I,Y,T,E)}}})});var At=U((Ze,Ve)=>{(function(e,t){typeof Ze=="object"&&typeof Ve<"u"?Ve.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self).dayjs_plugin_timezone=t()})(Ze,function(){"use strict";var e={year:0,month:1,day:2,hour:3,minute:4,second:5},t={};return function(r,n,i){var u,s=function(l,x,v){v===void 0&&(v={});var a=new Date(l),T=function(E,I){I===void 0&&(I={});var Y=I.timeZoneName||"short",F=E+"|"+Y,q=t[F];return q||(q=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:E,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:Y}),t[F]=q),q}(x,v);return T.formatToParts(a)},f=function(l,x){for(var v=s(l,x),a=[],T=0;T=0&&(a[F]=parseInt(Y,10))}var q=a[3],S=q===24?0:q,p=a[0]+"-"+a[1]+"-"+a[2]+" "+S+":"+a[4]+":"+a[5]+":000",o=+l;return(i.utc(p).valueOf()-(o-=o%1e3))/6e4},w=n.prototype;w.tz=function(l,x){l===void 0&&(l=u);var v=this.utcOffset(),a=this.toDate(),T=a.toLocaleString("en-US",{timeZone:l}),E=Math.round((a-new Date(T))/1e3/60),I=i(T,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(a.getTimezoneOffset()/15)-E,!0);if(x){var Y=I.utcOffset();I=I.add(v-Y,"minute")}return I.$x.$timezone=l,I},w.offsetName=function(l){var x=this.$x.$timezone||i.tz.guess(),v=s(this.valueOf(),x,{timeZoneName:l}).find(function(a){return a.type.toLowerCase()==="timezonename"});return v&&v.value};var g=w.startOf;w.startOf=function(l,x){if(!this.$x||!this.$x.$timezone)return g.call(this,l,x);var v=i(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return g.call(v,l,x).tz(this.$x.$timezone,!0)},i.tz=function(l,x,v){var a=v&&x,T=v||x||u,E=f(+i(),T);if(typeof l!="string")return i(l).tz(T);var I=function(S,p,o){var D=S-60*p*1e3,N=f(D,o);if(p===N)return[D,p];var O=f(D-=60*(N-p)*1e3,o);return N===O?[D,N]:[S-60*Math.min(N,O)*1e3,Math.max(N,O)]}(i.utc(l,a).valueOf(),E,T),Y=I[0],F=I[1],q=i(Y).utcOffset(F);return q.$x.$timezone=T,q},i.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},i.tz.setDefault=function(l){u=l}}})});var Dt=U((Ui,et)=>{var X=bt();X.extend(wt());X.extend(Ot());X.extend(xt());X.extend(St());X.extend(Nt());X.extend(Mt());X.extend(jt());X.extend(At());function oe(e){return typeof e=="object"&&typeof e.hash=="object"}function Qe(e){return typeof e=="object"&&typeof e.options=="object"&&typeof e.app=="object"}function Xe(e,t,r){if(oe(e))return Xe({},t,e);if(oe(t))return Xe(e,r,t);let n=Qe(e)?e.context:{};r=r||{},oe(r)||(t=Object.assign({},t,r)),oe(r)&&r.hash.root===!0&&(t=Object.assign({},r.data.root,t));let i=Object.assign({},n,t,r.hash);return Qe(e)||(i=Object.assign({},e,i)),Qe(e)&&e.view&&e.view.data&&(i=Object.assign({},i,e.view.data)),i}function Ke(e,t,r){return oe(t)&&(r=t,t=null),oe(e)&&(r=e,t=null,e=null),{str:e,pattern:t,options:r}}function kt(e,t,r){let n=Ke(e,t,r),i={lang:"en",date:new Date(n.str)},u=Xe(this,i,{});X.locale(u.lang||u.language)}et.exports.date=(e,t,r)=>{let n=Ke(e,t,r);if(n.str==null&&n.pattern==null)return X.locale("en"),X().format("MMMM DD, YYYY");kt(n.str,n.pattern,n.options);let i=X(new Date(n.str));return typeof n.options=="string"?i=n.options.toLowerCase()==="utc"?i.utc():i.tz(n.options):i=i.tz(X.tz.guess()),n.pattern===""?i.toISOString():i.format(n.pattern)};et.exports.duration=(e,t,r)=>{let n=Ke(e,t);kt(n.str,n.pattern);let i=X.duration(n.str,n.pattern);return r&&!oe(r)?i.format(r):i.humanize()}});var tt=U((Ti,Tt)=>{Tt.exports=function(e){return e!=null&&(Ut(e)||vn(e)||!!e._isBuffer)};function Ut(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function vn(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Ut(e.slice(0,0))}});var Yt=U((qi,qt)=>{var $n=tt(),bn=Object.prototype.toString;qt.exports=function(t){if(typeof t>"u")return"undefined";if(t===null)return"null";if(t===!0||t===!1||t instanceof Boolean)return"boolean";if(typeof t=="string"||t instanceof String)return"string";if(typeof t=="number"||t instanceof Number)return"number";if(typeof t=="function"||t instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(t))return"array";if(t instanceof RegExp)return"regexp";if(t instanceof Date)return"date";var r=bn.call(t);return r==="[object RegExp]"?"regexp":r==="[object Date]"?"date":r==="[object Arguments]"?"arguments":r==="[object Error]"?"error":$n(t)?"buffer":r==="[object Set]"?"set":r==="[object WeakSet]"?"weakset":r==="[object Map]"?"map":r==="[object WeakMap]"?"weakmap":r==="[object Symbol]"?"symbol":r==="[object Int8Array]"?"int8array":r==="[object Uint8Array]"?"uint8array":r==="[object Uint8ClampedArray]"?"uint8clampedarray":r==="[object Int16Array]"?"int16array":r==="[object Uint16Array]"?"uint16array":r==="[object Int32Array]"?"int32array":r==="[object Uint32Array]"?"uint32array":r==="[object Float32Array]"?"float32array":r==="[object Float64Array]"?"float64array":"object"}});var _t=U((Yi,It)=>{"use strict";var Ct=Yt(),Et={arguments:"an arguments object",array:"an array",boolean:"a boolean",buffer:"a buffer",date:"a date",error:"an error",float32array:"a float32array",float64array:"a float64array",function:"a function",int16array:"an int16array",int32array:"an int32array",int8array:"an int8array",map:"a Map",null:"null",number:"a number",object:"an object",regexp:"a regular expression",set:"a Set",string:"a string",symbol:"a symbol",uint16array:"an uint16array",uint32array:"an uint32array",uint8array:"an uint8array",uint8clampedarray:"an uint8clampedarray",undefined:"undefined",weakmap:"a WeakMap",weakset:"a WeakSet"};function rt(e){return Et[Ct(e)]}rt.types=Et;rt.typeOf=Ct;It.exports=rt});var Me=U((Ci,Ft)=>{var wn=Object.prototype.toString;Ft.exports=function(t){if(t===void 0)return"undefined";if(t===null)return"null";var r=typeof t;if(r==="boolean")return"boolean";if(r==="string")return"string";if(r==="number")return"number";if(r==="symbol")return"symbol";if(r==="function")return Mn(t)?"generatorfunction":"function";if(On(t))return"array";if(kn(t))return"buffer";if(An(t))return"arguments";if(Sn(t))return"date";if(xn(t))return"error";if(Nn(t))return"regexp";switch(Wt(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(jn(t))return"generator";switch(r=wn.call(t),r){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return r.slice(8,-1).toLowerCase().replace(/\s/g,"")};function Wt(e){return typeof e.constructor=="function"?e.constructor.name:null}function On(e){return Array.isArray?Array.isArray(e):e instanceof Array}function xn(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function Sn(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function Nn(e){return e instanceof RegExp?!0:typeof e.flags=="string"&&typeof e.ignoreCase=="boolean"&&typeof e.multiline=="boolean"&&typeof e.global=="boolean"}function Mn(e,t){return Wt(e)==="GeneratorFunction"}function jn(e){return typeof e.throw=="function"&&typeof e.return=="function"&&typeof e.next=="function"}function An(e){try{if(typeof e.length=="number"&&typeof e.callee=="function")return!0}catch(t){if(t.message.indexOf("callee")!==-1)return!0}return!1}function kn(e){return e.constructor&&typeof e.constructor.isBuffer=="function"?e.constructor.isBuffer(e):!1}});var ee=U((Lt,zt)=>{"use strict";var Dn=fe("util"),Ht=_t(),Un=Me(),m=Lt=zt.exports;m.extend=Bt;m.indexOf=In;m.escapeExpression=_n;m.isEmpty=Bn;m.createFrame=Wn;m.blockParams=Fn;m.appendContextPath=Hn;var Tn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},qn=/[&<>"'`=]/g,Yn=/[&<>"'`=]/;function Cn(e){return Tn[e]}function Bt(e){for(var t=1;t{"use strict";var Ln=ee();pe.contains=function(e,t,r){return e==null||t==null||isNaN(e.length)?!1:e.indexOf(t,r)!==-1};pe.chop=function(e){if(typeof e!="string")return"";var t=/^[-_.\W\s]+|[-_.\W\s]+$/g;return e.trim().replace(t,"")};pe.changecase=function(e,t){if(typeof e!="string")return"";if(e.length===1)return e.toLowerCase();e=pe.chop(e).toLowerCase(),typeof t!="function"&&(t=Ln.identity);var r=/[-_.\W\s]+(\w|$)/g;return e.replace(r,function(n,i){return t(i)})};pe.random=function(e,t){return e+Math.floor(Math.random()*(t-e+1))}});var Rt=U((Ii,Pt)=>{"use strict";var zn=je(),V=Pt.exports;V.abs=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.abs(e)};V.add=function(e,t){return!isNaN(e)&&!isNaN(t)?Number(e)+Number(t):typeof e=="string"&&typeof t=="string"?e+t:""};V.avg=function(){let e=[].concat.apply([],arguments);return e.pop(),V.sum(e)/e.length};V.ceil=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.ceil(e)};V.divide=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)/Number(t)};V.floor=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.floor(e)};V.minus=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)-Number(t)};V.modulo=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)%Number(t)};V.multiply=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)*Number(t)};V.plus=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)+Number(t)};V.random=function(e,t){if(isNaN(e))throw new TypeError("expected minimum to be a number");if(isNaN(t))throw new TypeError("expected maximum to be a number");return zn.random(e,t)};V.remainder=function(e,t){return e%t};V.round=function(e){if(isNaN(e))throw new TypeError("expected a number");return Math.round(e)};V.subtract=function(e,t){if(isNaN(e))throw new TypeError("expected the first argument to be a number");if(isNaN(t))throw new TypeError("expected the second argument to be a number");return Number(e)-Number(t)};V.sum=function(){for(var e=[].concat.apply([],arguments),t=e.length,r=0;t--;)isNaN(e[t])||(r+=Number(e[t]));return r}});var Gt=U((_i,Jt)=>{"use strict";Jt.exports=function(t){return t!=null&&typeof t=="object"&&Array.isArray(t)===!1}});var Ae=U((Wi,Xt)=>{var Qt=Gt();Xt.exports=function(e,t,r){if(Qt(r)||(r={default:r}),!Vt(e))return typeof r.default<"u"?r.default:e;typeof t=="number"&&(t=String(t));let n=Array.isArray(t),i=typeof t=="string",u=r.separator||".",s=r.joinChar||(typeof u=="string"?u:".");if(!i&&!n)return e;if(i&&t in e)return ut(t,e,r)?e[t]:r.default;let f=n?t:Pn(t,u,r),w=f.length,g=0;do{let l=f[g];for(typeof l=="number"&&(l=String(l));l&&l.slice(-1)==="\\";)l=Zt([l.slice(0,-1),f[++g]||""],s,r);if(l in e){if(!ut(l,e,r))return r.default;e=e[l]}else{let x=!1,v=g+1;for(;v{"use strict";Kt.exports=function(t){if(typeof t!="object")throw new TypeError("createFrame expects data to be an object");var r=Object.assign({},t);if(r._parent=t,r.extend=function(s){Object.assign(this,s)},arguments.length>1)for(var n=[].slice.call(arguments,1),i=n.length,u=-1;++u{"use strict";var y=ee(),C=er.exports,ae=Ae(),Rn=st();C.after=function(e,t){return y.isUndefined(e)?"":(e=y.result(e),Array.isArray(e)?e.slice(t):"")};C.arrayify=function(e){return y.isUndefined(e)?[]:e?Array.isArray(e)?e:[e]:[]};C.before=function(e,t){return y.isUndefined(e)?"":(e=y.result(e),Array.isArray(e)?e.slice(0,t-1):"")};C.eachIndex=function(e,t){var r="";if(y.isUndefined(e))return"";if(e=y.result(e),Array.isArray(e))for(var n=0;n0){for(var s=0;s-1,this,r):"")};C.isArray=function(e){return Array.isArray(e)};C.itemAt=function(e,t){if(y.isUndefined(e))return null;if(e=y.result(e),Array.isArray(e)){if(t=isNaN(t)?0:+t,t<0)return e[e.length+t];if(ti[t]>u[t]?1:-1)}return""};C.withAfter=function(e,t,r){if(y.isUndefined(e))return"";if(e=y.result(e),Array.isArray(e)){e=e.slice(t);for(var n="",i=0;i0){for(var i=[],u=0;u0&&u%t===0&&(n+=r.fn(i),i=[]),i.push(e[u]);n+=r.fn(i)}return n};C.withLast=function(e,t,r){if(y.isUndefined(e))return"";if(e=y.result(e),Array.isArray(e)){if(y.isUndefined(t)||(t=parseFloat(y.result(t))),y.isUndefined(t))return r=t,r.fn(e[e.length-1]);e=e.slice(-t);for(var n=e.length,i=-1,u="";++ig?1:w{"use strict";var tr=ee(),te=rr.exports;te.bytes=function(e,t,r){if(e==null||isNaN(e)&&(e=e.length,!e))return"0 B";isNaN(t)&&(t=2);var n=["B","kB","MB","GB","TB","PB","EB","ZB","YB"];t=Math.pow(10,t),e=Number(e);for(var i=n.length-1;i-->=0;){var u=Math.pow(10,i*3);if(u<=e+1){e=Math.round(e*t/u)/t,e+=" "+n[i];break}}return e};te.addCommas=function(e){return e.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,")};te.phoneNumber=function(e){return e=e.toString(),"("+e.substr(0,3)+") "+e.substr(3,3)+"-"+e.substr(6,4)};te.toAbbr=function(e,t){isNaN(e)&&(e=0),tr.isUndefined(t)&&(t=2),e=Number(e),t=Math.pow(10,t);for(var r=["k","m","b","t","q"],n=r.length-1;n>=0;){var i=Math.pow(10,(n+1)*3);if(i<=e+1){e=Math.round(e*t/i)/t,e+=r[n];break}n--}return e};te.toExponential=function(e,t){return isNaN(e)&&(e=0),tr.isUndefined(t)&&(t=0),Number(e).toExponential(t)};te.toFixed=function(e,t){return isNaN(e)&&(e=0),isNaN(t)&&(t=0),Number(e).toFixed(t)};te.toFloat=function(e){return parseFloat(e)};te.toInt=function(e){return parseInt(e,10)};te.toPrecision=function(e,t){return isNaN(e)&&(e=0),isNaN(t)&&(t=1),Number(e).toPrecision(t)}});var ur=U((Li,ir)=>{"use strict";var ft=fe("url"),ye=ee(),Jn=fe("querystring"),ce=ir.exports;ce.encodeURI=function(e){if(ye.isString(e))return encodeURIComponent(e)};ce.escape=function(e){if(ye.isString(e))return Jn.escape(e)};ce.decodeURI=function(e){if(ye.isString(e))return decodeURIComponent(e)};ce.urlResolve=function(e,t){return ft.resolve(e,t)};ce.urlParse=function(e){return ft.parse(e)};ce.stripQuerystring=function(e){if(ye.isString(e))return e.split("?")[0]};ce.stripProtocol=function(e){if(ye.isString(e)){var t=ft.parse(e);return t.protocol="",t.format()}}});var or=U((sr,fr)=>{"use strict";var z=ee(),le=je(),A=fr.exports;A.append=function(e,t){return typeof e=="string"&&typeof t=="string"?e+t:e};A.camelcase=function(e){return typeof e!="string"?"":le.changecase(e,function(t){return t.toUpperCase()})};A.capitalize=function(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)};A.capitalizeAll=function(e){if(typeof e!="string")return"";if(z.isString(e))return e.replace(/\w\S*/g,function(t){return A.capitalize(t)})};A.center=function(e,t){if(typeof e!="string")return"";for(var r="",n=0;n-1;)i++,n+=r;return i};A.pascalcase=function(e){return typeof e!="string"?"":(e=le.changecase(e,function(t){return t.toUpperCase()}),e.charAt(0).toUpperCase()+e.slice(1))};A.pathcase=function(e){return typeof e!="string"?"":le.changecase(e,function(t){return"/"+t})};A.plusify=function(e,t){return typeof e!="string"?"":(z.isString(t)||(t=" "),e.split(t).join("+"))};A.prepend=function(e,t){return typeof e=="string"&&typeof t=="string"?t+e:e};A.raw=function(e){var t=e.fn(),r=z.options(this,e);if(r.escape!==!1)for(var n=0;(n=t.indexOf("{{",n))!==-1;)t[n-1]!=="\\"&&(t=t.slice(0,n)+"\\"+t.slice(n)),n+=3;return t};A.remove=function(e,t){return typeof e!="string"?"":z.isString(t)?e.split(t).join(""):e};A.removeFirst=function(e,t){return typeof e!="string"?"":z.isString(t)?e.replace(t,""):e};A.replace=function(e,t,r){return typeof e!="string"?"":z.isString(t)?(z.isString(r)||(r=""),e.split(t).join(r)):e};A.replaceFirst=function(e,t,r){return typeof e!="string"?"":z.isString(t)?(z.isString(r)||(r=""),e.replace(t,r)):e};A.reverse=ke().reverse;A.sentence=function(e){return typeof e!="string"?"":e.replace(/((?:\S[^\.\?\!]*)[\.\?\!]*)/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()})};A.snakecase=function(e){return typeof e!="string"?"":le.changecase(e,function(t){return"_"+t})};A.split=function(e,t){return typeof e!="string"?"":(z.isString(t)||(t=","),e.split(t))};A.startsWith=function(e,t,r){var n=[].slice.call(arguments);return r=n.pop(),z.isString(t)&&t.indexOf(e)===0?r.fn(this):typeof r.inverse=="function"?r.inverse(this):""};A.titleize=function(e){if(typeof e!="string")return"";for(var t=e.replace(/[- _]+/g," "),r=t.split(" "),n=r.length,i=[],u=0;n--;){var s=r[u++];i.push(sr.capitalize(s))}return i.join(" ")};A.trim=function(e){return typeof e=="string"?e.trim():""};A.trimLeft=function(e){if(z.isString(e))return e.replace(/^\s+/,"")};A.trimRight=function(e){if(z.isString(e))return e.replace(/\s+$/,"")};A.truncate=function(e,t,r){if(z.isString(e))return typeof r!="string"&&(r=""),e.length>t?e.slice(0,t-r.length)+r:e};A.truncateWords=function(e,t,r){if(z.isString(e)&&!isNaN(t)){typeof r!="string"&&(r="\u2026");var n=Number(t),i=e.split(/[ \t]/);if(n>=i.length)return e;i=i.slice(0,n);var u=i.join(" ").trim();return u+r}};A.upcase=function(){return A.uppercase.apply(this,arguments)};A.uppercase=function(e){return z.isObject(e)&&e.fn?e.fn(this).toUpperCase():typeof e!="string"?"":e.toUpperCase()}});var cr=U((zi,ar)=>{"use strict";var Gn=Me();ar.exports=function e(t){switch(Gn(t)){case"boolean":case"date":case"function":case"null":case"number":return!0;case"undefined":return!1;case"regexp":return t.source!=="(?:)"&&t.source!=="";case"buffer":return t.toString()!=="";case"error":return t.message!=="";case"string":case"arguments":return t.length!==0;case"file":case"map":case"set":return t.size!==0;case"array":case"object":for(let r of Object.keys(t))if(e(t[r]))return!0;return!1;default:return!0}}});var dr=U((Pi,lr)=>{"use strict";var Zn=Ae(),Vn=cr();lr.exports=function(e,t,r){return Qn(e)&&(typeof t=="string"||Array.isArray(t))?Vn(Zn(e,t,r)):!1};function Qn(e){return e!=null&&(typeof e=="object"||typeof e=="function"||Array.isArray(e))}});var pr=U((Ri,hr)=>{"use strict";function ot(e,t){if(!e)return!0;let r=t||ot.keywords;Array.isArray(r)||(r=[r]);let n=typeof e=="string"?e.toLowerCase():null;for(let i of r)if(i===e||i===n)return!0;return!1}ot.keywords=["0","false","nada","nil","nay","nah","negative","no","none","nope","nul","null","nix","nyet","uh-uh","veto","zero"];hr.exports=ot});var gr=U((Ji,mr)=>{"use strict";mr.exports=function(t){let r=Math.abs(t);if(isNaN(r))throw new TypeError("expected a number");if(!Number.isInteger(r))throw new Error("expected an integer");if(!Number.isSafeInteger(r))throw new Error("value exceeds maximum safe integer");return r%2===1}});var br=U((Gi,$r)=>{"use strict";var Xn=dr(),k=ee(),Kn=je(),yr=pr(),vr=gr(),W=$r.exports;W.and=function(){for(var e=arguments.length-1,t=arguments[e],r=!0,n=0;n":i=e>r;break;case"<=":i=e<=r;break;case">=":i=e>=r;break;case"typeof":i=typeof e===r;break;default:throw new Error("helper {{compare}}: invalid operator: `"+t+"`")}return k.value(i,this,n)};W.contains=function(e,t,r,n){typeof r=="object"&&(n=r,r=void 0);var i=Kn.contains(e,t,r);return k.value(i,this,n)};W.default=function(){for(var e=0;et,this,r)};W.gte=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e>=t,this,r)};W.has=function(e,t,r){return k.isOptions(e)&&(r=e,t=null,e=null),k.isOptions(t)&&(r=t,t=null),e===null?k.value(!1,this,r):arguments.length===2?k.value(Xn(this,e),this,r):(Array.isArray(e)||k.isString(e))&&k.isString(t)&&e.indexOf(t)>-1?k.fn(!0,this,r):k.isObject(e)&&k.isString(t)&&t in e?k.fn(!0,this,r):k.inverse(!1,this,r)};W.isFalsey=function(e,t){return k.value(yr(e),this,t)};W.isTruthy=function(e,t){return k.value(!yr(e),this,t)};W.ifEven=function(e,t){return k.value(!vr(e),this,t)};W.ifNth=function(e,t,r){var n=!isNaN(e)&&!isNaN(t)&&t%e===0;return k.value(n,this,r)};W.ifOdd=function(e,t){return k.value(vr(e),this,t)};W.is=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e==t,this,r)};W.isnt=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e!=t,this,r)};W.lt=function(e,t,r){return arguments.length===2&&(r=t,t=r.hash.compare),k.value(e=t,this,r)};W.unlessGteq=function(e,t,r){return k.isOptions(t)&&(r=t,t=r.hash.compare),k.value(et,this,r)}});var Or=U((Zi,wr)=>{var ei=tt(),ti=Object.prototype.toString;wr.exports=function(t){if(typeof t>"u")return"undefined";if(t===null)return"null";if(t===!0||t===!1||t instanceof Boolean)return"boolean";if(typeof t=="string"||t instanceof String)return"string";if(typeof t=="number"||t instanceof Number)return"number";if(typeof t=="function"||t instanceof Function)return"function";if(typeof Array.isArray<"u"&&Array.isArray(t))return"array";if(t instanceof RegExp)return"regexp";if(t instanceof Date)return"date";var r=ti.call(t);return r==="[object RegExp]"?"regexp":r==="[object Date]"?"date":r==="[object Arguments]"?"arguments":r==="[object Error]"?"error":ei(t)?"buffer":r==="[object Set]"?"set":r==="[object WeakSet]"?"weakset":r==="[object Map]"?"map":r==="[object WeakMap]"?"weakmap":r==="[object Symbol]"?"symbol":r==="[object Int8Array]"?"int8array":r==="[object Uint8Array]"?"uint8array":r==="[object Uint8ClampedArray]"?"uint8clampedarray":r==="[object Int16Array]"?"int16array":r==="[object Uint16Array]"?"uint16array":r==="[object Int32Array]"?"int32array":r==="[object Uint32Array]"?"uint32array":r==="[object Float32Array]"?"float32array":r==="[object Float64Array]"?"float64array":"object"}});var Sr=U((Vi,xr)=>{"use strict";var ri=Or();xr.exports=function(t){var r=ri(t);if(r!=="number"&&r!=="string")return!1;var n=+t;return n-n+1>=0&&t!==""}});var Mr=U((Qi,Nr)=>{"use strict";var ni=Sr();Nr.exports=function(t,r){if(!r)return t;if(!t)return{};for(var n=String(r).split(/[[.\]]/).filter(Boolean),i=n[n.length-1],u={};r=n.shift();)if(t=t[r],!t)return{};return ni(i)?[t]:(u[i]=t,u)}});var Dr=U((Xi,kr)=>{"use strict";var ii=Object.hasOwnProperty,ve=ee(),ui=ke(),P=kr.exports,si=Ae(),jr=Mr(),Ar=st();P.extend=function(){var e=[].slice.call(arguments),t={};ve.isOptions(e[e.length-1])&&(t=e.pop().hash,e.push(t));for(var r={},n=0;n{"use strict";var fi=ee(),Ur=Tr.exports,oi=Me();Ur.toRegex=function(e,t,r){var n=fi.options({},t,r);return new RegExp(e,n.flags)};Ur.test=function(e,t){if(typeof e!="string")return!1;if(oi(t)!=="regexp")throw new TypeError("expected a regular expression");return t.test(e)}});function $e(){return De>Ue.length-16&&(Yr.default.randomFillSync(Ue),De=0),Ue.slice(De,De+=16)}var Yr,Ue,De,at=Z(()=>{Yr=Ne(fe("crypto")),Ue=new Uint8Array(256),De=Ue.length});var Cr,Er=Z(()=>{Cr=/^(?:[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 ai(e){return typeof e=="string"&&Cr.test(e)}var ne,be=Z(()=>{Er();ne=ai});function de(e,t=0){return R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]}function ci(e,t=0){let r=de(e,t);if(!ne(r))throw TypeError("Stringified UUID is invalid");return r}var R,Ir,we=Z(()=>{be();R=[];for(let e=0;e<256;++e)R.push((e+256).toString(16).slice(1));Ir=ci});function li(e,t,r){let n=t&&r||0,i=t||new Array(16);e=e||{};let u=e.node||_r,s=e.clockseq!==void 0?e.clockseq:ct;if(u==null||s==null){let v=e.random||(e.rng||$e)();u==null&&(u=_r=[v[0]|1,v[1],v[2],v[3],v[4],v[5]]),s==null&&(s=ct=(v[6]<<8|v[7])&16383)}let f=e.msecs!==void 0?e.msecs:Date.now(),w=e.nsecs!==void 0?e.nsecs:dt+1,g=f-lt+(w-dt)/1e4;if(g<0&&e.clockseq===void 0&&(s=s+1&16383),(g<0||f>lt)&&e.nsecs===void 0&&(w=0),w>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");lt=f,dt=w,ct=s,f+=122192928e5;let l=((f&268435455)*1e4+w)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=l&255;let x=f/4294967296*1e4&268435455;i[n++]=x>>>8&255,i[n++]=x&255,i[n++]=x>>>24&15|16,i[n++]=x>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(let v=0;v<6;++v)i[n+v]=u[v];return t||de(i)}var _r,ct,lt,dt,Wr,Fr=Z(()=>{at();we();lt=0,dt=0;Wr=li});function di(e){if(!ne(e))throw TypeError("Invalid UUID");let t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var Te,ht=Z(()=>{be();Te=di});function hi(e){e=unescape(encodeURIComponent(e));let t=[];for(let r=0;r{we();ht();pi="6ba7b810-9dad-11d1-80b4-00c04fd430c8",mi="6ba7b811-9dad-11d1-80b4-00c04fd430c8"});function gi(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),Hr.default.createHash("md5").update(e).digest()}var Hr,Br,Lr=Z(()=>{Hr=Ne(fe("crypto"));Br=gi});var yi,zr,Pr=Z(()=>{pt();Lr();yi=Oe("v3",48,Br),zr=yi});var Rr,mt,Jr=Z(()=>{Rr=Ne(fe("crypto")),mt={randomUUID:Rr.default.randomUUID}});function vi(e,t,r){if(mt.randomUUID&&!t&&!e)return mt.randomUUID();e=e||{};let n=e.random||(e.rng||$e)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return de(n)}var Gr,Zr=Z(()=>{Jr();at();we();Gr=vi});function $i(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),Vr.default.createHash("sha1").update(e).digest()}var Vr,Qr,Xr=Z(()=>{Vr=Ne(fe("crypto"));Qr=$i});var bi,Kr,en=Z(()=>{pt();Xr();bi=Oe("v5",80,Qr),Kr=bi});var tn,rn=Z(()=>{tn="00000000-0000-0000-0000-000000000000"});function wi(e){if(!ne(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}var nn,un=Z(()=>{be();nn=wi});var sn={};yt(sn,{NIL:()=>tn,parse:()=>Te,stringify:()=>Ir,v1:()=>Wr,v3:()=>zr,v4:()=>Gr,v5:()=>Kr,validate:()=>ne,version:()=>nn});var fn=Z(()=>{Fr();Pr();Zr();en();rn();un();be();we();ht()});var an=U((Wu,on)=>{var Oi=(fn(),$t(sn)),xi=on.exports;xi.uuid=function(){return Oi.v4()}});var dn=U((Fu,gt)=>{var{date:Si,duration:Ni}=Dt(),Mi={math:Rt(),array:ke(),number:nr(),url:ur(),string:or(),comparison:br(),object:Dr(),regex:qr(),uuid:an()},ln=["sortBy"];gt.exports.helpersToRemoveForJs=ln;var cn={date:Si,duration:Ni},ie;gt.exports.getJsHelperList=()=>{if(ie)return ie;ie={};for(let e of Object.values(Mi))for(let[t,r]of Object.entries(e))ie[t]=(...n)=>r(...n,{});for(let e of Object.keys(cn))ie[e]=cn[e];for(let e of ln)delete ie[e];return Object.freeze(ie),ie}});var ki={};yt(ki,{default:()=>Ai});var{getJsHelperList:ji}=dn(),Ai={...ji(),stripProtocol:helpersStripProtocol};return $t(ki);})();
/*! Bundled license information:
is-buffer/index.js:
diff --git a/packages/server/src/jsRunner/bundles/index-helpers.ts b/packages/server/src/jsRunner/bundles/index-helpers.ts
index fc3c860f20..a8992294a9 100644
--- a/packages/server/src/jsRunner/bundles/index-helpers.ts
+++ b/packages/server/src/jsRunner/bundles/index-helpers.ts
@@ -2,9 +2,8 @@ const {
getJsHelperList,
} = require("../../../../string-templates/src/helpers/list.js")
-const helpers = getJsHelperList()
export default {
- ...helpers,
+ ...getJsHelperList(),
// pointing stripProtocol to a unexisting function to be able to declare it on isolated-vm
// @ts-ignore
// eslint-disable-next-line no-undef
diff --git a/packages/server/src/jsRunner/bundles/index.ts b/packages/server/src/jsRunner/bundles/index.ts
index 37e677ef46..9e2960807a 100644
--- a/packages/server/src/jsRunner/bundles/index.ts
+++ b/packages/server/src/jsRunner/bundles/index.ts
@@ -7,22 +7,19 @@ export const enum BundleType {
BSON = "bson",
}
-const bundleSourceCode = {
- [BundleType.HELPERS]: "../bundles/index-helpers.ivm.bundle.js",
- [BundleType.BSON]: "../bundles/bson.ivm.bundle.js",
+const bundleSourceFile: Record = {
+ [BundleType.HELPERS]: "./index-helpers.ivm.bundle.js",
+ [BundleType.BSON]: "./bson.ivm.bundle.js",
}
+const bundleSourceCode: Partial> = {}
export function loadBundle(type: BundleType) {
- if (environment.isJest()) {
- return fs.readFileSync(require.resolve(bundleSourceCode[type]), "utf-8")
+ let sourceCode = bundleSourceCode[type]
+ if (sourceCode) {
+ return sourceCode
}
- switch (type) {
- case BundleType.HELPERS:
- return require("../bundles/index-helpers.ivm.bundle.js")
- case BundleType.BSON:
- return require("../bundles/bson.ivm.bundle.js")
- default:
- utils.unreachable(type)
- }
+ sourceCode = fs.readFileSync(require.resolve(bundleSourceFile[type]), "utf-8")
+ bundleSourceCode[type] = sourceCode
+ return sourceCode
}
diff --git a/packages/server/src/jsRunner/index.ts b/packages/server/src/jsRunner/index.ts
index e39dab1313..0fbfed3b66 100644
--- a/packages/server/src/jsRunner/index.ts
+++ b/packages/server/src/jsRunner/index.ts
@@ -1,68 +1,49 @@
-import vm from "vm"
-import env from "../environment"
-import { setJSRunner, setOnErrorLog } from "@budibase/string-templates"
-import { context, logging, timers } from "@budibase/backend-core"
-import tracer from "dd-trace"
import { serializeError } from "serialize-error"
+import env from "../environment"
+import {
+ JsErrorTimeout,
+ setJSRunner,
+ setOnErrorLog,
+} from "@budibase/string-templates"
+import { context, logging } from "@budibase/backend-core"
+import tracer from "dd-trace"
-type TrackerFn = (f: () => T) => T
+import { IsolatedVM } from "./vm"
export function init() {
- setJSRunner((js: string, ctx: vm.Context) => {
+ setJSRunner((js: string, ctx: Record) => {
return tracer.trace("runJS", {}, span => {
- const perRequestLimit = env.JS_PER_REQUEST_TIMEOUT_MS
- let track: TrackerFn = f => f()
- if (perRequestLimit) {
- const bbCtx = tracer.trace("runJS.getCurrentContext", {}, span =>
- context.getCurrentContext()
- )
+ try {
+ const bbCtx = context.getCurrentContext()
+
+ const vm = bbCtx?.vm
+ ? bbCtx.vm
+ : new IsolatedVM({
+ memoryLimit: env.JS_RUNNER_MEMORY_LIMIT,
+ invocationTimeout: env.JS_PER_INVOCATION_TIMEOUT_MS,
+ isolateAccumulatedTimeout: env.JS_PER_REQUEST_TIMEOUT_MS,
+ }).withHelpers()
+
if (bbCtx) {
- if (!bbCtx.jsExecutionTracker) {
- span?.addTags({
- createdExecutionTracker: true,
- })
- bbCtx.jsExecutionTracker = tracer.trace(
- "runJS.createExecutionTimeTracker",
- {},
- span => timers.ExecutionTimeTracker.withLimit(perRequestLimit)
- )
- }
- span?.addTags({
- js: {
- limitMS: bbCtx.jsExecutionTracker.limitMs,
- elapsedMS: bbCtx.jsExecutionTracker.elapsedMS,
- },
- })
- // We call checkLimit() here to prevent paying the cost of creating
- // a new VM context below when we don't need to.
- tracer.trace("runJS.checkLimitAndBind", {}, span => {
- bbCtx.jsExecutionTracker!.checkLimit()
- track = bbCtx.jsExecutionTracker!.track.bind(
- bbCtx.jsExecutionTracker
- )
- })
+ // If we have a context, we want to persist it to reuse the isolate
+ bbCtx.vm = vm
}
+ const { helpers, ...rest } = ctx
+ return vm.withContext(rest, () => vm.execute(js))
+ } catch (error: any) {
+ if (error.message === "Script execution timed out.") {
+ throw new JsErrorTimeout()
+ }
+ throw error
}
-
- ctx = {
- ...ctx,
- alert: undefined,
- setInterval: undefined,
- setTimeout: undefined,
- }
-
- vm.createContext(ctx)
- return track(() =>
- vm.runInNewContext(js, ctx, {
- timeout: env.JS_PER_INVOCATION_TIMEOUT_MS,
- })
- )
})
})
if (env.LOG_JS_ERRORS) {
setOnErrorLog((error: Error) => {
- logging.logWarn(JSON.stringify(serializeError(error)))
+ logging.logWarn(
+ `Error while executing js: ${JSON.stringify(serializeError(error))}`
+ )
})
}
}
diff --git a/packages/server/src/jsRunner/tests/jsRunner.spec.ts b/packages/server/src/jsRunner/tests/jsRunner.spec.ts
index 04f1bf20f1..30e29885b1 100644
--- a/packages/server/src/jsRunner/tests/jsRunner.spec.ts
+++ b/packages/server/src/jsRunner/tests/jsRunner.spec.ts
@@ -1,22 +1,4 @@
-// import { validate as isValidUUID } from "uuid"
-
-jest.mock("@budibase/handlebars-helpers/lib/math", () => {
- const actual = jest.requireActual("@budibase/handlebars-helpers/lib/math")
-
- return {
- ...actual,
- random: () => 10,
- }
-})
-jest.mock("@budibase/handlebars-helpers/lib/uuid", () => {
- const actual = jest.requireActual("@budibase/handlebars-helpers/lib/uuid")
-
- return {
- ...actual,
- uuid: () => "f34ebc66-93bd-4f7c-b79b-92b5569138bc",
- }
-})
-
+import { validate as isValidUUID } from "uuid"
import { processStringSync, encodeJSBinding } from "@budibase/string-templates"
const { runJsHelpersTests } = require("@budibase/string-templates/test/utils")
@@ -27,7 +9,7 @@ import TestConfiguration from "../../tests/utilities/TestConfiguration"
tk.freeze("2021-01-21T12:00:00")
-describe("jsRunner", () => {
+describe("jsRunner (using isolated-vm)", () => {
const config = new TestConfiguration()
beforeAll(async () => {
@@ -36,6 +18,10 @@ describe("jsRunner", () => {
await config.init()
})
+ afterAll(() => {
+ config.end()
+ })
+
const processJS = (js: string, context?: object) => {
return config.doInContext(config.getAppId(), async () =>
processStringSync(encodeJSBinding(js), context || {})
@@ -47,10 +33,14 @@ describe("jsRunner", () => {
expect(output).toBe(3)
})
- // TODO This should be reenabled when running on isolated-vm
- it.skip("should prevent sandbox escape", async () => {
+ it("it can execute sloppy javascript", async () => {
+ const output = await processJS(`a=2;b=3;return a + b`)
+ expect(output).toBe(5)
+ })
+
+ it("should prevent sandbox escape", async () => {
const output = await processJS(
- `return this.constructor.constructor("return process")()`
+ `return this.constructor.constructor("return process.env")()`
)
expect(output).toBe("Error while executing JS")
})
@@ -58,26 +48,26 @@ describe("jsRunner", () => {
describe("helpers", () => {
runJsHelpersTests({
funcWrap: (func: any) => config.doInContext(config.getAppId(), func),
- // testsToSkip: ["random", "uuid"],
+ testsToSkip: ["random", "uuid"],
})
- // describe("uuid", () => {
- // it("uuid helper returns a valid uuid", async () => {
- // const result = await processJS("return helpers.uuid()")
- // expect(result).toBeDefined()
- // expect(isValidUUID(result)).toBe(true)
- // })
- // })
+ describe("uuid", () => {
+ it("uuid helper returns a valid uuid", async () => {
+ const result = await processJS("return helpers.uuid()")
+ expect(result).toBeDefined()
+ expect(isValidUUID(result)).toBe(true)
+ })
+ })
- // describe("random", () => {
- // it("random helper returns a valid number", async () => {
- // const min = 1
- // const max = 8
- // const result = await processJS(`return helpers.random(${min}, ${max})`)
- // expect(result).toBeDefined()
- // expect(result).toBeGreaterThanOrEqual(min)
- // expect(result).toBeLessThanOrEqual(max)
- // })
- // })
+ describe("random", () => {
+ it("random helper returns a valid number", async () => {
+ const min = 1
+ const max = 8
+ const result = await processJS(`return helpers.random(${min}, ${max})`)
+ expect(result).toBeDefined()
+ expect(result).toBeGreaterThanOrEqual(min)
+ expect(result).toBeLessThanOrEqual(max)
+ })
+ })
})
})
diff --git a/packages/server/src/jsRunner/vm/index.ts b/packages/server/src/jsRunner/vm/index.ts
index ab26f3f6d1..286a277cfb 100644
--- a/packages/server/src/jsRunner/vm/index.ts
+++ b/packages/server/src/jsRunner/vm/index.ts
@@ -1,270 +1 @@
-import ivm from "isolated-vm"
-import bson from "bson"
-
-import url from "url"
-import crypto from "crypto"
-import querystring from "querystring"
-
-import { BundleType, loadBundle } from "../bundles"
-import { VM } from "@budibase/types"
-
-class ExecutionTimeoutError extends Error {
- constructor(message: string) {
- super(message)
- this.name = "ExecutionTimeoutError"
- }
-}
-
-class ModuleHandler {
- private modules: {
- import: string
- moduleKey: string
- module: ivm.Module
- }[] = []
-
- private generateRandomKey = () => `i${crypto.randomUUID().replace(/-/g, "")}`
-
- registerModule(module: ivm.Module, imports: string) {
- this.modules.push({
- moduleKey: this.generateRandomKey(),
- import: imports,
- module: module,
- })
- }
-
- generateImports() {
- return this.modules
- .map(m => `import ${m.import} from "${m.moduleKey}"`)
- .join(";")
- }
-
- getModule(key: string) {
- const module = this.modules.find(m => m.moduleKey === key)
- return module?.module
- }
-}
-
-export class IsolatedVM implements VM {
- private isolate: ivm.Isolate
- private vm: ivm.Context
- private jail: ivm.Reference
- private invocationTimeout: number
- private isolateAccumulatedTimeout?: number
-
- // By default the wrapper returns itself
- private codeWrapper: (code: string) => string = code => code
-
- private moduleHandler = new ModuleHandler()
-
- private readonly resultKey = "results"
-
- constructor({
- memoryLimit,
- invocationTimeout,
- isolateAccumulatedTimeout,
- }: {
- memoryLimit: number
- invocationTimeout: number
- isolateAccumulatedTimeout?: number
- }) {
- this.isolate = new ivm.Isolate({ memoryLimit })
- this.vm = this.isolate.createContextSync()
- this.jail = this.vm.global
- this.jail.setSync("global", this.jail.derefInto())
-
- this.addToContext({
- [this.resultKey]: { out: "" },
- })
-
- this.invocationTimeout = invocationTimeout
- this.isolateAccumulatedTimeout = isolateAccumulatedTimeout
- }
-
- withHelpers() {
- const urlModule = this.registerCallbacks({
- resolve: url.resolve,
- parse: url.parse,
- })
-
- const querystringModule = this.registerCallbacks({
- escape: querystring.escape,
- })
-
- this.addToContext({
- helpersStripProtocol: new ivm.Callback((str: string) => {
- var parsed = url.parse(str) as any
- parsed.protocol = ""
- return parsed.format()
- }),
- })
-
- const injectedRequire = `const require=function req(val) {
- switch (val) {
- case "url": return ${urlModule};
- case "querystring": return ${querystringModule};
- }
- }`
- const helpersSource = loadBundle(BundleType.HELPERS)
- const helpersModule = this.isolate.compileModuleSync(
- `${injectedRequire};${helpersSource}`
- )
-
- helpersModule.instantiateSync(this.vm, specifier => {
- if (specifier === "crypto") {
- const cryptoModule = this.registerCallbacks({
- randomUUID: crypto.randomUUID,
- })
- const module = this.isolate.compileModuleSync(
- `export default ${cryptoModule}`
- )
- module.instantiateSync(this.vm, specifier => {
- throw new Error(`No imports allowed. Required: ${specifier}`)
- })
- return module
- }
- throw new Error(`No imports allowed. Required: ${specifier}`)
- })
-
- this.moduleHandler.registerModule(helpersModule, "helpers")
- return this
- }
-
- withContext(context: Record) {
- this.addToContext(context)
-
- return this
- }
-
- withParsingBson(data: any) {
- this.addToContext({
- bsonData: bson.BSON.serialize({ data }),
- })
-
- // If we need to parse bson, we follow the next steps:
- // 1. Serialise the data from potential BSON to buffer before passing it to the isolate
- // 2. Deserialise the data within the isolate, to get the original data
- // 3. Process script
- // 4. Stringify the result in order to convert the result from BSON to json
- this.codeWrapper = code =>
- `(function(){
- const data = deserialize(bsonData, { validation: { utf8: false } }).data;
- const result = ${code}
- return toJson(result);
- })();`
-
- const bsonSource = loadBundle(BundleType.BSON)
-
- this.addToContext({
- textDecoderCb: new ivm.Callback(
- (args: {
- constructorArgs: any
- functionArgs: Parameters["decode"]>
- }) => {
- const result = new TextDecoder(...args.constructorArgs).decode(
- ...args.functionArgs
- )
- return result
- }
- ),
- })
-
- // "Polyfilling" text decoder. `bson.deserialize` requires decoding. We are creating a bridge function so we don't need to inject the full library
- const textDecoderPolyfill = class TextDecoder {
- constructorArgs
-
- constructor(...constructorArgs: any) {
- this.constructorArgs = constructorArgs
- }
-
- decode(...input: any) {
- // @ts-ignore
- return textDecoderCb({
- constructorArgs: this.constructorArgs,
- functionArgs: input,
- })
- }
- }.toString()
- const bsonModule = this.isolate.compileModuleSync(
- `${textDecoderPolyfill};${bsonSource}`
- )
- bsonModule.instantiateSync(this.vm, specifier => {
- throw new Error(`No imports allowed. Required: ${specifier}`)
- })
-
- this.moduleHandler.registerModule(bsonModule, "{deserialize, toJson}")
-
- return this
- }
-
- execute(code: string): any {
- if (this.isolateAccumulatedTimeout) {
- const cpuMs = Number(this.isolate.cpuTime) / 1e6
- if (cpuMs > this.isolateAccumulatedTimeout) {
- throw new ExecutionTimeoutError(
- `CPU time limit exceeded (${cpuMs}ms > ${this.isolateAccumulatedTimeout}ms)`
- )
- }
- }
-
- code = `${this.moduleHandler.generateImports()};results.out=${this.codeWrapper(
- code
- )};`
-
- const script = this.isolate.compileModuleSync(code)
-
- script.instantiateSync(this.vm, specifier => {
- const module = this.moduleHandler.getModule(specifier)
- if (module) {
- return module
- }
-
- throw new Error(`"${specifier}" import not allowed`)
- })
-
- script.evaluateSync({ timeout: this.invocationTimeout })
-
- const result = this.getFromContext(this.resultKey)
- return result.out
- }
-
- private registerCallbacks(functions: Record) {
- const libId = crypto.randomUUID().replace(/-/g, "")
-
- const x: Record = {}
- for (const [funcName, func] of Object.entries(functions)) {
- const key = `f${libId}${funcName}cb`
- x[funcName] = key
-
- this.addToContext({
- [key]: new ivm.Callback((...params: any[]) => (func as any)(...params)),
- })
- }
-
- const mod =
- `{` +
- Object.entries(x)
- .map(([key, func]) => `${key}: ${func}`)
- .join() +
- "}"
- return mod
- }
-
- private addToContext(context: Record) {
- for (let key in context) {
- const value = context[key]
- this.jail.setSync(
- key,
- typeof value === "function"
- ? value
- : new ivm.ExternalCopy(value).copyInto({ release: true })
- )
- }
- }
-
- private getFromContext(key: string) {
- const ref = this.vm.global.getSync(key, { reference: true })
- const result = ref.copySync()
- ref.release()
- return result
- }
-}
+export * from "./isolated-vm"
diff --git a/packages/server/src/jsRunner/vm/isolated-vm.ts b/packages/server/src/jsRunner/vm/isolated-vm.ts
new file mode 100644
index 0000000000..e5c431666d
--- /dev/null
+++ b/packages/server/src/jsRunner/vm/isolated-vm.ts
@@ -0,0 +1,246 @@
+import ivm from "isolated-vm"
+import bson from "bson"
+
+import url from "url"
+import crypto from "crypto"
+import querystring from "querystring"
+
+import { BundleType, loadBundle } from "../bundles"
+import { VM } from "@budibase/types"
+import environment from "../../environment"
+
+class ExecutionTimeoutError extends Error {
+ constructor(message: string) {
+ super(message)
+ this.name = "ExecutionTimeoutError"
+ }
+}
+
+export class IsolatedVM implements VM {
+ private isolate: ivm.Isolate
+ private vm: ivm.Context
+ private jail: ivm.Reference
+ private invocationTimeout: number
+ private isolateAccumulatedTimeout?: number
+
+ // By default the wrapper returns itself
+ private codeWrapper: (code: string) => string = code => code
+
+ private readonly resultKey = "results"
+ private runResultKey: string
+
+ constructor({
+ memoryLimit,
+ invocationTimeout,
+ isolateAccumulatedTimeout,
+ }: {
+ memoryLimit?: number
+ invocationTimeout?: number
+ isolateAccumulatedTimeout?: number
+ } = {}) {
+ this.isolate = new ivm.Isolate({
+ memoryLimit: memoryLimit || environment.JS_RUNNER_MEMORY_LIMIT,
+ })
+ this.vm = this.isolate.createContextSync()
+ this.jail = this.vm.global
+ this.jail.setSync("global", this.jail.derefInto())
+
+ this.runResultKey = crypto.randomUUID()
+ this.addToContext({
+ [this.resultKey]: { [this.runResultKey]: "" },
+ })
+
+ this.invocationTimeout =
+ invocationTimeout || environment.JS_PER_INVOCATION_TIMEOUT_MS
+ this.isolateAccumulatedTimeout = isolateAccumulatedTimeout
+ }
+
+ withHelpers() {
+ const urlModule = this.registerCallbacks({
+ resolve: url.resolve,
+ parse: url.parse,
+ })
+
+ const querystringModule = this.registerCallbacks({
+ escape: querystring.escape,
+ })
+
+ const cryptoModule = this.registerCallbacks({
+ randomUUID: crypto.randomUUID,
+ })
+
+ this.addToContext({
+ helpersStripProtocol: new ivm.Callback((str: string) => {
+ var parsed = url.parse(str) as any
+ parsed.protocol = ""
+ return parsed.format()
+ }),
+ })
+
+ const injectedRequire = `require=function req(val) {
+ switch (val) {
+ case "url": return ${urlModule};
+ case "querystring": return ${querystringModule};
+ case "crypto": return ${cryptoModule};
+ }
+ }`
+ const helpersSource = loadBundle(BundleType.HELPERS)
+ const script = this.isolate.compileScriptSync(
+ `${injectedRequire};${helpersSource};helpers=helpers.default`
+ )
+
+ script.runSync(this.vm, { timeout: this.invocationTimeout, release: false })
+ new Promise(() => {
+ script.release()
+ })
+
+ return this
+ }
+
+ withContext(context: Record, executeWithContext: () => T) {
+ this.addToContext(context)
+
+ try {
+ return executeWithContext()
+ } finally {
+ this.removeFromContext(Object.keys(context))
+ }
+ }
+
+ withParsingBson(data: any) {
+ this.addToContext({
+ bsonData: bson.BSON.serialize({ data }),
+ })
+
+ // If we need to parse bson, we follow the next steps:
+ // 1. Serialise the data from potential BSON to buffer before passing it to the isolate
+ // 2. Deserialise the data within the isolate, to get the original data
+ // 3. Process script
+ // 4. Stringify the result in order to convert the result from BSON to json
+ this.codeWrapper = code =>
+ `(function(){
+ const data = bson.deserialize(bsonData, { validation: { utf8: false } }).data;
+ const result = ${code}
+ return bson.toJson(result);
+ })();`
+
+ const bsonSource = loadBundle(BundleType.BSON)
+
+ this.addToContext({
+ textDecoderCb: new ivm.Callback(
+ (args: {
+ constructorArgs: any
+ functionArgs: Parameters["decode"]>
+ }) => {
+ const result = new TextDecoder(...args.constructorArgs).decode(
+ ...args.functionArgs
+ )
+ return result
+ }
+ ),
+ })
+
+ // "Polyfilling" text decoder. `bson.deserialize` requires decoding. We are creating a bridge function so we don't need to inject the full library
+ const textDecoderPolyfill = class TextDecoderMock {
+ constructorArgs
+
+ constructor(...constructorArgs: any) {
+ this.constructorArgs = constructorArgs
+ }
+
+ decode(...input: any) {
+ // @ts-ignore
+ return textDecoderCb({
+ constructorArgs: this.constructorArgs,
+ functionArgs: input,
+ })
+ }
+ }
+ .toString()
+ .replace(/TextDecoderMock/, "TextDecoder")
+
+ const script = this.isolate.compileScriptSync(
+ `${textDecoderPolyfill};${bsonSource}`
+ )
+ script.runSync(this.vm, { timeout: this.invocationTimeout, release: false })
+ new Promise(() => {
+ script.release()
+ })
+
+ return this
+ }
+
+ execute(code: string): any {
+ if (this.isolateAccumulatedTimeout) {
+ const cpuMs = Number(this.isolate.cpuTime) / 1e6
+ if (cpuMs > this.isolateAccumulatedTimeout) {
+ throw new ExecutionTimeoutError(
+ `CPU time limit exceeded (${cpuMs}ms > ${this.isolateAccumulatedTimeout}ms)`
+ )
+ }
+ }
+
+ code = `results['${this.runResultKey}']=${this.codeWrapper(code)}`
+
+ const script = this.isolate.compileScriptSync(code)
+
+ script.runSync(this.vm, { timeout: this.invocationTimeout, release: false })
+ new Promise(() => {
+ script.release()
+ })
+
+ // We can't rely on the script run result as it will not work for non-transferable values
+ const result = this.getFromContext(this.resultKey)
+ return result[this.runResultKey]
+ }
+
+ private registerCallbacks(functions: Record) {
+ const libId = crypto.randomUUID().replace(/-/g, "")
+
+ const x: Record = {}
+ for (const [funcName, func] of Object.entries(functions)) {
+ const key = `f${libId}${funcName}cb`
+ x[funcName] = key
+
+ this.addToContext({
+ [key]: new ivm.Callback((...params: any[]) => (func as any)(...params)),
+ })
+ }
+
+ const mod =
+ `{` +
+ Object.entries(x)
+ .map(([key, func]) => `${key}: ${func}`)
+ .join() +
+ "}"
+ return mod
+ }
+
+ private addToContext(context: Record) {
+ for (let key in context) {
+ const value = context[key]
+ this.jail.setSync(
+ key,
+ typeof value === "function"
+ ? value
+ : new ivm.ExternalCopy(value).copyInto({ release: true })
+ )
+ }
+ }
+
+ private removeFromContext(keys: string[]) {
+ for (let key of keys) {
+ this.jail.deleteSync(key)
+ }
+ }
+
+ private getFromContext(key: string) {
+ const ref = this.vm.global.getSync(key, { reference: true })
+ const result = ref.copySync()
+
+ new Promise(() => {
+ ref.release()
+ })
+ return result
+ }
+}
diff --git a/packages/server/src/sdk/users/tests/utils.spec.ts b/packages/server/src/sdk/users/tests/utils.spec.ts
index 86dc411caf..efe790d49b 100644
--- a/packages/server/src/sdk/users/tests/utils.spec.ts
+++ b/packages/server/src/sdk/users/tests/utils.spec.ts
@@ -84,7 +84,8 @@ describe("syncGlobalUsers", () => {
await syncGlobalUsers()
const metadata = await rawUserMetadata()
- expect(metadata).toHaveLength(2)
+
+ expect(metadata).toHaveLength(2 + 1) // ADMIN user created in test bootstrap still in the application
expect(metadata).toContainEqual(
expect.objectContaining({
_id: db.generateUserMetadataID(user1._id!),
@@ -121,7 +122,7 @@ describe("syncGlobalUsers", () => {
await syncGlobalUsers()
const metadata = await rawUserMetadata()
- expect(metadata).toHaveLength(1) //ADMIN user created in test bootstrap still in the application
+ expect(metadata).toHaveLength(1) // ADMIN user created in test bootstrap still in the application
})
})
})
diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts
index ea3204536a..22bb66b130 100644
--- a/packages/server/src/tests/utilities/TestConfiguration.ts
+++ b/packages/server/src/tests/utilities/TestConfiguration.ts
@@ -76,14 +76,6 @@ mocks.licenses.useUnlimited()
dbInit()
-type DefaultUserValues = {
- globalUserId: string
- email: string
- firstName: string
- lastName: string
- csrfToken: string
-}
-
export interface TableToBuild extends Omit {
sourceId?: string
sourceType?: TableSourceType
@@ -99,14 +91,17 @@ export default class TestConfiguration {
prodApp: any
prodAppId: any
user: any
- globalUserId: any
userMetadataId: any
table?: Table
automation: any
datasource?: Datasource
tenantId?: string
- defaultUserValues: DefaultUserValues
api: API
+ csrfToken?: string
+
+ private get globalUserId() {
+ return this.user._id
+ }
constructor(openServer = true) {
if (openServer) {
@@ -121,21 +116,10 @@ export default class TestConfiguration {
}
this.appId = null
this.allApps = []
- this.defaultUserValues = this.populateDefaultUserValues()
this.api = new API(this)
}
- populateDefaultUserValues(): DefaultUserValues {
- return {
- globalUserId: `us_${newid()}`,
- email: generator.email(),
- firstName: generator.first(),
- lastName: generator.last(),
- csrfToken: generator.hash(),
- }
- }
-
getRequest() {
return this.request
}
@@ -162,10 +146,10 @@ export default class TestConfiguration {
getUserDetails() {
return {
- globalId: this.defaultUserValues.globalUserId,
- email: this.defaultUserValues.email,
- firstName: this.defaultUserValues.firstName,
- lastName: this.defaultUserValues.lastName,
+ globalId: this.globalUserId,
+ email: this.user.email,
+ firstName: this.user.firstName,
+ lastName: this.user.lastName,
}
}
@@ -300,15 +284,27 @@ export default class TestConfiguration {
}
// USER / AUTH
- async globalUser({
- id = this.defaultUserValues.globalUserId,
- firstName = this.defaultUserValues.firstName,
- lastName = this.defaultUserValues.lastName,
- builder = true,
- admin = false,
- email = this.defaultUserValues.email,
- roles,
- }: any = {}): Promise {
+ async globalUser(
+ config: {
+ id?: string
+ firstName?: string
+ lastName?: string
+ builder?: boolean
+ admin?: boolean
+ email?: string
+ roles?: any
+ } = {}
+ ): Promise {
+ const {
+ id = `us_${newid()}`,
+ firstName = generator.first(),
+ lastName = generator.last(),
+ builder = true,
+ admin = false,
+ email = generator.email(),
+ roles,
+ } = config
+
const db = tenancy.getTenantDB(this.getTenantId())
let existing
try {
@@ -327,7 +323,7 @@ export default class TestConfiguration {
await sessions.createASession(id, {
sessionId: "sessionid",
tenantId: this.getTenantId(),
- csrfToken: this.defaultUserValues.csrfToken,
+ csrfToken: this.csrfToken,
})
if (builder) {
user.builder = { global: true }
@@ -357,14 +353,16 @@ export default class TestConfiguration {
roles?: UserRoles
} = {}
): Promise {
- let { id, firstName, lastName, email, builder, admin, roles } = user
- firstName = firstName || this.defaultUserValues.firstName
- lastName = lastName || this.defaultUserValues.lastName
- email = email || this.defaultUserValues.email
- roles = roles || {}
- if (builder == null) {
- builder = true
- }
+ const {
+ id,
+ firstName = generator.first(),
+ lastName = generator.last(),
+ email = generator.email(),
+ builder = true,
+ admin,
+ roles,
+ } = user
+
const globalId = !id ? `us_${Math.random()}` : `us_${id}`
const resp = await this.globalUser({
id: globalId,
@@ -373,7 +371,7 @@ export default class TestConfiguration {
email,
builder,
admin,
- roles,
+ roles: roles || {},
})
await cache.user.invalidateUser(globalId)
return resp
@@ -448,7 +446,7 @@ export default class TestConfiguration {
defaultHeaders(extras = {}, prodApp = false) {
const tenantId = this.getTenantId()
const authObj: AuthToken = {
- userId: this.defaultUserValues.globalUserId,
+ userId: this.globalUserId,
sessionId: "sessionid",
tenantId,
}
@@ -457,7 +455,7 @@ export default class TestConfiguration {
const headers: any = {
Accept: "application/json",
Cookie: [`${constants.Cookie.Auth}=${authToken}`],
- [constants.Header.CSRF_TOKEN]: this.defaultUserValues.csrfToken,
+ [constants.Header.CSRF_TOKEN]: this.csrfToken,
Host: this.tenantHost(),
...extras,
}
@@ -487,7 +485,7 @@ export default class TestConfiguration {
async basicRoleHeaders() {
return await this.roleHeaders({
- email: this.defaultUserValues.email,
+ email: generator.email(),
builder: false,
prodApp: true,
roleId: roles.BUILTIN_ROLE_IDS.BASIC,
@@ -495,7 +493,7 @@ export default class TestConfiguration {
}
async roleHeaders({
- email = this.defaultUserValues.email,
+ email = generator.email(),
roleId = roles.BUILTIN_ROLE_IDS.ADMIN,
builder = false,
prodApp = true,
@@ -519,11 +517,12 @@ export default class TestConfiguration {
}
async newTenant(appName = newid()): Promise {
- this.defaultUserValues = this.populateDefaultUserValues()
+ this.csrfToken = generator.hash()
+
this.tenantId = structures.tenant.id()
this.user = await this.globalUser()
- this.globalUserId = this.user._id
- this.userMetadataId = generateUserMetadataID(this.globalUserId)
+ this.userMetadataId = generateUserMetadataID(this.user._id)
+
return this.createApp(appName)
}
@@ -533,7 +532,7 @@ export default class TestConfiguration {
// API
- async generateApiKey(userId = this.defaultUserValues.globalUserId) {
+ async generateApiKey(userId = this.user._id) {
const db = tenancy.getTenantDB(this.getTenantId())
const id = dbCore.generateDevInfoID(userId)
let devInfo: any
@@ -867,28 +866,6 @@ export default class TestConfiguration {
// QUERY
- async previewQuery(
- request: any,
- config: any,
- datasource: any,
- fields: any,
- params: any,
- verb?: string
- ) {
- return request
- .post(`/api/queries/preview`)
- .send({
- datasourceId: datasource._id,
- parameters: params || {},
- fields,
- queryVerb: verb || "read",
- name: datasource.name,
- })
- .set(config.defaultHeaders())
- .expect("Content-Type", /json/)
- .expect(200)
- }
-
async createQuery(config?: any) {
if (!this.datasource && !config) {
throw "No datasource created for query."
diff --git a/packages/server/src/tests/utilities/api/backup.ts b/packages/server/src/tests/utilities/api/backup.ts
index f9cbc7086e..8cd1e58a29 100644
--- a/packages/server/src/tests/utilities/api/backup.ts
+++ b/packages/server/src/tests/utilities/api/backup.ts
@@ -31,6 +31,19 @@ export class BackupAPI extends TestAPI {
return result.body as CreateAppBackupResponse
}
+ waitForBackupToComplete = async (appId: string, backupId: string) => {
+ for (let i = 0; i < 10; i++) {
+ await new Promise(resolve => setTimeout(resolve, 1000))
+ const result = await this.request
+ .get(`/api/apps/${appId}/backups/${backupId}/file`)
+ .set(this.config.defaultHeaders())
+ if (result.status === 200) {
+ return
+ }
+ }
+ throw new Error("Backup did not complete")
+ }
+
importBackup = async (
appId: string,
backupId: string
diff --git a/packages/server/src/tests/utilities/api/query.ts b/packages/server/src/tests/utilities/api/query.ts
index 350fe03c74..b0eac5c8b7 100644
--- a/packages/server/src/tests/utilities/api/query.ts
+++ b/packages/server/src/tests/utilities/api/query.ts
@@ -1,6 +1,7 @@
import TestConfiguration from "../TestConfiguration"
import {
Query,
+ QueryPreview,
type ExecuteQueryRequest,
type ExecuteQueryResponse,
} from "@budibase/types"
@@ -41,4 +42,19 @@ export class QueryAPI extends TestAPI {
return res.body
}
+
+ previewQuery = async (queryPreview: QueryPreview) => {
+ const res = await this.request
+ .post(`/api/queries/preview`)
+ .send(queryPreview)
+ .set(this.config.defaultHeaders())
+ .expect("Content-Type", /json/)
+ .expect(200)
+
+ if (res.status !== 200) {
+ throw new Error(JSON.stringify(res.body))
+ }
+
+ return res.body
+ }
}
diff --git a/packages/server/src/tests/utilities/structures.ts b/packages/server/src/tests/utilities/structures.ts
index fe82311810..2fecf15fd6 100644
--- a/packages/server/src/tests/utilities/structures.ts
+++ b/packages/server/src/tests/utilities/structures.ts
@@ -366,7 +366,7 @@ export function basicDatasource(): { datasource: Datasource } {
export function basicQuery(datasourceId: string): Query {
return {
- datasourceId: datasourceId,
+ datasourceId,
name: "New Query",
parameters: [],
fields: {},
diff --git a/packages/server/src/threads/definitions.ts b/packages/server/src/threads/definitions.ts
index 52f5576d9d..14b97c57b1 100644
--- a/packages/server/src/threads/definitions.ts
+++ b/packages/server/src/threads/definitions.ts
@@ -7,10 +7,10 @@ export interface QueryEvent {
datasource: Datasource
queryVerb: string
fields: { [key: string]: any }
- parameters: { [key: string]: any }
+ parameters: { [key: string]: unknown }
pagination?: any
transformer: any
- queryId: string
+ queryId?: string
environmentVariables?: Record
ctx?: any
schema?: Record
diff --git a/packages/server/src/threads/query.ts b/packages/server/src/threads/query.ts
index 6b11ce4759..6cdccc7868 100644
--- a/packages/server/src/threads/query.ts
+++ b/packages/server/src/threads/query.ts
@@ -7,7 +7,7 @@ import {
QueryVariable,
QueryResponse,
} from "./definitions"
-import ScriptRunner from "../utilities/scriptRunner"
+import { IsolatedVM } from "../jsRunner/vm"
import { getIntegration } from "../integrations"
import { processStringSync } from "@budibase/string-templates"
import { context, cache, auth } from "@budibase/backend-core"
@@ -26,7 +26,7 @@ class QueryRunner {
fields: any
parameters: any
pagination: any
- transformer: any
+ transformer: string
cachedVariables: any[]
ctx: any
queryResponse: any
@@ -43,7 +43,7 @@ class QueryRunner {
this.parameters = input.parameters
this.pagination = input.pagination
this.transformer = input.transformer
- this.queryId = input.queryId
+ this.queryId = input.queryId!
this.schema = input.schema
this.noRecursiveQuery = flags.noRecursiveQuery
this.cachedVariables = []
@@ -127,11 +127,17 @@ class QueryRunner {
// transform as required
if (transformer) {
- const runner = new ScriptRunner(transformer, {
+ transformer = `(function(){\n${transformer}\n})();`
+ let vm = new IsolatedVM()
+ if (datasource.source === SourceName.MONGODB) {
+ vm = vm.withParsingBson(rows)
+ }
+
+ const ctx = {
data: rows,
params: enrichedParameters,
- })
- rows = runner.execute()
+ }
+ rows = vm.withContext(ctx, () => vm.execute(transformer))
}
// if the request fails we retry once, invalidating the cached value
diff --git a/packages/server/src/utilities/rowProcessor/attachments.ts b/packages/server/src/utilities/rowProcessor/attachments.ts
index 799eab1d3a..c289680eb3 100644
--- a/packages/server/src/utilities/rowProcessor/attachments.ts
+++ b/packages/server/src/utilities/rowProcessor/attachments.ts
@@ -72,6 +72,9 @@ export class AttachmentCleanup {
continue
}
rows.forEach(row => {
+ if (!Array.isArray(row[key])) {
+ return
+ }
files = files.concat(
row[key].map((attachment: any) => attachment.key)
)
diff --git a/packages/server/src/utilities/rowProcessor/tests/attachments.spec.ts b/packages/server/src/utilities/rowProcessor/tests/attachments.spec.ts
index 762ec3bb8c..43af79d82c 100644
--- a/packages/server/src/utilities/rowProcessor/tests/attachments.spec.ts
+++ b/packages/server/src/utilities/rowProcessor/tests/attachments.spec.ts
@@ -103,6 +103,14 @@ describe("attachment cleanup", () => {
expect(mockedDeleteFiles).toBeCalledWith(BUCKET, [FILE_NAME])
})
+ it("should handle row deletion and not throw when attachments are undefined", async () => {
+ await AttachmentCleanup.rowDelete(table(), [
+ {
+ attach: undefined,
+ },
+ ])
+ })
+
it("shouldn't cleanup attachments if row not updated", async () => {
await AttachmentCleanup.rowUpdate(table(), { row: row(), oldRow: row() })
expect(mockedDeleteFiles).not.toBeCalled()
diff --git a/packages/server/src/utilities/scriptRunner.ts b/packages/server/src/utilities/scriptRunner.ts
deleted file mode 100644
index fee0215d2e..0000000000
--- a/packages/server/src/utilities/scriptRunner.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import fetch from "node-fetch"
-import { VM, VMScript } from "vm2"
-
-const JS_TIMEOUT_MS = 1000
-
-class ScriptRunner {
- vm: VM
- results: { out: string }
- script: VMScript
-
- constructor(script: string, context: any) {
- const code = `let fn = () => {\n${script}\n}; results.out = fn();`
- this.vm = new VM({
- timeout: JS_TIMEOUT_MS,
- })
- this.results = { out: "" }
- this.vm.setGlobals(context)
- this.vm.setGlobal("fetch", fetch)
- this.vm.setGlobal("results", this.results)
- this.script = new VMScript(code)
- }
-
- execute() {
- this.vm.run(this.script)
- return this.results.out
- }
-}
-
-export default ScriptRunner
diff --git a/packages/string-templates/src/helpers/javascript.js b/packages/string-templates/src/helpers/javascript.js
index 4a7f602690..7827736812 100644
--- a/packages/string-templates/src/helpers/javascript.js
+++ b/packages/string-templates/src/helpers/javascript.js
@@ -1,4 +1,4 @@
-const { atob } = require("../utilities")
+const { atob, isBackendService, isJSAllowed } = require("../utilities")
const cloneDeep = require("lodash.clonedeep")
const { LITERAL_MARKER } = require("../helpers/constants")
const { getJsHelperList } = require("./list")
@@ -7,6 +7,9 @@ const { getJsHelperList } = require("./list")
// This setter is used in the entrypoint (either index.js or index.mjs).
let runJS
module.exports.setJSRunner = runner => (runJS = runner)
+module.exports.removeJSRunner = () => {
+ runJS = undefined
+}
let onErrorLog
module.exports.setOnErrorLog = delegate => (onErrorLog = delegate)
@@ -39,7 +42,7 @@ const getContextValue = (path, context) => {
// Evaluates JS code against a certain context
module.exports.processJS = (handlebars, context) => {
- if (process && process.env.NO_JS) {
+ if (!isJSAllowed() || (isBackendService() && !runJS)) {
throw new Error("JS disabled in environment.")
}
try {
diff --git a/packages/string-templates/src/index.js b/packages/string-templates/src/index.js
index bcd63d2e6f..0125b9e0ab 100644
--- a/packages/string-templates/src/index.js
+++ b/packages/string-templates/src/index.js
@@ -2,7 +2,7 @@ const vm = require("vm")
const handlebars = require("handlebars")
const { registerAll, registerMinimum } = require("./helpers/index")
const processors = require("./processors")
-const { atob, btoa } = require("./utilities")
+const { atob, btoa, isBackendService } = require("./utilities")
const manifest = require("../manifest.json")
const {
FIND_HBS_REGEX,
@@ -404,18 +404,25 @@ module.exports.JsErrorTimeout = errors.JsErrorTimeout
module.exports.helpersToRemoveForJs = helpersToRemoveForJs
-if (process && !process.env.NO_JS) {
- /**
- * Use polyfilled vm to run JS scripts in a browser Env
- */
- javascript.setJSRunner((js, context) => {
- context = {
- ...context,
- alert: undefined,
- setInterval: undefined,
- setTimeout: undefined,
- }
- vm.createContext(context)
- return vm.runInNewContext(js, context, { timeout: 1000 })
- })
+function defaultJSSetup() {
+ if (!isBackendService()) {
+ /**
+ * Use polyfilled vm to run JS scripts in a browser Env
+ */
+ javascript.setJSRunner((js, context) => {
+ context = {
+ ...context,
+ alert: undefined,
+ setInterval: undefined,
+ setTimeout: undefined,
+ }
+ vm.createContext(context)
+ return vm.runInNewContext(js, context, { timeout: 1000 })
+ })
+ } else {
+ javascript.removeJSRunner()
+ }
}
+defaultJSSetup()
+
+module.exports.defaultJSSetup = defaultJSSetup
diff --git a/packages/string-templates/src/utilities.js b/packages/string-templates/src/utilities.js
index 775c150e1b..00b2d7d855 100644
--- a/packages/string-templates/src/utilities.js
+++ b/packages/string-templates/src/utilities.js
@@ -4,6 +4,14 @@ module.exports.FIND_HBS_REGEX = /{{([^{].*?)}}/g
module.exports.FIND_ANY_HBS_REGEX = /{?{{([^{].*?)}}}?/g
module.exports.FIND_TRIPLE_HBS_REGEX = /{{{([^{].*?)}}}/g
+module.exports.isBackendService = () => {
+ return typeof window === "undefined"
+}
+
+module.exports.isJSAllowed = () => {
+ return process && !process.env.NO_JS
+}
+
// originally this could be done with a single regex using look behinds
// but safari does not support this feature
// original regex: /(? {
+ const utilities = jest.requireActual("../src/utilities")
+ return {
+ ...utilities,
+ isBackendService: jest.fn().mockReturnValue(true),
+ }
+})
+const { defaultJSSetup, processStringSync, encodeJSBinding } = require("../src")
+const { isBackendService } = require("../src/utilities")
+const mockedBackendService = jest.mocked(isBackendService)
+
+const binding = encodeJSBinding("return 1")
+describe("confirm VM is available when expected and when not", () => {
+ it("shouldn't have JS available in a backend service by default", () => {
+ defaultJSSetup()
+ const result = processStringSync(binding, {})
+ // shouldn't process at all
+ expect(result).toBe(binding)
+ })
+
+ it("should have JS available in frontend environments", () => {
+ mockedBackendService.mockReturnValue(false)
+ defaultJSSetup()
+ const result = processStringSync(binding, {})
+ expect(result).toBe(1)
+ })
+})
diff --git a/packages/types/src/documents/app/query.ts b/packages/types/src/documents/app/query.ts
index f4547b9774..b1b0a1d780 100644
--- a/packages/types/src/documents/app/query.ts
+++ b/packages/types/src/documents/app/query.ts
@@ -19,7 +19,7 @@ export interface Query extends Document {
}
export interface QueryPreview extends Omit {
- queryId: string
+ queryId?: string
}
export interface QueryParameter {
diff --git a/packages/types/src/sdk/vm.ts b/packages/types/src/sdk/vm.ts
index 43b7775d3b..f1099524bc 100644
--- a/packages/types/src/sdk/vm.ts
+++ b/packages/types/src/sdk/vm.ts
@@ -1,3 +1,4 @@
export interface VM {
execute(code: string): any
+ withContext(context: Record, executeWithContext: () => T): T
}
diff --git a/scripts/build.js b/scripts/build.js
index ad31381684..0c0c8f1548 100755
--- a/scripts/build.js
+++ b/scripts/build.js
@@ -49,7 +49,6 @@ function runBuild(entry, outfile) {
preserveSymlinks: true,
loader: {
".svelte": "copy",
- ".ivm.bundle.js": "text",
},
metafile: true,
external: [
@@ -70,7 +69,7 @@ function runBuild(entry, outfile) {
platform: "node",
outfile,
}).then(result => {
- glob(`${process.cwd()}/src/**/*.hbs`, {}, (err, files) => {
+ glob(`${process.cwd()}/src/**/*.{hbs,ivm.bundle.js}`, {}, (err, files) => {
for (const file of files) {
fs.copyFileSync(file, `${process.cwd()}/dist/${path.basename(file)}`)
}
diff --git a/scripts/install-node.sh b/scripts/install-node.sh
deleted file mode 100644
index 562bdf2cd3..0000000000
--- a/scripts/install-node.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-apt-get install -y gnupg
-curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg > /dev/null
-echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
-apt-get update
-echo "INSTALLING NODE $NODE_MAJOR"
-apt-get install -y --no-install-recommends nodejs
-npm install --global yarn pm2
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index c0a11b9bf7..47de6a67ec 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6463,7 +6463,7 @@ acorn@^7.1.1:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
-acorn@^8.1.0, acorn@^8.10.0, acorn@^8.2.4, acorn@^8.4.1, acorn@^8.5.0, acorn@^8.7.0, acorn@^8.7.1, acorn@^8.8.1, acorn@^8.8.2, acorn@^8.9.0:
+acorn@^8.1.0, acorn@^8.10.0, acorn@^8.2.4, acorn@^8.4.1, acorn@^8.5.0, acorn@^8.7.1, acorn@^8.8.1, acorn@^8.8.2, acorn@^8.9.0:
version "8.11.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a"
integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==
@@ -10763,7 +10763,7 @@ fetch-cookie@0.11.0:
dependencies:
tough-cookie "^2.3.3 || ^3.0.1 || ^4.0.0"
-fflate@^0.4.1, fflate@^0.4.8:
+fflate@^0.4.1:
version "0.4.8"
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.4.8.tgz#f90b82aefbd8ac174213abb338bd7ef848f0f5ae"
integrity sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==
@@ -21633,14 +21633,6 @@ vlq@^0.2.2:
resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.3.tgz#8f3e4328cf63b1540c0d67e1b2778386f8975b26"
integrity sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==
-vm2@^3.9.19:
- version "3.9.19"
- resolved "https://registry.yarnpkg.com/vm2/-/vm2-3.9.19.tgz#be1e1d7a106122c6c492b4d51c2e8b93d3ed6a4a"
- integrity sha512-J637XF0DHDMV57R6JyVsTak7nIL8gy5KH4r1HiwWLf/4GBbb5MKL5y7LpmF4A8E2nR6XmzpmMFQ7V7ppPTmUQg==
- dependencies:
- acorn "^8.7.0"
- acorn-walk "^8.2.0"
-
vuvuzela@1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/vuvuzela/-/vuvuzela-1.0.3.tgz#3be145e58271c73ca55279dd851f12a682114b0b"