prasi-bun/static/vi.921ac197.js

26481 lines
1.2 MiB
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
(function (modules, entry, mainEntry, parcelRequireName, globalName) {
/* eslint-disable no-undef */
var globalObject =
typeof globalThis !== 'undefined'
? globalThis
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: {};
/* eslint-enable no-undef */
// Save the require from previous bundle to this closure if any
var previousRequire =
typeof globalObject[parcelRequireName] === 'function' &&
globalObject[parcelRequireName];
var cache = previousRequire.cache || {};
// Do not use `require` to prevent Webpack from trying to bundle this call
var nodeRequire =
typeof module !== 'undefined' &&
typeof module.require === 'function' &&
module.require.bind(module);
function newRequire(name, jumped) {
if (!cache[name]) {
if (!modules[name]) {
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire =
typeof globalObject[parcelRequireName] === 'function' &&
globalObject[parcelRequireName];
if (!jumped && currentRequire) {
return currentRequire(name, true);
}
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if (previousRequire) {
return previousRequire(name, true);
}
// Try the node require function if it exists.
if (nodeRequire && typeof name === 'string') {
return nodeRequire(name);
}
var err = new Error("Cannot find module '" + name + "'");
err.code = 'MODULE_NOT_FOUND';
throw err;
}
localRequire.resolve = resolve;
localRequire.cache = {};
var module = (cache[name] = new newRequire.Module(name));
modules[name][0].call(
module.exports,
localRequire,
module,
module.exports,
this
);
}
return cache[name].exports;
function localRequire(x) {
var res = localRequire.resolve(x);
return res === false ? {} : newRequire(res);
}
function resolve(x) {
var id = modules[name][1][x];
return id != null ? id : x;
}
}
function Module(moduleName) {
this.id = moduleName;
this.bundle = newRequire;
this.exports = {};
}
newRequire.isParcelRequire = true;
newRequire.Module = Module;
newRequire.modules = modules;
newRequire.cache = cache;
newRequire.parent = previousRequire;
newRequire.register = function (id, exports) {
modules[id] = [
function (require, module) {
module.exports = exports;
},
{},
];
};
Object.defineProperty(newRequire, 'root', {
get: function () {
return globalObject[parcelRequireName];
},
});
globalObject[parcelRequireName] = newRequire;
for (var i = 0; i < entry.length; i++) {
newRequire(entry[i]);
}
if (mainEntry) {
// Expose entry point to Node, AMD or browser globals
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
var mainExports = newRequire(mainEntry);
// CommonJS
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = mainExports;
// RequireJS
} else if (typeof define === 'function' && define.amd) {
define(function () {
return mainExports;
});
// <script>
} else if (globalName) {
this[globalName] = mainExports;
}
}
})({"4cSjT":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _uuid = require("uuid");
var _webUtils = require("web-utils");
var _edGlobal = require("../../nova/ed/logic/ed-global");
var _edSync = require("../../nova/ed/logic/ed-sync");
var _loading = require("../../utils/ui/loading");
var _preview = require("../../nova/vi/preview");
exports.default = (0, _webUtils.page)({
url: "/vi/:domain/**",
component: ({})=>{
const p = (0, _webUtils.useGlobal)((0, _edGlobal.EDGlobal), "EDITOR");
params.site_id = params.domain;
let pathname = `/${params._ === "_" ? "" : params._}`;
if ((0, _uuid.validate)(params._)) {
const arr = params._.split("/");
params.page_id = arr.shift();
pathname = `/${arr.join("/")}`;
}
window.pathname = pathname;
const w = window;
if (!w.Y) {
(async ()=>{
window.Y = await require("c10c8889489e84f7");
window.syncronize = (await require("811adecf40594e30")).syncronize;
p.render();
})();
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _loading.Loading), {
note: "init"
}, void 0, false, {
fileName: "src/base/page/vi.tsx",
lineNumber: 29,
columnNumber: 14
}, undefined);
}
if (!(0, _edSync.edInitSync)(p) && !p.sync) return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _loading.Loading), {
note: "connecting-ws"
}, void 0, false, {
fileName: "src/base/page/vi.tsx",
lineNumber: 33,
columnNumber: 14
}, undefined);
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _preview.ViPreview), {
pathname: pathname
}, void 0, false, {
fileName: "src/base/page/vi.tsx",
lineNumber: 36,
columnNumber: 12
}, undefined);
}
});
},{"react/jsx-dev-runtime":"j0wtd","uuid":"FvQH3","web-utils":"aOKw0","../../nova/ed/logic/ed-global":"5VTke","../../nova/ed/logic/ed-sync":"eEfjs","../../utils/ui/loading":"jJynm","../../nova/vi/preview":"fXWtG","c10c8889489e84f7":"21HNT","811adecf40594e30":"efzlw","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"FvQH3":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "v1", ()=>(0, _v1JsDefault.default));
parcelHelpers.export(exports, "v3", ()=>(0, _v3JsDefault.default));
parcelHelpers.export(exports, "v4", ()=>(0, _v4JsDefault.default));
parcelHelpers.export(exports, "v5", ()=>(0, _v5JsDefault.default));
parcelHelpers.export(exports, "NIL", ()=>(0, _nilJsDefault.default));
parcelHelpers.export(exports, "version", ()=>(0, _versionJsDefault.default));
parcelHelpers.export(exports, "validate", ()=>(0, _validateJsDefault.default));
parcelHelpers.export(exports, "stringify", ()=>(0, _stringifyJsDefault.default));
parcelHelpers.export(exports, "parse", ()=>(0, _parseJsDefault.default));
var _v1Js = require("./v1.js");
var _v1JsDefault = parcelHelpers.interopDefault(_v1Js);
var _v3Js = require("./v3.js");
var _v3JsDefault = parcelHelpers.interopDefault(_v3Js);
var _v4Js = require("./v4.js");
var _v4JsDefault = parcelHelpers.interopDefault(_v4Js);
var _v5Js = require("./v5.js");
var _v5JsDefault = parcelHelpers.interopDefault(_v5Js);
var _nilJs = require("./nil.js");
var _nilJsDefault = parcelHelpers.interopDefault(_nilJs);
var _versionJs = require("./version.js");
var _versionJsDefault = parcelHelpers.interopDefault(_versionJs);
var _validateJs = require("./validate.js");
var _validateJsDefault = parcelHelpers.interopDefault(_validateJs);
var _stringifyJs = require("./stringify.js");
var _stringifyJsDefault = parcelHelpers.interopDefault(_stringifyJs);
var _parseJs = require("./parse.js");
var _parseJsDefault = parcelHelpers.interopDefault(_parseJs);
},{"./v1.js":false,"./v3.js":false,"./v4.js":false,"./v5.js":false,"./nil.js":false,"./version.js":false,"./validate.js":"fXivx","./stringify.js":false,"./parse.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fXivx":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _regexJs = require("./regex.js");
var _regexJsDefault = parcelHelpers.interopDefault(_regexJs);
function validate(uuid) {
return typeof uuid === "string" && (0, _regexJsDefault.default).test(uuid);
}
exports.default = validate;
},{"./regex.js":"aZpDf","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"aZpDf":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
exports.default = /^(?:[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;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"5VTke":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "EmptySite", ()=>EmptySite);
parcelHelpers.export(exports, "EmptyPage", ()=>EmptyPage);
parcelHelpers.export(exports, "active", ()=>active);
parcelHelpers.export(exports, "EDGlobal", ()=>EDGlobal);
var _webUtils = require("web-utils");
var _radix3 = require("radix3");
const EmptySite = {
id: "",
name: "",
domain: "",
config: {
api_url: ""
},
deploy_name: "",
js: "",
js_compiled: "",
responsive: "",
layout: {
id: "--",
meta: undefined,
entry: []
}
};
const EmptyPage = {
id: "",
name: "",
url: "",
snapshot: null,
comps: {}
};
const EmptyComp = {
id: "",
snapshot: null
};
const target = {
active_id: false,
comp_id: false,
instance_comp_id: false,
instance_item_id: false
};
const active = {
should_render_main: true,
hover: {
id: "",
tree: false
},
scope: {},
script_nav: {
list: [],
idx: -1
},
text: {
id: "",
content: "",
timeout: null,
el: null
},
get item_id () {
if (target.active_id === false) target.active_id = localStorage.getItem("prasi-active-id") || "";
return target.active_id || "";
},
set item_id (val){
localStorage.setItem("prasi-active-id", val || "");
target.active_id = val || "";
},
get comp_id () {
if (target.comp_id === false) target.comp_id = localStorage.getItem("prasi-comp-id") || "";
return target.comp_id || "";
},
set comp_id (val){
localStorage.setItem("prasi-comp-id", val || "");
target.comp_id = val || "";
},
instance: {
get comp_id () {
if (target.instance_comp_id === false) target.instance_comp_id = localStorage.getItem("prasi-instance-comp-id") || "";
return target.instance_comp_id || "";
},
set comp_id (val){
localStorage.setItem("prasi-instance-comp-id", val || "");
target.instance_comp_id = val || "";
},
get item_id () {
if (target.instance_item_id === false) target.instance_item_id = localStorage.getItem("prasi-instance-item-id") || "";
return target.instance_item_id || "";
},
set item_id (val){
localStorage.setItem("prasi-instance-item-id", val || "");
target.instance_item_id = val || "";
}
}
};
const EDGlobal = {
mode: "",
user: {
id: "",
username: "",
client_id: ""
},
clients: {},
status: "init",
preview: {
url_cache: new Set(),
route_cache: (0, _radix3.createRouter)(),
page_cache: {},
meta_cache: {}
},
sync: undefined,
site: (0, _webUtils.deepClone)(EmptySite),
site_tstamp: Date.now(),
site_exports: {},
site_dts: "",
site_dts_entry: {},
prisma_ext: "",
script: {
site_types: {},
loaded: false,
do_edit: async (newval, all)=>{},
db: null,
api: null,
init_local_effect: {}
},
page: {
history: {
id: "",
show: false
},
root_id: "root",
cur: EmptyPage,
doc: null,
list: {},
building: false,
meta: {},
entry: [],
tree: [],
render: ()=>{}
},
comp: {
doc: null,
item: null,
loaded: {},
list: {},
group: {}
},
code: {},
global_prop: [],
ui: {
build: {
status: "ready"
},
monaco: null,
comp_editable: localStorage.getItem("prasi-comp-editable") === "yes",
zoom: localStorage.zoom || "100%",
side: {
prop: true
},
layout: {
left: parseInt(localStorage.getItem("prasi-layout-left") || "250"),
right: parseInt(localStorage.getItem("prasi-layout-right") || "250")
},
prevent_indent_hook: false,
syncing: false,
tree: {
item_loading: [],
search: "",
search_ref: null,
search_mode: {
Name: true,
JS: false,
HTML: false,
CSS: false
},
rename_id: "",
open_all: false,
open: {}
},
popup: {
file: {
enabled: false,
open: false,
picker: {
value: "",
on_pick: false,
multi: false
},
path: "/",
expanded: JSON.parse(localStorage.getItem("panel-file-expanded") || "{}"),
entry: {},
selected: new Set(),
action: null,
file_renaming: "",
file_ctx_menu_event: null,
tree: [],
tree_renaming: "",
tree_ctx_path: "",
tree_ctx_menu_event: null,
preview: true,
upload: {
started: false,
progress: {}
}
},
code: {
init: false,
open: false,
name: "site",
log: "",
loading: false,
rebuilding: false,
startup_status: "init",
error: false,
show_log: false,
list: {}
},
page: {
open: null,
form: null
},
script: {
open: false,
mode: "js",
lastMode: "js",
type: "item",
prop_kind: "",
prop_name: "",
on_close: ()=>{},
typings: {
status: "ok",
err_msg: ""
},
wb_render: ()=>{}
},
site: null,
site_form: null,
comp: {
preview_id: "",
open: null,
import: false
},
comp_group: null,
api: {
open: false
}
}
}
};
},{"web-utils":"aOKw0","radix3":"9PPrn","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"eEfjs":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "loadSession", ()=>loadSession);
parcelHelpers.export(exports, "edInitSync", ()=>edInitSync);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _wasmGzip = require("wasm-gzip");
var _webUtils = require("web-utils");
var _yjs = require("yjs");
var _typings = require("../../../utils/script/typings");
var _wsClient = require("../../../utils/sync/ws-client");
var _general = require("../../../utils/types/general");
var _loading = require("../../../utils/ui/loading");
var _codeLoader = require("./code-loader");
var _load = require("./comp/load");
var _edGlobal = require("./ed-global");
var _edRoute = require("./ed-route");
var _edSite = require("./ed-site");
var _build = require("./tree/build");
var _dateFns = require("date-fns");
var Buffer = require("727807bed56e7e58").Buffer;
const decoder = new TextDecoder();
const page = {
list: [],
route: null
};
const loadSession = (p)=>{
const session = JSON.parse(localStorage.getItem("prasi-session") || "null");
if (!session && location.pathname.startsWith("/ed/")) {
location.href = "/login";
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _loading.Loading), {
note: "logging in"
}, void 0, false, {
fileName: "src/nova/ed/logic/ed-sync.tsx",
lineNumber: 30,
columnNumber: 12
}, undefined);
}
if (session?.data?.user) {
p.user.id = session.data.user.id;
p.user.username = session.data.user.username;
} else {
p.user.id = "ab1390f5-40d5-448e-a8c3-84b0fb600930";
p.user.username = "anonymous";
}
};
const edInitSync = (p)=>{
loadSession(p);
if (p.sync) {
if (p.site.id === "--loading--") return false;
if (params.site_id !== p.site.id) {
p.site = (0, _webUtils.deepClone)((0, _edGlobal.EmptySite));
p.site.id = "--loading--";
p.ui.popup.code.init = false;
p.sync.site.load(params.site_id).then(async (site)=>{
if (site) {
await (0, _edSite.loadSite)(p, site, "from-sync");
p.render();
} else {
alert("Site not found. redirecting...");
location.href = `/ed/`;
}
return;
});
return false;
}
if (!p.page.cur.id && !params.page_id && params.site_id && location.pathname.startsWith("/ed/")) {
_db.page.findFirst({
where: {
is_deleted: false,
is_default_layout: false,
id_site: params.site_id
},
select: {
id: true
}
}).then((e)=>{
if (params.site_id === "_") {
alert("asdsa");
return;
}
if (e) location.href = `/ed/${params.site_id}/${e.id}`;
});
return false;
}
}
if (!p.sync) {
p.site = (0, _webUtils.deepClone)((0, _edGlobal.EmptySite));
(0, _wsClient.clientStartSync)({
user_id: p.user.id,
site_id: params.site_id,
page_id: params.page_id,
events: {
opened () {
if ((0, _general.w).offline) {
console.log("reconnected!");
(0, _general.w).offline = false;
p.ui.syncing = true;
p.render();
} else {
(0, _general.w).offline = false;
p.render();
}
},
shakehand (client_id) {
p.user.client_id = client_id;
console.clear();
console.log(`\u{1F680} Prasi Ready (client_id: ${client_id})`);
},
disconnected () {
console.log("offline, reconnecting...");
(0, _general.w).offline = true;
p.render();
return {
reconnect: true
};
},
async editor_start (e) {
if (params.site_id !== e.site_id || params.page_id !== e.page_id) {
if (!p.page.cur.id) {
p.site.id = e.site_id;
p.page.cur.id = e.page_id;
if (location.pathname.startsWith("/ed/")) location.href = `/ed/${e.site_id}/${e.page_id}`;
}
} else {
p.site.id = e.site_id;
p.page.cur.id = e.page_id;
p.render();
}
},
site_updated (site) {
for (const [k, v] of Object.entries(site))if (k === "js" || k === "js_compiled") p.site[k] = decoder.decode((0, _wasmGzip.decompress)(v));
else p.site[k] = v;
p.render();
},
async code_changes ({ ts, mode, status }) {
if (mode === "frontend") {
if (status === "ok") {
p.ui.build.status = "ready";
p.render();
console.log(`${(0, _dateFns.format)(Date.now(), "HH:mm:ss")} \u{1F6A7} Code updated from vscode `);
await (0, _codeLoader.loadFrontEnd)(p, ts);
} else if (status === "building") {
p.ui.build.status = "loading";
p.render();
console.log(`${(0, _dateFns.format)(Date.now(), "HH:mm:ss")} \u{23F3} Code changed from vscode, rebuilding...`);
} else {
p.ui.build.status = "error";
p.render();
}
} else {
await (0, _codeLoader.loadTypings)(p);
if (p.ui.monaco) (0, _typings.registerSiteTypings)(p.ui.monaco, p);
}
await (0, _build.treeRebuild)(p);
p.render();
},
async remote_svlocal (data) {
let doc = null;
if (data.type === "page" && p.page.cur.id === data.id) doc = p.page.doc;
else if (data.type === "comp" && p.comp.list[data.id]) doc = p.comp.list[data.id].doc;
if (doc && p.sync) {
const diff_remote = _yjs.encodeStateAsUpdate(doc, (0, _wasmGzip.decompress)(data.sv_local));
const sv_remote = _yjs.encodeStateVector(doc);
const sv = Buffer.from((0, _wasmGzip.compress)(sv_remote));
const diff = Buffer.from((0, _wasmGzip.compress)(diff_remote));
const res = await p.sync.yjs.sv_remote(data.type, data.id, sv, diff);
if (res) {
_yjs.applyUpdate(doc, (0, _wasmGzip.decompress)(res.diff), "sv_remote");
if (data.type === "page") {
delete p.preview.meta_cache[data.id];
await (0, _build.treeRebuild)(p, {
note: "sv_remote"
});
} else if (data.type === "comp") {
const updated = await (0, _load.updateComponentMeta)(p, doc, data.id);
if (updated) {
p.comp.list[data.id].meta = updated.meta;
p.comp.list[data.id].tree = updated.tree;
}
await (0, _build.treeRebuild)(p, {
note: "sv_remote"
});
}
p.render();
}
}
}
}
}).then((e)=>{
p.sync = e;
});
return false;
} else if (params.page_id !== p.page.cur.id && location.pathname.startsWith("/ed")) {
(0, _edRoute.reloadPage)(p, params.page_id, "change page");
return false;
}
return true;
};
},{"727807bed56e7e58":"bwHdc","react/jsx-dev-runtime":"j0wtd","wasm-gzip":"9TduR","web-utils":"aOKw0","yjs":"85Wzk","../../../utils/script/typings":"bN75g","../../../utils/sync/ws-client":"g3FdK","../../../utils/types/general":"58I9D","../../../utils/ui/loading":"jJynm","./code-loader":"iWfqp","./comp/load":"fQ2tn","./ed-global":"5VTke","./ed-route":"fHUp0","./ed-site":"hPnT5","./tree/build":"53DOC","date-fns":"eJgDZ","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"9TduR":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "DecompressionError", ()=>s) //# sourceMappingURL=wasm_gzip.js.map
;
parcelHelpers.export(exports, "compress", ()=>l);
parcelHelpers.export(exports, "decompress", ()=>m);
parcelHelpers.export(exports, "default", ()=>r);
parcelHelpers.export(exports, "freeBuffer", ()=>y);
parcelHelpers.export(exports, "initSync", ()=>o);
let e = null;
async function n(n) {
if (e) return e;
const t = (async ()=>{
n || (n = new URL(require("ef0034b6e784b6d"))), ("string" == typeof n || "function" == typeof Request && n instanceof Request || "function" == typeof URL && n instanceof URL) && (n = fetch(n));
const t = await async function(e) {
const n = {};
if ("function" == typeof Response && e instanceof Response) {
if ("function" == typeof WebAssembly.instantiateStreaming) try {
return await WebAssembly.instantiateStreaming(e, n);
} catch (n) {
if ("application/wasm" == e.headers.get("Content-Type")) throw n;
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", n);
}
const t = await e.arrayBuffer();
return await WebAssembly.instantiate(t, n);
}
{
const t = await WebAssembly.instantiate(e, n);
return t instanceof WebAssembly.Instance ? {
instance: t,
module: e
} : t;
}
}(await n);
return e instanceof Promise && (e = t.instance.exports), e;
})();
return e = t;
}
let t = null;
async function r(e) {
t = await n(e);
}
function o(n) {
var r;
r = n, t = !e || e instanceof Promise ? (r instanceof WebAssembly.Module || (r = new WebAssembly.Module(r)), e = new WebAssembly.Instance(r, {}).exports, e) : e;
}
class s extends Error {
constructor(e){
super(e), this.name = "DecompressionError";
}
}
let i = 0, a = null, c = null;
function f(e, n, t) {
let r;
if (t) {
const o = n;
r = e.malloc_u8(o);
const s = new Uint8Array(e.memory.buffer, r, o);
try {
t(s);
} catch (n) {
throw e.free_u8(r, o), n;
}
return i = o, r;
}
if ("string" == typeof n) {
const t = i = function(e) {
let n = 0, t = 0, r = 0;
const o = e.length;
for(; n < o;)t = e.codePointAt(n), t <= 127 ? (r += 1, n++) : t <= 2047 ? (r += 2, n++) : t <= 65535 ? (r += 3, n++) : (r += 4, n += 2);
return r;
}(n);
r = e.malloc_u8(t);
const o = new Uint8Array(e.memory.buffer, r, t);
return a || (a = new TextEncoder), a.encodeInto(n, o), r;
}
const o = n;
return r = e.malloc_u8(i = o.length), c && c.length || (c = new Uint8Array(e.memory.buffer)), c.set(o, r), r;
}
const u = {
noCompression: 1,
fixedHuffmanCodes: 2,
multi: 1
};
function l(e, n, r = {}) {
w(t), !n || n instanceof Function || (r = n, n = void 0);
const o = b(r, u), s = f(t, e, n), a = t.gzip_compress(s, i, o) >>> 0;
t.free_u8(s, i);
const c = t.buffer() >>> 0;
return new Uint8Array(t.memory.buffer, c, a);
}
function m(e, n, r = {}) {
w(t), !n || n instanceof Function || (r = n, n = void 0);
const o = b(r, u), a = f(t, e, n), c = t.gzip_decompress(a, i, o) >>> 0;
if (t.free_u8(a, i), 4294967295 === c) {
const e = t.error_message(), n = t.error_message_len(), r = new Uint8Array(t.memory.buffer, e, n), o = (new TextDecoder).decode(r);
throw new s(o);
}
const l = t.buffer() >>> 0;
return new Uint8Array(t.memory.buffer, l, c);
}
function y() {
w(t), t.deallocate_buffer();
}
function w(e) {
if (!e) throw new Error("WASM not initialized");
}
function b(e, n) {
let t = 0;
for(const r in e)t |= +e[r] * n[r];
return t;
}
},{"ef0034b6e784b6d":"PytoC","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"PytoC":[function(require,module,exports) {
module.exports = require("eca0acbbf4ac5c50").getBundleURL("2E3Jw") + "wasm_gzip.922c2de1.wasm";
},{"eca0acbbf4ac5c50":"f17Mo"}],"85Wzk":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "AbsolutePosition", ()=>AbsolutePosition);
parcelHelpers.export(exports, "AbstractConnector", ()=>AbstractConnector);
parcelHelpers.export(exports, "AbstractStruct", ()=>AbstractStruct);
parcelHelpers.export(exports, "AbstractType", ()=>AbstractType);
parcelHelpers.export(exports, "Array", ()=>YArray);
parcelHelpers.export(exports, "ContentAny", ()=>ContentAny);
parcelHelpers.export(exports, "ContentBinary", ()=>ContentBinary);
parcelHelpers.export(exports, "ContentDeleted", ()=>ContentDeleted);
parcelHelpers.export(exports, "ContentDoc", ()=>ContentDoc);
parcelHelpers.export(exports, "ContentEmbed", ()=>ContentEmbed);
parcelHelpers.export(exports, "ContentFormat", ()=>ContentFormat);
parcelHelpers.export(exports, "ContentJSON", ()=>ContentJSON);
parcelHelpers.export(exports, "ContentString", ()=>ContentString);
parcelHelpers.export(exports, "ContentType", ()=>ContentType);
parcelHelpers.export(exports, "Doc", ()=>Doc);
parcelHelpers.export(exports, "GC", ()=>GC);
parcelHelpers.export(exports, "ID", ()=>ID);
parcelHelpers.export(exports, "Item", ()=>Item);
parcelHelpers.export(exports, "Map", ()=>YMap);
parcelHelpers.export(exports, "PermanentUserData", ()=>PermanentUserData);
parcelHelpers.export(exports, "RelativePosition", ()=>RelativePosition);
parcelHelpers.export(exports, "Skip", ()=>Skip);
parcelHelpers.export(exports, "Snapshot", ()=>Snapshot);
parcelHelpers.export(exports, "Text", ()=>YText);
parcelHelpers.export(exports, "Transaction", ()=>Transaction);
parcelHelpers.export(exports, "UndoManager", ()=>UndoManager);
parcelHelpers.export(exports, "UpdateDecoderV1", ()=>UpdateDecoderV1);
parcelHelpers.export(exports, "UpdateDecoderV2", ()=>UpdateDecoderV2);
parcelHelpers.export(exports, "UpdateEncoderV1", ()=>UpdateEncoderV1);
parcelHelpers.export(exports, "UpdateEncoderV2", ()=>UpdateEncoderV2);
parcelHelpers.export(exports, "XmlElement", ()=>YXmlElement);
parcelHelpers.export(exports, "XmlFragment", ()=>YXmlFragment);
parcelHelpers.export(exports, "XmlHook", ()=>YXmlHook);
parcelHelpers.export(exports, "XmlText", ()=>YXmlText);
parcelHelpers.export(exports, "YArrayEvent", ()=>YArrayEvent);
parcelHelpers.export(exports, "YEvent", ()=>YEvent);
parcelHelpers.export(exports, "YMapEvent", ()=>YMapEvent);
parcelHelpers.export(exports, "YTextEvent", ()=>YTextEvent);
parcelHelpers.export(exports, "YXmlEvent", ()=>YXmlEvent);
parcelHelpers.export(exports, "applyUpdate", ()=>applyUpdate);
parcelHelpers.export(exports, "applyUpdateV2", ()=>applyUpdateV2);
parcelHelpers.export(exports, "cleanupYTextFormatting", ()=>cleanupYTextFormatting);
parcelHelpers.export(exports, "compareIDs", ()=>compareIDs);
parcelHelpers.export(exports, "compareRelativePositions", ()=>compareRelativePositions);
parcelHelpers.export(exports, "convertUpdateFormatV1ToV2", ()=>convertUpdateFormatV1ToV2);
parcelHelpers.export(exports, "convertUpdateFormatV2ToV1", ()=>convertUpdateFormatV2ToV1);
parcelHelpers.export(exports, "createAbsolutePositionFromRelativePosition", ()=>createAbsolutePositionFromRelativePosition);
parcelHelpers.export(exports, "createDeleteSet", ()=>createDeleteSet);
parcelHelpers.export(exports, "createDeleteSetFromStructStore", ()=>createDeleteSetFromStructStore);
parcelHelpers.export(exports, "createDocFromSnapshot", ()=>createDocFromSnapshot);
parcelHelpers.export(exports, "createID", ()=>createID);
parcelHelpers.export(exports, "createRelativePositionFromJSON", ()=>createRelativePositionFromJSON);
parcelHelpers.export(exports, "createRelativePositionFromTypeIndex", ()=>createRelativePositionFromTypeIndex);
parcelHelpers.export(exports, "createSnapshot", ()=>createSnapshot);
parcelHelpers.export(exports, "decodeRelativePosition", ()=>decodeRelativePosition);
parcelHelpers.export(exports, "decodeSnapshot", ()=>decodeSnapshot);
parcelHelpers.export(exports, "decodeSnapshotV2", ()=>decodeSnapshotV2);
parcelHelpers.export(exports, "decodeStateVector", ()=>decodeStateVector);
parcelHelpers.export(exports, "decodeUpdate", ()=>decodeUpdate);
parcelHelpers.export(exports, "decodeUpdateV2", ()=>decodeUpdateV2);
parcelHelpers.export(exports, "diffUpdate", ()=>diffUpdate);
parcelHelpers.export(exports, "diffUpdateV2", ()=>diffUpdateV2);
parcelHelpers.export(exports, "emptySnapshot", ()=>emptySnapshot);
parcelHelpers.export(exports, "encodeRelativePosition", ()=>encodeRelativePosition);
parcelHelpers.export(exports, "encodeSnapshot", ()=>encodeSnapshot);
parcelHelpers.export(exports, "encodeSnapshotV2", ()=>encodeSnapshotV2);
parcelHelpers.export(exports, "encodeStateAsUpdate", ()=>encodeStateAsUpdate);
parcelHelpers.export(exports, "encodeStateAsUpdateV2", ()=>encodeStateAsUpdateV2);
parcelHelpers.export(exports, "encodeStateVector", ()=>encodeStateVector);
parcelHelpers.export(exports, "encodeStateVectorFromUpdate", ()=>encodeStateVectorFromUpdate);
parcelHelpers.export(exports, "encodeStateVectorFromUpdateV2", ()=>encodeStateVectorFromUpdateV2);
parcelHelpers.export(exports, "equalDeleteSets", ()=>equalDeleteSets);
parcelHelpers.export(exports, "equalSnapshots", ()=>equalSnapshots);
parcelHelpers.export(exports, "findIndexSS", ()=>findIndexSS);
parcelHelpers.export(exports, "findRootTypeKey", ()=>findRootTypeKey);
parcelHelpers.export(exports, "getItem", ()=>getItem);
parcelHelpers.export(exports, "getState", ()=>getState);
parcelHelpers.export(exports, "getTypeChildren", ()=>getTypeChildren);
parcelHelpers.export(exports, "isDeleted", ()=>isDeleted);
parcelHelpers.export(exports, "isParentOf", ()=>isParentOf);
parcelHelpers.export(exports, "iterateDeletedStructs", ()=>iterateDeletedStructs);
parcelHelpers.export(exports, "logType", ()=>logType);
parcelHelpers.export(exports, "logUpdate", ()=>logUpdate);
parcelHelpers.export(exports, "logUpdateV2", ()=>logUpdateV2);
parcelHelpers.export(exports, "mergeDeleteSets", ()=>mergeDeleteSets);
parcelHelpers.export(exports, "mergeUpdates", ()=>mergeUpdates);
parcelHelpers.export(exports, "mergeUpdatesV2", ()=>mergeUpdatesV2);
parcelHelpers.export(exports, "obfuscateUpdate", ()=>obfuscateUpdate);
parcelHelpers.export(exports, "obfuscateUpdateV2", ()=>obfuscateUpdateV2);
parcelHelpers.export(exports, "parseUpdateMeta", ()=>parseUpdateMeta);
parcelHelpers.export(exports, "parseUpdateMetaV2", ()=>parseUpdateMetaV2);
parcelHelpers.export(exports, "readUpdate", ()=>readUpdate);
parcelHelpers.export(exports, "readUpdateV2", ()=>readUpdateV2);
parcelHelpers.export(exports, "relativePositionToJSON", ()=>relativePositionToJSON);
parcelHelpers.export(exports, "snapshot", ()=>snapshot);
parcelHelpers.export(exports, "snapshotContainsUpdate", ()=>snapshotContainsUpdate);
parcelHelpers.export(exports, "transact", ()=>transact);
parcelHelpers.export(exports, "tryGc", ()=>tryGc);
parcelHelpers.export(exports, "typeListToArraySnapshot", ()=>typeListToArraySnapshot);
parcelHelpers.export(exports, "typeMapGetAllSnapshot", ()=>typeMapGetAllSnapshot);
parcelHelpers.export(exports, "typeMapGetSnapshot", ()=>typeMapGetSnapshot);
var _observable = require("lib0/observable");
var _array = require("lib0/array");
var _math = require("lib0/math");
var _map = require("lib0/map");
var _encoding = require("lib0/encoding");
var _decoding = require("lib0/decoding");
var _random = require("lib0/random");
var _promise = require("lib0/promise");
var _buffer = require("lib0/buffer");
var _error = require("lib0/error");
var _binary = require("lib0/binary");
var _function = require("lib0/function");
var _set = require("lib0/set");
var _logging = require("lib0/logging");
var _time = require("lib0/time");
var _string = require("lib0/string");
var _iterator = require("lib0/iterator");
var _object = require("lib0/object");
var global = arguments[3];
/**
* This is an abstract interface that all Connectors should implement to keep them interchangeable.
*
* @note This interface is experimental and it is not advised to actually inherit this class.
* It just serves as typing information.
*
* @extends {ObservableV2<any>}
*/ class AbstractConnector extends (0, _observable.ObservableV2) {
/**
* @param {Doc} ydoc
* @param {any} awareness
*/ constructor(ydoc, awareness){
super();
this.doc = ydoc;
this.awareness = awareness;
}
}
class DeleteItem {
/**
* @param {number} clock
* @param {number} len
*/ constructor(clock, len){
/**
* @type {number}
*/ this.clock = clock;
/**
* @type {number}
*/ this.len = len;
}
}
/**
* We no longer maintain a DeleteStore. DeleteSet is a temporary object that is created when needed.
* - When created in a transaction, it must only be accessed after sorting, and merging
* - This DeleteSet is send to other clients
* - We do not create a DeleteSet when we send a sync message. The DeleteSet message is created directly from StructStore
* - We read a DeleteSet as part of a sync/update message. In this case the DeleteSet is already sorted and merged.
*/ class DeleteSet {
constructor(){
/**
* @type {Map<number,Array<DeleteItem>>}
*/ this.clients = new Map();
}
}
/**
* Iterate over all structs that the DeleteSet gc's.
*
* @param {Transaction} transaction
* @param {DeleteSet} ds
* @param {function(GC|Item):void} f
*
* @function
*/ const iterateDeletedStructs = (transaction, ds, f)=>ds.clients.forEach((deletes, clientid)=>{
const structs = /** @type {Array<GC|Item>} */ transaction.doc.store.clients.get(clientid);
for(let i = 0; i < deletes.length; i++){
const del = deletes[i];
iterateStructs(transaction, structs, del.clock, del.len, f);
}
});
/**
* @param {Array<DeleteItem>} dis
* @param {number} clock
* @return {number|null}
*
* @private
* @function
*/ const findIndexDS = (dis, clock)=>{
let left = 0;
let right = dis.length - 1;
while(left <= right){
const midindex = _math.floor((left + right) / 2);
const mid = dis[midindex];
const midclock = mid.clock;
if (midclock <= clock) {
if (clock < midclock + mid.len) return midindex;
left = midindex + 1;
} else right = midindex - 1;
}
return null;
};
/**
* @param {DeleteSet} ds
* @param {ID} id
* @return {boolean}
*
* @private
* @function
*/ const isDeleted = (ds, id)=>{
const dis = ds.clients.get(id.client);
return dis !== undefined && findIndexDS(dis, id.clock) !== null;
};
/**
* @param {DeleteSet} ds
*
* @private
* @function
*/ const sortAndMergeDeleteSet = (ds)=>{
ds.clients.forEach((dels)=>{
dels.sort((a, b)=>a.clock - b.clock);
// merge items without filtering or splicing the array
// i is the current pointer
// j refers to the current insert position for the pointed item
// try to merge dels[i] into dels[j-1] or set dels[j]=dels[i]
let i, j;
for(i = 1, j = 1; i < dels.length; i++){
const left = dels[j - 1];
const right = dels[i];
if (left.clock + left.len >= right.clock) left.len = _math.max(left.len, right.clock + right.len - left.clock);
else {
if (j < i) dels[j] = right;
j++;
}
}
dels.length = j;
});
};
/**
* @param {Array<DeleteSet>} dss
* @return {DeleteSet} A fresh DeleteSet
*/ const mergeDeleteSets = (dss)=>{
const merged = new DeleteSet();
for(let dssI = 0; dssI < dss.length; dssI++)dss[dssI].clients.forEach((delsLeft, client)=>{
if (!merged.clients.has(client)) {
// Write all missing keys from current ds and all following.
// If merged already contains `client` current ds has already been added.
/**
* @type {Array<DeleteItem>}
*/ const dels = delsLeft.slice();
for(let i = dssI + 1; i < dss.length; i++)_array.appendTo(dels, dss[i].clients.get(client) || []);
merged.clients.set(client, dels);
}
});
sortAndMergeDeleteSet(merged);
return merged;
};
/**
* @param {DeleteSet} ds
* @param {number} client
* @param {number} clock
* @param {number} length
*
* @private
* @function
*/ const addToDeleteSet = (ds, client, clock, length)=>{
_map.setIfUndefined(ds.clients, client, ()=>/** @type {Array<DeleteItem>} */ []).push(new DeleteItem(clock, length));
};
const createDeleteSet = ()=>new DeleteSet();
/**
* @param {StructStore} ss
* @return {DeleteSet} Merged and sorted DeleteSet
*
* @private
* @function
*/ const createDeleteSetFromStructStore = (ss)=>{
const ds = createDeleteSet();
ss.clients.forEach((structs, client)=>{
/**
* @type {Array<DeleteItem>}
*/ const dsitems = [];
for(let i = 0; i < structs.length; i++){
const struct = structs[i];
if (struct.deleted) {
const clock = struct.id.clock;
let len = struct.length;
if (i + 1 < structs.length) for(let next = structs[i + 1]; i + 1 < structs.length && next.deleted; next = structs[++i + 1])len += next.length;
dsitems.push(new DeleteItem(clock, len));
}
}
if (dsitems.length > 0) ds.clients.set(client, dsitems);
});
return ds;
};
/**
* @param {DSEncoderV1 | DSEncoderV2} encoder
* @param {DeleteSet} ds
*
* @private
* @function
*/ const writeDeleteSet = (encoder, ds)=>{
_encoding.writeVarUint(encoder.restEncoder, ds.clients.size);
// Ensure that the delete set is written in a deterministic order
_array.from(ds.clients.entries()).sort((a, b)=>b[0] - a[0]).forEach(([client, dsitems])=>{
encoder.resetDsCurVal();
_encoding.writeVarUint(encoder.restEncoder, client);
const len = dsitems.length;
_encoding.writeVarUint(encoder.restEncoder, len);
for(let i = 0; i < len; i++){
const item = dsitems[i];
encoder.writeDsClock(item.clock);
encoder.writeDsLen(item.len);
}
});
};
/**
* @param {DSDecoderV1 | DSDecoderV2} decoder
* @return {DeleteSet}
*
* @private
* @function
*/ const readDeleteSet = (decoder)=>{
const ds = new DeleteSet();
const numClients = _decoding.readVarUint(decoder.restDecoder);
for(let i = 0; i < numClients; i++){
decoder.resetDsCurVal();
const client = _decoding.readVarUint(decoder.restDecoder);
const numberOfDeletes = _decoding.readVarUint(decoder.restDecoder);
if (numberOfDeletes > 0) {
const dsField = _map.setIfUndefined(ds.clients, client, ()=>/** @type {Array<DeleteItem>} */ []);
for(let i = 0; i < numberOfDeletes; i++)dsField.push(new DeleteItem(decoder.readDsClock(), decoder.readDsLen()));
}
}
return ds;
};
/**
* @todo YDecoder also contains references to String and other Decoders. Would make sense to exchange YDecoder.toUint8Array for YDecoder.DsToUint8Array()..
*/ /**
* @param {DSDecoderV1 | DSDecoderV2} decoder
* @param {Transaction} transaction
* @param {StructStore} store
* @return {Uint8Array|null} Returns a v2 update containing all deletes that couldn't be applied yet; or null if all deletes were applied successfully.
*
* @private
* @function
*/ const readAndApplyDeleteSet = (decoder, transaction, store)=>{
const unappliedDS = new DeleteSet();
const numClients = _decoding.readVarUint(decoder.restDecoder);
for(let i = 0; i < numClients; i++){
decoder.resetDsCurVal();
const client = _decoding.readVarUint(decoder.restDecoder);
const numberOfDeletes = _decoding.readVarUint(decoder.restDecoder);
const structs = store.clients.get(client) || [];
const state = getState(store, client);
for(let i = 0; i < numberOfDeletes; i++){
const clock = decoder.readDsClock();
const clockEnd = clock + decoder.readDsLen();
if (clock < state) {
if (state < clockEnd) addToDeleteSet(unappliedDS, client, state, clockEnd - state);
let index = findIndexSS(structs, clock);
/**
* We can ignore the case of GC and Delete structs, because we are going to skip them
* @type {Item}
*/ // @ts-ignore
let struct = structs[index];
// split the first item if necessary
if (!struct.deleted && struct.id.clock < clock) {
structs.splice(index + 1, 0, splitItem(transaction, struct, clock - struct.id.clock));
index++; // increase we now want to use the next struct
}
while(index < structs.length){
// @ts-ignore
struct = structs[index++];
if (struct.id.clock < clockEnd) {
if (!struct.deleted) {
if (clockEnd < struct.id.clock + struct.length) structs.splice(index, 0, splitItem(transaction, struct, clockEnd - struct.id.clock));
struct.delete(transaction);
}
} else break;
}
} else addToDeleteSet(unappliedDS, client, clock, clockEnd - clock);
}
}
if (unappliedDS.clients.size > 0) {
const ds = new UpdateEncoderV2();
_encoding.writeVarUint(ds.restEncoder, 0); // encode 0 structs
writeDeleteSet(ds, unappliedDS);
return ds.toUint8Array();
}
return null;
};
/**
* @param {DeleteSet} ds1
* @param {DeleteSet} ds2
*/ const equalDeleteSets = (ds1, ds2)=>{
if (ds1.clients.size !== ds2.clients.size) return false;
for (const [client, deleteItems1] of ds1.clients.entries()){
const deleteItems2 = /** @type {Array<import('../internals.js').DeleteItem>} */ ds2.clients.get(client);
if (deleteItems2 === undefined || deleteItems1.length !== deleteItems2.length) return false;
for(let i = 0; i < deleteItems1.length; i++){
const di1 = deleteItems1[i];
const di2 = deleteItems2[i];
if (di1.clock !== di2.clock || di1.len !== di2.len) return false;
}
}
return true;
};
/**
* @module Y
*/ const generateNewClientId = _random.uint32;
/**
* @typedef {Object} DocOpts
* @property {boolean} [DocOpts.gc=true] Disable garbage collection (default: gc=true)
* @property {function(Item):boolean} [DocOpts.gcFilter] Will be called before an Item is garbage collected. Return false to keep the Item.
* @property {string} [DocOpts.guid] Define a globally unique identifier for this document
* @property {string | null} [DocOpts.collectionid] Associate this document with a collection. This only plays a role if your provider has a concept of collection.
* @property {any} [DocOpts.meta] Any kind of meta information you want to associate with this document. If this is a subdocument, remote peers will store the meta information as well.
* @property {boolean} [DocOpts.autoLoad] If a subdocument, automatically load document. If this is a subdocument, remote peers will load the document as well automatically.
* @property {boolean} [DocOpts.shouldLoad] Whether the document should be synced by the provider now. This is toggled to true when you call ydoc.load()
*/ /**
* @typedef {Object} DocEvents
* @property {function(Doc):void} DocEvents.destroy
* @property {function(Doc):void} DocEvents.load
* @property {function(boolean, Doc):void} DocEvents.sync
* @property {function(Uint8Array, any, Doc, Transaction):void} DocEvents.update
* @property {function(Uint8Array, any, Doc, Transaction):void} DocEvents.updateV2
* @property {function(Doc):void} DocEvents.beforeAllTransactions
* @property {function(Transaction, Doc):void} DocEvents.beforeTransaction
* @property {function(Transaction, Doc):void} DocEvents.beforeObserverCalls
* @property {function(Transaction, Doc):void} DocEvents.afterTransaction
* @property {function(Transaction, Doc):void} DocEvents.afterTransactionCleanup
* @property {function(Doc, Array<Transaction>):void} DocEvents.afterAllTransactions
* @property {function({ loaded: Set<Doc>, added: Set<Doc>, removed: Set<Doc> }, Doc, Transaction):void} DocEvents.subdocs
*/ /**
* A Yjs instance handles the state of shared data.
* @extends ObservableV2<DocEvents>
*/ class Doc extends (0, _observable.ObservableV2) {
/**
* @param {DocOpts} opts configuration
*/ constructor({ guid = _random.uuidv4(), collectionid = null, gc = true, gcFilter = ()=>true, meta = null, autoLoad = false, shouldLoad = true } = {}){
super();
this.gc = gc;
this.gcFilter = gcFilter;
this.clientID = generateNewClientId();
this.guid = guid;
this.collectionid = collectionid;
/**
* @type {Map<string, AbstractType<YEvent<any>>>}
*/ this.share = new Map();
this.store = new StructStore();
/**
* @type {Transaction | null}
*/ this._transaction = null;
/**
* @type {Array<Transaction>}
*/ this._transactionCleanups = [];
/**
* @type {Set<Doc>}
*/ this.subdocs = new Set();
/**
* If this document is a subdocument - a document integrated into another document - then _item is defined.
* @type {Item?}
*/ this._item = null;
this.shouldLoad = shouldLoad;
this.autoLoad = autoLoad;
this.meta = meta;
/**
* This is set to true when the persistence provider loaded the document from the database or when the `sync` event fires.
* Note that not all providers implement this feature. Provider authors are encouraged to fire the `load` event when the doc content is loaded from the database.
*
* @type {boolean}
*/ this.isLoaded = false;
/**
* This is set to true when the connection provider has successfully synced with a backend.
* Note that when using peer-to-peer providers this event may not provide very useful.
* Also note that not all providers implement this feature. Provider authors are encouraged to fire
* the `sync` event when the doc has been synced (with `true` as a parameter) or if connection is
* lost (with false as a parameter).
*/ this.isSynced = false;
/**
* Promise that resolves once the document has been loaded from a presistence provider.
*/ this.whenLoaded = _promise.create((resolve)=>{
this.on("load", ()=>{
this.isLoaded = true;
resolve(this);
});
});
const provideSyncedPromise = ()=>_promise.create((resolve)=>{
/**
* @param {boolean} isSynced
*/ const eventHandler = (isSynced)=>{
if (isSynced === undefined || isSynced === true) {
this.off("sync", eventHandler);
resolve();
}
};
this.on("sync", eventHandler);
});
this.on("sync", (isSynced)=>{
if (isSynced === false && this.isSynced) this.whenSynced = provideSyncedPromise();
this.isSynced = isSynced === undefined || isSynced === true;
if (this.isSynced && !this.isLoaded) this.emit("load", [
this
]);
});
/**
* Promise that resolves once the document has been synced with a backend.
* This promise is recreated when the connection is lost.
* Note the documentation about the `isSynced` property.
*/ this.whenSynced = provideSyncedPromise();
}
/**
* Notify the parent document that you request to load data into this subdocument (if it is a subdocument).
*
* `load()` might be used in the future to request any provider to load the most current data.
*
* It is safe to call `load()` multiple times.
*/ load() {
const item = this._item;
if (item !== null && !this.shouldLoad) transact(/** @type {any} */ item.parent.doc, (transaction)=>{
transaction.subdocsLoaded.add(this);
}, null, true);
this.shouldLoad = true;
}
getSubdocs() {
return this.subdocs;
}
getSubdocGuids() {
return new Set(_array.from(this.subdocs).map((doc)=>doc.guid));
}
/**
* Changes that happen inside of a transaction are bundled. This means that
* the observer fires _after_ the transaction is finished and that all changes
* that happened inside of the transaction are sent as one message to the
* other peers.
*
* @template T
* @param {function(Transaction):T} f The function that should be executed as a transaction
* @param {any} [origin] Origin of who started the transaction. Will be stored on transaction.origin
* @return T
*
* @public
*/ transact(f, origin = null) {
return transact(this, f, origin);
}
/**
* Define a shared data type.
*
* Multiple calls of `ydoc.get(name, TypeConstructor)` yield the same result
* and do not overwrite each other. I.e.
* `ydoc.get(name, Y.Array) === ydoc.get(name, Y.Array)`
*
* After this method is called, the type is also available on `ydoc.share.get(name)`.
*
* *Best Practices:*
* Define all types right after the Y.Doc instance is created and store them in a separate object.
* Also use the typed methods `getText(name)`, `getArray(name)`, ..
*
* @template {typeof AbstractType<any>} Type
* @example
* const ydoc = new Y.Doc(..)
* const appState = {
* document: ydoc.getText('document')
* comments: ydoc.getArray('comments')
* }
*
* @param {string} name
* @param {Type} TypeConstructor The constructor of the type definition. E.g. Y.Text, Y.Array, Y.Map, ...
* @return {InstanceType<Type>} The created type. Constructed with TypeConstructor
*
* @public
*/ get(name, TypeConstructor = /** @type {any} */ AbstractType) {
const type = _map.setIfUndefined(this.share, name, ()=>{
// @ts-ignore
const t = new TypeConstructor();
t._integrate(this, null);
return t;
});
const Constr = type.constructor;
if (TypeConstructor !== AbstractType && Constr !== TypeConstructor) {
if (Constr === AbstractType) {
// @ts-ignore
const t = new TypeConstructor();
t._map = type._map;
type._map.forEach(/** @param {Item?} n */ (n)=>{
for(; n !== null; n = n.left)// @ts-ignore
n.parent = t;
});
t._start = type._start;
for(let n = t._start; n !== null; n = n.right)n.parent = t;
t._length = type._length;
this.share.set(name, t);
t._integrate(this, null);
return /** @type {InstanceType<Type>} */ t;
} else throw new Error(`Type with the name ${name} has already been defined with a different constructor`);
}
return /** @type {InstanceType<Type>} */ type;
}
/**
* @template T
* @param {string} [name]
* @return {YArray<T>}
*
* @public
*/ getArray(name = "") {
return /** @type {YArray<T>} */ this.get(name, YArray);
}
/**
* @param {string} [name]
* @return {YText}
*
* @public
*/ getText(name = "") {
return this.get(name, YText);
}
/**
* @template T
* @param {string} [name]
* @return {YMap<T>}
*
* @public
*/ getMap(name = "") {
return /** @type {YMap<T>} */ this.get(name, YMap);
}
/**
* @param {string} [name]
* @return {YXmlElement}
*
* @public
*/ getXmlElement(name = "") {
return /** @type {YXmlElement<{[key:string]:string}>} */ this.get(name, YXmlElement);
}
/**
* @param {string} [name]
* @return {YXmlFragment}
*
* @public
*/ getXmlFragment(name = "") {
return this.get(name, YXmlFragment);
}
/**
* Converts the entire document into a js object, recursively traversing each yjs type
* Doesn't log types that have not been defined (using ydoc.getType(..)).
*
* @deprecated Do not use this method and rather call toJSON directly on the shared types.
*
* @return {Object<string, any>}
*/ toJSON() {
/**
* @type {Object<string, any>}
*/ const doc = {};
this.share.forEach((value, key)=>{
doc[key] = value.toJSON();
});
return doc;
}
/**
* Emit `destroy` event and unregister all event handlers.
*/ destroy() {
_array.from(this.subdocs).forEach((subdoc)=>subdoc.destroy());
const item = this._item;
if (item !== null) {
this._item = null;
const content = /** @type {ContentDoc} */ item.content;
content.doc = new Doc({
guid: this.guid,
...content.opts,
shouldLoad: false
});
content.doc._item = item;
transact(/** @type {any} */ item.parent.doc, (transaction)=>{
const doc = content.doc;
if (!item.deleted) transaction.subdocsAdded.add(doc);
transaction.subdocsRemoved.add(this);
}, null, true);
}
// @ts-ignore
this.emit("destroyed", [
true
]); // DEPRECATED!
this.emit("destroy", [
this
]);
super.destroy();
}
}
class DSDecoderV1 {
/**
* @param {decoding.Decoder} decoder
*/ constructor(decoder){
this.restDecoder = decoder;
}
resetDsCurVal() {
// nop
}
/**
* @return {number}
*/ readDsClock() {
return _decoding.readVarUint(this.restDecoder);
}
/**
* @return {number}
*/ readDsLen() {
return _decoding.readVarUint(this.restDecoder);
}
}
class UpdateDecoderV1 extends DSDecoderV1 {
/**
* @return {ID}
*/ readLeftID() {
return createID(_decoding.readVarUint(this.restDecoder), _decoding.readVarUint(this.restDecoder));
}
/**
* @return {ID}
*/ readRightID() {
return createID(_decoding.readVarUint(this.restDecoder), _decoding.readVarUint(this.restDecoder));
}
/**
* Read the next client id.
* Use this in favor of readID whenever possible to reduce the number of objects created.
*/ readClient() {
return _decoding.readVarUint(this.restDecoder);
}
/**
* @return {number} info An unsigned 8-bit integer
*/ readInfo() {
return _decoding.readUint8(this.restDecoder);
}
/**
* @return {string}
*/ readString() {
return _decoding.readVarString(this.restDecoder);
}
/**
* @return {boolean} isKey
*/ readParentInfo() {
return _decoding.readVarUint(this.restDecoder) === 1;
}
/**
* @return {number} info An unsigned 8-bit integer
*/ readTypeRef() {
return _decoding.readVarUint(this.restDecoder);
}
/**
* Write len of a struct - well suited for Opt RLE encoder.
*
* @return {number} len
*/ readLen() {
return _decoding.readVarUint(this.restDecoder);
}
/**
* @return {any}
*/ readAny() {
return _decoding.readAny(this.restDecoder);
}
/**
* @return {Uint8Array}
*/ readBuf() {
return _buffer.copyUint8Array(_decoding.readVarUint8Array(this.restDecoder));
}
/**
* Legacy implementation uses JSON parse. We use any-decoding in v2.
*
* @return {any}
*/ readJSON() {
return JSON.parse(_decoding.readVarString(this.restDecoder));
}
/**
* @return {string}
*/ readKey() {
return _decoding.readVarString(this.restDecoder);
}
}
class DSDecoderV2 {
/**
* @param {decoding.Decoder} decoder
*/ constructor(decoder){
/**
* @private
*/ this.dsCurrVal = 0;
this.restDecoder = decoder;
}
resetDsCurVal() {
this.dsCurrVal = 0;
}
/**
* @return {number}
*/ readDsClock() {
this.dsCurrVal += _decoding.readVarUint(this.restDecoder);
return this.dsCurrVal;
}
/**
* @return {number}
*/ readDsLen() {
const diff = _decoding.readVarUint(this.restDecoder) + 1;
this.dsCurrVal += diff;
return diff;
}
}
class UpdateDecoderV2 extends DSDecoderV2 {
/**
* @param {decoding.Decoder} decoder
*/ constructor(decoder){
super(decoder);
/**
* List of cached keys. If the keys[id] does not exist, we read a new key
* from stringEncoder and push it to keys.
*
* @type {Array<string>}
*/ this.keys = [];
_decoding.readVarUint(decoder); // read feature flag - currently unused
this.keyClockDecoder = new _decoding.IntDiffOptRleDecoder(_decoding.readVarUint8Array(decoder));
this.clientDecoder = new _decoding.UintOptRleDecoder(_decoding.readVarUint8Array(decoder));
this.leftClockDecoder = new _decoding.IntDiffOptRleDecoder(_decoding.readVarUint8Array(decoder));
this.rightClockDecoder = new _decoding.IntDiffOptRleDecoder(_decoding.readVarUint8Array(decoder));
this.infoDecoder = new _decoding.RleDecoder(_decoding.readVarUint8Array(decoder), _decoding.readUint8);
this.stringDecoder = new _decoding.StringDecoder(_decoding.readVarUint8Array(decoder));
this.parentInfoDecoder = new _decoding.RleDecoder(_decoding.readVarUint8Array(decoder), _decoding.readUint8);
this.typeRefDecoder = new _decoding.UintOptRleDecoder(_decoding.readVarUint8Array(decoder));
this.lenDecoder = new _decoding.UintOptRleDecoder(_decoding.readVarUint8Array(decoder));
}
/**
* @return {ID}
*/ readLeftID() {
return new ID(this.clientDecoder.read(), this.leftClockDecoder.read());
}
/**
* @return {ID}
*/ readRightID() {
return new ID(this.clientDecoder.read(), this.rightClockDecoder.read());
}
/**
* Read the next client id.
* Use this in favor of readID whenever possible to reduce the number of objects created.
*/ readClient() {
return this.clientDecoder.read();
}
/**
* @return {number} info An unsigned 8-bit integer
*/ readInfo() {
return /** @type {number} */ this.infoDecoder.read();
}
/**
* @return {string}
*/ readString() {
return this.stringDecoder.read();
}
/**
* @return {boolean}
*/ readParentInfo() {
return this.parentInfoDecoder.read() === 1;
}
/**
* @return {number} An unsigned 8-bit integer
*/ readTypeRef() {
return this.typeRefDecoder.read();
}
/**
* Write len of a struct - well suited for Opt RLE encoder.
*
* @return {number}
*/ readLen() {
return this.lenDecoder.read();
}
/**
* @return {any}
*/ readAny() {
return _decoding.readAny(this.restDecoder);
}
/**
* @return {Uint8Array}
*/ readBuf() {
return _decoding.readVarUint8Array(this.restDecoder);
}
/**
* This is mainly here for legacy purposes.
*
* Initial we incoded objects using JSON. Now we use the much faster lib0/any-encoder. This method mainly exists for legacy purposes for the v1 encoder.
*
* @return {any}
*/ readJSON() {
return _decoding.readAny(this.restDecoder);
}
/**
* @return {string}
*/ readKey() {
const keyClock = this.keyClockDecoder.read();
if (keyClock < this.keys.length) return this.keys[keyClock];
else {
const key = this.stringDecoder.read();
this.keys.push(key);
return key;
}
}
}
class DSEncoderV1 {
constructor(){
this.restEncoder = _encoding.createEncoder();
}
toUint8Array() {
return _encoding.toUint8Array(this.restEncoder);
}
resetDsCurVal() {
// nop
}
/**
* @param {number} clock
*/ writeDsClock(clock) {
_encoding.writeVarUint(this.restEncoder, clock);
}
/**
* @param {number} len
*/ writeDsLen(len) {
_encoding.writeVarUint(this.restEncoder, len);
}
}
class UpdateEncoderV1 extends DSEncoderV1 {
/**
* @param {ID} id
*/ writeLeftID(id) {
_encoding.writeVarUint(this.restEncoder, id.client);
_encoding.writeVarUint(this.restEncoder, id.clock);
}
/**
* @param {ID} id
*/ writeRightID(id) {
_encoding.writeVarUint(this.restEncoder, id.client);
_encoding.writeVarUint(this.restEncoder, id.clock);
}
/**
* Use writeClient and writeClock instead of writeID if possible.
* @param {number} client
*/ writeClient(client) {
_encoding.writeVarUint(this.restEncoder, client);
}
/**
* @param {number} info An unsigned 8-bit integer
*/ writeInfo(info) {
_encoding.writeUint8(this.restEncoder, info);
}
/**
* @param {string} s
*/ writeString(s) {
_encoding.writeVarString(this.restEncoder, s);
}
/**
* @param {boolean} isYKey
*/ writeParentInfo(isYKey) {
_encoding.writeVarUint(this.restEncoder, isYKey ? 1 : 0);
}
/**
* @param {number} info An unsigned 8-bit integer
*/ writeTypeRef(info) {
_encoding.writeVarUint(this.restEncoder, info);
}
/**
* Write len of a struct - well suited for Opt RLE encoder.
*
* @param {number} len
*/ writeLen(len) {
_encoding.writeVarUint(this.restEncoder, len);
}
/**
* @param {any} any
*/ writeAny(any) {
_encoding.writeAny(this.restEncoder, any);
}
/**
* @param {Uint8Array} buf
*/ writeBuf(buf) {
_encoding.writeVarUint8Array(this.restEncoder, buf);
}
/**
* @param {any} embed
*/ writeJSON(embed) {
_encoding.writeVarString(this.restEncoder, JSON.stringify(embed));
}
/**
* @param {string} key
*/ writeKey(key) {
_encoding.writeVarString(this.restEncoder, key);
}
}
class DSEncoderV2 {
constructor(){
this.restEncoder = _encoding.createEncoder(); // encodes all the rest / non-optimized
this.dsCurrVal = 0;
}
toUint8Array() {
return _encoding.toUint8Array(this.restEncoder);
}
resetDsCurVal() {
this.dsCurrVal = 0;
}
/**
* @param {number} clock
*/ writeDsClock(clock) {
const diff = clock - this.dsCurrVal;
this.dsCurrVal = clock;
_encoding.writeVarUint(this.restEncoder, diff);
}
/**
* @param {number} len
*/ writeDsLen(len) {
if (len === 0) _error.unexpectedCase();
_encoding.writeVarUint(this.restEncoder, len - 1);
this.dsCurrVal += len;
}
}
class UpdateEncoderV2 extends DSEncoderV2 {
constructor(){
super();
/**
* @type {Map<string,number>}
*/ this.keyMap = new Map();
/**
* Refers to the next uniqe key-identifier to me used.
* See writeKey method for more information.
*
* @type {number}
*/ this.keyClock = 0;
this.keyClockEncoder = new _encoding.IntDiffOptRleEncoder();
this.clientEncoder = new _encoding.UintOptRleEncoder();
this.leftClockEncoder = new _encoding.IntDiffOptRleEncoder();
this.rightClockEncoder = new _encoding.IntDiffOptRleEncoder();
this.infoEncoder = new _encoding.RleEncoder(_encoding.writeUint8);
this.stringEncoder = new _encoding.StringEncoder();
this.parentInfoEncoder = new _encoding.RleEncoder(_encoding.writeUint8);
this.typeRefEncoder = new _encoding.UintOptRleEncoder();
this.lenEncoder = new _encoding.UintOptRleEncoder();
}
toUint8Array() {
const encoder = _encoding.createEncoder();
_encoding.writeVarUint(encoder, 0); // this is a feature flag that we might use in the future
_encoding.writeVarUint8Array(encoder, this.keyClockEncoder.toUint8Array());
_encoding.writeVarUint8Array(encoder, this.clientEncoder.toUint8Array());
_encoding.writeVarUint8Array(encoder, this.leftClockEncoder.toUint8Array());
_encoding.writeVarUint8Array(encoder, this.rightClockEncoder.toUint8Array());
_encoding.writeVarUint8Array(encoder, _encoding.toUint8Array(this.infoEncoder));
_encoding.writeVarUint8Array(encoder, this.stringEncoder.toUint8Array());
_encoding.writeVarUint8Array(encoder, _encoding.toUint8Array(this.parentInfoEncoder));
_encoding.writeVarUint8Array(encoder, this.typeRefEncoder.toUint8Array());
_encoding.writeVarUint8Array(encoder, this.lenEncoder.toUint8Array());
// @note The rest encoder is appended! (note the missing var)
_encoding.writeUint8Array(encoder, _encoding.toUint8Array(this.restEncoder));
return _encoding.toUint8Array(encoder);
}
/**
* @param {ID} id
*/ writeLeftID(id) {
this.clientEncoder.write(id.client);
this.leftClockEncoder.write(id.clock);
}
/**
* @param {ID} id
*/ writeRightID(id) {
this.clientEncoder.write(id.client);
this.rightClockEncoder.write(id.clock);
}
/**
* @param {number} client
*/ writeClient(client) {
this.clientEncoder.write(client);
}
/**
* @param {number} info An unsigned 8-bit integer
*/ writeInfo(info) {
this.infoEncoder.write(info);
}
/**
* @param {string} s
*/ writeString(s) {
this.stringEncoder.write(s);
}
/**
* @param {boolean} isYKey
*/ writeParentInfo(isYKey) {
this.parentInfoEncoder.write(isYKey ? 1 : 0);
}
/**
* @param {number} info An unsigned 8-bit integer
*/ writeTypeRef(info) {
this.typeRefEncoder.write(info);
}
/**
* Write len of a struct - well suited for Opt RLE encoder.
*
* @param {number} len
*/ writeLen(len) {
this.lenEncoder.write(len);
}
/**
* @param {any} any
*/ writeAny(any) {
_encoding.writeAny(this.restEncoder, any);
}
/**
* @param {Uint8Array} buf
*/ writeBuf(buf) {
_encoding.writeVarUint8Array(this.restEncoder, buf);
}
/**
* This is mainly here for legacy purposes.
*
* Initial we incoded objects using JSON. Now we use the much faster lib0/any-encoder. This method mainly exists for legacy purposes for the v1 encoder.
*
* @param {any} embed
*/ writeJSON(embed) {
_encoding.writeAny(this.restEncoder, embed);
}
/**
* Property keys are often reused. For example, in y-prosemirror the key `bold` might
* occur very often. For a 3d application, the key `position` might occur very often.
*
* We cache these keys in a Map and refer to them via a unique number.
*
* @param {string} key
*/ writeKey(key) {
const clock = this.keyMap.get(key);
if (clock === undefined) {
/**
* @todo uncomment to introduce this feature finally
*
* Background. The ContentFormat object was always encoded using writeKey, but the decoder used to use readString.
* Furthermore, I forgot to set the keyclock. So everything was working fine.
*
* However, this feature here is basically useless as it is not being used (it actually only consumes extra memory).
*
* I don't know yet how to reintroduce this feature..
*
* Older clients won't be able to read updates when we reintroduce this feature. So this should probably be done using a flag.
*
*/ // this.keyMap.set(key, this.keyClock)
this.keyClockEncoder.write(this.keyClock++);
this.stringEncoder.write(key);
} else this.keyClockEncoder.write(clock);
}
}
/**
* @module encoding
*/ /*
* We use the first five bits in the info flag for determining the type of the struct.
*
* 0: GC
* 1: Item with Deleted content
* 2: Item with JSON content
* 3: Item with Binary content
* 4: Item with String content
* 5: Item with Embed content (for richtext content)
* 6: Item with Format content (a formatting marker for richtext content)
* 7: Item with Type
*/ /**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {Array<GC|Item>} structs All structs by `client`
* @param {number} client
* @param {number} clock write structs starting with `ID(client,clock)`
*
* @function
*/ const writeStructs = (encoder, structs, client, clock)=>{
// write first id
clock = _math.max(clock, structs[0].id.clock); // make sure the first id exists
const startNewStructs = findIndexSS(structs, clock);
// write # encoded structs
_encoding.writeVarUint(encoder.restEncoder, structs.length - startNewStructs);
encoder.writeClient(client);
_encoding.writeVarUint(encoder.restEncoder, clock);
const firstStruct = structs[startNewStructs];
// write first struct with an offset
firstStruct.write(encoder, clock - firstStruct.id.clock);
for(let i = startNewStructs + 1; i < structs.length; i++)structs[i].write(encoder, 0);
};
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {StructStore} store
* @param {Map<number,number>} _sm
*
* @private
* @function
*/ const writeClientsStructs = (encoder, store, _sm)=>{
// we filter all valid _sm entries into sm
const sm = new Map();
_sm.forEach((clock, client)=>{
// only write if new structs are available
if (getState(store, client) > clock) sm.set(client, clock);
});
getStateVector(store).forEach((_clock, client)=>{
if (!_sm.has(client)) sm.set(client, 0);
});
// write # states that were updated
_encoding.writeVarUint(encoder.restEncoder, sm.size);
// Write items with higher client ids first
// This heavily improves the conflict algorithm.
_array.from(sm.entries()).sort((a, b)=>b[0] - a[0]).forEach(([client, clock])=>{
writeStructs(encoder, /** @type {Array<GC|Item>} */ store.clients.get(client), client, clock);
});
};
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder The decoder object to read data from.
* @param {Doc} doc
* @return {Map<number, { i: number, refs: Array<Item | GC> }>}
*
* @private
* @function
*/ const readClientsStructRefs = (decoder, doc)=>{
/**
* @type {Map<number, { i: number, refs: Array<Item | GC> }>}
*/ const clientRefs = _map.create();
const numOfStateUpdates = _decoding.readVarUint(decoder.restDecoder);
for(let i = 0; i < numOfStateUpdates; i++){
const numberOfStructs = _decoding.readVarUint(decoder.restDecoder);
/**
* @type {Array<GC|Item>}
*/ const refs = new Array(numberOfStructs);
const client = decoder.readClient();
let clock = _decoding.readVarUint(decoder.restDecoder);
// const start = performance.now()
clientRefs.set(client, {
i: 0,
refs
});
for(let i = 0; i < numberOfStructs; i++){
const info = decoder.readInfo();
switch(_binary.BITS5 & info){
case 0:
{
const len = decoder.readLen();
refs[i] = new GC(createID(client, clock), len);
clock += len;
break;
}
case 10:
{
// @todo we could reduce the amount of checks by adding Skip struct to clientRefs so we know that something is missing.
const len = _decoding.readVarUint(decoder.restDecoder);
refs[i] = new Skip(createID(client, clock), len);
clock += len;
break;
}
default:
{
/**
* The optimized implementation doesn't use any variables because inlining variables is faster.
* Below a non-optimized version is shown that implements the basic algorithm with
* a few comments
*/ const cantCopyParentInfo = (info & (_binary.BIT7 | _binary.BIT8)) === 0;
// If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`
// and we read the next string as parentYKey.
// It indicates how we store/retrieve parent from `y.share`
// @type {string|null}
const struct = new Item(createID(client, clock), null, (info & _binary.BIT8) === _binary.BIT8 ? decoder.readLeftID() : null, null, (info & _binary.BIT7) === _binary.BIT7 ? decoder.readRightID() : null, cantCopyParentInfo ? decoder.readParentInfo() ? doc.get(decoder.readString()) : decoder.readLeftID() : null, cantCopyParentInfo && (info & _binary.BIT6) === _binary.BIT6 ? decoder.readString() : null, readItemContent(decoder, info) // item content
);
/* A non-optimized implementation of the above algorithm:
// The item that was originally to the left of this item.
const origin = (info & binary.BIT8) === binary.BIT8 ? decoder.readLeftID() : null
// The item that was originally to the right of this item.
const rightOrigin = (info & binary.BIT7) === binary.BIT7 ? decoder.readRightID() : null
const cantCopyParentInfo = (info & (binary.BIT7 | binary.BIT8)) === 0
const hasParentYKey = cantCopyParentInfo ? decoder.readParentInfo() : false
// If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`
// and we read the next string as parentYKey.
// It indicates how we store/retrieve parent from `y.share`
// @type {string|null}
const parentYKey = cantCopyParentInfo && hasParentYKey ? decoder.readString() : null
const struct = new Item(
createID(client, clock),
null, // left
origin, // origin
null, // right
rightOrigin, // right origin
cantCopyParentInfo && !hasParentYKey ? decoder.readLeftID() : (parentYKey !== null ? doc.get(parentYKey) : null), // parent
cantCopyParentInfo && (info & binary.BIT6) === binary.BIT6 ? decoder.readString() : null, // parentSub
readItemContent(decoder, info) // item content
)
*/ refs[i] = struct;
clock += struct.length;
}
}
}
// console.log('time to read: ', performance.now() - start) // @todo remove
}
return clientRefs;
};
/**
* Resume computing structs generated by struct readers.
*
* While there is something to do, we integrate structs in this order
* 1. top element on stack, if stack is not empty
* 2. next element from current struct reader (if empty, use next struct reader)
*
* If struct causally depends on another struct (ref.missing), we put next reader of
* `ref.id.client` on top of stack.
*
* At some point we find a struct that has no causal dependencies,
* then we start emptying the stack.
*
* It is not possible to have circles: i.e. struct1 (from client1) depends on struct2 (from client2)
* depends on struct3 (from client1). Therefore the max stack size is eqaul to `structReaders.length`.
*
* This method is implemented in a way so that we can resume computation if this update
* causally depends on another update.
*
* @param {Transaction} transaction
* @param {StructStore} store
* @param {Map<number, { i: number, refs: (GC | Item)[] }>} clientsStructRefs
* @return { null | { update: Uint8Array, missing: Map<number,number> } }
*
* @private
* @function
*/ const integrateStructs = (transaction, store, clientsStructRefs)=>{
/**
* @type {Array<Item | GC>}
*/ const stack = [];
// sort them so that we take the higher id first, in case of conflicts the lower id will probably not conflict with the id from the higher user.
let clientsStructRefsIds = _array.from(clientsStructRefs.keys()).sort((a, b)=>a - b);
if (clientsStructRefsIds.length === 0) return null;
const getNextStructTarget = ()=>{
if (clientsStructRefsIds.length === 0) return null;
let nextStructsTarget = /** @type {{i:number,refs:Array<GC|Item>}} */ clientsStructRefs.get(clientsStructRefsIds[clientsStructRefsIds.length - 1]);
while(nextStructsTarget.refs.length === nextStructsTarget.i){
clientsStructRefsIds.pop();
if (clientsStructRefsIds.length > 0) nextStructsTarget = /** @type {{i:number,refs:Array<GC|Item>}} */ clientsStructRefs.get(clientsStructRefsIds[clientsStructRefsIds.length - 1]);
else return null;
}
return nextStructsTarget;
};
let curStructsTarget = getNextStructTarget();
if (curStructsTarget === null) return null;
/**
* @type {StructStore}
*/ const restStructs = new StructStore();
const missingSV = new Map();
/**
* @param {number} client
* @param {number} clock
*/ const updateMissingSv = (client, clock)=>{
const mclock = missingSV.get(client);
if (mclock == null || mclock > clock) missingSV.set(client, clock);
};
/**
* @type {GC|Item}
*/ let stackHead = /** @type {any} */ curStructsTarget.refs[/** @type {any} */ curStructsTarget.i++];
// caching the state because it is used very often
const state = new Map();
const addStackToRestSS = ()=>{
for (const item of stack){
const client = item.id.client;
const unapplicableItems = clientsStructRefs.get(client);
if (unapplicableItems) {
// decrement because we weren't able to apply previous operation
unapplicableItems.i--;
restStructs.clients.set(client, unapplicableItems.refs.slice(unapplicableItems.i));
clientsStructRefs.delete(client);
unapplicableItems.i = 0;
unapplicableItems.refs = [];
} else // item was the last item on clientsStructRefs and the field was already cleared. Add item to restStructs and continue
restStructs.clients.set(client, [
item
]);
// remove client from clientsStructRefsIds to prevent users from applying the same update again
clientsStructRefsIds = clientsStructRefsIds.filter((c)=>c !== client);
}
stack.length = 0;
};
// iterate over all struct readers until we are done
while(true){
if (stackHead.constructor !== Skip) {
const localClock = _map.setIfUndefined(state, stackHead.id.client, ()=>getState(store, stackHead.id.client));
const offset = localClock - stackHead.id.clock;
if (offset < 0) {
// update from the same client is missing
stack.push(stackHead);
updateMissingSv(stackHead.id.client, stackHead.id.clock - 1);
// hid a dead wall, add all items from stack to restSS
addStackToRestSS();
} else {
const missing = stackHead.getMissing(transaction, store);
if (missing !== null) {
stack.push(stackHead);
// get the struct reader that has the missing struct
/**
* @type {{ refs: Array<GC|Item>, i: number }}
*/ const structRefs = clientsStructRefs.get(/** @type {number} */ missing) || {
refs: [],
i: 0
};
if (structRefs.refs.length === structRefs.i) {
// This update message causally depends on another update message that doesn't exist yet
updateMissingSv(/** @type {number} */ missing, getState(store, missing));
addStackToRestSS();
} else {
stackHead = structRefs.refs[structRefs.i++];
continue;
}
} else if (offset === 0 || offset < stackHead.length) {
// all fine, apply the stackhead
stackHead.integrate(transaction, offset);
state.set(stackHead.id.client, stackHead.id.clock + stackHead.length);
}
}
}
// iterate to next stackHead
if (stack.length > 0) stackHead = /** @type {GC|Item} */ stack.pop();
else if (curStructsTarget !== null && curStructsTarget.i < curStructsTarget.refs.length) stackHead = /** @type {GC|Item} */ curStructsTarget.refs[curStructsTarget.i++];
else {
curStructsTarget = getNextStructTarget();
if (curStructsTarget === null) break;
else stackHead = /** @type {GC|Item} */ curStructsTarget.refs[curStructsTarget.i++];
}
}
if (restStructs.clients.size > 0) {
const encoder = new UpdateEncoderV2();
writeClientsStructs(encoder, restStructs, new Map());
// write empty deleteset
// writeDeleteSet(encoder, new DeleteSet())
_encoding.writeVarUint(encoder.restEncoder, 0); // => no need for an extra function call, just write 0 deletes
return {
missing: missingSV,
update: encoder.toUint8Array()
};
}
return null;
};
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {Transaction} transaction
*
* @private
* @function
*/ const writeStructsFromTransaction = (encoder, transaction)=>writeClientsStructs(encoder, transaction.doc.store, transaction.beforeState);
/**
* Read and apply a document update.
*
* This function has the same effect as `applyUpdate` but accepts a decoder.
*
* @param {decoding.Decoder} decoder
* @param {Doc} ydoc
* @param {any} [transactionOrigin] This will be stored on `transaction.origin` and `.on('update', (update, origin))`
* @param {UpdateDecoderV1 | UpdateDecoderV2} [structDecoder]
*
* @function
*/ const readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = new UpdateDecoderV2(decoder))=>transact(ydoc, (transaction)=>{
// force that transaction.local is set to non-local
transaction.local = false;
let retry = false;
const doc = transaction.doc;
const store = doc.store;
// let start = performance.now()
const ss = readClientsStructRefs(structDecoder, doc);
// console.log('time to read structs: ', performance.now() - start) // @todo remove
// start = performance.now()
// console.log('time to merge: ', performance.now() - start) // @todo remove
// start = performance.now()
const restStructs = integrateStructs(transaction, store, ss);
const pending = store.pendingStructs;
if (pending) {
// check if we can apply something
for (const [client, clock] of pending.missing)if (clock < getState(store, client)) {
retry = true;
break;
}
if (restStructs) {
// merge restStructs into store.pending
for (const [client, clock] of restStructs.missing){
const mclock = pending.missing.get(client);
if (mclock == null || mclock > clock) pending.missing.set(client, clock);
}
pending.update = mergeUpdatesV2([
pending.update,
restStructs.update
]);
}
} else store.pendingStructs = restStructs;
// console.log('time to integrate: ', performance.now() - start) // @todo remove
// start = performance.now()
const dsRest = readAndApplyDeleteSet(structDecoder, transaction, store);
if (store.pendingDs) {
// @todo we could make a lower-bound state-vector check as we do above
const pendingDSUpdate = new UpdateDecoderV2(_decoding.createDecoder(store.pendingDs));
_decoding.readVarUint(pendingDSUpdate.restDecoder); // read 0 structs, because we only encode deletes in pendingdsupdate
const dsRest2 = readAndApplyDeleteSet(pendingDSUpdate, transaction, store);
if (dsRest && dsRest2) // case 1: ds1 != null && ds2 != null
store.pendingDs = mergeUpdatesV2([
dsRest,
dsRest2
]);
else // case 2: ds1 != null
// case 3: ds2 != null
// case 4: ds1 == null && ds2 == null
store.pendingDs = dsRest || dsRest2;
} else // Either dsRest == null && pendingDs == null OR dsRest != null
store.pendingDs = dsRest;
// console.log('time to cleanup: ', performance.now() - start) // @todo remove
// start = performance.now()
// console.log('time to resume delete readers: ', performance.now() - start) // @todo remove
// start = performance.now()
if (retry) {
const update = /** @type {{update: Uint8Array}} */ store.pendingStructs.update;
store.pendingStructs = null;
applyUpdateV2(transaction.doc, update);
}
}, transactionOrigin, false);
/**
* Read and apply a document update.
*
* This function has the same effect as `applyUpdate` but accepts a decoder.
*
* @param {decoding.Decoder} decoder
* @param {Doc} ydoc
* @param {any} [transactionOrigin] This will be stored on `transaction.origin` and `.on('update', (update, origin))`
*
* @function
*/ const readUpdate = (decoder, ydoc, transactionOrigin)=>readUpdateV2(decoder, ydoc, transactionOrigin, new UpdateDecoderV1(decoder));
/**
* Apply a document update created by, for example, `y.on('update', update => ..)` or `update = encodeStateAsUpdate()`.
*
* This function has the same effect as `readUpdate` but accepts an Uint8Array instead of a Decoder.
*
* @param {Doc} ydoc
* @param {Uint8Array} update
* @param {any} [transactionOrigin] This will be stored on `transaction.origin` and `.on('update', (update, origin))`
* @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} [YDecoder]
*
* @function
*/ const applyUpdateV2 = (ydoc, update, transactionOrigin, YDecoder = UpdateDecoderV2)=>{
const decoder = _decoding.createDecoder(update);
readUpdateV2(decoder, ydoc, transactionOrigin, new YDecoder(decoder));
};
/**
* Apply a document update created by, for example, `y.on('update', update => ..)` or `update = encodeStateAsUpdate()`.
*
* This function has the same effect as `readUpdate` but accepts an Uint8Array instead of a Decoder.
*
* @param {Doc} ydoc
* @param {Uint8Array} update
* @param {any} [transactionOrigin] This will be stored on `transaction.origin` and `.on('update', (update, origin))`
*
* @function
*/ const applyUpdate = (ydoc, update, transactionOrigin)=>applyUpdateV2(ydoc, update, transactionOrigin, UpdateDecoderV1);
/**
* Write all the document as a single update message. If you specify the state of the remote client (`targetStateVector`) it will
* only write the operations that are missing.
*
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {Doc} doc
* @param {Map<number,number>} [targetStateVector] The state of the target that receives the update. Leave empty to write all known structs
*
* @function
*/ const writeStateAsUpdate = (encoder, doc, targetStateVector = new Map())=>{
writeClientsStructs(encoder, doc.store, targetStateVector);
writeDeleteSet(encoder, createDeleteSetFromStructStore(doc.store));
};
/**
* Write all the document as a single update message that can be applied on the remote document. If you specify the state of the remote client (`targetState`) it will
* only write the operations that are missing.
*
* Use `writeStateAsUpdate` instead if you are working with lib0/encoding.js#Encoder
*
* @param {Doc} doc
* @param {Uint8Array} [encodedTargetStateVector] The state of the target that receives the update. Leave empty to write all known structs
* @param {UpdateEncoderV1 | UpdateEncoderV2} [encoder]
* @return {Uint8Array}
*
* @function
*/ const encodeStateAsUpdateV2 = (doc, encodedTargetStateVector = new Uint8Array([
0
]), encoder = new UpdateEncoderV2())=>{
const targetStateVector = decodeStateVector(encodedTargetStateVector);
writeStateAsUpdate(encoder, doc, targetStateVector);
const updates = [
encoder.toUint8Array()
];
// also add the pending updates (if there are any)
if (doc.store.pendingDs) updates.push(doc.store.pendingDs);
if (doc.store.pendingStructs) updates.push(diffUpdateV2(doc.store.pendingStructs.update, encodedTargetStateVector));
if (updates.length > 1) {
if (encoder.constructor === UpdateEncoderV1) return mergeUpdates(updates.map((update, i)=>i === 0 ? update : convertUpdateFormatV2ToV1(update)));
else if (encoder.constructor === UpdateEncoderV2) return mergeUpdatesV2(updates);
}
return updates[0];
};
/**
* Write all the document as a single update message that can be applied on the remote document. If you specify the state of the remote client (`targetState`) it will
* only write the operations that are missing.
*
* Use `writeStateAsUpdate` instead if you are working with lib0/encoding.js#Encoder
*
* @param {Doc} doc
* @param {Uint8Array} [encodedTargetStateVector] The state of the target that receives the update. Leave empty to write all known structs
* @return {Uint8Array}
*
* @function
*/ const encodeStateAsUpdate = (doc, encodedTargetStateVector)=>encodeStateAsUpdateV2(doc, encodedTargetStateVector, new UpdateEncoderV1());
/**
* Read state vector from Decoder and return as Map
*
* @param {DSDecoderV1 | DSDecoderV2} decoder
* @return {Map<number,number>} Maps `client` to the number next expected `clock` from that client.
*
* @function
*/ const readStateVector = (decoder)=>{
const ss = new Map();
const ssLength = _decoding.readVarUint(decoder.restDecoder);
for(let i = 0; i < ssLength; i++){
const client = _decoding.readVarUint(decoder.restDecoder);
const clock = _decoding.readVarUint(decoder.restDecoder);
ss.set(client, clock);
}
return ss;
};
/**
* Read decodedState and return State as Map.
*
* @param {Uint8Array} decodedState
* @return {Map<number,number>} Maps `client` to the number next expected `clock` from that client.
*
* @function
*/ // export const decodeStateVectorV2 = decodedState => readStateVector(new DSDecoderV2(decoding.createDecoder(decodedState)))
/**
* Read decodedState and return State as Map.
*
* @param {Uint8Array} decodedState
* @return {Map<number,number>} Maps `client` to the number next expected `clock` from that client.
*
* @function
*/ const decodeStateVector = (decodedState)=>readStateVector(new DSDecoderV1(_decoding.createDecoder(decodedState)));
/**
* @param {DSEncoderV1 | DSEncoderV2} encoder
* @param {Map<number,number>} sv
* @function
*/ const writeStateVector = (encoder, sv)=>{
_encoding.writeVarUint(encoder.restEncoder, sv.size);
_array.from(sv.entries()).sort((a, b)=>b[0] - a[0]).forEach(([client, clock])=>{
_encoding.writeVarUint(encoder.restEncoder, client); // @todo use a special client decoder that is based on mapping
_encoding.writeVarUint(encoder.restEncoder, clock);
});
return encoder;
};
/**
* @param {DSEncoderV1 | DSEncoderV2} encoder
* @param {Doc} doc
*
* @function
*/ const writeDocumentStateVector = (encoder, doc)=>writeStateVector(encoder, getStateVector(doc.store));
/**
* Encode State as Uint8Array.
*
* @param {Doc|Map<number,number>} doc
* @param {DSEncoderV1 | DSEncoderV2} [encoder]
* @return {Uint8Array}
*
* @function
*/ const encodeStateVectorV2 = (doc, encoder = new DSEncoderV2())=>{
if (doc instanceof Map) writeStateVector(encoder, doc);
else writeDocumentStateVector(encoder, doc);
return encoder.toUint8Array();
};
/**
* Encode State as Uint8Array.
*
* @param {Doc|Map<number,number>} doc
* @return {Uint8Array}
*
* @function
*/ const encodeStateVector = (doc)=>encodeStateVectorV2(doc, new DSEncoderV1());
/**
* General event handler implementation.
*
* @template ARG0, ARG1
*
* @private
*/ class EventHandler {
constructor(){
/**
* @type {Array<function(ARG0, ARG1):void>}
*/ this.l = [];
}
}
/**
* @template ARG0,ARG1
* @returns {EventHandler<ARG0,ARG1>}
*
* @private
* @function
*/ const createEventHandler = ()=>new EventHandler();
/**
* Adds an event listener that is called when
* {@link EventHandler#callEventListeners} is called.
*
* @template ARG0,ARG1
* @param {EventHandler<ARG0,ARG1>} eventHandler
* @param {function(ARG0,ARG1):void} f The event handler.
*
* @private
* @function
*/ const addEventHandlerListener = (eventHandler, f)=>eventHandler.l.push(f);
/**
* Removes an event listener.
*
* @template ARG0,ARG1
* @param {EventHandler<ARG0,ARG1>} eventHandler
* @param {function(ARG0,ARG1):void} f The event handler that was added with
* {@link EventHandler#addEventListener}
*
* @private
* @function
*/ const removeEventHandlerListener = (eventHandler, f)=>{
const l = eventHandler.l;
const len = l.length;
eventHandler.l = l.filter((g)=>f !== g);
if (len === eventHandler.l.length) console.error("[yjs] Tried to remove event handler that doesn't exist.");
};
/**
* Call all event listeners that were added via
* {@link EventHandler#addEventListener}.
*
* @template ARG0,ARG1
* @param {EventHandler<ARG0,ARG1>} eventHandler
* @param {ARG0} arg0
* @param {ARG1} arg1
*
* @private
* @function
*/ const callEventHandlerListeners = (eventHandler, arg0, arg1)=>_function.callAll(eventHandler.l, [
arg0,
arg1
]);
class ID {
/**
* @param {number} client client id
* @param {number} clock unique per client id, continuous number
*/ constructor(client, clock){
/**
* Client id
* @type {number}
*/ this.client = client;
/**
* unique per client id, continuous number
* @type {number}
*/ this.clock = clock;
}
}
/**
* @param {ID | null} a
* @param {ID | null} b
* @return {boolean}
*
* @function
*/ const compareIDs = (a, b)=>a === b || a !== null && b !== null && a.client === b.client && a.clock === b.clock;
/**
* @param {number} client
* @param {number} clock
*
* @private
* @function
*/ const createID = (client, clock)=>new ID(client, clock);
/**
* @param {encoding.Encoder} encoder
* @param {ID} id
*
* @private
* @function
*/ const writeID = (encoder, id)=>{
_encoding.writeVarUint(encoder, id.client);
_encoding.writeVarUint(encoder, id.clock);
};
/**
* Read ID.
* * If first varUint read is 0xFFFFFF a RootID is returned.
* * Otherwise an ID is returned
*
* @param {decoding.Decoder} decoder
* @return {ID}
*
* @private
* @function
*/ const readID = (decoder)=>createID(_decoding.readVarUint(decoder), _decoding.readVarUint(decoder));
/**
* The top types are mapped from y.share.get(keyname) => type.
* `type` does not store any information about the `keyname`.
* This function finds the correct `keyname` for `type` and throws otherwise.
*
* @param {AbstractType<any>} type
* @return {string}
*
* @private
* @function
*/ const findRootTypeKey = (type)=>{
// @ts-ignore _y must be defined, otherwise unexpected case
for (const [key, value] of type.doc.share.entries()){
if (value === type) return key;
}
throw _error.unexpectedCase();
};
/**
* Check if `parent` is a parent of `child`.
*
* @param {AbstractType<any>} parent
* @param {Item|null} child
* @return {Boolean} Whether `parent` is a parent of `child`.
*
* @private
* @function
*/ const isParentOf = (parent, child)=>{
while(child !== null){
if (child.parent === parent) return true;
child = /** @type {AbstractType<any>} */ child.parent._item;
}
return false;
};
/**
* Convenient helper to log type information.
*
* Do not use in productive systems as the output can be immense!
*
* @param {AbstractType<any>} type
*/ const logType = (type)=>{
const res = [];
let n = type._start;
while(n){
res.push(n);
n = n.right;
}
console.log("Children: ", res);
console.log("Children content: ", res.filter((m)=>!m.deleted).map((m)=>m.content));
};
class PermanentUserData {
/**
* @param {Doc} doc
* @param {YMap<any>} [storeType]
*/ constructor(doc, storeType = doc.getMap("users")){
/**
* @type {Map<string,DeleteSet>}
*/ const dss = new Map();
this.yusers = storeType;
this.doc = doc;
/**
* Maps from clientid to userDescription
*
* @type {Map<number,string>}
*/ this.clients = new Map();
this.dss = dss;
/**
* @param {YMap<any>} user
* @param {string} userDescription
*/ const initUser = (user, userDescription)=>{
/**
* @type {YArray<Uint8Array>}
*/ const ds = user.get("ds");
const ids = user.get("ids");
const addClientId = /** @param {number} clientid */ (clientid)=>this.clients.set(clientid, userDescription);
ds.observe(/** @param {YArrayEvent<any>} event */ (event)=>{
event.changes.added.forEach((item)=>{
item.content.getContent().forEach((encodedDs)=>{
if (encodedDs instanceof Uint8Array) this.dss.set(userDescription, mergeDeleteSets([
this.dss.get(userDescription) || createDeleteSet(),
readDeleteSet(new DSDecoderV1(_decoding.createDecoder(encodedDs)))
]));
});
});
});
this.dss.set(userDescription, mergeDeleteSets(ds.map((encodedDs)=>readDeleteSet(new DSDecoderV1(_decoding.createDecoder(encodedDs))))));
ids.observe(/** @param {YArrayEvent<any>} event */ (event)=>event.changes.added.forEach((item)=>item.content.getContent().forEach(addClientId)));
ids.forEach(addClientId);
};
// observe users
storeType.observe((event)=>{
event.keysChanged.forEach((userDescription)=>initUser(storeType.get(userDescription), userDescription));
});
// add intial data
storeType.forEach(initUser);
}
/**
* @param {Doc} doc
* @param {number} clientid
* @param {string} userDescription
* @param {Object} conf
* @param {function(Transaction, DeleteSet):boolean} [conf.filter]
*/ setUserMapping(doc, clientid, userDescription, { filter = ()=>true } = {}) {
const users = this.yusers;
let user = users.get(userDescription);
if (!user) {
user = new YMap();
user.set("ids", new YArray());
user.set("ds", new YArray());
users.set(userDescription, user);
}
user.get("ids").push([
clientid
]);
users.observe((_event)=>{
setTimeout(()=>{
const userOverwrite = users.get(userDescription);
if (userOverwrite !== user) {
// user was overwritten, port all data over to the next user object
// @todo Experiment with Y.Sets here
user = userOverwrite;
// @todo iterate over old type
this.clients.forEach((_userDescription, clientid)=>{
if (userDescription === _userDescription) user.get("ids").push([
clientid
]);
});
const encoder = new DSEncoderV1();
const ds = this.dss.get(userDescription);
if (ds) {
writeDeleteSet(encoder, ds);
user.get("ds").push([
encoder.toUint8Array()
]);
}
}
}, 0);
});
doc.on("afterTransaction", /** @param {Transaction} transaction */ (transaction)=>{
setTimeout(()=>{
const yds = user.get("ds");
const ds = transaction.deleteSet;
if (transaction.local && ds.clients.size > 0 && filter(transaction, ds)) {
const encoder = new DSEncoderV1();
writeDeleteSet(encoder, ds);
yds.push([
encoder.toUint8Array()
]);
}
});
});
}
/**
* @param {number} clientid
* @return {any}
*/ getUserByClientId(clientid) {
return this.clients.get(clientid) || null;
}
/**
* @param {ID} id
* @return {string | null}
*/ getUserByDeletedId(id) {
for (const [userDescription, ds] of this.dss.entries()){
if (isDeleted(ds, id)) return userDescription;
}
return null;
}
}
/**
* A relative position is based on the Yjs model and is not affected by document changes.
* E.g. If you place a relative position before a certain character, it will always point to this character.
* If you place a relative position at the end of a type, it will always point to the end of the type.
*
* A numeric position is often unsuited for user selections, because it does not change when content is inserted
* before or after.
*
* ```Insert(0, 'x')('a|bc') = 'xa|bc'``` Where | is the relative position.
*
* One of the properties must be defined.
*
* @example
* // Current cursor position is at position 10
* const relativePosition = createRelativePositionFromIndex(yText, 10)
* // modify yText
* yText.insert(0, 'abc')
* yText.delete(3, 10)
* // Compute the cursor position
* const absolutePosition = createAbsolutePositionFromRelativePosition(y, relativePosition)
* absolutePosition.type === yText // => true
* console.log('cursor location is ' + absolutePosition.index) // => cursor location is 3
*
*/ class RelativePosition {
/**
* @param {ID|null} type
* @param {string|null} tname
* @param {ID|null} item
* @param {number} assoc
*/ constructor(type, tname, item, assoc = 0){
/**
* @type {ID|null}
*/ this.type = type;
/**
* @type {string|null}
*/ this.tname = tname;
/**
* @type {ID | null}
*/ this.item = item;
/**
* A relative position is associated to a specific character. By default
* assoc >= 0, the relative position is associated to the character
* after the meant position.
* I.e. position 1 in 'ab' is associated to character 'b'.
*
* If assoc < 0, then the relative position is associated to the caharacter
* before the meant position.
*
* @type {number}
*/ this.assoc = assoc;
}
}
/**
* @param {RelativePosition} rpos
* @return {any}
*/ const relativePositionToJSON = (rpos)=>{
const json = {};
if (rpos.type) json.type = rpos.type;
if (rpos.tname) json.tname = rpos.tname;
if (rpos.item) json.item = rpos.item;
if (rpos.assoc != null) json.assoc = rpos.assoc;
return json;
};
/**
* @param {any} json
* @return {RelativePosition}
*
* @function
*/ const createRelativePositionFromJSON = (json)=>new RelativePosition(json.type == null ? null : createID(json.type.client, json.type.clock), json.tname ?? null, json.item == null ? null : createID(json.item.client, json.item.clock), json.assoc == null ? 0 : json.assoc);
class AbsolutePosition {
/**
* @param {AbstractType<any>} type
* @param {number} index
* @param {number} [assoc]
*/ constructor(type, index, assoc = 0){
/**
* @type {AbstractType<any>}
*/ this.type = type;
/**
* @type {number}
*/ this.index = index;
this.assoc = assoc;
}
}
/**
* @param {AbstractType<any>} type
* @param {number} index
* @param {number} [assoc]
*
* @function
*/ const createAbsolutePosition = (type, index, assoc = 0)=>new AbsolutePosition(type, index, assoc);
/**
* @param {AbstractType<any>} type
* @param {ID|null} item
* @param {number} [assoc]
*
* @function
*/ const createRelativePosition = (type, item, assoc)=>{
let typeid = null;
let tname = null;
if (type._item === null) tname = findRootTypeKey(type);
else typeid = createID(type._item.id.client, type._item.id.clock);
return new RelativePosition(typeid, tname, item, assoc);
};
/**
* Create a relativePosition based on a absolute position.
*
* @param {AbstractType<any>} type The base type (e.g. YText or YArray).
* @param {number} index The absolute position.
* @param {number} [assoc]
* @return {RelativePosition}
*
* @function
*/ const createRelativePositionFromTypeIndex = (type, index, assoc = 0)=>{
let t = type._start;
if (assoc < 0) {
// associated to the left character or the beginning of a type, increment index if possible.
if (index === 0) return createRelativePosition(type, null, assoc);
index--;
}
while(t !== null){
if (!t.deleted && t.countable) {
if (t.length > index) // case 1: found position somewhere in the linked list
return createRelativePosition(type, createID(t.id.client, t.id.clock + index), assoc);
index -= t.length;
}
if (t.right === null && assoc < 0) // left-associated position, return last available id
return createRelativePosition(type, t.lastId, assoc);
t = t.right;
}
return createRelativePosition(type, null, assoc);
};
/**
* @param {encoding.Encoder} encoder
* @param {RelativePosition} rpos
*
* @function
*/ const writeRelativePosition = (encoder, rpos)=>{
const { type, tname, item, assoc } = rpos;
if (item !== null) {
_encoding.writeVarUint(encoder, 0);
writeID(encoder, item);
} else if (tname !== null) {
// case 2: found position at the end of the list and type is stored in y.share
_encoding.writeUint8(encoder, 1);
_encoding.writeVarString(encoder, tname);
} else if (type !== null) {
// case 3: found position at the end of the list and type is attached to an item
_encoding.writeUint8(encoder, 2);
writeID(encoder, type);
} else throw _error.unexpectedCase();
_encoding.writeVarInt(encoder, assoc);
return encoder;
};
/**
* @param {RelativePosition} rpos
* @return {Uint8Array}
*/ const encodeRelativePosition = (rpos)=>{
const encoder = _encoding.createEncoder();
writeRelativePosition(encoder, rpos);
return _encoding.toUint8Array(encoder);
};
/**
* @param {decoding.Decoder} decoder
* @return {RelativePosition}
*
* @function
*/ const readRelativePosition = (decoder)=>{
let type = null;
let tname = null;
let itemID = null;
switch(_decoding.readVarUint(decoder)){
case 0:
// case 1: found position somewhere in the linked list
itemID = readID(decoder);
break;
case 1:
// case 2: found position at the end of the list and type is stored in y.share
tname = _decoding.readVarString(decoder);
break;
case 2:
// case 3: found position at the end of the list and type is attached to an item
type = readID(decoder);
}
const assoc = _decoding.hasContent(decoder) ? _decoding.readVarInt(decoder) : 0;
return new RelativePosition(type, tname, itemID, assoc);
};
/**
* @param {Uint8Array} uint8Array
* @return {RelativePosition}
*/ const decodeRelativePosition = (uint8Array)=>readRelativePosition(_decoding.createDecoder(uint8Array));
/**
* Transform a relative position to an absolute position.
*
* If you want to share the relative position with other users, you should set
* `followUndoneDeletions` to false to get consistent results across all clients.
*
* When calculating the absolute position, we try to follow the "undone deletions". This yields
* better results for the user who performed undo. However, only the user who performed the undo
* will get the better results, the other users don't know which operations recreated a deleted
* range of content. There is more information in this ticket: https://github.com/yjs/yjs/issues/638
*
* @param {RelativePosition} rpos
* @param {Doc} doc
* @param {boolean} followUndoneDeletions - whether to follow undone deletions - see https://github.com/yjs/yjs/issues/638
* @return {AbsolutePosition|null}
*
* @function
*/ const createAbsolutePositionFromRelativePosition = (rpos, doc, followUndoneDeletions = true)=>{
const store = doc.store;
const rightID = rpos.item;
const typeID = rpos.type;
const tname = rpos.tname;
const assoc = rpos.assoc;
let type = null;
let index = 0;
if (rightID !== null) {
if (getState(store, rightID.client) <= rightID.clock) return null;
const res = followUndoneDeletions ? followRedone(store, rightID) : {
item: getItem(store, rightID),
diff: 0
};
const right = res.item;
if (!(right instanceof Item)) return null;
type = /** @type {AbstractType<any>} */ right.parent;
if (type._item === null || !type._item.deleted) {
index = right.deleted || !right.countable ? 0 : res.diff + (assoc >= 0 ? 0 : 1); // adjust position based on left association if necessary
let n = right.left;
while(n !== null){
if (!n.deleted && n.countable) index += n.length;
n = n.left;
}
}
} else {
if (tname !== null) type = doc.get(tname);
else if (typeID !== null) {
if (getState(store, typeID.client) <= typeID.clock) // type does not exist yet
return null;
const { item } = followUndoneDeletions ? followRedone(store, typeID) : {
item: getItem(store, typeID)
};
if (item instanceof Item && item.content instanceof ContentType) type = item.content.type;
else // struct is garbage collected
return null;
} else throw _error.unexpectedCase();
if (assoc >= 0) index = type._length;
else index = 0;
}
return createAbsolutePosition(type, index, rpos.assoc);
};
/**
* @param {RelativePosition|null} a
* @param {RelativePosition|null} b
* @return {boolean}
*
* @function
*/ const compareRelativePositions = (a, b)=>a === b || a !== null && b !== null && a.tname === b.tname && compareIDs(a.item, b.item) && compareIDs(a.type, b.type) && a.assoc === b.assoc;
class Snapshot {
/**
* @param {DeleteSet} ds
* @param {Map<number,number>} sv state map
*/ constructor(ds, sv){
/**
* @type {DeleteSet}
*/ this.ds = ds;
/**
* State Map
* @type {Map<number,number>}
*/ this.sv = sv;
}
}
/**
* @param {Snapshot} snap1
* @param {Snapshot} snap2
* @return {boolean}
*/ const equalSnapshots = (snap1, snap2)=>{
const ds1 = snap1.ds.clients;
const ds2 = snap2.ds.clients;
const sv1 = snap1.sv;
const sv2 = snap2.sv;
if (sv1.size !== sv2.size || ds1.size !== ds2.size) return false;
for (const [key, value] of sv1.entries()){
if (sv2.get(key) !== value) return false;
}
for (const [client, dsitems1] of ds1.entries()){
const dsitems2 = ds2.get(client) || [];
if (dsitems1.length !== dsitems2.length) return false;
for(let i = 0; i < dsitems1.length; i++){
const dsitem1 = dsitems1[i];
const dsitem2 = dsitems2[i];
if (dsitem1.clock !== dsitem2.clock || dsitem1.len !== dsitem2.len) return false;
}
}
return true;
};
/**
* @param {Snapshot} snapshot
* @param {DSEncoderV1 | DSEncoderV2} [encoder]
* @return {Uint8Array}
*/ const encodeSnapshotV2 = (snapshot, encoder = new DSEncoderV2())=>{
writeDeleteSet(encoder, snapshot.ds);
writeStateVector(encoder, snapshot.sv);
return encoder.toUint8Array();
};
/**
* @param {Snapshot} snapshot
* @return {Uint8Array}
*/ const encodeSnapshot = (snapshot)=>encodeSnapshotV2(snapshot, new DSEncoderV1());
/**
* @param {Uint8Array} buf
* @param {DSDecoderV1 | DSDecoderV2} [decoder]
* @return {Snapshot}
*/ const decodeSnapshotV2 = (buf, decoder = new DSDecoderV2(_decoding.createDecoder(buf)))=>{
return new Snapshot(readDeleteSet(decoder), readStateVector(decoder));
};
/**
* @param {Uint8Array} buf
* @return {Snapshot}
*/ const decodeSnapshot = (buf)=>decodeSnapshotV2(buf, new DSDecoderV1(_decoding.createDecoder(buf)));
/**
* @param {DeleteSet} ds
* @param {Map<number,number>} sm
* @return {Snapshot}
*/ const createSnapshot = (ds, sm)=>new Snapshot(ds, sm);
const emptySnapshot = createSnapshot(createDeleteSet(), new Map());
/**
* @param {Doc} doc
* @return {Snapshot}
*/ const snapshot = (doc)=>createSnapshot(createDeleteSetFromStructStore(doc.store), getStateVector(doc.store));
/**
* @param {Item} item
* @param {Snapshot|undefined} snapshot
*
* @protected
* @function
*/ const isVisible = (item, snapshot)=>snapshot === undefined ? !item.deleted : snapshot.sv.has(item.id.client) && (snapshot.sv.get(item.id.client) || 0) > item.id.clock && !isDeleted(snapshot.ds, item.id);
/**
* @param {Transaction} transaction
* @param {Snapshot} snapshot
*/ const splitSnapshotAffectedStructs = (transaction, snapshot)=>{
const meta = _map.setIfUndefined(transaction.meta, splitSnapshotAffectedStructs, _set.create);
const store = transaction.doc.store;
// check if we already split for this snapshot
if (!meta.has(snapshot)) {
snapshot.sv.forEach((clock, client)=>{
if (clock < getState(store, client)) getItemCleanStart(transaction, createID(client, clock));
});
iterateDeletedStructs(transaction, snapshot.ds, (_item)=>{});
meta.add(snapshot);
}
};
/**
* @example
* const ydoc = new Y.Doc({ gc: false })
* ydoc.getText().insert(0, 'world!')
* const snapshot = Y.snapshot(ydoc)
* ydoc.getText().insert(0, 'hello ')
* const restored = Y.createDocFromSnapshot(ydoc, snapshot)
* assert(restored.getText().toString() === 'world!')
*
* @param {Doc} originDoc
* @param {Snapshot} snapshot
* @param {Doc} [newDoc] Optionally, you may define the Yjs document that receives the data from originDoc
* @return {Doc}
*/ const createDocFromSnapshot = (originDoc, snapshot, newDoc = new Doc())=>{
if (originDoc.gc) // we should not try to restore a GC-ed document, because some of the restored items might have their content deleted
throw new Error("Garbage-collection must be disabled in `originDoc`!");
const { sv, ds } = snapshot;
const encoder = new UpdateEncoderV2();
originDoc.transact((transaction)=>{
let size = 0;
sv.forEach((clock)=>{
if (clock > 0) size++;
});
_encoding.writeVarUint(encoder.restEncoder, size);
// splitting the structs before writing them to the encoder
for (const [client, clock] of sv){
if (clock === 0) continue;
if (clock < getState(originDoc.store, client)) getItemCleanStart(transaction, createID(client, clock));
const structs = originDoc.store.clients.get(client) || [];
const lastStructIndex = findIndexSS(structs, clock - 1);
// write # encoded structs
_encoding.writeVarUint(encoder.restEncoder, lastStructIndex + 1);
encoder.writeClient(client);
// first clock written is 0
_encoding.writeVarUint(encoder.restEncoder, 0);
for(let i = 0; i <= lastStructIndex; i++)structs[i].write(encoder, 0);
}
writeDeleteSet(encoder, ds);
});
applyUpdateV2(newDoc, encoder.toUint8Array(), "snapshot");
return newDoc;
};
/**
* @param {Snapshot} snapshot
* @param {Uint8Array} update
* @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} [YDecoder]
*/ const snapshotContainsUpdateV2 = (snapshot, update, YDecoder = UpdateDecoderV2)=>{
const updateDecoder = new YDecoder(_decoding.createDecoder(update));
const lazyDecoder = new LazyStructReader(updateDecoder, false);
for(let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next()){
if ((snapshot.sv.get(curr.id.client) || 0) < curr.id.clock + curr.length) return false;
}
const mergedDS = mergeDeleteSets([
snapshot.ds,
readDeleteSet(updateDecoder)
]);
return equalDeleteSets(snapshot.ds, mergedDS);
};
/**
* @param {Snapshot} snapshot
* @param {Uint8Array} update
*/ const snapshotContainsUpdate = (snapshot, update)=>snapshotContainsUpdateV2(snapshot, update, UpdateDecoderV1);
class StructStore {
constructor(){
/**
* @type {Map<number,Array<GC|Item>>}
*/ this.clients = new Map();
/**
* @type {null | { missing: Map<number, number>, update: Uint8Array }}
*/ this.pendingStructs = null;
/**
* @type {null | Uint8Array}
*/ this.pendingDs = null;
}
}
/**
* Return the states as a Map<client,clock>.
* Note that clock refers to the next expected clock id.
*
* @param {StructStore} store
* @return {Map<number,number>}
*
* @public
* @function
*/ const getStateVector = (store)=>{
const sm = new Map();
store.clients.forEach((structs, client)=>{
const struct = structs[structs.length - 1];
sm.set(client, struct.id.clock + struct.length);
});
return sm;
};
/**
* @param {StructStore} store
* @param {number} client
* @return {number}
*
* @public
* @function
*/ const getState = (store, client)=>{
const structs = store.clients.get(client);
if (structs === undefined) return 0;
const lastStruct = structs[structs.length - 1];
return lastStruct.id.clock + lastStruct.length;
};
/**
* @param {StructStore} store
* @param {GC|Item} struct
*
* @private
* @function
*/ const addStruct = (store, struct)=>{
let structs = store.clients.get(struct.id.client);
if (structs === undefined) {
structs = [];
store.clients.set(struct.id.client, structs);
} else {
const lastStruct = structs[structs.length - 1];
if (lastStruct.id.clock + lastStruct.length !== struct.id.clock) throw _error.unexpectedCase();
}
structs.push(struct);
};
/**
* Perform a binary search on a sorted array
* @param {Array<Item|GC>} structs
* @param {number} clock
* @return {number}
*
* @private
* @function
*/ const findIndexSS = (structs, clock)=>{
let left = 0;
let right = structs.length - 1;
let mid = structs[right];
let midclock = mid.id.clock;
if (midclock === clock) return right;
// @todo does it even make sense to pivot the search?
// If a good split misses, it might actually increase the time to find the correct item.
// Currently, the only advantage is that search with pivoting might find the item on the first try.
let midindex = _math.floor(clock / (midclock + mid.length - 1) * right); // pivoting the search
while(left <= right){
mid = structs[midindex];
midclock = mid.id.clock;
if (midclock <= clock) {
if (clock < midclock + mid.length) return midindex;
left = midindex + 1;
} else right = midindex - 1;
midindex = _math.floor((left + right) / 2);
}
// Always check state before looking for a struct in StructStore
// Therefore the case of not finding a struct is unexpected
throw _error.unexpectedCase();
};
/**
* Expects that id is actually in store. This function throws or is an infinite loop otherwise.
*
* @param {StructStore} store
* @param {ID} id
* @return {GC|Item}
*
* @private
* @function
*/ const find = (store, id)=>{
/**
* @type {Array<GC|Item>}
*/ // @ts-ignore
const structs = store.clients.get(id.client);
return structs[findIndexSS(structs, id.clock)];
};
/**
* Expects that id is actually in store. This function throws or is an infinite loop otherwise.
* @private
* @function
*/ const getItem = /** @type {function(StructStore,ID):Item} */ find;
/**
* @param {Transaction} transaction
* @param {Array<Item|GC>} structs
* @param {number} clock
*/ const findIndexCleanStart = (transaction, structs, clock)=>{
const index = findIndexSS(structs, clock);
const struct = structs[index];
if (struct.id.clock < clock && struct instanceof Item) {
structs.splice(index + 1, 0, splitItem(transaction, struct, clock - struct.id.clock));
return index + 1;
}
return index;
};
/**
* Expects that id is actually in store. This function throws or is an infinite loop otherwise.
*
* @param {Transaction} transaction
* @param {ID} id
* @return {Item}
*
* @private
* @function
*/ const getItemCleanStart = (transaction, id)=>{
const structs = /** @type {Array<Item>} */ transaction.doc.store.clients.get(id.client);
return structs[findIndexCleanStart(transaction, structs, id.clock)];
};
/**
* Expects that id is actually in store. This function throws or is an infinite loop otherwise.
*
* @param {Transaction} transaction
* @param {StructStore} store
* @param {ID} id
* @return {Item}
*
* @private
* @function
*/ const getItemCleanEnd = (transaction, store, id)=>{
/**
* @type {Array<Item>}
*/ // @ts-ignore
const structs = store.clients.get(id.client);
const index = findIndexSS(structs, id.clock);
const struct = structs[index];
if (id.clock !== struct.id.clock + struct.length - 1 && struct.constructor !== GC) structs.splice(index + 1, 0, splitItem(transaction, struct, id.clock - struct.id.clock + 1));
return struct;
};
/**
* Replace `item` with `newitem` in store
* @param {StructStore} store
* @param {GC|Item} struct
* @param {GC|Item} newStruct
*
* @private
* @function
*/ const replaceStruct = (store, struct, newStruct)=>{
const structs = /** @type {Array<GC|Item>} */ store.clients.get(struct.id.client);
structs[findIndexSS(structs, struct.id.clock)] = newStruct;
};
/**
* Iterate over a range of structs
*
* @param {Transaction} transaction
* @param {Array<Item|GC>} structs
* @param {number} clockStart Inclusive start
* @param {number} len
* @param {function(GC|Item):void} f
*
* @function
*/ const iterateStructs = (transaction, structs, clockStart, len, f)=>{
if (len === 0) return;
const clockEnd = clockStart + len;
let index = findIndexCleanStart(transaction, structs, clockStart);
let struct;
do {
struct = structs[index++];
if (clockEnd < struct.id.clock + struct.length) findIndexCleanStart(transaction, structs, clockEnd);
f(struct);
}while (index < structs.length && structs[index].id.clock < clockEnd);
};
/**
* A transaction is created for every change on the Yjs model. It is possible
* to bundle changes on the Yjs model in a single transaction to
* minimize the number on messages sent and the number of observer calls.
* If possible the user of this library should bundle as many changes as
* possible. Here is an example to illustrate the advantages of bundling:
*
* @example
* const ydoc = new Y.Doc()
* const map = ydoc.getMap('map')
* // Log content when change is triggered
* map.observe(() => {
* console.log('change triggered')
* })
* // Each change on the map type triggers a log message:
* map.set('a', 0) // => "change triggered"
* map.set('b', 0) // => "change triggered"
* // When put in a transaction, it will trigger the log after the transaction:
* ydoc.transact(() => {
* map.set('a', 1)
* map.set('b', 1)
* }) // => "change triggered"
*
* @public
*/ class Transaction {
/**
* @param {Doc} doc
* @param {any} origin
* @param {boolean} local
*/ constructor(doc, origin, local){
/**
* The Yjs instance.
* @type {Doc}
*/ this.doc = doc;
/**
* Describes the set of deleted items by ids
* @type {DeleteSet}
*/ this.deleteSet = new DeleteSet();
/**
* Holds the state before the transaction started.
* @type {Map<Number,Number>}
*/ this.beforeState = getStateVector(doc.store);
/**
* Holds the state after the transaction.
* @type {Map<Number,Number>}
*/ this.afterState = new Map();
/**
* All types that were directly modified (property added or child
* inserted/deleted). New types are not included in this Set.
* Maps from type to parentSubs (`item.parentSub = null` for YArray)
* @type {Map<AbstractType<YEvent<any>>,Set<String|null>>}
*/ this.changed = new Map();
/**
* Stores the events for the types that observe also child elements.
* It is mainly used by `observeDeep`.
* @type {Map<AbstractType<YEvent<any>>,Array<YEvent<any>>>}
*/ this.changedParentTypes = new Map();
/**
* @type {Array<AbstractStruct>}
*/ this._mergeStructs = [];
/**
* @type {any}
*/ this.origin = origin;
/**
* Stores meta information on the transaction
* @type {Map<any,any>}
*/ this.meta = new Map();
/**
* Whether this change originates from this doc.
* @type {boolean}
*/ this.local = local;
/**
* @type {Set<Doc>}
*/ this.subdocsAdded = new Set();
/**
* @type {Set<Doc>}
*/ this.subdocsRemoved = new Set();
/**
* @type {Set<Doc>}
*/ this.subdocsLoaded = new Set();
/**
* @type {boolean}
*/ this._needFormattingCleanup = false;
}
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {Transaction} transaction
* @return {boolean} Whether data was written.
*/ const writeUpdateMessageFromTransaction = (encoder, transaction)=>{
if (transaction.deleteSet.clients.size === 0 && !_map.any(transaction.afterState, (clock, client)=>transaction.beforeState.get(client) !== clock)) return false;
sortAndMergeDeleteSet(transaction.deleteSet);
writeStructsFromTransaction(encoder, transaction);
writeDeleteSet(encoder, transaction.deleteSet);
return true;
};
/**
* If `type.parent` was added in current transaction, `type` technically
* did not change, it was just added and we should not fire events for `type`.
*
* @param {Transaction} transaction
* @param {AbstractType<YEvent<any>>} type
* @param {string|null} parentSub
*/ const addChangedTypeToTransaction = (transaction, type, parentSub)=>{
const item = type._item;
if (item === null || item.id.clock < (transaction.beforeState.get(item.id.client) || 0) && !item.deleted) _map.setIfUndefined(transaction.changed, type, _set.create).add(parentSub);
};
/**
* @param {Array<AbstractStruct>} structs
* @param {number} pos
* @return {number} # of merged structs
*/ const tryToMergeWithLefts = (structs, pos)=>{
let right = structs[pos];
let left = structs[pos - 1];
let i = pos;
for(; i > 0; right = left, left = structs[--i - 1]){
if (left.deleted === right.deleted && left.constructor === right.constructor) {
if (left.mergeWith(right)) {
if (right instanceof Item && right.parentSub !== null && /** @type {AbstractType<any>} */ right.parent._map.get(right.parentSub) === right) /** @type {AbstractType<any>} */ right.parent._map.set(right.parentSub, /** @type {Item} */ left);
continue;
}
}
break;
}
const merged = pos - i;
if (merged) // remove all merged structs from the array
structs.splice(pos + 1 - merged, merged);
return merged;
};
/**
* @param {DeleteSet} ds
* @param {StructStore} store
* @param {function(Item):boolean} gcFilter
*/ const tryGcDeleteSet = (ds, store, gcFilter)=>{
for (const [client, deleteItems] of ds.clients.entries()){
const structs = /** @type {Array<GC|Item>} */ store.clients.get(client);
for(let di = deleteItems.length - 1; di >= 0; di--){
const deleteItem = deleteItems[di];
const endDeleteItemClock = deleteItem.clock + deleteItem.len;
for(let si = findIndexSS(structs, deleteItem.clock), struct = structs[si]; si < structs.length && struct.id.clock < endDeleteItemClock; struct = structs[++si]){
const struct = structs[si];
if (deleteItem.clock + deleteItem.len <= struct.id.clock) break;
if (struct instanceof Item && struct.deleted && !struct.keep && gcFilter(struct)) struct.gc(store, false);
}
}
}
};
/**
* @param {DeleteSet} ds
* @param {StructStore} store
*/ const tryMergeDeleteSet = (ds, store)=>{
// try to merge deleted / gc'd items
// merge from right to left for better efficiency and so we don't miss any merge targets
ds.clients.forEach((deleteItems, client)=>{
const structs = /** @type {Array<GC|Item>} */ store.clients.get(client);
for(let di = deleteItems.length - 1; di >= 0; di--){
const deleteItem = deleteItems[di];
// start with merging the item next to the last deleted item
const mostRightIndexToCheck = _math.min(structs.length - 1, 1 + findIndexSS(structs, deleteItem.clock + deleteItem.len - 1));
for(let si = mostRightIndexToCheck, struct = structs[si]; si > 0 && struct.id.clock >= deleteItem.clock; struct = structs[si])si -= 1 + tryToMergeWithLefts(structs, si);
}
});
};
/**
* @param {DeleteSet} ds
* @param {StructStore} store
* @param {function(Item):boolean} gcFilter
*/ const tryGc = (ds, store, gcFilter)=>{
tryGcDeleteSet(ds, store, gcFilter);
tryMergeDeleteSet(ds, store);
};
/**
* @param {Array<Transaction>} transactionCleanups
* @param {number} i
*/ const cleanupTransactions = (transactionCleanups, i)=>{
if (i < transactionCleanups.length) {
const transaction = transactionCleanups[i];
const doc = transaction.doc;
const store = doc.store;
const ds = transaction.deleteSet;
const mergeStructs = transaction._mergeStructs;
try {
sortAndMergeDeleteSet(ds);
transaction.afterState = getStateVector(transaction.doc.store);
doc.emit("beforeObserverCalls", [
transaction,
doc
]);
/**
* An array of event callbacks.
*
* Each callback is called even if the other ones throw errors.
*
* @type {Array<function():void>}
*/ const fs = [];
// observe events on changed types
transaction.changed.forEach((subs, itemtype)=>fs.push(()=>{
if (itemtype._item === null || !itemtype._item.deleted) itemtype._callObserver(transaction, subs);
}));
fs.push(()=>{
// deep observe events
transaction.changedParentTypes.forEach((events, type)=>{
// We need to think about the possibility that the user transforms the
// Y.Doc in the event.
if (type._dEH.l.length > 0 && (type._item === null || !type._item.deleted)) {
events = events.filter((event)=>event.target._item === null || !event.target._item.deleted);
events.forEach((event)=>{
event.currentTarget = type;
// path is relative to the current target
event._path = null;
});
// sort events by path length so that top-level events are fired first.
events.sort((event1, event2)=>event1.path.length - event2.path.length);
// We don't need to check for events.length
// because we know it has at least one element
callEventHandlerListeners(type._dEH, events, transaction);
}
});
});
fs.push(()=>doc.emit("afterTransaction", [
transaction,
doc
]));
(0, _function.callAll)(fs, []);
if (transaction._needFormattingCleanup) cleanupYTextAfterTransaction(transaction);
} finally{
// Replace deleted items with ItemDeleted / GC.
// This is where content is actually remove from the Yjs Doc.
if (doc.gc) tryGcDeleteSet(ds, store, doc.gcFilter);
tryMergeDeleteSet(ds, store);
// on all affected store.clients props, try to merge
transaction.afterState.forEach((clock, client)=>{
const beforeClock = transaction.beforeState.get(client) || 0;
if (beforeClock !== clock) {
const structs = /** @type {Array<GC|Item>} */ store.clients.get(client);
// we iterate from right to left so we can safely remove entries
const firstChangePos = _math.max(findIndexSS(structs, beforeClock), 1);
for(let i = structs.length - 1; i >= firstChangePos;)i -= 1 + tryToMergeWithLefts(structs, i);
}
});
// try to merge mergeStructs
// @todo: it makes more sense to transform mergeStructs to a DS, sort it, and merge from right to left
// but at the moment DS does not handle duplicates
for(let i = mergeStructs.length - 1; i >= 0; i--){
const { client, clock } = mergeStructs[i].id;
const structs = /** @type {Array<GC|Item>} */ store.clients.get(client);
const replacedStructPos = findIndexSS(structs, clock);
if (replacedStructPos + 1 < structs.length) {
if (tryToMergeWithLefts(structs, replacedStructPos + 1) > 1) continue; // no need to perform next check, both are already merged
}
if (replacedStructPos > 0) tryToMergeWithLefts(structs, replacedStructPos);
}
if (!transaction.local && transaction.afterState.get(doc.clientID) !== transaction.beforeState.get(doc.clientID)) {
_logging.print(_logging.ORANGE, _logging.BOLD, "[yjs] ", _logging.UNBOLD, _logging.RED, "Changed the client-id because another client seems to be using it.");
doc.clientID = generateNewClientId();
}
// @todo Merge all the transactions into one and provide send the data as a single update message
doc.emit("afterTransactionCleanup", [
transaction,
doc
]);
if (doc._observers.has("update")) {
const encoder = new UpdateEncoderV1();
const hasContent = writeUpdateMessageFromTransaction(encoder, transaction);
if (hasContent) doc.emit("update", [
encoder.toUint8Array(),
transaction.origin,
doc,
transaction
]);
}
if (doc._observers.has("updateV2")) {
const encoder = new UpdateEncoderV2();
const hasContent = writeUpdateMessageFromTransaction(encoder, transaction);
if (hasContent) doc.emit("updateV2", [
encoder.toUint8Array(),
transaction.origin,
doc,
transaction
]);
}
const { subdocsAdded, subdocsLoaded, subdocsRemoved } = transaction;
if (subdocsAdded.size > 0 || subdocsRemoved.size > 0 || subdocsLoaded.size > 0) {
subdocsAdded.forEach((subdoc)=>{
subdoc.clientID = doc.clientID;
if (subdoc.collectionid == null) subdoc.collectionid = doc.collectionid;
doc.subdocs.add(subdoc);
});
subdocsRemoved.forEach((subdoc)=>doc.subdocs.delete(subdoc));
doc.emit("subdocs", [
{
loaded: subdocsLoaded,
added: subdocsAdded,
removed: subdocsRemoved
},
doc,
transaction
]);
subdocsRemoved.forEach((subdoc)=>subdoc.destroy());
}
if (transactionCleanups.length <= i + 1) {
doc._transactionCleanups = [];
doc.emit("afterAllTransactions", [
doc,
transactionCleanups
]);
} else cleanupTransactions(transactionCleanups, i + 1);
}
}
};
/**
* Implements the functionality of `y.transact(()=>{..})`
*
* @template T
* @param {Doc} doc
* @param {function(Transaction):T} f
* @param {any} [origin=true]
* @return {T}
*
* @function
*/ const transact = (doc, f, origin = null, local = true)=>{
const transactionCleanups = doc._transactionCleanups;
let initialCall = false;
/**
* @type {any}
*/ let result = null;
if (doc._transaction === null) {
initialCall = true;
doc._transaction = new Transaction(doc, origin, local);
transactionCleanups.push(doc._transaction);
if (transactionCleanups.length === 1) doc.emit("beforeAllTransactions", [
doc
]);
doc.emit("beforeTransaction", [
doc._transaction,
doc
]);
}
try {
result = f(doc._transaction);
} finally{
if (initialCall) {
const finishCleanup = doc._transaction === transactionCleanups[0];
doc._transaction = null;
if (finishCleanup) // The first transaction ended, now process observer calls.
// Observer call may create new transactions for which we need to call the observers and do cleanup.
// We don't want to nest these calls, so we execute these calls one after
// another.
// Also we need to ensure that all cleanups are called, even if the
// observes throw errors.
// This file is full of hacky try {} finally {} blocks to ensure that an
// event can throw errors and also that the cleanup is called.
cleanupTransactions(transactionCleanups, 0);
}
}
return result;
};
class StackItem {
/**
* @param {DeleteSet} deletions
* @param {DeleteSet} insertions
*/ constructor(deletions, insertions){
this.insertions = insertions;
this.deletions = deletions;
/**
* Use this to save and restore metadata like selection range
*/ this.meta = new Map();
}
}
/**
* @param {Transaction} tr
* @param {UndoManager} um
* @param {StackItem} stackItem
*/ const clearUndoManagerStackItem = (tr, um, stackItem)=>{
iterateDeletedStructs(tr, stackItem.deletions, (item)=>{
if (item instanceof Item && um.scope.some((type)=>isParentOf(type, item))) keepItem(item, false);
});
};
/**
* @param {UndoManager} undoManager
* @param {Array<StackItem>} stack
* @param {'undo'|'redo'} eventType
* @return {StackItem?}
*/ const popStackItem = (undoManager, stack, eventType)=>{
/**
* Keep a reference to the transaction so we can fire the event with the changedParentTypes
* @type {any}
*/ let _tr = null;
const doc = undoManager.doc;
const scope = undoManager.scope;
transact(doc, (transaction)=>{
while(stack.length > 0 && undoManager.currStackItem === null){
const store = doc.store;
const stackItem = /** @type {StackItem} */ stack.pop();
/**
* @type {Set<Item>}
*/ const itemsToRedo = new Set();
/**
* @type {Array<Item>}
*/ const itemsToDelete = [];
let performedChange = false;
iterateDeletedStructs(transaction, stackItem.insertions, (struct)=>{
if (struct instanceof Item) {
if (struct.redone !== null) {
let { item, diff } = followRedone(store, struct.id);
if (diff > 0) item = getItemCleanStart(transaction, createID(item.id.client, item.id.clock + diff));
struct = item;
}
if (!struct.deleted && scope.some((type)=>isParentOf(type, /** @type {Item} */ struct))) itemsToDelete.push(struct);
}
});
iterateDeletedStructs(transaction, stackItem.deletions, (struct)=>{
if (struct instanceof Item && scope.some((type)=>isParentOf(type, struct)) && // Never redo structs in stackItem.insertions because they were created and deleted in the same capture interval.
!isDeleted(stackItem.insertions, struct.id)) itemsToRedo.add(struct);
});
itemsToRedo.forEach((struct)=>{
performedChange = redoItem(transaction, struct, itemsToRedo, stackItem.insertions, undoManager.ignoreRemoteMapChanges, undoManager) !== null || performedChange;
});
// We want to delete in reverse order so that children are deleted before
// parents, so we have more information available when items are filtered.
for(let i = itemsToDelete.length - 1; i >= 0; i--){
const item = itemsToDelete[i];
if (undoManager.deleteFilter(item)) {
item.delete(transaction);
performedChange = true;
}
}
undoManager.currStackItem = performedChange ? stackItem : null;
}
transaction.changed.forEach((subProps, type)=>{
// destroy search marker if necessary
if (subProps.has(null) && type._searchMarker) type._searchMarker.length = 0;
});
_tr = transaction;
}, undoManager);
const res = undoManager.currStackItem;
if (res != null) {
const changedParentTypes = _tr.changedParentTypes;
undoManager.emit("stack-item-popped", [
{
stackItem: res,
type: eventType,
changedParentTypes,
origin: undoManager
},
undoManager
]);
undoManager.currStackItem = null;
}
return res;
};
/**
* @typedef {Object} UndoManagerOptions
* @property {number} [UndoManagerOptions.captureTimeout=500]
* @property {function(Transaction):boolean} [UndoManagerOptions.captureTransaction] Do not capture changes of a Transaction if result false.
* @property {function(Item):boolean} [UndoManagerOptions.deleteFilter=()=>true] Sometimes
* it is necessary to filter what an Undo/Redo operation can delete. If this
* filter returns false, the type/item won't be deleted even it is in the
* undo/redo scope.
* @property {Set<any>} [UndoManagerOptions.trackedOrigins=new Set([null])]
* @property {boolean} [ignoreRemoteMapChanges] Experimental. By default, the UndoManager will never overwrite remote changes. Enable this property to enable overwriting remote changes on key-value changes (Y.Map, properties on Y.Xml, etc..).
* @property {Doc} [doc] The document that this UndoManager operates on. Only needed if typeScope is empty.
*/ /**
* @typedef {Object} StackItemEvent
* @property {StackItem} StackItemEvent.stackItem
* @property {any} StackItemEvent.origin
* @property {'undo'|'redo'} StackItemEvent.type
* @property {Map<AbstractType<YEvent<any>>,Array<YEvent<any>>>} StackItemEvent.changedParentTypes
*/ /**
* Fires 'stack-item-added' event when a stack item was added to either the undo- or
* the redo-stack. You may store additional stack information via the
* metadata property on `event.stackItem.meta` (it is a `Map` of metadata properties).
* Fires 'stack-item-popped' event when a stack item was popped from either the
* undo- or the redo-stack. You may restore the saved stack information from `event.stackItem.meta`.
*
* @extends {ObservableV2<{'stack-item-added':function(StackItemEvent, UndoManager):void, 'stack-item-popped': function(StackItemEvent, UndoManager):void, 'stack-cleared': function({ undoStackCleared: boolean, redoStackCleared: boolean }):void, 'stack-item-updated': function(StackItemEvent, UndoManager):void }>}
*/ class UndoManager extends (0, _observable.ObservableV2) {
/**
* @param {AbstractType<any>|Array<AbstractType<any>>} typeScope Accepts either a single type, or an array of types
* @param {UndoManagerOptions} options
*/ constructor(typeScope, { captureTimeout = 500, captureTransaction = (_tr)=>true, deleteFilter = ()=>true, trackedOrigins = new Set([
null
]), ignoreRemoteMapChanges = false, doc = /** @type {Doc} */ _array.isArray(typeScope) ? typeScope[0].doc : typeScope.doc } = {}){
super();
/**
* @type {Array<AbstractType<any>>}
*/ this.scope = [];
this.doc = doc;
this.addToScope(typeScope);
this.deleteFilter = deleteFilter;
trackedOrigins.add(this);
this.trackedOrigins = trackedOrigins;
this.captureTransaction = captureTransaction;
/**
* @type {Array<StackItem>}
*/ this.undoStack = [];
/**
* @type {Array<StackItem>}
*/ this.redoStack = [];
/**
* Whether the client is currently undoing (calling UndoManager.undo)
*
* @type {boolean}
*/ this.undoing = false;
this.redoing = false;
/**
* The currently popped stack item if UndoManager.undoing or UndoManager.redoing
*
* @type {StackItem|null}
*/ this.currStackItem = null;
this.lastChange = 0;
this.ignoreRemoteMapChanges = ignoreRemoteMapChanges;
this.captureTimeout = captureTimeout;
/**
* @param {Transaction} transaction
*/ this.afterTransactionHandler = (transaction)=>{
// Only track certain transactions
if (!this.captureTransaction(transaction) || !this.scope.some((type)=>transaction.changedParentTypes.has(type)) || !this.trackedOrigins.has(transaction.origin) && (!transaction.origin || !this.trackedOrigins.has(transaction.origin.constructor))) return;
const undoing = this.undoing;
const redoing = this.redoing;
const stack = undoing ? this.redoStack : this.undoStack;
if (undoing) this.stopCapturing(); // next undo should not be appended to last stack item
else if (!redoing) // neither undoing nor redoing: delete redoStack
this.clear(false, true);
const insertions = new DeleteSet();
transaction.afterState.forEach((endClock, client)=>{
const startClock = transaction.beforeState.get(client) || 0;
const len = endClock - startClock;
if (len > 0) addToDeleteSet(insertions, client, startClock, len);
});
const now = _time.getUnixTime();
let didAdd = false;
if (this.lastChange > 0 && now - this.lastChange < this.captureTimeout && stack.length > 0 && !undoing && !redoing) {
// append change to last stack op
const lastOp = stack[stack.length - 1];
lastOp.deletions = mergeDeleteSets([
lastOp.deletions,
transaction.deleteSet
]);
lastOp.insertions = mergeDeleteSets([
lastOp.insertions,
insertions
]);
} else {
// create a new stack op
stack.push(new StackItem(transaction.deleteSet, insertions));
didAdd = true;
}
if (!undoing && !redoing) this.lastChange = now;
// make sure that deleted structs are not gc'd
iterateDeletedStructs(transaction, transaction.deleteSet, /** @param {Item|GC} item */ (item)=>{
if (item instanceof Item && this.scope.some((type)=>isParentOf(type, item))) keepItem(item, true);
});
/**
* @type {[StackItemEvent, UndoManager]}
*/ const changeEvent = [
{
stackItem: stack[stack.length - 1],
origin: transaction.origin,
type: undoing ? "redo" : "undo",
changedParentTypes: transaction.changedParentTypes
},
this
];
if (didAdd) this.emit("stack-item-added", changeEvent);
else this.emit("stack-item-updated", changeEvent);
};
this.doc.on("afterTransaction", this.afterTransactionHandler);
this.doc.on("destroy", ()=>{
this.destroy();
});
}
/**
* @param {Array<AbstractType<any>> | AbstractType<any>} ytypes
*/ addToScope(ytypes) {
ytypes = _array.isArray(ytypes) ? ytypes : [
ytypes
];
ytypes.forEach((ytype)=>{
if (this.scope.every((yt)=>yt !== ytype)) {
if (ytype.doc !== this.doc) _logging.warn("[yjs#509] Not same Y.Doc"); // use MultiDocUndoManager instead. also see https://github.com/yjs/yjs/issues/509
this.scope.push(ytype);
}
});
}
/**
* @param {any} origin
*/ addTrackedOrigin(origin) {
this.trackedOrigins.add(origin);
}
/**
* @param {any} origin
*/ removeTrackedOrigin(origin) {
this.trackedOrigins.delete(origin);
}
clear(clearUndoStack = true, clearRedoStack = true) {
if (clearUndoStack && this.canUndo() || clearRedoStack && this.canRedo()) this.doc.transact((tr)=>{
if (clearUndoStack) {
this.undoStack.forEach((item)=>clearUndoManagerStackItem(tr, this, item));
this.undoStack = [];
}
if (clearRedoStack) {
this.redoStack.forEach((item)=>clearUndoManagerStackItem(tr, this, item));
this.redoStack = [];
}
this.emit("stack-cleared", [
{
undoStackCleared: clearUndoStack,
redoStackCleared: clearRedoStack
}
]);
});
}
/**
* UndoManager merges Undo-StackItem if they are created within time-gap
* smaller than `options.captureTimeout`. Call `um.stopCapturing()` so that the next
* StackItem won't be merged.
*
*
* @example
* // without stopCapturing
* ytext.insert(0, 'a')
* ytext.insert(1, 'b')
* um.undo()
* ytext.toString() // => '' (note that 'ab' was removed)
* // with stopCapturing
* ytext.insert(0, 'a')
* um.stopCapturing()
* ytext.insert(0, 'b')
* um.undo()
* ytext.toString() // => 'a' (note that only 'b' was removed)
*
*/ stopCapturing() {
this.lastChange = 0;
}
/**
* Undo last changes on type.
*
* @return {StackItem?} Returns StackItem if a change was applied
*/ undo() {
this.undoing = true;
let res;
try {
res = popStackItem(this, this.undoStack, "undo");
} finally{
this.undoing = false;
}
return res;
}
/**
* Redo last undo operation.
*
* @return {StackItem?} Returns StackItem if a change was applied
*/ redo() {
this.redoing = true;
let res;
try {
res = popStackItem(this, this.redoStack, "redo");
} finally{
this.redoing = false;
}
return res;
}
/**
* Are undo steps available?
*
* @return {boolean} `true` if undo is possible
*/ canUndo() {
return this.undoStack.length > 0;
}
/**
* Are redo steps available?
*
* @return {boolean} `true` if redo is possible
*/ canRedo() {
return this.redoStack.length > 0;
}
destroy() {
this.trackedOrigins.delete(this);
this.doc.off("afterTransaction", this.afterTransactionHandler);
super.destroy();
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
*/ function* lazyStructReaderGenerator(decoder) {
const numOfStateUpdates = _decoding.readVarUint(decoder.restDecoder);
for(let i = 0; i < numOfStateUpdates; i++){
const numberOfStructs = _decoding.readVarUint(decoder.restDecoder);
const client = decoder.readClient();
let clock = _decoding.readVarUint(decoder.restDecoder);
for(let i = 0; i < numberOfStructs; i++){
const info = decoder.readInfo();
// @todo use switch instead of ifs
if (info === 10) {
const len = _decoding.readVarUint(decoder.restDecoder);
yield new Skip(createID(client, clock), len);
clock += len;
} else if ((_binary.BITS5 & info) !== 0) {
const cantCopyParentInfo = (info & (_binary.BIT7 | _binary.BIT8)) === 0;
// If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`
// and we read the next string as parentYKey.
// It indicates how we store/retrieve parent from `y.share`
// @type {string|null}
const struct = new Item(createID(client, clock), null, (info & _binary.BIT8) === _binary.BIT8 ? decoder.readLeftID() : null, null, (info & _binary.BIT7) === _binary.BIT7 ? decoder.readRightID() : null, // @ts-ignore Force writing a string here.
cantCopyParentInfo ? decoder.readParentInfo() ? decoder.readString() : decoder.readLeftID() : null, cantCopyParentInfo && (info & _binary.BIT6) === _binary.BIT6 ? decoder.readString() : null, readItemContent(decoder, info) // item content
);
yield struct;
clock += struct.length;
} else {
const len = decoder.readLen();
yield new GC(createID(client, clock), len);
clock += len;
}
}
}
}
class LazyStructReader {
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @param {boolean} filterSkips
*/ constructor(decoder, filterSkips){
this.gen = lazyStructReaderGenerator(decoder);
/**
* @type {null | Item | Skip | GC}
*/ this.curr = null;
this.done = false;
this.filterSkips = filterSkips;
this.next();
}
/**
* @return {Item | GC | Skip |null}
*/ next() {
// ignore "Skip" structs
do this.curr = this.gen.next().value || null;
while (this.filterSkips && this.curr !== null && this.curr.constructor === Skip);
return this.curr;
}
}
/**
* @param {Uint8Array} update
*
*/ const logUpdate = (update)=>logUpdateV2(update, UpdateDecoderV1);
/**
* @param {Uint8Array} update
* @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} [YDecoder]
*
*/ const logUpdateV2 = (update, YDecoder = UpdateDecoderV2)=>{
const structs = [];
const updateDecoder = new YDecoder(_decoding.createDecoder(update));
const lazyDecoder = new LazyStructReader(updateDecoder, false);
for(let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next())structs.push(curr);
_logging.print("Structs: ", structs);
const ds = readDeleteSet(updateDecoder);
_logging.print("DeleteSet: ", ds);
};
/**
* @param {Uint8Array} update
*
*/ const decodeUpdate = (update)=>decodeUpdateV2(update, UpdateDecoderV1);
/**
* @param {Uint8Array} update
* @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} [YDecoder]
*
*/ const decodeUpdateV2 = (update, YDecoder = UpdateDecoderV2)=>{
const structs = [];
const updateDecoder = new YDecoder(_decoding.createDecoder(update));
const lazyDecoder = new LazyStructReader(updateDecoder, false);
for(let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next())structs.push(curr);
return {
structs,
ds: readDeleteSet(updateDecoder)
};
};
class LazyStructWriter {
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
*/ constructor(encoder){
this.currClient = 0;
this.startClock = 0;
this.written = 0;
this.encoder = encoder;
/**
* We want to write operations lazily, but also we need to know beforehand how many operations we want to write for each client.
*
* This kind of meta-information (#clients, #structs-per-client-written) is written to the restEncoder.
*
* We fragment the restEncoder and store a slice of it per-client until we know how many clients there are.
* When we flush (toUint8Array) we write the restEncoder using the fragments and the meta-information.
*
* @type {Array<{ written: number, restEncoder: Uint8Array }>}
*/ this.clientStructs = [];
}
}
/**
* @param {Array<Uint8Array>} updates
* @return {Uint8Array}
*/ const mergeUpdates = (updates)=>mergeUpdatesV2(updates, UpdateDecoderV1, UpdateEncoderV1);
/**
* @param {Uint8Array} update
* @param {typeof DSEncoderV1 | typeof DSEncoderV2} YEncoder
* @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} YDecoder
* @return {Uint8Array}
*/ const encodeStateVectorFromUpdateV2 = (update, YEncoder = DSEncoderV2, YDecoder = UpdateDecoderV2)=>{
const encoder = new YEncoder();
const updateDecoder = new LazyStructReader(new YDecoder(_decoding.createDecoder(update)), false);
let curr = updateDecoder.curr;
if (curr !== null) {
let size = 0;
let currClient = curr.id.client;
let stopCounting = curr.id.clock !== 0; // must start at 0
let currClock = stopCounting ? 0 : curr.id.clock + curr.length;
for(; curr !== null; curr = updateDecoder.next()){
if (currClient !== curr.id.client) {
if (currClock !== 0) {
size++;
// We found a new client
// write what we have to the encoder
_encoding.writeVarUint(encoder.restEncoder, currClient);
_encoding.writeVarUint(encoder.restEncoder, currClock);
}
currClient = curr.id.client;
currClock = 0;
stopCounting = curr.id.clock !== 0;
}
// we ignore skips
if (curr.constructor === Skip) stopCounting = true;
if (!stopCounting) currClock = curr.id.clock + curr.length;
}
// write what we have
if (currClock !== 0) {
size++;
_encoding.writeVarUint(encoder.restEncoder, currClient);
_encoding.writeVarUint(encoder.restEncoder, currClock);
}
// prepend the size of the state vector
const enc = _encoding.createEncoder();
_encoding.writeVarUint(enc, size);
_encoding.writeBinaryEncoder(enc, encoder.restEncoder);
encoder.restEncoder = enc;
return encoder.toUint8Array();
} else {
_encoding.writeVarUint(encoder.restEncoder, 0);
return encoder.toUint8Array();
}
};
/**
* @param {Uint8Array} update
* @return {Uint8Array}
*/ const encodeStateVectorFromUpdate = (update)=>encodeStateVectorFromUpdateV2(update, DSEncoderV1, UpdateDecoderV1);
/**
* @param {Uint8Array} update
* @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} YDecoder
* @return {{ from: Map<number,number>, to: Map<number,number> }}
*/ const parseUpdateMetaV2 = (update, YDecoder = UpdateDecoderV2)=>{
/**
* @type {Map<number, number>}
*/ const from = new Map();
/**
* @type {Map<number, number>}
*/ const to = new Map();
const updateDecoder = new LazyStructReader(new YDecoder(_decoding.createDecoder(update)), false);
let curr = updateDecoder.curr;
if (curr !== null) {
let currClient = curr.id.client;
let currClock = curr.id.clock;
// write the beginning to `from`
from.set(currClient, currClock);
for(; curr !== null; curr = updateDecoder.next()){
if (currClient !== curr.id.client) {
// We found a new client
// write the end to `to`
to.set(currClient, currClock);
// write the beginning to `from`
from.set(curr.id.client, curr.id.clock);
// update currClient
currClient = curr.id.client;
}
currClock = curr.id.clock + curr.length;
}
// write the end to `to`
to.set(currClient, currClock);
}
return {
from,
to
};
};
/**
* @param {Uint8Array} update
* @return {{ from: Map<number,number>, to: Map<number,number> }}
*/ const parseUpdateMeta = (update)=>parseUpdateMetaV2(update, UpdateDecoderV1);
/**
* This method is intended to slice any kind of struct and retrieve the right part.
* It does not handle side-effects, so it should only be used by the lazy-encoder.
*
* @param {Item | GC | Skip} left
* @param {number} diff
* @return {Item | GC}
*/ const sliceStruct = (left, diff)=>{
if (left.constructor === GC) {
const { client, clock } = left.id;
return new GC(createID(client, clock + diff), left.length - diff);
} else if (left.constructor === Skip) {
const { client, clock } = left.id;
return new Skip(createID(client, clock + diff), left.length - diff);
} else {
const leftItem = /** @type {Item} */ left;
const { client, clock } = leftItem.id;
return new Item(createID(client, clock + diff), null, createID(client, clock + diff - 1), null, leftItem.rightOrigin, leftItem.parent, leftItem.parentSub, leftItem.content.splice(diff));
}
};
/**
*
* This function works similarly to `readUpdateV2`.
*
* @param {Array<Uint8Array>} updates
* @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} [YDecoder]
* @param {typeof UpdateEncoderV1 | typeof UpdateEncoderV2} [YEncoder]
* @return {Uint8Array}
*/ const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = UpdateEncoderV2)=>{
if (updates.length === 1) return updates[0];
const updateDecoders = updates.map((update)=>new YDecoder(_decoding.createDecoder(update)));
let lazyStructDecoders = updateDecoders.map((decoder)=>new LazyStructReader(decoder, true));
/**
* @todo we don't need offset because we always slice before
* @type {null | { struct: Item | GC | Skip, offset: number }}
*/ let currWrite = null;
const updateEncoder = new YEncoder();
// write structs lazily
const lazyStructEncoder = new LazyStructWriter(updateEncoder);
// Note: We need to ensure that all lazyStructDecoders are fully consumed
// Note: Should merge document updates whenever possible - even from different updates
// Note: Should handle that some operations cannot be applied yet ()
while(true){
// Write higher clients first ⇒ sort by clientID & clock and remove decoders without content
lazyStructDecoders = lazyStructDecoders.filter((dec)=>dec.curr !== null);
lazyStructDecoders.sort(/** @type {function(any,any):number} */ (dec1, dec2)=>{
if (dec1.curr.id.client === dec2.curr.id.client) {
const clockDiff = dec1.curr.id.clock - dec2.curr.id.clock;
if (clockDiff === 0) // @todo remove references to skip since the structDecoders must filter Skips.
return dec1.curr.constructor === dec2.curr.constructor ? 0 : dec1.curr.constructor === Skip ? 1 : -1 // we are filtering skips anyway.
;
else return clockDiff;
} else return dec2.curr.id.client - dec1.curr.id.client;
});
if (lazyStructDecoders.length === 0) break;
const currDecoder = lazyStructDecoders[0];
// write from currDecoder until the next operation is from another client or if filler-struct
// then we need to reorder the decoders and find the next operation to write
const firstClient = /** @type {Item | GC} */ currDecoder.curr.id.client;
if (currWrite !== null) {
let curr = /** @type {Item | GC | null} */ currDecoder.curr;
let iterated = false;
// iterate until we find something that we haven't written already
// remember: first the high client-ids are written
while(curr !== null && curr.id.clock + curr.length <= currWrite.struct.id.clock + currWrite.struct.length && curr.id.client >= currWrite.struct.id.client){
curr = currDecoder.next();
iterated = true;
}
if (curr === null || // current decoder is empty
curr.id.client !== firstClient || // check whether there is another decoder that has has updates from `firstClient`
iterated && curr.id.clock > currWrite.struct.id.clock + currWrite.struct.length // the above while loop was used and we are potentially missing updates
) continue;
if (firstClient !== currWrite.struct.id.client) {
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset);
currWrite = {
struct: curr,
offset: 0
};
currDecoder.next();
} else if (currWrite.struct.id.clock + currWrite.struct.length < curr.id.clock) {
// @todo write currStruct & set currStruct = Skip(clock = currStruct.id.clock + currStruct.length, length = curr.id.clock - self.clock)
if (currWrite.struct.constructor === Skip) // extend existing skip
currWrite.struct.length = curr.id.clock + curr.length - currWrite.struct.id.clock;
else {
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset);
const diff = curr.id.clock - currWrite.struct.id.clock - currWrite.struct.length;
/**
* @type {Skip}
*/ const struct = new Skip(createID(firstClient, currWrite.struct.id.clock + currWrite.struct.length), diff);
currWrite = {
struct,
offset: 0
};
}
} else {
const diff = currWrite.struct.id.clock + currWrite.struct.length - curr.id.clock;
if (diff > 0) {
if (currWrite.struct.constructor === Skip) // prefer to slice Skip because the other struct might contain more information
currWrite.struct.length -= diff;
else curr = sliceStruct(curr, diff);
}
if (!currWrite.struct.mergeWith(/** @type {any} */ curr)) {
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset);
currWrite = {
struct: curr,
offset: 0
};
currDecoder.next();
}
}
} else {
currWrite = {
struct: /** @type {Item | GC} */ currDecoder.curr,
offset: 0
};
currDecoder.next();
}
for(let next = currDecoder.curr; next !== null && next.id.client === firstClient && next.id.clock === currWrite.struct.id.clock + currWrite.struct.length && next.constructor !== Skip; next = currDecoder.next()){
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset);
currWrite = {
struct: next,
offset: 0
};
}
}
if (currWrite !== null) {
writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset);
currWrite = null;
}
finishLazyStructWriting(lazyStructEncoder);
const dss = updateDecoders.map((decoder)=>readDeleteSet(decoder));
const ds = mergeDeleteSets(dss);
writeDeleteSet(updateEncoder, ds);
return updateEncoder.toUint8Array();
};
/**
* @param {Uint8Array} update
* @param {Uint8Array} sv
* @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} [YDecoder]
* @param {typeof UpdateEncoderV1 | typeof UpdateEncoderV2} [YEncoder]
*/ const diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder = UpdateEncoderV2)=>{
const state = decodeStateVector(sv);
const encoder = new YEncoder();
const lazyStructWriter = new LazyStructWriter(encoder);
const decoder = new YDecoder(_decoding.createDecoder(update));
const reader = new LazyStructReader(decoder, false);
while(reader.curr){
const curr = reader.curr;
const currClient = curr.id.client;
const svClock = state.get(currClient) || 0;
if (reader.curr.constructor === Skip) {
// the first written struct shouldn't be a skip
reader.next();
continue;
}
if (curr.id.clock + curr.length > svClock) {
writeStructToLazyStructWriter(lazyStructWriter, curr, _math.max(svClock - curr.id.clock, 0));
reader.next();
while(reader.curr && reader.curr.id.client === currClient){
writeStructToLazyStructWriter(lazyStructWriter, reader.curr, 0);
reader.next();
}
} else // read until something new comes up
while(reader.curr && reader.curr.id.client === currClient && reader.curr.id.clock + reader.curr.length <= svClock)reader.next();
}
finishLazyStructWriting(lazyStructWriter);
// write ds
const ds = readDeleteSet(decoder);
writeDeleteSet(encoder, ds);
return encoder.toUint8Array();
};
/**
* @param {Uint8Array} update
* @param {Uint8Array} sv
*/ const diffUpdate = (update, sv)=>diffUpdateV2(update, sv, UpdateDecoderV1, UpdateEncoderV1);
/**
* @param {LazyStructWriter} lazyWriter
*/ const flushLazyStructWriter = (lazyWriter)=>{
if (lazyWriter.written > 0) {
lazyWriter.clientStructs.push({
written: lazyWriter.written,
restEncoder: _encoding.toUint8Array(lazyWriter.encoder.restEncoder)
});
lazyWriter.encoder.restEncoder = _encoding.createEncoder();
lazyWriter.written = 0;
}
};
/**
* @param {LazyStructWriter} lazyWriter
* @param {Item | GC} struct
* @param {number} offset
*/ const writeStructToLazyStructWriter = (lazyWriter, struct, offset)=>{
// flush curr if we start another client
if (lazyWriter.written > 0 && lazyWriter.currClient !== struct.id.client) flushLazyStructWriter(lazyWriter);
if (lazyWriter.written === 0) {
lazyWriter.currClient = struct.id.client;
// write next client
lazyWriter.encoder.writeClient(struct.id.client);
// write startClock
_encoding.writeVarUint(lazyWriter.encoder.restEncoder, struct.id.clock + offset);
}
struct.write(lazyWriter.encoder, offset);
lazyWriter.written++;
};
/**
* Call this function when we collected all parts and want to
* put all the parts together. After calling this method,
* you can continue using the UpdateEncoder.
*
* @param {LazyStructWriter} lazyWriter
*/ const finishLazyStructWriting = (lazyWriter)=>{
flushLazyStructWriter(lazyWriter);
// this is a fresh encoder because we called flushCurr
const restEncoder = lazyWriter.encoder.restEncoder;
/**
* Now we put all the fragments together.
* This works similarly to `writeClientsStructs`
*/ // write # states that were updated - i.e. the clients
_encoding.writeVarUint(restEncoder, lazyWriter.clientStructs.length);
for(let i = 0; i < lazyWriter.clientStructs.length; i++){
const partStructs = lazyWriter.clientStructs[i];
/**
* Works similarly to `writeStructs`
*/ // write # encoded structs
_encoding.writeVarUint(restEncoder, partStructs.written);
// write the rest of the fragment
_encoding.writeUint8Array(restEncoder, partStructs.restEncoder);
}
};
/**
* @param {Uint8Array} update
* @param {function(Item|GC|Skip):Item|GC|Skip} blockTransformer
* @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} YDecoder
* @param {typeof UpdateEncoderV2 | typeof UpdateEncoderV1 } YEncoder
*/ const convertUpdateFormat = (update, blockTransformer, YDecoder, YEncoder)=>{
const updateDecoder = new YDecoder(_decoding.createDecoder(update));
const lazyDecoder = new LazyStructReader(updateDecoder, false);
const updateEncoder = new YEncoder();
const lazyWriter = new LazyStructWriter(updateEncoder);
for(let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next())writeStructToLazyStructWriter(lazyWriter, blockTransformer(curr), 0);
finishLazyStructWriting(lazyWriter);
const ds = readDeleteSet(updateDecoder);
writeDeleteSet(updateEncoder, ds);
return updateEncoder.toUint8Array();
};
/**
* @typedef {Object} ObfuscatorOptions
* @property {boolean} [ObfuscatorOptions.formatting=true]
* @property {boolean} [ObfuscatorOptions.subdocs=true]
* @property {boolean} [ObfuscatorOptions.yxml=true] Whether to obfuscate nodeName / hookName
*/ /**
* @param {ObfuscatorOptions} obfuscator
*/ const createObfuscator = ({ formatting = true, subdocs = true, yxml = true } = {})=>{
let i = 0;
const mapKeyCache = _map.create();
const nodeNameCache = _map.create();
const formattingKeyCache = _map.create();
const formattingValueCache = _map.create();
formattingValueCache.set(null, null); // end of a formatting range should always be the end of a formatting range
/**
* @param {Item|GC|Skip} block
* @return {Item|GC|Skip}
*/ return (block)=>{
switch(block.constructor){
case GC:
case Skip:
return block;
case Item:
{
const item = /** @type {Item} */ block;
const content = item.content;
switch(content.constructor){
case ContentDeleted:
break;
case ContentType:
if (yxml) {
const type = /** @type {ContentType} */ content.type;
if (type instanceof YXmlElement) type.nodeName = _map.setIfUndefined(nodeNameCache, type.nodeName, ()=>"node-" + i);
if (type instanceof YXmlHook) type.hookName = _map.setIfUndefined(nodeNameCache, type.hookName, ()=>"hook-" + i);
}
break;
case ContentAny:
{
const c = /** @type {ContentAny} */ content;
c.arr = c.arr.map(()=>i);
break;
}
case ContentBinary:
{
const c = /** @type {ContentBinary} */ content;
c.content = new Uint8Array([
i
]);
break;
}
case ContentDoc:
{
const c = /** @type {ContentDoc} */ content;
if (subdocs) {
c.opts = {};
c.doc.guid = i + "";
}
break;
}
case ContentEmbed:
{
const c = /** @type {ContentEmbed} */ content;
c.embed = {};
break;
}
case ContentFormat:
{
const c = /** @type {ContentFormat} */ content;
if (formatting) {
c.key = _map.setIfUndefined(formattingKeyCache, c.key, ()=>i + "");
c.value = _map.setIfUndefined(formattingValueCache, c.value, ()=>({
i
}));
}
break;
}
case ContentJSON:
{
const c = /** @type {ContentJSON} */ content;
c.arr = c.arr.map(()=>i);
break;
}
case ContentString:
{
const c = /** @type {ContentString} */ content;
c.str = _string.repeat(i % 10 + "", c.str.length);
break;
}
default:
// unknown content type
_error.unexpectedCase();
}
if (item.parentSub) item.parentSub = _map.setIfUndefined(mapKeyCache, item.parentSub, ()=>i + "");
i++;
return block;
}
default:
// unknown block-type
_error.unexpectedCase();
}
};
};
/**
* This function obfuscates the content of a Yjs update. This is useful to share
* buggy Yjs documents while significantly limiting the possibility that a
* developer can on the user. Note that it might still be possible to deduce
* some information by analyzing the "structure" of the document or by analyzing
* the typing behavior using the CRDT-related metadata that is still kept fully
* intact.
*
* @param {Uint8Array} update
* @param {ObfuscatorOptions} [opts]
*/ const obfuscateUpdate = (update, opts)=>convertUpdateFormat(update, createObfuscator(opts), UpdateDecoderV1, UpdateEncoderV1);
/**
* @param {Uint8Array} update
* @param {ObfuscatorOptions} [opts]
*/ const obfuscateUpdateV2 = (update, opts)=>convertUpdateFormat(update, createObfuscator(opts), UpdateDecoderV2, UpdateEncoderV2);
/**
* @param {Uint8Array} update
*/ const convertUpdateFormatV1ToV2 = (update)=>convertUpdateFormat(update, _function.id, UpdateDecoderV1, UpdateEncoderV2);
/**
* @param {Uint8Array} update
*/ const convertUpdateFormatV2ToV1 = (update)=>convertUpdateFormat(update, _function.id, UpdateDecoderV2, UpdateEncoderV1);
const errorComputeChanges = "You must not compute changes after the event-handler fired.";
/**
* @template {AbstractType<any>} T
* YEvent describes the changes on a YType.
*/ class YEvent {
/**
* @param {T} target The changed type.
* @param {Transaction} transaction
*/ constructor(target, transaction){
/**
* The type on which this event was created on.
* @type {T}
*/ this.target = target;
/**
* The current target on which the observe callback is called.
* @type {AbstractType<any>}
*/ this.currentTarget = target;
/**
* The transaction that triggered this event.
* @type {Transaction}
*/ this.transaction = transaction;
/**
* @type {Object|null}
*/ this._changes = null;
/**
* @type {null | Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
*/ this._keys = null;
/**
* @type {null | Array<{ insert?: string | Array<any> | object | AbstractType<any>, retain?: number, delete?: number, attributes?: Object<string, any> }>}
*/ this._delta = null;
/**
* @type {Array<string|number>|null}
*/ this._path = null;
}
/**
* Computes the path from `y` to the changed type.
*
* @todo v14 should standardize on path: Array<{parent, index}> because that is easier to work with.
*
* The following property holds:
* @example
* let type = y
* event.path.forEach(dir => {
* type = type.get(dir)
* })
* type === event.target // => true
*/ get path() {
return this._path || (this._path = getPathTo(this.currentTarget, this.target));
}
/**
* Check if a struct is deleted by this event.
*
* In contrast to change.deleted, this method also returns true if the struct was added and then deleted.
*
* @param {AbstractStruct} struct
* @return {boolean}
*/ deletes(struct) {
return isDeleted(this.transaction.deleteSet, struct.id);
}
/**
* @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
*/ get keys() {
if (this._keys === null) {
if (this.transaction.doc._transactionCleanups.length === 0) throw _error.create(errorComputeChanges);
const keys = new Map();
const target = this.target;
const changed = /** @type Set<string|null> */ this.transaction.changed.get(target);
changed.forEach((key)=>{
if (key !== null) {
const item = /** @type {Item} */ target._map.get(key);
/**
* @type {'delete' | 'add' | 'update'}
*/ let action;
let oldValue;
if (this.adds(item)) {
let prev = item.left;
while(prev !== null && this.adds(prev))prev = prev.left;
if (this.deletes(item)) {
if (prev !== null && this.deletes(prev)) {
action = "delete";
oldValue = _array.last(prev.content.getContent());
} else return;
} else if (prev !== null && this.deletes(prev)) {
action = "update";
oldValue = _array.last(prev.content.getContent());
} else {
action = "add";
oldValue = undefined;
}
} else {
if (this.deletes(item)) {
action = "delete";
oldValue = _array.last(/** @type {Item} */ item.content.getContent());
} else return; // nop
}
keys.set(key, {
action,
oldValue
});
}
});
this._keys = keys;
}
return this._keys;
}
/**
* This is a computed property. Note that this can only be safely computed during the
* event call. Computing this property after other changes happened might result in
* unexpected behavior (incorrect computation of deltas). A safe way to collect changes
* is to store the `changes` or the `delta` object. Avoid storing the `transaction` object.
*
* @type {Array<{insert?: string | Array<any> | object | AbstractType<any>, retain?: number, delete?: number, attributes?: Object<string, any>}>}
*/ get delta() {
return this.changes.delta;
}
/**
* Check if a struct is added by this event.
*
* In contrast to change.deleted, this method also returns true if the struct was added and then deleted.
*
* @param {AbstractStruct} struct
* @return {boolean}
*/ adds(struct) {
return struct.id.clock >= (this.transaction.beforeState.get(struct.id.client) || 0);
}
/**
* This is a computed property. Note that this can only be safely computed during the
* event call. Computing this property after other changes happened might result in
* unexpected behavior (incorrect computation of deltas). A safe way to collect changes
* is to store the `changes` or the `delta` object. Avoid storing the `transaction` object.
*
* @type {{added:Set<Item>,deleted:Set<Item>,keys:Map<string,{action:'add'|'update'|'delete',oldValue:any}>,delta:Array<{insert?:Array<any>|string, delete?:number, retain?:number}>}}
*/ get changes() {
let changes = this._changes;
if (changes === null) {
if (this.transaction.doc._transactionCleanups.length === 0) throw _error.create(errorComputeChanges);
const target = this.target;
const added = _set.create();
const deleted = _set.create();
/**
* @type {Array<{insert:Array<any>}|{delete:number}|{retain:number}>}
*/ const delta = [];
changes = {
added,
deleted,
delta,
keys: this.keys
};
const changed = /** @type Set<string|null> */ this.transaction.changed.get(target);
if (changed.has(null)) {
/**
* @type {any}
*/ let lastOp = null;
const packOp = ()=>{
if (lastOp) delta.push(lastOp);
};
for(let item = target._start; item !== null; item = item.right){
if (item.deleted) {
if (this.deletes(item) && !this.adds(item)) {
if (lastOp === null || lastOp.delete === undefined) {
packOp();
lastOp = {
delete: 0
};
}
lastOp.delete += item.length;
deleted.add(item);
} // else nop
} else if (this.adds(item)) {
if (lastOp === null || lastOp.insert === undefined) {
packOp();
lastOp = {
insert: []
};
}
lastOp.insert = lastOp.insert.concat(item.content.getContent());
added.add(item);
} else {
if (lastOp === null || lastOp.retain === undefined) {
packOp();
lastOp = {
retain: 0
};
}
lastOp.retain += item.length;
}
}
if (lastOp !== null && lastOp.retain === undefined) packOp();
}
this._changes = changes;
}
return /** @type {any} */ changes;
}
}
/**
* Compute the path from this type to the specified target.
*
* @example
* // `child` should be accessible via `type.get(path[0]).get(path[1])..`
* const path = type.getPathTo(child)
* // assuming `type instanceof YArray`
* console.log(path) // might look like => [2, 'key1']
* child === type.get(path[0]).get(path[1])
*
* @param {AbstractType<any>} parent
* @param {AbstractType<any>} child target
* @return {Array<string|number>} Path to the target
*
* @private
* @function
*/ const getPathTo = (parent, child)=>{
const path = [];
while(child._item !== null && child !== parent){
if (child._item.parentSub !== null) // parent is map-ish
path.unshift(child._item.parentSub);
else {
// parent is array-ish
let i = 0;
let c = /** @type {AbstractType<any>} */ child._item.parent._start;
while(c !== child._item && c !== null){
if (!c.deleted && c.countable) i += c.length;
c = c.right;
}
path.unshift(i);
}
child = /** @type {AbstractType<any>} */ child._item.parent;
}
return path;
};
const maxSearchMarker = 80;
/**
* A unique timestamp that identifies each marker.
*
* Time is relative,.. this is more like an ever-increasing clock.
*
* @type {number}
*/ let globalSearchMarkerTimestamp = 0;
class ArraySearchMarker {
/**
* @param {Item} p
* @param {number} index
*/ constructor(p, index){
p.marker = true;
this.p = p;
this.index = index;
this.timestamp = globalSearchMarkerTimestamp++;
}
}
/**
* @param {ArraySearchMarker} marker
*/ const refreshMarkerTimestamp = (marker)=>{
marker.timestamp = globalSearchMarkerTimestamp++;
};
/**
* This is rather complex so this function is the only thing that should overwrite a marker
*
* @param {ArraySearchMarker} marker
* @param {Item} p
* @param {number} index
*/ const overwriteMarker = (marker, p, index)=>{
marker.p.marker = false;
marker.p = p;
p.marker = true;
marker.index = index;
marker.timestamp = globalSearchMarkerTimestamp++;
};
/**
* @param {Array<ArraySearchMarker>} searchMarker
* @param {Item} p
* @param {number} index
*/ const markPosition = (searchMarker, p, index)=>{
if (searchMarker.length >= maxSearchMarker) {
// override oldest marker (we don't want to create more objects)
const marker = searchMarker.reduce((a, b)=>a.timestamp < b.timestamp ? a : b);
overwriteMarker(marker, p, index);
return marker;
} else {
// create new marker
const pm = new ArraySearchMarker(p, index);
searchMarker.push(pm);
return pm;
}
};
/**
* Search marker help us to find positions in the associative array faster.
*
* They speed up the process of finding a position without much bookkeeping.
*
* A maximum of `maxSearchMarker` objects are created.
*
* This function always returns a refreshed marker (updated timestamp)
*
* @param {AbstractType<any>} yarray
* @param {number} index
*/ const findMarker = (yarray, index)=>{
if (yarray._start === null || index === 0 || yarray._searchMarker === null) return null;
const marker = yarray._searchMarker.length === 0 ? null : yarray._searchMarker.reduce((a, b)=>_math.abs(index - a.index) < _math.abs(index - b.index) ? a : b);
let p = yarray._start;
let pindex = 0;
if (marker !== null) {
p = marker.p;
pindex = marker.index;
refreshMarkerTimestamp(marker); // we used it, we might need to use it again
}
// iterate to right if possible
while(p.right !== null && pindex < index){
if (!p.deleted && p.countable) {
if (index < pindex + p.length) break;
pindex += p.length;
}
p = p.right;
}
// iterate to left if necessary (might be that pindex > index)
while(p.left !== null && pindex > index){
p = p.left;
if (!p.deleted && p.countable) pindex -= p.length;
}
// we want to make sure that p can't be merged with left, because that would screw up everything
// in that cas just return what we have (it is most likely the best marker anyway)
// iterate to left until p can't be merged with left
while(p.left !== null && p.left.id.client === p.id.client && p.left.id.clock + p.left.length === p.id.clock){
p = p.left;
if (!p.deleted && p.countable) pindex -= p.length;
}
// @todo remove!
// assure position
// {
// let start = yarray._start
// let pos = 0
// while (start !== p) {
// if (!start.deleted && start.countable) {
// pos += start.length
// }
// start = /** @type {Item} */ (start.right)
// }
// if (pos !== pindex) {
// debugger
// throw new Error('Gotcha position fail!')
// }
// }
// if (marker) {
// if (window.lengthes == null) {
// window.lengthes = []
// window.getLengthes = () => window.lengthes.sort((a, b) => a - b)
// }
// window.lengthes.push(marker.index - pindex)
// console.log('distance', marker.index - pindex, 'len', p && p.parent.length)
// }
if (marker !== null && _math.abs(marker.index - pindex) < /** @type {YText|YArray<any>} */ p.parent.length / maxSearchMarker) {
// adjust existing marker
overwriteMarker(marker, p, pindex);
return marker;
} else // create new marker
return markPosition(yarray._searchMarker, p, pindex);
};
/**
* Update markers when a change happened.
*
* This should be called before doing a deletion!
*
* @param {Array<ArraySearchMarker>} searchMarker
* @param {number} index
* @param {number} len If insertion, len is positive. If deletion, len is negative.
*/ const updateMarkerChanges = (searchMarker, index, len)=>{
for(let i = searchMarker.length - 1; i >= 0; i--){
const m = searchMarker[i];
if (len > 0) {
/**
* @type {Item|null}
*/ let p = m.p;
p.marker = false;
// Ideally we just want to do a simple position comparison, but this will only work if
// search markers don't point to deleted items for formats.
// Iterate marker to prev undeleted countable position so we know what to do when updating a position
while(p && (p.deleted || !p.countable)){
p = p.left;
if (p && !p.deleted && p.countable) // adjust position. the loop should break now
m.index -= p.length;
}
if (p === null || p.marker === true) {
// remove search marker if updated position is null or if position is already marked
searchMarker.splice(i, 1);
continue;
}
m.p = p;
p.marker = true;
}
if (index < m.index || len > 0 && index === m.index) m.index = _math.max(index, m.index + len);
}
};
/**
* Accumulate all (list) children of a type and return them as an Array.
*
* @param {AbstractType<any>} t
* @return {Array<Item>}
*/ const getTypeChildren = (t)=>{
let s = t._start;
const arr = [];
while(s){
arr.push(s);
s = s.right;
}
return arr;
};
/**
* Call event listeners with an event. This will also add an event to all
* parents (for `.observeDeep` handlers).
*
* @template EventType
* @param {AbstractType<EventType>} type
* @param {Transaction} transaction
* @param {EventType} event
*/ const callTypeObservers = (type, transaction, event)=>{
const changedType = type;
const changedParentTypes = transaction.changedParentTypes;
while(true){
// @ts-ignore
_map.setIfUndefined(changedParentTypes, type, ()=>[]).push(event);
if (type._item === null) break;
type = /** @type {AbstractType<any>} */ type._item.parent;
}
callEventHandlerListeners(changedType._eH, event, transaction);
};
/**
* @template EventType
* Abstract Yjs Type class
*/ class AbstractType {
constructor(){
/**
* @type {Item|null}
*/ this._item = null;
/**
* @type {Map<string,Item>}
*/ this._map = new Map();
/**
* @type {Item|null}
*/ this._start = null;
/**
* @type {Doc|null}
*/ this.doc = null;
this._length = 0;
/**
* Event handlers
* @type {EventHandler<EventType,Transaction>}
*/ this._eH = createEventHandler();
/**
* Deep event handlers
* @type {EventHandler<Array<YEvent<any>>,Transaction>}
*/ this._dEH = createEventHandler();
/**
* @type {null | Array<ArraySearchMarker>}
*/ this._searchMarker = null;
}
/**
* @return {AbstractType<any>|null}
*/ get parent() {
return this._item ? /** @type {AbstractType<any>} */ this._item.parent : null;
}
/**
* Integrate this type into the Yjs instance.
*
* * Save this struct in the os
* * This type is sent to other client
* * Observer functions are fired
*
* @param {Doc} y The Yjs instance
* @param {Item|null} item
*/ _integrate(y, item) {
this.doc = y;
this._item = item;
}
/**
* @return {AbstractType<EventType>}
*/ _copy() {
throw _error.methodUnimplemented();
}
/**
* Makes a copy of this data type that can be included somewhere else.
*
* Note that the content is only readable _after_ it has been included somewhere in the Ydoc.
*
* @return {AbstractType<EventType>}
*/ clone() {
throw _error.methodUnimplemented();
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} _encoder
*/ _write(_encoder) {}
/**
* The first non-deleted item
*/ get _first() {
let n = this._start;
while(n !== null && n.deleted)n = n.right;
return n;
}
/**
* Creates YEvent and calls all type observers.
* Must be implemented by each type.
*
* @param {Transaction} transaction
* @param {Set<null|string>} _parentSubs Keys changed on this type. `null` if list was modified.
*/ _callObserver(transaction, _parentSubs) {
if (!transaction.local && this._searchMarker) this._searchMarker.length = 0;
}
/**
* Observe all events that are created on this type.
*
* @param {function(EventType, Transaction):void} f Observer function
*/ observe(f) {
addEventHandlerListener(this._eH, f);
}
/**
* Observe all events that are created by this type and its children.
*
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
*/ observeDeep(f) {
addEventHandlerListener(this._dEH, f);
}
/**
* Unregister an observer function.
*
* @param {function(EventType,Transaction):void} f Observer function
*/ unobserve(f) {
removeEventHandlerListener(this._eH, f);
}
/**
* Unregister an observer function.
*
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
*/ unobserveDeep(f) {
removeEventHandlerListener(this._dEH, f);
}
/**
* @abstract
* @return {any}
*/ toJSON() {}
}
/**
* @param {AbstractType<any>} type
* @param {number} start
* @param {number} end
* @return {Array<any>}
*
* @private
* @function
*/ const typeListSlice = (type, start, end)=>{
if (start < 0) start = type._length + start;
if (end < 0) end = type._length + end;
let len = end - start;
const cs = [];
let n = type._start;
while(n !== null && len > 0){
if (n.countable && !n.deleted) {
const c = n.content.getContent();
if (c.length <= start) start -= c.length;
else {
for(let i = start; i < c.length && len > 0; i++){
cs.push(c[i]);
len--;
}
start = 0;
}
}
n = n.right;
}
return cs;
};
/**
* @param {AbstractType<any>} type
* @return {Array<any>}
*
* @private
* @function
*/ const typeListToArray = (type)=>{
const cs = [];
let n = type._start;
while(n !== null){
if (n.countable && !n.deleted) {
const c = n.content.getContent();
for(let i = 0; i < c.length; i++)cs.push(c[i]);
}
n = n.right;
}
return cs;
};
/**
* @param {AbstractType<any>} type
* @param {Snapshot} snapshot
* @return {Array<any>}
*
* @private
* @function
*/ const typeListToArraySnapshot = (type, snapshot)=>{
const cs = [];
let n = type._start;
while(n !== null){
if (n.countable && isVisible(n, snapshot)) {
const c = n.content.getContent();
for(let i = 0; i < c.length; i++)cs.push(c[i]);
}
n = n.right;
}
return cs;
};
/**
* Executes a provided function on once on every element of this YArray.
*
* @param {AbstractType<any>} type
* @param {function(any,number,any):void} f A function to execute on every element of this YArray.
*
* @private
* @function
*/ const typeListForEach = (type, f)=>{
let index = 0;
let n = type._start;
while(n !== null){
if (n.countable && !n.deleted) {
const c = n.content.getContent();
for(let i = 0; i < c.length; i++)f(c[i], index++, type);
}
n = n.right;
}
};
/**
* @template C,R
* @param {AbstractType<any>} type
* @param {function(C,number,AbstractType<any>):R} f
* @return {Array<R>}
*
* @private
* @function
*/ const typeListMap = (type, f)=>{
/**
* @type {Array<any>}
*/ const result = [];
typeListForEach(type, (c, i)=>{
result.push(f(c, i, type));
});
return result;
};
/**
* @param {AbstractType<any>} type
* @return {IterableIterator<any>}
*
* @private
* @function
*/ const typeListCreateIterator = (type)=>{
let n = type._start;
/**
* @type {Array<any>|null}
*/ let currentContent = null;
let currentContentIndex = 0;
return {
[Symbol.iterator] () {
return this;
},
next: ()=>{
// find some content
if (currentContent === null) {
while(n !== null && n.deleted)n = n.right;
// check if we reached the end, no need to check currentContent, because it does not exist
if (n === null) return {
done: true,
value: undefined
};
// we found n, so we can set currentContent
currentContent = n.content.getContent();
currentContentIndex = 0;
n = n.right; // we used the content of n, now iterate to next
}
const value = currentContent[currentContentIndex++];
// check if we need to empty currentContent
if (currentContent.length <= currentContentIndex) currentContent = null;
return {
done: false,
value
};
}
};
};
/**
* @param {AbstractType<any>} type
* @param {number} index
* @return {any}
*
* @private
* @function
*/ const typeListGet = (type, index)=>{
const marker = findMarker(type, index);
let n = type._start;
if (marker !== null) {
n = marker.p;
index -= marker.index;
}
for(; n !== null; n = n.right)if (!n.deleted && n.countable) {
if (index < n.length) return n.content.getContent()[index];
index -= n.length;
}
};
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {Item?} referenceItem
* @param {Array<Object<string,any>|Array<any>|boolean|number|null|string|Uint8Array>} content
*
* @private
* @function
*/ const typeListInsertGenericsAfter = (transaction, parent, referenceItem, content)=>{
let left = referenceItem;
const doc = transaction.doc;
const ownClientId = doc.clientID;
const store = doc.store;
const right = referenceItem === null ? parent._start : referenceItem.right;
/**
* @type {Array<Object|Array<any>|number|null>}
*/ let jsonContent = [];
const packJsonContent = ()=>{
if (jsonContent.length > 0) {
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentAny(jsonContent));
left.integrate(transaction, 0);
jsonContent = [];
}
};
content.forEach((c)=>{
if (c === null) jsonContent.push(c);
else switch(c.constructor){
case Number:
case Object:
case Boolean:
case Array:
case String:
jsonContent.push(c);
break;
default:
packJsonContent();
switch(c.constructor){
case Uint8Array:
case ArrayBuffer:
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentBinary(new Uint8Array(/** @type {Uint8Array} */ c)));
left.integrate(transaction, 0);
break;
case Doc:
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentDoc(/** @type {Doc} */ c));
left.integrate(transaction, 0);
break;
default:
if (c instanceof AbstractType) {
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentType(c));
left.integrate(transaction, 0);
} else throw new Error("Unexpected content type in insert operation");
}
}
});
packJsonContent();
};
const lengthExceeded = ()=>_error.create("Length exceeded!");
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {number} index
* @param {Array<Object<string,any>|Array<any>|number|null|string|Uint8Array>} content
*
* @private
* @function
*/ const typeListInsertGenerics = (transaction, parent, index, content)=>{
if (index > parent._length) throw lengthExceeded();
if (index === 0) {
if (parent._searchMarker) updateMarkerChanges(parent._searchMarker, index, content.length);
return typeListInsertGenericsAfter(transaction, parent, null, content);
}
const startIndex = index;
const marker = findMarker(parent, index);
let n = parent._start;
if (marker !== null) {
n = marker.p;
index -= marker.index;
// we need to iterate one to the left so that the algorithm works
if (index === 0) {
// @todo refactor this as it actually doesn't consider formats
n = n.prev; // important! get the left undeleted item so that we can actually decrease index
index += n && n.countable && !n.deleted ? n.length : 0;
}
}
for(; n !== null; n = n.right)if (!n.deleted && n.countable) {
if (index <= n.length) {
if (index < n.length) // insert in-between
getItemCleanStart(transaction, createID(n.id.client, n.id.clock + index));
break;
}
index -= n.length;
}
if (parent._searchMarker) updateMarkerChanges(parent._searchMarker, startIndex, content.length);
return typeListInsertGenericsAfter(transaction, parent, n, content);
};
/**
* Pushing content is special as we generally want to push after the last item. So we don't have to update
* the serach marker.
*
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {Array<Object<string,any>|Array<any>|number|null|string|Uint8Array>} content
*
* @private
* @function
*/ const typeListPushGenerics = (transaction, parent, content)=>{
// Use the marker with the highest index and iterate to the right.
const marker = (parent._searchMarker || []).reduce((maxMarker, currMarker)=>currMarker.index > maxMarker.index ? currMarker : maxMarker, {
index: 0,
p: parent._start
});
let n = marker.p;
if (n) while(n.right)n = n.right;
return typeListInsertGenericsAfter(transaction, parent, n, content);
};
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {number} index
* @param {number} length
*
* @private
* @function
*/ const typeListDelete = (transaction, parent, index, length)=>{
if (length === 0) return;
const startIndex = index;
const startLength = length;
const marker = findMarker(parent, index);
let n = parent._start;
if (marker !== null) {
n = marker.p;
index -= marker.index;
}
// compute the first item to be deleted
for(; n !== null && index > 0; n = n.right)if (!n.deleted && n.countable) {
if (index < n.length) getItemCleanStart(transaction, createID(n.id.client, n.id.clock + index));
index -= n.length;
}
// delete all items until done
while(length > 0 && n !== null){
if (!n.deleted) {
if (length < n.length) getItemCleanStart(transaction, createID(n.id.client, n.id.clock + length));
n.delete(transaction);
length -= n.length;
}
n = n.right;
}
if (length > 0) throw lengthExceeded();
if (parent._searchMarker) updateMarkerChanges(parent._searchMarker, startIndex, -startLength + length /* in case we remove the above exception */ );
};
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {string} key
*
* @private
* @function
*/ const typeMapDelete = (transaction, parent, key)=>{
const c = parent._map.get(key);
if (c !== undefined) c.delete(transaction);
};
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {string} key
* @param {Object|number|null|Array<any>|string|Uint8Array|AbstractType<any>} value
*
* @private
* @function
*/ const typeMapSet = (transaction, parent, key, value)=>{
const left = parent._map.get(key) || null;
const doc = transaction.doc;
const ownClientId = doc.clientID;
let content;
if (value == null) content = new ContentAny([
value
]);
else switch(value.constructor){
case Number:
case Object:
case Boolean:
case Array:
case String:
content = new ContentAny([
value
]);
break;
case Uint8Array:
content = new ContentBinary(/** @type {Uint8Array} */ value);
break;
case Doc:
content = new ContentDoc(/** @type {Doc} */ value);
break;
default:
if (value instanceof AbstractType) content = new ContentType(value);
else throw new Error("Unexpected content type");
}
new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, null, null, parent, key, content).integrate(transaction, 0);
};
/**
* @param {AbstractType<any>} parent
* @param {string} key
* @return {Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined}
*
* @private
* @function
*/ const typeMapGet = (parent, key)=>{
const val = parent._map.get(key);
return val !== undefined && !val.deleted ? val.content.getContent()[val.length - 1] : undefined;
};
/**
* @param {AbstractType<any>} parent
* @return {Object<string,Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined>}
*
* @private
* @function
*/ const typeMapGetAll = (parent)=>{
/**
* @type {Object<string,any>}
*/ const res = {};
parent._map.forEach((value, key)=>{
if (!value.deleted) res[key] = value.content.getContent()[value.length - 1];
});
return res;
};
/**
* @param {AbstractType<any>} parent
* @param {string} key
* @return {boolean}
*
* @private
* @function
*/ const typeMapHas = (parent, key)=>{
const val = parent._map.get(key);
return val !== undefined && !val.deleted;
};
/**
* @param {AbstractType<any>} parent
* @param {string} key
* @param {Snapshot} snapshot
* @return {Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined}
*
* @private
* @function
*/ const typeMapGetSnapshot = (parent, key, snapshot)=>{
let v = parent._map.get(key) || null;
while(v !== null && (!snapshot.sv.has(v.id.client) || v.id.clock >= (snapshot.sv.get(v.id.client) || 0)))v = v.left;
return v !== null && isVisible(v, snapshot) ? v.content.getContent()[v.length - 1] : undefined;
};
/**
* @param {AbstractType<any>} parent
* @param {Snapshot} snapshot
* @return {Object<string,Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined>}
*
* @private
* @function
*/ const typeMapGetAllSnapshot = (parent, snapshot)=>{
/**
* @type {Object<string,any>}
*/ const res = {};
parent._map.forEach((value, key)=>{
/**
* @type {Item|null}
*/ let v = value;
while(v !== null && (!snapshot.sv.has(v.id.client) || v.id.clock >= (snapshot.sv.get(v.id.client) || 0)))v = v.left;
if (v !== null && isVisible(v, snapshot)) res[key] = v.content.getContent()[v.length - 1];
});
return res;
};
/**
* @param {Map<string,Item>} map
* @return {IterableIterator<Array<any>>}
*
* @private
* @function
*/ const createMapIterator = (map)=>_iterator.iteratorFilter(map.entries(), /** @param {any} entry */ (entry)=>!entry[1].deleted);
/**
* @module YArray
*/ /**
* Event that describes the changes on a YArray
* @template T
* @extends YEvent<YArray<T>>
*/ class YArrayEvent extends YEvent {
}
/**
* A shared Array implementation.
* @template T
* @extends AbstractType<YArrayEvent<T>>
* @implements {Iterable<T>}
*/ class YArray extends AbstractType {
constructor(){
super();
/**
* @type {Array<any>?}
* @private
*/ this._prelimContent = [];
/**
* @type {Array<ArraySearchMarker>}
*/ this._searchMarker = [];
}
/**
* Construct a new YArray containing the specified items.
* @template {Object<string,any>|Array<any>|number|null|string|Uint8Array} T
* @param {Array<T>} items
* @return {YArray<T>}
*/ static from(items) {
/**
* @type {YArray<T>}
*/ const a = new YArray();
a.push(items);
return a;
}
/**
* Integrate this type into the Yjs instance.
*
* * Save this struct in the os
* * This type is sent to other client
* * Observer functions are fired
*
* @param {Doc} y The Yjs instance
* @param {Item} item
*/ _integrate(y, item) {
super._integrate(y, item);
this.insert(0, /** @type {Array<any>} */ this._prelimContent);
this._prelimContent = null;
}
/**
* @return {YArray<T>}
*/ _copy() {
return new YArray();
}
/**
* Makes a copy of this data type that can be included somewhere else.
*
* Note that the content is only readable _after_ it has been included somewhere in the Ydoc.
*
* @return {YArray<T>}
*/ clone() {
/**
* @type {YArray<T>}
*/ const arr = new YArray();
arr.insert(0, this.toArray().map((el)=>el instanceof AbstractType ? /** @type {typeof el} */ el.clone() : el));
return arr;
}
get length() {
return this._prelimContent === null ? this._length : this._prelimContent.length;
}
/**
* Creates YArrayEvent and calls observers.
*
* @param {Transaction} transaction
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
*/ _callObserver(transaction, parentSubs) {
super._callObserver(transaction, parentSubs);
callTypeObservers(this, transaction, new YArrayEvent(this, transaction));
}
/**
* Inserts new content at an index.
*
* Important: This function expects an array of content. Not just a content
* object. The reason for this "weirdness" is that inserting several elements
* is very efficient when it is done as a single operation.
*
* @example
* // Insert character 'a' at position 0
* yarray.insert(0, ['a'])
* // Insert numbers 1, 2 at position 1
* yarray.insert(1, [1, 2])
*
* @param {number} index The index to insert content at.
* @param {Array<T>} content The array of content
*/ insert(index, content) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeListInsertGenerics(transaction, this, index, /** @type {any} */ content);
});
else /** @type {Array<any>} */ this._prelimContent.splice(index, 0, ...content);
}
/**
* Appends content to this YArray.
*
* @param {Array<T>} content Array of content to append.
*
* @todo Use the following implementation in all types.
*/ push(content) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeListPushGenerics(transaction, this, /** @type {any} */ content);
});
else /** @type {Array<any>} */ this._prelimContent.push(...content);
}
/**
* Prepends content to this YArray.
*
* @param {Array<T>} content Array of content to prepend.
*/ unshift(content) {
this.insert(0, content);
}
/**
* Deletes elements starting from an index.
*
* @param {number} index Index at which to start deleting elements
* @param {number} length The number of elements to remove. Defaults to 1.
*/ delete(index, length = 1) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeListDelete(transaction, this, index, length);
});
else /** @type {Array<any>} */ this._prelimContent.splice(index, length);
}
/**
* Returns the i-th element from a YArray.
*
* @param {number} index The index of the element to return from the YArray
* @return {T}
*/ get(index) {
return typeListGet(this, index);
}
/**
* Transforms this YArray to a JavaScript Array.
*
* @return {Array<T>}
*/ toArray() {
return typeListToArray(this);
}
/**
* Returns a portion of this YArray into a JavaScript Array selected
* from start to end (end not included).
*
* @param {number} [start]
* @param {number} [end]
* @return {Array<T>}
*/ slice(start = 0, end = this.length) {
return typeListSlice(this, start, end);
}
/**
* Transforms this Shared Type to a JSON object.
*
* @return {Array<any>}
*/ toJSON() {
return this.map((c)=>c instanceof AbstractType ? c.toJSON() : c);
}
/**
* Returns an Array with the result of calling a provided function on every
* element of this YArray.
*
* @template M
* @param {function(T,number,YArray<T>):M} f Function that produces an element of the new Array
* @return {Array<M>} A new array with each element being the result of the
* callback function
*/ map(f) {
return typeListMap(this, /** @type {any} */ f);
}
/**
* Executes a provided function once on every element of this YArray.
*
* @param {function(T,number,YArray<T>):void} f A function to execute on every element of this YArray.
*/ forEach(f) {
typeListForEach(this, f);
}
/**
* @return {IterableIterator<T>}
*/ [Symbol.iterator]() {
return typeListCreateIterator(this);
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
*/ _write(encoder) {
encoder.writeTypeRef(YArrayRefID);
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} _decoder
*
* @private
* @function
*/ const readYArray = (_decoder)=>new YArray();
/**
* @module YMap
*/ /**
* @template T
* @extends YEvent<YMap<T>>
* Event that describes the changes on a YMap.
*/ class YMapEvent extends YEvent {
/**
* @param {YMap<T>} ymap The YArray that changed.
* @param {Transaction} transaction
* @param {Set<any>} subs The keys that changed.
*/ constructor(ymap, transaction, subs){
super(ymap, transaction);
this.keysChanged = subs;
}
}
/**
* @template MapType
* A shared Map implementation.
*
* @extends AbstractType<YMapEvent<MapType>>
* @implements {Iterable<[string, MapType]>}
*/ class YMap extends AbstractType {
/**
*
* @param {Iterable<readonly [string, any]>=} entries - an optional iterable to initialize the YMap
*/ constructor(entries){
super();
/**
* @type {Map<string,any>?}
* @private
*/ this._prelimContent = null;
if (entries === undefined) this._prelimContent = new Map();
else this._prelimContent = new Map(entries);
}
/**
* Integrate this type into the Yjs instance.
*
* * Save this struct in the os
* * This type is sent to other client
* * Observer functions are fired
*
* @param {Doc} y The Yjs instance
* @param {Item} item
*/ _integrate(y, item) {
super._integrate(y, item); /** @type {Map<string, any>} */
this._prelimContent.forEach((value, key)=>{
this.set(key, value);
});
this._prelimContent = null;
}
/**
* @return {YMap<MapType>}
*/ _copy() {
return new YMap();
}
/**
* Makes a copy of this data type that can be included somewhere else.
*
* Note that the content is only readable _after_ it has been included somewhere in the Ydoc.
*
* @return {YMap<MapType>}
*/ clone() {
/**
* @type {YMap<MapType>}
*/ const map = new YMap();
this.forEach((value, key)=>{
map.set(key, value instanceof AbstractType ? /** @type {typeof value} */ value.clone() : value);
});
return map;
}
/**
* Creates YMapEvent and calls observers.
*
* @param {Transaction} transaction
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
*/ _callObserver(transaction, parentSubs) {
callTypeObservers(this, transaction, new YMapEvent(this, transaction, parentSubs));
}
/**
* Transforms this Shared Type to a JSON object.
*
* @return {Object<string,any>}
*/ toJSON() {
/**
* @type {Object<string,MapType>}
*/ const map = {};
this._map.forEach((item, key)=>{
if (!item.deleted) {
const v = item.content.getContent()[item.length - 1];
map[key] = v instanceof AbstractType ? v.toJSON() : v;
}
});
return map;
}
/**
* Returns the size of the YMap (count of key/value pairs)
*
* @return {number}
*/ get size() {
return [
...createMapIterator(this._map)
].length;
}
/**
* Returns the keys for each element in the YMap Type.
*
* @return {IterableIterator<string>}
*/ keys() {
return _iterator.iteratorMap(createMapIterator(this._map), /** @param {any} v */ (v)=>v[0]);
}
/**
* Returns the values for each element in the YMap Type.
*
* @return {IterableIterator<MapType>}
*/ values() {
return _iterator.iteratorMap(createMapIterator(this._map), /** @param {any} v */ (v)=>v[1].content.getContent()[v[1].length - 1]);
}
/**
* Returns an Iterator of [key, value] pairs
*
* @return {IterableIterator<[string, MapType]>}
*/ entries() {
return _iterator.iteratorMap(createMapIterator(this._map), /** @param {any} v */ (v)=>/** @type {any} */ [
v[0],
v[1].content.getContent()[v[1].length - 1]
]);
}
/**
* Executes a provided function on once on every key-value pair.
*
* @param {function(MapType,string,YMap<MapType>):void} f A function to execute on every element of this YArray.
*/ forEach(f) {
this._map.forEach((item, key)=>{
if (!item.deleted) f(item.content.getContent()[item.length - 1], key, this);
});
}
/**
* Returns an Iterator of [key, value] pairs
*
* @return {IterableIterator<[string, MapType]>}
*/ [Symbol.iterator]() {
return this.entries();
}
/**
* Remove a specified element from this YMap.
*
* @param {string} key The key of the element to remove.
*/ delete(key) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeMapDelete(transaction, this, key);
});
else /** @type {Map<string, any>} */ this._prelimContent.delete(key);
}
/**
* Adds or updates an element with a specified key and value.
* @template {MapType} VAL
*
* @param {string} key The key of the element to add to this YMap
* @param {VAL} value The value of the element to add
* @return {VAL}
*/ set(key, value) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeMapSet(transaction, this, key, /** @type {any} */ value);
});
else /** @type {Map<string, any>} */ this._prelimContent.set(key, value);
return value;
}
/**
* Returns a specified element from this YMap.
*
* @param {string} key
* @return {MapType|undefined}
*/ get(key) {
return /** @type {any} */ typeMapGet(this, key);
}
/**
* Returns a boolean indicating whether the specified key exists or not.
*
* @param {string} key The key to test.
* @return {boolean}
*/ has(key) {
return typeMapHas(this, key);
}
/**
* Removes all elements from this YMap.
*/ clear() {
if (this.doc !== null) transact(this.doc, (transaction)=>{
this.forEach(function(_value, key, map) {
typeMapDelete(transaction, map, key);
});
});
else /** @type {Map<string, any>} */ this._prelimContent.clear();
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
*/ _write(encoder) {
encoder.writeTypeRef(YMapRefID);
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} _decoder
*
* @private
* @function
*/ const readYMap = (_decoder)=>new YMap();
/**
* @module YText
*/ /**
* @param {any} a
* @param {any} b
* @return {boolean}
*/ const equalAttrs = (a, b)=>a === b || typeof a === "object" && typeof b === "object" && a && b && _object.equalFlat(a, b);
class ItemTextListPosition {
/**
* @param {Item|null} left
* @param {Item|null} right
* @param {number} index
* @param {Map<string,any>} currentAttributes
*/ constructor(left, right, index, currentAttributes){
this.left = left;
this.right = right;
this.index = index;
this.currentAttributes = currentAttributes;
}
/**
* Only call this if you know that this.right is defined
*/ forward() {
if (this.right === null) _error.unexpectedCase();
switch(this.right.content.constructor){
case ContentFormat:
if (!this.right.deleted) updateCurrentAttributes(this.currentAttributes, /** @type {ContentFormat} */ this.right.content);
break;
default:
if (!this.right.deleted) this.index += this.right.length;
break;
}
this.left = this.right;
this.right = this.right.right;
}
}
/**
* @param {Transaction} transaction
* @param {ItemTextListPosition} pos
* @param {number} count steps to move forward
* @return {ItemTextListPosition}
*
* @private
* @function
*/ const findNextPosition = (transaction, pos, count)=>{
while(pos.right !== null && count > 0){
switch(pos.right.content.constructor){
case ContentFormat:
if (!pos.right.deleted) updateCurrentAttributes(pos.currentAttributes, /** @type {ContentFormat} */ pos.right.content);
break;
default:
if (!pos.right.deleted) {
if (count < pos.right.length) // split right
getItemCleanStart(transaction, createID(pos.right.id.client, pos.right.id.clock + count));
pos.index += pos.right.length;
count -= pos.right.length;
}
break;
}
pos.left = pos.right;
pos.right = pos.right.right;
// pos.forward() - we don't forward because that would halve the performance because we already do the checks above
}
return pos;
};
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {number} index
* @param {boolean} useSearchMarker
* @return {ItemTextListPosition}
*
* @private
* @function
*/ const findPosition = (transaction, parent, index, useSearchMarker)=>{
const currentAttributes = new Map();
const marker = useSearchMarker ? findMarker(parent, index) : null;
if (marker) {
const pos = new ItemTextListPosition(marker.p.left, marker.p, marker.index, currentAttributes);
return findNextPosition(transaction, pos, index - marker.index);
} else {
const pos = new ItemTextListPosition(null, parent._start, 0, currentAttributes);
return findNextPosition(transaction, pos, index);
}
};
/**
* Negate applied formats
*
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {ItemTextListPosition} currPos
* @param {Map<string,any>} negatedAttributes
*
* @private
* @function
*/ const insertNegatedAttributes = (transaction, parent, currPos, negatedAttributes)=>{
// check if we really need to remove attributes
while(currPos.right !== null && (currPos.right.deleted === true || currPos.right.content.constructor === ContentFormat && equalAttrs(negatedAttributes.get(/** @type {ContentFormat} */ currPos.right.content.key), /** @type {ContentFormat} */ currPos.right.content.value))){
if (!currPos.right.deleted) negatedAttributes.delete(/** @type {ContentFormat} */ currPos.right.content.key);
currPos.forward();
}
const doc = transaction.doc;
const ownClientId = doc.clientID;
negatedAttributes.forEach((val, key)=>{
const left = currPos.left;
const right = currPos.right;
const nextFormat = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val));
nextFormat.integrate(transaction, 0);
currPos.right = nextFormat;
currPos.forward();
});
};
/**
* @param {Map<string,any>} currentAttributes
* @param {ContentFormat} format
*
* @private
* @function
*/ const updateCurrentAttributes = (currentAttributes, format)=>{
const { key, value } = format;
if (value === null) currentAttributes.delete(key);
else currentAttributes.set(key, value);
};
/**
* @param {ItemTextListPosition} currPos
* @param {Object<string,any>} attributes
*
* @private
* @function
*/ const minimizeAttributeChanges = (currPos, attributes)=>{
// go right while attributes[right.key] === right.value (or right is deleted)
while(true){
if (currPos.right === null) break;
else if (currPos.right.deleted || currPos.right.content.constructor === ContentFormat && equalAttrs(attributes[/** @type {ContentFormat} */ currPos.right.content.key] ?? null, /** @type {ContentFormat} */ currPos.right.content.value)) ;
else break;
currPos.forward();
}
};
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {ItemTextListPosition} currPos
* @param {Object<string,any>} attributes
* @return {Map<string,any>}
*
* @private
* @function
**/ const insertAttributes = (transaction, parent, currPos, attributes)=>{
const doc = transaction.doc;
const ownClientId = doc.clientID;
const negatedAttributes = new Map();
// insert format-start items
for(const key in attributes){
const val = attributes[key];
const currentVal = currPos.currentAttributes.get(key) ?? null;
if (!equalAttrs(currentVal, val)) {
// save negated attribute (set null if currentVal undefined)
negatedAttributes.set(key, currentVal);
const { left, right } = currPos;
currPos.right = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val));
currPos.right.integrate(transaction, 0);
currPos.forward();
}
}
return negatedAttributes;
};
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {ItemTextListPosition} currPos
* @param {string|object|AbstractType<any>} text
* @param {Object<string,any>} attributes
*
* @private
* @function
**/ const insertText = (transaction, parent, currPos, text, attributes)=>{
currPos.currentAttributes.forEach((_val, key)=>{
if (attributes[key] === undefined) attributes[key] = null;
});
const doc = transaction.doc;
const ownClientId = doc.clientID;
minimizeAttributeChanges(currPos, attributes);
const negatedAttributes = insertAttributes(transaction, parent, currPos, attributes);
// insert content
const content = text.constructor === String ? new ContentString(/** @type {string} */ text) : text instanceof AbstractType ? new ContentType(text) : new ContentEmbed(text);
let { left, right, index } = currPos;
if (parent._searchMarker) updateMarkerChanges(parent._searchMarker, currPos.index, content.getLength());
right = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, content);
right.integrate(transaction, 0);
currPos.right = right;
currPos.index = index;
currPos.forward();
insertNegatedAttributes(transaction, parent, currPos, negatedAttributes);
};
/**
* @param {Transaction} transaction
* @param {AbstractType<any>} parent
* @param {ItemTextListPosition} currPos
* @param {number} length
* @param {Object<string,any>} attributes
*
* @private
* @function
*/ const formatText = (transaction, parent, currPos, length, attributes)=>{
const doc = transaction.doc;
const ownClientId = doc.clientID;
minimizeAttributeChanges(currPos, attributes);
const negatedAttributes = insertAttributes(transaction, parent, currPos, attributes);
// iterate until first non-format or null is found
// delete all formats with attributes[format.key] != null
// also check the attributes after the first non-format as we do not want to insert redundant negated attributes there
// eslint-disable-next-line no-labels
iterationLoop: while(currPos.right !== null && (length > 0 || negatedAttributes.size > 0 && (currPos.right.deleted || currPos.right.content.constructor === ContentFormat))){
if (!currPos.right.deleted) switch(currPos.right.content.constructor){
case ContentFormat:
{
const { key, value } = /** @type {ContentFormat} */ currPos.right.content;
const attr = attributes[key];
if (attr !== undefined) {
if (equalAttrs(attr, value)) negatedAttributes.delete(key);
else {
if (length === 0) break iterationLoop;
negatedAttributes.set(key, value);
}
currPos.right.delete(transaction);
} else currPos.currentAttributes.set(key, value);
break;
}
default:
if (length < currPos.right.length) getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length));
length -= currPos.right.length;
break;
}
currPos.forward();
}
// Quill just assumes that the editor starts with a newline and that it always
// ends with a newline. We only insert that newline when a new newline is
// inserted - i.e when length is bigger than type.length
if (length > 0) {
let newlines = "";
for(; length > 0; length--)newlines += "\n";
currPos.right = new Item(createID(ownClientId, getState(doc.store, ownClientId)), currPos.left, currPos.left && currPos.left.lastId, currPos.right, currPos.right && currPos.right.id, parent, null, new ContentString(newlines));
currPos.right.integrate(transaction, 0);
currPos.forward();
}
insertNegatedAttributes(transaction, parent, currPos, negatedAttributes);
};
/**
* Call this function after string content has been deleted in order to
* clean up formatting Items.
*
* @param {Transaction} transaction
* @param {Item} start
* @param {Item|null} curr exclusive end, automatically iterates to the next Content Item
* @param {Map<string,any>} startAttributes
* @param {Map<string,any>} currAttributes
* @return {number} The amount of formatting Items deleted.
*
* @function
*/ const cleanupFormattingGap = (transaction, start, curr, startAttributes, currAttributes)=>{
/**
* @type {Item|null}
*/ let end = start;
/**
* @type {Map<string,ContentFormat>}
*/ const endFormats = _map.create();
while(end && (!end.countable || end.deleted)){
if (!end.deleted && end.content.constructor === ContentFormat) {
const cf = /** @type {ContentFormat} */ end.content;
endFormats.set(cf.key, cf);
}
end = end.right;
}
let cleanups = 0;
let reachedCurr = false;
while(start !== end){
if (curr === start) reachedCurr = true;
if (!start.deleted) {
const content = start.content;
switch(content.constructor){
case ContentFormat:
{
const { key, value } = /** @type {ContentFormat} */ content;
const startAttrValue = startAttributes.get(key) ?? null;
if (endFormats.get(key) !== content || startAttrValue === value) {
// Either this format is overwritten or it is not necessary because the attribute already existed.
start.delete(transaction);
cleanups++;
if (!reachedCurr && (currAttributes.get(key) ?? null) === value && startAttrValue !== value) {
if (startAttrValue === null) currAttributes.delete(key);
else currAttributes.set(key, startAttrValue);
}
}
if (!reachedCurr && !start.deleted) updateCurrentAttributes(currAttributes, /** @type {ContentFormat} */ content);
break;
}
}
}
start = /** @type {Item} */ start.right;
}
return cleanups;
};
/**
* @param {Transaction} transaction
* @param {Item | null} item
*/ const cleanupContextlessFormattingGap = (transaction, item)=>{
// iterate until item.right is null or content
while(item && item.right && (item.right.deleted || !item.right.countable))item = item.right;
const attrs = new Set();
// iterate back until a content item is found
while(item && (item.deleted || !item.countable)){
if (!item.deleted && item.content.constructor === ContentFormat) {
const key = /** @type {ContentFormat} */ item.content.key;
if (attrs.has(key)) item.delete(transaction);
else attrs.add(key);
}
item = item.left;
}
};
/**
* This function is experimental and subject to change / be removed.
*
* Ideally, we don't need this function at all. Formatting attributes should be cleaned up
* automatically after each change. This function iterates twice over the complete YText type
* and removes unnecessary formatting attributes. This is also helpful for testing.
*
* This function won't be exported anymore as soon as there is confidence that the YText type works as intended.
*
* @param {YText} type
* @return {number} How many formatting attributes have been cleaned up.
*/ const cleanupYTextFormatting = (type)=>{
let res = 0;
transact(/** @type {Doc} */ type.doc, (transaction)=>{
let start = /** @type {Item} */ type._start;
let end = type._start;
let startAttributes = _map.create();
const currentAttributes = _map.copy(startAttributes);
while(end){
if (end.deleted === false) switch(end.content.constructor){
case ContentFormat:
updateCurrentAttributes(currentAttributes, /** @type {ContentFormat} */ end.content);
break;
default:
res += cleanupFormattingGap(transaction, start, end, startAttributes, currentAttributes);
startAttributes = _map.copy(currentAttributes);
start = end;
break;
}
end = end.right;
}
});
return res;
};
/**
* This will be called by the transction once the event handlers are called to potentially cleanup
* formatting attributes.
*
* @param {Transaction} transaction
*/ const cleanupYTextAfterTransaction = (transaction)=>{
/**
* @type {Set<YText>}
*/ const needFullCleanup = new Set();
// check if another formatting item was inserted
const doc = transaction.doc;
for (const [client, afterClock] of transaction.afterState.entries()){
const clock = transaction.beforeState.get(client) || 0;
if (afterClock === clock) continue;
iterateStructs(transaction, /** @type {Array<Item|GC>} */ doc.store.clients.get(client), clock, afterClock, (item)=>{
if (!item.deleted && /** @type {Item} */ item.content.constructor === ContentFormat && item.constructor !== GC) needFullCleanup.add(/** @type {any} */ item.parent);
});
}
// cleanup in a new transaction
transact(doc, (t)=>{
iterateDeletedStructs(transaction, transaction.deleteSet, (item)=>{
if (item instanceof GC || !/** @type {YText} */ item.parent._hasFormatting || needFullCleanup.has(/** @type {YText} */ item.parent)) return;
const parent = /** @type {YText} */ item.parent;
if (item.content.constructor === ContentFormat) needFullCleanup.add(parent);
else // If no formatting attribute was inserted or deleted, we can make due with contextless
// formatting cleanups.
// Contextless: it is not necessary to compute currentAttributes for the affected position.
cleanupContextlessFormattingGap(t, item);
});
// If a formatting item was inserted, we simply clean the whole type.
// We need to compute currentAttributes for the current position anyway.
for (const yText of needFullCleanup)cleanupYTextFormatting(yText);
});
};
/**
* @param {Transaction} transaction
* @param {ItemTextListPosition} currPos
* @param {number} length
* @return {ItemTextListPosition}
*
* @private
* @function
*/ const deleteText = (transaction, currPos, length)=>{
const startLength = length;
const startAttrs = _map.copy(currPos.currentAttributes);
const start = currPos.right;
while(length > 0 && currPos.right !== null){
if (currPos.right.deleted === false) switch(currPos.right.content.constructor){
case ContentType:
case ContentEmbed:
case ContentString:
if (length < currPos.right.length) getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length));
length -= currPos.right.length;
currPos.right.delete(transaction);
break;
}
currPos.forward();
}
if (start) cleanupFormattingGap(transaction, start, currPos.right, startAttrs, currPos.currentAttributes);
const parent = /** @type {AbstractType<any>} */ /** @type {Item} */ (currPos.left || currPos.right).parent;
if (parent._searchMarker) updateMarkerChanges(parent._searchMarker, currPos.index, -startLength + length);
return currPos;
};
/**
* The Quill Delta format represents changes on a text document with
* formatting information. For mor information visit {@link https://quilljs.com/docs/delta/|Quill Delta}
*
* @example
* {
* ops: [
* { insert: 'Gandalf', attributes: { bold: true } },
* { insert: ' the ' },
* { insert: 'Grey', attributes: { color: '#cccccc' } }
* ]
* }
*
*/ /**
* Attributes that can be assigned to a selection of text.
*
* @example
* {
* bold: true,
* font-size: '40px'
* }
*
* @typedef {Object} TextAttributes
*/ /**
* @extends YEvent<YText>
* Event that describes the changes on a YText type.
*/ class YTextEvent extends YEvent {
/**
* @param {YText} ytext
* @param {Transaction} transaction
* @param {Set<any>} subs The keys that changed
*/ constructor(ytext, transaction, subs){
super(ytext, transaction);
/**
* Whether the children changed.
* @type {Boolean}
* @private
*/ this.childListChanged = false;
/**
* Set of all changed attributes.
* @type {Set<string>}
*/ this.keysChanged = new Set();
subs.forEach((sub)=>{
if (sub === null) this.childListChanged = true;
else this.keysChanged.add(sub);
});
}
/**
* @type {{added:Set<Item>,deleted:Set<Item>,keys:Map<string,{action:'add'|'update'|'delete',oldValue:any}>,delta:Array<{insert?:Array<any>|string, delete?:number, retain?:number}>}}
*/ get changes() {
if (this._changes === null) {
/**
* @type {{added:Set<Item>,deleted:Set<Item>,keys:Map<string,{action:'add'|'update'|'delete',oldValue:any}>,delta:Array<{insert?:Array<any>|string|AbstractType<any>|object, delete?:number, retain?:number}>}}
*/ const changes = {
keys: this.keys,
delta: this.delta,
added: new Set(),
deleted: new Set()
};
this._changes = changes;
}
return /** @type {any} */ this._changes;
}
/**
* Compute the changes in the delta format.
* A {@link https://quilljs.com/docs/delta/|Quill Delta}) that represents the changes on the document.
*
* @type {Array<{insert?:string|object|AbstractType<any>, delete?:number, retain?:number, attributes?: Object<string,any>}>}
*
* @public
*/ get delta() {
if (this._delta === null) {
const y = /** @type {Doc} */ this.target.doc;
/**
* @type {Array<{insert?:string|object|AbstractType<any>, delete?:number, retain?:number, attributes?: Object<string,any>}>}
*/ const delta = [];
transact(y, (transaction)=>{
const currentAttributes = new Map(); // saves all current attributes for insert
const oldAttributes = new Map();
let item = this.target._start;
/**
* @type {string?}
*/ let action = null;
/**
* @type {Object<string,any>}
*/ const attributes = {}; // counts added or removed new attributes for retain
/**
* @type {string|object}
*/ let insert = "";
let retain = 0;
let deleteLen = 0;
const addOp = ()=>{
if (action !== null) {
/**
* @type {any}
*/ let op = null;
switch(action){
case "delete":
if (deleteLen > 0) op = {
delete: deleteLen
};
deleteLen = 0;
break;
case "insert":
if (typeof insert === "object" || insert.length > 0) {
op = {
insert
};
if (currentAttributes.size > 0) {
op.attributes = {};
currentAttributes.forEach((value, key)=>{
if (value !== null) op.attributes[key] = value;
});
}
}
insert = "";
break;
case "retain":
if (retain > 0) {
op = {
retain
};
if (!_object.isEmpty(attributes)) op.attributes = _object.assign({}, attributes);
}
retain = 0;
break;
}
if (op) delta.push(op);
action = null;
}
};
while(item !== null){
switch(item.content.constructor){
case ContentType:
case ContentEmbed:
if (this.adds(item)) {
if (!this.deletes(item)) {
addOp();
action = "insert";
insert = item.content.getContent()[0];
addOp();
}
} else if (this.deletes(item)) {
if (action !== "delete") {
addOp();
action = "delete";
}
deleteLen += 1;
} else if (!item.deleted) {
if (action !== "retain") {
addOp();
action = "retain";
}
retain += 1;
}
break;
case ContentString:
if (this.adds(item)) {
if (!this.deletes(item)) {
if (action !== "insert") {
addOp();
action = "insert";
}
insert += /** @type {ContentString} */ item.content.str;
}
} else if (this.deletes(item)) {
if (action !== "delete") {
addOp();
action = "delete";
}
deleteLen += item.length;
} else if (!item.deleted) {
if (action !== "retain") {
addOp();
action = "retain";
}
retain += item.length;
}
break;
case ContentFormat:
{
const { key, value } = /** @type {ContentFormat} */ item.content;
if (this.adds(item)) {
if (!this.deletes(item)) {
const curVal = currentAttributes.get(key) ?? null;
if (!equalAttrs(curVal, value)) {
if (action === "retain") addOp();
if (equalAttrs(value, oldAttributes.get(key) ?? null)) delete attributes[key];
else attributes[key] = value;
} else if (value !== null) item.delete(transaction);
}
} else if (this.deletes(item)) {
oldAttributes.set(key, value);
const curVal = currentAttributes.get(key) ?? null;
if (!equalAttrs(curVal, value)) {
if (action === "retain") addOp();
attributes[key] = curVal;
}
} else if (!item.deleted) {
oldAttributes.set(key, value);
const attr = attributes[key];
if (attr !== undefined) {
if (!equalAttrs(attr, value)) {
if (action === "retain") addOp();
if (value === null) delete attributes[key];
else attributes[key] = value;
} else if (attr !== null) item.delete(transaction);
}
}
if (!item.deleted) {
if (action === "insert") addOp();
updateCurrentAttributes(currentAttributes, /** @type {ContentFormat} */ item.content);
}
break;
}
}
item = item.right;
}
addOp();
while(delta.length > 0){
const lastOp = delta[delta.length - 1];
if (lastOp.retain !== undefined && lastOp.attributes === undefined) // retain delta's if they don't assign attributes
delta.pop();
else break;
}
});
this._delta = delta;
}
return /** @type {any} */ this._delta;
}
}
/**
* Type that represents text with formatting information.
*
* This type replaces y-richtext as this implementation is able to handle
* block formats (format information on a paragraph), embeds (complex elements
* like pictures and videos), and text formats (**bold**, *italic*).
*
* @extends AbstractType<YTextEvent>
*/ class YText extends AbstractType {
/**
* @param {String} [string] The initial value of the YText.
*/ constructor(string){
super();
/**
* Array of pending operations on this type
* @type {Array<function():void>?}
*/ this._pending = string !== undefined ? [
()=>this.insert(0, string)
] : [];
/**
* @type {Array<ArraySearchMarker>|null}
*/ this._searchMarker = [];
/**
* Whether this YText contains formatting attributes.
* This flag is updated when a formatting item is integrated (see ContentFormat.integrate)
*/ this._hasFormatting = false;
}
/**
* Number of characters of this text type.
*
* @type {number}
*/ get length() {
return this._length;
}
/**
* @param {Doc} y
* @param {Item} item
*/ _integrate(y, item) {
super._integrate(y, item);
try {
/** @type {Array<function>} */ this._pending.forEach((f)=>f());
} catch (e) {
console.error(e);
}
this._pending = null;
}
_copy() {
return new YText();
}
/**
* Makes a copy of this data type that can be included somewhere else.
*
* Note that the content is only readable _after_ it has been included somewhere in the Ydoc.
*
* @return {YText}
*/ clone() {
const text = new YText();
text.applyDelta(this.toDelta());
return text;
}
/**
* Creates YTextEvent and calls observers.
*
* @param {Transaction} transaction
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
*/ _callObserver(transaction, parentSubs) {
super._callObserver(transaction, parentSubs);
const event = new YTextEvent(this, transaction, parentSubs);
callTypeObservers(this, transaction, event);
// If a remote change happened, we try to cleanup potential formatting duplicates.
if (!transaction.local && this._hasFormatting) transaction._needFormattingCleanup = true;
}
/**
* Returns the unformatted string representation of this YText type.
*
* @public
*/ toString() {
let str = "";
/**
* @type {Item|null}
*/ let n = this._start;
while(n !== null){
if (!n.deleted && n.countable && n.content.constructor === ContentString) str += /** @type {ContentString} */ n.content.str;
n = n.right;
}
return str;
}
/**
* Returns the unformatted string representation of this YText type.
*
* @return {string}
* @public
*/ toJSON() {
return this.toString();
}
/**
* Apply a {@link Delta} on this shared YText type.
*
* @param {any} delta The changes to apply on this element.
* @param {object} opts
* @param {boolean} [opts.sanitize] Sanitize input delta. Removes ending newlines if set to true.
*
*
* @public
*/ applyDelta(delta, { sanitize = true } = {}) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
const currPos = new ItemTextListPosition(null, this._start, 0, new Map());
for(let i = 0; i < delta.length; i++){
const op = delta[i];
if (op.insert !== undefined) {
// Quill assumes that the content starts with an empty paragraph.
// Yjs/Y.Text assumes that it starts empty. We always hide that
// there is a newline at the end of the content.
// If we omit this step, clients will see a different number of
// paragraphs, but nothing bad will happen.
const ins = !sanitize && typeof op.insert === "string" && i === delta.length - 1 && currPos.right === null && op.insert.slice(-1) === "\n" ? op.insert.slice(0, -1) : op.insert;
if (typeof ins !== "string" || ins.length > 0) insertText(transaction, this, currPos, ins, op.attributes || {});
} else if (op.retain !== undefined) formatText(transaction, this, currPos, op.retain, op.attributes || {});
else if (op.delete !== undefined) deleteText(transaction, currPos, op.delete);
}
});
else /** @type {Array<function>} */ this._pending.push(()=>this.applyDelta(delta));
}
/**
* Returns the Delta representation of this YText type.
*
* @param {Snapshot} [snapshot]
* @param {Snapshot} [prevSnapshot]
* @param {function('removed' | 'added', ID):any} [computeYChange]
* @return {any} The Delta representation of this type.
*
* @public
*/ toDelta(snapshot, prevSnapshot, computeYChange) {
/**
* @type{Array<any>}
*/ const ops = [];
const currentAttributes = new Map();
const doc = /** @type {Doc} */ this.doc;
let str = "";
let n = this._start;
function packStr() {
if (str.length > 0) {
// pack str with attributes to ops
/**
* @type {Object<string,any>}
*/ const attributes = {};
let addAttributes = false;
currentAttributes.forEach((value, key)=>{
addAttributes = true;
attributes[key] = value;
});
/**
* @type {Object<string,any>}
*/ const op = {
insert: str
};
if (addAttributes) op.attributes = attributes;
ops.push(op);
str = "";
}
}
const computeDelta = ()=>{
while(n !== null){
if (isVisible(n, snapshot) || prevSnapshot !== undefined && isVisible(n, prevSnapshot)) switch(n.content.constructor){
case ContentString:
{
const cur = currentAttributes.get("ychange");
if (snapshot !== undefined && !isVisible(n, snapshot)) {
if (cur === undefined || cur.user !== n.id.client || cur.type !== "removed") {
packStr();
currentAttributes.set("ychange", computeYChange ? computeYChange("removed", n.id) : {
type: "removed"
});
}
} else if (prevSnapshot !== undefined && !isVisible(n, prevSnapshot)) {
if (cur === undefined || cur.user !== n.id.client || cur.type !== "added") {
packStr();
currentAttributes.set("ychange", computeYChange ? computeYChange("added", n.id) : {
type: "added"
});
}
} else if (cur !== undefined) {
packStr();
currentAttributes.delete("ychange");
}
str += /** @type {ContentString} */ n.content.str;
break;
}
case ContentType:
case ContentEmbed:
{
packStr();
/**
* @type {Object<string,any>}
*/ const op = {
insert: n.content.getContent()[0]
};
if (currentAttributes.size > 0) {
const attrs = /** @type {Object<string,any>} */ {};
op.attributes = attrs;
currentAttributes.forEach((value, key)=>{
attrs[key] = value;
});
}
ops.push(op);
break;
}
case ContentFormat:
if (isVisible(n, snapshot)) {
packStr();
updateCurrentAttributes(currentAttributes, /** @type {ContentFormat} */ n.content);
}
break;
}
n = n.right;
}
packStr();
};
if (snapshot || prevSnapshot) // snapshots are merged again after the transaction, so we need to keep the
// transaction alive until we are done
transact(doc, (transaction)=>{
if (snapshot) splitSnapshotAffectedStructs(transaction, snapshot);
if (prevSnapshot) splitSnapshotAffectedStructs(transaction, prevSnapshot);
computeDelta();
}, "cleanup");
else computeDelta();
return ops;
}
/**
* Insert text at a given index.
*
* @param {number} index The index at which to start inserting.
* @param {String} text The text to insert at the specified position.
* @param {TextAttributes} [attributes] Optionally define some formatting
* information to apply on the inserted
* Text.
* @public
*/ insert(index, text, attributes) {
if (text.length <= 0) return;
const y = this.doc;
if (y !== null) transact(y, (transaction)=>{
const pos = findPosition(transaction, this, index, !attributes);
if (!attributes) {
attributes = {};
// @ts-ignore
pos.currentAttributes.forEach((v, k)=>{
attributes[k] = v;
});
}
insertText(transaction, this, pos, text, attributes);
});
else /** @type {Array<function>} */ this._pending.push(()=>this.insert(index, text, attributes));
}
/**
* Inserts an embed at a index.
*
* @param {number} index The index to insert the embed at.
* @param {Object | AbstractType<any>} embed The Object that represents the embed.
* @param {TextAttributes} [attributes] Attribute information to apply on the
* embed
*
* @public
*/ insertEmbed(index, embed, attributes) {
const y = this.doc;
if (y !== null) transact(y, (transaction)=>{
const pos = findPosition(transaction, this, index, !attributes);
insertText(transaction, this, pos, embed, attributes || {});
});
else /** @type {Array<function>} */ this._pending.push(()=>this.insertEmbed(index, embed, attributes || {}));
}
/**
* Deletes text starting from an index.
*
* @param {number} index Index at which to start deleting.
* @param {number} length The number of characters to remove. Defaults to 1.
*
* @public
*/ delete(index, length) {
if (length === 0) return;
const y = this.doc;
if (y !== null) transact(y, (transaction)=>{
deleteText(transaction, findPosition(transaction, this, index, true), length);
});
else /** @type {Array<function>} */ this._pending.push(()=>this.delete(index, length));
}
/**
* Assigns properties to a range of text.
*
* @param {number} index The position where to start formatting.
* @param {number} length The amount of characters to assign properties to.
* @param {TextAttributes} attributes Attribute information to apply on the
* text.
*
* @public
*/ format(index, length, attributes) {
if (length === 0) return;
const y = this.doc;
if (y !== null) transact(y, (transaction)=>{
const pos = findPosition(transaction, this, index, false);
if (pos.right === null) return;
formatText(transaction, this, pos, length, attributes);
});
else /** @type {Array<function>} */ this._pending.push(()=>this.format(index, length, attributes));
}
/**
* Removes an attribute.
*
* @note Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.
*
* @param {String} attributeName The attribute name that is to be removed.
*
* @public
*/ removeAttribute(attributeName) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeMapDelete(transaction, this, attributeName);
});
else /** @type {Array<function>} */ this._pending.push(()=>this.removeAttribute(attributeName));
}
/**
* Sets or updates an attribute.
*
* @note Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.
*
* @param {String} attributeName The attribute name that is to be set.
* @param {any} attributeValue The attribute value that is to be set.
*
* @public
*/ setAttribute(attributeName, attributeValue) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeMapSet(transaction, this, attributeName, attributeValue);
});
else /** @type {Array<function>} */ this._pending.push(()=>this.setAttribute(attributeName, attributeValue));
}
/**
* Returns an attribute value that belongs to the attribute name.
*
* @note Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.
*
* @param {String} attributeName The attribute name that identifies the
* queried value.
* @return {any} The queried attribute value.
*
* @public
*/ getAttribute(attributeName) {
return /** @type {any} */ typeMapGet(this, attributeName);
}
/**
* Returns all attribute name/value pairs in a JSON Object.
*
* @note Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.
*
* @return {Object<string, any>} A JSON Object that describes the attributes.
*
* @public
*/ getAttributes() {
return typeMapGetAll(this);
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
*/ _write(encoder) {
encoder.writeTypeRef(YTextRefID);
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} _decoder
* @return {YText}
*
* @private
* @function
*/ const readYText = (_decoder)=>new YText();
/**
* @module YXml
*/ /**
* Define the elements to which a set of CSS queries apply.
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}
*
* @example
* query = '.classSelector'
* query = 'nodeSelector'
* query = '#idSelector'
*
* @typedef {string} CSS_Selector
*/ /**
* Dom filter function.
*
* @callback domFilter
* @param {string} nodeName The nodeName of the element
* @param {Map} attributes The map of attributes.
* @return {boolean} Whether to include the Dom node in the YXmlElement.
*/ /**
* Represents a subset of the nodes of a YXmlElement / YXmlFragment and a
* position within them.
*
* Can be created with {@link YXmlFragment#createTreeWalker}
*
* @public
* @implements {Iterable<YXmlElement|YXmlText|YXmlElement|YXmlHook>}
*/ class YXmlTreeWalker {
/**
* @param {YXmlFragment | YXmlElement} root
* @param {function(AbstractType<any>):boolean} [f]
*/ constructor(root, f = ()=>true){
this._filter = f;
this._root = root;
/**
* @type {Item}
*/ this._currentNode = /** @type {Item} */ root._start;
this._firstCall = true;
}
[Symbol.iterator]() {
return this;
}
/**
* Get the next node.
*
* @return {IteratorResult<YXmlElement|YXmlText|YXmlHook>} The next node.
*
* @public
*/ next() {
/**
* @type {Item|null}
*/ let n = this._currentNode;
let type = n && n.content && /** @type {any} */ n.content.type;
if (n !== null && (!this._firstCall || n.deleted || !this._filter(type))) do {
type = /** @type {any} */ n.content.type;
if (!n.deleted && (type.constructor === YXmlElement || type.constructor === YXmlFragment) && type._start !== null) // walk down in the tree
n = type._start;
else // walk right or up in the tree
while(n !== null){
if (n.right !== null) {
n = n.right;
break;
} else if (n.parent === this._root) n = null;
else n = /** @type {AbstractType<any>} */ n.parent._item;
}
}while (n !== null && (n.deleted || !this._filter(/** @type {ContentType} */ n.content.type)));
this._firstCall = false;
if (n === null) // @ts-ignore
return {
value: undefined,
done: true
};
this._currentNode = n;
return {
value: /** @type {any} */ n.content.type,
done: false
};
}
}
/**
* Represents a list of {@link YXmlElement}.and {@link YXmlText} types.
* A YxmlFragment is similar to a {@link YXmlElement}, but it does not have a
* nodeName and it does not have attributes. Though it can be bound to a DOM
* element - in this case the attributes and the nodeName are not shared.
*
* @public
* @extends AbstractType<YXmlEvent>
*/ class YXmlFragment extends AbstractType {
constructor(){
super();
/**
* @type {Array<any>|null}
*/ this._prelimContent = [];
}
/**
* @type {YXmlElement|YXmlText|null}
*/ get firstChild() {
const first = this._first;
return first ? first.content.getContent()[0] : null;
}
/**
* Integrate this type into the Yjs instance.
*
* * Save this struct in the os
* * This type is sent to other client
* * Observer functions are fired
*
* @param {Doc} y The Yjs instance
* @param {Item} item
*/ _integrate(y, item) {
super._integrate(y, item);
this.insert(0, /** @type {Array<any>} */ this._prelimContent);
this._prelimContent = null;
}
_copy() {
return new YXmlFragment();
}
/**
* Makes a copy of this data type that can be included somewhere else.
*
* Note that the content is only readable _after_ it has been included somewhere in the Ydoc.
*
* @return {YXmlFragment}
*/ clone() {
const el = new YXmlFragment();
// @ts-ignore
el.insert(0, this.toArray().map((item)=>item instanceof AbstractType ? item.clone() : item));
return el;
}
get length() {
return this._prelimContent === null ? this._length : this._prelimContent.length;
}
/**
* Create a subtree of childNodes.
*
* @example
* const walker = elem.createTreeWalker(dom => dom.nodeName === 'div')
* for (let node in walker) {
* // `node` is a div node
* nop(node)
* }
*
* @param {function(AbstractType<any>):boolean} filter Function that is called on each child element and
* returns a Boolean indicating whether the child
* is to be included in the subtree.
* @return {YXmlTreeWalker} A subtree and a position within it.
*
* @public
*/ createTreeWalker(filter) {
return new YXmlTreeWalker(this, filter);
}
/**
* Returns the first YXmlElement that matches the query.
* Similar to DOM's {@link querySelector}.
*
* Query support:
* - tagname
* TODO:
* - id
* - attribute
*
* @param {CSS_Selector} query The query on the children.
* @return {YXmlElement|YXmlText|YXmlHook|null} The first element that matches the query or null.
*
* @public
*/ querySelector(query) {
query = query.toUpperCase();
// @ts-ignore
const iterator = new YXmlTreeWalker(this, (element)=>element.nodeName && element.nodeName.toUpperCase() === query);
const next = iterator.next();
if (next.done) return null;
else return next.value;
}
/**
* Returns all YXmlElements that match the query.
* Similar to Dom's {@link querySelectorAll}.
*
* @todo Does not yet support all queries. Currently only query by tagName.
*
* @param {CSS_Selector} query The query on the children
* @return {Array<YXmlElement|YXmlText|YXmlHook|null>} The elements that match this query.
*
* @public
*/ querySelectorAll(query) {
query = query.toUpperCase();
// @ts-ignore
return _array.from(new YXmlTreeWalker(this, (element)=>element.nodeName && element.nodeName.toUpperCase() === query));
}
/**
* Creates YXmlEvent and calls observers.
*
* @param {Transaction} transaction
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
*/ _callObserver(transaction, parentSubs) {
callTypeObservers(this, transaction, new YXmlEvent(this, parentSubs, transaction));
}
/**
* Get the string representation of all the children of this YXmlFragment.
*
* @return {string} The string representation of all children.
*/ toString() {
return typeListMap(this, (xml)=>xml.toString()).join("");
}
/**
* @return {string}
*/ toJSON() {
return this.toString();
}
/**
* Creates a Dom Element that mirrors this YXmlElement.
*
* @param {Document} [_document=document] The document object (you must define
* this when calling this method in
* nodejs)
* @param {Object<string, any>} [hooks={}] Optional property to customize how hooks
* are presented in the DOM
* @param {any} [binding] You should not set this property. This is
* used if DomBinding wants to create a
* association to the created DOM type.
* @return {Node} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}
*
* @public
*/ toDOM(_document = document, hooks = {}, binding) {
const fragment = _document.createDocumentFragment();
if (binding !== undefined) binding._createAssociation(fragment, this);
typeListForEach(this, (xmlType)=>{
fragment.insertBefore(xmlType.toDOM(_document, hooks, binding), null);
});
return fragment;
}
/**
* Inserts new content at an index.
*
* @example
* // Insert character 'a' at position 0
* xml.insert(0, [new Y.XmlText('text')])
*
* @param {number} index The index to insert content at
* @param {Array<YXmlElement|YXmlText>} content The array of content
*/ insert(index, content) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeListInsertGenerics(transaction, this, index, content);
});
else // @ts-ignore _prelimContent is defined because this is not yet integrated
this._prelimContent.splice(index, 0, ...content);
}
/**
* Inserts new content at an index.
*
* @example
* // Insert character 'a' at position 0
* xml.insert(0, [new Y.XmlText('text')])
*
* @param {null|Item|YXmlElement|YXmlText} ref The index to insert content at
* @param {Array<YXmlElement|YXmlText>} content The array of content
*/ insertAfter(ref, content) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
const refItem = ref && ref instanceof AbstractType ? ref._item : ref;
typeListInsertGenericsAfter(transaction, this, refItem, content);
});
else {
const pc = /** @type {Array<any>} */ this._prelimContent;
const index = ref === null ? 0 : pc.findIndex((el)=>el === ref) + 1;
if (index === 0 && ref !== null) throw _error.create("Reference item not found");
pc.splice(index, 0, ...content);
}
}
/**
* Deletes elements starting from an index.
*
* @param {number} index Index at which to start deleting elements
* @param {number} [length=1] The number of elements to remove. Defaults to 1.
*/ delete(index, length = 1) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeListDelete(transaction, this, index, length);
});
else // @ts-ignore _prelimContent is defined because this is not yet integrated
this._prelimContent.splice(index, length);
}
/**
* Transforms this YArray to a JavaScript Array.
*
* @return {Array<YXmlElement|YXmlText|YXmlHook>}
*/ toArray() {
return typeListToArray(this);
}
/**
* Appends content to this YArray.
*
* @param {Array<YXmlElement|YXmlText>} content Array of content to append.
*/ push(content) {
this.insert(this.length, content);
}
/**
* Prepends content to this YArray.
*
* @param {Array<YXmlElement|YXmlText>} content Array of content to prepend.
*/ unshift(content) {
this.insert(0, content);
}
/**
* Returns the i-th element from a YArray.
*
* @param {number} index The index of the element to return from the YArray
* @return {YXmlElement|YXmlText}
*/ get(index) {
return typeListGet(this, index);
}
/**
* Returns a portion of this YXmlFragment into a JavaScript Array selected
* from start to end (end not included).
*
* @param {number} [start]
* @param {number} [end]
* @return {Array<YXmlElement|YXmlText>}
*/ slice(start = 0, end = this.length) {
return typeListSlice(this, start, end);
}
/**
* Executes a provided function on once on every child element.
*
* @param {function(YXmlElement|YXmlText,number, typeof self):void} f A function to execute on every element of this YArray.
*/ forEach(f) {
typeListForEach(this, f);
}
/**
* Transform the properties of this type to binary and write it to an
* BinaryEncoder.
*
* This is called when this Item is sent to a remote peer.
*
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
*/ _write(encoder) {
encoder.writeTypeRef(YXmlFragmentRefID);
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} _decoder
* @return {YXmlFragment}
*
* @private
* @function
*/ const readYXmlFragment = (_decoder)=>new YXmlFragment();
/**
* @typedef {Object|number|null|Array<any>|string|Uint8Array|AbstractType<any>} ValueTypes
*/ /**
* An YXmlElement imitates the behavior of a
* https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element
*
* * An YXmlElement has attributes (key value pairs)
* * An YXmlElement has childElements that must inherit from YXmlElement
*
* @template {{ [key: string]: ValueTypes }} [KV={ [key: string]: string }]
*/ class YXmlElement extends YXmlFragment {
constructor(nodeName = "UNDEFINED"){
super();
this.nodeName = nodeName;
/**
* @type {Map<string, any>|null}
*/ this._prelimAttrs = new Map();
}
/**
* @type {YXmlElement|YXmlText|null}
*/ get nextSibling() {
const n = this._item ? this._item.next : null;
return n ? /** @type {YXmlElement|YXmlText} */ /** @type {ContentType} */ n.content.type : null;
}
/**
* @type {YXmlElement|YXmlText|null}
*/ get prevSibling() {
const n = this._item ? this._item.prev : null;
return n ? /** @type {YXmlElement|YXmlText} */ /** @type {ContentType} */ n.content.type : null;
}
/**
* Integrate this type into the Yjs instance.
*
* * Save this struct in the os
* * This type is sent to other client
* * Observer functions are fired
*
* @param {Doc} y The Yjs instance
* @param {Item} item
*/ _integrate(y, item) {
super._integrate(y, item);
/** @type {Map<string, any>} */ this._prelimAttrs.forEach((value, key)=>{
this.setAttribute(key, value);
});
this._prelimAttrs = null;
}
/**
* Creates an Item with the same effect as this Item (without position effect)
*
* @return {YXmlElement}
*/ _copy() {
return new YXmlElement(this.nodeName);
}
/**
* Makes a copy of this data type that can be included somewhere else.
*
* Note that the content is only readable _after_ it has been included somewhere in the Ydoc.
*
* @return {YXmlElement<KV>}
*/ clone() {
/**
* @type {YXmlElement<KV>}
*/ const el = new YXmlElement(this.nodeName);
const attrs = this.getAttributes();
_object.forEach(attrs, (value, key)=>{
if (typeof value === "string") el.setAttribute(key, value);
});
// @ts-ignore
el.insert(0, this.toArray().map((item)=>item instanceof AbstractType ? item.clone() : item));
return el;
}
/**
* Returns the XML serialization of this YXmlElement.
* The attributes are ordered by attribute-name, so you can easily use this
* method to compare YXmlElements
*
* @return {string} The string representation of this type.
*
* @public
*/ toString() {
const attrs = this.getAttributes();
const stringBuilder = [];
const keys = [];
for(const key in attrs)keys.push(key);
keys.sort();
const keysLen = keys.length;
for(let i = 0; i < keysLen; i++){
const key = keys[i];
stringBuilder.push(key + '="' + attrs[key] + '"');
}
const nodeName = this.nodeName.toLocaleLowerCase();
const attrsString = stringBuilder.length > 0 ? " " + stringBuilder.join(" ") : "";
return `<${nodeName}${attrsString}>${super.toString()}</${nodeName}>`;
}
/**
* Removes an attribute from this YXmlElement.
*
* @param {string} attributeName The attribute name that is to be removed.
*
* @public
*/ removeAttribute(attributeName) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeMapDelete(transaction, this, attributeName);
});
else /** @type {Map<string,any>} */ this._prelimAttrs.delete(attributeName);
}
/**
* Sets or updates an attribute.
*
* @template {keyof KV & string} KEY
*
* @param {KEY} attributeName The attribute name that is to be set.
* @param {KV[KEY]} attributeValue The attribute value that is to be set.
*
* @public
*/ setAttribute(attributeName, attributeValue) {
if (this.doc !== null) transact(this.doc, (transaction)=>{
typeMapSet(transaction, this, attributeName, attributeValue);
});
else /** @type {Map<string, any>} */ this._prelimAttrs.set(attributeName, attributeValue);
}
/**
* Returns an attribute value that belongs to the attribute name.
*
* @template {keyof KV & string} KEY
*
* @param {KEY} attributeName The attribute name that identifies the
* queried value.
* @return {KV[KEY]|undefined} The queried attribute value.
*
* @public
*/ getAttribute(attributeName) {
return /** @type {any} */ typeMapGet(this, attributeName);
}
/**
* Returns whether an attribute exists
*
* @param {string} attributeName The attribute name to check for existence.
* @return {boolean} whether the attribute exists.
*
* @public
*/ hasAttribute(attributeName) {
return /** @type {any} */ typeMapHas(this, attributeName);
}
/**
* Returns all attribute name/value pairs in a JSON Object.
*
* @param {Snapshot} [snapshot]
* @return {{ [Key in Extract<keyof KV,string>]?: KV[Key]}} A JSON Object that describes the attributes.
*
* @public
*/ getAttributes(snapshot) {
return /** @type {any} */ snapshot ? typeMapGetAllSnapshot(this, snapshot) : typeMapGetAll(this);
}
/**
* Creates a Dom Element that mirrors this YXmlElement.
*
* @param {Document} [_document=document] The document object (you must define
* this when calling this method in
* nodejs)
* @param {Object<string, any>} [hooks={}] Optional property to customize how hooks
* are presented in the DOM
* @param {any} [binding] You should not set this property. This is
* used if DomBinding wants to create a
* association to the created DOM type.
* @return {Node} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}
*
* @public
*/ toDOM(_document = document, hooks = {}, binding) {
const dom = _document.createElement(this.nodeName);
const attrs = this.getAttributes();
for(const key in attrs){
const value = attrs[key];
if (typeof value === "string") dom.setAttribute(key, value);
}
typeListForEach(this, (yxml)=>{
dom.appendChild(yxml.toDOM(_document, hooks, binding));
});
if (binding !== undefined) binding._createAssociation(dom, this);
return dom;
}
/**
* Transform the properties of this type to binary and write it to an
* BinaryEncoder.
*
* This is called when this Item is sent to a remote peer.
*
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
*/ _write(encoder) {
encoder.writeTypeRef(YXmlElementRefID);
encoder.writeKey(this.nodeName);
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {YXmlElement}
*
* @function
*/ const readYXmlElement = (decoder)=>new YXmlElement(decoder.readKey());
/**
* @extends YEvent<YXmlElement|YXmlText|YXmlFragment>
* An Event that describes changes on a YXml Element or Yxml Fragment
*/ class YXmlEvent extends YEvent {
/**
* @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
* @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
* child list changed.
* @param {Transaction} transaction The transaction instance with wich the
* change was created.
*/ constructor(target, subs, transaction){
super(target, transaction);
/**
* Whether the children changed.
* @type {Boolean}
* @private
*/ this.childListChanged = false;
/**
* Set of all changed attributes.
* @type {Set<string>}
*/ this.attributesChanged = new Set();
subs.forEach((sub)=>{
if (sub === null) this.childListChanged = true;
else this.attributesChanged.add(sub);
});
}
}
/**
* You can manage binding to a custom type with YXmlHook.
*
* @extends {YMap<any>}
*/ class YXmlHook extends YMap {
/**
* @param {string} hookName nodeName of the Dom Node.
*/ constructor(hookName){
super();
/**
* @type {string}
*/ this.hookName = hookName;
}
/**
* Creates an Item with the same effect as this Item (without position effect)
*/ _copy() {
return new YXmlHook(this.hookName);
}
/**
* Makes a copy of this data type that can be included somewhere else.
*
* Note that the content is only readable _after_ it has been included somewhere in the Ydoc.
*
* @return {YXmlHook}
*/ clone() {
const el = new YXmlHook(this.hookName);
this.forEach((value, key)=>{
el.set(key, value);
});
return el;
}
/**
* Creates a Dom Element that mirrors this YXmlElement.
*
* @param {Document} [_document=document] The document object (you must define
* this when calling this method in
* nodejs)
* @param {Object.<string, any>} [hooks] Optional property to customize how hooks
* are presented in the DOM
* @param {any} [binding] You should not set this property. This is
* used if DomBinding wants to create a
* association to the created DOM type
* @return {Element} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}
*
* @public
*/ toDOM(_document = document, hooks = {}, binding) {
const hook = hooks[this.hookName];
let dom;
if (hook !== undefined) dom = hook.createDom(this);
else dom = document.createElement(this.hookName);
dom.setAttribute("data-yjs-hook", this.hookName);
if (binding !== undefined) binding._createAssociation(dom, this);
return dom;
}
/**
* Transform the properties of this type to binary and write it to an
* BinaryEncoder.
*
* This is called when this Item is sent to a remote peer.
*
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
*/ _write(encoder) {
encoder.writeTypeRef(YXmlHookRefID);
encoder.writeKey(this.hookName);
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {YXmlHook}
*
* @private
* @function
*/ const readYXmlHook = (decoder)=>new YXmlHook(decoder.readKey());
/**
* Represents text in a Dom Element. In the future this type will also handle
* simple formatting information like bold and italic.
*/ class YXmlText extends YText {
/**
* @type {YXmlElement|YXmlText|null}
*/ get nextSibling() {
const n = this._item ? this._item.next : null;
return n ? /** @type {YXmlElement|YXmlText} */ /** @type {ContentType} */ n.content.type : null;
}
/**
* @type {YXmlElement|YXmlText|null}
*/ get prevSibling() {
const n = this._item ? this._item.prev : null;
return n ? /** @type {YXmlElement|YXmlText} */ /** @type {ContentType} */ n.content.type : null;
}
_copy() {
return new YXmlText();
}
/**
* Makes a copy of this data type that can be included somewhere else.
*
* Note that the content is only readable _after_ it has been included somewhere in the Ydoc.
*
* @return {YXmlText}
*/ clone() {
const text = new YXmlText();
text.applyDelta(this.toDelta());
return text;
}
/**
* Creates a Dom Element that mirrors this YXmlText.
*
* @param {Document} [_document=document] The document object (you must define
* this when calling this method in
* nodejs)
* @param {Object<string, any>} [hooks] Optional property to customize how hooks
* are presented in the DOM
* @param {any} [binding] You should not set this property. This is
* used if DomBinding wants to create a
* association to the created DOM type.
* @return {Text} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}
*
* @public
*/ toDOM(_document = document, hooks, binding) {
const dom = _document.createTextNode(this.toString());
if (binding !== undefined) binding._createAssociation(dom, this);
return dom;
}
toString() {
// @ts-ignore
return this.toDelta().map((delta)=>{
const nestedNodes = [];
for(const nodeName in delta.attributes){
const attrs = [];
for(const key in delta.attributes[nodeName])attrs.push({
key,
value: delta.attributes[nodeName][key]
});
// sort attributes to get a unique order
attrs.sort((a, b)=>a.key < b.key ? -1 : 1);
nestedNodes.push({
nodeName,
attrs
});
}
// sort node order to get a unique order
nestedNodes.sort((a, b)=>a.nodeName < b.nodeName ? -1 : 1);
// now convert to dom string
let str = "";
for(let i = 0; i < nestedNodes.length; i++){
const node = nestedNodes[i];
str += `<${node.nodeName}`;
for(let j = 0; j < node.attrs.length; j++){
const attr = node.attrs[j];
str += ` ${attr.key}="${attr.value}"`;
}
str += ">";
}
str += delta.insert;
for(let i = nestedNodes.length - 1; i >= 0; i--)str += `</${nestedNodes[i].nodeName}>`;
return str;
}).join("");
}
/**
* @return {string}
*/ toJSON() {
return this.toString();
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
*/ _write(encoder) {
encoder.writeTypeRef(YXmlTextRefID);
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {YXmlText}
*
* @private
* @function
*/ const readYXmlText = (decoder)=>new YXmlText();
class AbstractStruct {
/**
* @param {ID} id
* @param {number} length
*/ constructor(id, length){
this.id = id;
this.length = length;
}
/**
* @type {boolean}
*/ get deleted() {
throw _error.methodUnimplemented();
}
/**
* Merge this struct with the item to the right.
* This method is already assuming that `this.id.clock + this.length === this.id.clock`.
* Also this method does *not* remove right from StructStore!
* @param {AbstractStruct} right
* @return {boolean} wether this merged with right
*/ mergeWith(right) {
return false;
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
* @param {number} offset
* @param {number} encodingRef
*/ write(encoder, offset, encodingRef) {
throw _error.methodUnimplemented();
}
/**
* @param {Transaction} transaction
* @param {number} offset
*/ integrate(transaction, offset) {
throw _error.methodUnimplemented();
}
}
const structGCRefNumber = 0;
/**
* @private
*/ class GC extends AbstractStruct {
get deleted() {
return true;
}
delete() {}
/**
* @param {GC} right
* @return {boolean}
*/ mergeWith(right) {
if (this.constructor !== right.constructor) return false;
this.length += right.length;
return true;
}
/**
* @param {Transaction} transaction
* @param {number} offset
*/ integrate(transaction, offset) {
if (offset > 0) {
this.id.clock += offset;
this.length -= offset;
}
addStruct(transaction.doc.store, this);
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
encoder.writeInfo(structGCRefNumber);
encoder.writeLen(this.length - offset);
}
/**
* @param {Transaction} transaction
* @param {StructStore} store
* @return {null | number}
*/ getMissing(transaction, store) {
return null;
}
}
class ContentBinary {
/**
* @param {Uint8Array} content
*/ constructor(content){
this.content = content;
}
/**
* @return {number}
*/ getLength() {
return 1;
}
/**
* @return {Array<any>}
*/ getContent() {
return [
this.content
];
}
/**
* @return {boolean}
*/ isCountable() {
return true;
}
/**
* @return {ContentBinary}
*/ copy() {
return new ContentBinary(this.content);
}
/**
* @param {number} offset
* @return {ContentBinary}
*/ splice(offset) {
throw _error.methodUnimplemented();
}
/**
* @param {ContentBinary} right
* @return {boolean}
*/ mergeWith(right) {
return false;
}
/**
* @param {Transaction} transaction
* @param {Item} item
*/ integrate(transaction, item) {}
/**
* @param {Transaction} transaction
*/ delete(transaction) {}
/**
* @param {StructStore} store
*/ gc(store) {}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
encoder.writeBuf(this.content);
}
/**
* @return {number}
*/ getRef() {
return 3;
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2 } decoder
* @return {ContentBinary}
*/ const readContentBinary = (decoder)=>new ContentBinary(decoder.readBuf());
class ContentDeleted {
/**
* @param {number} len
*/ constructor(len){
this.len = len;
}
/**
* @return {number}
*/ getLength() {
return this.len;
}
/**
* @return {Array<any>}
*/ getContent() {
return [];
}
/**
* @return {boolean}
*/ isCountable() {
return false;
}
/**
* @return {ContentDeleted}
*/ copy() {
return new ContentDeleted(this.len);
}
/**
* @param {number} offset
* @return {ContentDeleted}
*/ splice(offset) {
const right = new ContentDeleted(this.len - offset);
this.len = offset;
return right;
}
/**
* @param {ContentDeleted} right
* @return {boolean}
*/ mergeWith(right) {
this.len += right.len;
return true;
}
/**
* @param {Transaction} transaction
* @param {Item} item
*/ integrate(transaction, item) {
addToDeleteSet(transaction.deleteSet, item.id.client, item.id.clock, this.len);
item.markDeleted();
}
/**
* @param {Transaction} transaction
*/ delete(transaction) {}
/**
* @param {StructStore} store
*/ gc(store) {}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
encoder.writeLen(this.len - offset);
}
/**
* @return {number}
*/ getRef() {
return 1;
}
}
/**
* @private
*
* @param {UpdateDecoderV1 | UpdateDecoderV2 } decoder
* @return {ContentDeleted}
*/ const readContentDeleted = (decoder)=>new ContentDeleted(decoder.readLen());
/**
* @param {string} guid
* @param {Object<string, any>} opts
*/ const createDocFromOpts = (guid, opts)=>new Doc({
guid,
...opts,
shouldLoad: opts.shouldLoad || opts.autoLoad || false
});
/**
* @private
*/ class ContentDoc {
/**
* @param {Doc} doc
*/ constructor(doc){
if (doc._item) console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");
/**
* @type {Doc}
*/ this.doc = doc;
/**
* @type {any}
*/ const opts = {};
this.opts = opts;
if (!doc.gc) opts.gc = false;
if (doc.autoLoad) opts.autoLoad = true;
if (doc.meta !== null) opts.meta = doc.meta;
}
/**
* @return {number}
*/ getLength() {
return 1;
}
/**
* @return {Array<any>}
*/ getContent() {
return [
this.doc
];
}
/**
* @return {boolean}
*/ isCountable() {
return true;
}
/**
* @return {ContentDoc}
*/ copy() {
return new ContentDoc(createDocFromOpts(this.doc.guid, this.opts));
}
/**
* @param {number} offset
* @return {ContentDoc}
*/ splice(offset) {
throw _error.methodUnimplemented();
}
/**
* @param {ContentDoc} right
* @return {boolean}
*/ mergeWith(right) {
return false;
}
/**
* @param {Transaction} transaction
* @param {Item} item
*/ integrate(transaction, item) {
// this needs to be reflected in doc.destroy as well
this.doc._item = item;
transaction.subdocsAdded.add(this.doc);
if (this.doc.shouldLoad) transaction.subdocsLoaded.add(this.doc);
}
/**
* @param {Transaction} transaction
*/ delete(transaction) {
if (transaction.subdocsAdded.has(this.doc)) transaction.subdocsAdded.delete(this.doc);
else transaction.subdocsRemoved.add(this.doc);
}
/**
* @param {StructStore} store
*/ gc(store) {}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
encoder.writeString(this.doc.guid);
encoder.writeAny(this.opts);
}
/**
* @return {number}
*/ getRef() {
return 9;
}
}
/**
* @private
*
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {ContentDoc}
*/ const readContentDoc = (decoder)=>new ContentDoc(createDocFromOpts(decoder.readString(), decoder.readAny()));
/**
* @private
*/ class ContentEmbed {
/**
* @param {Object} embed
*/ constructor(embed){
this.embed = embed;
}
/**
* @return {number}
*/ getLength() {
return 1;
}
/**
* @return {Array<any>}
*/ getContent() {
return [
this.embed
];
}
/**
* @return {boolean}
*/ isCountable() {
return true;
}
/**
* @return {ContentEmbed}
*/ copy() {
return new ContentEmbed(this.embed);
}
/**
* @param {number} offset
* @return {ContentEmbed}
*/ splice(offset) {
throw _error.methodUnimplemented();
}
/**
* @param {ContentEmbed} right
* @return {boolean}
*/ mergeWith(right) {
return false;
}
/**
* @param {Transaction} transaction
* @param {Item} item
*/ integrate(transaction, item) {}
/**
* @param {Transaction} transaction
*/ delete(transaction) {}
/**
* @param {StructStore} store
*/ gc(store) {}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
encoder.writeJSON(this.embed);
}
/**
* @return {number}
*/ getRef() {
return 5;
}
}
/**
* @private
*
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {ContentEmbed}
*/ const readContentEmbed = (decoder)=>new ContentEmbed(decoder.readJSON());
/**
* @private
*/ class ContentFormat {
/**
* @param {string} key
* @param {Object} value
*/ constructor(key, value){
this.key = key;
this.value = value;
}
/**
* @return {number}
*/ getLength() {
return 1;
}
/**
* @return {Array<any>}
*/ getContent() {
return [];
}
/**
* @return {boolean}
*/ isCountable() {
return false;
}
/**
* @return {ContentFormat}
*/ copy() {
return new ContentFormat(this.key, this.value);
}
/**
* @param {number} _offset
* @return {ContentFormat}
*/ splice(_offset) {
throw _error.methodUnimplemented();
}
/**
* @param {ContentFormat} _right
* @return {boolean}
*/ mergeWith(_right) {
return false;
}
/**
* @param {Transaction} _transaction
* @param {Item} item
*/ integrate(_transaction, item) {
// @todo searchmarker are currently unsupported for rich text documents
const p = /** @type {YText} */ item.parent;
p._searchMarker = null;
p._hasFormatting = true;
}
/**
* @param {Transaction} transaction
*/ delete(transaction) {}
/**
* @param {StructStore} store
*/ gc(store) {}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
encoder.writeKey(this.key);
encoder.writeJSON(this.value);
}
/**
* @return {number}
*/ getRef() {
return 6;
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {ContentFormat}
*/ const readContentFormat = (decoder)=>new ContentFormat(decoder.readKey(), decoder.readJSON());
/**
* @private
*/ class ContentJSON {
/**
* @param {Array<any>} arr
*/ constructor(arr){
/**
* @type {Array<any>}
*/ this.arr = arr;
}
/**
* @return {number}
*/ getLength() {
return this.arr.length;
}
/**
* @return {Array<any>}
*/ getContent() {
return this.arr;
}
/**
* @return {boolean}
*/ isCountable() {
return true;
}
/**
* @return {ContentJSON}
*/ copy() {
return new ContentJSON(this.arr);
}
/**
* @param {number} offset
* @return {ContentJSON}
*/ splice(offset) {
const right = new ContentJSON(this.arr.slice(offset));
this.arr = this.arr.slice(0, offset);
return right;
}
/**
* @param {ContentJSON} right
* @return {boolean}
*/ mergeWith(right) {
this.arr = this.arr.concat(right.arr);
return true;
}
/**
* @param {Transaction} transaction
* @param {Item} item
*/ integrate(transaction, item) {}
/**
* @param {Transaction} transaction
*/ delete(transaction) {}
/**
* @param {StructStore} store
*/ gc(store) {}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
const len = this.arr.length;
encoder.writeLen(len - offset);
for(let i = offset; i < len; i++){
const c = this.arr[i];
encoder.writeString(c === undefined ? "undefined" : JSON.stringify(c));
}
}
/**
* @return {number}
*/ getRef() {
return 2;
}
}
/**
* @private
*
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {ContentJSON}
*/ const readContentJSON = (decoder)=>{
const len = decoder.readLen();
const cs = [];
for(let i = 0; i < len; i++){
const c = decoder.readString();
if (c === "undefined") cs.push(undefined);
else cs.push(JSON.parse(c));
}
return new ContentJSON(cs);
};
class ContentAny {
/**
* @param {Array<any>} arr
*/ constructor(arr){
/**
* @type {Array<any>}
*/ this.arr = arr;
}
/**
* @return {number}
*/ getLength() {
return this.arr.length;
}
/**
* @return {Array<any>}
*/ getContent() {
return this.arr;
}
/**
* @return {boolean}
*/ isCountable() {
return true;
}
/**
* @return {ContentAny}
*/ copy() {
return new ContentAny(this.arr);
}
/**
* @param {number} offset
* @return {ContentAny}
*/ splice(offset) {
const right = new ContentAny(this.arr.slice(offset));
this.arr = this.arr.slice(0, offset);
return right;
}
/**
* @param {ContentAny} right
* @return {boolean}
*/ mergeWith(right) {
this.arr = this.arr.concat(right.arr);
return true;
}
/**
* @param {Transaction} transaction
* @param {Item} item
*/ integrate(transaction, item) {}
/**
* @param {Transaction} transaction
*/ delete(transaction) {}
/**
* @param {StructStore} store
*/ gc(store) {}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
const len = this.arr.length;
encoder.writeLen(len - offset);
for(let i = offset; i < len; i++){
const c = this.arr[i];
encoder.writeAny(c);
}
}
/**
* @return {number}
*/ getRef() {
return 8;
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {ContentAny}
*/ const readContentAny = (decoder)=>{
const len = decoder.readLen();
const cs = [];
for(let i = 0; i < len; i++)cs.push(decoder.readAny());
return new ContentAny(cs);
};
/**
* @private
*/ class ContentString {
/**
* @param {string} str
*/ constructor(str){
/**
* @type {string}
*/ this.str = str;
}
/**
* @return {number}
*/ getLength() {
return this.str.length;
}
/**
* @return {Array<any>}
*/ getContent() {
return this.str.split("");
}
/**
* @return {boolean}
*/ isCountable() {
return true;
}
/**
* @return {ContentString}
*/ copy() {
return new ContentString(this.str);
}
/**
* @param {number} offset
* @return {ContentString}
*/ splice(offset) {
const right = new ContentString(this.str.slice(offset));
this.str = this.str.slice(0, offset);
// Prevent encoding invalid documents because of splitting of surrogate pairs: https://github.com/yjs/yjs/issues/248
const firstCharCode = this.str.charCodeAt(offset - 1);
if (firstCharCode >= 0xD800 && firstCharCode <= 0xDBFF) {
// Last character of the left split is the start of a surrogate utf16/ucs2 pair.
// We don't support splitting of surrogate pairs because this may lead to invalid documents.
// Replace the invalid character with a unicode replacement character (<28> / U+FFFD)
this.str = this.str.slice(0, offset - 1) + "\uFFFD";
// replace right as well
right.str = "\uFFFD" + right.str.slice(1);
}
return right;
}
/**
* @param {ContentString} right
* @return {boolean}
*/ mergeWith(right) {
this.str += right.str;
return true;
}
/**
* @param {Transaction} transaction
* @param {Item} item
*/ integrate(transaction, item) {}
/**
* @param {Transaction} transaction
*/ delete(transaction) {}
/**
* @param {StructStore} store
*/ gc(store) {}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
encoder.writeString(offset === 0 ? this.str : this.str.slice(offset));
}
/**
* @return {number}
*/ getRef() {
return 4;
}
}
/**
* @private
*
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {ContentString}
*/ const readContentString = (decoder)=>new ContentString(decoder.readString());
/**
* @type {Array<function(UpdateDecoderV1 | UpdateDecoderV2):AbstractType<any>>}
* @private
*/ const typeRefs = [
readYArray,
readYMap,
readYText,
readYXmlElement,
readYXmlFragment,
readYXmlHook,
readYXmlText
];
const YArrayRefID = 0;
const YMapRefID = 1;
const YTextRefID = 2;
const YXmlElementRefID = 3;
const YXmlFragmentRefID = 4;
const YXmlHookRefID = 5;
const YXmlTextRefID = 6;
/**
* @private
*/ class ContentType {
/**
* @param {AbstractType<any>} type
*/ constructor(type){
/**
* @type {AbstractType<any>}
*/ this.type = type;
}
/**
* @return {number}
*/ getLength() {
return 1;
}
/**
* @return {Array<any>}
*/ getContent() {
return [
this.type
];
}
/**
* @return {boolean}
*/ isCountable() {
return true;
}
/**
* @return {ContentType}
*/ copy() {
return new ContentType(this.type._copy());
}
/**
* @param {number} offset
* @return {ContentType}
*/ splice(offset) {
throw _error.methodUnimplemented();
}
/**
* @param {ContentType} right
* @return {boolean}
*/ mergeWith(right) {
return false;
}
/**
* @param {Transaction} transaction
* @param {Item} item
*/ integrate(transaction, item) {
this.type._integrate(transaction.doc, item);
}
/**
* @param {Transaction} transaction
*/ delete(transaction) {
let item = this.type._start;
while(item !== null){
if (!item.deleted) item.delete(transaction);
else if (item.id.clock < (transaction.beforeState.get(item.id.client) || 0)) // This will be gc'd later and we want to merge it if possible
// We try to merge all deleted items after each transaction,
// but we have no knowledge about that this needs to be merged
// since it is not in transaction.ds. Hence we add it to transaction._mergeStructs
transaction._mergeStructs.push(item);
item = item.right;
}
this.type._map.forEach((item)=>{
if (!item.deleted) item.delete(transaction);
else if (item.id.clock < (transaction.beforeState.get(item.id.client) || 0)) // same as above
transaction._mergeStructs.push(item);
});
transaction.changed.delete(this.type);
}
/**
* @param {StructStore} store
*/ gc(store) {
let item = this.type._start;
while(item !== null){
item.gc(store, true);
item = item.right;
}
this.type._start = null;
this.type._map.forEach(/** @param {Item | null} item */ (item)=>{
while(item !== null){
item.gc(store, true);
item = item.left;
}
});
this.type._map = new Map();
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
this.type._write(encoder);
}
/**
* @return {number}
*/ getRef() {
return 7;
}
}
/**
* @private
*
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @return {ContentType}
*/ const readContentType = (decoder)=>new ContentType(typeRefs[decoder.readTypeRef()](decoder));
/**
* @todo This should return several items
*
* @param {StructStore} store
* @param {ID} id
* @return {{item:Item, diff:number}}
*/ const followRedone = (store, id)=>{
/**
* @type {ID|null}
*/ let nextID = id;
let diff = 0;
let item;
do {
if (diff > 0) nextID = createID(nextID.client, nextID.clock + diff);
item = getItem(store, nextID);
diff = nextID.clock - item.id.clock;
nextID = item.redone;
}while (nextID !== null && item instanceof Item);
return {
item,
diff
};
};
/**
* Make sure that neither item nor any of its parents is ever deleted.
*
* This property does not persist when storing it into a database or when
* sending it to other peers
*
* @param {Item|null} item
* @param {boolean} keep
*/ const keepItem = (item, keep)=>{
while(item !== null && item.keep !== keep){
item.keep = keep;
item = /** @type {AbstractType<any>} */ item.parent._item;
}
};
/**
* Split leftItem into two items
* @param {Transaction} transaction
* @param {Item} leftItem
* @param {number} diff
* @return {Item}
*
* @function
* @private
*/ const splitItem = (transaction, leftItem, diff)=>{
// create rightItem
const { client, clock } = leftItem.id;
const rightItem = new Item(createID(client, clock + diff), leftItem, createID(client, clock + diff - 1), leftItem.right, leftItem.rightOrigin, leftItem.parent, leftItem.parentSub, leftItem.content.splice(diff));
if (leftItem.deleted) rightItem.markDeleted();
if (leftItem.keep) rightItem.keep = true;
if (leftItem.redone !== null) rightItem.redone = createID(leftItem.redone.client, leftItem.redone.clock + diff);
// update left (do not set leftItem.rightOrigin as it will lead to problems when syncing)
leftItem.right = rightItem;
// update right
if (rightItem.right !== null) rightItem.right.left = rightItem;
// right is more specific.
transaction._mergeStructs.push(rightItem);
// update parent._map
if (rightItem.parentSub !== null && rightItem.right === null) /** @type {AbstractType<any>} */ rightItem.parent._map.set(rightItem.parentSub, rightItem);
leftItem.length = diff;
return rightItem;
};
/**
* @param {Array<StackItem>} stack
* @param {ID} id
*/ const isDeletedByUndoStack = (stack, id)=>_array.some(stack, /** @param {StackItem} s */ (s)=>isDeleted(s.deletions, id));
/**
* Redoes the effect of this operation.
*
* @param {Transaction} transaction The Yjs instance.
* @param {Item} item
* @param {Set<Item>} redoitems
* @param {DeleteSet} itemsToDelete
* @param {boolean} ignoreRemoteMapChanges
* @param {import('../utils/UndoManager.js').UndoManager} um
*
* @return {Item|null}
*
* @private
*/ const redoItem = (transaction, item, redoitems, itemsToDelete, ignoreRemoteMapChanges, um)=>{
const doc = transaction.doc;
const store = doc.store;
const ownClientID = doc.clientID;
const redone = item.redone;
if (redone !== null) return getItemCleanStart(transaction, redone);
let parentItem = /** @type {AbstractType<any>} */ item.parent._item;
/**
* @type {Item|null}
*/ let left = null;
/**
* @type {Item|null}
*/ let right;
// make sure that parent is redone
if (parentItem !== null && parentItem.deleted === true) {
// try to undo parent if it will be undone anyway
if (parentItem.redone === null && (!redoitems.has(parentItem) || redoItem(transaction, parentItem, redoitems, itemsToDelete, ignoreRemoteMapChanges, um) === null)) return null;
while(parentItem.redone !== null)parentItem = getItemCleanStart(transaction, parentItem.redone);
}
const parentType = parentItem === null ? /** @type {AbstractType<any>} */ item.parent : /** @type {ContentType} */ parentItem.content.type;
if (item.parentSub === null) {
// Is an array item. Insert at the old position
left = item.left;
right = item;
// find next cloned_redo items
while(left !== null){
/**
* @type {Item|null}
*/ let leftTrace = left;
// trace redone until parent matches
while(leftTrace !== null && /** @type {AbstractType<any>} */ leftTrace.parent._item !== parentItem)leftTrace = leftTrace.redone === null ? null : getItemCleanStart(transaction, leftTrace.redone);
if (leftTrace !== null && /** @type {AbstractType<any>} */ leftTrace.parent._item === parentItem) {
left = leftTrace;
break;
}
left = left.left;
}
while(right !== null){
/**
* @type {Item|null}
*/ let rightTrace = right;
// trace redone until parent matches
while(rightTrace !== null && /** @type {AbstractType<any>} */ rightTrace.parent._item !== parentItem)rightTrace = rightTrace.redone === null ? null : getItemCleanStart(transaction, rightTrace.redone);
if (rightTrace !== null && /** @type {AbstractType<any>} */ rightTrace.parent._item === parentItem) {
right = rightTrace;
break;
}
right = right.right;
}
} else {
right = null;
if (item.right && !ignoreRemoteMapChanges) {
left = item;
// Iterate right while right is in itemsToDelete
// If it is intended to delete right while item is redone, we can expect that item should replace right.
while(left !== null && left.right !== null && (left.right.redone || isDeleted(itemsToDelete, left.right.id) || isDeletedByUndoStack(um.undoStack, left.right.id) || isDeletedByUndoStack(um.redoStack, left.right.id))){
left = left.right;
// follow redone
while(left.redone)left = getItemCleanStart(transaction, left.redone);
}
if (left && left.right !== null) // It is not possible to redo this item because it conflicts with a
// change from another client
return null;
} else left = parentType._map.get(item.parentSub) || null;
}
const nextClock = getState(store, ownClientID);
const nextId = createID(ownClientID, nextClock);
const redoneItem = new Item(nextId, left, left && left.lastId, right, right && right.id, parentType, item.parentSub, item.content.copy());
item.redone = nextId;
keepItem(redoneItem, true);
redoneItem.integrate(transaction, 0);
return redoneItem;
};
/**
* Abstract class that represents any content.
*/ class Item extends AbstractStruct {
/**
* @param {ID} id
* @param {Item | null} left
* @param {ID | null} origin
* @param {Item | null} right
* @param {ID | null} rightOrigin
* @param {AbstractType<any>|ID|null} parent Is a type if integrated, is null if it is possible to copy parent from left or right, is ID before integration to search for it.
* @param {string | null} parentSub
* @param {AbstractContent} content
*/ constructor(id, left, origin, right, rightOrigin, parent, parentSub, content){
super(id, content.getLength());
/**
* The item that was originally to the left of this item.
* @type {ID | null}
*/ this.origin = origin;
/**
* The item that is currently to the left of this item.
* @type {Item | null}
*/ this.left = left;
/**
* The item that is currently to the right of this item.
* @type {Item | null}
*/ this.right = right;
/**
* The item that was originally to the right of this item.
* @type {ID | null}
*/ this.rightOrigin = rightOrigin;
/**
* @type {AbstractType<any>|ID|null}
*/ this.parent = parent;
/**
* If the parent refers to this item with some kind of key (e.g. YMap, the
* key is specified here. The key is then used to refer to the list in which
* to insert this item. If `parentSub = null` type._start is the list in
* which to insert to. Otherwise it is `parent._map`.
* @type {String | null}
*/ this.parentSub = parentSub;
/**
* If this type's effect is redone this type refers to the type that undid
* this operation.
* @type {ID | null}
*/ this.redone = null;
/**
* @type {AbstractContent}
*/ this.content = content;
/**
* bit1: keep
* bit2: countable
* bit3: deleted
* bit4: mark - mark node as fast-search-marker
* @type {number} byte
*/ this.info = this.content.isCountable() ? _binary.BIT2 : 0;
}
/**
* This is used to mark the item as an indexed fast-search marker
*
* @type {boolean}
*/ set marker(isMarked) {
if ((this.info & _binary.BIT4) > 0 !== isMarked) this.info ^= _binary.BIT4;
}
get marker() {
return (this.info & _binary.BIT4) > 0;
}
/**
* If true, do not garbage collect this Item.
*/ get keep() {
return (this.info & _binary.BIT1) > 0;
}
set keep(doKeep) {
if (this.keep !== doKeep) this.info ^= _binary.BIT1;
}
get countable() {
return (this.info & _binary.BIT2) > 0;
}
/**
* Whether this item was deleted or not.
* @type {Boolean}
*/ get deleted() {
return (this.info & _binary.BIT3) > 0;
}
set deleted(doDelete) {
if (this.deleted !== doDelete) this.info ^= _binary.BIT3;
}
markDeleted() {
this.info |= _binary.BIT3;
}
/**
* Return the creator clientID of the missing op or define missing items and return null.
*
* @param {Transaction} transaction
* @param {StructStore} store
* @return {null | number}
*/ getMissing(transaction, store) {
if (this.origin && this.origin.client !== this.id.client && this.origin.clock >= getState(store, this.origin.client)) return this.origin.client;
if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= getState(store, this.rightOrigin.client)) return this.rightOrigin.client;
if (this.parent && this.parent.constructor === ID && this.id.client !== this.parent.client && this.parent.clock >= getState(store, this.parent.client)) return this.parent.client;
// We have all missing ids, now find the items
if (this.origin) {
this.left = getItemCleanEnd(transaction, store, this.origin);
this.origin = this.left.lastId;
}
if (this.rightOrigin) {
this.right = getItemCleanStart(transaction, this.rightOrigin);
this.rightOrigin = this.right.id;
}
if (this.left && this.left.constructor === GC || this.right && this.right.constructor === GC) this.parent = null;
else if (!this.parent) {
// only set parent if this shouldn't be garbage collected
if (this.left && this.left.constructor === Item) {
this.parent = this.left.parent;
this.parentSub = this.left.parentSub;
}
if (this.right && this.right.constructor === Item) {
this.parent = this.right.parent;
this.parentSub = this.right.parentSub;
}
} else if (this.parent.constructor === ID) {
const parentItem = getItem(store, this.parent);
if (parentItem.constructor === GC) this.parent = null;
else this.parent = /** @type {ContentType} */ parentItem.content.type;
}
return null;
}
/**
* @param {Transaction} transaction
* @param {number} offset
*/ integrate(transaction, offset) {
if (offset > 0) {
this.id.clock += offset;
this.left = getItemCleanEnd(transaction, transaction.doc.store, createID(this.id.client, this.id.clock - 1));
this.origin = this.left.lastId;
this.content = this.content.splice(offset);
this.length -= offset;
}
if (this.parent) {
if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
/**
* @type {Item|null}
*/ let left = this.left;
/**
* @type {Item|null}
*/ let o;
// set o to the first conflicting item
if (left !== null) o = left.right;
else if (this.parentSub !== null) {
o = /** @type {AbstractType<any>} */ this.parent._map.get(this.parentSub) || null;
while(o !== null && o.left !== null)o = o.left;
} else o = /** @type {AbstractType<any>} */ this.parent._start;
// TODO: use something like DeleteSet here (a tree implementation would be best)
// @todo use global set definitions
/**
* @type {Set<Item>}
*/ const conflictingItems = new Set();
/**
* @type {Set<Item>}
*/ const itemsBeforeOrigin = new Set();
// Let c in conflictingItems, b in itemsBeforeOrigin
// ***{origin}bbbb{this}{c,b}{c,b}{o}***
// Note that conflictingItems is a subset of itemsBeforeOrigin
while(o !== null && o !== this.right){
itemsBeforeOrigin.add(o);
conflictingItems.add(o);
if (compareIDs(this.origin, o.origin)) {
// case 1
if (o.id.client < this.id.client) {
left = o;
conflictingItems.clear();
} else if (compareIDs(this.rightOrigin, o.rightOrigin)) break;
// else, o might be integrated before an item that this conflicts with. If so, we will find it in the next iterations
} else if (o.origin !== null && itemsBeforeOrigin.has(getItem(transaction.doc.store, o.origin))) // case 2
{
if (!conflictingItems.has(getItem(transaction.doc.store, o.origin))) {
left = o;
conflictingItems.clear();
}
} else break;
o = o.right;
}
this.left = left;
}
// reconnect left/right + update parent map/start if necessary
if (this.left !== null) {
const right = this.left.right;
this.right = right;
this.left.right = this;
} else {
let r;
if (this.parentSub !== null) {
r = /** @type {AbstractType<any>} */ this.parent._map.get(this.parentSub) || null;
while(r !== null && r.left !== null)r = r.left;
} else {
r = /** @type {AbstractType<any>} */ this.parent._start; /** @type {AbstractType<any>} */
this.parent._start = this;
}
this.right = r;
}
if (this.right !== null) this.right.left = this;
else if (this.parentSub !== null) {
// set as current parent value if right === null and this is parentSub
/** @type {AbstractType<any>} */ this.parent._map.set(this.parentSub, this);
if (this.left !== null) // this is the current attribute value of parent. delete right
this.left.delete(transaction);
}
// adjust length of parent
if (this.parentSub === null && this.countable && !this.deleted) /** @type {AbstractType<any>} */ this.parent._length += this.length;
addStruct(transaction.doc.store, this);
this.content.integrate(transaction, this);
// add parent to transaction.changed
addChangedTypeToTransaction(transaction, /** @type {AbstractType<any>} */ this.parent, this.parentSub);
if (/** @type {AbstractType<any>} */ this.parent._item !== null && /** @type {AbstractType<any>} */ this.parent._item.deleted || this.parentSub !== null && this.right !== null) // delete if parent is deleted or if this is not the current attribute value of parent
this.delete(transaction);
} else // parent is not defined. Integrate GC struct instead
new GC(this.id, this.length).integrate(transaction, 0);
}
/**
* Returns the next non-deleted item
*/ get next() {
let n = this.right;
while(n !== null && n.deleted)n = n.right;
return n;
}
/**
* Returns the previous non-deleted item
*/ get prev() {
let n = this.left;
while(n !== null && n.deleted)n = n.left;
return n;
}
/**
* Computes the last content address of this Item.
*/ get lastId() {
// allocating ids is pretty costly because of the amount of ids created, so we try to reuse whenever possible
return this.length === 1 ? this.id : createID(this.id.client, this.id.clock + this.length - 1);
}
/**
* Try to merge two items
*
* @param {Item} right
* @return {boolean}
*/ mergeWith(right) {
if (this.constructor === right.constructor && compareIDs(right.origin, this.lastId) && this.right === right && compareIDs(this.rightOrigin, right.rightOrigin) && this.id.client === right.id.client && this.id.clock + this.length === right.id.clock && this.deleted === right.deleted && this.redone === null && right.redone === null && this.content.constructor === right.content.constructor && this.content.mergeWith(right.content)) {
const searchMarker = /** @type {AbstractType<any>} */ this.parent._searchMarker;
if (searchMarker) searchMarker.forEach((marker)=>{
if (marker.p === right) {
// right is going to be "forgotten" so we need to update the marker
marker.p = this;
// adjust marker index
if (!this.deleted && this.countable) marker.index -= this.length;
}
});
if (right.keep) this.keep = true;
this.right = right.right;
if (this.right !== null) this.right.left = this;
this.length += right.length;
return true;
}
return false;
}
/**
* Mark this Item as deleted.
*
* @param {Transaction} transaction
*/ delete(transaction) {
if (!this.deleted) {
const parent = /** @type {AbstractType<any>} */ this.parent;
// adjust the length of parent
if (this.countable && this.parentSub === null) parent._length -= this.length;
this.markDeleted();
addToDeleteSet(transaction.deleteSet, this.id.client, this.id.clock, this.length);
addChangedTypeToTransaction(transaction, parent, this.parentSub);
this.content.delete(transaction);
}
}
/**
* @param {StructStore} store
* @param {boolean} parentGCd
*/ gc(store, parentGCd) {
if (!this.deleted) throw _error.unexpectedCase();
this.content.gc(store);
if (parentGCd) replaceStruct(store, this, new GC(this.id, this.length));
else this.content = new ContentDeleted(this.length);
}
/**
* Transform the properties of this type to binary and write it to an
* BinaryEncoder.
*
* This is called when this Item is sent to a remote peer.
*
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
* @param {number} offset
*/ write(encoder, offset) {
const origin = offset > 0 ? createID(this.id.client, this.id.clock + offset - 1) : this.origin;
const rightOrigin = this.rightOrigin;
const parentSub = this.parentSub;
const info = this.content.getRef() & _binary.BITS5 | (origin === null ? 0 : _binary.BIT8) | // origin is defined
(rightOrigin === null ? 0 : _binary.BIT7) | // right origin is defined
(parentSub === null ? 0 : _binary.BIT6); // parentSub is non-null
encoder.writeInfo(info);
if (origin !== null) encoder.writeLeftID(origin);
if (rightOrigin !== null) encoder.writeRightID(rightOrigin);
if (origin === null && rightOrigin === null) {
const parent = /** @type {AbstractType<any>} */ this.parent;
if (parent._item !== undefined) {
const parentItem = parent._item;
if (parentItem === null) {
// parent type on y._map
// find the correct key
const ykey = findRootTypeKey(parent);
encoder.writeParentInfo(true); // write parentYKey
encoder.writeString(ykey);
} else {
encoder.writeParentInfo(false); // write parent id
encoder.writeLeftID(parentItem.id);
}
} else if (parent.constructor === String) {
encoder.writeParentInfo(true); // write parentYKey
encoder.writeString(parent);
} else if (parent.constructor === ID) {
encoder.writeParentInfo(false); // write parent id
encoder.writeLeftID(parent);
} else _error.unexpectedCase();
if (parentSub !== null) encoder.writeString(parentSub);
}
this.content.write(encoder, offset);
}
}
/**
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
* @param {number} info
*/ const readItemContent = (decoder, info)=>contentRefs[info & _binary.BITS5](decoder);
/**
* A lookup map for reading Item content.
*
* @type {Array<function(UpdateDecoderV1 | UpdateDecoderV2):AbstractContent>}
*/ const contentRefs = [
()=>{
_error.unexpectedCase();
},
readContentDeleted,
readContentJSON,
readContentBinary,
readContentString,
readContentEmbed,
readContentFormat,
readContentType,
readContentAny,
readContentDoc,
()=>{
_error.unexpectedCase();
} // 10 - Skip is not ItemContent
];
const structSkipRefNumber = 10;
/**
* @private
*/ class Skip extends AbstractStruct {
get deleted() {
return true;
}
delete() {}
/**
* @param {Skip} right
* @return {boolean}
*/ mergeWith(right) {
if (this.constructor !== right.constructor) return false;
this.length += right.length;
return true;
}
/**
* @param {Transaction} transaction
* @param {number} offset
*/ integrate(transaction, offset) {
// skip structs cannot be integrated
_error.unexpectedCase();
}
/**
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
* @param {number} offset
*/ write(encoder, offset) {
encoder.writeInfo(structSkipRefNumber);
// write as VarUint because Skips can't make use of predictable length-encoding
_encoding.writeVarUint(encoder.restEncoder, this.length - offset);
}
/**
* @param {Transaction} transaction
* @param {StructStore} store
* @return {null | number}
*/ getMissing(transaction, store) {
return null;
}
}
/** eslint-env browser */ const glo = /** @type {any} */ typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
const importIdentifier = "__ $YJS$ __";
if (glo[importIdentifier] === true) /**
* Dear reader of this message. Please take this seriously.
*
* If you see this message, make sure that you only import one version of Yjs. In many cases,
* your package manager installs two versions of Yjs that are used by different packages within your project.
* Another reason for this message is that some parts of your project use the commonjs version of Yjs
* and others use the EcmaScript version of Yjs.
*
* This often leads to issues that are hard to debug. We often need to perform constructor checks,
* e.g. `struct instanceof GC`. If you imported different versions of Yjs, it is impossible for us to
* do the constructor checks anymore - which might break the CRDT algorithm.
*
* https://github.com/yjs/yjs/issues/438
*/ console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
glo[importIdentifier] = true;
},{"lib0/observable":"4i7Nc","lib0/array":"fZD9X","lib0/math":"bBwSk","lib0/map":"1FJ4I","lib0/encoding":"8PAaf","lib0/decoding":"JPRoL","lib0/random":"blzcp","lib0/promise":"a6WAk","lib0/buffer":"2AAU4","lib0/error":"7eWBR","lib0/binary":"lsQIT","lib0/function":"dS7sP","lib0/set":"8kG8c","lib0/logging":"8fiiS","lib0/time":"8mk6w","lib0/string":"liNHi","lib0/iterator":"8ANgc","lib0/object":"fN1Sq","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"4i7Nc":[function(require,module,exports) {
/**
* Observable class prototype.
*
* @module observable
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
/**
* Handles named events.
* @experimental
*
* This is basically a (better typed) duplicate of Observable, which will replace Observable in the
* next release.
*
* @template {{[key in keyof EVENTS]: function(...any):void}} EVENTS
*/ parcelHelpers.export(exports, "ObservableV2", ()=>ObservableV2);
/* c8 ignore start */ /**
* Handles named events.
*
* @deprecated
* @template N
*/ parcelHelpers.export(exports, "Observable", ()=>Observable) /* c8 ignore end */ ;
var _mapJs = require("./map.js");
var _setJs = require("./set.js");
var _arrayJs = require("./array.js");
class ObservableV2 {
constructor(){
/**
* Some desc.
* @type {Map<string, Set<any>>}
*/ this._observers = _mapJs.create();
}
/**
* @template {keyof EVENTS & string} NAME
* @param {NAME} name
* @param {EVENTS[NAME]} f
*/ on(name, f) {
_mapJs.setIfUndefined(this._observers, /** @type {string} */ name, _setJs.create).add(f);
return f;
}
/**
* @template {keyof EVENTS & string} NAME
* @param {NAME} name
* @param {EVENTS[NAME]} f
*/ once(name, f) {
/**
* @param {...any} args
*/ const _f = (...args)=>{
this.off(name, /** @type {any} */ _f);
f(...args);
};
this.on(name, /** @type {any} */ _f);
}
/**
* @template {keyof EVENTS & string} NAME
* @param {NAME} name
* @param {EVENTS[NAME]} f
*/ off(name, f) {
const observers = this._observers.get(name);
if (observers !== undefined) {
observers.delete(f);
if (observers.size === 0) this._observers.delete(name);
}
}
/**
* Emit a named event. All registered event listeners that listen to the
* specified name will receive the event.
*
* @todo This should catch exceptions
*
* @template {keyof EVENTS & string} NAME
* @param {NAME} name The event name.
* @param {Parameters<EVENTS[NAME]>} args The arguments that are applied to the event listener.
*/ emit(name, args) {
// copy all listeners to an array first to make sure that no event is emitted to listeners that are subscribed while the event handler is called.
return _arrayJs.from((this._observers.get(name) || _mapJs.create()).values()).forEach((f)=>f(...args));
}
destroy() {
this._observers = _mapJs.create();
}
}
class Observable {
constructor(){
/**
* Some desc.
* @type {Map<N, any>}
*/ this._observers = _mapJs.create();
}
/**
* @param {N} name
* @param {function} f
*/ on(name, f) {
_mapJs.setIfUndefined(this._observers, name, _setJs.create).add(f);
}
/**
* @param {N} name
* @param {function} f
*/ once(name, f) {
/**
* @param {...any} args
*/ const _f = (...args)=>{
this.off(name, _f);
f(...args);
};
this.on(name, _f);
}
/**
* @param {N} name
* @param {function} f
*/ off(name, f) {
const observers = this._observers.get(name);
if (observers !== undefined) {
observers.delete(f);
if (observers.size === 0) this._observers.delete(name);
}
}
/**
* Emit a named event. All registered event listeners that listen to the
* specified name will receive the event.
*
* @todo This should catch exceptions
*
* @param {N} name The event name.
* @param {Array<any>} args The arguments that are applied to the event listener.
*/ emit(name, args) {
// copy all listeners to an array first to make sure that no event is emitted to listeners that are subscribed while the event handler is called.
return _arrayJs.from((this._observers.get(name) || _mapJs.create()).values()).forEach((f)=>f(...args));
}
destroy() {
this._observers = _mapJs.create();
}
}
},{"./map.js":"1FJ4I","./set.js":"8kG8c","./array.js":"fZD9X","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"1FJ4I":[function(require,module,exports) {
/**
* Utility module to work with key-value stores.
*
* @module map
*/ /**
* Creates a new Map instance.
*
* @function
* @return {Map<any, any>}
*
* @function
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "create", ()=>create);
parcelHelpers.export(exports, "copy", ()=>copy);
parcelHelpers.export(exports, "setIfUndefined", ()=>setIfUndefined);
parcelHelpers.export(exports, "map", ()=>map);
parcelHelpers.export(exports, "any", ()=>any);
parcelHelpers.export(exports, "all", ()=>all);
const create = ()=>new Map();
const copy = (m)=>{
const r = create();
m.forEach((v, k)=>{
r.set(k, v);
});
return r;
};
const setIfUndefined = (map, key, createT)=>{
let set = map.get(key);
if (set === undefined) map.set(key, set = createT());
return set;
};
const map = (m, f)=>{
const res = [];
for (const [key, value] of m)res.push(f(value, key));
return res;
};
const any = (m, f)=>{
for (const [key, value] of m){
if (f(value, key)) return true;
}
return false;
};
const all = (m, f)=>{
for (const [key, value] of m){
if (!f(value, key)) return false;
}
return true;
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8kG8c":[function(require,module,exports) {
/**
* Utility module to work with sets.
*
* @module set
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "create", ()=>create);
parcelHelpers.export(exports, "toArray", ()=>toArray);
parcelHelpers.export(exports, "first", ()=>first);
parcelHelpers.export(exports, "from", ()=>from);
const create = ()=>new Set();
const toArray = (set)=>Array.from(set);
const first = (set)=>set.values().next().value || undefined;
const from = (entries)=>new Set(entries);
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fZD9X":[function(require,module,exports) {
/**
* Utility module to work with Arrays.
*
* @module array
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "last", ()=>last);
parcelHelpers.export(exports, "create", ()=>create);
parcelHelpers.export(exports, "copy", ()=>copy);
parcelHelpers.export(exports, "appendTo", ()=>appendTo);
parcelHelpers.export(exports, "from", ()=>from);
parcelHelpers.export(exports, "every", ()=>every);
parcelHelpers.export(exports, "some", ()=>some);
parcelHelpers.export(exports, "equalFlat", ()=>equalFlat);
parcelHelpers.export(exports, "flatten", ()=>flatten);
parcelHelpers.export(exports, "unfold", ()=>unfold);
parcelHelpers.export(exports, "fold", ()=>fold);
parcelHelpers.export(exports, "isArray", ()=>isArray);
parcelHelpers.export(exports, "unique", ()=>unique);
parcelHelpers.export(exports, "uniqueBy", ()=>uniqueBy);
parcelHelpers.export(exports, "map", ()=>map);
var _setJs = require("./set.js");
const last = (arr)=>arr[arr.length - 1];
const create = ()=>/** @type {Array<C>} */ [];
const copy = (a)=>/** @type {Array<D>} */ a.slice();
const appendTo = (dest, src)=>{
for(let i = 0; i < src.length; i++)dest.push(src[i]);
};
const from = Array.from;
const every = (arr, f)=>{
for(let i = 0; i < arr.length; i++){
if (!f(arr[i], i, arr)) return false;
}
return true;
};
const some = (arr, f)=>{
for(let i = 0; i < arr.length; i++){
if (f(arr[i], i, arr)) return true;
}
return false;
};
const equalFlat = (a, b)=>a.length === b.length && every(a, (item, index)=>item === b[index]);
const flatten = (arr)=>fold(arr, /** @type {Array<ELEM>} */ [], (acc, val)=>acc.concat(val));
const unfold = (len, f)=>{
const array = new Array(len);
for(let i = 0; i < len; i++)array[i] = f(i, array);
return array;
};
const fold = (arr, seed, folder)=>arr.reduce(folder, seed);
const isArray = Array.isArray;
const unique = (arr)=>from(_setJs.from(arr));
const uniqueBy = (arr, mapper)=>{
/**
* @type {Set<M>}
*/ const happened = _setJs.create();
/**
* @type {Array<T>}
*/ const result = [];
for(let i = 0; i < arr.length; i++){
const el = arr[i];
const mapped = mapper(el);
if (!happened.has(mapped)) {
happened.add(mapped);
result.push(el);
}
}
return result;
};
const map = (arr, mapper)=>{
/**
* @type {Array<any>}
*/ const res = Array(arr.length);
for(let i = 0; i < arr.length; i++)res[i] = mapper(/** @type {any} */ arr[i], i, /** @type {any} */ arr);
return /** @type {any} */ res;
};
},{"./set.js":"8kG8c","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"bBwSk":[function(require,module,exports) {
/**
* Common Math expressions.
*
* @module math
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "floor", ()=>floor);
parcelHelpers.export(exports, "ceil", ()=>ceil);
parcelHelpers.export(exports, "abs", ()=>abs);
parcelHelpers.export(exports, "imul", ()=>imul);
parcelHelpers.export(exports, "round", ()=>round);
parcelHelpers.export(exports, "log10", ()=>log10);
parcelHelpers.export(exports, "log2", ()=>log2);
parcelHelpers.export(exports, "log", ()=>log);
parcelHelpers.export(exports, "sqrt", ()=>sqrt);
parcelHelpers.export(exports, "add", ()=>add);
parcelHelpers.export(exports, "min", ()=>min);
parcelHelpers.export(exports, "max", ()=>max);
parcelHelpers.export(exports, "isNaN", ()=>isNaN);
parcelHelpers.export(exports, "pow", ()=>pow);
parcelHelpers.export(exports, "exp10", ()=>exp10);
parcelHelpers.export(exports, "sign", ()=>sign);
parcelHelpers.export(exports, "isNegativeZero", ()=>isNegativeZero);
const floor = Math.floor;
const ceil = Math.ceil;
const abs = Math.abs;
const imul = Math.imul;
const round = Math.round;
const log10 = Math.log10;
const log2 = Math.log2;
const log = Math.log;
const sqrt = Math.sqrt;
const add = (a, b)=>a + b;
const min = (a, b)=>a < b ? a : b;
const max = (a, b)=>a > b ? a : b;
const isNaN = Number.isNaN;
const pow = Math.pow;
const exp10 = (exp)=>Math.pow(10, exp);
const sign = Math.sign;
const isNegativeZero = (n)=>n !== 0 ? n < 0 : 1 / n < 0;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8PAaf":[function(require,module,exports) {
/**
* Efficient schema-less binary encoding with support for variable length encoding.
*
* Use [lib0/encoding] with [lib0/decoding]. Every encoding function has a corresponding decoding function.
*
* Encodes numbers in little-endian order (least to most significant byte order)
* and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)
* which is also used in Protocol Buffers.
*
* ```js
* // encoding step
* const encoder = encoding.createEncoder()
* encoding.writeVarUint(encoder, 256)
* encoding.writeVarString(encoder, 'Hello world!')
* const buf = encoding.toUint8Array(encoder)
* ```
*
* ```js
* // decoding step
* const decoder = decoding.createDecoder(buf)
* decoding.readVarUint(decoder) // => 256
* decoding.readVarString(decoder) // => 'Hello world!'
* decoding.hasContent(decoder) // => false - all data is read
* ```
*
* @module encoding
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
/**
* A BinaryEncoder handles the encoding to an Uint8Array.
*/ parcelHelpers.export(exports, "Encoder", ()=>Encoder);
parcelHelpers.export(exports, "createEncoder", ()=>createEncoder);
parcelHelpers.export(exports, "encode", ()=>encode);
parcelHelpers.export(exports, "length", ()=>length);
parcelHelpers.export(exports, "hasContent", ()=>hasContent);
parcelHelpers.export(exports, "toUint8Array", ()=>toUint8Array);
parcelHelpers.export(exports, "verifyLen", ()=>verifyLen);
parcelHelpers.export(exports, "write", ()=>write);
parcelHelpers.export(exports, "set", ()=>set);
parcelHelpers.export(exports, "writeUint8", ()=>writeUint8);
parcelHelpers.export(exports, "setUint8", ()=>setUint8);
parcelHelpers.export(exports, "writeUint16", ()=>writeUint16);
parcelHelpers.export(exports, "setUint16", ()=>setUint16);
parcelHelpers.export(exports, "writeUint32", ()=>writeUint32);
parcelHelpers.export(exports, "writeUint32BigEndian", ()=>writeUint32BigEndian);
parcelHelpers.export(exports, "setUint32", ()=>setUint32);
parcelHelpers.export(exports, "writeVarUint", ()=>writeVarUint);
parcelHelpers.export(exports, "writeVarInt", ()=>writeVarInt);
parcelHelpers.export(exports, "_writeVarStringNative", ()=>_writeVarStringNative);
parcelHelpers.export(exports, "_writeVarStringPolyfill", ()=>_writeVarStringPolyfill);
parcelHelpers.export(exports, "writeVarString", ()=>writeVarString);
parcelHelpers.export(exports, "writeTerminatedString", ()=>writeTerminatedString);
parcelHelpers.export(exports, "writeTerminatedUint8Array", ()=>writeTerminatedUint8Array);
parcelHelpers.export(exports, "writeBinaryEncoder", ()=>writeBinaryEncoder);
parcelHelpers.export(exports, "writeUint8Array", ()=>writeUint8Array);
parcelHelpers.export(exports, "writeVarUint8Array", ()=>writeVarUint8Array);
parcelHelpers.export(exports, "writeOnDataView", ()=>writeOnDataView);
parcelHelpers.export(exports, "writeFloat32", ()=>writeFloat32);
parcelHelpers.export(exports, "writeFloat64", ()=>writeFloat64);
parcelHelpers.export(exports, "writeBigInt64", ()=>writeBigInt64);
parcelHelpers.export(exports, "writeBigUint64", ()=>writeBigUint64);
parcelHelpers.export(exports, "writeAny", ()=>writeAny);
/**
* Now come a few stateful encoder that have their own classes.
*/ /**
* Basic Run Length Encoder - a basic compression implementation.
*
* Encodes [1,1,1,7] to [1,3,7,1] (3 times 1, 1 time 7). This encoder might do more harm than good if there are a lot of values that are not repeated.
*
* It was originally used for image compression. Cool .. article http://csbruce.com/cbm/transactor/pdfs/trans_v7_i06.pdf
*
* @note T must not be null!
*
* @template T
*/ parcelHelpers.export(exports, "RleEncoder", ()=>RleEncoder);
/**
* Basic diff decoder using variable length encoding.
*
* Encodes the values [3, 1100, 1101, 1050, 0] to [3, 1097, 1, -51, -1050] using writeVarInt.
*/ parcelHelpers.export(exports, "IntDiffEncoder", ()=>IntDiffEncoder);
/**
* A combination of IntDiffEncoder and RleEncoder.
*
* Basically first writes the IntDiffEncoder and then counts duplicate diffs using RleEncoding.
*
* Encodes the values [1,1,1,2,3,4,5,6] as [1,1,0,2,1,5] (RLE([1,0,0,1,1,1,1,1]) ⇒ RleIntDiff[1,1,0,2,1,5])
*/ parcelHelpers.export(exports, "RleIntDiffEncoder", ()=>RleIntDiffEncoder);
/**
* Optimized Rle encoder that does not suffer from the mentioned problem of the basic Rle encoder.
*
* Internally uses VarInt encoder to write unsigned integers. If the input occurs multiple times, we write
* write it as a negative number. The UintOptRleDecoder then understands that it needs to read a count.
*
* Encodes [1,2,3,3,3] as [1,2,-3,3] (once 1, once 2, three times 3)
*/ parcelHelpers.export(exports, "UintOptRleEncoder", ()=>UintOptRleEncoder);
/**
* Increasing Uint Optimized RLE Encoder
*
* The RLE encoder counts the number of same occurences of the same value.
* The IncUintOptRle encoder counts if the value increases.
* I.e. 7, 8, 9, 10 will be encoded as [-7, 4]. 1, 3, 5 will be encoded
* as [1, 3, 5].
*/ parcelHelpers.export(exports, "IncUintOptRleEncoder", ()=>IncUintOptRleEncoder);
/**
* A combination of the IntDiffEncoder and the UintOptRleEncoder.
*
* The count approach is similar to the UintDiffOptRleEncoder, but instead of using the negative bitflag, it encodes
* in the LSB whether a count is to be read. Therefore this Encoder only supports 31 bit integers!
*
* Encodes [1, 2, 3, 2] as [3, 1, 6, -1] (more specifically [(1 << 1) | 1, (3 << 0) | 0, -1])
*
* Internally uses variable length encoding. Contrary to normal UintVar encoding, the first byte contains:
* * 1 bit that denotes whether the next value is a count (LSB)
* * 1 bit that denotes whether this value is negative (MSB - 1)
* * 1 bit that denotes whether to continue reading the variable length integer (MSB)
*
* Therefore, only five bits remain to encode diff ranges.
*
* Use this Encoder only when appropriate. In most cases, this is probably a bad idea.
*/ parcelHelpers.export(exports, "IntDiffOptRleEncoder", ()=>IntDiffOptRleEncoder);
/**
* Optimized String Encoder.
*
* Encoding many small strings in a simple Encoder is not very efficient. The function call to decode a string takes some time and creates references that must be eventually deleted.
* In practice, when decoding several million small strings, the GC will kick in more and more often to collect orphaned string objects (or maybe there is another reason?).
*
* This string encoder solves the above problem. All strings are concatenated and written as a single string using a single encoding call.
*
* The lengths are encoded using a UintOptRleEncoder.
*/ parcelHelpers.export(exports, "StringEncoder", ()=>StringEncoder);
var _mathJs = require("./math.js");
var _numberJs = require("./number.js");
var _binaryJs = require("./binary.js");
var _stringJs = require("./string.js");
var _arrayJs = require("./array.js");
class Encoder {
constructor(){
this.cpos = 0;
this.cbuf = new Uint8Array(100);
/**
* @type {Array<Uint8Array>}
*/ this.bufs = [];
}
}
const createEncoder = ()=>new Encoder();
const encode = (f)=>{
const encoder = createEncoder();
f(encoder);
return toUint8Array(encoder);
};
const length = (encoder)=>{
let len = encoder.cpos;
for(let i = 0; i < encoder.bufs.length; i++)len += encoder.bufs[i].length;
return len;
};
const hasContent = (encoder)=>encoder.cpos > 0 || encoder.bufs.length > 0;
const toUint8Array = (encoder)=>{
const uint8arr = new Uint8Array(length(encoder));
let curPos = 0;
for(let i = 0; i < encoder.bufs.length; i++){
const d = encoder.bufs[i];
uint8arr.set(d, curPos);
curPos += d.length;
}
uint8arr.set(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos), curPos);
return uint8arr;
};
const verifyLen = (encoder, len)=>{
const bufferLen = encoder.cbuf.length;
if (bufferLen - encoder.cpos < len) {
encoder.bufs.push(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos));
encoder.cbuf = new Uint8Array(_mathJs.max(bufferLen, len) * 2);
encoder.cpos = 0;
}
};
const write = (encoder, num)=>{
const bufferLen = encoder.cbuf.length;
if (encoder.cpos === bufferLen) {
encoder.bufs.push(encoder.cbuf);
encoder.cbuf = new Uint8Array(bufferLen * 2);
encoder.cpos = 0;
}
encoder.cbuf[encoder.cpos++] = num;
};
const set = (encoder, pos, num)=>{
let buffer = null;
// iterate all buffers and adjust position
for(let i = 0; i < encoder.bufs.length && buffer === null; i++){
const b = encoder.bufs[i];
if (pos < b.length) buffer = b // found buffer
;
else pos -= b.length;
}
if (buffer === null) // use current buffer
buffer = encoder.cbuf;
buffer[pos] = num;
};
const writeUint8 = write;
const setUint8 = set;
const writeUint16 = (encoder, num)=>{
write(encoder, num & _binaryJs.BITS8);
write(encoder, num >>> 8 & _binaryJs.BITS8);
};
const setUint16 = (encoder, pos, num)=>{
set(encoder, pos, num & _binaryJs.BITS8);
set(encoder, pos + 1, num >>> 8 & _binaryJs.BITS8);
};
const writeUint32 = (encoder, num)=>{
for(let i = 0; i < 4; i++){
write(encoder, num & _binaryJs.BITS8);
num >>>= 8;
}
};
const writeUint32BigEndian = (encoder, num)=>{
for(let i = 3; i >= 0; i--)write(encoder, num >>> 8 * i & _binaryJs.BITS8);
};
const setUint32 = (encoder, pos, num)=>{
for(let i = 0; i < 4; i++){
set(encoder, pos + i, num & _binaryJs.BITS8);
num >>>= 8;
}
};
const writeVarUint = (encoder, num)=>{
while(num > _binaryJs.BITS7){
write(encoder, _binaryJs.BIT8 | _binaryJs.BITS7 & num);
num = _mathJs.floor(num / 128) // shift >>> 7
;
}
write(encoder, _binaryJs.BITS7 & num);
};
const writeVarInt = (encoder, num)=>{
const isNegative = _mathJs.isNegativeZero(num);
if (isNegative) num = -num;
// |- whether to continue reading |- whether is negative |- number
write(encoder, (num > _binaryJs.BITS6 ? _binaryJs.BIT8 : 0) | (isNegative ? _binaryJs.BIT7 : 0) | _binaryJs.BITS6 & num);
num = _mathJs.floor(num / 64) // shift >>> 6
;
// We don't need to consider the case of num === 0 so we can use a different
// pattern here than above.
while(num > 0){
write(encoder, (num > _binaryJs.BITS7 ? _binaryJs.BIT8 : 0) | _binaryJs.BITS7 & num);
num = _mathJs.floor(num / 128) // shift >>> 7
;
}
};
/**
* A cache to store strings temporarily
*/ const _strBuffer = new Uint8Array(30000);
const _maxStrBSize = _strBuffer.length / 3;
const _writeVarStringNative = (encoder, str)=>{
if (str.length < _maxStrBSize) {
// We can encode the string into the existing buffer
/* c8 ignore next */ const written = _stringJs.utf8TextEncoder.encodeInto(str, _strBuffer).written || 0;
writeVarUint(encoder, written);
for(let i = 0; i < written; i++)write(encoder, _strBuffer[i]);
} else writeVarUint8Array(encoder, _stringJs.encodeUtf8(str));
};
const _writeVarStringPolyfill = (encoder, str)=>{
const encodedString = unescape(encodeURIComponent(str));
const len = encodedString.length;
writeVarUint(encoder, len);
for(let i = 0; i < len; i++)write(encoder, /** @type {number} */ encodedString.codePointAt(i));
};
const writeVarString = _stringJs.utf8TextEncoder && /** @type {any} */ _stringJs.utf8TextEncoder.encodeInto ? _writeVarStringNative : _writeVarStringPolyfill;
const writeTerminatedString = (encoder, str)=>writeTerminatedUint8Array(encoder, _stringJs.encodeUtf8(str));
const writeTerminatedUint8Array = (encoder, buf)=>{
for(let i = 0; i < buf.length; i++){
const b = buf[i];
if (b === 0 || b === 1) write(encoder, 1);
write(encoder, buf[i]);
}
write(encoder, 0);
};
const writeBinaryEncoder = (encoder, append)=>writeUint8Array(encoder, toUint8Array(append));
const writeUint8Array = (encoder, uint8Array)=>{
const bufferLen = encoder.cbuf.length;
const cpos = encoder.cpos;
const leftCopyLen = _mathJs.min(bufferLen - cpos, uint8Array.length);
const rightCopyLen = uint8Array.length - leftCopyLen;
encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos);
encoder.cpos += leftCopyLen;
if (rightCopyLen > 0) {
// Still something to write, write right half..
// Append new buffer
encoder.bufs.push(encoder.cbuf);
// must have at least size of remaining buffer
encoder.cbuf = new Uint8Array(_mathJs.max(bufferLen * 2, rightCopyLen));
// copy array
encoder.cbuf.set(uint8Array.subarray(leftCopyLen));
encoder.cpos = rightCopyLen;
}
};
const writeVarUint8Array = (encoder, uint8Array)=>{
writeVarUint(encoder, uint8Array.byteLength);
writeUint8Array(encoder, uint8Array);
};
const writeOnDataView = (encoder, len)=>{
verifyLen(encoder, len);
const dview = new DataView(encoder.cbuf.buffer, encoder.cpos, len);
encoder.cpos += len;
return dview;
};
const writeFloat32 = (encoder, num)=>writeOnDataView(encoder, 4).setFloat32(0, num, false);
const writeFloat64 = (encoder, num)=>writeOnDataView(encoder, 8).setFloat64(0, num, false);
const writeBigInt64 = (encoder, num)=>/** @type {any} */ writeOnDataView(encoder, 8).setBigInt64(0, num, false);
const writeBigUint64 = (encoder, num)=>/** @type {any} */ writeOnDataView(encoder, 8).setBigUint64(0, num, false);
const floatTestBed = new DataView(new ArrayBuffer(4));
/**
* Check if a number can be encoded as a 32 bit float.
*
* @param {number} num
* @return {boolean}
*/ const isFloat32 = (num)=>{
floatTestBed.setFloat32(0, num);
return floatTestBed.getFloat32(0) === num;
};
const writeAny = (encoder, data)=>{
switch(typeof data){
case "string":
// TYPE 119: STRING
write(encoder, 119);
writeVarString(encoder, data);
break;
case "number":
if (_numberJs.isInteger(data) && _mathJs.abs(data) <= _binaryJs.BITS31) {
// TYPE 125: INTEGER
write(encoder, 125);
writeVarInt(encoder, data);
} else if (isFloat32(data)) {
// TYPE 124: FLOAT32
write(encoder, 124);
writeFloat32(encoder, data);
} else {
// TYPE 123: FLOAT64
write(encoder, 123);
writeFloat64(encoder, data);
}
break;
case "bigint":
// TYPE 122: BigInt
write(encoder, 122);
writeBigInt64(encoder, data);
break;
case "object":
if (data === null) // TYPE 126: null
write(encoder, 126);
else if (_arrayJs.isArray(data)) {
// TYPE 117: Array
write(encoder, 117);
writeVarUint(encoder, data.length);
for(let i = 0; i < data.length; i++)writeAny(encoder, data[i]);
} else if (data instanceof Uint8Array) {
// TYPE 116: ArrayBuffer
write(encoder, 116);
writeVarUint8Array(encoder, data);
} else {
// TYPE 118: Object
write(encoder, 118);
const keys = Object.keys(data);
writeVarUint(encoder, keys.length);
for(let i = 0; i < keys.length; i++){
const key = keys[i];
writeVarString(encoder, key);
writeAny(encoder, data[key]);
}
}
break;
case "boolean":
// TYPE 120/121: boolean (true/false)
write(encoder, data ? 120 : 121);
break;
default:
// TYPE 127: undefined
write(encoder, 127);
}
};
class RleEncoder extends Encoder {
/**
* @param {function(Encoder, T):void} writer
*/ constructor(writer){
super();
/**
* The writer
*/ this.w = writer;
/**
* Current state
* @type {T|null}
*/ this.s = null;
this.count = 0;
}
/**
* @param {T} v
*/ write(v) {
if (this.s === v) this.count++;
else {
if (this.count > 0) // flush counter, unless this is the first value (count = 0)
writeVarUint(this, this.count - 1) // since count is always > 0, we can decrement by one. non-standard encoding ftw
;
this.count = 1;
// write first value
this.w(this, v);
this.s = v;
}
}
}
class IntDiffEncoder extends Encoder {
/**
* @param {number} start
*/ constructor(start){
super();
/**
* Current state
* @type {number}
*/ this.s = start;
}
/**
* @param {number} v
*/ write(v) {
writeVarInt(this, v - this.s);
this.s = v;
}
}
class RleIntDiffEncoder extends Encoder {
/**
* @param {number} start
*/ constructor(start){
super();
/**
* Current state
* @type {number}
*/ this.s = start;
this.count = 0;
}
/**
* @param {number} v
*/ write(v) {
if (this.s === v && this.count > 0) this.count++;
else {
if (this.count > 0) // flush counter, unless this is the first value (count = 0)
writeVarUint(this, this.count - 1) // since count is always > 0, we can decrement by one. non-standard encoding ftw
;
this.count = 1;
// write first value
writeVarInt(this, v - this.s);
this.s = v;
}
}
}
/**
* @param {UintOptRleEncoder} encoder
*/ const flushUintOptRleEncoder = (encoder)=>{
if (encoder.count > 0) {
// flush counter, unless this is the first value (count = 0)
// case 1: just a single value. set sign to positive
// case 2: write several values. set sign to negative to indicate that there is a length coming
writeVarInt(encoder.encoder, encoder.count === 1 ? encoder.s : -encoder.s);
if (encoder.count > 1) writeVarUint(encoder.encoder, encoder.count - 2) // since count is always > 1, we can decrement by one. non-standard encoding ftw
;
}
};
class UintOptRleEncoder {
constructor(){
this.encoder = new Encoder();
/**
* @type {number}
*/ this.s = 0;
this.count = 0;
}
/**
* @param {number} v
*/ write(v) {
if (this.s === v) this.count++;
else {
flushUintOptRleEncoder(this);
this.count = 1;
this.s = v;
}
}
/**
* Flush the encoded state and transform this to a Uint8Array.
*
* Note that this should only be called once.
*/ toUint8Array() {
flushUintOptRleEncoder(this);
return toUint8Array(this.encoder);
}
}
class IncUintOptRleEncoder {
constructor(){
this.encoder = new Encoder();
/**
* @type {number}
*/ this.s = 0;
this.count = 0;
}
/**
* @param {number} v
*/ write(v) {
if (this.s + this.count === v) this.count++;
else {
flushUintOptRleEncoder(this);
this.count = 1;
this.s = v;
}
}
/**
* Flush the encoded state and transform this to a Uint8Array.
*
* Note that this should only be called once.
*/ toUint8Array() {
flushUintOptRleEncoder(this);
return toUint8Array(this.encoder);
}
}
/**
* @param {IntDiffOptRleEncoder} encoder
*/ const flushIntDiffOptRleEncoder = (encoder)=>{
if (encoder.count > 0) {
// 31 bit making up the diff | wether to write the counter
// const encodedDiff = encoder.diff << 1 | (encoder.count === 1 ? 0 : 1)
const encodedDiff = encoder.diff * 2 + (encoder.count === 1 ? 0 : 1);
// flush counter, unless this is the first value (count = 0)
// case 1: just a single value. set first bit to positive
// case 2: write several values. set first bit to negative to indicate that there is a length coming
writeVarInt(encoder.encoder, encodedDiff);
if (encoder.count > 1) writeVarUint(encoder.encoder, encoder.count - 2) // since count is always > 1, we can decrement by one. non-standard encoding ftw
;
}
};
class IntDiffOptRleEncoder {
constructor(){
this.encoder = new Encoder();
/**
* @type {number}
*/ this.s = 0;
this.count = 0;
this.diff = 0;
}
/**
* @param {number} v
*/ write(v) {
if (this.diff === v - this.s) {
this.s = v;
this.count++;
} else {
flushIntDiffOptRleEncoder(this);
this.count = 1;
this.diff = v - this.s;
this.s = v;
}
}
/**
* Flush the encoded state and transform this to a Uint8Array.
*
* Note that this should only be called once.
*/ toUint8Array() {
flushIntDiffOptRleEncoder(this);
return toUint8Array(this.encoder);
}
}
class StringEncoder {
constructor(){
/**
* @type {Array<string>}
*/ this.sarr = [];
this.s = "";
this.lensE = new UintOptRleEncoder();
}
/**
* @param {string} string
*/ write(string) {
this.s += string;
if (this.s.length > 19) {
this.sarr.push(this.s);
this.s = "";
}
this.lensE.write(string.length);
}
toUint8Array() {
const encoder = new Encoder();
this.sarr.push(this.s);
this.s = "";
writeVarString(encoder, this.sarr.join(""));
writeUint8Array(encoder, this.lensE.toUint8Array());
return toUint8Array(encoder);
}
}
},{"./math.js":"bBwSk","./number.js":"71SfE","./binary.js":"lsQIT","./string.js":"liNHi","./array.js":"fZD9X","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"71SfE":[function(require,module,exports) {
/**
* Utility helpers for working with numbers.
*
* @module number
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "MAX_SAFE_INTEGER", ()=>MAX_SAFE_INTEGER);
parcelHelpers.export(exports, "MIN_SAFE_INTEGER", ()=>MIN_SAFE_INTEGER);
parcelHelpers.export(exports, "LOWEST_INT32", ()=>LOWEST_INT32);
parcelHelpers.export(exports, "HIGHEST_INT32", ()=>HIGHEST_INT32);
parcelHelpers.export(exports, "HIGHEST_UINT32", ()=>HIGHEST_UINT32);
parcelHelpers.export(exports, "isInteger", ()=>isInteger);
parcelHelpers.export(exports, "isNaN", ()=>isNaN);
parcelHelpers.export(exports, "parseInt", ()=>parseInt);
parcelHelpers.export(exports, "countBits", ()=>countBits);
var _mathJs = require("./math.js");
var _binaryJs = require("./binary.js");
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER;
const LOWEST_INT32 = -2147483648;
const HIGHEST_INT32 = _binaryJs.BITS31;
const HIGHEST_UINT32 = _binaryJs.BITS32;
const isInteger = Number.isInteger || ((num)=>typeof num === "number" && isFinite(num) && _mathJs.floor(num) === num);
const isNaN = Number.isNaN;
const parseInt = Number.parseInt;
const countBits = (n)=>{
n &= _binaryJs.BITS32;
let count = 0;
while(n){
n &= n - 1;
count++;
}
return count;
};
},{"./math.js":"bBwSk","./binary.js":"lsQIT","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"lsQIT":[function(require,module,exports) {
/* eslint-env browser */ /**
* Binary data constants.
*
* @module binary
*/ /**
* n-th bit activated.
*
* @type {number}
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "BIT1", ()=>BIT1);
parcelHelpers.export(exports, "BIT2", ()=>BIT2);
parcelHelpers.export(exports, "BIT3", ()=>BIT3);
parcelHelpers.export(exports, "BIT4", ()=>BIT4);
parcelHelpers.export(exports, "BIT5", ()=>BIT5);
parcelHelpers.export(exports, "BIT6", ()=>BIT6);
parcelHelpers.export(exports, "BIT7", ()=>BIT7);
parcelHelpers.export(exports, "BIT8", ()=>BIT8);
parcelHelpers.export(exports, "BIT9", ()=>BIT9);
parcelHelpers.export(exports, "BIT10", ()=>BIT10);
parcelHelpers.export(exports, "BIT11", ()=>BIT11);
parcelHelpers.export(exports, "BIT12", ()=>BIT12);
parcelHelpers.export(exports, "BIT13", ()=>BIT13);
parcelHelpers.export(exports, "BIT14", ()=>BIT14);
parcelHelpers.export(exports, "BIT15", ()=>BIT15);
parcelHelpers.export(exports, "BIT16", ()=>BIT16);
parcelHelpers.export(exports, "BIT17", ()=>BIT17);
parcelHelpers.export(exports, "BIT18", ()=>BIT18);
parcelHelpers.export(exports, "BIT19", ()=>BIT19);
parcelHelpers.export(exports, "BIT20", ()=>BIT20);
parcelHelpers.export(exports, "BIT21", ()=>BIT21);
parcelHelpers.export(exports, "BIT22", ()=>BIT22);
parcelHelpers.export(exports, "BIT23", ()=>BIT23);
parcelHelpers.export(exports, "BIT24", ()=>BIT24);
parcelHelpers.export(exports, "BIT25", ()=>BIT25);
parcelHelpers.export(exports, "BIT26", ()=>BIT26);
parcelHelpers.export(exports, "BIT27", ()=>BIT27);
parcelHelpers.export(exports, "BIT28", ()=>BIT28);
parcelHelpers.export(exports, "BIT29", ()=>BIT29);
parcelHelpers.export(exports, "BIT30", ()=>BIT30);
parcelHelpers.export(exports, "BIT31", ()=>BIT31);
parcelHelpers.export(exports, "BIT32", ()=>BIT32);
parcelHelpers.export(exports, "BITS0", ()=>BITS0);
parcelHelpers.export(exports, "BITS1", ()=>BITS1);
parcelHelpers.export(exports, "BITS2", ()=>BITS2);
parcelHelpers.export(exports, "BITS3", ()=>BITS3);
parcelHelpers.export(exports, "BITS4", ()=>BITS4);
parcelHelpers.export(exports, "BITS5", ()=>BITS5);
parcelHelpers.export(exports, "BITS6", ()=>BITS6);
parcelHelpers.export(exports, "BITS7", ()=>BITS7);
parcelHelpers.export(exports, "BITS8", ()=>BITS8);
parcelHelpers.export(exports, "BITS9", ()=>BITS9);
parcelHelpers.export(exports, "BITS10", ()=>BITS10);
parcelHelpers.export(exports, "BITS11", ()=>BITS11);
parcelHelpers.export(exports, "BITS12", ()=>BITS12);
parcelHelpers.export(exports, "BITS13", ()=>BITS13);
parcelHelpers.export(exports, "BITS14", ()=>BITS14);
parcelHelpers.export(exports, "BITS15", ()=>BITS15);
parcelHelpers.export(exports, "BITS16", ()=>BITS16);
parcelHelpers.export(exports, "BITS17", ()=>BITS17);
parcelHelpers.export(exports, "BITS18", ()=>BITS18);
parcelHelpers.export(exports, "BITS19", ()=>BITS19);
parcelHelpers.export(exports, "BITS20", ()=>BITS20);
parcelHelpers.export(exports, "BITS21", ()=>BITS21);
parcelHelpers.export(exports, "BITS22", ()=>BITS22);
parcelHelpers.export(exports, "BITS23", ()=>BITS23);
parcelHelpers.export(exports, "BITS24", ()=>BITS24);
parcelHelpers.export(exports, "BITS25", ()=>BITS25);
parcelHelpers.export(exports, "BITS26", ()=>BITS26);
parcelHelpers.export(exports, "BITS27", ()=>BITS27);
parcelHelpers.export(exports, "BITS28", ()=>BITS28);
parcelHelpers.export(exports, "BITS29", ()=>BITS29);
parcelHelpers.export(exports, "BITS30", ()=>BITS30);
parcelHelpers.export(exports, "BITS31", ()=>BITS31);
parcelHelpers.export(exports, "BITS32", ()=>BITS32);
const BIT1 = 1;
const BIT2 = 2;
const BIT3 = 4;
const BIT4 = 8;
const BIT5 = 16;
const BIT6 = 32;
const BIT7 = 64;
const BIT8 = 128;
const BIT9 = 256;
const BIT10 = 512;
const BIT11 = 1024;
const BIT12 = 2048;
const BIT13 = 4096;
const BIT14 = 8192;
const BIT15 = 16384;
const BIT16 = 32768;
const BIT17 = 65536;
const BIT18 = 131072;
const BIT19 = 262144;
const BIT20 = 524288;
const BIT21 = 1048576;
const BIT22 = 2097152;
const BIT23 = 4194304;
const BIT24 = 8388608;
const BIT25 = 16777216;
const BIT26 = 33554432;
const BIT27 = 67108864;
const BIT28 = 134217728;
const BIT29 = 268435456;
const BIT30 = 536870912;
const BIT31 = 1073741824;
const BIT32 = -2147483648;
const BITS0 = 0;
const BITS1 = 1;
const BITS2 = 3;
const BITS3 = 7;
const BITS4 = 15;
const BITS5 = 31;
const BITS6 = 63;
const BITS7 = 127;
const BITS8 = 255;
const BITS9 = 511;
const BITS10 = 1023;
const BITS11 = 2047;
const BITS12 = 4095;
const BITS13 = 8191;
const BITS14 = 16383;
const BITS15 = 32767;
const BITS16 = 65535;
const BITS17 = BIT18 - 1;
const BITS18 = BIT19 - 1;
const BITS19 = BIT20 - 1;
const BITS20 = BIT21 - 1;
const BITS21 = BIT22 - 1;
const BITS22 = BIT23 - 1;
const BITS23 = BIT24 - 1;
const BITS24 = BIT25 - 1;
const BITS25 = BIT26 - 1;
const BITS26 = BIT27 - 1;
const BITS27 = BIT28 - 1;
const BITS28 = BIT29 - 1;
const BITS29 = BIT30 - 1;
const BITS30 = BIT31 - 1;
const BITS31 = 0x7FFFFFFF;
const BITS32 = 0xFFFFFFFF;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"liNHi":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "fromCharCode", ()=>fromCharCode);
parcelHelpers.export(exports, "fromCodePoint", ()=>fromCodePoint);
parcelHelpers.export(exports, "MAX_UTF16_CHARACTER", ()=>MAX_UTF16_CHARACTER);
parcelHelpers.export(exports, "trimLeft", ()=>trimLeft);
parcelHelpers.export(exports, "fromCamelCase", ()=>fromCamelCase);
parcelHelpers.export(exports, "utf8ByteLength", ()=>utf8ByteLength);
parcelHelpers.export(exports, "_encodeUtf8Polyfill", ()=>_encodeUtf8Polyfill);
parcelHelpers.export(exports, "utf8TextEncoder", ()=>utf8TextEncoder);
parcelHelpers.export(exports, "_encodeUtf8Native", ()=>_encodeUtf8Native);
parcelHelpers.export(exports, "encodeUtf8", ()=>encodeUtf8);
parcelHelpers.export(exports, "_decodeUtf8Polyfill", ()=>_decodeUtf8Polyfill);
parcelHelpers.export(exports, "utf8TextDecoder", ()=>utf8TextDecoder);
parcelHelpers.export(exports, "_decodeUtf8Native", ()=>_decodeUtf8Native);
parcelHelpers.export(exports, "decodeUtf8", ()=>decodeUtf8);
parcelHelpers.export(exports, "splice", ()=>splice);
parcelHelpers.export(exports, "repeat", ()=>repeat);
var _arrayJs = require("./array.js");
const fromCharCode = String.fromCharCode;
const fromCodePoint = String.fromCodePoint;
const MAX_UTF16_CHARACTER = fromCharCode(65535);
/**
* @param {string} s
* @return {string}
*/ const toLowerCase = (s)=>s.toLowerCase();
const trimLeftRegex = /^\s*/g;
const trimLeft = (s)=>s.replace(trimLeftRegex, "");
const fromCamelCaseRegex = /([A-Z])/g;
const fromCamelCase = (s, separator)=>trimLeft(s.replace(fromCamelCaseRegex, (match)=>`${separator}${toLowerCase(match)}`));
const utf8ByteLength = (str)=>unescape(encodeURIComponent(str)).length;
const _encodeUtf8Polyfill = (str)=>{
const encodedString = unescape(encodeURIComponent(str));
const len = encodedString.length;
const buf = new Uint8Array(len);
for(let i = 0; i < len; i++)buf[i] = /** @type {number} */ encodedString.codePointAt(i);
return buf;
};
const utf8TextEncoder = /** @type {TextEncoder} */ typeof TextEncoder !== "undefined" ? new TextEncoder() : null;
const _encodeUtf8Native = (str)=>utf8TextEncoder.encode(str);
const encodeUtf8 = utf8TextEncoder ? _encodeUtf8Native : _encodeUtf8Polyfill;
const _decodeUtf8Polyfill = (buf)=>{
let remainingLen = buf.length;
let encodedString = "";
let bufPos = 0;
while(remainingLen > 0){
const nextLen = remainingLen < 10000 ? remainingLen : 10000;
const bytes = buf.subarray(bufPos, bufPos + nextLen);
bufPos += nextLen;
// Starting with ES5.1 we can supply a generic array-like object as arguments
encodedString += String.fromCodePoint.apply(null, /** @type {any} */ bytes);
remainingLen -= nextLen;
}
return decodeURIComponent(escape(encodedString));
};
let utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf-8", {
fatal: true,
ignoreBOM: true
});
/* c8 ignore start */ if (utf8TextDecoder && utf8TextDecoder.decode(new Uint8Array()).length === 1) // Safari doesn't handle BOM correctly.
// This fixes a bug in Safari 13.0.5 where it produces a BOM the first time it is called.
// utf8TextDecoder.decode(new Uint8Array()).length === 1 on the first call and
// utf8TextDecoder.decode(new Uint8Array()).length === 1 on the second call
// Another issue is that from then on no BOM chars are recognized anymore
/* c8 ignore next */ utf8TextDecoder = null;
const _decodeUtf8Native = (buf)=>/** @type {TextDecoder} */ utf8TextDecoder.decode(buf);
const decodeUtf8 = utf8TextDecoder ? _decodeUtf8Native : _decodeUtf8Polyfill;
const splice = (str, index, remove, insert = "")=>str.slice(0, index) + insert + str.slice(index + remove);
const repeat = (source, n)=>_arrayJs.unfold(n, ()=>source).join("");
},{"./array.js":"fZD9X","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"JPRoL":[function(require,module,exports) {
/**
* Efficient schema-less binary decoding with support for variable length encoding.
*
* Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.
*
* Encodes numbers in little-endian order (least to most significant byte order)
* and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)
* which is also used in Protocol Buffers.
*
* ```js
* // encoding step
* const encoder = encoding.createEncoder()
* encoding.writeVarUint(encoder, 256)
* encoding.writeVarString(encoder, 'Hello world!')
* const buf = encoding.toUint8Array(encoder)
* ```
*
* ```js
* // decoding step
* const decoder = decoding.createDecoder(buf)
* decoding.readVarUint(decoder) // => 256
* decoding.readVarString(decoder) // => 'Hello world!'
* decoding.hasContent(decoder) // => false - all data is read
* ```
*
* @module decoding
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
/**
* A Decoder handles the decoding of an Uint8Array.
*/ parcelHelpers.export(exports, "Decoder", ()=>Decoder);
parcelHelpers.export(exports, "createDecoder", ()=>createDecoder);
parcelHelpers.export(exports, "hasContent", ()=>hasContent);
parcelHelpers.export(exports, "clone", ()=>clone);
parcelHelpers.export(exports, "readUint8Array", ()=>readUint8Array);
parcelHelpers.export(exports, "readVarUint8Array", ()=>readVarUint8Array);
parcelHelpers.export(exports, "readTailAsUint8Array", ()=>readTailAsUint8Array);
parcelHelpers.export(exports, "skip8", ()=>skip8);
parcelHelpers.export(exports, "readUint8", ()=>readUint8);
parcelHelpers.export(exports, "readUint16", ()=>readUint16);
parcelHelpers.export(exports, "readUint32", ()=>readUint32);
parcelHelpers.export(exports, "readUint32BigEndian", ()=>readUint32BigEndian);
parcelHelpers.export(exports, "peekUint8", ()=>peekUint8);
parcelHelpers.export(exports, "peekUint16", ()=>peekUint16);
parcelHelpers.export(exports, "peekUint32", ()=>peekUint32);
parcelHelpers.export(exports, "readVarUint", ()=>readVarUint);
parcelHelpers.export(exports, "readVarInt", ()=>readVarInt);
parcelHelpers.export(exports, "peekVarUint", ()=>peekVarUint);
parcelHelpers.export(exports, "peekVarInt", ()=>peekVarInt);
parcelHelpers.export(exports, "_readVarStringPolyfill", ()=>_readVarStringPolyfill);
parcelHelpers.export(exports, "_readVarStringNative", ()=>_readVarStringNative);
parcelHelpers.export(exports, "readVarString", ()=>readVarString);
parcelHelpers.export(exports, "readTerminatedUint8Array", ()=>readTerminatedUint8Array);
parcelHelpers.export(exports, "readTerminatedString", ()=>readTerminatedString);
parcelHelpers.export(exports, "peekVarString", ()=>peekVarString);
parcelHelpers.export(exports, "readFromDataView", ()=>readFromDataView);
parcelHelpers.export(exports, "readFloat32", ()=>readFloat32);
parcelHelpers.export(exports, "readFloat64", ()=>readFloat64);
parcelHelpers.export(exports, "readBigInt64", ()=>readBigInt64);
parcelHelpers.export(exports, "readBigUint64", ()=>readBigUint64);
parcelHelpers.export(exports, "readAny", ()=>readAny);
/**
* T must not be null.
*
* @template T
*/ parcelHelpers.export(exports, "RleDecoder", ()=>RleDecoder);
parcelHelpers.export(exports, "IntDiffDecoder", ()=>IntDiffDecoder);
parcelHelpers.export(exports, "RleIntDiffDecoder", ()=>RleIntDiffDecoder);
parcelHelpers.export(exports, "UintOptRleDecoder", ()=>UintOptRleDecoder);
parcelHelpers.export(exports, "IncUintOptRleDecoder", ()=>IncUintOptRleDecoder);
parcelHelpers.export(exports, "IntDiffOptRleDecoder", ()=>IntDiffOptRleDecoder);
parcelHelpers.export(exports, "StringDecoder", ()=>StringDecoder);
var _binaryJs = require("./binary.js");
var _mathJs = require("./math.js");
var _numberJs = require("./number.js");
var _stringJs = require("./string.js");
var _errorJs = require("./error.js");
var _encodingJs = require("./encoding.js");
const errorUnexpectedEndOfArray = _errorJs.create("Unexpected end of array");
const errorIntegerOutOfRange = _errorJs.create("Integer out of Range");
class Decoder {
/**
* @param {Uint8Array} uint8Array Binary data to decode
*/ constructor(uint8Array){
/**
* Decoding target.
*
* @type {Uint8Array}
*/ this.arr = uint8Array;
/**
* Current decoding position.
*
* @type {number}
*/ this.pos = 0;
}
}
const createDecoder = (uint8Array)=>new Decoder(uint8Array);
const hasContent = (decoder)=>decoder.pos !== decoder.arr.length;
const clone = (decoder, newPos = decoder.pos)=>{
const _decoder = createDecoder(decoder.arr);
_decoder.pos = newPos;
return _decoder;
};
const readUint8Array = (decoder, len)=>{
const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len);
decoder.pos += len;
return view;
};
const readVarUint8Array = (decoder)=>readUint8Array(decoder, readVarUint(decoder));
const readTailAsUint8Array = (decoder)=>readUint8Array(decoder, decoder.arr.length - decoder.pos);
const skip8 = (decoder)=>decoder.pos++;
const readUint8 = (decoder)=>decoder.arr[decoder.pos++];
const readUint16 = (decoder)=>{
const uint = decoder.arr[decoder.pos] + (decoder.arr[decoder.pos + 1] << 8);
decoder.pos += 2;
return uint;
};
const readUint32 = (decoder)=>{
const uint = decoder.arr[decoder.pos] + (decoder.arr[decoder.pos + 1] << 8) + (decoder.arr[decoder.pos + 2] << 16) + (decoder.arr[decoder.pos + 3] << 24) >>> 0;
decoder.pos += 4;
return uint;
};
const readUint32BigEndian = (decoder)=>{
const uint = decoder.arr[decoder.pos + 3] + (decoder.arr[decoder.pos + 2] << 8) + (decoder.arr[decoder.pos + 1] << 16) + (decoder.arr[decoder.pos] << 24) >>> 0;
decoder.pos += 4;
return uint;
};
const peekUint8 = (decoder)=>decoder.arr[decoder.pos];
const peekUint16 = (decoder)=>decoder.arr[decoder.pos] + (decoder.arr[decoder.pos + 1] << 8);
const peekUint32 = (decoder)=>decoder.arr[decoder.pos] + (decoder.arr[decoder.pos + 1] << 8) + (decoder.arr[decoder.pos + 2] << 16) + (decoder.arr[decoder.pos + 3] << 24) >>> 0;
const readVarUint = (decoder)=>{
let num = 0;
let mult = 1;
const len = decoder.arr.length;
while(decoder.pos < len){
const r = decoder.arr[decoder.pos++];
// num = num | ((r & binary.BITS7) << len)
num = num + (r & _binaryJs.BITS7) * mult // shift $r << (7*#iterations) and add it to num
;
mult *= 128 // next iteration, shift 7 "more" to the left
;
if (r < _binaryJs.BIT8) return num;
/* c8 ignore start */ if (num > _numberJs.MAX_SAFE_INTEGER) throw errorIntegerOutOfRange;
/* c8 ignore stop */ }
throw errorUnexpectedEndOfArray;
};
const readVarInt = (decoder)=>{
let r = decoder.arr[decoder.pos++];
let num = r & _binaryJs.BITS6;
let mult = 64;
const sign = (r & _binaryJs.BIT7) > 0 ? -1 : 1;
if ((r & _binaryJs.BIT8) === 0) // don't continue reading
return sign * num;
const len = decoder.arr.length;
while(decoder.pos < len){
r = decoder.arr[decoder.pos++];
// num = num | ((r & binary.BITS7) << len)
num = num + (r & _binaryJs.BITS7) * mult;
mult *= 128;
if (r < _binaryJs.BIT8) return sign * num;
/* c8 ignore start */ if (num > _numberJs.MAX_SAFE_INTEGER) throw errorIntegerOutOfRange;
/* c8 ignore stop */ }
throw errorUnexpectedEndOfArray;
};
const peekVarUint = (decoder)=>{
const pos = decoder.pos;
const s = readVarUint(decoder);
decoder.pos = pos;
return s;
};
const peekVarInt = (decoder)=>{
const pos = decoder.pos;
const s = readVarInt(decoder);
decoder.pos = pos;
return s;
};
const _readVarStringPolyfill = (decoder)=>{
let remainingLen = readVarUint(decoder);
if (remainingLen === 0) return "";
else {
let encodedString = String.fromCodePoint(readUint8(decoder)) // remember to decrease remainingLen
;
if (--remainingLen < 100) while(remainingLen--)encodedString += String.fromCodePoint(readUint8(decoder));
else while(remainingLen > 0){
const nextLen = remainingLen < 10000 ? remainingLen : 10000;
// this is dangerous, we create a fresh array view from the existing buffer
const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen);
decoder.pos += nextLen;
// Starting with ES5.1 we can supply a generic array-like object as arguments
encodedString += String.fromCodePoint.apply(null, /** @type {any} */ bytes);
remainingLen -= nextLen;
}
return decodeURIComponent(escape(encodedString));
}
};
const _readVarStringNative = (decoder)=>/** @type any */ _stringJs.utf8TextDecoder.decode(readVarUint8Array(decoder));
const readVarString = _stringJs.utf8TextDecoder ? _readVarStringNative : _readVarStringPolyfill;
const readTerminatedUint8Array = (decoder)=>{
const encoder = _encodingJs.createEncoder();
let b;
while(true){
b = readUint8(decoder);
if (b === 0) return _encodingJs.toUint8Array(encoder);
if (b === 1) b = readUint8(decoder);
_encodingJs.write(encoder, b);
}
};
const readTerminatedString = (decoder)=>_stringJs.decodeUtf8(readTerminatedUint8Array(decoder));
const peekVarString = (decoder)=>{
const pos = decoder.pos;
const s = readVarString(decoder);
decoder.pos = pos;
return s;
};
const readFromDataView = (decoder, len)=>{
const dv = new DataView(decoder.arr.buffer, decoder.arr.byteOffset + decoder.pos, len);
decoder.pos += len;
return dv;
};
const readFloat32 = (decoder)=>readFromDataView(decoder, 4).getFloat32(0, false);
const readFloat64 = (decoder)=>readFromDataView(decoder, 8).getFloat64(0, false);
const readBigInt64 = (decoder)=>/** @type {any} */ readFromDataView(decoder, 8).getBigInt64(0, false);
const readBigUint64 = (decoder)=>/** @type {any} */ readFromDataView(decoder, 8).getBigUint64(0, false);
/**
* @type {Array<function(Decoder):any>}
*/ const readAnyLookupTable = [
(decoder)=>undefined,
(decoder)=>null,
readVarInt,
readFloat32,
readFloat64,
readBigInt64,
(decoder)=>false,
(decoder)=>true,
readVarString,
(decoder)=>{
const len = readVarUint(decoder);
/**
* @type {Object<string,any>}
*/ const obj = {};
for(let i = 0; i < len; i++){
const key = readVarString(decoder);
obj[key] = readAny(decoder);
}
return obj;
},
(decoder)=>{
const len = readVarUint(decoder);
const arr = [];
for(let i = 0; i < len; i++)arr.push(readAny(decoder));
return arr;
},
readVarUint8Array // CASE 116: Uint8Array
];
const readAny = (decoder)=>readAnyLookupTable[127 - readUint8(decoder)](decoder);
class RleDecoder extends Decoder {
/**
* @param {Uint8Array} uint8Array
* @param {function(Decoder):T} reader
*/ constructor(uint8Array, reader){
super(uint8Array);
/**
* The reader
*/ this.reader = reader;
/**
* Current state
* @type {T|null}
*/ this.s = null;
this.count = 0;
}
read() {
if (this.count === 0) {
this.s = this.reader(this);
if (hasContent(this)) this.count = readVarUint(this) + 1 // see encoder implementation for the reason why this is incremented
;
else this.count = -1 // read the current value forever
;
}
this.count--;
return /** @type {T} */ this.s;
}
}
class IntDiffDecoder extends Decoder {
/**
* @param {Uint8Array} uint8Array
* @param {number} start
*/ constructor(uint8Array, start){
super(uint8Array);
/**
* Current state
* @type {number}
*/ this.s = start;
}
/**
* @return {number}
*/ read() {
this.s += readVarInt(this);
return this.s;
}
}
class RleIntDiffDecoder extends Decoder {
/**
* @param {Uint8Array} uint8Array
* @param {number} start
*/ constructor(uint8Array, start){
super(uint8Array);
/**
* Current state
* @type {number}
*/ this.s = start;
this.count = 0;
}
/**
* @return {number}
*/ read() {
if (this.count === 0) {
this.s += readVarInt(this);
if (hasContent(this)) this.count = readVarUint(this) + 1 // see encoder implementation for the reason why this is incremented
;
else this.count = -1 // read the current value forever
;
}
this.count--;
return /** @type {number} */ this.s;
}
}
class UintOptRleDecoder extends Decoder {
/**
* @param {Uint8Array} uint8Array
*/ constructor(uint8Array){
super(uint8Array);
/**
* @type {number}
*/ this.s = 0;
this.count = 0;
}
read() {
if (this.count === 0) {
this.s = readVarInt(this);
// if the sign is negative, we read the count too, otherwise count is 1
const isNegative = _mathJs.isNegativeZero(this.s);
this.count = 1;
if (isNegative) {
this.s = -this.s;
this.count = readVarUint(this) + 2;
}
}
this.count--;
return /** @type {number} */ this.s;
}
}
class IncUintOptRleDecoder extends Decoder {
/**
* @param {Uint8Array} uint8Array
*/ constructor(uint8Array){
super(uint8Array);
/**
* @type {number}
*/ this.s = 0;
this.count = 0;
}
read() {
if (this.count === 0) {
this.s = readVarInt(this);
// if the sign is negative, we read the count too, otherwise count is 1
const isNegative = _mathJs.isNegativeZero(this.s);
this.count = 1;
if (isNegative) {
this.s = -this.s;
this.count = readVarUint(this) + 2;
}
}
this.count--;
return /** @type {number} */ this.s++;
}
}
class IntDiffOptRleDecoder extends Decoder {
/**
* @param {Uint8Array} uint8Array
*/ constructor(uint8Array){
super(uint8Array);
/**
* @type {number}
*/ this.s = 0;
this.count = 0;
this.diff = 0;
}
/**
* @return {number}
*/ read() {
if (this.count === 0) {
const diff = readVarInt(this);
// if the first bit is set, we read more data
const hasCount = diff & 1;
this.diff = _mathJs.floor(diff / 2) // shift >> 1
;
this.count = 1;
if (hasCount) this.count = readVarUint(this) + 2;
}
this.s += this.diff;
this.count--;
return this.s;
}
}
class StringDecoder {
/**
* @param {Uint8Array} uint8Array
*/ constructor(uint8Array){
this.decoder = new UintOptRleDecoder(uint8Array);
this.str = readVarString(this.decoder);
/**
* @type {number}
*/ this.spos = 0;
}
/**
* @return {string}
*/ read() {
const end = this.spos + this.decoder.read();
const res = this.str.slice(this.spos, end);
this.spos = end;
return res;
}
}
},{"./binary.js":"lsQIT","./math.js":"bBwSk","./number.js":"71SfE","./string.js":"liNHi","./error.js":"7eWBR","./encoding.js":"8PAaf","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"7eWBR":[function(require,module,exports) {
/**
* Error helpers.
*
* @module error
*/ /**
* @param {string} s
* @return {Error}
*/ /* c8 ignore next */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "create", ()=>create);
parcelHelpers.export(exports, "methodUnimplemented", ()=>methodUnimplemented);
parcelHelpers.export(exports, "unexpectedCase", ()=>unexpectedCase);
const create = (s)=>new Error(s);
const methodUnimplemented = ()=>{
throw create("Method unimplemented");
};
const unexpectedCase = ()=>{
throw create("Unexpected case");
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"blzcp":[function(require,module,exports) {
/**
* Isomorphic module for true random numbers / buffers / uuids.
*
* Attention: falls back to Math.random if the browser does not support crypto.
*
* @module random
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "rand", ()=>rand);
parcelHelpers.export(exports, "uint32", ()=>uint32);
parcelHelpers.export(exports, "uint53", ()=>uint53);
parcelHelpers.export(exports, "oneOf", ()=>oneOf);
parcelHelpers.export(exports, "uuidv4", ()=>uuidv4);
var _mathJs = require("./math.js");
var _binaryJs = require("./binary.js");
var _webcrypto = require("lib0/webcrypto");
const rand = Math.random;
const uint32 = ()=>(0, _webcrypto.getRandomValues)(new Uint32Array(1))[0];
const uint53 = ()=>{
const arr = (0, _webcrypto.getRandomValues)(new Uint32Array(8));
return (arr[0] & _binaryJs.BITS21) * (_binaryJs.BITS32 + 1) + (arr[1] >>> 0);
};
const oneOf = (arr)=>arr[_mathJs.floor(rand() * arr.length)];
// @ts-ignore
const uuidv4Template = "10000000-1000-4000-8000-100000000000";
const uuidv4 = ()=>uuidv4Template.replace(/[018]/g, /** @param {number} c */ (c)=>(c ^ uint32() & 15 >> c / 4).toString(16));
},{"./math.js":"bBwSk","./binary.js":"lsQIT","lib0/webcrypto":"2FDep","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"2FDep":[function(require,module,exports) {
/* eslint-env browser */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "subtle", ()=>subtle);
parcelHelpers.export(exports, "getRandomValues", ()=>getRandomValues);
const subtle = crypto.subtle;
const getRandomValues = crypto.getRandomValues.bind(crypto);
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"a6WAk":[function(require,module,exports) {
/**
* Utility helpers to work with promises.
*
* @module promise
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "create", ()=>create);
parcelHelpers.export(exports, "createEmpty", ()=>createEmpty);
parcelHelpers.export(exports, "all", ()=>all);
parcelHelpers.export(exports, "reject", ()=>reject);
parcelHelpers.export(exports, "resolve", ()=>resolve);
parcelHelpers.export(exports, "resolveWith", ()=>resolveWith);
parcelHelpers.export(exports, "until", ()=>until);
parcelHelpers.export(exports, "untilAsync", ()=>untilAsync);
parcelHelpers.export(exports, "wait", ()=>wait);
parcelHelpers.export(exports, "isPromise", ()=>isPromise);
var _timeJs = require("./time.js");
const create = (f)=>/** @type {Promise<T>} */ new Promise(f);
const createEmpty = (f)=>new Promise(f);
const all = Promise.all.bind(Promise);
const reject = (reason)=>Promise.reject(reason);
const resolve = (res)=>Promise.resolve(res);
const resolveWith = (res)=>Promise.resolve(res);
const until = (timeout, check, intervalResolution = 10)=>create((resolve, reject)=>{
const startTime = _timeJs.getUnixTime();
const hasTimeout = timeout > 0;
const untilInterval = ()=>{
if (check()) {
clearInterval(intervalHandle);
resolve();
} else if (hasTimeout) /* c8 ignore else */ {
if (_timeJs.getUnixTime() - startTime > timeout) {
clearInterval(intervalHandle);
reject(new Error("Timeout"));
}
}
};
const intervalHandle = setInterval(untilInterval, intervalResolution);
});
const untilAsync = async (check, timeout = 0, intervalResolution = 10)=>{
const startTime = _timeJs.getUnixTime();
const noTimeout = timeout <= 0;
// eslint-disable-next-line no-unmodified-loop-condition
while(noTimeout || _timeJs.getUnixTime() - startTime <= timeout){
if (await check()) return;
await wait(intervalResolution);
}
throw new Error("Timeout");
};
const wait = (timeout)=>create((resolve, _reject)=>setTimeout(resolve, timeout));
const isPromise = (p)=>p instanceof Promise || p && p.then && p.catch && p.finally;
},{"./time.js":"8mk6w","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8mk6w":[function(require,module,exports) {
/**
* Utility module to work with time.
*
* @module time
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "getDate", ()=>getDate);
parcelHelpers.export(exports, "getUnixTime", ()=>getUnixTime);
parcelHelpers.export(exports, "humanizeDuration", ()=>humanizeDuration);
var _metricJs = require("./metric.js");
var _mathJs = require("./math.js");
const getDate = ()=>new Date();
const getUnixTime = Date.now;
const humanizeDuration = (d)=>{
if (d < 60000) {
const p = _metricJs.prefix(d, -1);
return _mathJs.round(p.n * 100) / 100 + p.prefix + "s";
}
d = _mathJs.floor(d / 1000);
const seconds = d % 60;
const minutes = _mathJs.floor(d / 60) % 60;
const hours = _mathJs.floor(d / 3600) % 24;
const days = _mathJs.floor(d / 86400);
if (days > 0) return days + "d" + (hours > 0 || minutes > 30 ? " " + (minutes > 30 ? hours + 1 : hours) + "h" : "");
if (hours > 0) /* c8 ignore next */ return hours + "h" + (minutes > 0 || seconds > 30 ? " " + (seconds > 30 ? minutes + 1 : minutes) + "min" : "");
return minutes + "min" + (seconds > 0 ? " " + seconds + "s" : "");
};
},{"./metric.js":"abRtD","./math.js":"bBwSk","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"abRtD":[function(require,module,exports) {
/**
* Utility module to convert metric values.
*
* @module metric
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "yotta", ()=>yotta);
parcelHelpers.export(exports, "zetta", ()=>zetta);
parcelHelpers.export(exports, "exa", ()=>exa);
parcelHelpers.export(exports, "peta", ()=>peta);
parcelHelpers.export(exports, "tera", ()=>tera);
parcelHelpers.export(exports, "giga", ()=>giga);
parcelHelpers.export(exports, "mega", ()=>mega);
parcelHelpers.export(exports, "kilo", ()=>kilo);
parcelHelpers.export(exports, "hecto", ()=>hecto);
parcelHelpers.export(exports, "deca", ()=>deca);
parcelHelpers.export(exports, "deci", ()=>deci);
parcelHelpers.export(exports, "centi", ()=>centi);
parcelHelpers.export(exports, "milli", ()=>milli);
parcelHelpers.export(exports, "micro", ()=>micro);
parcelHelpers.export(exports, "nano", ()=>nano);
parcelHelpers.export(exports, "pico", ()=>pico);
parcelHelpers.export(exports, "femto", ()=>femto);
parcelHelpers.export(exports, "atto", ()=>atto);
parcelHelpers.export(exports, "zepto", ()=>zepto);
parcelHelpers.export(exports, "yocto", ()=>yocto);
parcelHelpers.export(exports, "prefix", ()=>prefix);
var _mathJs = require("./math.js");
const yotta = 1e24;
const zetta = 1e21;
const exa = 1e18;
const peta = 1e15;
const tera = 1e12;
const giga = 1e9;
const mega = 1e6;
const kilo = 1e3;
const hecto = 1e2;
const deca = 10;
const deci = 0.1;
const centi = 0.01;
const milli = 1e-3;
const micro = 1e-6;
const nano = 1e-9;
const pico = 1e-12;
const femto = 1e-15;
const atto = 1e-18;
const zepto = 1e-21;
const yocto = 1e-24;
const prefixUp = [
"",
"k",
"M",
"G",
"T",
"P",
"E",
"Z",
"Y"
];
const prefixDown = [
"",
"m",
"\u03BC",
"n",
"p",
"f",
"a",
"z",
"y"
];
const prefix = (n, baseMultiplier = 0)=>{
const nPow = n === 0 ? 0 : _mathJs.log10(n);
let mult = 0;
while(nPow < mult * 3 && baseMultiplier > -8){
baseMultiplier--;
mult--;
}
while(nPow >= 3 + mult * 3 && baseMultiplier < 8){
baseMultiplier++;
mult++;
}
const prefix = baseMultiplier < 0 ? prefixDown[-baseMultiplier] : prefixUp[baseMultiplier];
return {
n: _mathJs.round((mult > 0 ? n / _mathJs.exp10(mult * 3) : n * _mathJs.exp10(mult * -3)) * 1e12) / 1e12,
prefix
};
};
},{"./math.js":"bBwSk","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"2AAU4":[function(require,module,exports) {
/**
* Utility functions to work with buffers (Uint8Array).
*
* @module buffer
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "createUint8ArrayFromLen", ()=>createUint8ArrayFromLen);
parcelHelpers.export(exports, "createUint8ArrayViewFromArrayBuffer", ()=>createUint8ArrayViewFromArrayBuffer);
parcelHelpers.export(exports, "createUint8ArrayFromArrayBuffer", ()=>createUint8ArrayFromArrayBuffer);
parcelHelpers.export(exports, "toBase64", ()=>toBase64);
parcelHelpers.export(exports, "fromBase64", ()=>fromBase64);
parcelHelpers.export(exports, "toBase64UrlEncoded", ()=>toBase64UrlEncoded);
parcelHelpers.export(exports, "fromBase64UrlEncoded", ()=>fromBase64UrlEncoded);
parcelHelpers.export(exports, "toHexString", ()=>toHexString);
parcelHelpers.export(exports, "fromHexString", ()=>fromHexString);
parcelHelpers.export(exports, "copyUint8Array", ()=>copyUint8Array);
parcelHelpers.export(exports, "encodeAny", ()=>encodeAny);
parcelHelpers.export(exports, "decodeAny", ()=>decodeAny);
parcelHelpers.export(exports, "shiftNBitsLeft", ()=>shiftNBitsLeft);
var _stringJs = require("./string.js");
var _environmentJs = require("./environment.js");
var _arrayJs = require("./array.js");
var _mathJs = require("./math.js");
var _encodingJs = require("./encoding.js");
var _decodingJs = require("./decoding.js");
var Buffer = require("f3dd72291113e2d0").Buffer;
const createUint8ArrayFromLen = (len)=>new Uint8Array(len);
const createUint8ArrayViewFromArrayBuffer = (buffer, byteOffset, length)=>new Uint8Array(buffer, byteOffset, length);
const createUint8ArrayFromArrayBuffer = (buffer)=>new Uint8Array(buffer);
/* c8 ignore start */ /**
* @param {Uint8Array} bytes
* @return {string}
*/ const toBase64Browser = (bytes)=>{
let s = "";
for(let i = 0; i < bytes.byteLength; i++)s += _stringJs.fromCharCode(bytes[i]);
// eslint-disable-next-line no-undef
return btoa(s);
};
/* c8 ignore stop */ /**
* @param {Uint8Array} bytes
* @return {string}
*/ const toBase64Node = (bytes)=>Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
/* c8 ignore start */ /**
* @param {string} s
* @return {Uint8Array}
*/ const fromBase64Browser = (s)=>{
// eslint-disable-next-line no-undef
const a = atob(s);
const bytes = createUint8ArrayFromLen(a.length);
for(let i = 0; i < a.length; i++)bytes[i] = a.charCodeAt(i);
return bytes;
};
/* c8 ignore stop */ /**
* @param {string} s
*/ const fromBase64Node = (s)=>{
const buf = Buffer.from(s, "base64");
return createUint8ArrayViewFromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength);
};
const toBase64 = _environmentJs.isBrowser ? toBase64Browser : toBase64Node;
const fromBase64 = _environmentJs.isBrowser ? fromBase64Browser : fromBase64Node;
const toBase64UrlEncoded = (buf)=>toBase64(buf).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
const fromBase64UrlEncoded = (base64)=>fromBase64(base64.replaceAll("-", "+").replaceAll("_", "/"));
const toHexString = (buf)=>_arrayJs.map(buf, (b)=>b.toString(16).padStart(2, "0")).join("");
const fromHexString = (hex)=>{
const hlen = hex.length;
const buf = new Uint8Array(_mathJs.ceil(hlen / 2));
for(let i = 0; i < hlen; i += 2)buf[buf.length - i / 2 - 1] = Number.parseInt(hex.slice(hlen - i - 2, hlen - i), 16);
return buf;
};
const copyUint8Array = (uint8Array)=>{
const newBuf = createUint8ArrayFromLen(uint8Array.byteLength);
newBuf.set(uint8Array);
return newBuf;
};
const encodeAny = (data)=>_encodingJs.encode((encoder)=>_encodingJs.writeAny(encoder, data));
const decodeAny = (buf)=>_decodingJs.readAny(_decodingJs.createDecoder(buf));
const shiftNBitsLeft = (bs, N)=>{
if (N === 0) return bs;
bs = new Uint8Array(bs);
bs[0] <<= N;
for(let i = 1; i < bs.length; i++){
bs[i - 1] |= bs[i] >>> 8 - N;
bs[i] <<= N;
}
return bs;
};
},{"f3dd72291113e2d0":"bwHdc","./string.js":"liNHi","./environment.js":"jDk3n","./array.js":"fZD9X","./math.js":"bBwSk","./encoding.js":"8PAaf","./decoding.js":"JPRoL","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"jDk3n":[function(require,module,exports) {
/**
* Isomorphic module to work access the environment (query params, env variables).
*
* @module map
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "isNode", ()=>isNode);
parcelHelpers.export(exports, "isBrowser", ()=>isBrowser);
parcelHelpers.export(exports, "isMac", ()=>isMac);
parcelHelpers.export(exports, "hasParam", ()=>hasParam);
parcelHelpers.export(exports, "getParam", ()=>getParam);
parcelHelpers.export(exports, "getVariable", ()=>getVariable);
parcelHelpers.export(exports, "getConf", ()=>getConf);
parcelHelpers.export(exports, "ensureConf", ()=>ensureConf);
parcelHelpers.export(exports, "hasConf", ()=>hasConf);
parcelHelpers.export(exports, "production", ()=>production);
parcelHelpers.export(exports, "supportsColor", ()=>supportsColor);
var _mapJs = require("./map.js");
var _stringJs = require("./string.js");
var _conditionsJs = require("./conditions.js");
var _storageJs = require("./storage.js");
var _functionJs = require("./function.js");
var process = require("7bffcb6793b3d5d2");
const isNode = typeof process !== "undefined" && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
const isBrowser = typeof window !== "undefined" && typeof document !== "undefined" && !isNode;
const isMac = typeof navigator !== "undefined" ? /Mac/.test(navigator.platform) : false;
/**
* @type {Map<string,string>}
*/ let params;
const args = [];
/* c8 ignore start */ const computeParams = ()=>{
if (params === undefined) {
if (isNode) {
params = _mapJs.create();
const pargs = process.argv;
let currParamName = null;
for(let i = 0; i < pargs.length; i++){
const parg = pargs[i];
if (parg[0] === "-") {
if (currParamName !== null) params.set(currParamName, "");
currParamName = parg;
} else if (currParamName !== null) {
params.set(currParamName, parg);
currParamName = null;
} else args.push(parg);
}
if (currParamName !== null) params.set(currParamName, "");
// in ReactNative for example this would not be true (unless connected to the Remote Debugger)
} else if (typeof location === "object") {
params = _mapJs.create(); // eslint-disable-next-line no-undef
(location.search || "?").slice(1).split("&").forEach((kv)=>{
if (kv.length !== 0) {
const [key, value] = kv.split("=");
params.set(`--${_stringJs.fromCamelCase(key, "-")}`, value);
params.set(`-${_stringJs.fromCamelCase(key, "-")}`, value);
}
});
} else params = _mapJs.create();
}
return params;
};
const hasParam = (name)=>computeParams().has(name);
const getParam = (name, defaultVal)=>computeParams().get(name) || defaultVal;
const getVariable = (name)=>isNode ? _conditionsJs.undefinedToNull(process.env[name.toUpperCase().replaceAll("-", "_")]) : _conditionsJs.undefinedToNull(_storageJs.varStorage.getItem(name));
const getConf = (name)=>computeParams().get("--" + name) || getVariable(name);
const ensureConf = (name)=>{
const c = getConf(name);
if (c == null) throw new Error(`Expected configuration "${name.toUpperCase().replaceAll("-", "_")}"`);
return c;
};
const hasConf = (name)=>hasParam("--" + name) || getVariable(name) !== null;
const production = hasConf("production");
/* c8 ignore next 2 */ const forceColor = isNode && _functionJs.isOneOf(undefined, [
"true",
"1",
"2"
]);
const supportsColor = !hasParam("--no-colors") && (!isNode || process.stdout.isTTY || forceColor) && (!isNode || hasParam("--color") || forceColor || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color") /* c8 ignore stop */ );
},{"7bffcb6793b3d5d2":"8en8U","./map.js":"1FJ4I","./string.js":"liNHi","./conditions.js":"8EqQQ","./storage.js":"fUJk3","./function.js":"dS7sP","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8en8U":[function(require,module,exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error("setTimeout has not been defined");
}
function defaultClearTimeout() {
throw new Error("clearTimeout has not been defined");
}
(function() {
try {
if (typeof setTimeout === "function") cachedSetTimeout = setTimeout;
else cachedSetTimeout = defaultSetTimout;
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === "function") cachedClearTimeout = clearTimeout;
else cachedClearTimeout = defaultClearTimeout;
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
})();
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) //normal enviroments in sane situations
return setTimeout(fun, 0);
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch (e) {
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch (e) {
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) //normal enviroments in sane situations
return clearTimeout(marker);
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e) {
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e) {
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) return;
draining = false;
if (currentQueue.length) queue = currentQueue.concat(queue);
else queueIndex = -1;
if (queue.length) drainQueue();
}
function drainQueue() {
if (draining) return;
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len){
currentQueue = queue;
queue = [];
while(++queueIndex < len)if (currentQueue) currentQueue[queueIndex].run();
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function(fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) for(var i = 1; i < arguments.length; i++)args[i - 1] = arguments[i];
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) runTimeout(drainQueue);
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function() {
this.fun.apply(null, this.array);
};
process.title = "browser";
process.browser = true;
process.env = {};
process.argv = [];
process.version = ""; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function(name) {
return [];
};
process.binding = function(name) {
throw new Error("process.binding is not supported");
};
process.cwd = function() {
return "/";
};
process.chdir = function(dir) {
throw new Error("process.chdir is not supported");
};
process.umask = function() {
return 0;
};
},{}],"8EqQQ":[function(require,module,exports) {
/**
* Often used conditions.
*
* @module conditions
*/ /**
* @template T
* @param {T|null|undefined} v
* @return {T|null}
*/ /* c8 ignore next */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "undefinedToNull", ()=>undefinedToNull);
const undefinedToNull = (v)=>v === undefined ? null : v;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fUJk3":[function(require,module,exports) {
/* eslint-env browser */ /**
* Isomorphic variable storage.
*
* Uses LocalStorage in the browser and falls back to in-memory storage.
*
* @module storage
*/ /* c8 ignore start */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "varStorage", ()=>varStorage);
parcelHelpers.export(exports, "onChange", ()=>onChange);
parcelHelpers.export(exports, "offChange", ()=>offChange);
class VarStoragePolyfill {
constructor(){
this.map = new Map();
}
/**
* @param {string} key
* @param {any} newValue
*/ setItem(key, newValue) {
this.map.set(key, newValue);
}
/**
* @param {string} key
*/ getItem(key) {
return this.map.get(key);
}
}
/* c8 ignore stop */ /**
* @type {any}
*/ let _localStorage = new VarStoragePolyfill();
let usePolyfill = true;
/* c8 ignore start */ try {
// if the same-origin rule is violated, accessing localStorage might thrown an error
if (typeof localStorage !== "undefined" && localStorage) {
_localStorage = localStorage;
usePolyfill = false;
}
} catch (e) {}
const varStorage = _localStorage;
const onChange = (eventHandler)=>usePolyfill || addEventListener("storage", /** @type {any} */ eventHandler);
const offChange = (eventHandler)=>usePolyfill || removeEventListener("storage", /** @type {any} */ eventHandler);
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"dS7sP":[function(require,module,exports) {
/**
* Common functions and function call helpers.
*
* @module function
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "callAll", ()=>callAll);
parcelHelpers.export(exports, "nop", ()=>nop);
parcelHelpers.export(exports, "apply", ()=>apply);
parcelHelpers.export(exports, "id", ()=>id);
parcelHelpers.export(exports, "equalityStrict", ()=>equalityStrict);
parcelHelpers.export(exports, "equalityFlat", ()=>equalityFlat);
parcelHelpers.export(exports, "equalityDeep", ()=>equalityDeep);
parcelHelpers.export(exports, "isOneOf", ()=>isOneOf);
parcelHelpers.export(exports, "isArray", ()=>isArray);
parcelHelpers.export(exports, "isString", ()=>isString);
parcelHelpers.export(exports, "isNumber", ()=>isNumber);
parcelHelpers.export(exports, "is", ()=>is);
parcelHelpers.export(exports, "isTemplate", ()=>isTemplate);
var _arrayJs = require("./array.js");
var _objectJs = require("./object.js");
const callAll = (fs, args, i = 0)=>{
try {
for(; i < fs.length; i++)fs[i](...args);
} finally{
if (i < fs.length) callAll(fs, args, i + 1);
}
};
const nop = ()=>{};
const apply = (f)=>f();
const id = (a)=>a;
const equalityStrict = (a, b)=>a === b;
const equalityFlat = (a, b)=>a === b || a != null && b != null && a.constructor === b.constructor && (_arrayJs.isArray(a) && _arrayJs.equalFlat(a, /** @type {Array<T>} */ b) || typeof a === "object" && _objectJs.equalFlat(a, b));
const equalityDeep = (a, b)=>{
if (a == null || b == null) return equalityStrict(a, b);
if (a.constructor !== b.constructor) return false;
if (a === b) return true;
switch(a.constructor){
case ArrayBuffer:
a = new Uint8Array(a);
b = new Uint8Array(b);
// eslint-disable-next-line no-fallthrough
case Uint8Array:
if (a.byteLength !== b.byteLength) return false;
for(let i = 0; i < a.length; i++){
if (a[i] !== b[i]) return false;
}
break;
case Set:
if (a.size !== b.size) return false;
for (const value of a){
if (!b.has(value)) return false;
}
break;
case Map:
if (a.size !== b.size) return false;
for (const key of a.keys()){
if (!b.has(key) || !equalityDeep(a.get(key), b.get(key))) return false;
}
break;
case Object:
if (_objectJs.length(a) !== _objectJs.length(b)) return false;
for(const key in a){
if (!_objectJs.hasProperty(a, key) || !equalityDeep(a[key], b[key])) return false;
}
break;
case Array:
if (a.length !== b.length) return false;
for(let i = 0; i < a.length; i++){
if (!equalityDeep(a[i], b[i])) return false;
}
break;
default:
return false;
}
return true;
};
const isOneOf = (value, options)=>options.includes(value);
const isArray = _arrayJs.isArray;
const isString = (s)=>s && s.constructor === String;
const isNumber = (n)=>n != null && n.constructor === Number;
const is = (n, T)=>n && n.constructor === T;
const isTemplate = (T)=>/**
* @param {any} n
* @return {n is InstanceType<TYPE>}
**/ (n)=>n && n.constructor === T;
},{"./array.js":"fZD9X","./object.js":"fN1Sq","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fN1Sq":[function(require,module,exports) {
/**
* Utility functions for working with EcmaScript objects.
*
* @module object
*/ /**
* @return {Object<string,any>} obj
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "create", ()=>create);
parcelHelpers.export(exports, "assign", ()=>assign);
parcelHelpers.export(exports, "keys", ()=>keys);
parcelHelpers.export(exports, "forEach", ()=>forEach);
parcelHelpers.export(exports, "map", ()=>map);
parcelHelpers.export(exports, "length", ()=>length);
parcelHelpers.export(exports, "size", ()=>size);
parcelHelpers.export(exports, "some", ()=>some);
parcelHelpers.export(exports, "isEmpty", ()=>isEmpty);
parcelHelpers.export(exports, "every", ()=>every);
parcelHelpers.export(exports, "hasProperty", ()=>hasProperty);
parcelHelpers.export(exports, "equalFlat", ()=>equalFlat);
const create = ()=>Object.create(null);
const assign = Object.assign;
const keys = Object.keys;
const forEach = (obj, f)=>{
for(const key in obj)f(obj[key], key);
};
const map = (obj, f)=>{
const results = [];
for(const key in obj)results.push(f(obj[key], key));
return results;
};
const length = (obj)=>keys(obj).length;
const size = (obj)=>keys(obj).length;
const some = (obj, f)=>{
for(const key in obj){
if (f(obj[key], key)) return true;
}
return false;
};
const isEmpty = (obj)=>{
// eslint-disable-next-line
for(const _k in obj)return false;
return true;
};
const every = (obj, f)=>{
for(const key in obj){
if (!f(obj[key], key)) return false;
}
return true;
};
const hasProperty = (obj, key)=>Object.prototype.hasOwnProperty.call(obj, key);
const equalFlat = (a, b)=>a === b || size(a) === size(b) && every(a, (val, key)=>(val !== undefined || hasProperty(b, key)) && b[key] === val);
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8fiiS":[function(require,module,exports) {
/**
* Isomorphic logging module with support for colors!
*
* @module logging
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "BOLD", ()=>(0, _loggingCommonJs.BOLD));
parcelHelpers.export(exports, "UNBOLD", ()=>(0, _loggingCommonJs.UNBOLD));
parcelHelpers.export(exports, "BLUE", ()=>(0, _loggingCommonJs.BLUE));
parcelHelpers.export(exports, "GREY", ()=>(0, _loggingCommonJs.GREY));
parcelHelpers.export(exports, "GREEN", ()=>(0, _loggingCommonJs.GREEN));
parcelHelpers.export(exports, "RED", ()=>(0, _loggingCommonJs.RED));
parcelHelpers.export(exports, "PURPLE", ()=>(0, _loggingCommonJs.PURPLE));
parcelHelpers.export(exports, "ORANGE", ()=>(0, _loggingCommonJs.ORANGE));
parcelHelpers.export(exports, "UNCOLOR", ()=>(0, _loggingCommonJs.UNCOLOR));
parcelHelpers.export(exports, "print", ()=>print);
parcelHelpers.export(exports, "warn", ()=>warn);
parcelHelpers.export(exports, "printError", ()=>printError);
parcelHelpers.export(exports, "printImg", ()=>printImg);
parcelHelpers.export(exports, "printImgBase64", ()=>printImgBase64);
parcelHelpers.export(exports, "group", ()=>group);
parcelHelpers.export(exports, "groupCollapsed", ()=>groupCollapsed);
parcelHelpers.export(exports, "groupEnd", ()=>groupEnd);
parcelHelpers.export(exports, "printDom", ()=>printDom);
parcelHelpers.export(exports, "printCanvas", ()=>printCanvas);
parcelHelpers.export(exports, "vconsoles", ()=>vconsoles);
/* c8 ignore start */ parcelHelpers.export(exports, "VConsole", ()=>VConsole);
parcelHelpers.export(exports, "createVConsole", ()=>createVConsole);
parcelHelpers.export(exports, "createModuleLogger", ()=>createModuleLogger);
var _environmentJs = require("./environment.js");
var _setJs = require("./set.js");
var _pairJs = require("./pair.js");
var _domJs = require("./dom.js");
var _jsonJs = require("./json.js");
var _mapJs = require("./map.js");
var _eventloopJs = require("./eventloop.js");
var _mathJs = require("./math.js");
var _loggingCommonJs = require("./logging.common.js");
/**
* @type {Object<Symbol,pair.Pair<string,string>>}
*/ const _browserStyleMap = {
[_loggingCommonJs.BOLD]: _pairJs.create("font-weight", "bold"),
[_loggingCommonJs.UNBOLD]: _pairJs.create("font-weight", "normal"),
[_loggingCommonJs.BLUE]: _pairJs.create("color", "blue"),
[_loggingCommonJs.GREEN]: _pairJs.create("color", "green"),
[_loggingCommonJs.GREY]: _pairJs.create("color", "grey"),
[_loggingCommonJs.RED]: _pairJs.create("color", "red"),
[_loggingCommonJs.PURPLE]: _pairJs.create("color", "purple"),
[_loggingCommonJs.ORANGE]: _pairJs.create("color", "orange"),
[_loggingCommonJs.UNCOLOR]: _pairJs.create("color", "black")
};
/**
* @param {Array<string|Symbol|Object|number|function():any>} args
* @return {Array<string|object|number>}
*/ /* c8 ignore start */ const computeBrowserLoggingArgs = (args)=>{
if (args.length === 1 && args[0]?.constructor === Function) args = /** @type {Array<string|Symbol|Object|number>} */ /** @type {[function]} */ args[0]();
const strBuilder = [];
const styles = [];
const currentStyle = _mapJs.create();
/**
* @type {Array<string|Object|number>}
*/ let logArgs = [];
// try with formatting until we find something unsupported
let i = 0;
for(; i < args.length; i++){
const arg = args[i];
// @ts-ignore
const style = _browserStyleMap[arg];
if (style !== undefined) currentStyle.set(style.left, style.right);
else {
if (arg === undefined) break;
if (arg.constructor === String || arg.constructor === Number) {
const style = _domJs.mapToStyleString(currentStyle);
if (i > 0 || style.length > 0) {
strBuilder.push("%c" + arg);
styles.push(style);
} else strBuilder.push(arg);
} else break;
}
}
if (i > 0) {
// create logArgs with what we have so far
logArgs = styles;
logArgs.unshift(strBuilder.join(""));
}
// append the rest
for(; i < args.length; i++){
const arg = args[i];
if (!(arg instanceof Symbol)) logArgs.push(arg);
}
return logArgs;
};
/* c8 ignore stop */ /* c8 ignore start */ const computeLoggingArgs = _environmentJs.supportsColor ? computeBrowserLoggingArgs : _loggingCommonJs.computeNoColorLoggingArgs;
const print = (...args)=>{
console.log(...computeLoggingArgs(args));
/* c8 ignore next */ vconsoles.forEach((vc)=>vc.print(args));
};
const warn = (...args)=>{
console.warn(...computeLoggingArgs(args));
args.unshift(_loggingCommonJs.ORANGE);
vconsoles.forEach((vc)=>vc.print(args));
};
const printError = (err)=>{
console.error(err);
vconsoles.forEach((vc)=>vc.printError(err));
};
const printImg = (url, height)=>{
if (_environmentJs.isBrowser) console.log("%c ", `font-size: ${height}px; background-size: contain; background-repeat: no-repeat; background-image: url(${url})`);
vconsoles.forEach((vc)=>vc.printImg(url, height));
};
const printImgBase64 = (base64, height)=>printImg(`data:image/gif;base64,${base64}`, height);
const group = (...args)=>{
console.group(...computeLoggingArgs(args));
/* c8 ignore next */ vconsoles.forEach((vc)=>vc.group(args));
};
const groupCollapsed = (...args)=>{
console.groupCollapsed(...computeLoggingArgs(args));
/* c8 ignore next */ vconsoles.forEach((vc)=>vc.groupCollapsed(args));
};
const groupEnd = ()=>{
console.groupEnd();
/* c8 ignore next */ vconsoles.forEach((vc)=>vc.groupEnd());
};
const printDom = (createNode)=>vconsoles.forEach((vc)=>vc.printDom(createNode()));
const printCanvas = (canvas, height)=>printImg(canvas.toDataURL(), height);
const vconsoles = _setJs.create();
/**
* @param {Array<string|Symbol|Object|number>} args
* @return {Array<Element>}
*/ /* c8 ignore start */ const _computeLineSpans = (args)=>{
const spans = [];
const currentStyle = new Map();
// try with formatting until we find something unsupported
let i = 0;
for(; i < args.length; i++){
let arg = args[i];
// @ts-ignore
const style = _browserStyleMap[arg];
if (style !== undefined) currentStyle.set(style.left, style.right);
else {
if (arg === undefined) arg = "undefined ";
if (arg.constructor === String || arg.constructor === Number) {
// @ts-ignore
const span = _domJs.element("span", [
_pairJs.create("style", _domJs.mapToStyleString(currentStyle))
], [
_domJs.text(arg.toString())
]);
if (span.innerHTML === "") span.innerHTML = "&nbsp;";
spans.push(span);
} else break;
}
}
// append the rest
for(; i < args.length; i++){
let content = args[i];
if (!(content instanceof Symbol)) {
if (content.constructor !== String && content.constructor !== Number) content = " " + _jsonJs.stringify(content) + " ";
spans.push(_domJs.element("span", [], [
_domJs.text(/** @type {string} */ content)
]));
}
}
return spans;
};
/* c8 ignore stop */ const lineStyle = "font-family:monospace;border-bottom:1px solid #e2e2e2;padding:2px;";
class VConsole {
/**
* @param {Element} dom
*/ constructor(dom){
this.dom = dom;
/**
* @type {Element}
*/ this.ccontainer = this.dom;
this.depth = 0;
vconsoles.add(this);
}
/**
* @param {Array<string|Symbol|Object|number>} args
* @param {boolean} collapsed
*/ group(args, collapsed = false) {
_eventloopJs.enqueue(()=>{
const triangleDown = _domJs.element("span", [
_pairJs.create("hidden", collapsed),
_pairJs.create("style", "color:grey;font-size:120%;")
], [
_domJs.text("\u25BC")
]);
const triangleRight = _domJs.element("span", [
_pairJs.create("hidden", !collapsed),
_pairJs.create("style", "color:grey;font-size:125%;")
], [
_domJs.text("\u25B6")
]);
const content = _domJs.element("div", [
_pairJs.create("style", `${lineStyle};padding-left:${this.depth * 10}px`)
], [
triangleDown,
triangleRight,
_domJs.text(" ")
].concat(_computeLineSpans(args)));
const nextContainer = _domJs.element("div", [
_pairJs.create("hidden", collapsed)
]);
const nextLine = _domJs.element("div", [], [
content,
nextContainer
]);
_domJs.append(this.ccontainer, [
nextLine
]);
this.ccontainer = nextContainer;
this.depth++;
// when header is clicked, collapse/uncollapse container
_domJs.addEventListener(content, "click", (_event)=>{
nextContainer.toggleAttribute("hidden");
triangleDown.toggleAttribute("hidden");
triangleRight.toggleAttribute("hidden");
});
});
}
/**
* @param {Array<string|Symbol|Object|number>} args
*/ groupCollapsed(args) {
this.group(args, true);
}
groupEnd() {
_eventloopJs.enqueue(()=>{
if (this.depth > 0) {
this.depth--;
// @ts-ignore
this.ccontainer = this.ccontainer.parentElement.parentElement;
}
});
}
/**
* @param {Array<string|Symbol|Object|number>} args
*/ print(args) {
_eventloopJs.enqueue(()=>{
_domJs.append(this.ccontainer, [
_domJs.element("div", [
_pairJs.create("style", `${lineStyle};padding-left:${this.depth * 10}px`)
], _computeLineSpans(args))
]);
});
}
/**
* @param {Error} err
*/ printError(err) {
this.print([
_loggingCommonJs.RED,
_loggingCommonJs.BOLD,
err.toString()
]);
}
/**
* @param {string} url
* @param {number} height
*/ printImg(url, height) {
_eventloopJs.enqueue(()=>{
_domJs.append(this.ccontainer, [
_domJs.element("img", [
_pairJs.create("src", url),
_pairJs.create("height", `${_mathJs.round(height * 1.5)}px`)
])
]);
});
}
/**
* @param {Node} node
*/ printDom(node) {
_eventloopJs.enqueue(()=>{
_domJs.append(this.ccontainer, [
node
]);
});
}
destroy() {
_eventloopJs.enqueue(()=>{
vconsoles.delete(this);
});
}
}
const createVConsole = (dom)=>new VConsole(dom);
const createModuleLogger = (moduleName)=>_loggingCommonJs.createModuleLogger(print, moduleName);
},{"./environment.js":"jDk3n","./set.js":"8kG8c","./pair.js":"dLVrl","./dom.js":"jsMUy","./json.js":"gt3UH","./map.js":"1FJ4I","./eventloop.js":"iDHWJ","./math.js":"bBwSk","./logging.common.js":"klZ3H","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"dLVrl":[function(require,module,exports) {
/**
* Working with value pairs.
*
* @module pair
*/ /**
* @template L,R
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "Pair", ()=>Pair);
parcelHelpers.export(exports, "create", ()=>create);
parcelHelpers.export(exports, "createReversed", ()=>createReversed);
parcelHelpers.export(exports, "forEach", ()=>forEach);
parcelHelpers.export(exports, "map", ()=>map);
class Pair {
/**
* @param {L} left
* @param {R} right
*/ constructor(left, right){
this.left = left;
this.right = right;
}
}
const create = (left, right)=>new Pair(left, right);
const createReversed = (right, left)=>new Pair(left, right);
const forEach = (arr, f)=>arr.forEach((p)=>f(p.left, p.right));
const map = (arr, f)=>arr.map((p)=>f(p.left, p.right));
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"jsMUy":[function(require,module,exports) {
/* eslint-env browser */ /**
* Utility module to work with the DOM.
*
* @module dom
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "doc", ()=>doc);
parcelHelpers.export(exports, "createElement", ()=>createElement);
parcelHelpers.export(exports, "createDocumentFragment", ()=>createDocumentFragment);
parcelHelpers.export(exports, "createTextNode", ()=>createTextNode);
parcelHelpers.export(exports, "domParser", ()=>domParser);
parcelHelpers.export(exports, "emitCustomEvent", ()=>emitCustomEvent);
parcelHelpers.export(exports, "setAttributes", ()=>setAttributes);
parcelHelpers.export(exports, "setAttributesMap", ()=>setAttributesMap);
parcelHelpers.export(exports, "fragment", ()=>fragment);
parcelHelpers.export(exports, "append", ()=>append);
parcelHelpers.export(exports, "remove", ()=>remove);
parcelHelpers.export(exports, "addEventListener", ()=>addEventListener);
parcelHelpers.export(exports, "removeEventListener", ()=>removeEventListener);
parcelHelpers.export(exports, "addEventListeners", ()=>addEventListeners);
parcelHelpers.export(exports, "removeEventListeners", ()=>removeEventListeners);
parcelHelpers.export(exports, "element", ()=>element);
parcelHelpers.export(exports, "canvas", ()=>canvas);
parcelHelpers.export(exports, "text", ()=>text);
parcelHelpers.export(exports, "pairToStyleString", ()=>pairToStyleString);
parcelHelpers.export(exports, "pairsToStyleString", ()=>pairsToStyleString);
parcelHelpers.export(exports, "mapToStyleString", ()=>mapToStyleString);
parcelHelpers.export(exports, "querySelector", ()=>querySelector);
parcelHelpers.export(exports, "querySelectorAll", ()=>querySelectorAll);
parcelHelpers.export(exports, "getElementById", ()=>getElementById);
parcelHelpers.export(exports, "parseFragment", ()=>parseFragment);
parcelHelpers.export(exports, "parseElement", ()=>parseElement);
parcelHelpers.export(exports, "replaceWith", ()=>replaceWith);
parcelHelpers.export(exports, "insertBefore", ()=>insertBefore);
parcelHelpers.export(exports, "appendChild", ()=>appendChild);
parcelHelpers.export(exports, "ELEMENT_NODE", ()=>ELEMENT_NODE);
parcelHelpers.export(exports, "TEXT_NODE", ()=>TEXT_NODE);
parcelHelpers.export(exports, "CDATA_SECTION_NODE", ()=>CDATA_SECTION_NODE);
parcelHelpers.export(exports, "COMMENT_NODE", ()=>COMMENT_NODE);
parcelHelpers.export(exports, "DOCUMENT_NODE", ()=>DOCUMENT_NODE);
parcelHelpers.export(exports, "DOCUMENT_TYPE_NODE", ()=>DOCUMENT_TYPE_NODE);
parcelHelpers.export(exports, "DOCUMENT_FRAGMENT_NODE", ()=>DOCUMENT_FRAGMENT_NODE);
parcelHelpers.export(exports, "checkNodeType", ()=>checkNodeType);
parcelHelpers.export(exports, "isParentOf", ()=>isParentOf);
var _pairJs = require("./pair.js");
var _mapJs = require("./map.js");
const doc = /** @type {Document} */ typeof document !== "undefined" ? document : {};
const createElement = (name)=>doc.createElement(name);
const createDocumentFragment = ()=>doc.createDocumentFragment();
const createTextNode = (text)=>doc.createTextNode(text);
const domParser = /** @type {DOMParser} */ typeof DOMParser !== "undefined" ? new DOMParser() : null;
const emitCustomEvent = (el, name, opts)=>el.dispatchEvent(new CustomEvent(name, opts));
const setAttributes = (el, attrs)=>{
_pairJs.forEach(attrs, (key, value)=>{
if (value === false) el.removeAttribute(key);
else if (value === true) el.setAttribute(key, "");
else // @ts-ignore
el.setAttribute(key, value);
});
return el;
};
const setAttributesMap = (el, attrs)=>{
attrs.forEach((value, key)=>{
el.setAttribute(key, value);
});
return el;
};
const fragment = (children)=>{
const fragment = createDocumentFragment();
for(let i = 0; i < children.length; i++)appendChild(fragment, children[i]);
return fragment;
};
const append = (parent, nodes)=>{
appendChild(parent, fragment(nodes));
return parent;
};
const remove = (el)=>el.remove();
const addEventListener = (el, name, f)=>el.addEventListener(name, f);
const removeEventListener = (el, name, f)=>el.removeEventListener(name, f);
const addEventListeners = (node, listeners)=>{
_pairJs.forEach(listeners, (name, f)=>addEventListener(node, name, f));
return node;
};
const removeEventListeners = (node, listeners)=>{
_pairJs.forEach(listeners, (name, f)=>removeEventListener(node, name, f));
return node;
};
const element = (name, attrs = [], children = [])=>append(setAttributes(createElement(name), attrs), children);
const canvas = (width, height)=>{
const c = /** @type {HTMLCanvasElement} */ createElement("canvas");
c.height = height;
c.width = width;
return c;
};
const text = createTextNode;
const pairToStyleString = (pair)=>`${pair.left}:${pair.right};`;
const pairsToStyleString = (pairs)=>pairs.map(pairToStyleString).join("");
const mapToStyleString = (m)=>_mapJs.map(m, (value, key)=>`${key}:${value};`).join("");
const querySelector = (el, query)=>el.querySelector(query);
const querySelectorAll = (el, query)=>el.querySelectorAll(query);
const getElementById = (id)=>/** @type {HTMLElement} */ doc.getElementById(id);
/**
* @param {string} html
* @return {HTMLElement}
*/ const _parse = (html)=>domParser.parseFromString(`<html><body>${html}</body></html>`, "text/html").body;
const parseFragment = (html)=>fragment(/** @type {any} */ _parse(html).childNodes);
const parseElement = (html)=>/** @type HTMLElement */ _parse(html).firstElementChild;
const replaceWith = (oldEl, newEl)=>oldEl.replaceWith(newEl);
const insertBefore = (parent, el, ref)=>parent.insertBefore(el, ref);
const appendChild = (parent, child)=>parent.appendChild(child);
const ELEMENT_NODE = doc.ELEMENT_NODE;
const TEXT_NODE = doc.TEXT_NODE;
const CDATA_SECTION_NODE = doc.CDATA_SECTION_NODE;
const COMMENT_NODE = doc.COMMENT_NODE;
const DOCUMENT_NODE = doc.DOCUMENT_NODE;
const DOCUMENT_TYPE_NODE = doc.DOCUMENT_TYPE_NODE;
const DOCUMENT_FRAGMENT_NODE = doc.DOCUMENT_FRAGMENT_NODE;
const checkNodeType = (node, type)=>node.nodeType === type;
const isParentOf = (parent, child)=>{
let p = child.parentNode;
while(p && p !== parent)p = p.parentNode;
return p === parent;
} /* c8 ignore stop */ ;
},{"./pair.js":"dLVrl","./map.js":"1FJ4I","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"gt3UH":[function(require,module,exports) {
/**
* JSON utility functions.
*
* @module json
*/ /**
* Transform JavaScript object to JSON.
*
* @param {any} object
* @return {string}
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "stringify", ()=>stringify);
parcelHelpers.export(exports, "parse", ()=>parse);
const stringify = JSON.stringify;
const parse = JSON.parse;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"iDHWJ":[function(require,module,exports) {
/* global requestIdleCallback, requestAnimationFrame, cancelIdleCallback, cancelAnimationFrame */ /**
* Utility module to work with EcmaScript's event loop.
*
* @module eventloop
*/ /**
* @type {Array<function>}
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "enqueue", ()=>enqueue);
parcelHelpers.export(exports, "timeout", ()=>timeout);
parcelHelpers.export(exports, "interval", ()=>interval);
parcelHelpers.export(exports, "Animation", ()=>Animation);
parcelHelpers.export(exports, "animationFrame", ()=>animationFrame);
parcelHelpers.export(exports, "idleCallback", ()=>idleCallback);
parcelHelpers.export(exports, "createDebouncer", ()=>createDebouncer);
let queue = [];
const _runQueue = ()=>{
for(let i = 0; i < queue.length; i++)queue[i]();
queue = [];
};
const enqueue = (f)=>{
queue.push(f);
if (queue.length === 1) setTimeout(_runQueue, 0);
};
/**
* @typedef {Object} TimeoutObject
* @property {function} TimeoutObject.destroy
*/ /**
* @param {function(number):void} clearFunction
*/ const createTimeoutClass = (clearFunction)=>class TT {
/**
* @param {number} timeoutId
*/ constructor(timeoutId){
this._ = timeoutId;
}
destroy() {
clearFunction(this._);
}
};
const Timeout = createTimeoutClass(clearTimeout);
const timeout = (timeout, callback)=>new Timeout(setTimeout(callback, timeout));
const Interval = createTimeoutClass(clearInterval);
const interval = (timeout, callback)=>new Interval(setInterval(callback, timeout));
const Animation = createTimeoutClass((arg)=>typeof requestAnimationFrame !== "undefined" && cancelAnimationFrame(arg));
const animationFrame = (cb)=>typeof requestAnimationFrame === "undefined" ? timeout(0, cb) : new Animation(requestAnimationFrame(cb));
/* c8 ignore next */ // @ts-ignore
const Idle = createTimeoutClass((arg)=>typeof cancelIdleCallback !== "undefined" && cancelIdleCallback(arg));
const idleCallback = (cb)=>typeof requestIdleCallback !== "undefined" ? new Idle(requestIdleCallback(cb)) : timeout(1000, cb);
const createDebouncer = (timeout)=>{
let timer = -1;
return (f)=>{
clearTimeout(timer);
if (f) timer = /** @type {any} */ setTimeout(f, timeout);
};
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"klZ3H":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "BOLD", ()=>BOLD);
parcelHelpers.export(exports, "UNBOLD", ()=>UNBOLD);
parcelHelpers.export(exports, "BLUE", ()=>BLUE);
parcelHelpers.export(exports, "GREY", ()=>GREY);
parcelHelpers.export(exports, "GREEN", ()=>GREEN);
parcelHelpers.export(exports, "RED", ()=>RED);
parcelHelpers.export(exports, "PURPLE", ()=>PURPLE);
parcelHelpers.export(exports, "ORANGE", ()=>ORANGE);
parcelHelpers.export(exports, "UNCOLOR", ()=>UNCOLOR);
parcelHelpers.export(exports, "computeNoColorLoggingArgs", ()=>computeNoColorLoggingArgs);
parcelHelpers.export(exports, "createModuleLogger", ()=>createModuleLogger);
var _symbolJs = require("./symbol.js");
var _timeJs = require("./time.js");
var _environmentJs = require("./environment.js");
var _functionJs = require("./function.js");
var _jsonJs = require("./json.js");
const BOLD = _symbolJs.create();
const UNBOLD = _symbolJs.create();
const BLUE = _symbolJs.create();
const GREY = _symbolJs.create();
const GREEN = _symbolJs.create();
const RED = _symbolJs.create();
const PURPLE = _symbolJs.create();
const ORANGE = _symbolJs.create();
const UNCOLOR = _symbolJs.create();
const computeNoColorLoggingArgs = (args)=>{
if (args.length === 1 && args[0]?.constructor === Function) args = /** @type {Array<string|Symbol|Object|number>} */ /** @type {[function]} */ args[0]();
const strBuilder = [];
const logArgs = [];
// try with formatting until we find something unsupported
let i = 0;
for(; i < args.length; i++){
const arg = args[i];
if (arg === undefined) strBuilder.push("undefined");
else if (arg.constructor === String || arg.constructor === Number) strBuilder.push(arg);
else if (arg.constructor === Object) logArgs.push(JSON.stringify(arg));
}
return logArgs;
};
/* c8 ignore stop */ const loggingColors = [
GREEN,
PURPLE,
ORANGE,
BLUE
];
let nextColor = 0;
let lastLoggingTime = _timeJs.getUnixTime();
const createModuleLogger = (_print, moduleName)=>{
const color = loggingColors[nextColor];
const debugRegexVar = _environmentJs.getVariable("log");
const doLogging = debugRegexVar !== null && (debugRegexVar === "*" || debugRegexVar === "true" || new RegExp(debugRegexVar, "gi").test(moduleName));
nextColor = (nextColor + 1) % loggingColors.length;
moduleName += ": ";
return !doLogging ? _functionJs.nop : (...args)=>{
if (args.length === 1 && args[0]?.constructor === Function) args = args[0]();
const timeNow = _timeJs.getUnixTime();
const timeDiff = timeNow - lastLoggingTime;
lastLoggingTime = timeNow;
_print(color, moduleName, UNCOLOR, ...args.map((arg)=>{
if (arg != null && arg.constructor === Uint8Array) arg = Array.from(arg);
const t = typeof arg;
switch(t){
case "string":
case "symbol":
return arg;
default:
return _jsonJs.stringify(arg);
}
}), color, " +" + timeDiff + "ms");
};
} /* c8 ignore stop */ ;
},{"./symbol.js":"jqHRx","./time.js":"8mk6w","./environment.js":"jDk3n","./function.js":"dS7sP","./json.js":"gt3UH","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"jqHRx":[function(require,module,exports) {
/**
* Utility module to work with EcmaScript Symbols.
*
* @module symbol
*/ /**
* Return fresh symbol.
*
* @return {Symbol}
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "create", ()=>create);
parcelHelpers.export(exports, "isSymbol", ()=>isSymbol);
const create = Symbol;
const isSymbol = (s)=>typeof s === "symbol";
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8ANgc":[function(require,module,exports) {
/**
* Utility module to create and manipulate Iterators.
*
* @module iterator
*/ /**
* @template T,R
* @param {Iterator<T>} iterator
* @param {function(T):R} f
* @return {IterableIterator<R>}
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "mapIterator", ()=>mapIterator);
parcelHelpers.export(exports, "createIterator", ()=>createIterator);
parcelHelpers.export(exports, "iteratorFilter", ()=>iteratorFilter);
parcelHelpers.export(exports, "iteratorMap", ()=>iteratorMap);
const mapIterator = (iterator, f)=>({
[Symbol.iterator] () {
return this;
},
// @ts-ignore
next () {
const r = iterator.next();
return {
value: r.done ? undefined : f(r.value),
done: r.done
};
}
});
const createIterator = (next)=>({
/**
* @return {IterableIterator<T>}
*/ [Symbol.iterator] () {
return this;
},
// @ts-ignore
next
});
const iteratorFilter = (iterator, filter)=>createIterator(()=>{
let res;
do res = iterator.next();
while (!res.done && !filter(res.value));
return res;
});
const iteratorMap = (iterator, fmap)=>createIterator(()=>{
const { done, value } = iterator.next();
return {
done,
value: done ? undefined : fmap(value)
};
});
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"bN75g":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "registerSiteTypings", ()=>registerSiteTypings);
parcelHelpers.export(exports, "monacoTypings", ()=>monacoTypings);
parcelHelpers.export(exports, "iftext", ()=>iftext);
parcelHelpers.export(exports, "register", ()=>register);
var _general = require("../types/general");
var _base = require("./types/base");
var _prop = require("./types/prop");
const map = new WeakMap();
const registerSiteTypings = (monaco, p)=>{
if (p.site_dts) {
register(monaco, p.site_dts, "ts:site.d.ts");
const dts_text = Object.entries(p.site_dts_entry).map(([name, type])=>{
return `
${type} ${name} = _.${name};`;
}).join("\n");
register(monaco, `\
declare global {
import * as _ from "index"
${dts_text}
}
export {}
`, "ts:active_global.d.ts");
}
};
const monacoTypings = async (p, monaco, prop)=>{
registerSiteTypings(monaco, p);
if (!map.has(prop.values)) map.set(prop.values, true);
else return;
const prasi_api = (0, _general.w).prasiApi[p.site.api_url];
if (prasi_api) {
if (prasi_api && prasi_api.prismaTypes) {
const prisma = prasi_api.prismaTypes;
if (prisma) {
register(monaco, `\
declare module "ts:runtime/index" {
${prisma["runtime/index.d.ts"]}
}`, `ts:runtime/index.d.ts`);
register(monaco, `\
declare module "ts:runtime/library" {
${prisma["runtime/library.d.ts"]}
}`, `ts:runtime/library.d.ts`);
const prisma_text = `\
declare global {
${prisma["prisma.d.ts"].replace(`import * as runtime from './runtime/library.js';`, `import * as runtime from 'ts:runtime/library';`).replace(`import * as runtime from './runtime/library';`, `import * as runtime from 'ts:runtime/library';`).replaceAll(`export type`, `type`)}
}
export {}`;
register(monaco, prisma_text, `ts:prisma.d.ts`);
register(monaco, `\
declare module "ts:prisma_ext" {
${p.prisma_ext}
}`, "ts:prisma_ext");
}
const api_types = prasi_api.apiTypes;
if (api_types) register(monaco, api_types, "ts:api.d.ts");
}
}
monaco.languages.typescript.typescriptDefaults.setExtraLibs([
{
filePath: "csstype.d.ts",
content: `declare module "csstype" {
${await loadText("https://cdn.jsdelivr.net/npm/csstype@3.1.3/index.d.ts")}
}`
},
{
filePath: "prop-types.d.ts",
content: `declare module "prop-types" {
${await loadText("https://cdn.jsdelivr.net/npm/@types/prop-types@15.7.12/index.d.ts")}
}`
},
{
filePath: "react.d.ts",
content: `
${await loadText("https://cdn.jsdelivr.net/npm/@types/react@18.3.3/index.d.ts")}
`
},
{
filePath: "jsx-runtime.d.ts",
content: `declare module "react/jsx-runtime" {
import * as React from "./";
export { Fragment } from "./";
export namespace JSX {
type ElementType = React.JSX.ElementType;
}
/**
* Create a React element.
*
* You should not use this function directly. Use JSX and a transpiler instead.
*/
export function jsx(
type: React.ElementType,
props: unknown,
key?: React.Key,
): React.ReactElement;
/**
* Create a React element.
*
* You should not use this function directly. Use JSX and a transpiler instead.
*/
export function jsxs(
type: React.ElementType,
props: unknown,
key?: React.Key,
): React.ReactElement;
`
}
]);
const propText = (0, _prop.extractProp)({
values: prop.values,
types: {
...prop.types,
...p.script.siteTypes
}
});
const apiTypes = (0, _general.w).prasiApi[p.site.api_url] ? (0, _general.w).prasiApi[p.site.api_url].apiTypes : "";
let apiPath = "app/gen/srv/api/srv";
if (apiTypes && apiTypes.includes(`export * as srv from "gen/srv/api/srv"`)) apiPath = "gen/srv/api/srv";
register(monaco, `\
import { PrismaExtend } from "ts:prisma_ext"
${iftext(apiTypes, `\
import "./api"
import type * as SRVAPI from "${apiPath}";`)}
declare global {
const db: PrismaClient & PrismaExtend;
${(0, _base.baseTypings)}
${iftext(apiTypes, `
type Api = typeof SRVAPI;
type ApiName = keyof Api;
const api: { [k in ApiName]: Awaited<Api[k]["handler"]>["_"]["api"] } & { _raw: any };
`)}
}
`, "ts:prasi-global.d.ts");
register(monaco, propText.join("\n"), "ts:typings.d.ts");
};
const loadText = async (url)=>{
try {
const res = await fetch(url);
return await res.text();
} catch (e) {
return "";
}
};
const iftext = (condition, text)=>{
if (condition) return text;
return "";
};
const register = (monaco, source, uri)=>{
const model = monaco.editor.getModels().find((e)=>{
return e.uri.toString() === uri;
});
if (model) model.setValue(source);
else monaco.editor.createModel(source, "typescript", monaco.Uri.parse(uri));
};
},{"../types/general":"58I9D","./types/base":"h5A8c","./types/prop":"kOkKO","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"h5A8c":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "baseTypings", ()=>baseTypings);
const baseTypings = `
type FC<T> = React.FC<T>;
const Fragment: typeof React.Fragment;
const ReactNode: typeo React.ReactNode;
const useCallback: typeof React.useCallback;
const useMemo: typeof React.useMemo;
const ReactElement: typeof React.ReactElement;
const isValidElement: typeof React.isValidElement;
const useEffect: typeof React.useEffect;
const useState: typeof React.useState;
const prasi_internal: {
page: { id: string };
};
const pathname: string;
const isEditor: boolean;
const isLayout: boolean;
const isMobile: boolean;
const isDesktop: boolean;
const __props: any;
const siteurl: (path:string) => string;
const preloaded: (url:string) => boolean;
const preload: (urls: string | string[], opt?: {
on_load?: (
pages: {
id: string;
url: string;
root: IRoot;
}[],
walk: (
root: { root: IRoot }[],
visit: (item: IContent) => void | Promise<void>
) => void
) => void;}) => ReactNode;
const navigate: (url: string,
params?: {
name?: string;
where?: any;
create?: any;
update?: any;
breads?: { label: string; url?: string }[];
}
) => void;
const params: any;
const cx: (...classNames: any[]) => string;
const css: (
tag: TemplateStringsArray | string,
...props: Array<string | number | boolean | undefined | null>
) => string;
const props: {
className: string;
onPointerDown?: () => void;
onPointerMove?: () => void;
onPointerLeave?: () => void;
inherit?: {
style: any,
className: string
}
};
const children: ReactElement;
type IItem = {
id: string;
name: string;
type: "item" | "text";
adv?: {
js?: string;
jsBuilt?: string;
css?: string;
html?: string;
};
text?: string;
html?: string;
component?: {
id: string;
props: Record<
string,
{ type: "string" | "raw"; value: string; valueBuilt?: string }
>;
};
childs: IItem[];
};
type SingleChange =
| { type: "set"; name: string; value: any }
| ({ type: "prop"; name: string } & PropVal)
| { type: "child"; childs: SimpleItem[] };
export type PropVal =
| { mode: "string"; value: string }
| { mode: "raw"; value: string; valueBuilt?: string }
| { mode: "jsx"; value: null | (IItem & PrasiEdit) | SimpleItem };
type ParentArg = {
item: IItem & PrasiEdit;
child_type: "jsx" | "child";
child_idx: number;
};
type SimpleItem = Partial<Omit<IItem, "component">> & {
component?: { id: string; props: Record<string, PropVal> };
};
type PrasiEdit = {
edit: {
setValue: <T extends keyof IItem>(name: T, value: IItem[T]) => void;
setProp: (name: string, value: PropVal | string) => void;
pending: SingleChange[];
childs: (IItem & PrasiEdit)[];
setChilds: (childs: ((IItem & PrasiEdit) | SimpleItem)[]) => void;
readonly parent: null | ParentArg;
commit: () => Promise<void>;
readonly props?: Record<string, PropVal>;
};
};
type PrasiItem = IItem & PrasiEdit;
const _item: PrasiItem;
const _metas: Record<string, any>;
const _meta: {
item: any;
mitem?: any;
parent?: {
id: string;
instance_id?: string;
comp_id?: string;
};
instances?: Record<string, Record<string, string>>;
jsx_prop?: {
name: string;
comp_id: string;
is_root: boolean;
child?: {
prop_id: string;
comp_id: string;
};
};
editor_props?: any;
script?: {
scope?: any;
result: any;
Local: any;
PassProp: any;
};
render?: () => void;
};
const PassProp: (arg:Record<string, any> & { children: ReactNode }>) => ReactElement;
const mobile: {
notif: {
register: (user_id: string) => void;
send: (data: {
user_id: string;
title: string;
body: string;
data: any;
}) => void;
onTap: (
data: null | {
user_id: string;
title: string;
body: string;
data: any;
}
) => void | Promise<void>;
onReceive: (data: {
user_id: string;
title: string;
body: string;
data: any;
}) => void | Promise<void>;
};
};
const Local: <T extends Record<string, any>>(arg: {
name: string;
idx?: any;
value: T;
children?: any;
deps?: any[];
effect?: (
local: T & { render: () => void }
) => void | (() => void) | Promise<void | (() => void)>;
hook?: (
local: T & { render: () => void }
) => void | (() => void) | Promise<void | (() => void)>;
cache?: boolean;
}) => ReactElement
`;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"kOkKO":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "extractProp", ()=>extractProp);
var _lodashTrim = require("lodash.trim");
var _lodashTrimDefault = parcelHelpers.interopDefault(_lodashTrim);
var _react = require("react");
const extractProp = (prop)=>{
const propTypes = [];
const props = {};
if (prop) {
if (prop.values) for (const [k, v] of Object.entries(prop.values)){
if (!props[k]) props[k] = {};
if (typeof v === "function") {
if (isFunctionalComponent(v)) props[k].type = "React.FC";
else if (isClassComponent(v)) props[k].type = "React.Component";
else props[k].type = "any";
} else if (v) {
if (typeof v === "object" && v._jsx) props[k].type = "React.ReactElement;";
else if (!!v.render && typeof v.$$typeof === "symbol") props[k].type = "React.FC<Record<string,any> & {ref?:any}>";
else props[k].val = v;
}
}
}
if (prop.types) for (const [k, v] of Object.entries(prop.types)){
if (!props[k]) props[k] = {};
props[k].type = v;
}
for (const [k, v] of Object.entries(props)){
if (v.type) {
if (k.startsWith("_raw")) propTypes.push(v.type);
else {
let const_or_type = "const";
let str = v.type;
if (v.type.startsWith("type:")) {
str = v.type.substring(5);
const_or_type = "type";
}
propTypes.push(`${const_or_type} ${k}: ${(0, _lodashTrimDefault.default)(str, "; \n")};`);
}
} else if (v.val) {
if (typeof v.val === "object" && /*#__PURE__*/ (0, _react.isValidElement)(v.val)) propTypes.push(`const ${k}: ReactElement;`);
else try {
let val = v.val;
if (typeof val === "object") {
if (typeof val.render === "function") val = {
...val,
render: ()=>{}
};
propTypes.push(`const ${k}: ${recurseTypes(val)};`);
} else propTypes.push(`const ${k}: string;`);
} catch (e) {}
}
}
return propTypes;
};
function recurseTypes(object) {
const result = [];
if (typeof object === "object") {
if (object === null) return "null";
if (Array.isArray(object)) return `any[]`;
for (const [k, v] of Object.entries(object))result.push(`${k}: ${typeof v === "object" && v ? recurseTypes(v) : typeof v}`);
return `{
${result.join(";\n ")}
}`;
}
return typeof object;
}
function isFunctionalComponent(Component) {
return typeof Component === "function" && // can be various things
!(Component.prototype && // native arrows don't have prototypes
Component.prototype.isReactComponent // special property
);
}
function isClassComponent(Component) {
return !!(typeof Component === "function" && Component.prototype && Component.prototype.isReactComponent);
}
},{"lodash.trim":"dnpK3","react":"ftK02","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"g3FdK":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "clientStartSync", ()=>clientStartSync);
var _deepProxy = require("@qiwi/deep-proxy");
var _hashWasm = require("hash-wasm");
var _idbKeyval = require("idb-keyval");
var _msgpackr = require("msgpackr");
var _safeStableStringify = require("safe-stable-stringify");
var _actionsDef = require("../../../../srv/ws/sync/actions-def");
var _type = require("../../../../srv/ws/sync/type");
var _general = require("../types/general");
var _idb = require("./idb");
var Buffer = require("e2d22eba78b6ebea").Buffer;
const packr = new (0, _msgpackr.Packr)({
structuredClone: true
});
/** CONSTANT */ const WS_CONFIG = {
debug: !!localStorage.getItem("prasi-ws-debug"),
reconnectTimeout: 1000
};
(0, _general.w).debug = new Proxy({}, {
get (target, p, receiver) {
if (p === "off") {
WS_CONFIG.debug = false;
localStorage.removeItem("prasi-js-debug");
localStorage.removeItem("prasi-ws-debug");
console.clear();
return [
"WS DEBUG: Deactivated"
];
}
if (p === "on") {
WS_CONFIG.debug = true;
localStorage.setItem("prasi-ws-debug", "1");
console.clear();
return [
"WS DEBUG: Activated"
];
}
if (p === "js") {
localStorage.setItem("prasi-js-debug", "1");
console.clear();
return [
"JS DEBUG: Activated"
];
}
}
});
const conf = {
ws: null,
client_id: "",
idb: null,
event: null
};
const runtime = {
action: {
done: [],
pending: {}
}
};
const sendWs = (ws, msg)=>{
const raw = packr.pack(msg);
if (WS_CONFIG.debug) console.log(`%c\u{2B06}`, "color:blue", formatBytes(raw.length, 0), msg);
ws.send(raw);
};
const clientStartSync = async (arg)=>{
const { user_id, site_id, page_id, events } = arg;
conf.idb = (0, _idb.initIDB)(user_id);
await connect({
user_id,
site_id,
page_id
}, events);
return new (0, _deepProxy.DeepProxy)((0, _actionsDef.SyncActionDefinition), ({ target, trapName, value, key, DEFAULT, PROXY })=>{
if (trapName === "set") throw new TypeError("target is immutable");
if (typeof value === "string") return (...args)=>{
return new Promise((resolve)=>{
doAction({
code: value,
resolve,
args
});
});
};
if (trapName === "get") {
if (typeof value === "object" && value !== null) return PROXY;
}
return DEFAULT;
});
};
const connect = (opt, event)=>{
const { user_id, page_id, site_id } = opt;
conf.event = event;
if ((0, _general.w).offline) return new Promise(async (resolve)=>{
resolve();
const eventName = "editor_start";
const data = await loadEventOffline(eventName);
if (event[eventName]) event[eventName](data);
});
else return new Promise((resolve, reject)=>{
if (!conf.ws) {
const retry = ()=>{
const url = new URL((0, _general.w).basehost || location.href);
url.pathname = "/sync";
url.protocol = url.protocol === "http:" ? "ws:" : "wss:";
const ws = new WebSocket(`${url.protocol}//${url.host}${url.pathname}`);
let timeout = setTimeout(()=>{
clearTimeout(timeout);
ws.close();
retry();
}, 2000);
ws.onopen = ()=>{
clearTimeout(timeout);
(0, _general.w).offline = false;
(0, _general.w).editorRender?.();
sendWs(ws, {
type: (0, _type.SyncType).UserID,
user_id,
site_id,
page_id
});
conf.ws = ws;
event.opened();
};
ws.onmessage = async (e)=>{
const raw = e.data;
const msg = packr.unpack(Buffer.from(await raw.arrayBuffer()));
if (WS_CONFIG.debug) console.log(`%c\u{2B07}`, `color:red`, formatBytes(raw.size, 0), msg);
if (msg.type === (0, _type.SyncType).ClientID) {
conf.client_id = msg.client_id;
event.shakehand(msg.client_id);
resolve();
} else if (msg.type === (0, _type.SyncType).Event) {
const eventName = msg.event;
if (event[eventName]) {
if (offlineEvents.includes(eventName)) saveEventOffline(eventName, msg.data);
event[eventName](msg.data);
}
} else if (msg.type === (0, _type.SyncType).ActionResult) {
const pending = runtime.action.pending[msg.argid];
if (pending) {
pending.resolves.map((e)=>e(msg.val));
clearTimeout(pending.timeout);
delete runtime.action.pending[msg.argid];
const idb = conf.idb;
if (idb) await (0, _idbKeyval.set)(msg.argid, msg.val, idb);
}
}
};
};
retry();
}
});
};
const offlineEvents = [
"editor_start"
];
const saveEventOffline = async (name, data)=>{
const idb = conf.idb;
if (idb) {
const hargs = await (0, _hashWasm.xxhash32)(`ev-${name}`);
await (0, _idbKeyval.set)(hargs, data, idb);
}
};
const loadEventOffline = async (name)=>{
const idb = conf.idb;
if (idb) {
const hargs = await (0, _hashWasm.xxhash32)(`ev-${name}`);
return await (0, _idbKeyval.get)(hargs, idb);
}
};
const doAction = async (arg)=>{
const { args, code, resolve } = arg;
const ws = conf.ws;
const idb = conf.idb;
if (idb) {
const sargs = (0, _safeStableStringify.stringify)(args);
const path = (0, _actionsDef.SyncActionPaths)[code];
const argid = await (0, _hashWasm.xxhash32)(`op-${path}-${sargs}`);
if (runtime.action.pending[argid]) {
runtime.action.pending[argid].resolves.push(resolve);
return;
}
if (runtime.action.done.includes(argid)) {
resolve(undefined);
return;
}
if (ws && ws.readyState === ws.OPEN) {
runtime.action.done.push(argid);
while(runtime.action.done.length > 50)runtime.action.done.shift();
// online
runtime.action.pending[argid] = {
ts: Date.now(),
resolves: [
resolve
],
timeout: path.startsWith("yjs.") ? setTimeout(()=>{
console.error(`Sync too long: `, {
type: (0, _type.SyncType).Action,
code,
args,
argid
});
(0, _general.w).sync_too_long = true;
}, 10000) : undefined
};
sendWs(ws, {
type: (0, _type.SyncType).Action,
code,
args,
argid
});
} else {
// offline
const cache = await (0, _idbKeyval.get)(argid, idb);
resolve(cache);
}
}
};
function formatBytes(bytes, decimals) {
if (bytes == 0) return "0 Bytes";
var k = 1024, dm = decimals || 2, sizes = [
"Bytes",
"KB",
"MB",
"GB",
"TB",
"PB",
"EB",
"ZB",
"YB"
], i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
}
},{"e2d22eba78b6ebea":"bwHdc","@qiwi/deep-proxy":"b3vlY","hash-wasm":"6sNkF","idb-keyval":"in1MU","msgpackr":"g4H5L","safe-stable-stringify":"I0WvA","../../../../srv/ws/sync/actions-def":"azubS","../../../../srv/ws/sync/type":"cC357","../types/general":"58I9D","./idb":"iOtgT","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"b3vlY":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "DEFAULT", ()=>o);
parcelHelpers.export(exports, "DeepProxy", ()=>y);
parcelHelpers.export(exports, "createDeepProxy", ()=>f);
parcelHelpers.export(exports, "defaultProxyHandler", ()=>l);
function e() {
return e = Object.assign || function(e) {
for(var t = 1; t < arguments.length; t++){
var r = arguments[t];
for(var a in r)Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
}
return e;
}, e.apply(this, arguments);
}
var t = {
proxies: new WeakMap,
traps: new WeakMap
}, r = function(e, t, r) {
return e.get(t) || e.set(t, new r).get(t);
}, a = function(e) {
return e.join();
}, n = function(e, r, n) {
var o, p;
return t.proxies.get(null == (o = t.traps.get(e)) || null == (p = o.get(r)) ? void 0 : p.get(a(n)));
}, o = Symbol("default"), p = Object.keys(Object.getOwnPropertyDescriptors(Reflect)), s = [
"get",
"has",
"set",
"defineProperty",
"deleteProperty",
"getOwnPropertyDescriptor"
], c = function(e, t) {
var r = e.trapName, a = e.handler, p = e.traps, c = e.root, i = e.path, u = function(e, t) {
var r, a, n, o, p, s, c, i;
switch(e){
case "get":
r = t[0], a = t[1], o = t[2];
break;
case "set":
r = t[0], a = t[1], n = t[2], o = t[3];
break;
case "deleteProperty":
case "defineProperty":
r = t[0], s = t[1];
break;
case "has":
case "getOwnPropertyDescriptor":
r = t[0], a = t[1];
break;
case "apply":
r = t[0], c = t[1], p = t[2];
break;
case "construct":
r = t[0], p = t[1];
break;
case "setPrototypeOf":
r = t[0], i = t[1];
break;
default:
r = t[0];
}
return {
target: r,
name: a,
receiver: o,
val: n,
args: p,
descriptor: s,
thisValue: c,
prototype: i
};
}(r, t), l = u.target, y = u.name, d = u.val, h = u.receiver, g = u.args, v = u.descriptor, b = u.thisValue, k = u.prototype, w = s.includes(r) ? y : void 0;
return {
parameters: t,
target: l,
name: y,
val: d,
args: g,
descriptor: v,
receiver: h,
thisValue: b,
prototype: k,
trapName: r,
traps: p,
path: i,
handler: a,
key: w,
newValue: "set" === r ? d : void 0,
root: c,
get proxy () {
return n(c, l, i);
},
get value () {
return w && l[w];
},
DEFAULT: o,
PROXY: f.bind({
root: c,
handler: a,
path: [].concat(i, [
w
])
})
};
}, i = function() {
var e = [].slice.call(arguments), t = this.trapName, r = this.handler, a = c(this, e), n = a.PROXY, o = a.DEFAULT, p = r(a);
return p === n ? n(a.value) : p === o ? Reflect[t].apply(Reflect, e) : p;
}, u = function(e, t, r) {
return p.reduce(function(a, n) {
return a[n] = i.bind({
trapName: n,
handler: e,
traps: a,
root: t,
path: r
}), a;
}, {});
}, l = function(e) {
return e.DEFAULT;
}, f = function(o, p, s, c) {
!function(e) {
if (null === e || "object" != typeof e && "function" != typeof e) throw new TypeError("Deep proxy could be applied to objects and functions only");
}(o);
var i = e({}, this), f = p || i.handler || l, y = s || i.path || [], d = i.root || c || o, h = n(d, o, y);
if (h) return h;
var g = u(f, d, y), v = new Proxy(o, g);
return function(e, n, o, p, s) {
r(r(t.traps, e, WeakMap), n, Map).set(a(o), p), t.proxies.set(p, s);
}(d, o, y, g, v), v;
}, y = function(e, t, r, a) {
return f(e, t, r, a);
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"6sNkF":[function(require,module,exports) {
/*!
* hash-wasm (https://www.npmjs.com/package/hash-wasm)
* (c) Dani Biro
* @license MIT
*/ /******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol */ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "adler32", ()=>adler32);
parcelHelpers.export(exports, "argon2Verify", ()=>argon2Verify);
parcelHelpers.export(exports, "argon2d", ()=>argon2d);
parcelHelpers.export(exports, "argon2i", ()=>argon2i);
parcelHelpers.export(exports, "argon2id", ()=>argon2id);
parcelHelpers.export(exports, "bcrypt", ()=>bcrypt);
parcelHelpers.export(exports, "bcryptVerify", ()=>bcryptVerify);
parcelHelpers.export(exports, "blake2b", ()=>blake2b);
parcelHelpers.export(exports, "blake2s", ()=>blake2s);
parcelHelpers.export(exports, "blake3", ()=>blake3);
parcelHelpers.export(exports, "crc32", ()=>crc32);
parcelHelpers.export(exports, "crc32c", ()=>crc32c);
parcelHelpers.export(exports, "createAdler32", ()=>createAdler32);
parcelHelpers.export(exports, "createBLAKE2b", ()=>createBLAKE2b);
parcelHelpers.export(exports, "createBLAKE2s", ()=>createBLAKE2s);
parcelHelpers.export(exports, "createBLAKE3", ()=>createBLAKE3);
parcelHelpers.export(exports, "createCRC32", ()=>createCRC32);
parcelHelpers.export(exports, "createCRC32C", ()=>createCRC32C);
parcelHelpers.export(exports, "createHMAC", ()=>createHMAC);
parcelHelpers.export(exports, "createKeccak", ()=>createKeccak);
parcelHelpers.export(exports, "createMD4", ()=>createMD4);
parcelHelpers.export(exports, "createMD5", ()=>createMD5);
parcelHelpers.export(exports, "createRIPEMD160", ()=>createRIPEMD160);
parcelHelpers.export(exports, "createSHA1", ()=>createSHA1);
parcelHelpers.export(exports, "createSHA224", ()=>createSHA224);
parcelHelpers.export(exports, "createSHA256", ()=>createSHA256);
parcelHelpers.export(exports, "createSHA3", ()=>createSHA3);
parcelHelpers.export(exports, "createSHA384", ()=>createSHA384);
parcelHelpers.export(exports, "createSHA512", ()=>createSHA512);
parcelHelpers.export(exports, "createSM3", ()=>createSM3);
parcelHelpers.export(exports, "createWhirlpool", ()=>createWhirlpool);
parcelHelpers.export(exports, "createXXHash128", ()=>createXXHash128);
parcelHelpers.export(exports, "createXXHash3", ()=>createXXHash3);
parcelHelpers.export(exports, "createXXHash32", ()=>createXXHash32);
parcelHelpers.export(exports, "createXXHash64", ()=>createXXHash64);
parcelHelpers.export(exports, "keccak", ()=>keccak);
parcelHelpers.export(exports, "md4", ()=>md4);
parcelHelpers.export(exports, "md5", ()=>md5);
parcelHelpers.export(exports, "pbkdf2", ()=>pbkdf2);
parcelHelpers.export(exports, "ripemd160", ()=>ripemd160);
parcelHelpers.export(exports, "scrypt", ()=>scrypt);
parcelHelpers.export(exports, "sha1", ()=>sha1);
parcelHelpers.export(exports, "sha224", ()=>sha224);
parcelHelpers.export(exports, "sha256", ()=>sha256);
parcelHelpers.export(exports, "sha3", ()=>sha3);
parcelHelpers.export(exports, "sha384", ()=>sha384);
parcelHelpers.export(exports, "sha512", ()=>sha512);
parcelHelpers.export(exports, "sm3", ()=>sm3);
parcelHelpers.export(exports, "whirlpool", ()=>whirlpool);
parcelHelpers.export(exports, "xxhash128", ()=>xxhash128);
parcelHelpers.export(exports, "xxhash3", ()=>xxhash3);
parcelHelpers.export(exports, "xxhash32", ()=>xxhash32);
parcelHelpers.export(exports, "xxhash64", ()=>xxhash64);
var global = arguments[3];
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
typeof SuppressedError === "function" && SuppressedError;
class Mutex {
constructor(){
this.mutex = Promise.resolve();
}
lock() {
let begin = ()=>{};
this.mutex = this.mutex.then(()=>new Promise(begin));
return new Promise((res)=>{
begin = res;
});
}
dispatch(fn) {
return __awaiter(this, void 0, void 0, function*() {
const unlock = yield this.lock();
try {
return yield Promise.resolve(fn());
} finally{
unlock();
}
});
}
}
/* eslint-disable import/prefer-default-export */ /* eslint-disable no-bitwise */ var _a;
function getGlobal() {
if (typeof globalThis !== "undefined") return globalThis;
// eslint-disable-next-line no-restricted-globals
if (typeof self !== "undefined") return self;
if (typeof window !== "undefined") return window;
return global;
}
const globalObject = getGlobal();
const nodeBuffer = (_a = globalObject.Buffer) !== null && _a !== void 0 ? _a : null;
const textEncoder = globalObject.TextEncoder ? new globalObject.TextEncoder() : null;
function intArrayToString(arr, len) {
return String.fromCharCode(...arr.subarray(0, len));
}
function hexCharCodesToInt(a, b) {
return (a & 0xF) + (a >> 6 | a >> 3 & 0x8) << 4 | (b & 0xF) + (b >> 6 | b >> 3 & 0x8);
}
function writeHexToUInt8(buf, str) {
const size = str.length >> 1;
for(let i = 0; i < size; i++){
const index = i << 1;
buf[i] = hexCharCodesToInt(str.charCodeAt(index), str.charCodeAt(index + 1));
}
}
function hexStringEqualsUInt8(str, buf) {
if (str.length !== buf.length * 2) return false;
for(let i = 0; i < buf.length; i++){
const strIndex = i << 1;
if (buf[i] !== hexCharCodesToInt(str.charCodeAt(strIndex), str.charCodeAt(strIndex + 1))) return false;
}
return true;
}
const alpha = "a".charCodeAt(0) - 10;
const digit = "0".charCodeAt(0);
function getDigestHex(tmpBuffer, input, hashLength) {
let p = 0;
/* eslint-disable no-plusplus */ for(let i = 0; i < hashLength; i++){
let nibble = input[i] >>> 4;
tmpBuffer[p++] = nibble > 9 ? nibble + alpha : nibble + digit;
nibble = input[i] & 0xF;
tmpBuffer[p++] = nibble > 9 ? nibble + alpha : nibble + digit;
}
/* eslint-enable no-plusplus */ return String.fromCharCode.apply(null, tmpBuffer);
}
const getUInt8Buffer = nodeBuffer !== null ? (data)=>{
if (typeof data === "string") {
const buf = nodeBuffer.from(data, "utf8");
return new Uint8Array(buf.buffer, buf.byteOffset, buf.length);
}
if (nodeBuffer.isBuffer(data)) return new Uint8Array(data.buffer, data.byteOffset, data.length);
if (ArrayBuffer.isView(data)) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
throw new Error("Invalid data type!");
} : (data)=>{
if (typeof data === "string") return textEncoder.encode(data);
if (ArrayBuffer.isView(data)) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
throw new Error("Invalid data type!");
};
const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const base64Lookup = new Uint8Array(256);
for(let i = 0; i < base64Chars.length; i++)base64Lookup[base64Chars.charCodeAt(i)] = i;
function encodeBase64(data, pad = true) {
const len = data.length;
const extraBytes = len % 3;
const parts = [];
const len2 = len - extraBytes;
for(let i = 0; i < len2; i += 3){
const tmp = (data[i] << 16 & 0xFF0000) + (data[i + 1] << 8 & 0xFF00) + (data[i + 2] & 0xFF);
const triplet = base64Chars.charAt(tmp >> 18 & 0x3F) + base64Chars.charAt(tmp >> 12 & 0x3F) + base64Chars.charAt(tmp >> 6 & 0x3F) + base64Chars.charAt(tmp & 0x3F);
parts.push(triplet);
}
if (extraBytes === 1) {
const tmp = data[len - 1];
const a = base64Chars.charAt(tmp >> 2);
const b = base64Chars.charAt(tmp << 4 & 0x3F);
parts.push(`${a}${b}`);
if (pad) parts.push("==");
} else if (extraBytes === 2) {
const tmp = (data[len - 2] << 8) + data[len - 1];
const a = base64Chars.charAt(tmp >> 10);
const b = base64Chars.charAt(tmp >> 4 & 0x3F);
const c = base64Chars.charAt(tmp << 2 & 0x3F);
parts.push(`${a}${b}${c}`);
if (pad) parts.push("=");
}
return parts.join("");
}
function getDecodeBase64Length(data) {
let bufferLength = Math.floor(data.length * 0.75);
const len = data.length;
if (data[len - 1] === "=") {
bufferLength -= 1;
if (data[len - 2] === "=") bufferLength -= 1;
}
return bufferLength;
}
function decodeBase64(data) {
const bufferLength = getDecodeBase64Length(data);
const len = data.length;
const bytes = new Uint8Array(bufferLength);
let p = 0;
for(let i = 0; i < len; i += 4){
const encoded1 = base64Lookup[data.charCodeAt(i)];
const encoded2 = base64Lookup[data.charCodeAt(i + 1)];
const encoded3 = base64Lookup[data.charCodeAt(i + 2)];
const encoded4 = base64Lookup[data.charCodeAt(i + 3)];
bytes[p] = encoded1 << 2 | encoded2 >> 4;
p += 1;
bytes[p] = (encoded2 & 15) << 4 | encoded3 >> 2;
p += 1;
bytes[p] = (encoded3 & 3) << 6 | encoded4 & 63;
p += 1;
}
return bytes;
}
const MAX_HEAP = 16384;
const WASM_FUNC_HASH_LENGTH = 4;
const wasmMutex = new Mutex();
const wasmModuleCache = new Map();
function WASMInterface(binary, hashLength) {
return __awaiter(this, void 0, void 0, function*() {
let wasmInstance = null;
let memoryView = null;
let initialized = false;
if (typeof WebAssembly === "undefined") throw new Error("WebAssembly is not supported in this environment!");
const writeMemory = (data, offset = 0)=>{
memoryView.set(data, offset);
};
const getMemory = ()=>memoryView;
const getExports = ()=>wasmInstance.exports;
const setMemorySize = (totalSize)=>{
wasmInstance.exports.Hash_SetMemorySize(totalSize);
const arrayOffset = wasmInstance.exports.Hash_GetBuffer();
const memoryBuffer = wasmInstance.exports.memory.buffer;
memoryView = new Uint8Array(memoryBuffer, arrayOffset, totalSize);
};
const getStateSize = ()=>{
const view = new DataView(wasmInstance.exports.memory.buffer);
const stateSize = view.getUint32(wasmInstance.exports.STATE_SIZE, true);
return stateSize;
};
const loadWASMPromise = wasmMutex.dispatch(()=>__awaiter(this, void 0, void 0, function*() {
if (!wasmModuleCache.has(binary.name)) {
const asm = decodeBase64(binary.data);
const promise = WebAssembly.compile(asm);
wasmModuleCache.set(binary.name, promise);
}
const module = yield wasmModuleCache.get(binary.name);
wasmInstance = yield WebAssembly.instantiate(module, {
});
// wasmInstance.exports._start();
}));
const setupInterface = ()=>__awaiter(this, void 0, void 0, function*() {
if (!wasmInstance) yield loadWASMPromise;
const arrayOffset = wasmInstance.exports.Hash_GetBuffer();
const memoryBuffer = wasmInstance.exports.memory.buffer;
memoryView = new Uint8Array(memoryBuffer, arrayOffset, MAX_HEAP);
});
const init = (bits = null)=>{
initialized = true;
wasmInstance.exports.Hash_Init(bits);
};
const updateUInt8Array = (data)=>{
let read = 0;
while(read < data.length){
const chunk = data.subarray(read, read + MAX_HEAP);
read += chunk.length;
memoryView.set(chunk);
wasmInstance.exports.Hash_Update(chunk.length);
}
};
const update = (data)=>{
if (!initialized) throw new Error("update() called before init()");
const Uint8Buffer = getUInt8Buffer(data);
updateUInt8Array(Uint8Buffer);
};
const digestChars = new Uint8Array(hashLength * 2);
const digest = (outputType, padding = null)=>{
if (!initialized) throw new Error("digest() called before init()");
initialized = false;
wasmInstance.exports.Hash_Final(padding);
if (outputType === "binary") // the data is copied to allow GC of the original memory object
return memoryView.slice(0, hashLength);
return getDigestHex(digestChars, memoryView, hashLength);
};
const save = ()=>{
if (!initialized) throw new Error("save() can only be called after init() and before digest()");
const stateOffset = wasmInstance.exports.Hash_GetState();
const stateLength = getStateSize();
const memoryBuffer = wasmInstance.exports.memory.buffer;
const internalState = new Uint8Array(memoryBuffer, stateOffset, stateLength);
// prefix is 4 bytes from SHA1 hash of the WASM binary
// it is used to detect incompatible internal states between different versions of hash-wasm
const prefixedState = new Uint8Array(WASM_FUNC_HASH_LENGTH + stateLength);
writeHexToUInt8(prefixedState, binary.hash);
prefixedState.set(internalState, WASM_FUNC_HASH_LENGTH);
return prefixedState;
};
const load = (state)=>{
if (!(state instanceof Uint8Array)) throw new Error("load() expects an Uint8Array generated by save()");
const stateOffset = wasmInstance.exports.Hash_GetState();
const stateLength = getStateSize();
const overallLength = WASM_FUNC_HASH_LENGTH + stateLength;
const memoryBuffer = wasmInstance.exports.memory.buffer;
if (state.length !== overallLength) throw new Error(`Bad state length (expected ${overallLength} bytes, got ${state.length})`);
if (!hexStringEqualsUInt8(binary.hash, state.subarray(0, WASM_FUNC_HASH_LENGTH))) throw new Error("This state was written by an incompatible hash implementation");
const internalState = state.subarray(WASM_FUNC_HASH_LENGTH);
new Uint8Array(memoryBuffer, stateOffset, stateLength).set(internalState);
initialized = true;
};
const isDataShort = (data)=>{
if (typeof data === "string") // worst case is 4 bytes / char
return data.length < MAX_HEAP / 4;
return data.byteLength < MAX_HEAP;
};
let canSimplify = isDataShort;
switch(binary.name){
case "argon2":
case "scrypt":
canSimplify = ()=>true;
break;
case "blake2b":
case "blake2s":
// if there is a key at blake2 then cannot simplify
canSimplify = (data, initParam)=>initParam <= 512 && isDataShort(data);
break;
case "blake3":
// if there is a key at blake3 then cannot simplify
canSimplify = (data, initParam)=>initParam === 0 && isDataShort(data);
break;
case "xxhash64":
case "xxhash3":
case "xxhash128":
canSimplify = ()=>false;
break;
}
// shorthand for (init + update + digest) for better performance
const calculate = (data, initParam = null, digestParam = null)=>{
if (!canSimplify(data, initParam)) {
init(initParam);
update(data);
return digest("hex", digestParam);
}
const buffer = getUInt8Buffer(data);
memoryView.set(buffer);
wasmInstance.exports.Hash_Calculate(buffer.length, initParam, digestParam);
return getDigestHex(digestChars, memoryView, hashLength);
};
yield setupInterface();
return {
getMemory,
writeMemory,
getExports,
setMemorySize,
init,
update,
digest,
save,
load,
calculate,
hashLength
};
});
}
var name$k = "adler32";
var data$k = "AGFzbQEAAAABDANgAAF/YAAAYAF/AAMHBgABAgEAAgUEAQECAgYOAn8BQYCJBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAQtIYXNoX1VwZGF0ZQACCkhhc2hfRmluYWwAAw1IYXNoX0dldFN0YXRlAAQOSGFzaF9DYWxjdWxhdGUABQpTVEFURV9TSVpFAwEK6wkGBQBBgAkLCgBBAEEBNgKECAvjCAEHf0EAKAKECCIBQf//A3EhAiABQRB2IQMCQAJAIABBAUcNACACQQAtAIAJaiIBQY+AfGogASABQfD/A0sbIgEgA2oiBEEQdCIFQYCAPGogBSAEQfD/A0sbIAFyIQEMAQsCQAJAAkACQAJAIABBEEkNAEGACSEGIABBsCtJDQFBgAkhBgNAQQAhBQNAIAYgBWoiASgCACIEQf8BcSACaiICIANqIAIgBEEI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2ohAyABQQFqIQEgBEF/aiIEDQALIAYgBWohBgsgB0EDSQ0AA0AgAiAGLQAAaiIBIAYtAAFqIgQgBi0AAmoiBSAGQQNqLQAAaiICIAUgBCABIANqampqIQMgBkEEaiEGIABBfGoiAA0ACwsgA0Hx/wNwIQMgAkHx/wNwIQILIAIgA0EQdHIhAQtBACABNgKECAsxAQF/QQBBACgChAgiAEEYdCAAQYD+A3FBCHRyIABBCHZBgP4DcSAAQRh2cnI2AoAJCwUAQYQICzsAQQBBATYChAggABACQQBBACgChAgiAEEYdCAAQYD+A3FBCHRyIABBCHZBgP4DcSAAQRh2cnI2AoAJCwsVAgBBgAgLBAQAAAAAQYQICwQBAAAA";
var hash$k = "02ddbd17";
var wasmJson$k = {
name: name$k,
data: data$k,
hash: hash$k
};
function lockedCreate(mutex, binary, hashLength) {
return __awaiter(this, void 0, void 0, function*() {
const unlock = yield mutex.lock();
const wasm = yield WASMInterface(binary, hashLength);
unlock();
return wasm;
});
}
const mutex$l = new Mutex();
let wasmCache$l = null;
/**
* Calculates Adler-32 hash. The resulting 32-bit hash is stored in
* network byte order (big-endian).
*
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function adler32(data) {
if (wasmCache$l === null) return lockedCreate(mutex$l, wasmJson$k, 4).then((wasm)=>{
wasmCache$l = wasm;
return wasmCache$l.calculate(data);
});
try {
const hash = wasmCache$l.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new Adler-32 hash instance
*/ function createAdler32() {
return WASMInterface(wasmJson$k, 4).then((wasm)=>{
wasm.init();
const obj = {
init: ()=>{
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 4,
digestSize: 4
};
return obj;
});
}
var name$j = "blake2b";
var data$j = "AGFzbQEAAAABEQRgAAF/YAJ/fwBgAX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AXE2AuSKAQJAIAFBAUgNACACQgA3A3ggAkIANwNwIAJCADcDaCACQgA3A2AgAkIANwNYIAJCADcDUCACQgA3A0ggAkIANwNAIAJCADcDOCACQgA3AzAgAkIANwMoIAJCADcDICACQgA3AxggAkIANwMQIAJCADcDCCACQgA3AwBBACEEA0AgAiAAaiAAQYAJai0AADoAACAAQQFqIQAgBEEBaiIEQf8BcSABSA0ACyACQYABEAELIAJBgAFqJAALEgAgAEEDdkH/P3EgAEEQdhAECwkAQYAJIAAQAQsGAEGAiQELGwAgAUEDdkH/P3EgAUEQdhAEQYAJIAAQARADCwsLAQBBgAgLBPAAAAA=";
var hash$j = "656e0f66";
var wasmJson$j = {
name: name$j,
data: data$j,
hash: hash$j
};
const mutex$k = new Mutex();
let wasmCache$k = null;
function validateBits$4(bits) {
if (!Number.isInteger(bits) || bits < 8 || bits > 512 || bits % 8 !== 0) return new Error("Invalid variant! Valid values: 8, 16, ..., 512");
return null;
}
function getInitParam$1(outputBits, keyBits) {
// eslint-disable-next-line no-bitwise
return outputBits | keyBits << 16;
}
/**
* Calculates BLAKE2b hash
* @param data Input data (string, Buffer or TypedArray)
* @param bits Number of output bits, which has to be a number
* divisible by 8, between 8 and 512. Defaults to 512.
* @param key Optional key (string, Buffer or TypedArray). Maximum length is 64 bytes.
* @returns Computed hash as a hexadecimal string
*/ function blake2b(data, bits = 512, key = null) {
if (validateBits$4(bits)) return Promise.reject(validateBits$4(bits));
let keyBuffer = null;
let initParam = bits;
if (key !== null) {
keyBuffer = getUInt8Buffer(key);
if (keyBuffer.length > 64) return Promise.reject(new Error("Max key length is 64 bytes"));
initParam = getInitParam$1(bits, keyBuffer.length);
}
const hashLength = bits / 8;
if (wasmCache$k === null || wasmCache$k.hashLength !== hashLength) return lockedCreate(mutex$k, wasmJson$j, hashLength).then((wasm)=>{
wasmCache$k = wasm;
if (initParam > 512) wasmCache$k.writeMemory(keyBuffer);
return wasmCache$k.calculate(data, initParam);
});
try {
if (initParam > 512) wasmCache$k.writeMemory(keyBuffer);
const hash = wasmCache$k.calculate(data, initParam);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new BLAKE2b hash instance
* @param bits Number of output bits, which has to be a number
* divisible by 8, between 8 and 512. Defaults to 512.
* @param key Optional key (string, Buffer or TypedArray). Maximum length is 64 bytes.
*/ function createBLAKE2b(bits = 512, key = null) {
if (validateBits$4(bits)) return Promise.reject(validateBits$4(bits));
let keyBuffer = null;
let initParam = bits;
if (key !== null) {
keyBuffer = getUInt8Buffer(key);
if (keyBuffer.length > 64) return Promise.reject(new Error("Max key length is 64 bytes"));
initParam = getInitParam$1(bits, keyBuffer.length);
}
const outputSize = bits / 8;
return WASMInterface(wasmJson$j, outputSize).then((wasm)=>{
if (initParam > 512) wasm.writeMemory(keyBuffer);
wasm.init(initParam);
const obj = {
init: initParam > 512 ? ()=>{
wasm.writeMemory(keyBuffer);
wasm.init(initParam);
return obj;
} : ()=>{
wasm.init(initParam);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 128,
digestSize: outputSize
};
return obj;
});
}
var name$i = "argon2";
var data$i = "AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvkyBVgBAn9BACEBAkBBACgCiAgiAiAARg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAg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EKQQAoAoAIIQILIAIgA0EKdGogAiAeaiACIAopAwAiH0IgiKcgBXAgHCAYGyIeIARsIAEgAUEAIBsgHq1RIh4bIgogHRsgGWogCiALaiARGyABRSAecmsiHSAXaq0gH0L/////D4MiHyAffkIgiCAdrX5CIIh9IAyCp2pBCnRqQQEQAyADQQFqIQMgCCABQQFqIgFHDQALCyAbQgF8IhsgDVINAAsgFEIBfCIUpyEBIBRCBFINAAsgEEIBfCIQIAdSDQALCyAJQQx0QYB4aiEZQQAoAoAIIQIgBUF/aiIKRQ0CDAELQQBCAzcDoBBBACAEQX9qrTcDkBBBgHghGQsgAiAZaiEdIAhBDHQhCEEAIR4DQCAIIB5BAWoiHmxBgHhqIQRBACEBA0AgHSABaiIDIAMpAwAgAiAEIAFqaikDAIU3AwAgA0EIaiIDIAMpAwAgAiAEIAFBCHJqaikDAIU3AwAgAUEIaiEDIAFBEGohASADQfgHSQ0ACyAeIApHDQALCyACIBlqIR1BeCEBA0AgAiABaiIDQQhqIB0gAWoiBEEIaikDADcDACADQRBqIARBEGopAwA3AwAgA0EYaiAEQRhqKQMANwMAIANBIGogBEEgaikDADcDACABQSBqIgFB+AdJDQALCws=";
var hash$i = "7ab14c91";
var wasmJson$i = {
name: name$i,
data: data$i,
hash: hash$i
};
function encodeResult(salt, options, res) {
const parameters = [
`m=${options.memorySize}`,
`t=${options.iterations}`,
`p=${options.parallelism}`
].join(",");
return `$argon2${options.hashType}$v=19$${parameters}$${encodeBase64(salt, false)}$${encodeBase64(res, false)}`;
}
const uint32View = new DataView(new ArrayBuffer(4));
function int32LE(x) {
uint32View.setInt32(0, x, true);
return new Uint8Array(uint32View.buffer);
}
function hashFunc(blake512, buf, len) {
return __awaiter(this, void 0, void 0, function*() {
if (len <= 64) {
const blake = yield createBLAKE2b(len * 8);
blake.update(int32LE(len));
blake.update(buf);
return blake.digest("binary");
}
const r = Math.ceil(len / 32) - 2;
const ret = new Uint8Array(len);
blake512.init();
blake512.update(int32LE(len));
blake512.update(buf);
let vp = blake512.digest("binary");
ret.set(vp.subarray(0, 32), 0);
for(let i = 1; i < r; i++){
blake512.init();
blake512.update(vp);
vp = blake512.digest("binary");
ret.set(vp.subarray(0, 32), i * 32);
}
const partialBytesNeeded = len - 32 * r;
let blakeSmall;
if (partialBytesNeeded === 64) {
blakeSmall = blake512;
blakeSmall.init();
} else blakeSmall = yield createBLAKE2b(partialBytesNeeded * 8);
blakeSmall.update(vp);
vp = blakeSmall.digest("binary");
ret.set(vp.subarray(0, partialBytesNeeded), r * 32);
return ret;
});
}
function getHashType(type) {
switch(type){
case "d":
return 0;
case "i":
return 1;
default:
return 2;
}
}
function argon2Internal(options) {
var _a;
return __awaiter(this, void 0, void 0, function*() {
const { parallelism, iterations, hashLength } = options;
const password = getUInt8Buffer(options.password);
const salt = getUInt8Buffer(options.salt);
const version = 0x13;
const hashType = getHashType(options.hashType);
const { memorySize } = options; // in KB
const secret = getUInt8Buffer((_a = options.secret) !== null && _a !== void 0 ? _a : "");
const [argon2Interface, blake512] = yield Promise.all([
WASMInterface(wasmJson$i, 1024),
createBLAKE2b(512)
]);
// last block is for storing the init vector
argon2Interface.setMemorySize(memorySize * 1024 + 1024);
const initVector = new Uint8Array(24);
const initVectorView = new DataView(initVector.buffer);
initVectorView.setInt32(0, parallelism, true);
initVectorView.setInt32(4, hashLength, true);
initVectorView.setInt32(8, memorySize, true);
initVectorView.setInt32(12, iterations, true);
initVectorView.setInt32(16, version, true);
initVectorView.setInt32(20, hashType, true);
argon2Interface.writeMemory(initVector, memorySize * 1024);
blake512.init();
blake512.update(initVector);
blake512.update(int32LE(password.length));
blake512.update(password);
blake512.update(int32LE(salt.length));
blake512.update(salt);
blake512.update(int32LE(secret.length));
blake512.update(secret);
blake512.update(int32LE(0)); // associatedData length + associatedData
const segments = Math.floor(memorySize / (parallelism * 4)); // length of each lane
const lanes = segments * 4;
const param = new Uint8Array(72);
const H0 = blake512.digest("binary");
param.set(H0);
for(let lane = 0; lane < parallelism; lane++){
param.set(int32LE(0), 64);
param.set(int32LE(lane), 68);
let position = lane * lanes;
let chunk = yield hashFunc(blake512, param, 1024);
argon2Interface.writeMemory(chunk, position * 1024);
position += 1;
param.set(int32LE(1), 64);
chunk = yield hashFunc(blake512, param, 1024);
argon2Interface.writeMemory(chunk, position * 1024);
}
const C = new Uint8Array(1024);
writeHexToUInt8(C, argon2Interface.calculate(new Uint8Array([]), memorySize));
const res = yield hashFunc(blake512, C, hashLength);
if (options.outputType === "hex") {
const digestChars = new Uint8Array(hashLength * 2);
return getDigestHex(digestChars, res, hashLength);
}
if (options.outputType === "encoded") return encodeResult(salt, options, res);
// return binary format
return res;
});
}
const validateOptions$3 = (options)=>{
var _a;
if (!options || typeof options !== "object") throw new Error("Invalid options parameter. It requires an object.");
if (!options.password) throw new Error("Password must be specified");
options.password = getUInt8Buffer(options.password);
if (options.password.length < 1) throw new Error("Password must be specified");
if (!options.salt) throw new Error("Salt must be specified");
options.salt = getUInt8Buffer(options.salt);
if (options.salt.length < 8) throw new Error("Salt should be at least 8 bytes long");
options.secret = getUInt8Buffer((_a = options.secret) !== null && _a !== void 0 ? _a : "");
if (!Number.isInteger(options.iterations) || options.iterations < 1) throw new Error("Iterations should be a positive number");
if (!Number.isInteger(options.parallelism) || options.parallelism < 1) throw new Error("Parallelism should be a positive number");
if (!Number.isInteger(options.hashLength) || options.hashLength < 4) throw new Error("Hash length should be at least 4 bytes.");
if (!Number.isInteger(options.memorySize)) throw new Error("Memory size should be specified.");
if (options.memorySize < 8 * options.parallelism) throw new Error("Memory size should be at least 8 * parallelism.");
if (options.outputType === undefined) options.outputType = "hex";
if (![
"hex",
"binary",
"encoded"
].includes(options.outputType)) throw new Error(`Insupported output type ${options.outputType}. Valid values: ['hex', 'binary', 'encoded']`);
};
/**
* Calculates hash using the argon2i password-hashing function
* @returns Computed hash
*/ function argon2i(options) {
return __awaiter(this, void 0, void 0, function*() {
validateOptions$3(options);
return argon2Internal(Object.assign(Object.assign({}, options), {
hashType: "i"
}));
});
}
/**
* Calculates hash using the argon2id password-hashing function
* @returns Computed hash
*/ function argon2id(options) {
return __awaiter(this, void 0, void 0, function*() {
validateOptions$3(options);
return argon2Internal(Object.assign(Object.assign({}, options), {
hashType: "id"
}));
});
}
/**
* Calculates hash using the argon2d password-hashing function
* @returns Computed hash
*/ function argon2d(options) {
return __awaiter(this, void 0, void 0, function*() {
validateOptions$3(options);
return argon2Internal(Object.assign(Object.assign({}, options), {
hashType: "d"
}));
});
}
const getHashParameters = (password, encoded, secret)=>{
const regex = /^\$argon2(id|i|d)\$v=([0-9]+)\$((?:[mtp]=[0-9]+,){2}[mtp]=[0-9]+)\$([A-Za-z0-9+/]+)\$([A-Za-z0-9+/]+)$/;
const match = encoded.match(regex);
if (!match) throw new Error("Invalid hash");
const [, hashType, version, parameters, salt, hash] = match;
if (version !== "19") throw new Error(`Unsupported version: ${version}`);
const parsedParameters = {};
const paramMap = {
m: "memorySize",
p: "parallelism",
t: "iterations"
};
parameters.split(",").forEach((x)=>{
const [n, v] = x.split("=");
parsedParameters[paramMap[n]] = parseInt(v, 10);
});
return Object.assign(Object.assign({}, parsedParameters), {
password,
secret,
hashType: hashType,
salt: decodeBase64(salt),
hashLength: getDecodeBase64Length(hash),
outputType: "encoded"
});
};
const validateVerifyOptions$1 = (options)=>{
if (!options || typeof options !== "object") throw new Error("Invalid options parameter. It requires an object.");
if (options.hash === undefined || typeof options.hash !== "string") throw new Error("Hash should be specified");
};
/**
* Verifies password using the argon2 password-hashing function
* @returns True if the encoded hash matches the password
*/ function argon2Verify(options) {
return __awaiter(this, void 0, void 0, function*() {
validateVerifyOptions$1(options);
const params = getHashParameters(options.password, options.hash, options.secret);
validateOptions$3(params);
const hashStart = options.hash.lastIndexOf("$") + 1;
const result = yield argon2Internal(params);
return result.substring(hashStart) === options.hash.substring(hashStart);
});
}
var name$h = "blake2s";
var data$h = "AGFzbQEAAAABEQRgAAF/YAJ/fwBgAX8AYAAAAwkIAAECAwICAAEFBAEBAgIGDgJ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AGokAAsJAEGACSAAEAELBgBBgIkBCw8AIAEQBEGACSAAEAEQAwsLCwEAQYAICwR8AAAA";
var hash$h = "c5c746d4";
var wasmJson$h = {
name: name$h,
data: data$h,
hash: hash$h
};
const mutex$j = new Mutex();
let wasmCache$j = null;
function validateBits$3(bits) {
if (!Number.isInteger(bits) || bits < 8 || bits > 256 || bits % 8 !== 0) return new Error("Invalid variant! Valid values: 8, 16, ..., 256");
return null;
}
function getInitParam(outputBits, keyBits) {
// eslint-disable-next-line no-bitwise
return outputBits | keyBits << 16;
}
/**
* Calculates BLAKE2s hash
* @param data Input data (string, Buffer or TypedArray)
* @param bits Number of output bits, which has to be a number
* divisible by 8, between 8 and 256. Defaults to 256.
* @param key Optional key (string, Buffer or TypedArray). Maximum length is 32 bytes.
* @returns Computed hash as a hexadecimal string
*/ function blake2s(data, bits = 256, key = null) {
if (validateBits$3(bits)) return Promise.reject(validateBits$3(bits));
let keyBuffer = null;
let initParam = bits;
if (key !== null) {
keyBuffer = getUInt8Buffer(key);
if (keyBuffer.length > 32) return Promise.reject(new Error("Max key length is 32 bytes"));
initParam = getInitParam(bits, keyBuffer.length);
}
const hashLength = bits / 8;
if (wasmCache$j === null || wasmCache$j.hashLength !== hashLength) return lockedCreate(mutex$j, wasmJson$h, hashLength).then((wasm)=>{
wasmCache$j = wasm;
if (initParam > 512) wasmCache$j.writeMemory(keyBuffer);
return wasmCache$j.calculate(data, initParam);
});
try {
if (initParam > 512) wasmCache$j.writeMemory(keyBuffer);
const hash = wasmCache$j.calculate(data, initParam);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new BLAKE2s hash instance
* @param bits Number of output bits, which has to be a number
* divisible by 8, between 8 and 256. Defaults to 256.
* @param key Optional key (string, Buffer or TypedArray). Maximum length is 32 bytes.
*/ function createBLAKE2s(bits = 256, key = null) {
if (validateBits$3(bits)) return Promise.reject(validateBits$3(bits));
let keyBuffer = null;
let initParam = bits;
if (key !== null) {
keyBuffer = getUInt8Buffer(key);
if (keyBuffer.length > 32) return Promise.reject(new Error("Max key length is 32 bytes"));
initParam = getInitParam(bits, keyBuffer.length);
}
const outputSize = bits / 8;
return WASMInterface(wasmJson$h, outputSize).then((wasm)=>{
if (initParam > 512) wasm.writeMemory(keyBuffer);
wasm.init(initParam);
const obj = {
init: initParam > 512 ? ()=>{
wasm.writeMemory(keyBuffer);
wasm.init(initParam);
return obj;
} : ()=>{
wasm.init(initParam);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 64,
digestSize: outputSize
};
return obj;
});
}
var name$g = "blake3";
var data$g = "AGFzbQEAAAABMQdgAAF/YAl/f39+f39/f38AYAZ/f39/fn8AYAF/AGADf39/AGABfgBgBX9/fn9/AX8DDg0AAQIDBAUGAwMDAwAEBQQBAQICBg4CfwFBgJgFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACUhhc2hfSW5pdAAIC0hhc2hfVXBkYXRlAAkKSGFzaF9GaW5hbAAKDUhhc2hfR2V0U3RhdGUACw5IYXNoX0NhbGN1bGF0ZQAMClNUQVRFX1NJWkUDAQqcWw0FAEGACQujAwQCfwF+AX8EfiMAQeAAayIJJAACQCABRQ0AIAcgBXIhCiAEQQBHrSELIAdBACACQQFGGyAGciAFciEMA0AgACgCACEHIAlBACkDgIkBNwMAIAlBACkDiIkBNwMIIAlBACkDkIkBNwMQIAlBACkDmIkBNwMYIAlBIGogCSAHQcAAIAMgDBACIAkgCSkDQCAJKQMghSINNwMAIAkgCSkDSCAJKQMohSIONwMIIAkgCSkDUCAJKQMwhSIPNwMQIAkgCSkDWCAJKQM4hSIQNwMYIAdBwABqIQcgAiEEAkADQCAFIQYCQAJAIARBf2oiBA4CAwABCyAKIQYLIAlBIGogCSAHQcAAIAMgBhACIAkgCSkDQCAJKQMghSINNwMAIAkgCSkDSC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kDMCENIAEpAzghDkEAKQPAiQEQBUEAQQAtAJCKASICQQFqOgCQigEgAkEFdCICQamKAWogCjcDACACQaGKAWogBDcDACACQZmKAWogBTcDACACQZGKAWogBjcDAEEAKQPAiQEgE0IBiHwQBUEAQQAtAJCKASICQQFqOgCQigEgAkEFdCICQamKAWogDjcDACACQaGKAWogDTcDACACQZmKAWogDDcDACACQZGKAWogBzcDAAtBAEEAKQPAiQEgE3wiBDcDwIkBIAMgEmohAyAAIBJrIgBBgAhLDQALIABFDQELQaCJASADIAAQBEEAKQPAiQEQBQsgAUHQAmokAAuGBwIJfwF+IwBBwABrIgMkAAJAAkAgAC0AaCIERQ0AAkBBwAAgBGsiBSACIAUgAkkbIgZFDQAgBkEDcSEHQQAhBQJAIAZBBEkNACAAIARqIQggBkF8cSEJQQAhBQNAIAggBWoiCkEoaiABIAVqIgstAAA6AAAgCkEpaiALQQFqLQAAOgAAIApBKmogC0ECai0AADoAACAKQStqIAtBA2otAAA6AAAgCSAFQQRqIgVHDQALCwJAIAdFDQAgASAFaiEKIAUgBGogAGpBKGohBQNAIAUgCi0AADoAACAKQQFqIQogBUEBaiEFIAdBf2oiBw0ACwsgAC0AaCEECyAAIAQgBmoiBzoAaCABIAZqIQECQCACIAZrIgINAEEAIQIMAgsgAyAAIABBKGpBwAAgACkDICAALQBqIABB6QBqIgUtAAAiCkVyEAIgACADKQMgIAMpAwCFNwMAIAAgAykDKCADKQMIhTcDCCAAIAMpAzAgAykDEIU3AxAgACADKQM4IAMpAxiFNwMYIABBADoAaCAFIApBAWo6AAAgAEHgAGpCADcDACAAQdgAakIANwMAIABB0ABqQgA3AwAgAEHIAGpCADcDACAAQcAAakIANwMAIABBOGpCADcDACAAQTBqQgA3AwAgAEIANwMoC0EAIQcgAkHBAEkNACAAQekAaiIKLQAAIQUgAC0AaiELIAApAyAhDANAIAMgACABQcAAIAwgCyAFQf8BcUVyQf8BcRACIAAgAykDICADKQMAhTcDACAAIAMpAyggAykDCIU3AwggACADKQ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3AzhBAiEGDAELQQAhBkEAIQACQCABIAdqIglBAkkNACAJQX5qIgpBAXZBAWoiBkEDcSEOQQAhBwJAIApBBkkNACAGQXxxIQggBUGUAWohAUEAIQcgBSEAA0AgASAAQcABajYCACABQXxqIABBgAFqNgIAIAFBeGogAEHAAGo2AgAgAUF0aiAANgIAIABBgAJqIQAgAUEQaiEBIAggB0EEaiIHRw0ACwsgCkF+cSEIAkAgDkUNACAFIAdBBnRqIQEgBUGIAWogB0ECdGohAANAIAAgATYCACABQcAAaiEBIABBBGohACAOQX9qIg4NAAsLIAhBAmohAAsgBUGIAWogBkEBQgBBACADQQRyQQBBACAEEAEgACAJTw0AIAQgBkEFdGoiASAFIAZBBnRqIgApAwA3AwAgASAAKQMINwMIIAEgACkDEDcDECABIAApAxg3AxggBkEBaiEGCyAFQeACaiQAIAYLrRAIAn8EfgF/AX4EfwR+BH8EfiMAQfABayIBJAACQCAARQ0AAkBBAC0AkIoBIgINACABQTBqQQApA9CJATcDACABQThqQQApA9iJATcDACABQQApA6CJASIDNwMAIAFBACkDqIkBIgQ3AwggAUEAKQOwiQEiBTcDECABQQApA7iJASIGNwMYIAFBACkDyIkBNwMoQQAtAIqKASECQQAtAImKASEHQQApA8CJASEIQQAtAIiKASEJIAFBwABqQQApA+CJATcDACABQcgAakEAKQPoiQE3AwAgAUHQAGpBACkD8IkBNwMAIAFB2ABqQQApA/iJATcDACABQeAAakEAKQOAigE3AwAgASAJOgBoIAEgCDcDICABIAIgB0VyIgJBAnI6AGkgAUEoaiEKQgAhCEGACSELIAJBCnJB/wFxIQwDQCABQbABaiABIAogCUH/AXEgCCAMEAIgASABKQPQASINIAEpA7ABhTcDcCABIAEpA9gBIg4gASkDuAGFNwN4IAEgASkD4AEiDyABKQPAAYU3A4ABIAEgASkD6AEiECAGhTcDqAEgASAPIAWFNwOgASABIA4gBIU3A5gBIAEgDSADhTcDkAEgASAQIAEpA8gBhTcDiAEgAEHAACAAQcAASRsiEUF/aiESAkACQCARQQdxIhMNACABQfAAaiECIAshByARIRQMAQsgEUH4AHEhFCABQfAAaiECIAshBwNAIAcgAi0AADoAACAHQQFqIQcgAkEBaiECIBNBf2oiEw0ACwsCQCASQQdJDQADQCAHIAIpAAA3AAAgB0EIaiEHIAJBCGohAiAUQXhqIhQNAAsLIAhCAXwhCCALIBFqIQsgACARayIADQAMAgsLAkACQAJAQQAtAImKASIHQQZ0QQBBAC0AiIoBIhFrRg0AIAEgEToAaCABQQApA4CKATcDYCABQQApA/iJATcDWCABQQApA/CJATcDUCABQQApA+iJATcDSCABQQApA+CJATcDQCABQQApA9iJATcDOCABQQApA9CJATcDMCABQQApA8iJATcDKCABQQApA8CJASIINwMgIAFBACkDuIkBIgM3AxggAUEAKQOwiQEiBDcDECABQQApA6iJASIFNwMIIAFBACkDoIkBIgY3AwAgAUEALQCKigEiEyAHRXJBAnIiCzoAaSATQQRyIRNBACkDmIkBIQ1BACkDkIkBIQ5BACkDiIkBIQ9BACkDgIkBIRAMAQtBwAAhESABQcAAOgBoQgAhCCABQgA3AyAgAUEAKQOYiQEiDTcDGCABQQApA5CJASIONwMQIAFBACkDiIkBIg83AwggAUEAKQOAiQEiEDcDACABQQAtAIqKAUEEciITOgBpIAEgAkF+aiICQQV0IgdByYoBaikDADcDYCABIAdBwYoBaikDADcDWCABIAdBuYoBaikDADcDUCABIAdBsYoBaikDADcDSCABIAdBqYoBaikDADcDQCABIAdBoYoBaikDADcDOCABIAdBmYoBaikDADcDMCABIAdBkYoBaikDADcDKCATIQsgECEGIA8hBSAOIQQgDSEDIAJFDQELIAJBf2oiB0EFdCIUQZGKAWopAwAhFSAUQZmKAWopAwAhFiAUQaGKAWopAwAhFyAUQamKAWopAwAhGCABIAM3A4gBIAEgBDcDgAEgASAFNwN4IAEgBjcDcCABQbABaiABQfAAaiABQShqIhQgESAIIAtB/wFxEAIgASATOgBpIAFBwAA6AGggASAYNwNAIAEgFzcDOCABIBY3AzAgASAVNwMoIAFCADcDICABIA03AxggASAONwMQIAEgDzcDCCABIBA3AwAgASABKQPoASABKQPIAYU3A2AgASABKQPgASABKQPAAYU3A1ggASABKQPYASABKQO4AYU3A1AgASABKQPQASABKQOwAYU3A0ggB0UNACACQQV0QemJAWohAiATQf8BcSERA0AgAkFoaikDACEIIAJBcGopAwAhAyACQXhqKQMAIQQgAikDACEFIAEgDTcDiAEgASAONwOAASABIA83A3ggASAQNwNwIAFBsAFqIAFB8ABqIBRBwABCACAREAIgASATOgBpIAFBwAA6AGggASAFNwNAIAEgBDcDOCABIAM3AzAgASAINwMoIAFCADcDICABIA03AxggASAONwMQIAEgDzcDCCABIBA3AwAgASABKQPoASABKQPIAYU3A2AgASABKQPgASABKQPAAYU3A1ggASABKQPYASABKQO4AYU3A1AgASABKQPQASABKQOwAYU3A0ggAkFgaiECIAdBf2oiBw0ACwsgAUEoaiEJQgAhCEGACSELIBNBCHJB/wFxIQoDQCABQbABaiABIAlBwAAgCCAKEAIgASABKQPQASIDIAEpA7ABhTcDcCABIAEpA9gBIgQgASkDuAGFNwN4IAEgASkD4AEiBSABKQPAAYU3A4ABIAEgDSABKQPoASIGhTcDqAEgASAOIAWFNwOgASABIA8gBIU3A5gBIAEgECADhTcDkAEgASAGIAEpA8gBhTcDiAEgAEHAACAAQcAASRsiEUF/aiESAkACQCARQQdxIhMNACABQfAAaiECIAshByARIRQMAQsgEUH4AHEhFCABQfAAaiECIAshBwNAIAcgAi0AADoAACAHQQFqIQcgAkEBaiECIBNBf2oiEw0ACwsCQCASQQdJDQADQCAHIAIpAAA3AAAgB0EIaiEHIAJBCGohAiAUQXhqIhQNAAsLIAhCAXwhCCALIBFqIQsgACARayIADQALCyABQfABaiQAC6MCAQR+AkACQCAAQSBGDQBCq7OP/JGjs/DbACEBQv+kuYjFkdqCm38hAkLy5rvjo6f9p6V/IQNC58yn0NbQ67O7fyEEQQAhAAwBC0EAKQOYCSEBQQApA5AJIQJBACkDiAkhA0EAKQOACSEEQRAhAAtBACAAOgCKigFBAEIANwOAigFBAEIANwP4iQFBAEIANwPwiQFBAEIANwPoiQFBAEIANwPgiQFBAEIANwPYiQFBAEIANwPQiQFBAEIANwPIiQFBAEIANwPAiQFBACABNwO4iQFBACACNwOwiQFBACADNwOoiQFBACAENwOgiQFBACABNwOYiQFBACACNwOQiQFBACADNwOIiQFBACAENwOAiQFBAEEAOgCQigFBAEEAOwGIigELBgAgABADCwYAIAAQBwsGAEGAiQELqwIBBH4CQAJAIAFBIEYNAEKrs4/8kaOz8NsAIQNC/6S5iMWR2oKbfyEEQvLmu+Ojp/2npX8hBULnzKfQ1tDrs7t/IQZBACEBDAELQQApA5gJIQNBACkDkAkhBEEAKQOICSEFQQApA4AJIQZBECEBC0EAIAE6AIqKAUEAQgA3A4CKAUEAQgA3A/iJAUEAQgA3A/CJAUEAQgA3A+iJAUEAQgA3A+CJAUEAQgA3A9iJAUEAQgA3A9CJAUEAQgA3A8iJAUEAQgA3A8CJAUEAIAM3A7iJAUEAIAQ3A7CJAUEAIAU3A6iJAUEAIAY3A6CJAUEAIAM3A5iJAUEAIAQ3A5CJAUEAIAU3A4iJAUEAIAY3A4CJAUEAQQA6AJCKAUEAQQA7AYiKASAAEAMgAhAHCwsLAQBBgAgLBHgHAAA=";
var hash$g = "540e8b8e";
var wasmJson$g = {
name: name$g,
data: data$g,
hash: hash$g
};
const mutex$i = new Mutex();
let wasmCache$i = null;
function validateBits$2(bits) {
if (!Number.isInteger(bits) || bits < 8 || bits % 8 !== 0) return new Error("Invalid variant! Valid values: 8, 16, ...");
return null;
}
/**
* Calculates BLAKE3 hash
* @param data Input data (string, Buffer or TypedArray)
* @param bits Number of output bits, which has to be a number
* divisible by 8. Defaults to 256.
* @param key Optional key (string, Buffer or TypedArray). Length should be 32 bytes.
* @returns Computed hash as a hexadecimal string
*/ function blake3(data, bits = 256, key = null) {
if (validateBits$2(bits)) return Promise.reject(validateBits$2(bits));
let keyBuffer = null;
let initParam = 0; // key is empty by default
if (key !== null) {
keyBuffer = getUInt8Buffer(key);
if (keyBuffer.length !== 32) return Promise.reject(new Error("Key length must be exactly 32 bytes"));
initParam = 32;
}
const hashLength = bits / 8;
const digestParam = hashLength;
if (wasmCache$i === null || wasmCache$i.hashLength !== hashLength) return lockedCreate(mutex$i, wasmJson$g, hashLength).then((wasm)=>{
wasmCache$i = wasm;
if (initParam === 32) wasmCache$i.writeMemory(keyBuffer);
return wasmCache$i.calculate(data, initParam, digestParam);
});
try {
if (initParam === 32) wasmCache$i.writeMemory(keyBuffer);
const hash = wasmCache$i.calculate(data, initParam, digestParam);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new BLAKE3 hash instance
* @param bits Number of output bits, which has to be a number
* divisible by 8. Defaults to 256.
* @param key Optional key (string, Buffer or TypedArray). Length should be 32 bytes.
*/ function createBLAKE3(bits = 256, key = null) {
if (validateBits$2(bits)) return Promise.reject(validateBits$2(bits));
let keyBuffer = null;
let initParam = 0; // key is empty by default
if (key !== null) {
keyBuffer = getUInt8Buffer(key);
if (keyBuffer.length !== 32) return Promise.reject(new Error("Key length must be exactly 32 bytes"));
initParam = 32;
}
const outputSize = bits / 8;
const digestParam = outputSize;
return WASMInterface(wasmJson$g, outputSize).then((wasm)=>{
if (initParam === 32) wasm.writeMemory(keyBuffer);
wasm.init(initParam);
const obj = {
init: initParam === 32 ? ()=>{
wasm.writeMemory(keyBuffer);
wasm.init(initParam);
return obj;
} : ()=>{
wasm.init(initParam);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType, digestParam),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 64,
digestSize: outputSize
};
return obj;
});
}
var name$f = "crc32";
var data$f = "AGFzbQEAAAABEQRgAAF/YAF/AGAAAGACf38AAwgHAAEBAQIAAwUEAQECAgYOAn8BQZDJBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAgtIYXNoX1VwZ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AELIAFB/wFxIAItAABzQQJ0QYCJAWooAgAgAUEIdnMhASACQQFqIQIgAEF/aiEDCyAAQQFGDQADQCABQf8BcSACLQAAc0ECdEGAiQFqKAIAIAFBCHZzIgFB/wFxIAJBAWotAABzQQJ0QYCJAWooAgAgAUEIdnMhASACQQJqIQIgA0F+aiIDDQALC0EAIAFBf3M2AoTJAQsyAQF/QQBBACgChMkBIgBBGHQgAEGA/gNxQQh0ciAAQQh2QYD+A3EgAEEYdnJyNgKACQsGAEGEyQELWQACQEEAKAKAyQEgAUYNACABEAFBACABNgKAyQELQQBBADYChMkBIAAQA0EAQQAoAoTJASIBQRh0IAFBgP4DcUEIdHIgAUEIdkGA/gNxIAFBGHZycjYCgAkLCwsBAEGACAsEBAAAAA==";
var hash$f = "d2eba587";
var wasmJson$f = {
name: name$f,
data: data$f,
hash: hash$f
};
const mutex$h = new Mutex();
let wasmCache$h = null;
/**
* Calculates CRC-32 hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function crc32(data) {
if (wasmCache$h === null) return lockedCreate(mutex$h, wasmJson$f, 4).then((wasm)=>{
wasmCache$h = wasm;
return wasmCache$h.calculate(data, 0xEDB88320);
});
try {
const hash = wasmCache$h.calculate(data, 0xEDB88320);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new CRC-32 hash instance
*/ function createCRC32() {
return WASMInterface(wasmJson$f, 4).then((wasm)=>{
wasm.init(0xEDB88320);
const obj = {
init: ()=>{
wasm.init(0xEDB88320);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 4,
digestSize: 4
};
return obj;
});
}
const mutex$g = new Mutex();
let wasmCache$g = null;
/**
* Calculates CRC-32C hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function crc32c(data) {
if (wasmCache$g === null) return lockedCreate(mutex$g, wasmJson$f, 4).then((wasm)=>{
wasmCache$g = wasm;
return wasmCache$g.calculate(data, 0x82F63B78);
});
try {
const hash = wasmCache$g.calculate(data, 0x82F63B78);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new CRC-32C hash instance
*/ function createCRC32C() {
return WASMInterface(wasmJson$f, 4).then((wasm)=>{
wasm.init(0x82F63B78);
const obj = {
init: ()=>{
wasm.init(0x82F63B78);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 4,
digestSize: 4
};
return obj;
});
}
var name$e = "md4";
var data$e = "AGFzbQEAAAABEgRgAAF/YAAAYAF/AGACf38BfwMIBwABAgMBAAIFBAEBAgIGDgJ/AUGgigULfwBBgAgLB3AIBm1lbW9yeQIADkhhc2hfR2V0QnVmZmVyAAAJSGFzaF9Jbml0AAELSGFzaF9VcGRhdGUAAgpIYXNoX0ZpbmFsAAQNSGFzaF9HZXRTdGF0ZQAFDkhhc2hfQ2FsY3VsYXRlAAYKU1RBVEVfU0laRQMBCu4UBwUAQYAJCy0AQQBC/rnrxemOlZkQNwKQiQFBAEKBxpS6lvHq5m83AoiJAUEAQgA3AoCJAQu+BQEHf0EAQQAoAoCJASIBIABqQf////8BcSICNgKAiQFBAEEAKAKEiQEgAiABSWogAEEddmo2AoSJAQJAAkACQAJAAkACQCABQT9xIgMNAEGACSEEDAELQcAAIANrIgUgAEsNASAFQQNxIQZBACEBAkAgA0E/c0EDSQ0AIANBgIkBaiEEIAVB/ABxIQdBACEBA0AgBCABaiICQRhqIAFBgAlqLQAAOgAAIAJBGWogAUGBCWotAAA6AAAgAkEaaiABQYIJai0AADoAACACQRtqIAFBgwlqLQAAOgAAIAcgAUEEaiIBRw0ACwsCQCAGRQ0AIANBmIkBaiECA0AgAiABaiABQYAJai0AADoAACABQQFqIQEgBk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c2pBodfn9gZqQQl3IhJzakGh1+f2BmpBC3ciEyADaiEDIAkgEWogEiAVcyATc2pBodfn9gZqQQ93IARqIQQgEiACaiECIBUgBWohBSAAQcAAaiEAIAFBQGoiAQ0AC0EAIAI2ApSJAUEAIAM2ApCJAUEAIAQ2AoyJAUEAIAU2AoiJASAAC88DAQR/QQAoAoCJAUE/cSIAQZiJAWpBgAE6AAAgAEEBaiEBAkACQAJAAkAgAEE/cyICQQdLDQAgAkUNASABQZiJAWpBADoAACACQQFGDQEgAEGaiQFqQQA6AAAgAkECRg0BIABBm4kBakEAOgAAIAJBA0YNASAAQZyJAWpBADoAACACQQRGDQEgAEGdiQFqQQA6AAAgAkEFRg0BIABBnokBakEAOgAAIAJBBkYNASAAQZ+JAWpBADoAAAwBCyACQQhGDQJBNiAAayEDAkAgAkEDcSIADQAgAyECDAILQQAgAGshAkEAIQADQCAAQc+JAWpBADoAACACIABBf2oiAEcNAAsgAyAAaiECDAELQZiJAUHAABADGkEAIQFBNyEDQTchAgsgA0EDSQ0AIAFBgIkBaiEAQX8hAQNAIAAgAmpBFWpBADYAACAAQXxqIQAgAiABQQRqIgFHDQALC0EAQQAoAoSJATYC1IkBQQBBACgCgIkBIgBBFXY6ANOJAUEAIABBDXY6ANKJAUEAIABBBXY6ANGJAUEAIABBA3QiADoA0IkBQQAgADYCgIkBQZiJAUHAABADGkEAQQApAoiJATcDgAlBAEEAKQKQiQE3A4gJCwYAQYCJAQszAEEAQv6568XpjpWZEDcCkIkBQQBCgcaUupbx6uZvNwKIiQFBAEIANwKAiQEgABACEAQLCwsBAEGACAsEmAAAAA==";
var hash$e = "74909c24";
var wasmJson$e = {
name: name$e,
data: data$e,
hash: hash$e
};
const mutex$f = new Mutex();
let wasmCache$f = null;
/**
* Calculates MD4 hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function md4(data) {
if (wasmCache$f === null) return lockedCreate(mutex$f, wasmJson$e, 16).then((wasm)=>{
wasmCache$f = wasm;
return wasmCache$f.calculate(data);
});
try {
const hash = wasmCache$f.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new MD4 hash instance
*/ function createMD4() {
return WASMInterface(wasmJson$e, 16).then((wasm)=>{
wasm.init();
const obj = {
init: ()=>{
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 64,
digestSize: 16
};
return obj;
});
}
var name$d = "md5";
var data$d = "AGFzbQEAAAABEgRgAAF/YAAAYAF/AGACf38BfwMIBwABAgMBAAIFBAEBAgIGDgJ/AUGgigULfwBBgAgLB3AIBm1lbW9yeQIADkhhc2hfR2V0QnVmZmVyAAAJSGFzaF9Jbml0AAELSGFzaF9VcGRhdGUAAgpIYXNoX0ZpbmFsAAQNSGFzaF9HZXRTdGF0ZQAFDkhhc2hfQ2FsY3VsYXRlAAYKU1RBVEVfU0laRQMBCooaBwUAQYAJCy0AQQBC/rnrxemOlZkQNwKQiQFBAEKBxpS6lvHq5m83AoiJAUEAQgA3AoCJAQu+BQEHf0EAQQAoAoCJASIBIABqQf////8BcSICNgKAiQFBAEEAKAKEiQEgAiABSWogAEEddmo2AoSJAQJAAkACQAJAAkACQCABQT9xIgMNAEGACSEEDAELQcAAIANrIgUgAEsNASAFQQNxIQZBACEBAkAgA0E/c0EDSQ0AIANBgIkBaiEEIAVB/ABxIQdBACEBA0AgBCABaiICQRhqIAFBgAlqLQAAOgAAIAJBGWogAUGBCWotAAA6AAAgAkEaaiABQYIJai0AADoAACACQRtqIAFBgwlqLQAAOgAAIAcgAUEEaiIBRw0ACwsCQCAGRQ0AIANBmIkBaiECA0AgAiABaiABQYAJai0AADoAACABQQFqIQEgBkF/aiIGDQALC0GYiQFBwAAQAxogACAFayEAIAVBgAlqIQQLIABBwABPDQEgACECDAILIABFDQIgAEEDcSEGQQAhAQJAI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JBAUYNASAAQZqJAWpBADoAACACQQJGDQEgAEGbiQFqQQA6AAAgAkEDRg0BIABBnIkBakEAOgAAIAJBBEYNASAAQZ2JAWpBADoAACACQQVGDQEgAEGeiQFqQQA6AAAgAkEGRg0BIABBn4kBakEAOgAADAELIAJBCEYNAkE2IABrIQMCQCACQQNxIgANACADIQIMAgtBACAAayECQQAhAANAIABBz4kBakEAOgAAIAIgAEF/aiIARw0ACyADIABqIQIMAQtBmIkBQcAAEAMaQQAhAUE3IQNBNyECCyADQQNJDQAgAUGAiQFqIQBBfyEBA0AgACACakEVakEANgAAIABBfGohACACIAFBBGoiAUcNAAsLQQBBACgChIkBNgLUiQFBAEEAKAKAiQEiAEEVdjoA04kBQQAgAEENdjoA0okBQQAgAEEFdjoA0YkBQQAgAEEDdCIAOgDQiQFBACAANgKAiQFBmIkBQcAAEAMaQQBBACkCiIkBNwOACUEAQQApApCJATcDiAkLBgBBgIkBCzMAQQBC/rnrxemOlZkQNwKQiQFBAEKBxpS6lvHq5m83AoiJAUEAQgA3AoCJASAAEAIQBAsLCwEAQYAICwSYAAAA";
var hash$d = "42fa4d29";
var wasmJson$d = {
name: name$d,
data: data$d,
hash: hash$d
};
const mutex$e = new Mutex();
let wasmCache$e = null;
/**
* Calculates MD5 hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function md5(data) {
if (wasmCache$e === null) return lockedCreate(mutex$e, wasmJson$d, 16).then((wasm)=>{
wasmCache$e = wasm;
return wasmCache$e.calculate(data);
});
try {
const hash = wasmCache$e.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new MD5 hash instance
*/ function createMD5() {
return WASMInterface(wasmJson$d, 16).then((wasm)=>{
wasm.init();
const obj = {
init: ()=>{
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
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F/aiIGDQALC0GciQEQASAFQf8AcyEDQQAhBSADIAFPDQADQCAAIAJqEAEgAkH/AGohAyACQcAAaiIEIQIgAyABSQ0ACyAEIQILAkAgASACRg0AIAEgAmshCSAAIAJqIQIgBUGciQFqIQNBACEEA0AgAyACLQAAOgAAIAJBAWohAiADQQFqIQMgCSAEQQFqIgRB/wFxSw0ACwsLCQBBgAkgABADC6YDAQJ/IwBBEGsiACQAIABBgAE6AAcgAEEAKAKYiQEiAUEYdCABQYD+A3FBCHRyIAFBCHZBgP4DcSABQRh2cnI2AAggAEEAKAKUiQEiAUEYdCABQYD+A3FBCHRyIAFBCHZBgP4DcSABQRh2cnI2AAwgAEEHakEBEAMCQEEAKAKUiQFB+ANxQcADRg0AA0AgAEEAOgAHIABBB2pBARADQQAoApSJAUH4A3FBwANHDQALCyAAQQhqQQgQA0EAQQAoAoCJASIBQRh0IAFBgP4DcUEIdHIgAUEIdkGA/gNxIAFBGHZycjYCgAlBAEEAKAKEiQEiAUEYdCABQYD+A3FBCHRyIAFBCHZBgP4DcSABQRh2cnI2AoQJQQBBACgCiIkBIgFBGHQgAUGA/gNxQQh0ciABQQh2QYD+A3EgAUEYdnJyNgKICUEAQQAoAoyJASIBQRh0IAFBgP4DcUEIdHIgAUEIdkGA/gNxIAFBGHZycjYCjAlBAEEAKAKQiQEiAUEYdCABQYD+A3FBCHRyIAFBCHZBgP4DcSABQRh2cnI2ApAJIABBEGokAAsGAEGAiQELQwBBAEL+uevF6Y6VmRA3AoiJAUEAQoHGlLqW8ermbzcCgIkBQQBC8MPLngw3ApCJAUEAQQA2ApiJAUGACSAAEAMQBQsLCwEAQYAICwRcAAAA";
var hash$c = "6b530c24";
var wasmJson$c = {
name: name$c,
data: data$c,
hash: hash$c
};
const mutex$d = new Mutex();
let wasmCache$d = null;
/**
* Calculates SHA-1 hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function sha1(data) {
if (wasmCache$d === null) return lockedCreate(mutex$d, wasmJson$c, 20).then((wasm)=>{
wasmCache$d = wasm;
return wasmCache$d.calculate(data);
});
try {
const hash = wasmCache$d.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new SHA-1 hash instance
*/ function createSHA1() {
return WASMInterface(wasmJson$c, 20).then((wasm)=>{
wasm.init();
const obj = {
init: ()=>{
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 64,
digestSize: 20
};
return obj;
});
}
var name$b = "sha3";
var data$b = "AGFzbQEAAAABFARgAAF/YAF/AGACf38AYAN/f38AAwgHAAEBAgEAAwUEAQECAgYOAn8BQZCNBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAQtIYXNoX1VwZGF0ZQACCkhhc2hfRmluYWwABA1IYXNoX0dldFN0YXRlAAUOSGFzaF9DYWxjdWxhdGUABgpTVEFURV9TSVpFAwEKqBwHBQBBgAoL1wMAQQBCADcDgI0BQQBCADcD+IwBQQBCADcD8IwBQQBCADcD6IwBQQBCADcD4IwBQQBCADcD2IwBQQBCADcD0IwBQQBCADcDyIwBQQBCADcDwIwBQQBCADcDuIwBQQBCADcDsIwBQQBCADcDqIwBQQBCADcDoIwBQQBCADcDmIwBQQBCADcDkIwBQQBCADcDiIwBQQBCADcDgIwBQQBCADcD+IsBQQBCADcD8IsBQQBCADcD6IsBQQBCADcD4IsBQQBCADcD2IsBQQBCADcD0IsBQQBCADcDyIsBQQBCADcDwIsBQQBCADcDuIsBQQBCADcDsIsBQQBCADcDqIsBQQBCADcDoIsBQQBCADcDmIsBQQBCADcDkIsBQQBCADcDiIsBQQBCADcDgIsBQQBCADcD+IoBQQBCADcD8IoBQQBCADcD6IoBQQBCADcD4IoBQQBCADcD2IoBQQBCADcD0IoBQQBCADcDyIoBQQBCADcDwIoBQQBCADcDuIoBQQBCADcDsIoBQQBCADcDqIoBQQBCADcDoIoBQQBCADcDmIoBQQBCADcDkIoBQQBCADcDiIoBQQBCADcDgIoBQQBBwAwgAEEBdGtBA3Y2AoyNAUEAQQA2AoiNAQuMAwEIfwJAQQAoAoiNASIBQQBIDQBBACABIABqQQAoAoyNASICcDYCiI0BAkACQCABDQBBgAohAwwBCwJAIAIgAWsiBCAAIAQgAEkbIgNFDQAgA0EDcSEFQQAhBgJAIANBBEkNACABQYCKAWohByADQXxxIQhBACEGA0AgByAGaiIDQcgBaiAGQYAKai0AADoAACADQckBaiAGQYEKai0AADoAACADQcoBaiAGQYIKai0AADoAACADQcsBaiAGQYMKai0AADoAACAIIAZBBGoiBkcNAAsLIAVFDQAgAUHIiwFqIQMDQCADIAZqIAZBgApqLQAAOgAAIAZBAWohBiAFQX9qIgUNAAsLIAQgAEsNAUHIiwEgAhADIAAgBGshACAEQYAKaiEDCwJAIAAgAkkNAANAIAMgAhADIAMgAmohAyAAIAJrIgAgAk8NAAsLIABFDQBBACECQcgBIQYDQCAGQYCKAWogAyAGakG4fmotAAA6AAAgBkEBaiEGIAAgAkEBaiICQf8BcUsNAAsLC+QLAS1+IAApA0AhAkEAKQPAigEhAyAAKQM4IQRBACkDuIoBIQUgACkDMCEGQQApA7CKASEHIAApAyghCEEAKQOoigEhCSAAKQMgIQpBACkDoIoBIQsgACkDGCEMQQApA5iKASENIAApAxAhDkEAKQOQigEhDyAAKQMIIRBBACkDiIoBIREgACkDACESQQApA4CKASETQQApA8iKASEUAkACQCABQcgASw0AQQApA9CKASEVQQApA+CKASEWQQApA9iKASEXDAELQQApA+CKASAAKQNghSEWQQApA9iKASAAKQNYhSEXQQApA9CKASAAKQNQhSEVIBQgACkDSIUhFCABQekASQ0AQQBBACkD6IoBIAApA2iFNwPoigFBAEEAKQPwigEgACkDcIU3A/CKAUEAQQApA/iKASAAKQN4hTcD+IoBQQBBACkDgIsBIAApA4ABhTcDgIsBIAFBiQF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wOwjAFBAEIANwOojAFBAEIANwOgjAFBAEIANwOYjAFBAEIANwOQjAFBAEIANwOIjAFBAEIANwOAjAFBAEIANwP4iwFBAEIANwPwiwFBAEIANwPoiwFBAEIANwPgiwFBAEIANwPYiwFBAEIANwPQiwFBAEIANwPIiwFBAEIANwPAiwFBAEIANwO4iwFBAEIANwOwiwFBAEIANwOoiwFBAEIANwOgiwFBAEIANwOYiwFBAEIANwOQiwFBAEIANwOIiwFBAEIANwOAiwFBAEIANwP4igFBAEIANwPwigFBAEIANwPoigFBAEIANwPgigFBAEIANwPYigFBAEIANwPQigFBAEIANwPIigFBAEIANwPAigFBAEIANwO4igFBAEIANwOwigFBAEIANwOoigFBAEIANwOgigFBAEIANwOYigFBAEIANwOQigFBAEIANwOIigFBAEIANwOAigFBAEHADCABQQF0a0EDdjYCjI0BQQBBADYCiI0BIAAQAkHkAEEAKAKMjQEiAEEBdmshAwJAQQAoAoiNASIBQQBIDQAgACEEAkAgACABRg0AIAFByIsBaiEFQQAhAQNAIAUgAWpBADoAACABQQFqIgEgAEEAKAKIjQEiBGtJDQALCyAEQciLAWoiASABLQAAIAJyOgAAIABBx4sBaiIBIAEtAABBgAFyOgAAQciLASAAEANBAEGAgICAeDYCiI0BCwJAIANBBEkNACADQQJ2IgFBA3EhBUEAIQQCQCABQX9qQQNJDQAgAUH8////A3EhAEEAIQFBACEEA0AgAUGACmogAUGAigFqKAIANgIAIAFBhApqIAFBhIoBaigCADYCACABQYgKaiABQYiKAWooAgA2AgAgAUGMCmogAUGMigFqKAIANgIAIAFBEGohASAAIARBBGoiBEcNAAsLIAVFDQAgBUECdCEAIARBAnQhAQNAIAFBgApqIAFBgIoBaigCADYCACABQQRqIQEgAEF8aiIADQALCwsL2AEBAEGACAvQAZABAAAAAAAAAAAAAAAAAAABAAAAAAAAAIKAAAAAAAAAioAAAAAAAIAAgACAAAAAgIuAAAAAAAAAAQAAgAAAAACBgACAAAAAgAmAAAAAAACAigAAAAAAAACIAAAAAAAAAAmAAIAAAAAACgAAgAAAAACLgACAAAAAAIsAAAAAAACAiYAAAAAAAIADgAAAAAAAgAKAAAAAAACAgAAAAAAAAIAKgAAAAAAAAAoAAIAAAACAgYAAgAAAAICAgAAAAAAAgAEAAIAAAAAACIAAgAAAAIA=";
var hash$b = "f2f6f5b2";
var wasmJson$b = {
name: name$b,
data: data$b,
hash: hash$b
};
const mutex$c = new Mutex();
let wasmCache$c = null;
function validateBits$1(bits) {
if (![
224,
256,
384,
512
].includes(bits)) return new Error("Invalid variant! Valid values: 224, 256, 384, 512");
return null;
}
/**
* Calculates SHA-3 hash
* @param data Input data (string, Buffer or TypedArray)
* @param bits Number of output bits. Valid values: 224, 256, 384, 512
* @returns Computed hash as a hexadecimal string
*/ function sha3(data, bits = 512) {
if (validateBits$1(bits)) return Promise.reject(validateBits$1(bits));
const hashLength = bits / 8;
if (wasmCache$c === null || wasmCache$c.hashLength !== hashLength) return lockedCreate(mutex$c, wasmJson$b, hashLength).then((wasm)=>{
wasmCache$c = wasm;
return wasmCache$c.calculate(data, bits, 0x06);
});
try {
const hash = wasmCache$c.calculate(data, bits, 0x06);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new SHA-3 hash instance
* @param bits Number of output bits. Valid values: 224, 256, 384, 512
*/ function createSHA3(bits = 512) {
if (validateBits$1(bits)) return Promise.reject(validateBits$1(bits));
const outputSize = bits / 8;
return WASMInterface(wasmJson$b, outputSize).then((wasm)=>{
wasm.init(bits);
const obj = {
init: ()=>{
wasm.init(bits);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType, 0x06),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 200 - 2 * outputSize,
digestSize: outputSize
};
return obj;
});
}
const mutex$b = new Mutex();
let wasmCache$b = null;
function validateBits(bits) {
if (![
224,
256,
384,
512
].includes(bits)) return new Error("Invalid variant! Valid values: 224, 256, 384, 512");
return null;
}
/**
* Calculates Keccak hash
* @param data Input data (string, Buffer or TypedArray)
* @param bits Number of output bits. Valid values: 224, 256, 384, 512
* @returns Computed hash as a hexadecimal string
*/ function keccak(data, bits = 512) {
if (validateBits(bits)) return Promise.reject(validateBits(bits));
const hashLength = bits / 8;
if (wasmCache$b === null || wasmCache$b.hashLength !== hashLength) return lockedCreate(mutex$b, wasmJson$b, hashLength).then((wasm)=>{
wasmCache$b = wasm;
return wasmCache$b.calculate(data, bits, 0x01);
});
try {
const hash = wasmCache$b.calculate(data, bits, 0x01);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new Keccak hash instance
* @param bits Number of output bits. Valid values: 224, 256, 384, 512
*/ function createKeccak(bits = 512) {
if (validateBits(bits)) return Promise.reject(validateBits(bits));
const outputSize = bits / 8;
return WASMInterface(wasmJson$b, outputSize).then((wasm)=>{
wasm.init(bits);
const obj = {
init: ()=>{
wasm.init(bits);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType, 0x01),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 200 - 2 * outputSize,
digestSize: outputSize
};
return obj;
});
}
var name$a = "sha256";
var data$a = "AGFzbQEAAAABEQRgAAF/YAF/AGAAAGACf38AAwgHAAEBAQIAAwUEAQECAgYOAn8BQfCJBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAQtIYXNoX1VwZGF0ZQACCkhhc2hfRmluYWwABA1IYXNoX0dldFN0YXRlAAUOSGFzaF9DYWxjdWxhdGUABgpTVEFURV9TSVpFAwEKoEoHBQBBgAkLnQEAQQBCADcDwIkBQQBBHEEgIABB4AFGIgAbNgLoiQFBAEKnn+anxvST/b5/Qquzj/yRo7Pw2wAgABs3A+CJAUEAQrGWgP6fooWs6ABC/6S5iMWR2oKbfyAAGzcD2IkBQQBCl7rDg5Onlod3QvLmu+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MgHtqIhggASADcyACcSABIANxcyABQR53IAFBE3dzIAFBCndzaiAUaiICaiIRIAkgE3NxIBNzaiARQRp3IBFBFXdzIBFBB3dzakHH/+X6e2oiFCACIAFzIANxIAIgAXFzIAJBHncgAkETd3MgAkEKd3NqIBdqIgNqIhIgESAJc3EgCXNqIBJBGncgEkEVd3MgEkEHd3NqQfOXgLd8aiIXIAMgAnMgAXEgAyACcXMgA0EedyADQRN3cyADQQp3c2ogGWoiAWoiE2ogICASaiAcIBFqIB8gCWogEyASIBFzcSARc2ogE0EadyATQRV3cyATQQd3c2pBx6KerX1qIhkgASADcyACcSABIANxcyABQR53IAFBE3dzIAFBCndzaiAaaiICaiIJIBMgEnNxIBJzaiAJQRp3IAlBFXdzIAlBB3dzakHRxqk2aiIaIAIgAXMgA3EgAiABcXMgAkEedyACQRN3cyACQQp3c2ogGGoiA2oiESAJIBNzcSATc2ogEUEadyARQRV3cyARQQd3c2pB59KkoQFqIhggAyACcyABcSADIAJxcyADQR53IANBE3dzIANBCndzaiAUaiIBaiISIBEgCXNxIAlzaiASQRp3IBJBFXdzIBJBB3dzakGFldy9AmoiFCABIANzIAJxIAEgA3FzIAFBHncgAUETd3MgAUEKd3NqIBdqIgJqIhMgI2ogJiASaiAiIBFqICUgCWogEyASIBFzcSARc2ogE0EadyATQRV3cyATQQd3c2pBuMLs8AJqIhcgAiABcyADcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiAZaiIDaiIJIBMgEnNxIBJzaiAJQRp3IAlBFXdzIAlBB3dzakH827HpBGoiGSADIAJzIAFxIAMgAnFzIANBHncgA0ETd3MgA0EKd3NqIBpqIgFqIhEgCSATc3EgE3NqIBFBGncgEUEVd3MgEUEHd3NqQZOa4JkFaiIaIAEgA3MgAnEgASADcXMgAUEedyABQRN3cyABQQp3c2ogGGoiAmoiEiARIAlzcSAJc2ogEkEadyASQRV3cyASQQd3c2pB1OapqAZqIhggAiABcyADcSACIAFxcyACQR53IAJBE3dzIAJBCndzaiAUai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FBCHRyIABBCHZBgP4DcSAAQRh2cnI2AtCJAUEAQQAoAsyJASIAQRh0IABBgP4DcUEIdHIgAEEIdkGA/gNxIABBGHZycjYCzIkBQQBBACgCyIkBIgBBGHQgAEGA/gNxQQh0ciAAQQh2QYD+A3EgAEEYdnJyNgLIiQECQEEAKALoiQEiAkUNAEEAIQADQCABQYAJaiABQciJAWotAAA6AAAgAUEBaiEBIAIgAEEBaiIAQf8BcUsNAAsLCwYAQYCJAQujAQBBAEIANwPAiQFBAEEcQSAgAUHgAUYiARs2AuiJAUEAQqef5qfG9JP9vn9Cq7OP/JGjs/DbACABGzcD4IkBQQBCsZaA/p+ihazoAEL/pLmIxZHagpt/IAEbNwPYiQFBAEKXusODk6eWh3dC8ua746On/aelfyABGzcD0IkBQQBC2L2WiPygtb42QufMp9DW0Ouzu38gARs3A8iJASAAEAIQBAsLCwEAQYAICwRwAAAA";
var hash$a = "64f06674";
var wasmJson$a = {
name: name$a,
data: data$a,
hash: hash$a
};
const mutex$a = new Mutex();
let wasmCache$a = null;
/**
* Calculates SHA-2 (SHA-224) hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function sha224(data) {
if (wasmCache$a === null) return lockedCreate(mutex$a, wasmJson$a, 28).then((wasm)=>{
wasmCache$a = wasm;
return wasmCache$a.calculate(data, 224);
});
try {
const hash = wasmCache$a.calculate(data, 224);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new SHA-2 (SHA-224) hash instance
*/ function createSHA224() {
return WASMInterface(wasmJson$a, 28).then((wasm)=>{
wasm.init(224);
const obj = {
init: ()=>{
wasm.init(224);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 64,
digestSize: 28
};
return obj;
});
}
const mutex$9 = new Mutex();
let wasmCache$9 = null;
/**
* Calculates SHA-2 (SHA-256) hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function sha256(data) {
if (wasmCache$9 === null) return lockedCreate(mutex$9, wasmJson$a, 32).then((wasm)=>{
wasmCache$9 = wasm;
return wasmCache$9.calculate(data, 256);
});
try {
const hash = wasmCache$9.calculate(data, 256);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new SHA-2 (SHA-256) hash instance
*/ function createSHA256() {
return WASMInterface(wasmJson$a, 32).then((wasm)=>{
wasm.init(256);
const obj = {
init: ()=>{
wasm.init(256);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 64,
digestSize: 32
};
return obj;
});
}
var name$9 = "sha512";
var data$9 = "AGFzbQEAAAABEQRgAAF/YAF/AGAAAGACf38AAwgHAAEBAQIAAwUEAQECAgYOAn8BQdCKBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAQtIYXNoX1VwZGF0ZQACCkhhc2hfRmluYWwABA1IYXNoX0dldFN0YXRlAAUOSGFzaF9DYWxjdWxhdGUABgpTVEFURV9TSVpFAwEKmWgHBQBBgAkLmwIAQQBCADcDgIoBQQBBMEHAACAAQYADRiIAGzYCyIoBQQBCpJ/p99uD0trHAEL5wvibkaOz8NsAIAAbNwPAigFBAEKnn+an1sGLhltC6/qG2r+19sEfIAAbNwO4igFBAEKRquDC9tCS2o5/Qp/Y+dnCkdqCm38gABs3A7CKAUEAQrGWgP7/zMmZ5wBC0YWa7/rPlIfRACAAGzcDqIoBQQBCubK5uI+b+5cVQvHt9Pilp/2npX8gABs3A6CKAUEAQpe6w4Ojq8CskX9Cq/DT9K/uvLc8IAAbNwOYigFBAEKHqvOzo6WKzeIAQrvOqqbY0Ouzu38gABs3A5CKAUEAQti9lojcq+fdS0KIkvOd/8z5hO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C+cL4m5Gjs/DbACABGzcDwIoBQQBCp5/mp9bBi4ZbQuv6htq/tfbBHyABGzcDuIoBQQBCkargwvbQktqOf0Kf2PnZwpHagpt/IAEbNwOwigFBAEKxloD+/8zJmecAQtGFmu/6z5SH0QAgARs3A6iKAUEAQrmyubiPm/uXFULx7fT4paf9p6V/IAEbNwOgigFBAEKXusODo6vArJF/Qqvw0/Sv7ry3PCABGzcDmIoBQQBCh6rzs6Olis3iAEK7zqqm2NDrs7t/IAEbNwOQigFBAELYvZaI3Kvn3UtCiJLznf/M+YTqACABGzcDiIoBIAAQAhAECwsLAQBBgAgLBNAAAAA=";
var hash$9 = "cdd57f6a";
var wasmJson$9 = {
name: name$9,
data: data$9,
hash: hash$9
};
const mutex$8 = new Mutex();
let wasmCache$8 = null;
/**
* Calculates SHA-2 (SHA-384) hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function sha384(data) {
if (wasmCache$8 === null) return lockedCreate(mutex$8, wasmJson$9, 48).then((wasm)=>{
wasmCache$8 = wasm;
return wasmCache$8.calculate(data, 384);
});
try {
const hash = wasmCache$8.calculate(data, 384);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new SHA-2 (SHA-384) hash instance
*/ function createSHA384() {
return WASMInterface(wasmJson$9, 48).then((wasm)=>{
wasm.init(384);
const obj = {
init: ()=>{
wasm.init(384);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 128,
digestSize: 48
};
return obj;
});
}
const mutex$7 = new Mutex();
let wasmCache$7 = null;
/**
* Calculates SHA-2 (SHA-512) hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function sha512(data) {
if (wasmCache$7 === null) return lockedCreate(mutex$7, wasmJson$9, 64).then((wasm)=>{
wasmCache$7 = wasm;
return wasmCache$7.calculate(data, 512);
});
try {
const hash = wasmCache$7.calculate(data, 512);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new SHA-2 (SHA-512) hash instance
*/ function createSHA512() {
return WASMInterface(wasmJson$9, 64).then((wasm)=>{
wasm.init(512);
const obj = {
init: ()=>{
wasm.init(512);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 128,
digestSize: 64
};
return obj;
});
}
var name$8 = "xxhash32";
var data$8 = "AGFzbQEAAAABEQRgAAF/YAF/AGAAAGACf38AAwcGAAEBAgADBQQBAQICBg4CfwFBsIkFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACUhhc2hfSW5pdAABC0hhc2hfVXBkYXRlAAIKSGFzaF9GaW5hbAADDUhhc2hfR2V0U3RhdGUABA5IYXNoX0NhbGN1bGF0ZQAFClNUQVRFX1NJWkUDAQqxEAYFAEGACQtNAEEAQgA3A6iJAUEAIAA2AoiJAUEAIABBz4yijgZqNgKMiQFBACAAQfeUr694ajYChIkBQQAgAEGoiI2hAmo2AoCJAUEAQQA2AqCJAQu4CAEHfwJAIABFDQBBAEEAKQOoiQEgAK18NwOoiQECQEEAKAKgiQEiASAAakEPSw0AAkACQCAAQQNxIgINAEGACSEDIAAhBAwBCyAAQXxxIQRBgAkhAwNAQQBBACgCoIkBIgVBAWo2AqCJASAFQZCJAWogAy0AADoAACADQQFqIQMgAkF/aiICDQALCyAAQQRJDQEDQEEAQQAoAqCJASICQQFqNgKgiQEgAkGQiQFqIAMtAAA6AAAgA0EBai0AACECQQBBACgCoIkBIgVBAWo2AqCJASAFQZCJAWogAjoAACADQQJqLQAAIQJBAEEAKAKgiQEiBUEBajYCoIkBIAVBkIkBaiACOgAAIANBA2otAAAhAkEAQQAoAqCJASIFQQFqNgKgiQEgBUGQiQFqIAI6AAAg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iABc0G93MqVfGwiAUEQdiABcyIAQRh0IABBgP4DcUEIdHIgAUEIdkGA/gNxIAFBGHZycq03A4AJCwsLAQBBgAgLBDAAAAA=";
var hash$8 = "9e3a00cd";
var wasmJson$8 = {
name: name$8,
data: data$8,
hash: hash$8
};
const mutex$6 = new Mutex();
let wasmCache$6 = null;
function validateSeed$3(seed) {
if (!Number.isInteger(seed) || seed < 0 || seed > 0xFFFFFFFF) return new Error("Seed must be a valid 32-bit long unsigned integer.");
return null;
}
/**
* Calculates xxHash32 hash
* @param data Input data (string, Buffer or TypedArray)
* @param seed Number used to initialize the internal state of the algorithm (defaults to 0)
* @returns Computed hash as a hexadecimal string
*/ function xxhash32(data, seed = 0) {
if (validateSeed$3(seed)) return Promise.reject(validateSeed$3(seed));
if (wasmCache$6 === null) return lockedCreate(mutex$6, wasmJson$8, 4).then((wasm)=>{
wasmCache$6 = wasm;
return wasmCache$6.calculate(data, seed);
});
try {
const hash = wasmCache$6.calculate(data, seed);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new xxHash32 hash instance
* @param data Input data (string, Buffer or TypedArray)
* @param seed Number used to initialize the internal state of the algorithm (defaults to 0)
*/ function createXXHash32(seed = 0) {
if (validateSeed$3(seed)) return Promise.reject(validateSeed$3(seed));
return WASMInterface(wasmJson$8, 4).then((wasm)=>{
wasm.init(seed);
const obj = {
init: ()=>{
wasm.init(seed);
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 16,
digestSize: 4
};
return obj;
});
}
var name$7 = "xxhash64";
var data$7 = "AGFzbQEAAAABDANgAAF/YAAAYAF/AAMHBgABAgEAAQUEAQECAgYOAn8BQdCJBQt/AEGACAsHcAgGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAlIYXNoX0luaXQAAQtIYXNoX1VwZGF0ZQACCkhhc2hfRmlu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Vr6+Ytt6bnn9+QuPcypX8zvL1hX98IQAgCEEQaiEJIAhBCGoiBSEIIAkgB00NAAsLAkACQCAFQQRqIgkgB00NACAFIQkMAQsgBTUCAEKHla+vmLbem55/fiAAhUIXiULP1tO+0ser2UJ+Qvnz3fGZ9pmrFnwhAAsCQCAJIAdGDQAgBkGfiQFqIQUCQAJAIAYgCWtBAXENACAJIQgMAQsgCUEBaiEIIAkxAABCxc/ZsvHluuonfiAAhUILiUKHla+vmLbem55/fiEACyAFIAlGDQADQCAIQQFqMQAAQsXP2bLx5brqJ34gCDEAAELFz9my8eW66id+IACFQguJQoeVr6+Ytt6bnn9+hUILiUKHla+vmLbem55/fiEAIAhBAmoiCCAHRw0ACwtBACAAQiGIIACFQs/W077Sx6vZQn4iAEIdiCAAhUL5893xmfaZqxZ+IgBCIIggAIUiAUI4hiABQoD+A4NCKIaEIAFCgID8B4NCGIYgAUKAgID4D4NCCIaEhCAAQgiIQoCAgPgPgyAAQhiIQoCA/AeDhCAAQiiIQoD+A4MgAEI4iISEhDcDgAkLBgBBgIkBCwIACwsLAQBBgAgLBFAAAAA=";
var hash$7 = "dc61b4e7";
var wasmJson$7 = {
name: name$7,
data: data$7,
hash: hash$7
};
const mutex$5 = new Mutex();
let wasmCache$5 = null;
const seedBuffer$2 = new ArrayBuffer(8);
function validateSeed$2(seed) {
if (!Number.isInteger(seed) || seed < 0 || seed > 0xFFFFFFFF) return new Error("Seed must be given as two valid 32-bit long unsigned integers (lo + high).");
return null;
}
function writeSeed$2(arr, low, high) {
// write in little-endian format
const buffer = new DataView(arr);
buffer.setUint32(0, low, true);
buffer.setUint32(4, high, true);
}
/**
* Calculates xxHash64 hash
* @param data Input data (string, Buffer or TypedArray)
* @param seedLow Lower 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
* @param seedHigh Higher 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
* @returns Computed hash as a hexadecimal string
*/ function xxhash64(data, seedLow = 0, seedHigh = 0) {
if (validateSeed$2(seedLow)) return Promise.reject(validateSeed$2(seedLow));
if (validateSeed$2(seedHigh)) return Promise.reject(validateSeed$2(seedHigh));
if (wasmCache$5 === null) return lockedCreate(mutex$5, wasmJson$7, 8).then((wasm)=>{
wasmCache$5 = wasm;
writeSeed$2(seedBuffer$2, seedLow, seedHigh);
wasmCache$5.writeMemory(new Uint8Array(seedBuffer$2));
return wasmCache$5.calculate(data);
});
try {
writeSeed$2(seedBuffer$2, seedLow, seedHigh);
wasmCache$5.writeMemory(new Uint8Array(seedBuffer$2));
const hash = wasmCache$5.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new xxHash64 hash instance
* @param seedLow Lower 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
* @param seedHigh Higher 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
*/ function createXXHash64(seedLow = 0, seedHigh = 0) {
if (validateSeed$2(seedLow)) return Promise.reject(validateSeed$2(seedLow));
if (validateSeed$2(seedHigh)) return Promise.reject(validateSeed$2(seedHigh));
return WASMInterface(wasmJson$7, 8).then((wasm)=>{
const instanceBuffer = new ArrayBuffer(8);
writeSeed$2(instanceBuffer, seedLow, seedHigh);
wasm.writeMemory(new Uint8Array(instanceBuffer));
wasm.init();
const obj = {
init: ()=>{
wasm.writeMemory(new Uint8Array(instanceBuffer));
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 32,
digestSize: 8
};
return obj;
});
}
var name$6 = "xxhash3";
var data$6 = "AGFzbQEAAAABNAhgAAF/YAR/f39/AGAHf39/f39/fwBgBH9+fn4BfmAEf39/fgF+YAN/f34BfmAAAGABfwADDg0AAQIDBAUFBQYHBgAGBQQBAQICBg4CfwFBwI4FC38AQcAJCwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACUhhc2hfSW5pdAAIC0hhc2hfVXBkYXRlAAkKSGFzaF9GaW5hbAAKDUhhc2hfR2V0U3RhdGUACw5IYXNoX0NhbGN1bGF0ZQAMClNUQVRFX1NJWkUDAQrNQg0FAEGACgvvAwEQfgJAIANFDQAgAUE4aiEBIAJBOGohAiAAKQMwIQQgACkDOCEFIAApAyAhBiAAKQMoIQcgACkDECEIIAApAxghCSAAKQMAIQogACkDCCELA0AgByABQWhqKQMAIgx8IAJBcGopAwAgAUFwaikDACINhSIHQiCIIAdC/////w+DfnwhByAJIAFBWGopAwAiDnwgAkFgaikDACABQWBqKQMAIg+FIglCIIggCUL/////D4N+fCEJIAsgAUFIaikDACIQfCACQVBqKQMAIAFBUGopAwAiEYUiC0IgiCALQv////8Pg358IQsgAkF4aikDACABQXhqKQMAIhKFIhNCIIggE0L/////D4N+IAR8IAEpAwAiE3whBCACQWhqKQMAIAyFIgxCIIggDEL/////D4N+IAZ8IA18IQYgAkFYaikDACAOhSIMQiCIIAxC/////w+DfiAIfCAPfCEIIAJBSGopAwAgEIUiDEIgiCAMQv////8Pg34gCnwgEXwhCiAFIBJ8IAIpAwAgE4UiBUIgiCAFQv////8Pg358IQUgAUHAAGohASACQQhqIQIgA0F/aiIDDQALIAAgCTcDGCAAIAo3AwAgACALNwMIIAAgBzcDKCAAIAg3AxAgACAFNwM4IAAgBjcDICAAIAQ3AzALC94CAgF/AX4CQCACIAEoAgAiB2siAiAESw0AIAAgAyAFIAdBA3RqIAIQASAAIAUgBmoiBykDACAAKQMAIghCL4iFIAiFQrHz3fEJfjcDACAAIAcpAwggACkDCCIIQi+IhSAIhUKx893xCX43AwggACAHKQMQIAApAxAiCEIviIUgCIVCsfPd8Ql+NwMQIAAgBykDGCAAKQMYIghCL4iFIAiFQrHz3fEJfjcDGCAAIAcpAyAgACkDICIIQi+IhSAIhUKx893xCX43AyAgACAHKQMoIAApAygiCEIviIUgCIVCsfPd8Ql+NwMoIAAgBykDMCAAKQMwIghCL4iFIAiFQrHz3fEJfjcDMCAAIAcpAzggACkDOCIIQi+IhSAIhUKx893xCX43AzggACADIAJBBnRqIAUgBCACayIHEAEgASAHNgIADwsgACADIAUgB0EDdGogBBABIAEgByAEajYCAAuFAQEBfyACIAGFIAOnIgRBGHQgBEGA/gNxQQh0ciAEQQh2QYD+A3EgBEEYdnJyrUIghiADhX1BADUCgIwBQiCGIABB/IsBajUCAISFIgNCMYkgA0IYiYUgA4VCpb7j9NGMh9mff34iA0IjiCAArXwgA4VCpb7j9NGMh9mff34iA0IciCADhQtnACACIAFzrSADfCIDQiGIQQAtAICMAUEQdCAAQQh0ciAAQQF2QYCMAWotAABBGHRyIABB/4sBai0AAHKthSADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC4kDAQR+AkAgAEEJSQ0AQQApA4CMASABKQMgIAEpAxiFIAJ8hSIDQjiGIANCgP4Dg0IohoQgA0KAgPwHg0IYhiADQoCAgPgPg0IIhoSEIANCCIhCgICA+A+DIANCGIhCgID8B4OEIANCKIhCgP4DgyADQjiIhISEIACtfCAAQfiLAWopAwAgASkDMCABKQMohSACfYUiAnwgAkL/////D4MiBCADQiCIIgV+IgZC/////w+DIAJCIIgiAiADQv////8PgyIDfnwgBCADfiIDQiCIfCIEQiCGIANC/////w+DhCAGQiCIIAIgBX58IARCIIh8hXwiA0IliCADhUL5893xmfKZqxZ+IgNCIIggA4UPCwJAIABBBEkNACAAIAFBCGopAwAgAUEQaikDACACEAMPCwJAIABFDQAgACABKAIAIAFBBGooAgAgAhAEDwsgASkDOCABKQNAhSAChSIDQiGIIAOFQs/W077Sx6vZQn4iA0IdiCADhUL5893xmfaZqxZ+IgNCIIggA4UL3ggBBn4gAK1Ch5Wvr5i23puef34hAwJAIABBIUkNAAJAIABBwQBJDQACQCAAQeEASQ0AIAEpA2ggAn1BACkDuIwBhSIEQv////8PgyIFIAEpA2AgAnxBACkDsIwBhSIGQiCIIgd+IghC/////w+DIARCIIgiBCAGQv////8PgyIGfnwgBSAGfiIFQiCIfCIGQiCGIAVC/////w+DhCAIQiCIIAQgB358IAZCIIh8hSADfCABKQN4IAJ9IABByIsBaikDAIUiA0L/////D4MiBCABKQNwIAJ8IABBwIsBaikDAIUiBUIgiCIGfiIHQv////8PgyADQiCIIgMgBUL/////D4MiBX58IAQgBX4iBEIgiHwiBUIghiAEQv////8Pg4QgB0IgiCADIAZ+fCAFQiCIfIV8IQMLIAEpA0ggAn1BACkDqIwBhSIEQv////8PgyIFIAEpA0AgAnxBACkDoIwBhSIGQiCIIgd+IghC/////w+DIARCIIgiBCAGQv////8PgyIGfnwgBSAGfiIFQiCIfCIGQiCGIAVC/////w+DhCAIQiCIIAQgB358IAZCIIh8hSADfCABKQNYIAJ9IABB2IsBaikDAIUiA0L/////D4MiBCABKQNQIAJ8IABB0IsBaikDAIUiBUIgiCIGfiIHQv////8PgyADQiCIIgMgBUL/////D4MiBX58IAQgBX4iBEIgiHwiBUIghiAEQv////8Pg4QgB0IgiCADIAZ+fCAFQiCIfIV8IQMLIAEpAyggAn1BACkDmIwBhSIEQv////8PgyIFIAEpAyAgAnxBACkDkIwBhSIGQiCIIgd+IghC/////w+DIARCIIgiBCAGQv////8PgyIGfnwgBSAGfiIFQiCIfCIGQiCGIAVC/////w+DhCAIQiCIIAQgB358IAZCIIh8hSADfCABKQM4IAJ9IABB6IsBaikDAIUiA0L/////D4MiBCABKQMwIAJ8IABB4IsBaikDAIUiBUIgiCIGfiIHQv////8PgyADQiCIIgMgBUL/////D4MiBX58IAQgBX4iBEIgiHwiBUIghiAEQv////8Pg4QgB0IgiCADIAZ+fCAFQiCIfIV8IQMLIAEpAwggAn1BACkDiIwBhSIEQv////8PgyIFIAEpAwAgAnxBACkDgIwBhSIGQiCIIgd+IghC/////w+DIARCIIgiBCAGQv////8PgyIGfnwgBSAGfiIFQiCIfCIGQiCGIAVC/////w+DhCAIQiCIIAQgB358IAZCIIh8hSADfCABKQMYIAJ9IABB+IsBaikDAIUiA0L/////D4MiBCABKQMQIAJ8IABB8IsBaikDAIUiAkIgiCIFfiIGQv////8PgyADQiCIIgMgAkL/////D4MiAn58IAQgAn4iAkIgiHwiBEIghiACQv////8Pg4QgBkIgiCADIAV+fCAEQiCIfIV8IgJCJYggAoVC+fPd8ZnymasWfiICQiCIIAKFC/wKBAF/BX4CfwF+QQAhAyABKQN4IAJ9QQApA/iMAYUiBEL/////D4MiBSABKQNwIAJ8QQApA/CMAYUiBkIgiCIHfiIIQv////8PgyAEQiCIIgQgBkL/////D4MiBn58IAUgBn4iBUIgiHwiBkIghiAFQv////8Pg4QgCEIgiCAEIAd+fCAGQiCIfIUgASkDaCACfUEAKQPojAGFIgRC/////w+DIgUgASkDYCACfEEAKQPgjAGFIgZCIIgiB34iCEL/////D4MgBEIgiCIEIAZC/////w+DIgZ+fCAFIAZ+IgVCIIh8IgZCIIYgBUL/////D4OEIAhCIIggBCAHfnwgBkIgiHyFIAEpA1ggAn1BACkD2IwBhSIEQv////8PgyIFIAEpA1AgAnxBACkD0IwBhSIGQiCIIgd+IghC/////w+DIARCIIgiBCAGQv////8PgyIGfnwgBSAGfiIFQiCIfCIGQiCGIAVC/////w+DhCAIQiCIIAQgB358IAZCIIh8hSABKQNIIAJ9QQApA8iMAYUiBEL/////D4MiBSABKQNAIAJ8QQApA8CMAYUiBkIgiCIHfiIIQv////8PgyAEQiCIIgQgBkL/////D4MiBn58IAUgBn4iBUIgiHwiBkIghiAFQv////8Pg4QgCEIgiCAEIAd+fCAGQiCIfIUgASkDOCACfUEAKQO4jAGFIgRC/////w+DIgUgASkDMCACfEEAKQOwjAGFIgZCIIgiB34iCEL/////D4MgBEIgiCIEIAZC/////w+DIgZ+fCAFIAZ+IgVCIIh8IgZCIIYgBUL/////D4OEIAhCIIggBCAHfnwgBkIgiHyFIAEpAyggAn1BACkDqIwBhSIEQv////8PgyIFIAEpAyAgAnxBACkDoIwBhSIGQiCIIgd+IghC/////w+DIARCIIgiBCAGQv////8PgyIGfnwgBSAGfiI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sLIAZFDQEDQCADIAQtAAA6AAAgA0EBaiEDIARBAWohBCAGQX9qIgYNAAwCCwsgAUUNAAJAAkAgAUEHcSIGDQAgASECDAELIAFBeHEhAgNAIAMgBC0AADoAACADQQFqIQMgBEEBaiEEIAZBf2oiBg0ACwsCQCABQQhJDQADQCADIAQpAAA3AAAgA0EIaiEDIARBCGohBCACQXhqIgINAAsLQQAoAoCOASAAaiECC0EAIAI2AoCOAQusEwUEfwJ+AX8VfgV/IwAiACEBIABBgAFrQUBxIgIkAEEAKAKwjgEiAEHAigEgABshAwJAAkBBACkDkI4BIgRC8QFUDQAgAkEAKQOAigE3AwAgAkEAKQOIigE3AwggAkEAKQOQigE3AxAgAkEAKQOYigE3AxggAkEAKQOgigE3AyAgAkEAKQOoigE3AyggAkEAKQOwigEiBDcDMCACQQApA7iKASIFNwM4AkACQEEAKAKAjgEiBkHAAEkNACACQQAoAoiOATYCQCACIAJBwABqQQAoApiOAUGAjAEgBkF/akEGdiADQQAoApyOASIAEAIgAyAAaiIAQXlqKQMAIQcgAEEJaikDACEIIABBGWopAwAhCSAGQcCLAWopAwAhBCAAQQFqKQMAIQogBkHIiwFqKQMAIQUgBkHQiwFqKQMAIQsgAEERaikDACEMIAZB2IsBaikDACENIAZB4IsBaikDACEOIABBIWopAwAhDyAGQeiLAWopAwAhECAAQSlqKQMAIREgAikDACESIAIpAxAhEyACKQMgIRQgAikDCCEVIAIpAxghFiACKQMoIRcgAikDMCEYIAIgAikDOCAGQfCLAWopAwAiGXwgAEExaikDACAGQfiLAWopAwAiGoUiG0IgiCAbQv////8Pg358NwM4IAIgGiAYIBEgGYUiEUIgiCARQv////8Pg358fDcDMCAXIA58IA8gEIUiD0IgiCAPQv////8Pg358IQ8gFiALfCAMIA2FIgxCIIggDEL/////D4N+fCEMIBUgBHwgCiAFhSIKQiCIIApC/////w+DfnwhCiAQIBQgCSAOhSIOQiCIIA5C/////w+Dfnx8IRAgDSATIAggC4UiC0IgiCALQv////8Pg358fCEIIA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A2ghByACIAUgAikDcCIafCAAQTFqKQMAIAIpA3giBYUiG0IgiCAbQv////8Pg358NwM4IAIgBSATIBqFIhNCIIggE0L/////D4N+IAR8fDcDMCAZIBB8IA8gB4UiBEIgiCAEQv////8Pg358IQ8gGCAOfCAMIAiFIgRCIIggBEL/////D4N+fCEMIBcgC3wgCiANhSIEQiCIIARC/////w+DfnwhCiAHIBYgEiAQhSIEQiCIIARC/////w+Dfnx8IRAgCCAVIBEgDoUiBEIgiCAEQv////8Pg358fCEIIA0gFCAJIAuFIgRCIIggBEL/////D4N+fHwhBwsgAykDQyACKQM4hSIEQv////8PgyIFIAMpAzsgAikDMIUiC0IgiCINfiIOQv////8PgyAEQiCIIgQgC0L/////D4MiC358IAUgC34iBUIgiHwiC0IghiAFQv////8Pg4QgDkIgiCAEIA1+fCALQiCIfIUgAykDMyAPhSIEQv////8PgyIFIAMpAysgEIUiC0IgiCINfiIOQv////8PgyAEQiCIIgQgC0L/////D4MiC358IAUgC34iBUIgiHwiC0IghiAFQv////8Pg4QgDkIgiCAEIA1+fCALQiCIfIUgAykDIyAMhSIEQv////8PgyIFIAMpAxsgCIUiC0IgiCINfiIOQv////8PgyAEQiCIIgQgC0L/////D4MiC358IAUgC34iBUIgiHwiC0IghiAFQv////8Pg4QgDkIgiCAEIA1+fCALQiCIfIUgAykDEyAKhSIEQv////8PgyIFIAMpAwsgB4UiC0IgiCINfiIOQv////8PgyAEQiCIIgQgC0L/////D4MiC358IAUgC34iBUIgiHwiC0IghiAFQv////8Pg4QgDkIgiCAEIA1+fCALQiCIfIVBACkDkI4BQoeVr6+Ytt6bnn9+fHx8fCIEQiWIIASFQvnz3fGZ8pmrFn4iBEIgiCAEhSEEDAELIASnIQACQEEAKQOgjgEiBFANAAJAIABBEEsNACAAQYAIIAQQBSEEDAILAkAgAEGAAUsNACAAQYAIIAQQBiEEDAILIABBgAggBBAHIQQMAQsCQCAAQRBLDQAgACADQgAQBSEEDAELAkAgAEGAAUsNACAAIANCABAGIQQMAQsgACADQgAQByEEC0EAIARCOIYgBEKA/gODQiiGhCAEQoCA/AeDQhiGIARCgICA+A+DQgiGhIQgBEIIiEKAgID4D4MgBEIYiEKAgPwHg4QgBEIoiEKA/gODIARCOIiEhIQ3A4AKIAEkAAsGAEGAigELAgALC8wBAQBBgAgLxAG4/mw5I6RLvnwBgSz3Ia0c3tRt6YOQl9tyQKSkt7NnH8t55k7MwOV4glrQfcz/ciG4CEZ090MkjuA1kOaBOiZMPChSu5HDAMuI0GWLG1Muo3FkSJeiDflOOBnvRqnerNio+nY/45w0P/ncu8fHC08dilHgS820WTHIn37J2XhzZOrFrIM00+vDxYGg//oTY+sXDd1Rt/DaSdMWVSYp1GieKxa+WH1HofyP+LjRetAxzkXLOo+VFgQor9f7yrtLQH5AAgAA";
var hash$6 = "0dca92d1";
var wasmJson$6 = {
name: name$6,
data: data$6,
hash: hash$6
};
const mutex$4 = new Mutex();
let wasmCache$4 = null;
const seedBuffer$1 = new ArrayBuffer(8);
function validateSeed$1(seed) {
if (!Number.isInteger(seed) || seed < 0 || seed > 0xFFFFFFFF) return new Error("Seed must be given as two valid 32-bit long unsigned integers (lo + high).");
return null;
}
function writeSeed$1(arr, low, high) {
// write in little-endian format
const buffer = new DataView(arr);
buffer.setUint32(0, low, true);
buffer.setUint32(4, high, true);
}
/**
* Calculates xxHash3 hash
* @param data Input data (string, Buffer or TypedArray)
* @param seedLow Lower 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
* @param seedHigh Higher 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
* @returns Computed hash as a hexadecimal string
*/ function xxhash3(data, seedLow = 0, seedHigh = 0) {
if (validateSeed$1(seedLow)) return Promise.reject(validateSeed$1(seedLow));
if (validateSeed$1(seedHigh)) return Promise.reject(validateSeed$1(seedHigh));
if (wasmCache$4 === null) return lockedCreate(mutex$4, wasmJson$6, 8).then((wasm)=>{
wasmCache$4 = wasm;
writeSeed$1(seedBuffer$1, seedLow, seedHigh);
wasmCache$4.writeMemory(new Uint8Array(seedBuffer$1));
return wasmCache$4.calculate(data);
});
try {
writeSeed$1(seedBuffer$1, seedLow, seedHigh);
wasmCache$4.writeMemory(new Uint8Array(seedBuffer$1));
const hash = wasmCache$4.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new xxHash3 hash instance
* @param seedLow Lower 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
* @param seedHigh Higher 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
*/ function createXXHash3(seedLow = 0, seedHigh = 0) {
if (validateSeed$1(seedLow)) return Promise.reject(validateSeed$1(seedLow));
if (validateSeed$1(seedHigh)) return Promise.reject(validateSeed$1(seedHigh));
return WASMInterface(wasmJson$6, 8).then((wasm)=>{
const instanceBuffer = new ArrayBuffer(8);
writeSeed$1(instanceBuffer, seedLow, seedHigh);
wasm.writeMemory(new Uint8Array(instanceBuffer));
wasm.init();
const obj = {
init: ()=>{
wasm.writeMemory(new Uint8Array(instanceBuffer));
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 512,
digestSize: 8
};
return obj;
});
}
var name$5 = "xxhash128";
var data$5 = "AGFzbQEAAAABKwdgAAF/YAR/f39/AGAHf39/f39/fwBgA39/fgF+YAR/f39+AGAAAGABfwADDQwAAQIDBAQEBQYFAAUFBAEBAgIGDgJ/AUHAjgULfwBBwAkLB3AIBm1lbW9yeQIADkhhc2hfR2V0QnVmZmVyAAAJSGFzaF9Jbml0AAcLSGFzaF9VcGRhdGUACApIYXNoX0ZpbmFsAAkNSGFzaF9HZXRTdGF0ZQAKDkhhc2hfQ2FsY3VsYXRlAAsKU1RBVEVfU0laRQMBCuxNDAUAQYAKC+8DARB+AkAgA0UNACABQThqIQEgAkE4aiECIAApAzAhBCAAKQM4IQUgACkDICEGIAApAyghByAAKQMQIQggACkDGCEJIAApAwAhCiAAKQMIIQsDQCAHIAFBaGopAwAiDHwgAkFwaikDACABQXBqKQMAIg2FIgdCIIggB0L/////D4N+fCEHIAkgAUFYaikDACIOfCACQWBqKQMAIAFBYGopAwAiD4UiCUIgiCAJQv////8Pg358IQkgCyABQUhqKQMAIhB8IAJBUGopAwAgAUFQaikDACIRhSILQiCIIAtC/////w+DfnwhCyACQXhqKQMAIAFBeGopAwAiEoUiE0IgiCATQv////8Pg34gBHwgASkDACITfCEEIAJBaGopAwAgDIUiDEIgiCAMQv////8Pg34gBnwgDXwhBiACQVhqKQMAIA6FIgxCIIggDEL/////D4N+IAh8IA98IQggAkFIaikDACAQhSIMQiCIIAxC/////w+DfiAKfCARfCEKIAUgEnwgAikDACAThSIFQiCIIAVC/////w+DfnwhBSABQcAAaiEBIAJBCGohAiADQX9qIgMNAAsgACAJNwMYIAAgCjcDACAAIAs3AwggACAHNwMoIAAgCDcDECAAIAU3AzggACAGNwMgIAAgBDcDMAsL3gICAX8BfgJAIAIgASgCACIHayICIARLDQAgACADIAUgB0EDdGogAhABIAAgBSAGaiIHKQMAIAApAwAiCEIviIUgCIVCsfPd8Ql+NwMAIAAgBykDCCAAKQMIIghCL4iFIAiFQrHz3fEJfjcDCCAAIAcpAxAgACkDECIIQi+IhSAIhUKx893xCX43AxAgACAHKQMYIAApAxgiCEIviIUgCIVCsfPd8Ql+NwMYIAAgBykDICAAKQMgIghCL4iFIAiFQrHz3fEJfjcDICAAIAcpAyggACkDKCIIQi+IhSAIhUKx893xCX43AyggACAHKQMwIAApAzAiCEIviIUgCIVCsfPd8Ql+NwMwIAAgBykDOCAAKQM4IghCL4iFIAiFQrHz3fEJfjcDOCAAIAMgAkEGdGogBSAEIAJrIgcQASABIAc2AgAPCyAAIAMgBSAHQQN0aiAEEAEgASAHIARqNgIAC+0DAQV+IAEpAzggACkDOIUiA0L/////D4MiBCABKQMwIAApAzCFIgVCIIgiBn4iB0L/////D4MgA0IgiCIDIAVC/////w+DIgV+fCAEIAV+IgRCIIh8IgVCIIYgBEL/////D4OEIAdCIIggAyAGfnwgBUIgiHyFIAEpAyggACkDKIUiA0L/////D4MiBCABKQMgIAApAyCFIgVCIIgiBn4iB0L/////D4MgA0IgiCIDIAVC/////w+DIgV+fCAEIAV+IgRCIIh8IgVCIIYgBEL/////D4OEIAdCIIggAyAGfnwgBUIgiHyFIAEpAxggACkDGIUiA0L/////D4MiBCABKQMQIAApAxCFIgVCIIgiBn4iB0L/////D4MgA0IgiCIDIAVC/////w+DIgV+fCAEIAV+IgRCIIh8IgVCIIYgBEL/////D4OEIAdCIIggAyAGfnwgBUIgiHyFIAEpAwggACkDCIUiA0L/////D4MiBCABKQMAIAApAwCFIgVCIIgiBn4iB0L/////D4MgA0IgiCIDIAVC/////w+DIgV+fCAEIAV+IgRCIIh8IgVCIIYgBEL/////D4OEIAdCIIggAyAGfnwgBUIgiHyFIAJ8fHx8IgJCJYggAoVC+fPd8ZnymasWfiICQiCIIAKFC7oIAgV+A38CQCABQQlJDQAgACABQfiLAWopAwAiBCACKQM4IAIpAzCFIAN8hSIFQv////8Pg0L3lK+vCH4gBUKAgICAcIN8QQApA4CMASACKQMoIAIpAyCFIAN9hSAEhSIDQiCIIgRCsfPd8Ql+fCAEQoeVr68IfiIEQiCIfCAEQv////8PgyADQv////8PgyIDQrHz3fEJfnwgA0KHla+vCH4iBEIgiHwiBUIgiHwiA0I4hiADQoD+A4NCKIaEIANCgID8B4NCGIYgA0KAgID4D4NCCIaEhCADQgiIQoCAgPgPgyADQhiIQoCA/AeDhCADQiiIQoD+A4MgA0I4iISEhCAEQv////8PgyABQX9qrUI2hoQgBUIghnyFIgRCIIgiBULP1tO+An4iBkL/////D4MgBEL/////D4MiBEK93MqVDH58IARCz9bTvgJ+IgRCIIh8IgdCIIYiCEIliCAIIARC/////w+DhIVC+fPd8ZnymasWfiIEQiCIIASFNwMAIAAgBUK93MqVDH4gA0LP1tO+0ser2UJ+fCAGQi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gDH58IA1C/////w+DIAcgC0L/////D4MiC358IAkgC34iB0IgiHwiCUIgiHxBACkDuIwBIgtBACkDsIwBIgx8hSAJQiCGIAdC/////w+DhIUhByACQegAaikDACADfSALhSIJQv////8PgyILIAIpA2AgA3wgDIUiDEIgiCINfiIGQv////8PgyAJQiCIIgkgDEL/////D4MiDH58IAsgDH4iC0IgiHwiDEIghiALQv////8Pg4QgBkIgiCAJIA1+fCAMQiCIfIUgBXwgCCAKfIUhBQsgAkHYAGopAwAgA30gAUHYiwFqKQMAIgiFIglC/////w+DIgogAikDUCADfCABQdCLAWopAwAiC4UiDEIgiCINfiIGQv////8PgyAJQiCIIgkgDEL/////D4MiDH58IAogDH4iCkIgiHwiDEIghiAKQv////8Pg4QgBkIgiCAJIA1+fCAMQiCIfIUgB3xBACkDqIwBIglBACkDoIwBIgp8hSEHIAJByABqKQMAIAN9IAmFIglC/////w+DIgwgAikDQCADfCAKhSIKQiCIIg1+IgZC/////w+DIAlCIIgiCSAKQv////8PgyIKfnwgDCAKfiIKQiCIfCIMQiCGIApC/////w+DhCAGQiCIIAkgDX58IAxCIIh8hSAFfCAIIAt8hSEFCyACQThqKQMAIAN9IAFB6IsBaikDACIIhSIJQv////8PgyIKIAIpAzAgA3wgAUHgiwFqKQMAIguFIgxCIIgiDX4iBkL/////D4MgCUIgiCIJIAxC/////w+DIgx+fCAKIAx+IgpCIIh8IgxCIIYgCkL/////D4OEIAZCIIggCSANfnwgDEIgiHyFIAd8QQApA5iMASIHQQApA5CMASIJfIUhBiACQShqKQMAIAN9IAeFIgdC/////w+DIgogAikDICADfCAJhSIJQiCIIgx+Ig1C/////w+DIAdCIIgiByAJQv////8PgyIJfnwgCiAJfiIJQiCIfCIKQiCGIAlC/////w+DhCANQiCIIAcgDH58IApCIIh8hSAFfCAIIAt8hSEFCyAAIAJBGGopAwAgA30gAUH4iwFqKQMAIgeFIghC/////w+DIgkgAikDECADfCABQfCLAWopAwAiCoUiC0IgiCIMfiINQv////8PgyAIQiCIIgggC0L/////D4MiC358IAkgC34iCUIgiHwiC0IghiAJQv////8Pg4QgDUIgiCAIIAx+fCALQiCIfIUgBnxBACkDiIwBIghBACkDgIwBIgl8hSILIAJBCGopAwAgA30gCIUiCEL/////D4MiDCACKQMAIAN8IAmFIglCIIgiDX4iBkL/////D4MgCEIgiCIIIAlC/////w+DIgl+fCAMIAl+IglCIIh8IgxCIIYgCUL/////D4OEIAZCIIggCCANfnwgDEIgiHyFIAV8IAcgCnyFIgV8IgdCJYggB4VC+fPd8ZnymasWfiIHQiCIIAeFNwMAIABCACAFQoeVr6+Ytt6bnn9+IAQgA31Cz9bTvtLHq9lCfnwgC0Lj3MqV/M7y9YV/fnwiA0IliCADhUL5893xmfKZqxZ+IgNCIIggA4V9NwMIC6EPAwF/FH4Cf0EAIQQgAkH4AGopAwAgA31BACkD+IwBIgWFIgZC/////w+DIgcgAikDcCADfEEAKQPwjAEiCIUiCUIgiCIKfiILQv////8PgyAGQiCIIgYgCUL/////D4MiCX58IAcgCX4iB0IgiHwiCUIghiAHQv////8Pg4QgC0IgiCAGIAp+fCAJQiCIfIUgAkHYAGopAwAgA31BACkD2IwBIgeFIgZC/////w+DIgkgAikDUCADfEEAKQPQjAEiCoUiC0IgiCIMfiINQv////8PgyAGQiCIIgYgC0L/////D4MiC358IAkgC34iCUIgiHwiC0IghiAJQv////8Pg4QgDUIgiCAGIAx+fCALQiCIfIUgAkE4aikDACADfUEAKQO4jAEiCYUiBkL/////D4MiCyACKQMwIAN8QQApA7CMASIMhSINQiCIIg5+Ig9C/////w+DIAZCIIgiBiANQv////8PgyINfnwgCyANfiILQiCIfCINQiCGIAtC/////w+DhCAPQiCIIAYgDn58IA1CIIh8hSACQRhqKQMAIAN9QQApA5iMASILhSIGQv////8PgyINIAIpAxAgA3xBACkDkIwBIg6FIg9CIIgiEH4iEUL/////D4MgBkIgiCIGIA9C/////w+DIg9+fCANIA9+Ig1CIIh8Ig9CIIYgDUL/////D4OEIBFCIIggBiAQfnwgD0IgiHyFQQApA4iMASINQQApA4CMASIPfIV8QQApA6iMASIQQQApA6CMASIRfIV8QQApA8iMASISQQApA8CMASITfIV8QQApA+iMASIUQQApA+CMASIVfIUiBkIliCAGhUL5893xmfKZqxZ+IgZCIIggBoUhBiACQegAaikDACADfSAUhSIUQv////8PgyIWIAIpA2AgA3wgFYUiFUIgiCIXfiIYQv////8PgyAUQiCIIhQgFUL/////D4MiFX58IBYgFX4iFUIgiHwiFkIghiAVQv////8Pg4QgGEIgiCAUIBd+fCAWQiCIfIUgAkHIAGopAwAgA30gEoUiEkL/////D4MiFCACKQNAIAN8IBOFIhNCIIgiFX4iFkL/////D4MgEkIgiCISIBNC/////w+DIhN+fCAUIBN+IhNCIIh8IhRCIIYgE0L/////D4OEIBZCIIggEiAVfnwgFEIgiHyFIAJBKGopAwAgA30gEIUiEEL/////D4MiEiACKQMgIAN8IBGFIhFCIIgiE34iFEL/////D4MgEEIgiCIQIBFC/////w+DIhF+fCASIBF+IhFCIIh8IhJCIIYgEUL/////D4OEIBRCIIggECATfnwgEkIgiHyFIAJBCGopAwAgA30gDYUiDUL/////D4MiECACKQMAIAN8IA+FIg9CIIgiEX4iEkL/////D4MgDUIgiCINIA9C/////w+DIg9+fCAQIA9+Ig9CIIh8IhBCIIYgD0L/////D4OEIBJCIIggDSARfnwgEEIgiHyFIAGtIg9Ch5Wvr5i23puef358IAsgDnyFfCAJIAx8hXwgByAKfIV8IAUgCHyFIgVCJYggBYVC+fPd8ZnymasWfiIFQiCIIAWFIQUCQCABQaABSA0AIAFBBXZBfGohGQNAIAIgBGoiGkEbaikDACADfSAEQZiNAWopAwAiB4UiCEL/////D4MiCSAaQRNqKQMAIAN8IARBkI0BaikDACIKhSILQiCIIgx+Ig1C/////w+DIAhCIIgiCCALQv////8PgyILfnwgCSALfiIJQiCIfCILQiCGIAlC/////w+DhCANQiCIIAggDH58IAtCIIh8hSAGfCAEQYiNAWopAwAiCCAEQYCNAWopAwAiCXyFIQYgGkELaikDAC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AA3AAAgA0EIaiEDIARBCGohBCACQXhqIgINAAsLQQAoAoCOASAAaiECC0EAIAI2AoCOAQuQEQYEfwJ+AX8DfgV/An4jACIAIQEgAEGAAWtBQHEiAiQAQQAoArCOASIAQcCKASAAGyEDAkACQEEAKQOQjgEiBELxAVQNACACQQApA4CKATcDACACQQApA4iKATcDCCACQQApA5CKATcDECACQQApA5iKATcDGCACQQApA6CKATcDICACQQApA6iKATcDKCACQQApA7CKASIENwMwIAJBACkDuIoBIgU3AzgCQAJAQQAoAoCOASIGQcAASQ0AIAJBACgCiI4BNgJAIAIgAkHAAGpBACgCmI4BQYCMASAGQX9qQQZ2IANBACgCnI4BIgAQAiACIAIpAwggBkHAiwFqKQMAIgR8IAMgAGoiAEEBaikDACAGQciLAWopAwAiBYUiB0IgiCAHQv////8Pg358NwMIIAIgAikDGCAGQdCLAWopAwAiB3wgAEERaikDACAGQdiLAWopAwAiCIUiCUIgiCAJQv////8Pg358NwMYIAIgBSAEIABBeWopAwCFIgRCIIggBEL/////D4N+IAIpAwB8fDcDACACIAggByAAQQlqKQMAhSIEQiCIIARC/////w+DfiACKQMQfHw3AxAgAEEZaikDACEEIAIpAyAhBSACIAIpAyggBkHgiwFqKQMAIgd8IABBIWopAwAgBkHoiwFqKQMAIgiFIglCIIggCUL/////D4N+fDcDKCACIAggBSAEIAeFIgRCIIggBEL/////D4N+fHw3AyAgAiACKQM4IAZB8IsBaikDACIEfCAAQTFqKQMAIAZB+IsBaikDACIFhSIHQiCIIAdC/////w+Dfnw3AzggAiAFIAQgAEEpaikDAIUiBEIgiCAEQv////8Pg34gAikDMHx8NwMwDAELIAZBwI0BaiEKQcAAIAZrIQsgAkHAAGohAAJAAkACQCAGQThNDQAgCyEMDAELAkACQEE4IAZrIg1BA3ZBAWpBB3EiDA0AIAJBwABqIQAgCyEMDAELIAJBwABqIQAgDEEDdCIOIQwDQCAAIAopAwA3AwAgAEEIaiEAIApBCGohCiAMQXhqIgwNAAtBwAAgBiAOamshDAsCQCANQThJDQADQCAAIAopAwA3AwAgAEEIaiAKQQhqKQMANwMAIABBEGogCkEQaikDADcDACAAQRhqIApBGGopAwA3AwAgAEEgaiAKQSBqKQMANwMAIABBKGogCkEoaikDADcDACAAQTBqIApBMGopAwA3AwAgAEE4aiAKQThqKQMANwMAIABBwABqIQAgCkHAAGohCiAMQUBqIgxBB0sNAAsLIAxFDQELIAxBf2ohDgJAIAxBB3EiDUUNACAMQXhxIQwDQCAAIAotAAA6AAAgAEEBaiEAIApBAWohCiANQX9qIg0NAAsLIA5BB0kNAANAIAAgCikAADcAACAAQQhqIQAgCkEIaiEKIAxBeGoiDA0ACwsgAkHAAGogC2ohCkGAjAEhAAJAAkACQCAGQQhJDQACQCAGQThqQQN2QQFqQQdxIgwNAAwCCyAMQQN0IQ1BgIwBIQADQCAKIAApAwA3AwAgCkEIaiEKIABBCGohACAMQX9qIgwNAAsgBiANayEGCyAGRQ0BAkAgBkEHcSINDQAgBiEMDAELIAZBeHEhDANAIAogAC0AADoAACAKQQFqIQogAEEBaiEAIA1Bf2oiDQ0ACwsgBkEISQ0AA0AgCiAAKQAANwAAIApBCGohCiAAQQhqIQAgDEF4aiIMDQALCyACIAIpAwggAikDQCIHfCADQQAoApyOAWoiAEEBaikDACACKQNIIgiFIglCIIggCUL/////D4N+fDcDCCACIAIpAxggAikDUCIJfCAAQRFqKQMAIAIpA1giD4UiEEIgiCAQQv////8Pg358NwMYIAIgCCAHIABBeWopAwCFIgdCIIggB0L/////D4N+IAIpAwB8fDcDACACIA8gCSAAQQlqKQMAhSIHQiCIIAdC/////w+DfiACKQMQfHw3AxAgAEEZaikDACEHIAIpAyAhCCACIAIpAyggAikDYCIJfCAAQSFqKQMAIAIpA2giD4UiEEIgiCAQQv////8Pg358NwMoIAIgDyAIIAcgCYUiB0IgiCAHQv////8Pg358fDcDICACIAUgAikDcCIHfCAAQTFqKQMAIAIpA3giBYUiCEIgiCAIQv////8Pg358NwM4IAIgBSAHIABBKWopAwCFIgdCIIggB0L/////D4N+IAR8fDcDMAsgAiACIANBC2pBACkDkI4BIgRCh5Wvr5i23puef34QAzcDQCACIAIgA0EAKAKcjgFqQXVqIARCz9bTvtLHq9lCfkJ/hRADNwNIDAELIASnIQACQEEAKQOgjgEiBFANAAJAIABBEEsNACACQcAAaiAAQYAIIAQQBAwCCwJAIABBgAFLDQAgAkHAAGogAEGACCAEEAUMAgsgAkHAAGogAEGACCAEEAYMAQsCQCAAQRBLDQAgAkHAAGogACADQgAQBAwBCwJAIABBgAFLDQAgAkHAAGogACADQgAQBQwBCyACQcAAaiAAIANCABAGC0EAIAIpA3A3A7gKQQAgAikDYDcDqApBACACKQNQNwOYCkEAIAJB+ABqKQMANwPACkEAIAJB6ABqKQMANwOwCkEAIAJB2ABqKQMANwOgCkEAIAIpA0giBEI4hiAEQoD+A4NCKIaEIARCgID8B4NCGIYgBEKAgID4D4NCCIaEhCAEQgiIQoCAgPgPgyAEQhiIQoCA/AeDhCAEQiiIQoD+A4MgBEI4iISEhCIENwOACkEAIAQ3A5AKQQAgAikDQCIEQjiGIARCgP4Dg0IohoQgBEKAgPwHg0IYhiAEQoCAgPgPg0IIhoSEIARCCIhCgICA+A+DIARCGIhCgID8B4OEIARCKIhCgP4DgyAEQjiIhISENwOICiABJAALBgBBgIoBCwIACwvMAQEAQYAIC8QBuP5sOSOkS758AYEs9yGtHN7UbemDkJfbckCkpLezZx/LeeZOzMDleIJa0H3M/3IhuAhGdPdDJI7gNZDmgTomTDwoUruRwwDLiNBlixtTLqNxZEiXog35TjgZ70ap3qzYqPp2P+OcND/53LvHxwtPHYpR4EvNtFkxyJ9+ydl4c2TqxayDNNPrw8WBoP/6E2PrFw3dUbfw2knTFlUmKdRonisWvlh9R6H8j/i40XrQMc5FyzqPlRYEKK/X+8q7S0B+QAIAAA==";
var hash$5 = "1f682d91";
var wasmJson$5 = {
name: name$5,
data: data$5,
hash: hash$5
};
const mutex$3 = new Mutex();
let wasmCache$3 = null;
const seedBuffer = new ArrayBuffer(8);
function validateSeed(seed) {
if (!Number.isInteger(seed) || seed < 0 || seed > 0xFFFFFFFF) return new Error("Seed must be given as two valid 32-bit long unsigned integers (lo + high).");
return null;
}
function writeSeed(arr, low, high) {
// write in little-endian format
const buffer = new DataView(arr);
buffer.setUint32(0, low, true);
buffer.setUint32(4, high, true);
}
/**
* Calculates xxHash128 hash
* @param data Input data (string, Buffer or TypedArray)
* @param seedLow Lower 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
* @param seedHigh Higher 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
* @returns Computed hash as a hexadecimal string
*/ function xxhash128(data, seedLow = 0, seedHigh = 0) {
if (validateSeed(seedLow)) return Promise.reject(validateSeed(seedLow));
if (validateSeed(seedHigh)) return Promise.reject(validateSeed(seedHigh));
if (wasmCache$3 === null) return lockedCreate(mutex$3, wasmJson$5, 16).then((wasm)=>{
wasmCache$3 = wasm;
writeSeed(seedBuffer, seedLow, seedHigh);
wasmCache$3.writeMemory(new Uint8Array(seedBuffer));
return wasmCache$3.calculate(data);
});
try {
writeSeed(seedBuffer, seedLow, seedHigh);
wasmCache$3.writeMemory(new Uint8Array(seedBuffer));
const hash = wasmCache$3.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new xxHash128 hash instance
* @param seedLow Lower 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
* @param seedHigh Higher 32 bits of the number used to
* initialize the internal state of the algorithm (defaults to 0)
*/ function createXXHash128(seedLow = 0, seedHigh = 0) {
if (validateSeed(seedLow)) return Promise.reject(validateSeed(seedLow));
if (validateSeed(seedHigh)) return Promise.reject(validateSeed(seedHigh));
return WASMInterface(wasmJson$5, 16).then((wasm)=>{
const instanceBuffer = new ArrayBuffer(8);
writeSeed(instanceBuffer, seedLow, seedHigh);
wasm.writeMemory(new Uint8Array(instanceBuffer));
wasm.init();
const obj = {
init: ()=>{
wasm.writeMemory(new Uint8Array(instanceBuffer));
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 512,
digestSize: 16
};
return obj;
});
}
var name$4 = "ripemd160";
var data$4 = "AGFzbQEAAAABEQRgAAF/YAAAYAF/AGACf38AAwkIAAECAwIBAAIFBAEBAgIGDgJ/AUHgiQULfwBBgAgLB4MBCQZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACUhhc2hfSW5pdAABEHJpcGVtZDE2MF91cGRhdGUAAwtIYXNoX1VwZGF0ZQAECkhhc2hfRmluYWwABQ1IYXNoX0dldFN0YXRlAAYOSGFzaF9DYWxjdWxhdGUABwpTVEFURV9TSVpFAwEKzzIIBQBBgAkLOgBBAEHww8uefDYCmIkBQQBC/rnrxemOlZkQNwKQiQFBAEKBxpS6lvHq5m83AoiJAUEAQgA3AoCJAQuPLAEhf0EAIAAoAiQiASAAKAIAIgIgACgCECIDIAIgACgCLCIEIAAoAgwiBSAAKAIEIgYgACgCPCIHIAIgACgCMCIIIAcgACgCCCIJQQAoAoiJASIKQQAoApCJASILQQAoApSJASIMQX9zckEAKAKMiQEiDXNqIAAoAhQiDmpB5peKhQVqQQh3QQAoApiJASIPaiIQQQp3IhFqIAEgDUEKdyISaiACIAtBCnciE2ogDCAAKAIcIhRqIA8gACgCOCIVaiAQIA0gE0F/c3JzakHml4qFBWpBCXcgDGoiFiAQIBJBf3Nyc2pB5peKhQVqQQl3IBNqIhAgFiARQX9zcnNqQeaXioUFakELdyASaiIXIBAgFkEKdyIWQX9zcnNqQeaXioUFakENdyARaiIYIBcgEEEKdyIZQX9zcnNqQeaXioUFakEPdyAWaiIaQQp3IhtqIAAoAhgiECAYQQp3IhxqIAAoAjQiESAXQQp3IhdqIAMgGWogBCAWaiAaIBggF0F/c3JzakHml4qFBWpBD3cgGWoiFiAaIBxBf3Nyc2pB5peKhQVqQQV3IBdqIhcgFiA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iAUE4SRsgAWsQAyAAQQhqQQgQA0EAQQAoAoiJATYCgAlBAEEAKQKMiQE3AoQJQQBBACkClIkBNwKMCSAAQRBqJAALBgBBgIkBC8EBAQF/IwBBEGsiASQAQQBB8MPLnnw2ApiJAUEAQv6568XpjpWZEDcCkIkBQQBCgcaUupbx6uZvNwKIiQFBAEIANwKAiQFBgAkgABADIAFBACgCgIkBIgBBA3Q2AgggAUEAKAKEiQFBA3QgAEEddnI2AgxBkAhBOEH4ACAAQT9xIgBBOEkbIABrEAMgAUEIakEIEANBAEEAKAKIiQE2AoAJQQBBACkCjIkBNwKECUEAQQApApSJATcCjAkgAUEQaiQACwtXAQBBgAgLUFwAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
var hash$4 = "c089a7ca";
var wasmJson$4 = {
name: name$4,
data: data$4,
hash: hash$4
};
const mutex$2 = new Mutex();
let wasmCache$2 = null;
/**
* Calculates RIPEMD-160 hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function ripemd160(data) {
if (wasmCache$2 === null) return lockedCreate(mutex$2, wasmJson$4, 20).then((wasm)=>{
wasmCache$2 = wasm;
return wasmCache$2.calculate(data);
});
try {
const hash = wasmCache$2.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new RIPEMD-160 hash instance
*/ function createRIPEMD160() {
return WASMInterface(wasmJson$4, 20).then((wasm)=>{
wasm.init();
const obj = {
init: ()=>{
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 64,
digestSize: 20
};
return obj;
});
}
function calculateKeyBuffer(hasher, key) {
const { blockSize } = hasher;
const buf = getUInt8Buffer(key);
if (buf.length > blockSize) {
hasher.update(buf);
const uintArr = hasher.digest("binary");
hasher.init();
return uintArr;
}
return new Uint8Array(buf.buffer, buf.byteOffset, buf.length);
}
function calculateHmac(hasher, key) {
hasher.init();
const { blockSize } = hasher;
const keyBuf = calculateKeyBuffer(hasher, key);
const keyBuffer = new Uint8Array(blockSize);
keyBuffer.set(keyBuf);
const opad = new Uint8Array(blockSize);
for(let i = 0; i < blockSize; i++){
const v = keyBuffer[i];
opad[i] = v ^ 0x5C;
keyBuffer[i] = v ^ 0x36;
}
hasher.update(keyBuffer);
const obj = {
init: ()=>{
hasher.init();
hasher.update(keyBuffer);
return obj;
},
update: (data)=>{
hasher.update(data);
return obj;
},
digest: (outputType)=>{
const uintArr = hasher.digest("binary");
hasher.init();
hasher.update(opad);
hasher.update(uintArr);
return hasher.digest(outputType);
},
save: ()=>{
throw new Error("save() not supported");
},
load: ()=>{
throw new Error("load() not supported");
},
blockSize: hasher.blockSize,
digestSize: hasher.digestSize
};
return obj;
}
/**
* Calculates HMAC hash
* @param hash Hash algorithm to use. It has to be the return value of a function like createSHA1()
* @param key Key (string, Buffer or TypedArray)
*/ function createHMAC(hash, key) {
if (!hash || !hash.then) throw new Error('Invalid hash function is provided! Usage: createHMAC(createMD5(), "key").');
return hash.then((hasher)=>calculateHmac(hasher, key));
}
function calculatePBKDF2(digest, salt, iterations, hashLength, outputType) {
return __awaiter(this, void 0, void 0, function*() {
const DK = new Uint8Array(hashLength);
const block1 = new Uint8Array(salt.length + 4);
const block1View = new DataView(block1.buffer);
const saltBuffer = getUInt8Buffer(salt);
const saltUIntBuffer = new Uint8Array(saltBuffer.buffer, saltBuffer.byteOffset, saltBuffer.length);
block1.set(saltUIntBuffer);
let destPos = 0;
const hLen = digest.digestSize;
const l = Math.ceil(hashLength / hLen);
let T = null;
let U = null;
for(let i = 1; i <= l; i++){
block1View.setUint32(salt.length, i);
digest.init();
digest.update(block1);
T = digest.digest("binary");
U = T.slice();
for(let j = 1; j < iterations; j++){
digest.init();
digest.update(U);
U = digest.digest("binary");
for(let k = 0; k < hLen; k++)T[k] ^= U[k];
}
DK.set(T.subarray(0, hashLength - destPos), destPos);
destPos += hLen;
}
if (outputType === "binary") return DK;
const digestChars = new Uint8Array(hashLength * 2);
return getDigestHex(digestChars, DK, hashLength);
});
}
const validateOptions$2 = (options)=>{
if (!options || typeof options !== "object") throw new Error("Invalid options parameter. It requires an object.");
if (!options.hashFunction || !options.hashFunction.then) throw new Error('Invalid hash function is provided! Usage: pbkdf2("password", "salt", 1000, 32, createSHA1()).');
if (!Number.isInteger(options.iterations) || options.iterations < 1) throw new Error("Iterations should be a positive number");
if (!Number.isInteger(options.hashLength) || options.hashLength < 1) throw new Error("Hash length should be a positive number");
if (options.outputType === undefined) options.outputType = "hex";
if (![
"hex",
"binary"
].includes(options.outputType)) throw new Error(`Insupported output type ${options.outputType}. Valid values: ['hex', 'binary']`);
};
/**
* Generates a new PBKDF2 hash for the supplied password
*/ function pbkdf2(options) {
return __awaiter(this, void 0, void 0, function*() {
validateOptions$2(options);
const hmac = yield createHMAC(options.hashFunction, options.password);
return calculatePBKDF2(hmac, options.salt, options.iterations, options.hashLength, options.outputType);
});
}
var name$3 = "scrypt";
var data$3 = "AGFzbQEAAAABGwVgAX8Bf2AAAX9gBH9/f38AYAF/AGADf39/AAMGBQABAgMEBQYBAQKAgAIGCAF/AUGQiAQLBzkEBm1lbW9yeQIAEkhhc2hfU2V0TWVtb3J5U2l6ZQAADkhhc2hfR2V0QnVmZmVyAAEGc2NyeXB0AAQKxyYFWAECf0EAIQECQEEAKAKICCICIABGDQACQCAAIAJrIgBBEHYgAEGAgHxxIABJaiIAQABBf0cNAEH/AcAPC0EAIQFBAEEAKQOICCAAQRB0rXw3A4gICyABwAtwAQJ/AkBBACgCgAgiAA0AQQA/AEEQdCIANgKACEEAKAKICCIBQYCAIEYNAAJAQYCAICABayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBBAA8LQQBBACkDiAggAEEQdK18NwOICEEAKAKACCEACyAAC6sFAQN/IAIgA0EHdCAAakFAaiIEKQMANwMAIAIgBCkDCDcDCCACIAQpAxA3AxAgAiAEKQMYNwMYIAIgBCkDIDcDICACIAQpAyg3AyggAiAEKQMwNwMwIAIgBCkDODcDOAJAIANFDQAgA0EBdCEFIABB+ABqIQQgA0EGdCEGQQAhAANAIAIgAikDACAEQYh/aikDAIU3AwAgAiACKQMIIARBkH9qKQMAhTcDCCACIAIpAxAgBEGYf2opAwCFNwMQIAIgAikDGCAEQaB/aikDAIU3AxggAiACKQMgIARBqH9qKQMAhTcDICACIAIpAyggBEGwf2opAwCFNwMoIAIgAikDMCAEQbh/aikDAIU3AzAgAiACKQM4IARBQGopAwCFNwM4IAIQAyABIAIpAwA3AwAgAUEIaiACKQMINwMAIAFBEGogAikDEDcDACABQRhqIAIpAxg3AwAgAUEgaiACKQMgNwMAIAFBKGogAikDKDcDACABQTBqIAIpAzA3AwAgAUE4aiACKQM4NwMAIAIgAikDACAEQUhqKQMAhTcDACACIAIpAwggBEFQaikDAIU3AwggAiACKQMQIARBWGopAwCFNwMQIAIgAikDGCAEQWBqKQMAhTcDGCACIAIpAyAgBEFoaikDAIU3AyAgAiACKQMoIARBcGopAwCFNwMoIAIgAikDMCAEQXhqKQMAhTcDMCACIAIpAzggBCkDAIU3AzggAhADIAEgBmoiAyACKQMANwMAIANBCGogAikDCDcDACADQRBqIAIpAxA3AwAgA0EYaiACKQMYNwMAIANBIGogAikDIDcDACADQShqIAIpAyg3AwAgA0EwaiACKQMwNwMAIANBOGogAikDODcDACAEQYABaiEEIAFBwABqIQEgAEECaiIAIAVJDQALCwu6DQgBfgF/AX4BfwF+AX8BfhJ/IAAgACgCBCAAKQMoIgFCIIinIgIgACkDOCIDQiCIpyIEakEHdyAAKQMIIgVCIIincyIGIARqQQl3IAApAxgiB0IgiKdzIgggBmpBDXcgAnMiCSAHpyIKIAGnIgtqQQd3IAOncyICIAtqQQl3IAWncyIMIAJqQQ13IApzIg0gDGpBEncgC3MiD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aiILbCEMIAAgC0GAAWpsIQ0gAEEFdCILQQEgC0EBSxsiC0FgcSEOIAtBAXEhDyAHQUBqIRAgAa1Cf3whESAEIAdqIRIgByAAQQh0IhNqIRQgACAKQYABamwhFSALQX9qQQNJIRZBACEXQQAhGANAQQAoAoAIIhkgAyAYbGohGgJAIABFDQBBACEbAkAgFg0AIBkgF2ohHEEAIQtBACEbA0AgByALaiIEIBwgC2oiHSgCADYCACAEQQRqIB1BBGooAgA2AgAgBEEIaiAdQQhqKAIANgIAIARBDGogHUEMaigCADYCACALQRBqIQsgDiAbQQRqIhtHDQALCyAPRQ0AIAcgG0ECdCILaiAaIAtqKAIANgIACwJAIAFFDQBBACEeIBUhHCAGIR8DQCAFIR0gACEbAkACQCAADQAgFCAQKQMANwMAIBQgECkDCDcDCCAUIBApAxA3AxAgFCAQKQMYNwMYIBQgECkDIDcDICAUIBApAyg3AyggFCAQKQMwNwMwIBQgECkDODcDOAwBCwNAIB0gH2oiCyAdIAxqIgQpAwA3AwAgC0EIaiAEQQhqKQMANwMAIAtBEGogBEEQaikDADcDACALQRhqIARBGGopAwA3AwAgC0EgaiAEQSBqKQMANwMAIAtBKGogBEEoaikDADcDACALQTBqIARBMGopAwA3AwAgC0E4aiAEQThqKQMANwMAIAtBwABqIARBwABqKQMANwMAIAtByABqIARByABqKQMANwMAIAtB0ABqIARB0ABqKQMANwMAIAtB2ABqIARB2ABqKQMANwMAIAtB4ABqIARB4ABqKQMANwMAIAtB6ABqIARB6ABqKQMANwMAIAtB8ABqIARB8ABqKQMANwMAIAtB+ABqIARB+ABqKQMANwMAIB1BgAFqIR0gG0F/aiIbDQALIAcgCCAUIAAQAiAFIR0gACEbA0AgHSAcaiILIB0gDWoiBCkDADcDACALQQhqIARBCGopAwA3AwAgC0EQaiAEQRBqKQMANwMAIAtBGGogBEEYaikDADcDACALQSBqIARBIGopAwA3AwAgC0EoaiAEQShqKQMANwMAIAtBMGogBEEwaikDADcDACALQThqIARBOGopAwA3AwAgC0H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AwAgC0EQaiIcIBwpAwAgBEEQaikDAIU3AwAgC0EYaiIcIBwpAwAgBEEYaikDAIU3AwAgC0EgaiIcIBwpAwAgBEEgaikDAIU3AwAgC0EoaiIcIBwpAwAgBEEoaikDAIU3AwAgC0EwaiIcIBwpAwAgBEEwaikDAIU3AwAgC0E4aiIcIBwpAwAgBEE4aikDAIU3AwAgC0HAAGoiHCAcKQMAIARBwABqKQMAhTcDACALQcgAaiIcIBwpAwAgBEHIAGopAwCFNwMAIAtB0ABqIhwgHCkDACAEQdAAaikDAIU3AwAgC0HYAGoiHCAcKQMAIARB2ABqKQMAhTcDACALQeAAaiIcIBwpAwAgBEHgAGopAwCFNwMAIAtB6ABqIhwgHCkDACAEQegAaikDAIU3AwAgC0HwAGoiHCAcKQMAIARB8ABqKQMAhTcDACALQfgAaiILIAspAwAgBEH4AGopAwCFNwMAIB1BgAFqIR0gG0F/aiIbDQALCyAIIAcgFCAAEAIgHkECaiIeIAFJDQALCwJAIABFDQBBACEbAkAgFg0AIBkgF2ohHEEAIQtBACEbA0AgHCALaiIEIAcgC2oiHSgCADYCACAEQQRqIB1BBGooAgA2AgAgBEEIaiAdQQhqKAIANgIAIARBDGogHUEMaigCADYCACALQRBqIQsgDiAbQQRqIhtHDQALCyAPRQ0AIBogG0ECdCILaiAHIAtqKAIANgIACyAXIANqIRcgGEEBaiIYIAJHDQALCws=";
var hash$3 = "c51b8bf7";
var wasmJson$3 = {
name: name$3,
data: data$3,
hash: hash$3
};
function scryptInternal(options) {
return __awaiter(this, void 0, void 0, function*() {
const { costFactor, blockSize, parallelism, hashLength } = options;
const SHA256Hasher = createSHA256();
const blockData = yield pbkdf2({
password: options.password,
salt: options.salt,
iterations: 1,
hashLength: 128 * blockSize * parallelism,
hashFunction: SHA256Hasher,
outputType: "binary"
});
const scryptInterface = yield WASMInterface(wasmJson$3, 0);
// last block is for storing the temporary vectors
const VSize = 128 * blockSize * costFactor;
const XYSize = 256 * blockSize;
scryptInterface.setMemorySize(blockData.length + VSize + XYSize);
scryptInterface.writeMemory(blockData, 0);
// mix blocks
scryptInterface.getExports().scrypt(blockSize, costFactor, parallelism);
const expensiveSalt = scryptInterface.getMemory().subarray(0, 128 * blockSize * parallelism);
const outputData = yield pbkdf2({
password: options.password,
salt: expensiveSalt,
iterations: 1,
hashLength,
hashFunction: SHA256Hasher,
outputType: "binary"
});
if (options.outputType === "hex") {
const digestChars = new Uint8Array(hashLength * 2);
return getDigestHex(digestChars, outputData, hashLength);
}
// return binary format
return outputData;
});
}
// eslint-disable-next-line no-bitwise
const isPowerOfTwo = (v)=>v && !(v & v - 1);
const validateOptions$1 = (options)=>{
if (!options || typeof options !== "object") throw new Error("Invalid options parameter. It requires an object.");
if (!Number.isInteger(options.blockSize) || options.blockSize < 1) throw new Error("Block size should be a positive number");
if (!Number.isInteger(options.costFactor) || options.costFactor < 2 || !isPowerOfTwo(options.costFactor)) throw new Error("Cost factor should be a power of 2, greater than 1");
if (!Number.isInteger(options.parallelism) || options.parallelism < 1) throw new Error("Parallelism should be a positive number");
if (!Number.isInteger(options.hashLength) || options.hashLength < 1) throw new Error("Hash length should be a positive number.");
if (options.outputType === undefined) options.outputType = "hex";
if (![
"hex",
"binary"
].includes(options.outputType)) throw new Error(`Insupported output type ${options.outputType}. Valid values: ['hex', 'binary']`);
};
/**
* Calculates hash using the scrypt password-based key derivation function
* @returns Computed hash as a hexadecimal string or as
* Uint8Array depending on the outputType option
*/ function scrypt(options) {
return __awaiter(this, void 0, void 0, function*() {
validateOptions$1(options);
return scryptInternal(options);
});
}
var name$2 = "bcrypt";
var data$2 = "AGFzbQEAAAABFwRgAAF/YAR/f39/AGADf39/AGABfwF/AwUEAAECAwUEAQECAgYIAX8BQZCrBQsHNAQGbWVtb3J5AgAOSGFzaF9HZXRCdWZmZXIAAAZiY3J5cHQAAg1iY3J5cHRfdmVyaWZ5AAMK+GAEBQBBgCsL3lkEFH8Bfgh/AX4jAEHwAGshBCACQQA6AAIgAkGq4AA7AAACQCABL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AjVgbfwHSzLvjtGt+aqLdRf9ZOkQKNT7VzbS8qM7qcruEZPquEmaNR288v2Pkm9KeXS9UG3fCrnBjTvaNDQ50VxNb53EWcvhdfVOvCMtAQMzitE5qRtI0hK8VASgEsOEdOpiVtJ+4Bkigbs6COz9vgqsgNUsdGgH4J3InsWAVYdw/k+creTq7vSVFNOE5iKBLec5Rt8kyL8m6H6B+yBzg9tHHvMMRAc/HquihSYeQGpq9T9TL3trQONoK1SrDOQNnNpHGfDH5jU8rseC3WZ73Orv1Q/8Z1fKcRdknLCKXvyr85hVx/JEPJRWUm2GT5frrnLbOWWSowtGouhJeB8G2DGoF42VQ0hBCpAPLDm7s4DvbmBa+oJhMZOl4MjKVH5/fktPgKzSg0x7ycYlBdAobjDSjSyBxvsXYMnbDjZ813y4vmZtHbwvmHfHjD1TaTOWR2Noez3lizm9+Ps1msRgWBR0s/cXSj4SZIvv2V/Mj9SN2MqYxNaiTAs3MVmKB8Ky163ValzYWbsxz0oiSYpbe0Em5gRuQUEwUVsZxvcfG5goUejIG0OFFmnvyw/1TqskAD6hi4r8lu/bSvTUFaRJxIgIEsnzPy7YrnHbNwD4RU9PjQBZgvas48K1HJZwgOLp2zkb3xaGvd2BgdSBO/suF2I3oirD5qnp+qvlMXMJIGYyK+wLkasMB+eHr1mn41JCg3lymLSUJP5/mCMIyYU63W+J3zuPfj1fmcsM6iGo/JNMIo4UuihkTRHNwAyI4CaTQMZ8pmPouCIlsTuzmIShFdxPQOM9mVL5sDOk0tymswN1QfMm11YQ/FwlHtdnVFpIb+3mJ";
var hash$2 = "497b89b2";
var wasmJson$2 = {
name: name$2,
data: data$2,
hash: hash$2
};
function bcryptInternal(options) {
return __awaiter(this, void 0, void 0, function*() {
const { costFactor, password, salt } = options;
const bcryptInterface = yield WASMInterface(wasmJson$2, 0);
bcryptInterface.writeMemory(getUInt8Buffer(salt), 0);
const passwordBuffer = getUInt8Buffer(password);
bcryptInterface.writeMemory(passwordBuffer, 16);
const shouldEncode = options.outputType === "encoded" ? 1 : 0;
bcryptInterface.getExports().bcrypt(passwordBuffer.length, costFactor, shouldEncode);
const memory = bcryptInterface.getMemory();
if (options.outputType === "encoded") return intArrayToString(memory, 60);
if (options.outputType === "hex") {
const digestChars = new Uint8Array(48);
return getDigestHex(digestChars, memory, 24);
}
// return binary format
// the data is copied to allow GC of the original memory buffer
return memory.slice(0, 24);
});
}
const validateOptions = (options)=>{
if (!options || typeof options !== "object") throw new Error("Invalid options parameter. It requires an object.");
if (!Number.isInteger(options.costFactor) || options.costFactor < 4 || options.costFactor > 31) throw new Error("Cost factor should be a number between 4 and 31");
options.password = getUInt8Buffer(options.password);
if (options.password.length < 1) throw new Error("Password should be at least 1 byte long");
if (options.password.length > 72) throw new Error("Password should be at most 72 bytes long");
options.salt = getUInt8Buffer(options.salt);
if (options.salt.length !== 16) throw new Error("Salt should be 16 bytes long");
if (options.outputType === undefined) options.outputType = "encoded";
if (![
"hex",
"binary",
"encoded"
].includes(options.outputType)) throw new Error(`Insupported output type ${options.outputType}. Valid values: ['hex', 'binary', 'encoded']`);
};
/**
* Calculates hash using the bcrypt password-hashing function
* @returns Computed hash
*/ function bcrypt(options) {
return __awaiter(this, void 0, void 0, function*() {
validateOptions(options);
return bcryptInternal(options);
});
}
const validateHashCharacters = (hash)=>{
if (!/^\$2[axyb]\$[0-3][0-9]\$[./A-Za-z0-9]{53}$/.test(hash)) return false;
if (hash[4] === "0" && parseInt(hash[5], 10) < 4) return false;
if (hash[4] === "3" && parseInt(hash[5], 10) > 1) return false;
return true;
};
const validateVerifyOptions = (options)=>{
if (!options || typeof options !== "object") throw new Error("Invalid options parameter. It requires an object.");
if (options.hash === undefined || typeof options.hash !== "string") throw new Error("Hash should be specified");
if (options.hash.length !== 60) throw new Error("Hash should be 60 bytes long");
if (!validateHashCharacters(options.hash)) throw new Error("Invalid hash");
options.password = getUInt8Buffer(options.password);
if (options.password.length < 1) throw new Error("Password should be at least 1 byte long");
if (options.password.length > 72) throw new Error("Password should be at most 72 bytes long");
};
/**
* Verifies password using bcrypt password-hashing function
* @returns True if the encoded hash matches the password
*/ function bcryptVerify(options) {
return __awaiter(this, void 0, void 0, function*() {
validateVerifyOptions(options);
const { hash, password } = options;
const bcryptInterface = yield WASMInterface(wasmJson$2, 0);
bcryptInterface.writeMemory(getUInt8Buffer(hash), 0);
const passwordBuffer = getUInt8Buffer(password);
bcryptInterface.writeMemory(passwordBuffer, 60);
return !!bcryptInterface.getExports().bcrypt_verify(passwordBuffer.length);
});
}
var name$1 = "whirlpool";
var data$1 = "AGFzbQEAAAABEQRgAAF/YAF/AGACf38AYAAAAwkIAAECAwEDAAEFBAEBAgIGDgJ/AUHQmwULfwBBgAgLB3AIBm1lbW9yeQIADkhhc2hfR2V0QnVmZmVyAAAJSGFzaF9Jbml0AAMLSGFzaF9VcGRhdGUABApIYXNoX0ZpbmFsAAUNSGFzaF9HZXRTdGF0ZQAGDkhhc2hfQ2FsY3VsYXRlAAcKU1RBVEVfU0laRQMBCuwbCAUAQYAZC8wGAQl+IAApAwAhAUEAQQApA4CbASICNwPAmQEgACkDGCEDIAApAxAhBCAAKQMIIQVBAEEAKQOYmwEiBjcD2JkBQQBBACkDkJsBIgc3A9CZAUEAQQApA4ibASIINwPImQFBACABIAKFNwOAmgFBACAFIAiFNwOImgFBACAEIAeFNwOQmgFBACADIAaFNwOYmgEgACkDICEDQQBBACkDoJsBIgE3A+CZAUEAIAMgAYU3A6CaASAAKQMoIQRBAEEAKQOomwEiAzcD6JkBQQAgBCADhTcDqJoBIAApAzAhBUEAQQApA7CbASIENwPwmQFBACAFIASFNwOwmgEgACkDOCEJQQBBACkDuJsBIgU3A/iZAUEAIAkgBYU3A7iaAUEAQpjGmMb+kO6AzwA3A4CZAUHAmQFBgJkBEAJBgJoBQcCZARACQQBCtszKrp/v28jSADcDgJkBQcCZAUGAmQEQAkGAmgFBwJkBEAJBAELg+O70uJTDvTU3A4CZAUHAmQFBgJkBEAJBgJoBQcCZARACQQBCncDfluzlk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Ta9PWuLsF5+e752tc04xubqVuV8vcOcTEN8Ru85WqAwMMAxgPBhtWVkVWihOs3EREDUQaSYhef3/hf9+e/qCpqZ6pITdPiCoqqCpNglRnu7vWu7FtawrBwSPBRuKfh1NTUVOiAqbx3NxX3K6LpXILCywLWCcWU52dTp2c0ycBbGytbEfB2CsxMcQxlfVipHR0zXSHuejz9vb/9uMJ8RVGRgVGCkOMTKysiqwJJkWliYkeiTyXD7UUFFAUoEQotOHho+FbQt+6FhZYFrBOLKY6Oug6zdJ092lpuWlv0NIGCQkkCUgtEkFwcN1wp63g17a24rbZVHFv0NBn0M63vR7t7ZPtO37H1szMF8wu24XiQkIVQipXhGiYmFqYtMItLKSkqqRJDlXtKCigKF2IUHVcXG1c2jG4hvj4x/iTP+1rhoYihkSkEcI=";
var hash$1 = "dba12019";
var wasmJson$1 = {
name: name$1,
data: data$1,
hash: hash$1
};
const mutex$1 = new Mutex();
let wasmCache$1 = null;
/**
* Calculates Whirlpool hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function whirlpool(data) {
if (wasmCache$1 === null) return lockedCreate(mutex$1, wasmJson$1, 64).then((wasm)=>{
wasmCache$1 = wasm;
return wasmCache$1.calculate(data);
});
try {
const hash = wasmCache$1.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new Whirlpool hash instance
*/ function createWhirlpool() {
return WASMInterface(wasmJson$1, 64).then((wasm)=>{
wasm.init();
const obj = {
init: ()=>{
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 64,
digestSize: 64
};
return obj;
});
}
var name = "sm3";
var data = "AGFzbQEAAAABDANgAAF/YAAAYAF/AAMIBwABAgIBAAIFBAEBAgIGDgJ/AUHwiQULfwBBgAgLB3AIBm1lbW9yeQIADkhhc2hfR2V0QnVmZ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QQBBACgCjIkBIgFBGHQgAUGA/gNxQQh0ciABQQh2QYD+A3EgAUEYdnJyNgKECUEAQQAoApCJASIBQRh0IAFBgP4DcUEIdHIgAUEIdkGA/gNxIAFBGHZycjYCiAlBAEEAKAKUiQEiAUEYdCABQYD+A3FBCHRyIAFBCHZBgP4DcSABQRh2cnI2AowJQQBBACgCmIkBIgFBGHQgAUGA/gNxQQh0ciABQQh2QYD+A3EgAUEYdnJyNgKQCUEAQQAoApyJASIBQRh0IAFBgP4DcUEIdHIgAUEIdkGA/gNxIAFBGHZycjYClAlBAEEAKAKgiQEiAUEYdCABQYD+A3FBCHRyIAFBCHZBgP4DcSABQRh2cnI2ApgJQQBBACgCpIkBIgFBGHQgAUGA/gNxQQh0ciABQQh2QYD+A3EgAUEYdnJyNgKcCSAAQRBqJAALBgBBgIkBC5UCAQR/QQBCzdy3nO7Jw/2wfzcCoIkBQQBCvOG8y6qVzpgWNwKYiQFBAELXhZG5gcCBxVo3ApCJAUEAQu+sgJyX16yKyQA3AoiJAUEAQgA3AoCJAQJAIABFDQBBACAANgKAiQFBgAkhAQJAIABBwABJDQBBgAkhAQNAIAEQAyABQcAAaiEBIABBQGoiAEE/Sw0ACyAARQ0BCyAAQX9qIQICQAJAIABBB3EiAw0AQaiJASEEDAELIABBeHEhAEGoiQEhBANAIAQgAS0AADoAACAEQQFqIQQgAUEBaiEBIANBf2oiAw0ACwsgAkEHSQ0AA0AgBCABKQAANwAAIARBCGohBCABQQhqIQEgAEF4aiIADQALCxAECwtRAgBBgAgLBGgAAAAAQZAIC0CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
var hash = "56515712";
var wasmJson = {
name: name,
data: data,
hash: hash
};
const mutex = new Mutex();
let wasmCache = null;
/**
* Calculates SM3 hash
* @param data Input data (string, Buffer or TypedArray)
* @returns Computed hash as a hexadecimal string
*/ function sm3(data) {
if (wasmCache === null) return lockedCreate(mutex, wasmJson, 32).then((wasm)=>{
wasmCache = wasm;
return wasmCache.calculate(data);
});
try {
const hash = wasmCache.calculate(data);
return Promise.resolve(hash);
} catch (err) {
return Promise.reject(err);
}
}
/**
* Creates a new SM3 hash instance
*/ function createSM3() {
return WASMInterface(wasmJson, 32).then((wasm)=>{
wasm.init();
const obj = {
init: ()=>{
wasm.init();
return obj;
},
update: (data)=>{
wasm.update(data);
return obj;
},
digest: (outputType)=>wasm.digest(outputType),
save: ()=>wasm.save(),
load: (data)=>{
wasm.load(data);
return obj;
},
blockSize: 64,
digestSize: 32
};
return obj;
});
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"I0WvA":[function(require,module,exports) {
"use strict";
const { hasOwnProperty } = Object.prototype;
const stringify = configure();
// @ts-expect-error
stringify.configure = configure;
// @ts-expect-error
stringify.stringify = stringify;
// @ts-expect-error
stringify.default = stringify;
// @ts-expect-error used for named export
exports.stringify = stringify;
// @ts-expect-error used for named export
exports.configure = configure;
module.exports = stringify;
// eslint-disable-next-line no-control-regex
const strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;
// Escape C0 control characters, double quotes, the backslash and every code
// unit with a numeric value in the inclusive range 0xD800 to 0xDFFF.
function strEscape(str) {
// Some magic numbers that worked out fine while benchmarking with v8 8.0
if (str.length < 5000 && !strEscapeSequencesRegExp.test(str)) return `"${str}"`;
return JSON.stringify(str);
}
function insertSort(array) {
// Insertion sort is very efficient for small input sizes but it has a bad
// worst case complexity. Thus, use native array sort for bigger values.
if (array.length > 2e2) return array.sort();
for(let i = 1; i < array.length; i++){
const currentValue = array[i];
let position = i;
while(position !== 0 && array[position - 1] > currentValue){
array[position] = array[position - 1];
position--;
}
array[position] = currentValue;
}
return array;
}
const typedArrayPrototypeGetSymbolToStringTag = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array())), Symbol.toStringTag).get;
function isTypedArrayWithEntries(value) {
return typedArrayPrototypeGetSymbolToStringTag.call(value) !== undefined && value.length !== 0;
}
function stringifyTypedArray(array, separator, maximumBreadth) {
if (array.length < maximumBreadth) maximumBreadth = array.length;
const whitespace = separator === "," ? "" : " ";
let res = `"0":${whitespace}${array[0]}`;
for(let i = 1; i < maximumBreadth; i++)res += `${separator}"${i}":${whitespace}${array[i]}`;
return res;
}
function getCircularValueOption(options) {
if (hasOwnProperty.call(options, "circularValue")) {
const circularValue = options.circularValue;
if (typeof circularValue === "string") return `"${circularValue}"`;
if (circularValue == null) return circularValue;
if (circularValue === Error || circularValue === TypeError) return {
toString () {
throw new TypeError("Converting circular structure to JSON");
}
};
throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
}
return '"[Circular]"';
}
function getBooleanOption(options, key) {
let value;
if (hasOwnProperty.call(options, key)) {
value = options[key];
if (typeof value !== "boolean") throw new TypeError(`The "${key}" argument must be of type boolean`);
}
return value === undefined ? true : value;
}
function getPositiveIntegerOption(options, key) {
let value;
if (hasOwnProperty.call(options, key)) {
value = options[key];
if (typeof value !== "number") throw new TypeError(`The "${key}" argument must be of type number`);
if (!Number.isInteger(value)) throw new TypeError(`The "${key}" argument must be an integer`);
if (value < 1) throw new RangeError(`The "${key}" argument must be >= 1`);
}
return value === undefined ? Infinity : value;
}
function getItemCount(number) {
if (number === 1) return "1 item";
return `${number} items`;
}
function getUniqueReplacerSet(replacerArray) {
const replacerSet = new Set();
for (const value of replacerArray)if (typeof value === "string" || typeof value === "number") replacerSet.add(String(value));
return replacerSet;
}
function getStrictOption(options) {
if (hasOwnProperty.call(options, "strict")) {
const value = options.strict;
if (typeof value !== "boolean") throw new TypeError('The "strict" argument must be of type boolean');
if (value) return (value)=>{
let message = `Object can not safely be stringified. Received type ${typeof value}`;
if (typeof value !== "function") message += ` (${value.toString()})`;
throw new Error(message);
};
}
}
function configure(options) {
options = {
...options
};
const fail = getStrictOption(options);
if (fail) {
if (options.bigint === undefined) options.bigint = false;
if (!("circularValue" in options)) options.circularValue = Error;
}
const circularValue = getCircularValueOption(options);
const bigint = getBooleanOption(options, "bigint");
const deterministic = getBooleanOption(options, "deterministic");
const maximumDepth = getPositiveIntegerOption(options, "maximumDepth");
const maximumBreadth = getPositiveIntegerOption(options, "maximumBreadth");
function stringifyFnReplacer(key, parent, stack, replacer, spacer, indentation) {
let value = parent[key];
if (typeof value === "object" && value !== null && typeof value.toJSON === "function") value = value.toJSON(key);
value = replacer.call(parent, key, value);
switch(typeof value){
case "string":
return strEscape(value);
case "object":
{
if (value === null) return "null";
if (stack.indexOf(value) !== -1) return circularValue;
let res = "";
let join = ",";
const originalIndentation = indentation;
if (Array.isArray(value)) {
if (value.length === 0) return "[]";
if (maximumDepth < stack.length + 1) return '"[Array]"';
stack.push(value);
if (spacer !== "") {
indentation += spacer;
res += `\n${indentation}`;
join = `,\n${indentation}`;
}
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
let i = 0;
for(; i < maximumValuesToStringify - 1; i++){
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
res += tmp !== undefined ? tmp : "null";
res += join;
}
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
res += tmp !== undefined ? tmp : "null";
if (value.length - 1 > maximumBreadth) {
const removedKeys = value.length - maximumBreadth - 1;
res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
}
if (spacer !== "") res += `\n${originalIndentation}`;
stack.pop();
return `[${res}]`;
}
let keys = Object.keys(value);
const keyLength = keys.length;
if (keyLength === 0) return "{}";
if (maximumDepth < stack.length + 1) return '"[Object]"';
let whitespace = "";
let separator = "";
if (spacer !== "") {
indentation += spacer;
join = `,\n${indentation}`;
whitespace = " ";
}
const maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
if (deterministic && !isTypedArrayWithEntries(value)) keys = insertSort(keys);
stack.push(value);
for(let i = 0; i < maximumPropertiesToStringify; i++){
const key = keys[i];
const tmp = stringifyFnReplacer(key, value, stack, replacer, spacer, indentation);
if (tmp !== undefined) {
res += `${separator}${strEscape(key)}:${whitespace}${tmp}`;
separator = join;
}
}
if (keyLength > maximumBreadth) {
const removedKeys = keyLength - maximumBreadth;
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
separator = join;
}
if (spacer !== "" && separator.length > 1) res = `\n${indentation}${res}\n${originalIndentation}`;
stack.pop();
return `{${res}}`;
}
case "number":
return isFinite(value) ? String(value) : fail ? fail(value) : "null";
case "boolean":
return value === true ? "true" : "false";
case "undefined":
return undefined;
case "bigint":
if (bigint) return String(value);
// fallthrough
default:
return fail ? fail(value) : undefined;
}
}
function stringifyArrayReplacer(key, value, stack, replacer, spacer, indentation) {
if (typeof value === "object" && value !== null && typeof value.toJSON === "function") value = value.toJSON(key);
switch(typeof value){
case "string":
return strEscape(value);
case "object":
{
if (value === null) return "null";
if (stack.indexOf(value) !== -1) return circularValue;
const originalIndentation = indentation;
let res = "";
let join = ",";
if (Array.isArray(value)) {
if (value.length === 0) return "[]";
if (maximumDepth < stack.length + 1) return '"[Array]"';
stack.push(value);
if (spacer !== "") {
indentation += spacer;
res += `\n${indentation}`;
join = `,\n${indentation}`;
}
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
let i = 0;
for(; i < maximumValuesToStringify - 1; i++){
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
res += tmp !== undefined ? tmp : "null";
res += join;
}
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
res += tmp !== undefined ? tmp : "null";
if (value.length - 1 > maximumBreadth) {
const removedKeys = value.length - maximumBreadth - 1;
res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
}
if (spacer !== "") res += `\n${originalIndentation}`;
stack.pop();
return `[${res}]`;
}
stack.push(value);
let whitespace = "";
if (spacer !== "") {
indentation += spacer;
join = `,\n${indentation}`;
whitespace = " ";
}
let separator = "";
for (const key of replacer){
const tmp = stringifyArrayReplacer(key, value[key], stack, replacer, spacer, indentation);
if (tmp !== undefined) {
res += `${separator}${strEscape(key)}:${whitespace}${tmp}`;
separator = join;
}
}
if (spacer !== "" && separator.length > 1) res = `\n${indentation}${res}\n${originalIndentation}`;
stack.pop();
return `{${res}}`;
}
case "number":
return isFinite(value) ? String(value) : fail ? fail(value) : "null";
case "boolean":
return value === true ? "true" : "false";
case "undefined":
return undefined;
case "bigint":
if (bigint) return String(value);
// fallthrough
default:
return fail ? fail(value) : undefined;
}
}
function stringifyIndent(key, value, stack, spacer, indentation) {
switch(typeof value){
case "string":
return strEscape(value);
case "object":
{
if (value === null) return "null";
if (typeof value.toJSON === "function") {
value = value.toJSON(key);
// Prevent calling `toJSON` again.
if (typeof value !== "object") return stringifyIndent(key, value, stack, spacer, indentation);
if (value === null) return "null";
}
if (stack.indexOf(value) !== -1) return circularValue;
const originalIndentation = indentation;
if (Array.isArray(value)) {
if (value.length === 0) return "[]";
if (maximumDepth < stack.length + 1) return '"[Array]"';
stack.push(value);
indentation += spacer;
let res = `\n${indentation}`;
const join = `,\n${indentation}`;
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
let i = 0;
for(; i < maximumValuesToStringify - 1; i++){
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
res += tmp !== undefined ? tmp : "null";
res += join;
}
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
res += tmp !== undefined ? tmp : "null";
if (value.length - 1 > maximumBreadth) {
const removedKeys = value.length - maximumBreadth - 1;
res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
}
res += `\n${originalIndentation}`;
stack.pop();
return `[${res}]`;
}
let keys = Object.keys(value);
const keyLength = keys.length;
if (keyLength === 0) return "{}";
if (maximumDepth < stack.length + 1) return '"[Object]"';
indentation += spacer;
const join = `,\n${indentation}`;
let res = "";
let separator = "";
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
if (isTypedArrayWithEntries(value)) {
res += stringifyTypedArray(value, join, maximumBreadth);
keys = keys.slice(value.length);
maximumPropertiesToStringify -= value.length;
separator = join;
}
if (deterministic) keys = insertSort(keys);
stack.push(value);
for(let i = 0; i < maximumPropertiesToStringify; i++){
const key = keys[i];
const tmp = stringifyIndent(key, value[key], stack, spacer, indentation);
if (tmp !== undefined) {
res += `${separator}${strEscape(key)}: ${tmp}`;
separator = join;
}
}
if (keyLength > maximumBreadth) {
const removedKeys = keyLength - maximumBreadth;
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
separator = join;
}
if (separator !== "") res = `\n${indentation}${res}\n${originalIndentation}`;
stack.pop();
return `{${res}}`;
}
case "number":
return isFinite(value) ? String(value) : fail ? fail(value) : "null";
case "boolean":
return value === true ? "true" : "false";
case "undefined":
return undefined;
case "bigint":
if (bigint) return String(value);
// fallthrough
default:
return fail ? fail(value) : undefined;
}
}
function stringifySimple(key, value, stack) {
switch(typeof value){
case "string":
return strEscape(value);
case "object":
{
if (value === null) return "null";
if (typeof value.toJSON === "function") {
value = value.toJSON(key);
// Prevent calling `toJSON` again
if (typeof value !== "object") return stringifySimple(key, value, stack);
if (value === null) return "null";
}
if (stack.indexOf(value) !== -1) return circularValue;
let res = "";
if (Array.isArray(value)) {
if (value.length === 0) return "[]";
if (maximumDepth < stack.length + 1) return '"[Array]"';
stack.push(value);
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
let i = 0;
for(; i < maximumValuesToStringify - 1; i++){
const tmp = stringifySimple(String(i), value[i], stack);
res += tmp !== undefined ? tmp : "null";
res += ",";
}
const tmp = stringifySimple(String(i), value[i], stack);
res += tmp !== undefined ? tmp : "null";
if (value.length - 1 > maximumBreadth) {
const removedKeys = value.length - maximumBreadth - 1;
res += `,"... ${getItemCount(removedKeys)} not stringified"`;
}
stack.pop();
return `[${res}]`;
}
let keys = Object.keys(value);
const keyLength = keys.length;
if (keyLength === 0) return "{}";
if (maximumDepth < stack.length + 1) return '"[Object]"';
let separator = "";
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
if (isTypedArrayWithEntries(value)) {
res += stringifyTypedArray(value, ",", maximumBreadth);
keys = keys.slice(value.length);
maximumPropertiesToStringify -= value.length;
separator = ",";
}
if (deterministic) keys = insertSort(keys);
stack.push(value);
for(let i = 0; i < maximumPropertiesToStringify; i++){
const key = keys[i];
const tmp = stringifySimple(key, value[key], stack);
if (tmp !== undefined) {
res += `${separator}${strEscape(key)}:${tmp}`;
separator = ",";
}
}
if (keyLength > maximumBreadth) {
const removedKeys = keyLength - maximumBreadth;
res += `${separator}"...":"${getItemCount(removedKeys)} not stringified"`;
}
stack.pop();
return `{${res}}`;
}
case "number":
return isFinite(value) ? String(value) : fail ? fail(value) : "null";
case "boolean":
return value === true ? "true" : "false";
case "undefined":
return undefined;
case "bigint":
if (bigint) return String(value);
// fallthrough
default:
return fail ? fail(value) : undefined;
}
}
function stringify(value, replacer, space) {
if (arguments.length > 1) {
let spacer = "";
if (typeof space === "number") spacer = " ".repeat(Math.min(space, 10));
else if (typeof space === "string") spacer = space.slice(0, 10);
if (replacer != null) {
if (typeof replacer === "function") return stringifyFnReplacer("", {
"": value
}, [], replacer, spacer, "");
if (Array.isArray(replacer)) return stringifyArrayReplacer("", value, [], getUniqueReplacerSet(replacer), spacer, "");
}
if (spacer.length !== 0) return stringifyIndent("", value, [], spacer, "");
}
return stringifySimple("", value, []);
}
return stringify;
}
},{}],"azubS":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "SyncActionDefinition", ()=>SyncActionDefinition);
parcelHelpers.export(exports, "SyncActionPaths", ()=>SyncActionPaths);
const SyncActionDefinition = {
"site": {
"list": "0",
"group": "1",
"load": "2",
"update": "3"
},
"comp": {
"new": "4",
"list": "5",
"group": "6",
"load": "7"
},
"page": {
"list": "8",
"load": "9",
"cache": "10"
},
"yjs": {
"um": "11",
"sv_local": "12",
"diff_local": "13",
"sv_remote": "14"
},
"client": {
"info": "15"
},
"code": {
"load": "16",
"edit": "17",
"action": "18"
}
};
const SyncActionPaths = {
"0": "site.list",
"1": "site.group",
"2": "site.load",
"3": "site.update",
"4": "comp.new",
"5": "comp.list",
"6": "comp.group",
"7": "comp.load",
"8": "page.list",
"9": "page.load",
"10": "page.cache",
"11": "yjs.um",
"12": "yjs.sv_local",
"13": "yjs.diff_local",
"14": "yjs.sv_remote",
"15": "client.info",
"16": "code.load",
"17": "code.edit",
"18": "code.action"
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"cC357":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "SyncType", ()=>SyncType);
var SyncType;
(function(SyncType) {
SyncType[SyncType["ClientID"] = 0] = "ClientID";
SyncType[SyncType["UserID"] = 1] = "UserID";
SyncType[SyncType["Event"] = 2] = "Event";
SyncType[SyncType["Action"] = 3] = "Action";
SyncType[SyncType["ActionResult"] = 4] = "ActionResult";
})(SyncType || (SyncType = {}));
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"iOtgT":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "initIDB", ()=>initIDB);
var _idbKeyval = require("idb-keyval");
const initIDB = (user_id)=>{
const store = (0, _idbKeyval.createStore)(`prasi-user-${user_id}`, "default");
return store;
};
},{"idb-keyval":"in1MU","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"iWfqp":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "loadFrontEnd", ()=>loadFrontEnd);
parcelHelpers.export(exports, "loadTypings", ()=>loadTypings);
parcelHelpers.export(exports, "loadCode", ()=>loadCode);
const loadFrontEnd = async (p, ts)=>{
const id_site = p.site.id;
const url = `/prod/${id_site}/_prasi/code/index.js?ts=${ts}`;
const fn = new Function("callback", `
import("${url}")
.catch((e) => console.error("Failed to load site code\\n\\n", e))
.then(callback)`);
try {
await new Promise((resolve)=>{
try {
fn((exports)=>{
const w = window;
for (const [k, v] of Object.entries(exports)){
w[k] = v;
p.site_exports[k] = v;
}
resolve(exports);
});
} catch (e) {
console.log("Failed to load site code", e);
}
});
} catch (e) {}
};
const loadTypings = async (p)=>{
const id_site = p.site.id;
await Promise.all([
fetch(`/prod/${id_site}/_prasi/typings.d.ts`).catch(()=>{}).then(async (res)=>{
if (res) {
p.site_dts = await res.text();
p.render();
}
}),
fetch(`/prod/${id_site}/_prasi/type_def`).catch(()=>{}).then(async (res)=>{
if (res) {
p.site_dts_entry = await res.json();
p.render();
}
}),
fetch(`/prod/${id_site}/_prasi/prisma.ext`).catch(()=>{}).then(async (res)=>{
if (res) {
p.prisma_ext = (await res.text()).replace("./prisma", "ts:prisma");
p.render();
}
})
]);
};
const loadCode = async (p, ts)=>{
try {
await Promise.all([
loadTypings(p),
loadFrontEnd(p, ts)
]);
} catch (e) {
console.log("Failed to load site code", e);
}
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fQ2tn":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "loadcomp", ()=>loadcomp);
parcelHelpers.export(exports, "loadComponent", ()=>loadComponent);
parcelHelpers.export(exports, "loadCompSnapshot", ()=>loadCompSnapshot);
parcelHelpers.export(exports, "updateComponentMeta", ()=>updateComponentMeta);
var _cuid2 = require("@paralleldrive/cuid2");
var _wasmGzip = require("wasm-gzip");
var _initCompLoad = require("../../../vi/meta/comp/init-comp-load");
var _meta = require("../../../vi/meta/meta");
var _isEditing = require("../active/is-editing");
var _assignMitem = require("../tree/assign-mitem");
var _build = require("../tree/build");
var _pushTree = require("../tree/build/push-tree");
var Buffer = require("2c077da2988489ba").Buffer;
const loadcomp = {
timeout: 0,
pending: new Set()
};
const loadComponent = async (p, id_comp, sync)=>{
return new Promise((resolve)=>{
if (p.comp.list[id_comp]) {
resolve(true);
return;
}
loadcomp.pending.add(id_comp);
clearTimeout(loadcomp.timeout);
loadcomp.timeout = setTimeout(async ()=>{
const comps = await p.sync?.comp.load([
...loadcomp.pending
], sync);
if (comps) {
let result = Object.entries(comps);
for (const [id_comp, comp] of result)if (comp && comp.snapshot) await loadCompSnapshot(p, id_comp, comp.snapshot);
loadcomp.pending.clear();
resolve(result.length > 0);
} else resolve(false);
}, 150);
});
};
const loadCompSnapshot = async (p, comp_id, snapshot)=>{
if (p.comp.list[comp_id]) return;
const doc = new Y.Doc();
Y.applyUpdate(doc, (0, _wasmGzip.decompress)(snapshot));
const mitem = doc.getMap("map").get("root");
if (mitem) {
p.comp.loaded[comp_id] = mitem.toJSON();
const ref = p.comp.list[comp_id];
if (typeof ref?.on_update === "function") doc.off("update", ref.on_update);
const updated = await updateComponentMeta(p, doc, comp_id);
if (updated) {
const { meta, tree } = updated;
if (ref) {
ref.meta = meta;
ref.tree = tree;
} else {
p.comp.list[comp_id] = {
comp: {
id: comp_id,
snapshot
},
doc,
meta,
tree,
async on_update (bin, origin) {
if (origin === "sv_remote" || origin === "local") return;
const res = await p.sync?.yjs.sv_local("comp", comp_id, Buffer.from((0, _wasmGzip.compress)(bin)));
if (res) {
if (res.sv === res.diff && res.sv === "not-found") {
console.warn("reload 5");
location.reload();
}
const diff_local = Y.encodeStateAsUpdate(doc, (0, _wasmGzip.decompress)(res.sv));
Y.applyUpdate(doc, (0, _wasmGzip.decompress)(res.diff), "local");
await p.sync?.yjs.diff_local("comp", comp_id, Buffer.from((0, _wasmGzip.compress)(diff_local)));
const updated = await updateComponentMeta(p, p.comp.list[comp_id].doc, comp_id);
if (updated) {
p.comp.list[comp_id].meta = updated.meta;
p.comp.list[comp_id].tree = updated.tree;
}
p.comp.loaded[comp_id] = doc.getMap("map").get("root")?.toJSON();
if ((0, _isEditing.isTextEditing)()) return;
(0, _build.treeRebuild)(p);
p.render();
}
}
};
doc.on("update", p.comp.list[comp_id].on_update);
}
}
}
};
const updateComponentMeta = async (p, doc, comp_id)=>{
const mitem = doc.getMap("map").get("root");
if (!mitem) return;
const meta = {};
const tree = [];
const item = mitem.toJSON();
p.comp.loaded[comp_id] = item;
await (0, _initCompLoad.initLoadComp)({
comps: p.comp.loaded,
meta,
set_meta: false,
mode: "comp"
}, item, {
load: async (comp_ids)=>{
const ids = comp_ids.filter((id)=>!p.comp.loaded[id]);
const comps = await p.sync?.comp.load(ids, true);
if (comps) {
let result = Object.entries(comps);
for (const [id_comp, comp] of result)if (comp && comp.snapshot && !p.comp.list[id_comp]) await loadCompSnapshot(p, id_comp, comp.snapshot);
}
}
});
(0, _meta.genMeta)({
comps: p.comp.loaded,
meta,
mode: "comp",
on: {
async visit (m) {
(0, _pushTree.pushTreeNode)(p, m, meta, tree);
(0, _assignMitem.assignMitem)({
m,
root: item,
mitem,
meta,
new_prop_jsx (meta, mprops, prop_name, prop_val) {
transact.list.push(()=>{
const map = new Y.Map();
if (prop_val.content) prop_val.content.id = (0, _cuid2.createId)();
syncronize(map, prop_val);
mprops.set(prop_name, map);
});
}
});
}
},
note: "load-comp-scan-meta"
}, {
item,
ignore_first_component: true
});
if (transact.list.length > 0) p.page.doc?.transact(()=>{
for (const fn of transact.list)fn();
});
p.comp.loaded[comp_id] = item;
return {
meta,
tree,
item
};
};
const transact = {
list: []
};
},{"2c077da2988489ba":"bwHdc","@paralleldrive/cuid2":"41M7L","wasm-gzip":"9TduR","../../../vi/meta/comp/init-comp-load":"6QRQn","../../../vi/meta/meta":"4JpTf","../active/is-editing":"1zeD1","../tree/assign-mitem":"fUXV7","../tree/build":"53DOC","../tree/build/push-tree":"ipgUQ","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"41M7L":[function(require,module,exports) {
const { createId, init, getConstants, isCuid } = require("f4754cad0617f281");
module.exports.createId = createId;
module.exports.init = init;
module.exports.getConstants = getConstants;
module.exports.isCuid = isCuid;
},{"f4754cad0617f281":"aNnHS"}],"aNnHS":[function(require,module,exports) {
/* global global, window, module */ var global = arguments[3];
const { sha3_512: sha3 } = require("d0dc733fdfe478ab");
const defaultLength = 24;
const bigLength = 32;
const createEntropy = (length = 4, random = Math.random)=>{
let entropy = "";
while(entropy.length < length)entropy = entropy + Math.floor(random() * 36).toString(36);
return entropy;
};
/*
* Adapted from https://github.com/juanelas/bigint-conversion
* MIT License Copyright (c) 2018 Juan Hernández Serrano
*/ function bufToBigInt(buf) {
let bits = 8n;
let value = 0n;
for (const i of buf.values()){
const bi = BigInt(i);
value = (value << bits) + bi;
}
return value;
}
const hash = (input = "")=>{
// Drop the first character because it will bias the histogram
// to the left.
return bufToBigInt(sha3(input)).toString(36).slice(1);
};
const alphabet = Array.from({
length: 26
}, (x, i)=>String.fromCharCode(i + 97));
const randomLetter = (random)=>alphabet[Math.floor(random() * alphabet.length)];
/*
This is a fingerprint of the host environment. It is used to help
prevent collisions when generating ids in a distributed system.
If no global object is available, you can pass in your own, or fall back
on a random string.
*/ const createFingerprint = ({ globalObj = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {}, random = Math.random } = {})=>{
const globals = Object.keys(globalObj).toString();
const sourceString = globals.length ? globals + createEntropy(bigLength, random) : createEntropy(bigLength, random);
return hash(sourceString).substring(0, bigLength);
};
const createCounter = (count)=>()=>{
return count++;
};
// ~22k hosts before 50% chance of initial counter collision
// with a remaining counter range of 9.0e+15 in JavaScript.
const initialCountMax = 476782367;
const init = ({ // Fallback if the user does not pass in a CSPRNG. This should be OK
// because we don't rely solely on the random number generator for entropy.
// We also use the host fingerprint, current time, and a session counter.
random = Math.random, counter = createCounter(Math.floor(random() * initialCountMax)), length = defaultLength, fingerprint = createFingerprint({
random
}) } = {})=>{
return function cuid2() {
const firstLetter = randomLetter(random);
// If we're lucky, the `.toString(36)` calls may reduce hashing rounds
// by shortening the input to the hash function a little.
const time = Date.now().toString(36);
const count = counter().toString(36);
// The salt should be long enough to be globally unique across the full
// length of the hash. For simplicity, we use the same length as the
// intended id output.
const salt = createEntropy(length, random);
const hashInput = `${time + salt + count + fingerprint}`;
return `${firstLetter + hash(hashInput).substring(1, length)}`;
};
};
const createId = init();
const isCuid = (id, { minLength = 2, maxLength = bigLength } = {})=>{
const length = id.length;
const regex = /^[0-9a-z]+$/;
if (typeof id === "string" && length >= minLength && length <= maxLength && regex.test(id)) return true;
return false;
};
module.exports.getConstants = ()=>({
defaultLength,
bigLength
});
module.exports.init = init;
module.exports.createId = createId;
module.exports.bufToBigInt = bufToBigInt;
module.exports.createCounter = createCounter;
module.exports.createFingerprint = createFingerprint;
module.exports.isCuid = isCuid;
},{"d0dc733fdfe478ab":"24jOj"}],"24jOj":[function(require,module,exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = exports.keccakP = void 0;
const _assert_js_1 = require("b5d8367685d2f01a");
const _u64_js_1 = require("a1dd24a362368716");
const utils_js_1 = require("4f25a63eeb3984c4");
// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
// It's called a sponge function.
// Various per round constants calculations
const SHA3_PI = [];
const SHA3_ROTL = [];
const _SHA3_IOTA = [];
const _0n = /* @__PURE__ */ BigInt(0);
const _1n = /* @__PURE__ */ BigInt(1);
const _2n = /* @__PURE__ */ BigInt(2);
const _7n = /* @__PURE__ */ BigInt(7);
const _256n = /* @__PURE__ */ BigInt(256);
const _0x71n = /* @__PURE__ */ BigInt(0x71);
for(let round = 0, R = _1n, x = 1, y = 0; round < 24; round++){
// Pi
[x, y] = [
y,
(2 * x + 3 * y) % 5
];
SHA3_PI.push(2 * (5 * y + x));
// Rotational
SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
// Iota
let t = _0n;
for(let j = 0; j < 7; j++){
R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
if (R & _2n) t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n;
}
_SHA3_IOTA.push(t);
}
const [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ (0, _u64_js_1.split)(_SHA3_IOTA, true);
// Left rotation (without 0, 32, 64)
const rotlH = (h, l, s)=>s > 32 ? (0, _u64_js_1.rotlBH)(h, l, s) : (0, _u64_js_1.rotlSH)(h, l, s);
const rotlL = (h, l, s)=>s > 32 ? (0, _u64_js_1.rotlBL)(h, l, s) : (0, _u64_js_1.rotlSL)(h, l, s);
// Same as keccakf1600, but allows to skip some rounds
function keccakP(s, rounds = 24) {
const B = new Uint32Array(10);
// NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)
for(let round = 24 - rounds; round < 24; round++){
// Theta θ
for(let x = 0; x < 10; x++)B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
for(let x = 0; x < 10; x += 2){
const idx1 = (x + 8) % 10;
const idx0 = (x + 2) % 10;
const B0 = B[idx0];
const B1 = B[idx0 + 1];
const Th = rotlH(B0, B1, 1) ^ B[idx1];
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
for(let y = 0; y < 50; y += 10){
s[x + y] ^= Th;
s[x + y + 1] ^= Tl;
}
}
// Rho (ρ) and Pi (π)
let curH = s[2];
let curL = s[3];
for(let t = 0; t < 24; t++){
const shift = SHA3_ROTL[t];
const Th = rotlH(curH, curL, shift);
const Tl = rotlL(curH, curL, shift);
const PI = SHA3_PI[t];
curH = s[PI];
curL = s[PI + 1];
s[PI] = Th;
s[PI + 1] = Tl;
}
// Chi (χ)
for(let y = 0; y < 50; y += 10){
for(let x = 0; x < 10; x++)B[x] = s[y + x];
for(let x = 0; x < 10; x++)s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
}
// Iota (ι)
s[0] ^= SHA3_IOTA_H[round];
s[1] ^= SHA3_IOTA_L[round];
}
B.fill(0);
}
exports.keccakP = keccakP;
class Keccak extends utils_js_1.Hash {
// NOTE: we accept arguments in bytes instead of bits here.
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24){
super();
this.blockLen = blockLen;
this.suffix = suffix;
this.outputLen = outputLen;
this.enableXOF = enableXOF;
this.rounds = rounds;
this.pos = 0;
this.posOut = 0;
this.finished = false;
this.destroyed = false;
// Can be passed from user as dkLen
(0, _assert_js_1.number)(outputLen);
// 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
if (0 >= this.blockLen || this.blockLen >= 200) throw new Error("Sha3 supports only keccak-f1600 function");
this.state = new Uint8Array(200);
this.state32 = (0, utils_js_1.u32)(this.state);
}
keccak() {
if (!utils_js_1.isLE) (0, utils_js_1.byteSwap32)(this.state32);
keccakP(this.state32, this.rounds);
if (!utils_js_1.isLE) (0, utils_js_1.byteSwap32)(this.state32);
this.posOut = 0;
this.pos = 0;
}
update(data) {
(0, _assert_js_1.exists)(this);
const { blockLen, state } = this;
data = (0, utils_js_1.toBytes)(data);
const len = data.length;
for(let pos = 0; pos < len;){
const take = Math.min(blockLen - this.pos, len - pos);
for(let i = 0; i < take; i++)state[this.pos++] ^= data[pos++];
if (this.pos === blockLen) this.keccak();
}
return this;
}
finish() {
if (this.finished) return;
this.finished = true;
const { state, suffix, pos, blockLen } = this;
// Do the padding
state[pos] ^= suffix;
if ((suffix & 0x80) !== 0 && pos === blockLen - 1) this.keccak();
state[blockLen - 1] ^= 0x80;
this.keccak();
}
writeInto(out) {
(0, _assert_js_1.exists)(this, false);
(0, _assert_js_1.bytes)(out);
this.finish();
const bufferOut = this.state;
const { blockLen } = this;
for(let pos = 0, len = out.length; pos < len;){
if (this.posOut >= blockLen) this.keccak();
const take = Math.min(blockLen - this.posOut, len - pos);
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
this.posOut += take;
pos += take;
}
return out;
}
xofInto(out) {
// Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF
if (!this.enableXOF) throw new Error("XOF is not possible for this instance");
return this.writeInto(out);
}
xof(bytes) {
(0, _assert_js_1.number)(bytes);
return this.xofInto(new Uint8Array(bytes));
}
digestInto(out) {
(0, _assert_js_1.output)(out, this);
if (this.finished) throw new Error("digest() was already called");
this.writeInto(out);
this.destroy();
return out;
}
digest() {
return this.digestInto(new Uint8Array(this.outputLen));
}
destroy() {
this.destroyed = true;
this.state.fill(0);
}
_cloneInto(to) {
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
to.state32.set(this.state32);
to.pos = this.pos;
to.posOut = this.posOut;
to.finished = this.finished;
to.rounds = rounds;
// Suffix can change in cSHAKE
to.suffix = suffix;
to.outputLen = outputLen;
to.enableXOF = enableXOF;
to.destroyed = this.destroyed;
return to;
}
}
exports.Keccak = Keccak;
const gen = (suffix, blockLen, outputLen)=>(0, utils_js_1.wrapConstructor)(()=>new Keccak(blockLen, suffix, outputLen));
exports.sha3_224 = gen(0x06, 144, 28);
/**
* SHA3-256 hash function
* @param message - that would be hashed
*/ exports.sha3_256 = gen(0x06, 136, 32);
exports.sha3_384 = gen(0x06, 104, 48);
exports.sha3_512 = gen(0x06, 72, 64);
exports.keccak_224 = gen(0x01, 144, 28);
/**
* keccak-256 hash function. Different from SHA3-256.
* @param message - that would be hashed
*/ exports.keccak_256 = gen(0x01, 136, 32);
exports.keccak_384 = gen(0x01, 104, 48);
exports.keccak_512 = gen(0x01, 72, 64);
const genShake = (suffix, blockLen, outputLen)=>(0, utils_js_1.wrapXOFConstructorWithOpts)((opts = {})=>new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
exports.shake128 = genShake(0x1f, 168, 16);
exports.shake256 = genShake(0x1f, 136, 32);
},{"b5d8367685d2f01a":"b192z","a1dd24a362368716":"8Lv7M","4f25a63eeb3984c4":"94JMP"}],"b192z":[function(require,module,exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.output = exports.exists = exports.hash = exports.bytes = exports.bool = exports.number = exports.isBytes = void 0;
function number(n) {
if (!Number.isSafeInteger(n) || n < 0) throw new Error(`positive integer expected, not ${n}`);
}
exports.number = number;
function bool(b) {
if (typeof b !== "boolean") throw new Error(`boolean expected, not ${b}`);
}
exports.bool = bool;
// copied from utils
function isBytes(a) {
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
}
exports.isBytes = isBytes;
function bytes(b, ...lengths) {
if (!isBytes(b)) throw new Error("Uint8Array expected");
if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
}
exports.bytes = bytes;
function hash(h) {
if (typeof h !== "function" || typeof h.create !== "function") throw new Error("Hash should be wrapped by utils.wrapConstructor");
number(h.outputLen);
number(h.blockLen);
}
exports.hash = hash;
function exists(instance, checkFinished = true) {
if (instance.destroyed) throw new Error("Hash instance has been destroyed");
if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called");
}
exports.exists = exists;
function output(out, instance) {
bytes(out);
const min = instance.outputLen;
if (out.length < min) throw new Error(`digestInto() expects output buffer of length at least ${min}`);
}
exports.output = output;
const assert = {
number,
bool,
bytes,
hash,
exists,
output
};
exports.default = assert;
},{}],"8Lv7M":[function(require,module,exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.add = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = exports.split = exports.fromBig = void 0;
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
const _32n = /* @__PURE__ */ BigInt(32);
// We are not using BigUint64Array, because they are extremely slow as per 2022
function fromBig(n, le = false) {
if (le) return {
h: Number(n & U32_MASK64),
l: Number(n >> _32n & U32_MASK64)
};
return {
h: Number(n >> _32n & U32_MASK64) | 0,
l: Number(n & U32_MASK64) | 0
};
}
exports.fromBig = fromBig;
function split(lst, le = false) {
let Ah = new Uint32Array(lst.length);
let Al = new Uint32Array(lst.length);
for(let i = 0; i < lst.length; i++){
const { h, l } = fromBig(lst[i], le);
[Ah[i], Al[i]] = [
h,
l
];
}
return [
Ah,
Al
];
}
exports.split = split;
const toBig = (h, l)=>BigInt(h >>> 0) << _32n | BigInt(l >>> 0);
exports.toBig = toBig;
// for Shift in [0, 32)
const shrSH = (h, _l, s)=>h >>> s;
exports.shrSH = shrSH;
const shrSL = (h, l, s)=>h << 32 - s | l >>> s;
exports.shrSL = shrSL;
// Right rotate for Shift in [1, 32)
const rotrSH = (h, l, s)=>h >>> s | l << 32 - s;
exports.rotrSH = rotrSH;
const rotrSL = (h, l, s)=>h << 32 - s | l >>> s;
exports.rotrSL = rotrSL;
// Right rotate for Shift in (32, 64), NOTE: 32 is special case.
const rotrBH = (h, l, s)=>h << 64 - s | l >>> s - 32;
exports.rotrBH = rotrBH;
const rotrBL = (h, l, s)=>h >>> s - 32 | l << 64 - s;
exports.rotrBL = rotrBL;
// Right rotate for shift===32 (just swaps l&h)
const rotr32H = (_h, l)=>l;
exports.rotr32H = rotr32H;
const rotr32L = (h, _l)=>h;
exports.rotr32L = rotr32L;
// Left rotate for Shift in [1, 32)
const rotlSH = (h, l, s)=>h << s | l >>> 32 - s;
exports.rotlSH = rotlSH;
const rotlSL = (h, l, s)=>l << s | h >>> 32 - s;
exports.rotlSL = rotlSL;
// Left rotate for Shift in (32, 64), NOTE: 32 is special case.
const rotlBH = (h, l, s)=>l << s - 32 | h >>> 64 - s;
exports.rotlBH = rotlBH;
const rotlBL = (h, l, s)=>h << s - 32 | l >>> 64 - s;
exports.rotlBL = rotlBL;
// JS uses 32-bit signed integers for bitwise operations which means we cannot
// simple take carry out of low bit sum by shift, we need to use division.
function add(Ah, Al, Bh, Bl) {
const l = (Al >>> 0) + (Bl >>> 0);
return {
h: Ah + Bh + (l / 2 ** 32 | 0) | 0,
l: l | 0
};
}
exports.add = add;
// Addition with more than 2 elements
const add3L = (Al, Bl, Cl)=>(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
exports.add3L = add3L;
const add3H = (low, Ah, Bh, Ch)=>Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
exports.add3H = add3H;
const add4L = (Al, Bl, Cl, Dl)=>(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
exports.add4L = add4L;
const add4H = (low, Ah, Bh, Ch, Dh)=>Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
exports.add4H = add4H;
const add5L = (Al, Bl, Cl, Dl, El)=>(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
exports.add5L = add5L;
const add5H = (low, Ah, Bh, Ch, Dh, Eh)=>Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
exports.add5H = add5H;
// prettier-ignore
const u64 = {
fromBig,
split,
toBig,
shrSH,
shrSL,
rotrSH,
rotrSL,
rotrBH,
rotrBL,
rotr32H,
rotr32L,
rotlSH,
rotlSL,
rotlBH,
rotlBL,
add,
add3L,
add3H,
add4L,
add4H,
add5H,
add5L
};
exports.default = u64;
},{}],"94JMP":[function(require,module,exports) {
"use strict";
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ Object.defineProperty(exports, "__esModule", {
value: true
});
exports.randomBytes = exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.byteSwap32 = exports.byteSwapIfBE = exports.byteSwap = exports.isLE = exports.rotl = exports.rotr = exports.createView = exports.u32 = exports.u8 = exports.isBytes = void 0;
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
// node.js versions earlier than v19 don't declare it in global scope.
// For node.js, package.json#exports field mapping rewrites import
// from `crypto` to `cryptoNode`, which imports native module.
// Makes the utils un-importable in browsers without a bundler.
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
const crypto_1 = require("59719913569e95e6");
const _assert_js_1 = require("7db109b6118697b1");
// export { isBytes } from './_assert.js';
// We can't reuse isBytes from _assert, because somehow this causes huge perf issues
function isBytes(a) {
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
}
exports.isBytes = isBytes;
// Cast array to different type
const u8 = (arr)=>new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
exports.u8 = u8;
const u32 = (arr)=>new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
exports.u32 = u32;
// Cast array to view
const createView = (arr)=>new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
exports.createView = createView;
// The rotate right (circular right shift) operation for uint32
const rotr = (word, shift)=>word << 32 - shift | word >>> shift;
exports.rotr = rotr;
// The rotate left (circular left shift) operation for uint32
const rotl = (word, shift)=>word << shift | word >>> 32 - shift >>> 0;
exports.rotl = rotl;
exports.isLE = new Uint8Array(new Uint32Array([
0x11223344
]).buffer)[0] === 0x44;
// The byte swap operation for uint32
const byteSwap = (word)=>word << 24 & 0xff000000 | word << 8 & 0xff0000 | word >>> 8 & 0xff00 | word >>> 24 & 0xff;
exports.byteSwap = byteSwap;
// Conditionally byte swap if on a big-endian platform
exports.byteSwapIfBE = exports.isLE ? (n)=>n : (n)=>(0, exports.byteSwap)(n);
// In place byte swap for Uint32Array
function byteSwap32(arr) {
for(let i = 0; i < arr.length; i++)arr[i] = (0, exports.byteSwap)(arr[i]);
}
exports.byteSwap32 = byteSwap32;
// Array where index 0xf0 (240) is mapped to string 'f0'
const hexes = /* @__PURE__ */ Array.from({
length: 256
}, (_, i)=>i.toString(16).padStart(2, "0"));
/**
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
*/ function bytesToHex(bytes) {
(0, _assert_js_1.bytes)(bytes);
// pre-caching improves the speed 6x
let hex = "";
for(let i = 0; i < bytes.length; i++)hex += hexes[bytes[i]];
return hex;
}
exports.bytesToHex = bytesToHex;
// We use optimized technique to convert hex string to byte array
const asciis = {
_0: 48,
_9: 57,
_A: 65,
_F: 70,
_a: 97,
_f: 102
};
function asciiToBase16(char) {
if (char >= asciis._0 && char <= asciis._9) return char - asciis._0;
if (char >= asciis._A && char <= asciis._F) return char - (asciis._A - 10);
if (char >= asciis._a && char <= asciis._f) return char - (asciis._a - 10);
return;
}
/**
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
*/ function hexToBytes(hex) {
if (typeof hex !== "string") throw new Error("hex string expected, got " + typeof hex);
const hl = hex.length;
const al = hl / 2;
if (hl % 2) throw new Error("padded hex string expected, got unpadded hex of length " + hl);
const array = new Uint8Array(al);
for(let ai = 0, hi = 0; ai < al; ai++, hi += 2){
const n1 = asciiToBase16(hex.charCodeAt(hi));
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
if (n1 === undefined || n2 === undefined) {
const char = hex[hi] + hex[hi + 1];
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
}
array[ai] = n1 * 16 + n2;
}
return array;
}
exports.hexToBytes = hexToBytes;
// There is no setImmediate in browser and setTimeout is slow.
// call of async fn will return Promise, which will be fullfiled only on
// next scheduler queue processing step and this is exactly what we need.
const nextTick = async ()=>{};
exports.nextTick = nextTick;
// Returns control to thread each 'tick' ms to avoid blocking
async function asyncLoop(iters, tick, cb) {
let ts = Date.now();
for(let i = 0; i < iters; i++){
cb(i);
// Date.now() is not monotonic, so in case if clock goes backwards we return return control too
const diff = Date.now() - ts;
if (diff >= 0 && diff < tick) continue;
await (0, exports.nextTick)();
ts += diff;
}
}
exports.asyncLoop = asyncLoop;
/**
* @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
*/ function utf8ToBytes(str) {
if (typeof str !== "string") throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
}
exports.utf8ToBytes = utf8ToBytes;
/**
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
* Warning: when Uint8Array is passed, it would NOT get copied.
* Keep in mind for future mutable operations.
*/ function toBytes(data) {
if (typeof data === "string") data = utf8ToBytes(data);
(0, _assert_js_1.bytes)(data);
return data;
}
exports.toBytes = toBytes;
/**
* Copies several Uint8Arrays into one.
*/ function concatBytes(...arrays) {
let sum = 0;
for(let i = 0; i < arrays.length; i++){
const a = arrays[i];
(0, _assert_js_1.bytes)(a);
sum += a.length;
}
const res = new Uint8Array(sum);
for(let i = 0, pad = 0; i < arrays.length; i++){
const a = arrays[i];
res.set(a, pad);
pad += a.length;
}
return res;
}
exports.concatBytes = concatBytes;
// For runtime check if class implements interface
class Hash {
// Safe version that clones internal state
clone() {
return this._cloneInto();
}
}
exports.Hash = Hash;
const toStr = {}.toString;
function checkOpts(defaults, opts) {
if (opts !== undefined && toStr.call(opts) !== "[object Object]") throw new Error("Options should be object or undefined");
const merged = Object.assign(defaults, opts);
return merged;
}
exports.checkOpts = checkOpts;
function wrapConstructor(hashCons) {
const hashC = (msg)=>hashCons().update(toBytes(msg)).digest();
const tmp = hashCons();
hashC.outputLen = tmp.outputLen;
hashC.blockLen = tmp.blockLen;
hashC.create = ()=>hashCons();
return hashC;
}
exports.wrapConstructor = wrapConstructor;
function wrapConstructorWithOpts(hashCons) {
const hashC = (msg, opts)=>hashCons(opts).update(toBytes(msg)).digest();
const tmp = hashCons({});
hashC.outputLen = tmp.outputLen;
hashC.blockLen = tmp.blockLen;
hashC.create = (opts)=>hashCons(opts);
return hashC;
}
exports.wrapConstructorWithOpts = wrapConstructorWithOpts;
function wrapXOFConstructorWithOpts(hashCons) {
const hashC = (msg, opts)=>hashCons(opts).update(toBytes(msg)).digest();
const tmp = hashCons({});
hashC.outputLen = tmp.outputLen;
hashC.blockLen = tmp.blockLen;
hashC.create = (opts)=>hashCons(opts);
return hashC;
}
exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;
/**
* Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.
*/ function randomBytes(bytesLength = 32) {
if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
throw new Error("crypto.getRandomValues must be defined");
}
exports.randomBytes = randomBytes;
},{"59719913569e95e6":"lFXxs","7db109b6118697b1":"b192z"}],"lFXxs":[function(require,module,exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.crypto = void 0;
exports.crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : undefined;
},{}],"6QRQn":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "initLoadComp", ()=>initLoadComp);
var _meta = require("../meta");
const initLoadComp = async (p, item, opt, _loaded)=>{
const comp_ids = new Set();
const shared = {
root: item
};
const comps = [];
(0, _meta.genMeta)({
...p,
on: {
visit_component: ({ component })=>{
if (component) {
const { id } = component;
if (!p.comps[id]) {
if (!_loaded || _loaded && !_loaded.has(id)) comp_ids.add(id);
}
comps.push(component);
}
},
visit (meta, vitem) {
if (opt.visit) opt.visit(meta, vitem, shared);
}
},
set_meta: false,
note: "init-load-comp"
}, {
item,
ignore_first_component: true
});
if (opt.done) opt.done(shared);
let loaded = _loaded;
if (!loaded) loaded = new Set();
if (comp_ids.size > 0) {
await opt.load([
...comp_ids
]);
comp_ids.forEach((id)=>{
if (loaded) loaded.add(id);
});
for (const id of [
...loaded
]){
const comp = p.comps[id];
if (comp) await initLoadComp(p, comp, opt, loaded);
}
}
for (const component of comps)if (component.props) {
for (const prop of Object.values(component.props))if (prop.meta?.type === "content-element" && prop.content) await initLoadComp(p, prop.content, opt, loaded);
}
};
},{"../meta":"4JpTf","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"4JpTf":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "genMeta", ()=>genMeta);
var _comp = require("./comp");
var _simplify = require("./simplify");
const genMeta = (p, arg)=>{
const item = arg.item;
if (item.type === "item" && item.component?.id) {
if (arg.ignore_first_component !== true) {
(0, _comp.genComp)(p, arg);
return;
}
}
const meta = {
item: (0, _simplify.simplifyItemChild)(item),
parent: {
id: arg.parent?.item.id || "root",
instance_id: arg.parent?.instance_id,
comp_id: arg.parent?.comp?.component?.id
}
};
if (arg.jsx_prop) meta.jsx_prop = arg.jsx_prop;
if (p.on?.visit) p.on.visit(meta, item, arg.root || arg.item);
if (item.id) {
if (p.set_meta !== false) p.meta[meta.item.id] = meta;
}
if (item.childs) {
for (const [_, v] of Object.entries(item.childs))if (v.id) {
const carg = {
item: v,
is_root: false,
root: arg.root || arg.item,
parent: {
item: meta.item,
instance_id: arg.parent?.instance_id,
comp: arg.parent?.comp,
root_instances: arg.parent?.root_instances
}
};
if (arg.jsx_prop) carg.jsx_prop = {
...arg.jsx_prop,
is_root: false
};
genMeta(p, carg);
}
}
};
},{"./comp":"1EtyT","./simplify":"iHOZk","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"1EtyT":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "genComp", ()=>genComp);
var _instantiate = require("./comp/instantiate");
var _walkProp = require("./comp/walk-prop");
var _meta = require("./meta");
var _simplify = require("./simplify");
const genComp = (p, arg)=>{
const { item } = arg;
if (item.type === "item" && item.component?.id && arg.parent?.item.id) {
let item_comp = p.comps[item.component.id];
if (p.on?.visit_component) p.on.visit_component(item, arg.root || arg.item);
if (!item_comp) return;
if (item_comp) {
let instances = undefined;
if (p.mode === "page") {
if (!item.component.instances) item.component.instances = {};
instances = item.component.instances;
} else instances = arg.parent?.root_instances;
if (instances) {
let instance = instances[item.id];
if (!instances[item.id]) {
instances[item.id] = {};
instance = instances[item.id];
}
(0, _instantiate.instantiate)({
item,
item_comp: item_comp,
ids: instance
});
}
const meta = {
item: (0, _simplify.simplifyItemChild)(item),
jsx_prop: arg.jsx_prop,
parent: {
id: arg.parent.item.id,
comp_id: arg.parent?.comp?.component?.id,
instance_id: arg.parent?.instance_id
},
instances
};
if (p.on?.visit) p.on.visit(meta, item, arg.root || arg.item);
if (item.id) {
if (p.set_meta !== false) p.meta[item.id] = meta;
}
(0, _walkProp.walkProp)({
item,
item_comp: item_comp,
instance: instances ? instances[item.id] : {},
each (name, prop) {
const comp_id = item.component?.id;
if (prop.meta?.type === "content-element" && comp_id) {
if (prop.content) {
prop.content.name = name;
(0, _meta.genMeta)({
...p
}, {
item: prop.content,
root: arg.root || prop.content,
is_root: false,
jsx_prop: {
is_root: true,
comp_id,
name
},
parent: {
item: meta.item,
instance_id: item.id,
comp: item_comp,
root_instances: instances
}
});
}
}
}
});
if (item.childs) for (const child of Object.values(item.childs)){
if (child?.name?.startsWith("jsx:")) continue;
if (child && Object.keys(child).length > 3) (0, _meta.genMeta)({
...p,
mode: "comp"
}, {
item: child,
is_root: false,
root: arg.root || arg.item,
parent: {
item,
instance_id: item.id,
root_instances: instances,
comp: item_comp
}
});
}
}
}
};
},{"./comp/instantiate":"3xTLr","./comp/walk-prop":"8OFuM","./meta":"4JpTf","./simplify":"iHOZk","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"3xTLr":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "instantiate", ()=>instantiate);
parcelHelpers.export(exports, "walkChild", ()=>walkChild);
var _cuid2 = require("@paralleldrive/cuid2");
var _webUtils = require("web-utils");
const instantiate = (arg)=>{
const { item, item_comp, ids } = arg;
const newitem = (0, _webUtils.deepClone)(item_comp);
walkChild(newitem, ids);
if (item.id) newitem.id = item.id;
newitem.hidden = item.hidden;
if (newitem.component) {
if (newitem.component.props && item.component && item.component.props) for (const k of Object.keys(newitem.component.props)){
const cprop = item.component.props[k];
const nprop = newitem.component.props[k];
if (cprop) {
nprop.value = cprop.value;
nprop.valueBuilt = cprop.valueBuilt;
nprop.jsxCalledBy = cprop.jsxCalledBy;
nprop.content = cprop.content;
}
}
newitem.component.instances = item.component?.instances;
newitem.component.style = item.component?.style;
}
for (const key of Object.keys(item))delete item[key];
for (const [k, v] of Object.entries(newitem))item[k] = v;
};
const walkChild = (item, ids)=>{
item.originalId = item.id;
if (!ids[item.id]) ids[item.id] = (0, _cuid2.createId)();
item.id = ids[item.id];
if (item.childs) for (const child of item.childs)walkChild(child, ids);
};
},{"@paralleldrive/cuid2":"41M7L","web-utils":"aOKw0","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8OFuM":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "walkProp", ()=>walkProp);
var _webUtils = require("web-utils");
const walkProp = (arg)=>{
const props = Object.entries(arg.item_comp.component?.props || {}).sort((a, b)=>{
return a[1].idx - b[1].idx;
});
for (const [k, v] of props){
let prop = (0, _webUtils.deepClone)(v);
const props = arg.item.component?.props;
if (props && props[k]) {
prop.value = props[k].value;
prop.valueBuilt = props[k].valueBuilt;
if (props[k].content) prop.content = props[k].content;
}
if (prop) arg.each(k, prop);
}
};
},{"web-utils":"aOKw0","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"iHOZk":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "simplifyItemChild", ()=>simplifyItemChild);
parcelHelpers.export(exports, "simplifyMeta", ()=>simplifyMeta);
const simplifyItemChild = (item)=>{
const newitem = {};
for (const [k, v] of Object.entries(item))if (k === "childs") {
newitem.childs = [];
if (v && Array.isArray(v)) {
for (const child of v)if (child.type === "item" && child.component) newitem.childs.push(child);
else newitem.childs.push({
name: child.name,
id: child.id,
originalId: child.originalId
});
}
} else newitem[k] = v;
return newitem;
};
const simplifyMeta = (allmeta)=>{
const smeta = {};
for (const [k, meta] of Object.entries(allmeta))smeta[k] = {
id: meta.item.id,
parent: meta.parent ? {
id: meta.parent.id,
comp_id: meta.parent.comp_id,
instance_id: meta.parent.instance_id
} : undefined,
comp: meta.item.component && meta.instances ? {
id: meta.item.component.id,
instances: meta.instances
} : undefined
};
return smeta;
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"1zeD1":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "isTextEditing", ()=>isTextEditing);
const isTextEditing = ()=>{
const el = document.activeElement;
if (el && el.attributes.getNamedItem("contenteditable")) return true;
return false;
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fUXV7":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "assignMitem", ()=>assignMitem);
var _cuid2 = require("@paralleldrive/cuid2");
const assignMitem = (arg)=>{
const { m, root, mitem, meta } = arg;
if (m.jsx_prop && m.parent?.instance_id) {
const instance_meta = meta[m.parent?.instance_id];
if (instance_meta) {
if (m.jsx_prop.is_root) {
const prop = instance_meta.item.component?.props[m.jsx_prop.name];
if (prop) prop.content = m.item;
}
}
}
if (m.parent) {
if (m.parent.id === "root") {
if (m.item.id === root.id) m.mitem = mitem;
} else {
let parent = meta[m.parent.id];
if (!parent.mitem && m.parent.instance_id && meta[m.parent.instance_id]) parent = meta[m.parent.instance_id];
if (parent.mitem) {
if (m.jsx_prop?.is_root === true) {
const mprops = parent.mitem.get("component")?.get("props");
if (mprops) {
const mprop = mprops.get(m.jsx_prop.name);
if (mprop) {
const mcontent = mprop.get("content");
if (!mcontent) {
const map = new Y.Map();
syncronize(map, {
id: (0, _cuid2.createId)(),
name: m.jsx_prop.name,
type: "item",
dim: {
w: "full",
h: "full"
},
childs: [],
adv: {
css: ""
}
});
mprop.set("content", map);
}
if (mcontent) m.mitem = mcontent;
}
}
} else parent.mitem.get("childs")?.forEach((child)=>{
const id = child && child.get && child.get("id");
if (typeof id === "string" && id === m.item.id) m.mitem = child;
});
}
if (m.item.component?.props) for (const [prop_name, v] of Object.entries(m.item.component.props)){
let mprop = m.mitem?.get("component")?.get("props")?.get(prop_name);
if (!mprop) {
const mprops = m.mitem?.get("component")?.get("props");
if (mprops) arg.new_prop_jsx(m, mprops, prop_name, v);
}
if (v.content) {
if (mprop) {
const pmeta = meta[v.content.id];
if (pmeta) pmeta.mitem = mprop.get("content");
} else {
const mprops = m.mitem?.get("component")?.get("props");
if (mprops) arg.new_prop_jsx(m, mprops, prop_name, v);
}
}
}
}
}
};
},{"@paralleldrive/cuid2":"41M7L","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"53DOC":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "treeCacheBuild", ()=>treeCacheBuild);
parcelHelpers.export(exports, "treeRebuild", ()=>treeRebuild);
var _idbKeyval = require("idb-keyval");
var _initCompLoad = require("../../../vi/meta/comp/init-comp-load");
var _meta = require("../../../vi/meta/meta");
var _extractNav = require("../../../vi/render/script/extract-nav");
var _load = require("../comp/load");
var _edGlobal = require("../ed-global");
var _assignMitem = require("./assign-mitem");
var _pushTree = require("./build/push-tree");
const treeCacheBuild = async (p, page_id)=>{
const page_cache = p.preview.page_cache[page_id];
if (page_cache) {
const meta_cache = {
meta: {},
entry: [],
url: page_cache.url
};
await (0, _initCompLoad.initLoadComp)({
comps: p.comp.loaded,
meta: meta_cache.meta,
mode: "page"
}, page_cache.root, {
async load (comp_ids) {
if (!p.sync) return;
const ids = comp_ids.filter((id)=>!p.comp.loaded[id]);
const comps = await p.sync.comp.load(ids, true);
let result = Object.entries(comps);
for (const [id_comp, comp] of result){
const cached = await (0, _idbKeyval.get)(`comp-${id_comp}`, (0, _extractNav.nav).store);
if (cached) p.comp.loaded[id_comp] = cached;
if (comp && comp.snapshot && !p.comp.list[id_comp]) {
if (p.comp.loaded[id_comp]) (0, _load.loadCompSnapshot)(p, id_comp, comp.snapshot).then(()=>{
if (p.comp.loaded[id_comp]) (0, _idbKeyval.set)(`comp-${id_comp}`, p.comp.loaded[id_comp], (0, _extractNav.nav).store);
});
else {
await (0, _load.loadCompSnapshot)(p, id_comp, comp.snapshot);
if (p.comp.loaded[id_comp]) (0, _idbKeyval.set)(`comp-${id_comp}`, p.comp.loaded[id_comp], (0, _extractNav.nav).store);
}
}
}
}
});
for (const item of page_cache.root.childs){
meta_cache.entry.push(item.id);
(0, _meta.genMeta)({
note: "cache-rebuild",
comps: p.comp.loaded,
meta: meta_cache.meta,
mode: "page"
}, {
item: item
});
}
p.preview.meta_cache[page_id] = meta_cache;
(0, _idbKeyval.set)(`page-${page_id}`, meta_cache, (0, _extractNav.nav).store);
}
};
const treeRebuild = async (p, arg)=>{
if (document.activeElement) {
const a = document.activeElement;
if (a.tagName === "DIV" && a.getAttribute("contenteditable") === "true") return;
}
(0, _edGlobal.active).should_render_main = true;
const is_layout = p.site.layout && p.site.layout.id === p.page.cur.id && arg?.note === "load-layout page-init";
for (const [k, v] of Object.entries(p.comp.list))if (!p.comp.loaded[k]) {
const mcomp = v.doc.getMap("map").get("root");
const icomp = mcomp?.toJSON();
if (icomp) p.comp.loaded[k] = icomp;
}
const mroot = p.page.doc?.getMap("map").get("root");
const mitems = [];
mroot?.get("childs")?.forEach((m)=>mitems.push(m));
const meta = {};
p.page.tree = [];
for (const mitem of mitems){
const item = mitem.toJSON();
if (item) {
await (0, _initCompLoad.initLoadComp)({
comps: p.comp.loaded,
meta,
mode: "page"
}, item, {
async load (comp_ids) {
for (const id of comp_ids)await (0, _load.loadComponent)(p, id);
}
});
(0, _meta.genMeta)({
note: "tree-rebuild",
comps: p.comp.loaded,
meta,
mode: "page",
on: {
async visit (m) {
if (!is_layout) {
if (m.parent?.instance_id !== m.parent?.id || m.jsx_prop) (0, _pushTree.pushTreeNode)(p, m, meta, p.page.tree);
(0, _assignMitem.assignMitem)({
m,
root: item,
mitem,
meta,
new_prop_jsx (meta, mprops, prop_name, prop_val) {
if (!mprops.get(prop_name)) {
const map = new Y.Map();
syncronize(map, prop_val);
mprops.set(prop_name, map);
}
}
});
}
}
}
}, {
item
});
}
}
if (is_layout) p.site.layout.meta = meta;
else {
let root_id = "root";
if (p.site.layout && p.site.layout.meta) {
for (const [_, v] of Object.entries(p.site.layout.meta))if (v.item.name === "content") {
root_id = v.item.id;
break;
}
p.page.root_id = root_id;
}
if (p.site.layout && p.site.layout.id === p.page.cur.id) p.page.meta = meta;
else if (root_id !== "root") {
for (const m of Object.values(meta))if (m.parent?.id === "root") m.parent.id = root_id;
p.page.meta = {
...p.site.layout.meta,
...meta
};
} else p.page.meta = meta;
}
};
},{"idb-keyval":"in1MU","../../../vi/meta/comp/init-comp-load":"6QRQn","../../../vi/meta/meta":"4JpTf","../../../vi/render/script/extract-nav":"kVlwd","../comp/load":"fQ2tn","../ed-global":"5VTke","./assign-mitem":"fUXV7","./build/push-tree":"ipgUQ","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"kVlwd":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "nav", ()=>nav);
parcelHelpers.export(exports, "extractNavigate", ()=>extractNavigate);
var _idbKeyval = require("idb-keyval");
const store = (0, _idbKeyval.createStore)(`prasi-cache`, `prasi-cache-store`);
const nav = {
timeout: null,
store
};
const extractNavigate = (vi, str)=>{
const found_nav = [
...findBetween(str, `navigate(`, `)`),
...findBetween(str, `href = `, `;`)
];
const page_id = vi.page.cur.id;
if (!vi.page.navs[page_id]) vi.page.navs[page_id] = new Set();
for (const url of found_nav)vi.page.navs[page_id].add(url);
clearTimeout(nav.timeout);
nav.timeout = setTimeout(()=>{
if (vi.on_nav_loaded) vi.on_nav_loaded({
urls: Array.from(vi.page.navs[page_id])
});
}, 100);
};
const findBetween = (text, opener, closer)=>{
let i = 0;
let last = 0;
const founds = [];
while(true){
const startIndex = text.indexOf(opener, i);
last = i;
if (startIndex >= 0) {
const char = text[startIndex + opener.length];
if (char === '"' || char === "'" || char === "`") {
const end = text.indexOf(`${char}${closer}`, startIndex + opener.length + 1);
const found = text.substring(startIndex + opener.length + 1, end);
i = end + 2 + closer.length;
founds.push(found);
}
}
if (last === i) break;
}
return founds;
};
},{"idb-keyval":"in1MU","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"ipgUQ":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "pushTreeNode", ()=>pushTreeNode);
var _cuid2 = require("@paralleldrive/cuid2");
const pushTreeNode = (p, meta, metas, tree)=>{
if (meta.parent?.id === "root") p.page.doc?.getMap("map").get("root")?.get("childs")?.forEach((mitem)=>{
if (mitem.get("id") === meta.item.id) meta.mitem = mitem;
});
else {
const parent = metas[meta.parent?.id || ""];
if (parent && parent.mitem) {
parent.mitem.get("childs")?.forEach((mitem)=>{
if (mitem && mitem.get && mitem.get("id") === meta.item.id) meta.mitem = mitem;
});
parent.mitem.get("component")?.get("props")?.forEach((v, k)=>{
if (typeof v === "object") {
if (v?.get("meta")?.get("type") === "content-element") {
const mitem = v?.get("content");
if (mitem && meta.item.id === mitem.get("id")) meta.mitem = mitem;
}
}
});
}
}
if (!meta.item || !meta.item.id) {
console.error("Emptry Tree Item ", meta);
return null;
}
if (tree.find((t)=>t.id === meta.item.id)) {
console.error("Double Tree Item: ", meta.item.id, meta.item.name);
meta.mitem?.set("id", (0, _cuid2.createId)());
} else {
if (!meta.parent?.comp_id) tree.push({
id: meta.item.id,
parent: meta.parent?.id || "root",
text: meta.item.name,
data: meta
});
else if (meta.jsx_prop) {
if (meta.jsx_prop.is_root) {
if (meta.jsx_prop.name !== "child") tree.push({
id: meta.item.id,
parent: meta.parent?.instance_id || "root",
text: meta.jsx_prop.name,
data: meta
});
} else {
if (meta.jsx_prop.name === "child" && meta.parent.instance_id) {
const comp_meta = metas[meta.parent.instance_id];
const child_id = comp_meta.item.component?.props?.child?.content?.id;
if (child_id && comp_meta.mitem) {
const child_meta = metas[child_id];
if (child_meta.item.childs.find((e)=>meta.item.id === e.id)) tree.push({
id: meta.item.id,
parent: meta.parent?.instance_id || "root",
text: meta.item.name,
data: meta
});
}
}
if (meta.parent.id !== meta.parent.instance_id) tree.push({
id: meta.item.id,
parent: meta.parent?.id || "root",
text: meta.item.name,
data: meta
});
}
}
}
};
},{"@paralleldrive/cuid2":"41M7L","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fHUp0":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "edRoute", ()=>edRoute);
parcelHelpers.export(exports, "reloadLayout", ()=>reloadLayout);
parcelHelpers.export(exports, "reloadPage", ()=>reloadPage);
parcelHelpers.export(exports, "loadPageMetaCache", ()=>loadPageMetaCache);
parcelHelpers.export(exports, "savePageMetaCache", ()=>savePageMetaCache);
var _wasmGzip = require("wasm-gzip");
var _isEditing = require("./active/is-editing");
var _load = require("./comp/load");
var _edGlobal = require("./ed-global");
var _edSite = require("./ed-site");
var _build = require("./tree/build");
var _idbKeyval = require("idb-keyval");
var _extractNav = require("../../vi/render/script/extract-nav");
var Buffer = require("686da3b6f0fee310").Buffer;
const UPDATE_TIMEOUT = 0;
const edRoute = async (p)=>{
if (p.sync && (p.status === "ready" || p.status === "init")) {
if (!p.site.domain && !p.site.name) {
p.status = "load-site";
const site = await p.sync.site.load(p.site.id);
if (!site) {
p.status = "site-not-found";
p.render();
return;
}
await (0, _edSite.loadSite)(p, site, "from-route");
}
if (p.page.cur.id !== params.page_id || !p.page.cur.snapshot || !p.page.list[p.page.cur.id]) {
const page = p.page.list[params.page_id];
if (page && p.page.doc && page.on_update) {
p.page.doc.off("update", page.on_update);
const cur = p.page.list[params.page_id];
p.page.cur = cur.page;
p.page.doc = cur.doc;
}
await reloadPage(p, params.page_id, "load-route");
}
}
};
const reloadLayout = async (p, layout_id, note)=>{
if (!p.sync) return;
const remotePage = await p.sync.page.load(layout_id);
if (remotePage) {
if (remotePage.comps) {
for (const [id_comp, c] of Object.entries(remotePage.comps))if (c && c.snapshot) await (0, _load.loadCompSnapshot)(p, id_comp, c.snapshot);
}
if (remotePage.snapshot) {
const doc = new Y.Doc();
Y.applyUpdate(doc, (0, _wasmGzip.decompress)(remotePage.snapshot));
let page = p.page.list[remotePage.id];
if (!page) {
p.page.list[remotePage.id] = {};
page = p.page.list[remotePage.id];
}
if (page.on_update && page.doc) page.doc.off("update", page.on_update);
page.on_update = async (bin, origin)=>{
clearTimeout(page.update_timeout);
page.update_timeout = setTimeout(async ()=>{
if (origin === "local" || !p.sync) return;
console.log("page on update snap");
const res = await p.sync.yjs.sv_local("page", layout_id, Buffer.from((0, _wasmGzip.compress)(bin)));
if (res) {
if (res.sv === res.diff && res.sv === "not-found") {
console.warn("reload 1");
location.reload();
}
const diff_local = Y.encodeStateAsUpdate(doc, (0, _wasmGzip.decompress)(res.sv));
Y.applyUpdate(doc, (0, _wasmGzip.decompress)(res.diff), "local");
if (!(0, _isEditing.isTextEditing)()) await (0, _build.treeRebuild)(p, {
note: note + " page-on-update"
});
await p.sync.yjs.diff_local("page", p.page.cur.id, Buffer.from((0, _wasmGzip.compress)(diff_local)));
p.preview.page_cache[layout_id] = {
root,
url: "~~@$#%^#@~LAYOUT~~@$#%^#@~"
};
await (0, _build.treeCacheBuild)(p, layout_id);
p.render();
const meta_cache = p.preview.meta_cache[layout_id];
if (meta_cache) {
p.site.layout.meta = meta_cache.meta;
p.site.layout.entry = meta_cache.entry;
savePageMetaCache(p, meta_cache.meta);
}
}
}, UPDATE_TIMEOUT);
};
const root = doc.getMap("map").get("root")?.toJSON();
if (root) {
p.preview.page_cache[layout_id] = {
root,
url: "~~@$#%^#@~LAYOUT~~@$#%^#@~"
};
await (0, _build.treeCacheBuild)(p, layout_id);
const meta_cache = p.preview.meta_cache[layout_id];
if (meta_cache) {
p.site.layout.meta = meta_cache.meta;
p.site.layout.entry = meta_cache.entry;
savePageMetaCache(p, meta_cache.meta);
}
p.render();
}
}
}
};
const reloadPage = async (p, page_id, note, should_render)=>{
if (!p.sync) return;
p.status = "reload";
const remotePage = await p.sync.page.load(page_id);
if (!remotePage) {
p.status = "page-not-found";
p.render();
location.reload();
return;
}
if (remotePage.comps) {
for (const [id_comp, c] of Object.entries(remotePage.comps))if (c && c.snapshot) await (0, _load.loadCompSnapshot)(p, id_comp, c.snapshot);
}
p.page.cur = remotePage;
if (remotePage.snapshot) {
const doc = new Y.Doc();
Y.applyUpdate(doc, (0, _wasmGzip.decompress)(remotePage.snapshot));
let page = p.page.list[remotePage.id];
if (!page) {
p.page.list[remotePage.id] = {};
page = p.page.list[remotePage.id];
}
if (page.on_update && page.doc) page.doc.off("update", page.on_update);
page.on_update = async (bin, origin)=>{
clearTimeout(page.update_timeout);
page.update_timeout = setTimeout(async ()=>{
if (origin === "local" || !p.sync) return;
if (page.page.id !== remotePage.id) {
alert("Page ID Mismatch!\n Refreshing to preventing data loss...");
console.warn("reload 2");
location.reload();
return;
}
if (window.catch) throw new Error("woi");
const res = await p.sync.yjs.sv_local("page", p.page.cur.id, Buffer.from((0, _wasmGzip.compress)(bin)));
if (res) {
if (res.sv === res.diff && res.sv === "not-found") {
console.warn("reload 3");
location.reload();
}
const diff_local = Y.encodeStateAsUpdate(doc, (0, _wasmGzip.decompress)(res.sv));
Y.applyUpdate(doc, (0, _wasmGzip.decompress)(res.diff), "local");
if (!(0, _isEditing.isTextEditing)()) await (0, _build.treeRebuild)(p, {
note: note + " page-on-update"
});
await p.sync.yjs.diff_local("page", p.page.cur.id, Buffer.from((0, _wasmGzip.compress)(diff_local)));
p.ui.syncing = false;
p.page.entry = doc.getMap("map").get("root")?.get("childs")?.map((e)=>e.get("id"));
if ((0, _edGlobal.active).should_render_main) p.render();
}
}, UPDATE_TIMEOUT);
};
doc.on("update", page.on_update);
p.page.doc = doc;
if (p.page.doc) {
page.page = p.page.cur;
page.doc = p.page.doc;
p.page.entry = p.page.doc.getMap("map").get("root")?.get("childs")?.map((e)=>e.get("id"));
if (!Array.isArray(p.page.entry)) p.sync.code.action({
type: "flush-page-cache",
page_id: page_id
}).then(()=>{
console.warn("reload 4");
location.reload();
});
}
if (p.page.doc) await (0, _build.treeRebuild)(p, {
note: note + " page-init"
});
}
p.status = "ready";
if (should_render !== false) p.render();
};
const loadPageMetaCache = async (p, page_id)=>{
const idb_cache = await (0, _idbKeyval.get)(`page-${page_id}`, (0, _extractNav.nav).store);
if (idb_cache) {
p.preview.meta_cache[page_id] = idb_cache;
return p.preview.meta_cache[page_id];
}
};
const savePageMetaCache = async (p, meta)=>{
const cleaned_meta = {};
for (const [k, v] of Object.entries(meta))cleaned_meta[k] = {
item: v.item,
instances: v.instances,
parent: v.parent,
jsx_prop: v.jsx_prop
};
p.preview.meta_cache[params.page_id] = {
meta: cleaned_meta,
entry: p.page.entry,
url: p.page.cur.url
};
(0, _idbKeyval.set)(`page-${params.page_id}`, p.preview.meta_cache[params.page_id], (0, _extractNav.nav).store);
};
},{"686da3b6f0fee310":"bwHdc","wasm-gzip":"9TduR","./active/is-editing":"1zeD1","./comp/load":"fQ2tn","./ed-global":"5VTke","./ed-site":"hPnT5","./tree/build":"53DOC","idb-keyval":"in1MU","../../vi/render/script/extract-nav":"kVlwd","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"hPnT5":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "loadSite", ()=>loadSite);
var _apiProxy = require("../../../base/load/api/api-proxy");
var _loadLegacy = require("../../vi/load/load-legacy");
var _loadSnapshot = require("../../vi/load/load-snapshot");
var _apiUtils = require("../panel/popup/api/api-utils");
const loadSite = async (p, site, note)=>{
p.site = site;
const url = (0, _apiUtils.apiUrl)(p);
if (!(0, _apiUtils.apiRef)[url]) (0, _apiUtils.apiRef)[url] = (0, _apiProxy.apiProxy)(url);
const api = (0, _apiUtils.apiRef)[url];
try {
const res = await api._deploy({
type: "db-ver",
id_site: p.site.id
});
if (parseInt(res)) {
const cur = localStorage.getItem("api-ts-" + p.site.config.api_url);
if (cur && parseInt(cur) !== parseInt(res)) localStorage.removeItem(`schema-md-${p.site.id}`);
localStorage.setItem("api-ts-" + p.site.config.api_url, res);
}
} catch (e) {
console.log(e);
}
if (!p.script.db && !p.script.api) {
if (!location.pathname.startsWith("/ed/")) await (0, _loadLegacy.viLoadLegacy)({
mode: p.mode,
site: {
api_url: p.site.config.api_url,
id: p.site.id,
api: {
get () {
return p.script.api;
},
set (val) {
p.script.api = val;
}
},
db: {
get () {
return p.script.db;
},
set (val) {
p.script.db = val;
}
}
},
render: ()=>{}
});
else await (0, _loadSnapshot.viLoadSnapshot)(p);
}
};
},{"../../../base/load/api/api-proxy":"lj6qP","../../vi/load/load-legacy":"j3Paf","../../vi/load/load-snapshot":"7AnsG","../panel/popup/api/api-utils":"4Aaal","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"j3Paf":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "viLoadLegacy", ()=>viLoadLegacy);
var _apiProxy = require("../../../base/load/api/api-proxy");
var _apiProxyDef = require("../../../base/load/api/api-proxy-def");
var _dbProxy = require("../../../base/load/db/db-proxy");
var _dynamicImport = require("../../ed/panel/side/style/tools/dynamic-import");
var _dynamicImportDefault = parcelHelpers.interopDefault(_dynamicImport);
var _arg = require("../render/script/arg");
const viLoadLegacy = async (vi)=>{
const w = window;
if (!w.exports) w.exports = {};
const site = await _db.site.findFirst({
where: {
id: vi.site.id
},
include: {
component_site: true
}
});
if (site) {
if (site.component_site) for (const cg of site.component_site){
const path = `/npm/site/${cg.id_site}/site.js`;
await (0, _dynamicImportDefault.default)(path);
}
let api_url = vi.site.api_url;
if (!api_url) api_url = (site.config || {}).api_url || "";
if (!api_url) return;
try {
const apiURL = new URL(api_url);
if (api_url && apiURL.hostname) try {
await (0, _apiProxyDef.loadApiProxyDef)(api_url, true);
} catch (e) {
console.error("Failed to load API [Legacy]:", api_url);
}
} catch (e) {}
const path = `/npm/site/${vi.site.id}/site.js`;
await (0, _dynamicImportDefault.default)(path);
if (!vi.site.db.get()) vi.site.db.set((0, _dbProxy.dbProxy)(api_url));
if (!vi.site.api.get()) vi.site.api.set((0, _apiProxy.apiProxy)(api_url));
const w = window;
if (site.js_compiled) {
const config = site.config;
const exec = (fn, scopes)=>{
if (config.api_url && !scopes["api"]) {
scopes["api"] = vi.site.api.get();
scopes["db"] = vi.site.db.get();
}
scopes.params = w.params;
scopes.module = {};
const f = new Function(...Object.keys(scopes), fn);
const res = f(...Object.values(scopes));
return res;
};
const scope = {
...(0, _arg.viScriptArg)({
site: vi.site,
mode: vi.mode
}),
types: {},
exports: w.exports,
load: (0, _dynamicImportDefault.default),
render: vi.render,
module: {
exports: {}
}
};
await exec(site.js_compiled, scope);
if (scope.module.exports) for (const [k, v] of Object.entries(scope.module.exports))w.exports[k] = v;
}
}
};
},{"../../../base/load/api/api-proxy":"lj6qP","../../../base/load/api/api-proxy-def":"hzkoB","../../../base/load/db/db-proxy":"ir4Sn","../../ed/panel/side/style/tools/dynamic-import":"cxUUY","../render/script/arg":"e5PfR","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"cxUUY":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "importModule", ()=>importModule);
var _general = require("../../../../../../utils/types/general");
function toAbsoluteURL(url) {
const a = document.createElement("a");
a.setAttribute("href", url); // <a href="hoge.html">
return a.cloneNode(false).href; // -> "http://example.com/hoge.html"
}
function importModule(url) {
if (!url) return "";
return new Promise((resolve, reject)=>{
const vector = "$importModule$" + Math.random().toString(32).slice(2);
const script = document.createElement("script");
const destructor = ()=>{
delete window[vector];
script.onerror = null;
script.onload = null;
script.remove();
URL.revokeObjectURL(script.src);
script.src = "";
};
script.defer = true;
script.type = "module";
script.onerror = ()=>{
reject(new Error(`Failed to import: ${url}`));
destructor();
};
script.onload = ()=>{
resolve(window[vector]);
destructor();
};
const absURL = (0, _general.w).basehost ? (0, _general.w).basehost + url : toAbsoluteURL(url);
const loader = `import * as m from "${absURL}"; window.${vector} = m;`; // export Module
const blob = new Blob([
loader
], {
type: "text/javascript"
});
script.src = URL.createObjectURL(blob);
document.head.appendChild(script);
});
}
exports.default = importModule;
},{"../../../../../../utils/types/general":"58I9D","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"e5PfR":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "viScriptArg", ()=>viScriptArg);
const viScriptArg = (vi)=>({
isMobile: vi.mode === "mobile",
isDesktop: vi.mode === "desktop",
isEditor: location.pathname.startsWith("/ed/")
});
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"7AnsG":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "viLoadSnapshot", ()=>viLoadSnapshot);
parcelHelpers.export(exports, "applyEnv", ()=>applyEnv);
var _apiProxy = require("../../../base/load/api/api-proxy");
var _apiProxyDef = require("../../../base/load/api/api-proxy-def");
var _dbProxy = require("../../../base/load/db/db-proxy");
var _codeLoader = require("../../ed/logic/code-loader");
const encoder = new TextEncoder();
const viLoadSnapshot = async (p)=>{
let api_url = p.site.config.api_url;
try {
const apiURL = new URL(api_url);
if (api_url && apiURL.hostname) {
await (0, _apiProxyDef.loadApiProxyDef)(api_url, true);
if (!p.script.db) p.script.db = (0, _dbProxy.dbProxy)(api_url);
if (!p.script.api) p.script.api = (0, _apiProxy.apiProxy)(api_url);
}
} catch (e) {
if (e && !e.message.toLowerCase().includes("invalid url")) console.error("Failed to load API [Snapshot]:", api_url);
}
await applyEnv(p);
};
const applyEnv = async (p)=>{
const w = window;
if (p.site.config.api_url) {
w.db = (0, _dbProxy.dbProxy)(p.site.config.api_url);
w.api = (0, _apiProxy.apiProxy)(p.site.config.api_url);
}
await (0, _codeLoader.loadCode)(p, p.site_tstamp);
};
},{"../../../base/load/api/api-proxy":"lj6qP","../../../base/load/api/api-proxy-def":"hzkoB","../../../base/load/db/db-proxy":"ir4Sn","../../ed/logic/code-loader":"iWfqp","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"4Aaal":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "apiRef", ()=>apiRef);
parcelHelpers.export(exports, "dev", ()=>dev);
parcelHelpers.export(exports, "server", ()=>server);
parcelHelpers.export(exports, "apiUrl", ()=>apiUrl);
parcelHelpers.export(exports, "checkAPI", ()=>checkAPI);
var _apiProxy = require("../../../../../base/load/api/api-proxy");
var _general = require("../../../../../utils/types/general");
const apiRef = {};
const dev = JSON.parse(localStorage.getItem("prasi-dev") || "{}");
const server = {
status: "ready"
};
const apiUrl = (p)=>{
return p.site?.config?.api_url || "";
};
const checkAPI = async (url, id_site)=>{
if (!url) return "offline";
try {
if (!apiRef[url]) apiRef[url] = (0, _apiProxy.apiProxy)(url);
const capi = apiRef[url];
if (!capi) console.error(`Cannot initialize API for ${url}.`, (0, _general.w).prasiApi[url]);
else {
let res = await capi._deploy({
type: "check",
id_site
});
if (!res) return {
deployable: false,
db: "",
hasDB: false,
domains: []
};
else {
if (res.db && res.now) return {
deployable: true,
db: res.db,
hasDB: true,
domains: res.domains,
deploy: {
now: res.now,
current: res.current,
deploys: res.deploys
}
};
}
}
} catch (e) {
console.error(e);
return "error";
}
return {
deployable: false,
db: "",
hasDB: false,
domains: []
};
};
},{"../../../../../base/load/api/api-proxy":"lj6qP","../../../../../utils/types/general":"58I9D","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"eJgDZ":[function(require,module,exports) {
// This file is generated automatically by `scripts/build/indices.ts`. Please, don't change it.
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "add", ()=>(0, _indexJsDefault.default));
parcelHelpers.export(exports, "addBusinessDays", ()=>(0, _indexJsDefault1.default));
parcelHelpers.export(exports, "addDays", ()=>(0, _indexJsDefault2.default));
parcelHelpers.export(exports, "addHours", ()=>(0, _indexJsDefault3.default));
parcelHelpers.export(exports, "addISOWeekYears", ()=>(0, _indexJsDefault4.default));
parcelHelpers.export(exports, "addMilliseconds", ()=>(0, _indexJsDefault5.default));
parcelHelpers.export(exports, "addMinutes", ()=>(0, _indexJsDefault6.default));
parcelHelpers.export(exports, "addMonths", ()=>(0, _indexJsDefault7.default));
parcelHelpers.export(exports, "addQuarters", ()=>(0, _indexJsDefault8.default));
parcelHelpers.export(exports, "addSeconds", ()=>(0, _indexJsDefault9.default));
parcelHelpers.export(exports, "addWeeks", ()=>(0, _indexJsDefault10.default));
parcelHelpers.export(exports, "addYears", ()=>(0, _indexJsDefault11.default));
parcelHelpers.export(exports, "areIntervalsOverlapping", ()=>(0, _indexJsDefault12.default));
parcelHelpers.export(exports, "clamp", ()=>(0, _indexJsDefault13.default));
parcelHelpers.export(exports, "closestIndexTo", ()=>(0, _indexJsDefault14.default));
parcelHelpers.export(exports, "closestTo", ()=>(0, _indexJsDefault15.default));
parcelHelpers.export(exports, "compareAsc", ()=>(0, _indexJsDefault16.default));
parcelHelpers.export(exports, "compareDesc", ()=>(0, _indexJsDefault17.default));
parcelHelpers.export(exports, "daysToWeeks", ()=>(0, _indexJsDefault18.default));
parcelHelpers.export(exports, "differenceInBusinessDays", ()=>(0, _indexJsDefault19.default));
parcelHelpers.export(exports, "differenceInCalendarDays", ()=>(0, _indexJsDefault20.default));
parcelHelpers.export(exports, "differenceInCalendarISOWeekYears", ()=>(0, _indexJsDefault21.default));
parcelHelpers.export(exports, "differenceInCalendarISOWeeks", ()=>(0, _indexJsDefault22.default));
parcelHelpers.export(exports, "differenceInCalendarMonths", ()=>(0, _indexJsDefault23.default));
parcelHelpers.export(exports, "differenceInCalendarQuarters", ()=>(0, _indexJsDefault24.default));
parcelHelpers.export(exports, "differenceInCalendarWeeks", ()=>(0, _indexJsDefault25.default));
parcelHelpers.export(exports, "differenceInCalendarYears", ()=>(0, _indexJsDefault26.default));
parcelHelpers.export(exports, "differenceInDays", ()=>(0, _indexJsDefault27.default));
parcelHelpers.export(exports, "differenceInHours", ()=>(0, _indexJsDefault28.default));
parcelHelpers.export(exports, "differenceInISOWeekYears", ()=>(0, _indexJsDefault29.default));
parcelHelpers.export(exports, "differenceInMilliseconds", ()=>(0, _indexJsDefault30.default));
parcelHelpers.export(exports, "differenceInMinutes", ()=>(0, _indexJsDefault31.default));
parcelHelpers.export(exports, "differenceInMonths", ()=>(0, _indexJsDefault32.default));
parcelHelpers.export(exports, "differenceInQuarters", ()=>(0, _indexJsDefault33.default));
parcelHelpers.export(exports, "differenceInSeconds", ()=>(0, _indexJsDefault34.default));
parcelHelpers.export(exports, "differenceInWeeks", ()=>(0, _indexJsDefault35.default));
parcelHelpers.export(exports, "differenceInYears", ()=>(0, _indexJsDefault36.default));
parcelHelpers.export(exports, "eachDayOfInterval", ()=>(0, _indexJsDefault37.default));
parcelHelpers.export(exports, "eachHourOfInterval", ()=>(0, _indexJsDefault38.default));
parcelHelpers.export(exports, "eachMinuteOfInterval", ()=>(0, _indexJsDefault39.default));
parcelHelpers.export(exports, "eachMonthOfInterval", ()=>(0, _indexJsDefault40.default));
parcelHelpers.export(exports, "eachQuarterOfInterval", ()=>(0, _indexJsDefault41.default));
parcelHelpers.export(exports, "eachWeekOfInterval", ()=>(0, _indexJsDefault42.default));
parcelHelpers.export(exports, "eachWeekendOfInterval", ()=>(0, _indexJsDefault43.default));
parcelHelpers.export(exports, "eachWeekendOfMonth", ()=>(0, _indexJsDefault44.default));
parcelHelpers.export(exports, "eachWeekendOfYear", ()=>(0, _indexJsDefault45.default));
parcelHelpers.export(exports, "eachYearOfInterval", ()=>(0, _indexJsDefault46.default));
parcelHelpers.export(exports, "endOfDay", ()=>(0, _indexJsDefault47.default));
parcelHelpers.export(exports, "endOfDecade", ()=>(0, _indexJsDefault48.default));
parcelHelpers.export(exports, "endOfHour", ()=>(0, _indexJsDefault49.default));
parcelHelpers.export(exports, "endOfISOWeek", ()=>(0, _indexJsDefault50.default));
parcelHelpers.export(exports, "endOfISOWeekYear", ()=>(0, _indexJsDefault51.default));
parcelHelpers.export(exports, "endOfMinute", ()=>(0, _indexJsDefault52.default));
parcelHelpers.export(exports, "endOfMonth", ()=>(0, _indexJsDefault53.default));
parcelHelpers.export(exports, "endOfQuarter", ()=>(0, _indexJsDefault54.default));
parcelHelpers.export(exports, "endOfSecond", ()=>(0, _indexJsDefault55.default));
parcelHelpers.export(exports, "endOfToday", ()=>(0, _indexJsDefault56.default));
parcelHelpers.export(exports, "endOfTomorrow", ()=>(0, _indexJsDefault57.default));
parcelHelpers.export(exports, "endOfWeek", ()=>(0, _indexJsDefault58.default));
parcelHelpers.export(exports, "endOfYear", ()=>(0, _indexJsDefault59.default));
parcelHelpers.export(exports, "endOfYesterday", ()=>(0, _indexJsDefault60.default));
parcelHelpers.export(exports, "format", ()=>(0, _indexJsDefault61.default));
parcelHelpers.export(exports, "formatDistance", ()=>(0, _indexJsDefault62.default));
parcelHelpers.export(exports, "formatDistanceStrict", ()=>(0, _indexJsDefault63.default));
parcelHelpers.export(exports, "formatDistanceToNow", ()=>(0, _indexJsDefault64.default));
parcelHelpers.export(exports, "formatDistanceToNowStrict", ()=>(0, _indexJsDefault65.default));
parcelHelpers.export(exports, "formatDuration", ()=>(0, _indexJsDefault66.default));
parcelHelpers.export(exports, "formatISO", ()=>(0, _indexJsDefault67.default));
parcelHelpers.export(exports, "formatISO9075", ()=>(0, _indexJsDefault68.default));
parcelHelpers.export(exports, "formatISODuration", ()=>(0, _indexJsDefault69.default));
parcelHelpers.export(exports, "formatRFC3339", ()=>(0, _indexJsDefault70.default));
parcelHelpers.export(exports, "formatRFC7231", ()=>(0, _indexJsDefault71.default));
parcelHelpers.export(exports, "formatRelative", ()=>(0, _indexJsDefault72.default));
parcelHelpers.export(exports, "fromUnixTime", ()=>(0, _indexJsDefault73.default));
parcelHelpers.export(exports, "getDate", ()=>(0, _indexJsDefault74.default));
parcelHelpers.export(exports, "getDay", ()=>(0, _indexJsDefault75.default));
parcelHelpers.export(exports, "getDayOfYear", ()=>(0, _indexJsDefault76.default));
parcelHelpers.export(exports, "getDaysInMonth", ()=>(0, _indexJsDefault77.default));
parcelHelpers.export(exports, "getDaysInYear", ()=>(0, _indexJsDefault78.default));
parcelHelpers.export(exports, "getDecade", ()=>(0, _indexJsDefault79.default));
parcelHelpers.export(exports, "getDefaultOptions", ()=>(0, _indexJsDefault80.default));
parcelHelpers.export(exports, "getHours", ()=>(0, _indexJsDefault81.default));
parcelHelpers.export(exports, "getISODay", ()=>(0, _indexJsDefault82.default));
parcelHelpers.export(exports, "getISOWeek", ()=>(0, _indexJsDefault83.default));
parcelHelpers.export(exports, "getISOWeekYear", ()=>(0, _indexJsDefault84.default));
parcelHelpers.export(exports, "getISOWeeksInYear", ()=>(0, _indexJsDefault85.default));
parcelHelpers.export(exports, "getMilliseconds", ()=>(0, _indexJsDefault86.default));
parcelHelpers.export(exports, "getMinutes", ()=>(0, _indexJsDefault87.default));
parcelHelpers.export(exports, "getMonth", ()=>(0, _indexJsDefault88.default));
parcelHelpers.export(exports, "getOverlappingDaysInIntervals", ()=>(0, _indexJsDefault89.default));
parcelHelpers.export(exports, "getQuarter", ()=>(0, _indexJsDefault90.default));
parcelHelpers.export(exports, "getSeconds", ()=>(0, _indexJsDefault91.default));
parcelHelpers.export(exports, "getTime", ()=>(0, _indexJsDefault92.default));
parcelHelpers.export(exports, "getUnixTime", ()=>(0, _indexJsDefault93.default));
parcelHelpers.export(exports, "getWeek", ()=>(0, _indexJsDefault94.default));
parcelHelpers.export(exports, "getWeekOfMonth", ()=>(0, _indexJsDefault95.default));
parcelHelpers.export(exports, "getWeekYear", ()=>(0, _indexJsDefault96.default));
parcelHelpers.export(exports, "getWeeksInMonth", ()=>(0, _indexJsDefault97.default));
parcelHelpers.export(exports, "getYear", ()=>(0, _indexJsDefault98.default));
parcelHelpers.export(exports, "hoursToMilliseconds", ()=>(0, _indexJsDefault99.default));
parcelHelpers.export(exports, "hoursToMinutes", ()=>(0, _indexJsDefault100.default));
parcelHelpers.export(exports, "hoursToSeconds", ()=>(0, _indexJsDefault101.default));
parcelHelpers.export(exports, "intervalToDuration", ()=>(0, _indexJsDefault102.default));
parcelHelpers.export(exports, "intlFormat", ()=>(0, _indexJsDefault103.default));
parcelHelpers.export(exports, "intlFormatDistance", ()=>(0, _indexJsDefault104.default));
parcelHelpers.export(exports, "isAfter", ()=>(0, _indexJsDefault105.default));
parcelHelpers.export(exports, "isBefore", ()=>(0, _indexJsDefault106.default));
parcelHelpers.export(exports, "isDate", ()=>(0, _indexJsDefault107.default));
parcelHelpers.export(exports, "isEqual", ()=>(0, _indexJsDefault108.default));
parcelHelpers.export(exports, "isExists", ()=>(0, _indexJsDefault109.default));
parcelHelpers.export(exports, "isFirstDayOfMonth", ()=>(0, _indexJsDefault110.default));
parcelHelpers.export(exports, "isFriday", ()=>(0, _indexJsDefault111.default));
parcelHelpers.export(exports, "isFuture", ()=>(0, _indexJsDefault112.default));
parcelHelpers.export(exports, "isLastDayOfMonth", ()=>(0, _indexJsDefault113.default));
parcelHelpers.export(exports, "isLeapYear", ()=>(0, _indexJsDefault114.default));
parcelHelpers.export(exports, "isMatch", ()=>(0, _indexJsDefault115.default));
parcelHelpers.export(exports, "isMonday", ()=>(0, _indexJsDefault116.default));
parcelHelpers.export(exports, "isPast", ()=>(0, _indexJsDefault117.default));
parcelHelpers.export(exports, "isSameDay", ()=>(0, _indexJsDefault118.default));
parcelHelpers.export(exports, "isSameHour", ()=>(0, _indexJsDefault119.default));
parcelHelpers.export(exports, "isSameISOWeek", ()=>(0, _indexJsDefault120.default));
parcelHelpers.export(exports, "isSameISOWeekYear", ()=>(0, _indexJsDefault121.default));
parcelHelpers.export(exports, "isSameMinute", ()=>(0, _indexJsDefault122.default));
parcelHelpers.export(exports, "isSameMonth", ()=>(0, _indexJsDefault123.default));
parcelHelpers.export(exports, "isSameQuarter", ()=>(0, _indexJsDefault124.default));
parcelHelpers.export(exports, "isSameSecond", ()=>(0, _indexJsDefault125.default));
parcelHelpers.export(exports, "isSameWeek", ()=>(0, _indexJsDefault126.default));
parcelHelpers.export(exports, "isSameYear", ()=>(0, _indexJsDefault127.default));
parcelHelpers.export(exports, "isSaturday", ()=>(0, _indexJsDefault128.default));
parcelHelpers.export(exports, "isSunday", ()=>(0, _indexJsDefault129.default));
parcelHelpers.export(exports, "isThisHour", ()=>(0, _indexJsDefault130.default));
parcelHelpers.export(exports, "isThisISOWeek", ()=>(0, _indexJsDefault131.default));
parcelHelpers.export(exports, "isThisMinute", ()=>(0, _indexJsDefault132.default));
parcelHelpers.export(exports, "isThisMonth", ()=>(0, _indexJsDefault133.default));
parcelHelpers.export(exports, "isThisQuarter", ()=>(0, _indexJsDefault134.default));
parcelHelpers.export(exports, "isThisSecond", ()=>(0, _indexJsDefault135.default));
parcelHelpers.export(exports, "isThisWeek", ()=>(0, _indexJsDefault136.default));
parcelHelpers.export(exports, "isThisYear", ()=>(0, _indexJsDefault137.default));
parcelHelpers.export(exports, "isThursday", ()=>(0, _indexJsDefault138.default));
parcelHelpers.export(exports, "isToday", ()=>(0, _indexJsDefault139.default));
parcelHelpers.export(exports, "isTomorrow", ()=>(0, _indexJsDefault140.default));
parcelHelpers.export(exports, "isTuesday", ()=>(0, _indexJsDefault141.default));
parcelHelpers.export(exports, "isValid", ()=>(0, _indexJsDefault142.default));
parcelHelpers.export(exports, "isWednesday", ()=>(0, _indexJsDefault143.default));
parcelHelpers.export(exports, "isWeekend", ()=>(0, _indexJsDefault144.default));
parcelHelpers.export(exports, "isWithinInterval", ()=>(0, _indexJsDefault145.default));
parcelHelpers.export(exports, "isYesterday", ()=>(0, _indexJsDefault146.default));
parcelHelpers.export(exports, "lastDayOfDecade", ()=>(0, _indexJsDefault147.default));
parcelHelpers.export(exports, "lastDayOfISOWeek", ()=>(0, _indexJsDefault148.default));
parcelHelpers.export(exports, "lastDayOfISOWeekYear", ()=>(0, _indexJsDefault149.default));
parcelHelpers.export(exports, "lastDayOfMonth", ()=>(0, _indexJsDefault150.default));
parcelHelpers.export(exports, "lastDayOfQuarter", ()=>(0, _indexJsDefault151.default));
parcelHelpers.export(exports, "lastDayOfWeek", ()=>(0, _indexJsDefault152.default));
parcelHelpers.export(exports, "lastDayOfYear", ()=>(0, _indexJsDefault153.default));
parcelHelpers.export(exports, "lightFormat", ()=>(0, _indexJsDefault154.default));
parcelHelpers.export(exports, "max", ()=>(0, _indexJsDefault155.default));
parcelHelpers.export(exports, "milliseconds", ()=>(0, _indexJsDefault156.default));
parcelHelpers.export(exports, "millisecondsToHours", ()=>(0, _indexJsDefault157.default));
parcelHelpers.export(exports, "millisecondsToMinutes", ()=>(0, _indexJsDefault158.default));
parcelHelpers.export(exports, "millisecondsToSeconds", ()=>(0, _indexJsDefault159.default));
parcelHelpers.export(exports, "min", ()=>(0, _indexJsDefault160.default));
parcelHelpers.export(exports, "minutesToHours", ()=>(0, _indexJsDefault161.default));
parcelHelpers.export(exports, "minutesToMilliseconds", ()=>(0, _indexJsDefault162.default));
parcelHelpers.export(exports, "minutesToSeconds", ()=>(0, _indexJsDefault163.default));
parcelHelpers.export(exports, "monthsToQuarters", ()=>(0, _indexJsDefault164.default));
parcelHelpers.export(exports, "monthsToYears", ()=>(0, _indexJsDefault165.default));
parcelHelpers.export(exports, "nextDay", ()=>(0, _indexJsDefault166.default));
parcelHelpers.export(exports, "nextFriday", ()=>(0, _indexJsDefault167.default));
parcelHelpers.export(exports, "nextMonday", ()=>(0, _indexJsDefault168.default));
parcelHelpers.export(exports, "nextSaturday", ()=>(0, _indexJsDefault169.default));
parcelHelpers.export(exports, "nextSunday", ()=>(0, _indexJsDefault170.default));
parcelHelpers.export(exports, "nextThursday", ()=>(0, _indexJsDefault171.default));
parcelHelpers.export(exports, "nextTuesday", ()=>(0, _indexJsDefault172.default));
parcelHelpers.export(exports, "nextWednesday", ()=>(0, _indexJsDefault173.default));
parcelHelpers.export(exports, "parse", ()=>(0, _indexJsDefault174.default));
parcelHelpers.export(exports, "parseISO", ()=>(0, _indexJsDefault175.default));
parcelHelpers.export(exports, "parseJSON", ()=>(0, _indexJsDefault176.default));
parcelHelpers.export(exports, "previousDay", ()=>(0, _indexJsDefault177.default));
parcelHelpers.export(exports, "previousFriday", ()=>(0, _indexJsDefault178.default));
parcelHelpers.export(exports, "previousMonday", ()=>(0, _indexJsDefault179.default));
parcelHelpers.export(exports, "previousSaturday", ()=>(0, _indexJsDefault180.default));
parcelHelpers.export(exports, "previousSunday", ()=>(0, _indexJsDefault181.default));
parcelHelpers.export(exports, "previousThursday", ()=>(0, _indexJsDefault182.default));
parcelHelpers.export(exports, "previousTuesday", ()=>(0, _indexJsDefault183.default));
parcelHelpers.export(exports, "previousWednesday", ()=>(0, _indexJsDefault184.default));
parcelHelpers.export(exports, "quartersToMonths", ()=>(0, _indexJsDefault185.default));
parcelHelpers.export(exports, "quartersToYears", ()=>(0, _indexJsDefault186.default));
parcelHelpers.export(exports, "roundToNearestMinutes", ()=>(0, _indexJsDefault187.default));
parcelHelpers.export(exports, "secondsToHours", ()=>(0, _indexJsDefault188.default));
parcelHelpers.export(exports, "secondsToMilliseconds", ()=>(0, _indexJsDefault189.default));
parcelHelpers.export(exports, "secondsToMinutes", ()=>(0, _indexJsDefault190.default));
parcelHelpers.export(exports, "set", ()=>(0, _indexJsDefault191.default));
parcelHelpers.export(exports, "setDate", ()=>(0, _indexJsDefault192.default));
parcelHelpers.export(exports, "setDay", ()=>(0, _indexJsDefault193.default));
parcelHelpers.export(exports, "setDayOfYear", ()=>(0, _indexJsDefault194.default));
parcelHelpers.export(exports, "setDefaultOptions", ()=>(0, _indexJsDefault195.default));
parcelHelpers.export(exports, "setHours", ()=>(0, _indexJsDefault196.default));
parcelHelpers.export(exports, "setISODay", ()=>(0, _indexJsDefault197.default));
parcelHelpers.export(exports, "setISOWeek", ()=>(0, _indexJsDefault198.default));
parcelHelpers.export(exports, "setISOWeekYear", ()=>(0, _indexJsDefault199.default));
parcelHelpers.export(exports, "setMilliseconds", ()=>(0, _indexJsDefault200.default));
parcelHelpers.export(exports, "setMinutes", ()=>(0, _indexJsDefault201.default));
parcelHelpers.export(exports, "setMonth", ()=>(0, _indexJsDefault202.default));
parcelHelpers.export(exports, "setQuarter", ()=>(0, _indexJsDefault203.default));
parcelHelpers.export(exports, "setSeconds", ()=>(0, _indexJsDefault204.default));
parcelHelpers.export(exports, "setWeek", ()=>(0, _indexJsDefault205.default));
parcelHelpers.export(exports, "setWeekYear", ()=>(0, _indexJsDefault206.default));
parcelHelpers.export(exports, "setYear", ()=>(0, _indexJsDefault207.default));
parcelHelpers.export(exports, "startOfDay", ()=>(0, _indexJsDefault208.default));
parcelHelpers.export(exports, "startOfDecade", ()=>(0, _indexJsDefault209.default));
parcelHelpers.export(exports, "startOfHour", ()=>(0, _indexJsDefault210.default));
parcelHelpers.export(exports, "startOfISOWeek", ()=>(0, _indexJsDefault211.default));
parcelHelpers.export(exports, "startOfISOWeekYear", ()=>(0, _indexJsDefault212.default));
parcelHelpers.export(exports, "startOfMinute", ()=>(0, _indexJsDefault213.default));
parcelHelpers.export(exports, "startOfMonth", ()=>(0, _indexJsDefault214.default));
parcelHelpers.export(exports, "startOfQuarter", ()=>(0, _indexJsDefault215.default));
parcelHelpers.export(exports, "startOfSecond", ()=>(0, _indexJsDefault216.default));
parcelHelpers.export(exports, "startOfToday", ()=>(0, _indexJsDefault217.default));
parcelHelpers.export(exports, "startOfTomorrow", ()=>(0, _indexJsDefault218.default));
parcelHelpers.export(exports, "startOfWeek", ()=>(0, _indexJsDefault219.default));
parcelHelpers.export(exports, "startOfWeekYear", ()=>(0, _indexJsDefault220.default));
parcelHelpers.export(exports, "startOfYear", ()=>(0, _indexJsDefault221.default));
parcelHelpers.export(exports, "startOfYesterday", ()=>(0, _indexJsDefault222.default));
parcelHelpers.export(exports, "sub", ()=>(0, _indexJsDefault223.default));
parcelHelpers.export(exports, "subBusinessDays", ()=>(0, _indexJsDefault224.default));
parcelHelpers.export(exports, "subDays", ()=>(0, _indexJsDefault225.default));
parcelHelpers.export(exports, "subHours", ()=>(0, _indexJsDefault226.default));
parcelHelpers.export(exports, "subISOWeekYears", ()=>(0, _indexJsDefault227.default));
parcelHelpers.export(exports, "subMilliseconds", ()=>(0, _indexJsDefault228.default));
parcelHelpers.export(exports, "subMinutes", ()=>(0, _indexJsDefault229.default));
parcelHelpers.export(exports, "subMonths", ()=>(0, _indexJsDefault230.default));
parcelHelpers.export(exports, "subQuarters", ()=>(0, _indexJsDefault231.default));
parcelHelpers.export(exports, "subSeconds", ()=>(0, _indexJsDefault232.default));
parcelHelpers.export(exports, "subWeeks", ()=>(0, _indexJsDefault233.default));
parcelHelpers.export(exports, "subYears", ()=>(0, _indexJsDefault234.default));
parcelHelpers.export(exports, "toDate", ()=>(0, _indexJsDefault235.default));
parcelHelpers.export(exports, "weeksToDays", ()=>(0, _indexJsDefault236.default));
parcelHelpers.export(exports, "yearsToMonths", ()=>(0, _indexJsDefault237.default));
parcelHelpers.export(exports, "yearsToQuarters", ()=>(0, _indexJsDefault238.default));
var _indexJs = require("./add/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("./addBusinessDays/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("./addDays/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("./addHours/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
var _indexJs4 = require("./addISOWeekYears/index.js");
var _indexJsDefault4 = parcelHelpers.interopDefault(_indexJs4);
var _indexJs5 = require("./addMilliseconds/index.js");
var _indexJsDefault5 = parcelHelpers.interopDefault(_indexJs5);
var _indexJs6 = require("./addMinutes/index.js");
var _indexJsDefault6 = parcelHelpers.interopDefault(_indexJs6);
var _indexJs7 = require("./addMonths/index.js");
var _indexJsDefault7 = parcelHelpers.interopDefault(_indexJs7);
var _indexJs8 = require("./addQuarters/index.js");
var _indexJsDefault8 = parcelHelpers.interopDefault(_indexJs8);
var _indexJs9 = require("./addSeconds/index.js");
var _indexJsDefault9 = parcelHelpers.interopDefault(_indexJs9);
var _indexJs10 = require("./addWeeks/index.js");
var _indexJsDefault10 = parcelHelpers.interopDefault(_indexJs10);
var _indexJs11 = require("./addYears/index.js");
var _indexJsDefault11 = parcelHelpers.interopDefault(_indexJs11);
var _indexJs12 = require("./areIntervalsOverlapping/index.js");
var _indexJsDefault12 = parcelHelpers.interopDefault(_indexJs12);
var _indexJs13 = require("./clamp/index.js");
var _indexJsDefault13 = parcelHelpers.interopDefault(_indexJs13);
var _indexJs14 = require("./closestIndexTo/index.js");
var _indexJsDefault14 = parcelHelpers.interopDefault(_indexJs14);
var _indexJs15 = require("./closestTo/index.js");
var _indexJsDefault15 = parcelHelpers.interopDefault(_indexJs15);
var _indexJs16 = require("./compareAsc/index.js");
var _indexJsDefault16 = parcelHelpers.interopDefault(_indexJs16);
var _indexJs17 = require("./compareDesc/index.js");
var _indexJsDefault17 = parcelHelpers.interopDefault(_indexJs17);
var _indexJs18 = require("./daysToWeeks/index.js");
var _indexJsDefault18 = parcelHelpers.interopDefault(_indexJs18);
var _indexJs19 = require("./differenceInBusinessDays/index.js");
var _indexJsDefault19 = parcelHelpers.interopDefault(_indexJs19);
var _indexJs20 = require("./differenceInCalendarDays/index.js");
var _indexJsDefault20 = parcelHelpers.interopDefault(_indexJs20);
var _indexJs21 = require("./differenceInCalendarISOWeekYears/index.js");
var _indexJsDefault21 = parcelHelpers.interopDefault(_indexJs21);
var _indexJs22 = require("./differenceInCalendarISOWeeks/index.js");
var _indexJsDefault22 = parcelHelpers.interopDefault(_indexJs22);
var _indexJs23 = require("./differenceInCalendarMonths/index.js");
var _indexJsDefault23 = parcelHelpers.interopDefault(_indexJs23);
var _indexJs24 = require("./differenceInCalendarQuarters/index.js");
var _indexJsDefault24 = parcelHelpers.interopDefault(_indexJs24);
var _indexJs25 = require("./differenceInCalendarWeeks/index.js");
var _indexJsDefault25 = parcelHelpers.interopDefault(_indexJs25);
var _indexJs26 = require("./differenceInCalendarYears/index.js");
var _indexJsDefault26 = parcelHelpers.interopDefault(_indexJs26);
var _indexJs27 = require("./differenceInDays/index.js");
var _indexJsDefault27 = parcelHelpers.interopDefault(_indexJs27);
var _indexJs28 = require("./differenceInHours/index.js");
var _indexJsDefault28 = parcelHelpers.interopDefault(_indexJs28);
var _indexJs29 = require("./differenceInISOWeekYears/index.js");
var _indexJsDefault29 = parcelHelpers.interopDefault(_indexJs29);
var _indexJs30 = require("./differenceInMilliseconds/index.js");
var _indexJsDefault30 = parcelHelpers.interopDefault(_indexJs30);
var _indexJs31 = require("./differenceInMinutes/index.js");
var _indexJsDefault31 = parcelHelpers.interopDefault(_indexJs31);
var _indexJs32 = require("./differenceInMonths/index.js");
var _indexJsDefault32 = parcelHelpers.interopDefault(_indexJs32);
var _indexJs33 = require("./differenceInQuarters/index.js");
var _indexJsDefault33 = parcelHelpers.interopDefault(_indexJs33);
var _indexJs34 = require("./differenceInSeconds/index.js");
var _indexJsDefault34 = parcelHelpers.interopDefault(_indexJs34);
var _indexJs35 = require("./differenceInWeeks/index.js");
var _indexJsDefault35 = parcelHelpers.interopDefault(_indexJs35);
var _indexJs36 = require("./differenceInYears/index.js");
var _indexJsDefault36 = parcelHelpers.interopDefault(_indexJs36);
var _indexJs37 = require("./eachDayOfInterval/index.js");
var _indexJsDefault37 = parcelHelpers.interopDefault(_indexJs37);
var _indexJs38 = require("./eachHourOfInterval/index.js");
var _indexJsDefault38 = parcelHelpers.interopDefault(_indexJs38);
var _indexJs39 = require("./eachMinuteOfInterval/index.js");
var _indexJsDefault39 = parcelHelpers.interopDefault(_indexJs39);
var _indexJs40 = require("./eachMonthOfInterval/index.js");
var _indexJsDefault40 = parcelHelpers.interopDefault(_indexJs40);
var _indexJs41 = require("./eachQuarterOfInterval/index.js");
var _indexJsDefault41 = parcelHelpers.interopDefault(_indexJs41);
var _indexJs42 = require("./eachWeekOfInterval/index.js");
var _indexJsDefault42 = parcelHelpers.interopDefault(_indexJs42);
var _indexJs43 = require("./eachWeekendOfInterval/index.js");
var _indexJsDefault43 = parcelHelpers.interopDefault(_indexJs43);
var _indexJs44 = require("./eachWeekendOfMonth/index.js");
var _indexJsDefault44 = parcelHelpers.interopDefault(_indexJs44);
var _indexJs45 = require("./eachWeekendOfYear/index.js");
var _indexJsDefault45 = parcelHelpers.interopDefault(_indexJs45);
var _indexJs46 = require("./eachYearOfInterval/index.js");
var _indexJsDefault46 = parcelHelpers.interopDefault(_indexJs46);
var _indexJs47 = require("./endOfDay/index.js");
var _indexJsDefault47 = parcelHelpers.interopDefault(_indexJs47);
var _indexJs48 = require("./endOfDecade/index.js");
var _indexJsDefault48 = parcelHelpers.interopDefault(_indexJs48);
var _indexJs49 = require("./endOfHour/index.js");
var _indexJsDefault49 = parcelHelpers.interopDefault(_indexJs49);
var _indexJs50 = require("./endOfISOWeek/index.js");
var _indexJsDefault50 = parcelHelpers.interopDefault(_indexJs50);
var _indexJs51 = require("./endOfISOWeekYear/index.js");
var _indexJsDefault51 = parcelHelpers.interopDefault(_indexJs51);
var _indexJs52 = require("./endOfMinute/index.js");
var _indexJsDefault52 = parcelHelpers.interopDefault(_indexJs52);
var _indexJs53 = require("./endOfMonth/index.js");
var _indexJsDefault53 = parcelHelpers.interopDefault(_indexJs53);
var _indexJs54 = require("./endOfQuarter/index.js");
var _indexJsDefault54 = parcelHelpers.interopDefault(_indexJs54);
var _indexJs55 = require("./endOfSecond/index.js");
var _indexJsDefault55 = parcelHelpers.interopDefault(_indexJs55);
var _indexJs56 = require("./endOfToday/index.js");
var _indexJsDefault56 = parcelHelpers.interopDefault(_indexJs56);
var _indexJs57 = require("./endOfTomorrow/index.js");
var _indexJsDefault57 = parcelHelpers.interopDefault(_indexJs57);
var _indexJs58 = require("./endOfWeek/index.js");
var _indexJsDefault58 = parcelHelpers.interopDefault(_indexJs58);
var _indexJs59 = require("./endOfYear/index.js");
var _indexJsDefault59 = parcelHelpers.interopDefault(_indexJs59);
var _indexJs60 = require("./endOfYesterday/index.js");
var _indexJsDefault60 = parcelHelpers.interopDefault(_indexJs60);
var _indexJs61 = require("./format/index.js");
var _indexJsDefault61 = parcelHelpers.interopDefault(_indexJs61);
var _indexJs62 = require("./formatDistance/index.js");
var _indexJsDefault62 = parcelHelpers.interopDefault(_indexJs62);
var _indexJs63 = require("./formatDistanceStrict/index.js");
var _indexJsDefault63 = parcelHelpers.interopDefault(_indexJs63);
var _indexJs64 = require("./formatDistanceToNow/index.js");
var _indexJsDefault64 = parcelHelpers.interopDefault(_indexJs64);
var _indexJs65 = require("./formatDistanceToNowStrict/index.js");
var _indexJsDefault65 = parcelHelpers.interopDefault(_indexJs65);
var _indexJs66 = require("./formatDuration/index.js");
var _indexJsDefault66 = parcelHelpers.interopDefault(_indexJs66);
var _indexJs67 = require("./formatISO/index.js");
var _indexJsDefault67 = parcelHelpers.interopDefault(_indexJs67);
var _indexJs68 = require("./formatISO9075/index.js");
var _indexJsDefault68 = parcelHelpers.interopDefault(_indexJs68);
var _indexJs69 = require("./formatISODuration/index.js");
var _indexJsDefault69 = parcelHelpers.interopDefault(_indexJs69);
var _indexJs70 = require("./formatRFC3339/index.js");
var _indexJsDefault70 = parcelHelpers.interopDefault(_indexJs70);
var _indexJs71 = require("./formatRFC7231/index.js");
var _indexJsDefault71 = parcelHelpers.interopDefault(_indexJs71);
var _indexJs72 = require("./formatRelative/index.js");
var _indexJsDefault72 = parcelHelpers.interopDefault(_indexJs72);
var _indexJs73 = require("./fromUnixTime/index.js");
var _indexJsDefault73 = parcelHelpers.interopDefault(_indexJs73);
var _indexJs74 = require("./getDate/index.js");
var _indexJsDefault74 = parcelHelpers.interopDefault(_indexJs74);
var _indexJs75 = require("./getDay/index.js");
var _indexJsDefault75 = parcelHelpers.interopDefault(_indexJs75);
var _indexJs76 = require("./getDayOfYear/index.js");
var _indexJsDefault76 = parcelHelpers.interopDefault(_indexJs76);
var _indexJs77 = require("./getDaysInMonth/index.js");
var _indexJsDefault77 = parcelHelpers.interopDefault(_indexJs77);
var _indexJs78 = require("./getDaysInYear/index.js");
var _indexJsDefault78 = parcelHelpers.interopDefault(_indexJs78);
var _indexJs79 = require("./getDecade/index.js");
var _indexJsDefault79 = parcelHelpers.interopDefault(_indexJs79);
var _indexJs80 = require("./getDefaultOptions/index.js");
var _indexJsDefault80 = parcelHelpers.interopDefault(_indexJs80);
var _indexJs81 = require("./getHours/index.js");
var _indexJsDefault81 = parcelHelpers.interopDefault(_indexJs81);
var _indexJs82 = require("./getISODay/index.js");
var _indexJsDefault82 = parcelHelpers.interopDefault(_indexJs82);
var _indexJs83 = require("./getISOWeek/index.js");
var _indexJsDefault83 = parcelHelpers.interopDefault(_indexJs83);
var _indexJs84 = require("./getISOWeekYear/index.js");
var _indexJsDefault84 = parcelHelpers.interopDefault(_indexJs84);
var _indexJs85 = require("./getISOWeeksInYear/index.js");
var _indexJsDefault85 = parcelHelpers.interopDefault(_indexJs85);
var _indexJs86 = require("./getMilliseconds/index.js");
var _indexJsDefault86 = parcelHelpers.interopDefault(_indexJs86);
var _indexJs87 = require("./getMinutes/index.js");
var _indexJsDefault87 = parcelHelpers.interopDefault(_indexJs87);
var _indexJs88 = require("./getMonth/index.js");
var _indexJsDefault88 = parcelHelpers.interopDefault(_indexJs88);
var _indexJs89 = require("./getOverlappingDaysInIntervals/index.js");
var _indexJsDefault89 = parcelHelpers.interopDefault(_indexJs89);
var _indexJs90 = require("./getQuarter/index.js");
var _indexJsDefault90 = parcelHelpers.interopDefault(_indexJs90);
var _indexJs91 = require("./getSeconds/index.js");
var _indexJsDefault91 = parcelHelpers.interopDefault(_indexJs91);
var _indexJs92 = require("./getTime/index.js");
var _indexJsDefault92 = parcelHelpers.interopDefault(_indexJs92);
var _indexJs93 = require("./getUnixTime/index.js");
var _indexJsDefault93 = parcelHelpers.interopDefault(_indexJs93);
var _indexJs94 = require("./getWeek/index.js");
var _indexJsDefault94 = parcelHelpers.interopDefault(_indexJs94);
var _indexJs95 = require("./getWeekOfMonth/index.js");
var _indexJsDefault95 = parcelHelpers.interopDefault(_indexJs95);
var _indexJs96 = require("./getWeekYear/index.js");
var _indexJsDefault96 = parcelHelpers.interopDefault(_indexJs96);
var _indexJs97 = require("./getWeeksInMonth/index.js");
var _indexJsDefault97 = parcelHelpers.interopDefault(_indexJs97);
var _indexJs98 = require("./getYear/index.js");
var _indexJsDefault98 = parcelHelpers.interopDefault(_indexJs98);
var _indexJs99 = require("./hoursToMilliseconds/index.js");
var _indexJsDefault99 = parcelHelpers.interopDefault(_indexJs99);
var _indexJs100 = require("./hoursToMinutes/index.js");
var _indexJsDefault100 = parcelHelpers.interopDefault(_indexJs100);
var _indexJs101 = require("./hoursToSeconds/index.js");
var _indexJsDefault101 = parcelHelpers.interopDefault(_indexJs101);
var _indexJs102 = require("./intervalToDuration/index.js");
var _indexJsDefault102 = parcelHelpers.interopDefault(_indexJs102);
var _indexJs103 = require("./intlFormat/index.js");
var _indexJsDefault103 = parcelHelpers.interopDefault(_indexJs103);
var _indexJs104 = require("./intlFormatDistance/index.js");
var _indexJsDefault104 = parcelHelpers.interopDefault(_indexJs104);
var _indexJs105 = require("./isAfter/index.js");
var _indexJsDefault105 = parcelHelpers.interopDefault(_indexJs105);
var _indexJs106 = require("./isBefore/index.js");
var _indexJsDefault106 = parcelHelpers.interopDefault(_indexJs106);
var _indexJs107 = require("./isDate/index.js");
var _indexJsDefault107 = parcelHelpers.interopDefault(_indexJs107);
var _indexJs108 = require("./isEqual/index.js");
var _indexJsDefault108 = parcelHelpers.interopDefault(_indexJs108);
var _indexJs109 = require("./isExists/index.js");
var _indexJsDefault109 = parcelHelpers.interopDefault(_indexJs109);
var _indexJs110 = require("./isFirstDayOfMonth/index.js");
var _indexJsDefault110 = parcelHelpers.interopDefault(_indexJs110);
var _indexJs111 = require("./isFriday/index.js");
var _indexJsDefault111 = parcelHelpers.interopDefault(_indexJs111);
var _indexJs112 = require("./isFuture/index.js");
var _indexJsDefault112 = parcelHelpers.interopDefault(_indexJs112);
var _indexJs113 = require("./isLastDayOfMonth/index.js");
var _indexJsDefault113 = parcelHelpers.interopDefault(_indexJs113);
var _indexJs114 = require("./isLeapYear/index.js");
var _indexJsDefault114 = parcelHelpers.interopDefault(_indexJs114);
var _indexJs115 = require("./isMatch/index.js");
var _indexJsDefault115 = parcelHelpers.interopDefault(_indexJs115);
var _indexJs116 = require("./isMonday/index.js");
var _indexJsDefault116 = parcelHelpers.interopDefault(_indexJs116);
var _indexJs117 = require("./isPast/index.js");
var _indexJsDefault117 = parcelHelpers.interopDefault(_indexJs117);
var _indexJs118 = require("./isSameDay/index.js");
var _indexJsDefault118 = parcelHelpers.interopDefault(_indexJs118);
var _indexJs119 = require("./isSameHour/index.js");
var _indexJsDefault119 = parcelHelpers.interopDefault(_indexJs119);
var _indexJs120 = require("./isSameISOWeek/index.js");
var _indexJsDefault120 = parcelHelpers.interopDefault(_indexJs120);
var _indexJs121 = require("./isSameISOWeekYear/index.js");
var _indexJsDefault121 = parcelHelpers.interopDefault(_indexJs121);
var _indexJs122 = require("./isSameMinute/index.js");
var _indexJsDefault122 = parcelHelpers.interopDefault(_indexJs122);
var _indexJs123 = require("./isSameMonth/index.js");
var _indexJsDefault123 = parcelHelpers.interopDefault(_indexJs123);
var _indexJs124 = require("./isSameQuarter/index.js");
var _indexJsDefault124 = parcelHelpers.interopDefault(_indexJs124);
var _indexJs125 = require("./isSameSecond/index.js");
var _indexJsDefault125 = parcelHelpers.interopDefault(_indexJs125);
var _indexJs126 = require("./isSameWeek/index.js");
var _indexJsDefault126 = parcelHelpers.interopDefault(_indexJs126);
var _indexJs127 = require("./isSameYear/index.js");
var _indexJsDefault127 = parcelHelpers.interopDefault(_indexJs127);
var _indexJs128 = require("./isSaturday/index.js");
var _indexJsDefault128 = parcelHelpers.interopDefault(_indexJs128);
var _indexJs129 = require("./isSunday/index.js");
var _indexJsDefault129 = parcelHelpers.interopDefault(_indexJs129);
var _indexJs130 = require("./isThisHour/index.js");
var _indexJsDefault130 = parcelHelpers.interopDefault(_indexJs130);
var _indexJs131 = require("./isThisISOWeek/index.js");
var _indexJsDefault131 = parcelHelpers.interopDefault(_indexJs131);
var _indexJs132 = require("./isThisMinute/index.js");
var _indexJsDefault132 = parcelHelpers.interopDefault(_indexJs132);
var _indexJs133 = require("./isThisMonth/index.js");
var _indexJsDefault133 = parcelHelpers.interopDefault(_indexJs133);
var _indexJs134 = require("./isThisQuarter/index.js");
var _indexJsDefault134 = parcelHelpers.interopDefault(_indexJs134);
var _indexJs135 = require("./isThisSecond/index.js");
var _indexJsDefault135 = parcelHelpers.interopDefault(_indexJs135);
var _indexJs136 = require("./isThisWeek/index.js");
var _indexJsDefault136 = parcelHelpers.interopDefault(_indexJs136);
var _indexJs137 = require("./isThisYear/index.js");
var _indexJsDefault137 = parcelHelpers.interopDefault(_indexJs137);
var _indexJs138 = require("./isThursday/index.js");
var _indexJsDefault138 = parcelHelpers.interopDefault(_indexJs138);
var _indexJs139 = require("./isToday/index.js");
var _indexJsDefault139 = parcelHelpers.interopDefault(_indexJs139);
var _indexJs140 = require("./isTomorrow/index.js");
var _indexJsDefault140 = parcelHelpers.interopDefault(_indexJs140);
var _indexJs141 = require("./isTuesday/index.js");
var _indexJsDefault141 = parcelHelpers.interopDefault(_indexJs141);
var _indexJs142 = require("./isValid/index.js");
var _indexJsDefault142 = parcelHelpers.interopDefault(_indexJs142);
var _indexJs143 = require("./isWednesday/index.js");
var _indexJsDefault143 = parcelHelpers.interopDefault(_indexJs143);
var _indexJs144 = require("./isWeekend/index.js");
var _indexJsDefault144 = parcelHelpers.interopDefault(_indexJs144);
var _indexJs145 = require("./isWithinInterval/index.js");
var _indexJsDefault145 = parcelHelpers.interopDefault(_indexJs145);
var _indexJs146 = require("./isYesterday/index.js");
var _indexJsDefault146 = parcelHelpers.interopDefault(_indexJs146);
var _indexJs147 = require("./lastDayOfDecade/index.js");
var _indexJsDefault147 = parcelHelpers.interopDefault(_indexJs147);
var _indexJs148 = require("./lastDayOfISOWeek/index.js");
var _indexJsDefault148 = parcelHelpers.interopDefault(_indexJs148);
var _indexJs149 = require("./lastDayOfISOWeekYear/index.js");
var _indexJsDefault149 = parcelHelpers.interopDefault(_indexJs149);
var _indexJs150 = require("./lastDayOfMonth/index.js");
var _indexJsDefault150 = parcelHelpers.interopDefault(_indexJs150);
var _indexJs151 = require("./lastDayOfQuarter/index.js");
var _indexJsDefault151 = parcelHelpers.interopDefault(_indexJs151);
var _indexJs152 = require("./lastDayOfWeek/index.js");
var _indexJsDefault152 = parcelHelpers.interopDefault(_indexJs152);
var _indexJs153 = require("./lastDayOfYear/index.js");
var _indexJsDefault153 = parcelHelpers.interopDefault(_indexJs153);
var _indexJs154 = require("./lightFormat/index.js");
var _indexJsDefault154 = parcelHelpers.interopDefault(_indexJs154);
var _indexJs155 = require("./max/index.js");
var _indexJsDefault155 = parcelHelpers.interopDefault(_indexJs155);
var _indexJs156 = require("./milliseconds/index.js");
var _indexJsDefault156 = parcelHelpers.interopDefault(_indexJs156);
var _indexJs157 = require("./millisecondsToHours/index.js");
var _indexJsDefault157 = parcelHelpers.interopDefault(_indexJs157);
var _indexJs158 = require("./millisecondsToMinutes/index.js");
var _indexJsDefault158 = parcelHelpers.interopDefault(_indexJs158);
var _indexJs159 = require("./millisecondsToSeconds/index.js");
var _indexJsDefault159 = parcelHelpers.interopDefault(_indexJs159);
var _indexJs160 = require("./min/index.js");
var _indexJsDefault160 = parcelHelpers.interopDefault(_indexJs160);
var _indexJs161 = require("./minutesToHours/index.js");
var _indexJsDefault161 = parcelHelpers.interopDefault(_indexJs161);
var _indexJs162 = require("./minutesToMilliseconds/index.js");
var _indexJsDefault162 = parcelHelpers.interopDefault(_indexJs162);
var _indexJs163 = require("./minutesToSeconds/index.js");
var _indexJsDefault163 = parcelHelpers.interopDefault(_indexJs163);
var _indexJs164 = require("./monthsToQuarters/index.js");
var _indexJsDefault164 = parcelHelpers.interopDefault(_indexJs164);
var _indexJs165 = require("./monthsToYears/index.js");
var _indexJsDefault165 = parcelHelpers.interopDefault(_indexJs165);
var _indexJs166 = require("./nextDay/index.js");
var _indexJsDefault166 = parcelHelpers.interopDefault(_indexJs166);
var _indexJs167 = require("./nextFriday/index.js");
var _indexJsDefault167 = parcelHelpers.interopDefault(_indexJs167);
var _indexJs168 = require("./nextMonday/index.js");
var _indexJsDefault168 = parcelHelpers.interopDefault(_indexJs168);
var _indexJs169 = require("./nextSaturday/index.js");
var _indexJsDefault169 = parcelHelpers.interopDefault(_indexJs169);
var _indexJs170 = require("./nextSunday/index.js");
var _indexJsDefault170 = parcelHelpers.interopDefault(_indexJs170);
var _indexJs171 = require("./nextThursday/index.js");
var _indexJsDefault171 = parcelHelpers.interopDefault(_indexJs171);
var _indexJs172 = require("./nextTuesday/index.js");
var _indexJsDefault172 = parcelHelpers.interopDefault(_indexJs172);
var _indexJs173 = require("./nextWednesday/index.js");
var _indexJsDefault173 = parcelHelpers.interopDefault(_indexJs173);
var _indexJs174 = require("./parse/index.js");
var _indexJsDefault174 = parcelHelpers.interopDefault(_indexJs174);
var _indexJs175 = require("./parseISO/index.js");
var _indexJsDefault175 = parcelHelpers.interopDefault(_indexJs175);
var _indexJs176 = require("./parseJSON/index.js");
var _indexJsDefault176 = parcelHelpers.interopDefault(_indexJs176);
var _indexJs177 = require("./previousDay/index.js");
var _indexJsDefault177 = parcelHelpers.interopDefault(_indexJs177);
var _indexJs178 = require("./previousFriday/index.js");
var _indexJsDefault178 = parcelHelpers.interopDefault(_indexJs178);
var _indexJs179 = require("./previousMonday/index.js");
var _indexJsDefault179 = parcelHelpers.interopDefault(_indexJs179);
var _indexJs180 = require("./previousSaturday/index.js");
var _indexJsDefault180 = parcelHelpers.interopDefault(_indexJs180);
var _indexJs181 = require("./previousSunday/index.js");
var _indexJsDefault181 = parcelHelpers.interopDefault(_indexJs181);
var _indexJs182 = require("./previousThursday/index.js");
var _indexJsDefault182 = parcelHelpers.interopDefault(_indexJs182);
var _indexJs183 = require("./previousTuesday/index.js");
var _indexJsDefault183 = parcelHelpers.interopDefault(_indexJs183);
var _indexJs184 = require("./previousWednesday/index.js");
var _indexJsDefault184 = parcelHelpers.interopDefault(_indexJs184);
var _indexJs185 = require("./quartersToMonths/index.js");
var _indexJsDefault185 = parcelHelpers.interopDefault(_indexJs185);
var _indexJs186 = require("./quartersToYears/index.js");
var _indexJsDefault186 = parcelHelpers.interopDefault(_indexJs186);
var _indexJs187 = require("./roundToNearestMinutes/index.js");
var _indexJsDefault187 = parcelHelpers.interopDefault(_indexJs187);
var _indexJs188 = require("./secondsToHours/index.js");
var _indexJsDefault188 = parcelHelpers.interopDefault(_indexJs188);
var _indexJs189 = require("./secondsToMilliseconds/index.js");
var _indexJsDefault189 = parcelHelpers.interopDefault(_indexJs189);
var _indexJs190 = require("./secondsToMinutes/index.js");
var _indexJsDefault190 = parcelHelpers.interopDefault(_indexJs190);
var _indexJs191 = require("./set/index.js");
var _indexJsDefault191 = parcelHelpers.interopDefault(_indexJs191);
var _indexJs192 = require("./setDate/index.js");
var _indexJsDefault192 = parcelHelpers.interopDefault(_indexJs192);
var _indexJs193 = require("./setDay/index.js");
var _indexJsDefault193 = parcelHelpers.interopDefault(_indexJs193);
var _indexJs194 = require("./setDayOfYear/index.js");
var _indexJsDefault194 = parcelHelpers.interopDefault(_indexJs194);
var _indexJs195 = require("./setDefaultOptions/index.js");
var _indexJsDefault195 = parcelHelpers.interopDefault(_indexJs195);
var _indexJs196 = require("./setHours/index.js");
var _indexJsDefault196 = parcelHelpers.interopDefault(_indexJs196);
var _indexJs197 = require("./setISODay/index.js");
var _indexJsDefault197 = parcelHelpers.interopDefault(_indexJs197);
var _indexJs198 = require("./setISOWeek/index.js");
var _indexJsDefault198 = parcelHelpers.interopDefault(_indexJs198);
var _indexJs199 = require("./setISOWeekYear/index.js");
var _indexJsDefault199 = parcelHelpers.interopDefault(_indexJs199);
var _indexJs200 = require("./setMilliseconds/index.js");
var _indexJsDefault200 = parcelHelpers.interopDefault(_indexJs200);
var _indexJs201 = require("./setMinutes/index.js");
var _indexJsDefault201 = parcelHelpers.interopDefault(_indexJs201);
var _indexJs202 = require("./setMonth/index.js");
var _indexJsDefault202 = parcelHelpers.interopDefault(_indexJs202);
var _indexJs203 = require("./setQuarter/index.js");
var _indexJsDefault203 = parcelHelpers.interopDefault(_indexJs203);
var _indexJs204 = require("./setSeconds/index.js");
var _indexJsDefault204 = parcelHelpers.interopDefault(_indexJs204);
var _indexJs205 = require("./setWeek/index.js");
var _indexJsDefault205 = parcelHelpers.interopDefault(_indexJs205);
var _indexJs206 = require("./setWeekYear/index.js");
var _indexJsDefault206 = parcelHelpers.interopDefault(_indexJs206);
var _indexJs207 = require("./setYear/index.js");
var _indexJsDefault207 = parcelHelpers.interopDefault(_indexJs207);
var _indexJs208 = require("./startOfDay/index.js");
var _indexJsDefault208 = parcelHelpers.interopDefault(_indexJs208);
var _indexJs209 = require("./startOfDecade/index.js");
var _indexJsDefault209 = parcelHelpers.interopDefault(_indexJs209);
var _indexJs210 = require("./startOfHour/index.js");
var _indexJsDefault210 = parcelHelpers.interopDefault(_indexJs210);
var _indexJs211 = require("./startOfISOWeek/index.js");
var _indexJsDefault211 = parcelHelpers.interopDefault(_indexJs211);
var _indexJs212 = require("./startOfISOWeekYear/index.js");
var _indexJsDefault212 = parcelHelpers.interopDefault(_indexJs212);
var _indexJs213 = require("./startOfMinute/index.js");
var _indexJsDefault213 = parcelHelpers.interopDefault(_indexJs213);
var _indexJs214 = require("./startOfMonth/index.js");
var _indexJsDefault214 = parcelHelpers.interopDefault(_indexJs214);
var _indexJs215 = require("./startOfQuarter/index.js");
var _indexJsDefault215 = parcelHelpers.interopDefault(_indexJs215);
var _indexJs216 = require("./startOfSecond/index.js");
var _indexJsDefault216 = parcelHelpers.interopDefault(_indexJs216);
var _indexJs217 = require("./startOfToday/index.js");
var _indexJsDefault217 = parcelHelpers.interopDefault(_indexJs217);
var _indexJs218 = require("./startOfTomorrow/index.js");
var _indexJsDefault218 = parcelHelpers.interopDefault(_indexJs218);
var _indexJs219 = require("./startOfWeek/index.js");
var _indexJsDefault219 = parcelHelpers.interopDefault(_indexJs219);
var _indexJs220 = require("./startOfWeekYear/index.js");
var _indexJsDefault220 = parcelHelpers.interopDefault(_indexJs220);
var _indexJs221 = require("./startOfYear/index.js");
var _indexJsDefault221 = parcelHelpers.interopDefault(_indexJs221);
var _indexJs222 = require("./startOfYesterday/index.js");
var _indexJsDefault222 = parcelHelpers.interopDefault(_indexJs222);
var _indexJs223 = require("./sub/index.js");
var _indexJsDefault223 = parcelHelpers.interopDefault(_indexJs223);
var _indexJs224 = require("./subBusinessDays/index.js");
var _indexJsDefault224 = parcelHelpers.interopDefault(_indexJs224);
var _indexJs225 = require("./subDays/index.js");
var _indexJsDefault225 = parcelHelpers.interopDefault(_indexJs225);
var _indexJs226 = require("./subHours/index.js");
var _indexJsDefault226 = parcelHelpers.interopDefault(_indexJs226);
var _indexJs227 = require("./subISOWeekYears/index.js");
var _indexJsDefault227 = parcelHelpers.interopDefault(_indexJs227);
var _indexJs228 = require("./subMilliseconds/index.js");
var _indexJsDefault228 = parcelHelpers.interopDefault(_indexJs228);
var _indexJs229 = require("./subMinutes/index.js");
var _indexJsDefault229 = parcelHelpers.interopDefault(_indexJs229);
var _indexJs230 = require("./subMonths/index.js");
var _indexJsDefault230 = parcelHelpers.interopDefault(_indexJs230);
var _indexJs231 = require("./subQuarters/index.js");
var _indexJsDefault231 = parcelHelpers.interopDefault(_indexJs231);
var _indexJs232 = require("./subSeconds/index.js");
var _indexJsDefault232 = parcelHelpers.interopDefault(_indexJs232);
var _indexJs233 = require("./subWeeks/index.js");
var _indexJsDefault233 = parcelHelpers.interopDefault(_indexJs233);
var _indexJs234 = require("./subYears/index.js");
var _indexJsDefault234 = parcelHelpers.interopDefault(_indexJs234);
var _indexJs235 = require("./toDate/index.js");
var _indexJsDefault235 = parcelHelpers.interopDefault(_indexJs235);
var _indexJs236 = require("./weeksToDays/index.js");
var _indexJsDefault236 = parcelHelpers.interopDefault(_indexJs236);
var _indexJs237 = require("./yearsToMonths/index.js");
var _indexJsDefault237 = parcelHelpers.interopDefault(_indexJs237);
var _indexJs238 = require("./yearsToQuarters/index.js");
var _indexJsDefault238 = parcelHelpers.interopDefault(_indexJs238);
var _indexJs239 = require("./constants/index.js");
parcelHelpers.exportAll(_indexJs239, exports);
},{"./add/index.js":false,"./addBusinessDays/index.js":false,"./addDays/index.js":false,"./addHours/index.js":false,"./addISOWeekYears/index.js":false,"./addMilliseconds/index.js":false,"./addMinutes/index.js":false,"./addMonths/index.js":false,"./addQuarters/index.js":false,"./addSeconds/index.js":false,"./addWeeks/index.js":false,"./addYears/index.js":false,"./areIntervalsOverlapping/index.js":false,"./clamp/index.js":false,"./closestIndexTo/index.js":false,"./closestTo/index.js":false,"./compareAsc/index.js":false,"./compareDesc/index.js":false,"./daysToWeeks/index.js":false,"./differenceInBusinessDays/index.js":false,"./differenceInCalendarDays/index.js":false,"./differenceInCalendarISOWeekYears/index.js":false,"./differenceInCalendarISOWeeks/index.js":false,"./differenceInCalendarMonths/index.js":false,"./differenceInCalendarQuarters/index.js":false,"./differenceInCalendarWeeks/index.js":false,"./differenceInCalendarYears/index.js":false,"./differenceInDays/index.js":false,"./differenceInHours/index.js":false,"./differenceInISOWeekYears/index.js":false,"./differenceInMilliseconds/index.js":false,"./differenceInMinutes/index.js":false,"./differenceInMonths/index.js":false,"./differenceInQuarters/index.js":false,"./differenceInSeconds/index.js":false,"./differenceInWeeks/index.js":false,"./differenceInYears/index.js":false,"./eachDayOfInterval/index.js":false,"./eachHourOfInterval/index.js":false,"./eachMinuteOfInterval/index.js":false,"./eachMonthOfInterval/index.js":false,"./eachQuarterOfInterval/index.js":false,"./eachWeekOfInterval/index.js":false,"./eachWeekendOfInterval/index.js":false,"./eachWeekendOfMonth/index.js":false,"./eachWeekendOfYear/index.js":false,"./eachYearOfInterval/index.js":false,"./endOfDay/index.js":false,"./endOfDecade/index.js":false,"./endOfHour/index.js":false,"./endOfISOWeek/index.js":false,"./endOfISOWeekYear/index.js":false,"./endOfMinute/index.js":false,"./endOfMonth/index.js":false,"./endOfQuarter/index.js":false,"./endOfSecond/index.js":false,"./endOfToday/index.js":false,"./endOfTomorrow/index.js":false,"./endOfWeek/index.js":false,"./endOfYear/index.js":false,"./endOfYesterday/index.js":false,"./format/index.js":"j6qcm","./formatDistance/index.js":"3Ar5s","./formatDistanceStrict/index.js":false,"./formatDistanceToNow/index.js":false,"./formatDistanceToNowStrict/index.js":false,"./formatDuration/index.js":false,"./formatISO/index.js":false,"./formatISO9075/index.js":false,"./formatISODuration/index.js":false,"./formatRFC3339/index.js":false,"./formatRFC7231/index.js":false,"./formatRelative/index.js":false,"./fromUnixTime/index.js":false,"./getDate/index.js":false,"./getDay/index.js":false,"./getDayOfYear/index.js":false,"./getDaysInMonth/index.js":false,"./getDaysInYear/index.js":false,"./getDecade/index.js":false,"./getDefaultOptions/index.js":false,"./getHours/index.js":false,"./getISODay/index.js":false,"./getISOWeek/index.js":false,"./getISOWeekYear/index.js":false,"./getISOWeeksInYear/index.js":false,"./getMilliseconds/index.js":false,"./getMinutes/index.js":false,"./getMonth/index.js":false,"./getOverlappingDaysInIntervals/index.js":false,"./getQuarter/index.js":false,"./getSeconds/index.js":false,"./getTime/index.js":false,"./getUnixTime/index.js":false,"./getWeek/index.js":false,"./getWeekOfMonth/index.js":false,"./getWeekYear/index.js":false,"./getWeeksInMonth/index.js":false,"./getYear/index.js":false,"./hoursToMilliseconds/index.js":false,"./hoursToMinutes/index.js":false,"./hoursToSeconds/index.js":false,"./intervalToDuration/index.js":false,"./intlFormat/index.js":false,"./intlFormatDistance/index.js":false,"./isAfter/index.js":false,"./isBefore/index.js":false,"./isDate/index.js":false,"./isEqual/index.js":false,"./isExists/index.js":false,"./isFirstDayOfMonth/index.js":false,"./isFriday/index.js":false,"./isFuture/index.js":false,"./isLastDayOfMonth/index.js":false,"./isLeapYear/index.js":false,"./isMatch/index.js":false,"./isMonday/index.js":false,"./isPast/index.js":false,"./isSameDay/index.js":false,"./isSameHour/index.js":false,"./isSameISOWeek/index.js":false,"./isSameISOWeekYear/index.js":false,"./isSameMinute/index.js":false,"./isSameMonth/index.js":false,"./isSameQuarter/index.js":false,"./isSameSecond/index.js":false,"./isSameWeek/index.js":false,"./isSameYear/index.js":false,"./isSaturday/index.js":false,"./isSunday/index.js":false,"./isThisHour/index.js":false,"./isThisISOWeek/index.js":false,"./isThisMinute/index.js":false,"./isThisMonth/index.js":false,"./isThisQuarter/index.js":false,"./isThisSecond/index.js":false,"./isThisWeek/index.js":false,"./isThisYear/index.js":false,"./isThursday/index.js":false,"./isToday/index.js":false,"./isTomorrow/index.js":false,"./isTuesday/index.js":false,"./isValid/index.js":false,"./isWednesday/index.js":false,"./isWeekend/index.js":false,"./isWithinInterval/index.js":false,"./isYesterday/index.js":false,"./lastDayOfDecade/index.js":false,"./lastDayOfISOWeek/index.js":false,"./lastDayOfISOWeekYear/index.js":false,"./lastDayOfMonth/index.js":false,"./lastDayOfQuarter/index.js":false,"./lastDayOfWeek/index.js":false,"./lastDayOfYear/index.js":false,"./lightFormat/index.js":false,"./max/index.js":false,"./milliseconds/index.js":false,"./millisecondsToHours/index.js":false,"./millisecondsToMinutes/index.js":false,"./millisecondsToSeconds/index.js":false,"./min/index.js":false,"./minutesToHours/index.js":false,"./minutesToMilliseconds/index.js":false,"./minutesToSeconds/index.js":false,"./monthsToQuarters/index.js":false,"./monthsToYears/index.js":false,"./nextDay/index.js":false,"./nextFriday/index.js":false,"./nextMonday/index.js":false,"./nextSaturday/index.js":false,"./nextSunday/index.js":false,"./nextThursday/index.js":false,"./nextTuesday/index.js":false,"./nextWednesday/index.js":false,"./parse/index.js":false,"./parseISO/index.js":false,"./parseJSON/index.js":false,"./previousDay/index.js":false,"./previousFriday/index.js":false,"./previousMonday/index.js":false,"./previousSaturday/index.js":false,"./previousSunday/index.js":false,"./previousThursday/index.js":false,"./previousTuesday/index.js":false,"./previousWednesday/index.js":false,"./quartersToMonths/index.js":false,"./quartersToYears/index.js":false,"./roundToNearestMinutes/index.js":false,"./secondsToHours/index.js":false,"./secondsToMilliseconds/index.js":false,"./secondsToMinutes/index.js":false,"./set/index.js":false,"./setDate/index.js":false,"./setDay/index.js":false,"./setDayOfYear/index.js":false,"./setDefaultOptions/index.js":false,"./setHours/index.js":false,"./setISODay/index.js":false,"./setISOWeek/index.js":false,"./setISOWeekYear/index.js":false,"./setMilliseconds/index.js":false,"./setMinutes/index.js":false,"./setMonth/index.js":false,"./setQuarter/index.js":false,"./setSeconds/index.js":false,"./setWeek/index.js":false,"./setWeekYear/index.js":false,"./setYear/index.js":false,"./startOfDay/index.js":false,"./startOfDecade/index.js":false,"./startOfHour/index.js":false,"./startOfISOWeek/index.js":false,"./startOfISOWeekYear/index.js":false,"./startOfMinute/index.js":false,"./startOfMonth/index.js":false,"./startOfQuarter/index.js":false,"./startOfSecond/index.js":false,"./startOfToday/index.js":false,"./startOfTomorrow/index.js":false,"./startOfWeek/index.js":false,"./startOfWeekYear/index.js":false,"./startOfYear/index.js":false,"./startOfYesterday/index.js":false,"./sub/index.js":false,"./subBusinessDays/index.js":false,"./subDays/index.js":false,"./subHours/index.js":false,"./subISOWeekYears/index.js":false,"./subMilliseconds/index.js":false,"./subMinutes/index.js":false,"./subMonths/index.js":false,"./subQuarters/index.js":false,"./subSeconds/index.js":false,"./subWeeks/index.js":false,"./subYears/index.js":false,"./toDate/index.js":false,"./weeksToDays/index.js":false,"./yearsToMonths/index.js":false,"./yearsToQuarters/index.js":false,"./constants/index.js":false,"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"64RNi":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>addMilliseconds);
var _indexJs = require("../_lib/toInteger/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../toDate/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
function addMilliseconds(dirtyDate, dirtyAmount) {
(0, _indexJsDefault2.default)(2, arguments);
var timestamp = (0, _indexJsDefault1.default)(dirtyDate).getTime();
var amount = (0, _indexJsDefault.default)(dirtyAmount);
return new Date(timestamp + amount);
}
},{"../_lib/toInteger/index.js":"nPgxy","../toDate/index.js":"g6izO","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"nPgxy":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>toInteger);
function toInteger(dirtyNumber) {
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) return NaN;
var number = Number(dirtyNumber);
if (isNaN(number)) return number;
return number < 0 ? Math.ceil(number) : Math.floor(number);
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"g6izO":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>toDate);
var _typeof = require("@babel/runtime/helpers/esm/typeof");
var _typeofDefault = parcelHelpers.interopDefault(_typeof);
var _indexJs = require("../_lib/requiredArgs/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
function toDate(argument) {
(0, _indexJsDefault.default)(1, arguments);
var argStr = Object.prototype.toString.call(argument);
// Clone the date
if (argument instanceof Date || (0, _typeofDefault.default)(argument) === "object" && argStr === "[object Date]") // Prevent the date to lose the milliseconds when passed to new Date() in IE10
return new Date(argument.getTime());
else if (typeof argument === "number" || argStr === "[object Number]") return new Date(argument);
else {
if ((typeof argument === "string" || argStr === "[object String]") && typeof console !== "undefined") {
// eslint-disable-next-line no-console
console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
// eslint-disable-next-line no-console
console.warn(new Error().stack);
}
return new Date(NaN);
}
}
},{"@babel/runtime/helpers/esm/typeof":"3EuKG","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"3EuKG":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>_typeof);
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
return typeof o;
} : function(o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"1toZm":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>requiredArgs);
function requiredArgs(required, args) {
if (args.length < required) throw new TypeError(required + " argument" + (required > 1 ? "s" : "") + " required, but only " + args.length + " present");
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"k8jty":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>compareAsc);
var _indexJs = require("../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
function compareAsc(dirtyDateLeft, dirtyDateRight) {
(0, _indexJsDefault1.default)(2, arguments);
var dateLeft = (0, _indexJsDefault.default)(dirtyDateLeft);
var dateRight = (0, _indexJsDefault.default)(dirtyDateRight);
var diff = dateLeft.getTime() - dateRight.getTime();
if (diff < 0) return -1;
else if (diff > 0) return 1;
else return diff;
}
},{"../toDate/index.js":"g6izO","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8F7VT":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>differenceInCalendarMonths);
var _indexJs = require("../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) {
(0, _indexJsDefault1.default)(2, arguments);
var dateLeft = (0, _indexJsDefault.default)(dirtyDateLeft);
var dateRight = (0, _indexJsDefault.default)(dirtyDateRight);
var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear();
var monthDiff = dateLeft.getMonth() - dateRight.getMonth();
return yearDiff * 12 + monthDiff;
}
},{"../toDate/index.js":"g6izO","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"iQSeV":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>differenceInMilliseconds);
var _indexJs = require("../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
function differenceInMilliseconds(dateLeft, dateRight) {
(0, _indexJsDefault1.default)(2, arguments);
return (0, _indexJsDefault.default)(dateLeft).getTime() - (0, _indexJsDefault.default)(dateRight).getTime();
}
},{"../toDate/index.js":"g6izO","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"3M6D4":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>differenceInMonths);
var _indexJs = require("../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../differenceInCalendarMonths/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../compareAsc/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
var _indexJs4 = require("../isLastDayOfMonth/index.js");
var _indexJsDefault4 = parcelHelpers.interopDefault(_indexJs4);
function differenceInMonths(dirtyDateLeft, dirtyDateRight) {
(0, _indexJsDefault3.default)(2, arguments);
var dateLeft = (0, _indexJsDefault.default)(dirtyDateLeft);
var dateRight = (0, _indexJsDefault.default)(dirtyDateRight);
var sign = (0, _indexJsDefault2.default)(dateLeft, dateRight);
var difference = Math.abs((0, _indexJsDefault1.default)(dateLeft, dateRight));
var result;
// Check for the difference of less than month
if (difference < 1) result = 0;
else {
if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) // This will check if the date is end of Feb and assign a higher end of month date
// to compare it with Jan
dateLeft.setDate(30);
dateLeft.setMonth(dateLeft.getMonth() - sign * difference);
// Math.abs(diff in full months - diff in calendar months) === 1 if last calendar month is not full
// If so, result must be decreased by 1 in absolute value
var isLastMonthNotFull = (0, _indexJsDefault2.default)(dateLeft, dateRight) === -sign;
// Check for cases of one full calendar month
if ((0, _indexJsDefault4.default)((0, _indexJsDefault.default)(dirtyDateLeft)) && difference === 1 && (0, _indexJsDefault2.default)(dirtyDateLeft, dateRight) === 1) isLastMonthNotFull = false;
result = sign * (difference - Number(isLastMonthNotFull));
}
// Prevent negative zero
return result === 0 ? 0 : result;
}
},{"../toDate/index.js":"g6izO","../differenceInCalendarMonths/index.js":"8F7VT","../compareAsc/index.js":"k8jty","../_lib/requiredArgs/index.js":"1toZm","../isLastDayOfMonth/index.js":"5gn3S","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"5gn3S":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>isLastDayOfMonth);
var _indexJs = require("../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../endOfDay/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../endOfMonth/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
function isLastDayOfMonth(dirtyDate) {
(0, _indexJsDefault3.default)(1, arguments);
var date = (0, _indexJsDefault.default)(dirtyDate);
return (0, _indexJsDefault1.default)(date).getTime() === (0, _indexJsDefault2.default)(date).getTime();
}
},{"../toDate/index.js":"g6izO","../endOfDay/index.js":"dShT4","../endOfMonth/index.js":"lcg62","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"dShT4":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>endOfDay);
var _indexJs = require("../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
function endOfDay(dirtyDate) {
(0, _indexJsDefault1.default)(1, arguments);
var date = (0, _indexJsDefault.default)(dirtyDate);
date.setHours(23, 59, 59, 999);
return date;
}
},{"../toDate/index.js":"g6izO","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"lcg62":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>endOfMonth);
var _indexJs = require("../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
function endOfMonth(dirtyDate) {
(0, _indexJsDefault1.default)(1, arguments);
var date = (0, _indexJsDefault.default)(dirtyDate);
var month = date.getMonth();
date.setFullYear(date.getFullYear(), month + 1, 0);
date.setHours(23, 59, 59, 999);
return date;
}
},{"../toDate/index.js":"g6izO","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"gZFNs":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>differenceInSeconds);
var _indexJs = require("../differenceInMilliseconds/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../_lib/roundingMethods/index.js");
function differenceInSeconds(dateLeft, dateRight, options) {
(0, _indexJsDefault1.default)(2, arguments);
var diff = (0, _indexJsDefault.default)(dateLeft, dateRight) / 1000;
return (0, _indexJs2.getRoundingMethod)(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
}
},{"../differenceInMilliseconds/index.js":"iQSeV","../_lib/requiredArgs/index.js":"1toZm","../_lib/roundingMethods/index.js":"eMTDk","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"eMTDk":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "getRoundingMethod", ()=>getRoundingMethod);
var roundingMap = {
ceil: Math.ceil,
round: Math.round,
floor: Math.floor,
trunc: function trunc(value) {
return value < 0 ? Math.ceil(value) : Math.floor(value);
} // Math.trunc is not supported by IE
};
var defaultRoundingMethod = "trunc";
function getRoundingMethod(method) {
return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"j6qcm":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>format);
var _indexJs = require("../isValid/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../subMilliseconds/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../toDate/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../_lib/format/formatters/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
var _indexJs4 = require("../_lib/format/longFormatters/index.js");
var _indexJsDefault4 = parcelHelpers.interopDefault(_indexJs4);
var _indexJs5 = require("../_lib/getTimezoneOffsetInMilliseconds/index.js");
var _indexJsDefault5 = parcelHelpers.interopDefault(_indexJs5);
var _indexJs6 = require("../_lib/protectedTokens/index.js");
var _indexJs7 = require("../_lib/toInteger/index.js");
var _indexJsDefault6 = parcelHelpers.interopDefault(_indexJs7);
var _indexJs8 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault7 = parcelHelpers.interopDefault(_indexJs8);
var _indexJs9 = require("../_lib/defaultOptions/index.js");
var _indexJs10 = require("../_lib/defaultLocale/index.js"); // This RegExp consists of three parts separated by `|`:
var _indexJsDefault8 = parcelHelpers.interopDefault(_indexJs10);
// - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
// (one of the certain letters followed by `o`)
// - (\w)\1* matches any sequences of the same letter
// - '' matches two quote characters in a row
// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
// except a single quote symbol, which ends the sequence.
// Two quote characters do not end the sequence.
// If there is no matching single quote
// then the sequence will continue until the end of the string.
// - . matches any single character unmatched by previous parts of the RegExps
var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
// This RegExp catches symbols escaped by quotes, and also
// sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
var escapedStringRegExp = /^'([^]*?)'?$/;
var doubleQuoteRegExp = /''/g;
var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
function format(dirtyDate, dirtyFormatStr, options) {
var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
(0, _indexJsDefault7.default)(2, arguments);
var formatStr = String(dirtyFormatStr);
var defaultOptions = (0, _indexJs9.getDefaultOptions)();
var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : (0, _indexJsDefault8.default);
var firstWeekContainsDate = (0, _indexJsDefault6.default)((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
// Test if weekStartsOn is between 1 and 7 _and_ is not NaN
if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");
var weekStartsOn = (0, _indexJsDefault6.default)((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
// Test if weekStartsOn is between 0 and 6 _and_ is not NaN
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");
if (!locale.localize) throw new RangeError("locale must contain localize property");
if (!locale.formatLong) throw new RangeError("locale must contain formatLong property");
var originalDate = (0, _indexJsDefault2.default)(dirtyDate);
if (!(0, _indexJsDefault.default)(originalDate)) throw new RangeError("Invalid time value");
// Convert the date in system timezone to the same date in UTC+00:00 timezone.
// This ensures that when UTC functions will be implemented, locales will be compatible with them.
// See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
var timezoneOffset = (0, _indexJsDefault5.default)(originalDate);
var utcDate = (0, _indexJsDefault1.default)(originalDate, timezoneOffset);
var formatterOptions = {
firstWeekContainsDate: firstWeekContainsDate,
weekStartsOn: weekStartsOn,
locale: locale,
_originalDate: originalDate
};
var result = formatStr.match(longFormattingTokensRegExp).map(function(substring) {
var firstCharacter = substring[0];
if (firstCharacter === "p" || firstCharacter === "P") {
var longFormatter = (0, _indexJsDefault4.default)[firstCharacter];
return longFormatter(substring, locale.formatLong);
}
return substring;
}).join("").match(formattingTokensRegExp).map(function(substring) {
// Replace two single quote characters with one single quote character
if (substring === "''") return "'";
var firstCharacter = substring[0];
if (firstCharacter === "'") return cleanEscapedString(substring);
var formatter = (0, _indexJsDefault3.default)[firstCharacter];
if (formatter) {
if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && (0, _indexJs6.isProtectedWeekYearToken)(substring)) (0, _indexJs6.throwProtectedError)(substring, dirtyFormatStr, String(dirtyDate));
if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && (0, _indexJs6.isProtectedDayOfYearToken)(substring)) (0, _indexJs6.throwProtectedError)(substring, dirtyFormatStr, String(dirtyDate));
return formatter(utcDate, substring, locale.localize, formatterOptions);
}
if (firstCharacter.match(unescapedLatinCharacterRegExp)) throw new RangeError("Format string contains an unescaped latin alphabet character `" + firstCharacter + "`");
return substring;
}).join("");
return result;
}
function cleanEscapedString(input) {
var matched = input.match(escapedStringRegExp);
if (!matched) return input;
return matched[1].replace(doubleQuoteRegExp, "'");
}
},{"../isValid/index.js":"gkSGH","../subMilliseconds/index.js":"46U1K","../toDate/index.js":"g6izO","../_lib/format/formatters/index.js":"djoJZ","../_lib/format/longFormatters/index.js":"ifl2k","../_lib/getTimezoneOffsetInMilliseconds/index.js":"jL4If","../_lib/protectedTokens/index.js":"VXKfn","../_lib/toInteger/index.js":"nPgxy","../_lib/requiredArgs/index.js":"1toZm","../_lib/defaultOptions/index.js":"iBwxJ","../_lib/defaultLocale/index.js":"1TdkP","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"gkSGH":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>isValid);
var _indexJs = require("../isDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../toDate/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
function isValid(dirtyDate) {
(0, _indexJsDefault2.default)(1, arguments);
if (!(0, _indexJsDefault.default)(dirtyDate) && typeof dirtyDate !== "number") return false;
var date = (0, _indexJsDefault1.default)(dirtyDate);
return !isNaN(Number(date));
}
},{"../isDate/index.js":"2V8pz","../toDate/index.js":"g6izO","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"2V8pz":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>isDate);
var _typeof = require("@babel/runtime/helpers/esm/typeof");
var _typeofDefault = parcelHelpers.interopDefault(_typeof);
var _indexJs = require("../_lib/requiredArgs/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
function isDate(value) {
(0, _indexJsDefault.default)(1, arguments);
return value instanceof Date || (0, _typeofDefault.default)(value) === "object" && Object.prototype.toString.call(value) === "[object Date]";
}
},{"@babel/runtime/helpers/esm/typeof":"3EuKG","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"46U1K":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>subMilliseconds);
var _indexJs = require("../addMilliseconds/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../_lib/toInteger/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
function subMilliseconds(dirtyDate, dirtyAmount) {
(0, _indexJsDefault1.default)(2, arguments);
var amount = (0, _indexJsDefault2.default)(dirtyAmount);
return (0, _indexJsDefault.default)(dirtyDate, -amount);
}
},{"../addMilliseconds/index.js":"64RNi","../_lib/requiredArgs/index.js":"1toZm","../_lib/toInteger/index.js":"nPgxy","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"djoJZ":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _indexJs = require("../../../_lib/getUTCDayOfYear/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../../../_lib/getUTCISOWeek/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../../../_lib/getUTCISOWeekYear/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../../../_lib/getUTCWeek/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
var _indexJs4 = require("../../../_lib/getUTCWeekYear/index.js");
var _indexJsDefault4 = parcelHelpers.interopDefault(_indexJs4);
var _indexJs5 = require("../../addLeadingZeros/index.js");
var _indexJsDefault5 = parcelHelpers.interopDefault(_indexJs5);
var _indexJs6 = require("../lightFormatters/index.js");
var _indexJsDefault6 = parcelHelpers.interopDefault(_indexJs6);
var dayPeriodEnum = {
am: "am",
pm: "pm",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
};
/*
* | | Unit | | Unit |
* |-----|--------------------------------|-----|--------------------------------|
* | a | AM, PM | A* | Milliseconds in day |
* | b | AM, PM, noon, midnight | B | Flexible day period |
* | c | Stand-alone local day of week | C* | Localized hour w/ day period |
* | d | Day of month | D | Day of year |
* | e | Local day of week | E | Day of week |
* | f | | F* | Day of week in month |
* | g* | Modified Julian day | G | Era |
* | h | Hour [1-12] | H | Hour [0-23] |
* | i! | ISO day of week | I! | ISO week of year |
* | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
* | k | Hour [1-24] | K | Hour [0-11] |
* | l* | (deprecated) | L | Stand-alone month |
* | m | Minute | M | Month |
* | n | | N | |
* | o! | Ordinal number modifier | O | Timezone (GMT) |
* | p! | Long localized time | P! | Long localized date |
* | q | Stand-alone quarter | Q | Quarter |
* | r* | Related Gregorian year | R! | ISO week-numbering year |
* | s | Second | S | Fraction of second |
* | t! | Seconds timestamp | T! | Milliseconds timestamp |
* | u | Extended year | U* | Cyclic year |
* | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
* | w | Local week of year | W* | Week of month |
* | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
* | y | Year (abs) | Y | Local week-numbering year |
* | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
*
* Letters marked by * are not implemented but reserved by Unicode standard.
*
* Letters marked by ! are non-standard, but implemented by date-fns:
* - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
* - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
* i.e. 7 for Sunday, 1 for Monday, etc.
* - `I` is ISO week of year, as opposed to `w` which is local week of year.
* - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
* `R` is supposed to be used in conjunction with `I` and `i`
* for universal ISO week-numbering date, whereas
* `Y` is supposed to be used in conjunction with `w` and `e`
* for week-numbering date specific to the locale.
* - `P` is long localized date format
* - `p` is long localized time format
*/ var formatters = {
// Era
G: function G(date, token, localize) {
var era = date.getUTCFullYear() > 0 ? 1 : 0;
switch(token){
// AD, BC
case "G":
case "GG":
case "GGG":
return localize.era(era, {
width: "abbreviated"
});
// A, B
case "GGGGG":
return localize.era(era, {
width: "narrow"
});
// Anno Domini, Before Christ
case "GGGG":
default:
return localize.era(era, {
width: "wide"
});
}
},
// Year
y: function y(date, token, localize) {
// Ordinal number
if (token === "yo") {
var signedYear = date.getUTCFullYear();
// Returns 1 for 1 BC (which is year 0 in JavaScript)
var year = signedYear > 0 ? signedYear : 1 - signedYear;
return localize.ordinalNumber(year, {
unit: "year"
});
}
return (0, _indexJsDefault6.default).y(date, token);
},
// Local week-numbering year
Y: function Y(date, token, localize, options) {
var signedWeekYear = (0, _indexJsDefault4.default)(date, options);
// Returns 1 for 1 BC (which is year 0 in JavaScript)
var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
// Two digit year
if (token === "YY") {
var twoDigitYear = weekYear % 100;
return (0, _indexJsDefault5.default)(twoDigitYear, 2);
}
// Ordinal number
if (token === "Yo") return localize.ordinalNumber(weekYear, {
unit: "year"
});
// Padding
return (0, _indexJsDefault5.default)(weekYear, token.length);
},
// ISO week-numbering year
R: function R(date, token) {
var isoWeekYear = (0, _indexJsDefault2.default)(date);
// Padding
return (0, _indexJsDefault5.default)(isoWeekYear, token.length);
},
// Extended year. This is a single number designating the year of this calendar system.
// The main difference between `y` and `u` localizers are B.C. years:
// | Year | `y` | `u` |
// |------|-----|-----|
// | AC 1 | 1 | 1 |
// | BC 1 | 1 | 0 |
// | BC 2 | 2 | -1 |
// Also `yy` always returns the last two digits of a year,
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
u: function u(date, token) {
var year = date.getUTCFullYear();
return (0, _indexJsDefault5.default)(year, token.length);
},
// Quarter
Q: function Q(date, token, localize) {
var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
switch(token){
// 1, 2, 3, 4
case "Q":
return String(quarter);
// 01, 02, 03, 04
case "QQ":
return (0, _indexJsDefault5.default)(quarter, 2);
// 1st, 2nd, 3rd, 4th
case "Qo":
return localize.ordinalNumber(quarter, {
unit: "quarter"
});
// Q1, Q2, Q3, Q4
case "QQQ":
return localize.quarter(quarter, {
width: "abbreviated",
context: "formatting"
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "QQQQQ":
return localize.quarter(quarter, {
width: "narrow",
context: "formatting"
});
// 1st quarter, 2nd quarter, ...
case "QQQQ":
default:
return localize.quarter(quarter, {
width: "wide",
context: "formatting"
});
}
},
// Stand-alone quarter
q: function q(date, token, localize) {
var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
switch(token){
// 1, 2, 3, 4
case "q":
return String(quarter);
// 01, 02, 03, 04
case "qq":
return (0, _indexJsDefault5.default)(quarter, 2);
// 1st, 2nd, 3rd, 4th
case "qo":
return localize.ordinalNumber(quarter, {
unit: "quarter"
});
// Q1, Q2, Q3, Q4
case "qqq":
return localize.quarter(quarter, {
width: "abbreviated",
context: "standalone"
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "qqqqq":
return localize.quarter(quarter, {
width: "narrow",
context: "standalone"
});
// 1st quarter, 2nd quarter, ...
case "qqqq":
default:
return localize.quarter(quarter, {
width: "wide",
context: "standalone"
});
}
},
// Month
M: function M(date, token, localize) {
var month = date.getUTCMonth();
switch(token){
case "M":
case "MM":
return (0, _indexJsDefault6.default).M(date, token);
// 1st, 2nd, ..., 12th
case "Mo":
return localize.ordinalNumber(month + 1, {
unit: "month"
});
// Jan, Feb, ..., Dec
case "MMM":
return localize.month(month, {
width: "abbreviated",
context: "formatting"
});
// J, F, ..., D
case "MMMMM":
return localize.month(month, {
width: "narrow",
context: "formatting"
});
// January, February, ..., December
case "MMMM":
default:
return localize.month(month, {
width: "wide",
context: "formatting"
});
}
},
// Stand-alone month
L: function L(date, token, localize) {
var month = date.getUTCMonth();
switch(token){
// 1, 2, ..., 12
case "L":
return String(month + 1);
// 01, 02, ..., 12
case "LL":
return (0, _indexJsDefault5.default)(month + 1, 2);
// 1st, 2nd, ..., 12th
case "Lo":
return localize.ordinalNumber(month + 1, {
unit: "month"
});
// Jan, Feb, ..., Dec
case "LLL":
return localize.month(month, {
width: "abbreviated",
context: "standalone"
});
// J, F, ..., D
case "LLLLL":
return localize.month(month, {
width: "narrow",
context: "standalone"
});
// January, February, ..., December
case "LLLL":
default:
return localize.month(month, {
width: "wide",
context: "standalone"
});
}
},
// Local week of year
w: function w(date, token, localize, options) {
var week = (0, _indexJsDefault3.default)(date, options);
if (token === "wo") return localize.ordinalNumber(week, {
unit: "week"
});
return (0, _indexJsDefault5.default)(week, token.length);
},
// ISO week of year
I: function I(date, token, localize) {
var isoWeek = (0, _indexJsDefault1.default)(date);
if (token === "Io") return localize.ordinalNumber(isoWeek, {
unit: "week"
});
return (0, _indexJsDefault5.default)(isoWeek, token.length);
},
// Day of the month
d: function d(date, token, localize) {
if (token === "do") return localize.ordinalNumber(date.getUTCDate(), {
unit: "date"
});
return (0, _indexJsDefault6.default).d(date, token);
},
// Day of year
D: function D(date, token, localize) {
var dayOfYear = (0, _indexJsDefault.default)(date);
if (token === "Do") return localize.ordinalNumber(dayOfYear, {
unit: "dayOfYear"
});
return (0, _indexJsDefault5.default)(dayOfYear, token.length);
},
// Day of week
E: function E(date, token, localize) {
var dayOfWeek = date.getUTCDay();
switch(token){
// Tue
case "E":
case "EE":
case "EEE":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "formatting"
});
// T
case "EEEEE":
return localize.day(dayOfWeek, {
width: "narrow",
context: "formatting"
});
// Tu
case "EEEEEE":
return localize.day(dayOfWeek, {
width: "short",
context: "formatting"
});
// Tuesday
case "EEEE":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "formatting"
});
}
},
// Local day of week
e: function e(date, token, localize, options) {
var dayOfWeek = date.getUTCDay();
var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
switch(token){
// Numerical value (Nth day of week with current locale or weekStartsOn)
case "e":
return String(localDayOfWeek);
// Padded numerical value
case "ee":
return (0, _indexJsDefault5.default)(localDayOfWeek, 2);
// 1st, 2nd, ..., 7th
case "eo":
return localize.ordinalNumber(localDayOfWeek, {
unit: "day"
});
case "eee":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "formatting"
});
// T
case "eeeee":
return localize.day(dayOfWeek, {
width: "narrow",
context: "formatting"
});
// Tu
case "eeeeee":
return localize.day(dayOfWeek, {
width: "short",
context: "formatting"
});
// Tuesday
case "eeee":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "formatting"
});
}
},
// Stand-alone local day of week
c: function c(date, token, localize, options) {
var dayOfWeek = date.getUTCDay();
var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
switch(token){
// Numerical value (same as in `e`)
case "c":
return String(localDayOfWeek);
// Padded numerical value
case "cc":
return (0, _indexJsDefault5.default)(localDayOfWeek, token.length);
// 1st, 2nd, ..., 7th
case "co":
return localize.ordinalNumber(localDayOfWeek, {
unit: "day"
});
case "ccc":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "standalone"
});
// T
case "ccccc":
return localize.day(dayOfWeek, {
width: "narrow",
context: "standalone"
});
// Tu
case "cccccc":
return localize.day(dayOfWeek, {
width: "short",
context: "standalone"
});
// Tuesday
case "cccc":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "standalone"
});
}
},
// ISO day of week
i: function i(date, token, localize) {
var dayOfWeek = date.getUTCDay();
var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
switch(token){
// 2
case "i":
return String(isoDayOfWeek);
// 02
case "ii":
return (0, _indexJsDefault5.default)(isoDayOfWeek, token.length);
// 2nd
case "io":
return localize.ordinalNumber(isoDayOfWeek, {
unit: "day"
});
// Tue
case "iii":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "formatting"
});
// T
case "iiiii":
return localize.day(dayOfWeek, {
width: "narrow",
context: "formatting"
});
// Tu
case "iiiiii":
return localize.day(dayOfWeek, {
width: "short",
context: "formatting"
});
// Tuesday
case "iiii":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "formatting"
});
}
},
// AM or PM
a: function a(date, token, localize) {
var hours = date.getUTCHours();
var dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
switch(token){
case "a":
case "aa":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
});
case "aaa":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "aaaaa":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting"
});
case "aaaa":
default:
return localize.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting"
});
}
},
// AM, PM, midnight, noon
b: function b(date, token, localize) {
var hours = date.getUTCHours();
var dayPeriodEnumValue;
if (hours === 12) dayPeriodEnumValue = dayPeriodEnum.noon;
else if (hours === 0) dayPeriodEnumValue = dayPeriodEnum.midnight;
else dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
switch(token){
case "b":
case "bb":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
});
case "bbb":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
}).toLowerCase();
case "bbbbb":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting"
});
case "bbbb":
default:
return localize.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting"
});
}
},
// in the morning, in the afternoon, in the evening, at night
B: function B(date, token, localize) {
var hours = date.getUTCHours();
var dayPeriodEnumValue;
if (hours >= 17) dayPeriodEnumValue = dayPeriodEnum.evening;
else if (hours >= 12) dayPeriodEnumValue = dayPeriodEnum.afternoon;
else if (hours >= 4) dayPeriodEnumValue = dayPeriodEnum.morning;
else dayPeriodEnumValue = dayPeriodEnum.night;
switch(token){
case "B":
case "BB":
case "BBB":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting"
});
case "BBBBB":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting"
});
case "BBBB":
default:
return localize.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting"
});
}
},
// Hour [1-12]
h: function h(date, token, localize) {
if (token === "ho") {
var hours = date.getUTCHours() % 12;
if (hours === 0) hours = 12;
return localize.ordinalNumber(hours, {
unit: "hour"
});
}
return (0, _indexJsDefault6.default).h(date, token);
},
// Hour [0-23]
H: function H(date, token, localize) {
if (token === "Ho") return localize.ordinalNumber(date.getUTCHours(), {
unit: "hour"
});
return (0, _indexJsDefault6.default).H(date, token);
},
// Hour [0-11]
K: function K(date, token, localize) {
var hours = date.getUTCHours() % 12;
if (token === "Ko") return localize.ordinalNumber(hours, {
unit: "hour"
});
return (0, _indexJsDefault5.default)(hours, token.length);
},
// Hour [1-24]
k: function k(date, token, localize) {
var hours = date.getUTCHours();
if (hours === 0) hours = 24;
if (token === "ko") return localize.ordinalNumber(hours, {
unit: "hour"
});
return (0, _indexJsDefault5.default)(hours, token.length);
},
// Minute
m: function m(date, token, localize) {
if (token === "mo") return localize.ordinalNumber(date.getUTCMinutes(), {
unit: "minute"
});
return (0, _indexJsDefault6.default).m(date, token);
},
// Second
s: function s(date, token, localize) {
if (token === "so") return localize.ordinalNumber(date.getUTCSeconds(), {
unit: "second"
});
return (0, _indexJsDefault6.default).s(date, token);
},
// Fraction of second
S: function S(date, token) {
return (0, _indexJsDefault6.default).S(date, token);
},
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
X: function X(date, token, _localize, options) {
var originalDate = options._originalDate || date;
var timezoneOffset = originalDate.getTimezoneOffset();
if (timezoneOffset === 0) return "Z";
switch(token){
// Hours and optional minutes
case "X":
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XX`
case "XXXX":
case "XX":
// Hours and minutes without `:` delimiter
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XXX`
case "XXXXX":
case "XXX":
default:
return formatTimezone(timezoneOffset, ":");
}
},
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
x: function x(date, token, _localize, options) {
var originalDate = options._originalDate || date;
var timezoneOffset = originalDate.getTimezoneOffset();
switch(token){
// Hours and optional minutes
case "x":
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xx`
case "xxxx":
case "xx":
// Hours and minutes without `:` delimiter
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xxx`
case "xxxxx":
case "xxx":
default:
return formatTimezone(timezoneOffset, ":");
}
},
// Timezone (GMT)
O: function O(date, token, _localize, options) {
var originalDate = options._originalDate || date;
var timezoneOffset = originalDate.getTimezoneOffset();
switch(token){
// Short
case "O":
case "OO":
case "OOO":
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
// Long
case "OOOO":
default:
return "GMT" + formatTimezone(timezoneOffset, ":");
}
},
// Timezone (specific non-location)
z: function z(date, token, _localize, options) {
var originalDate = options._originalDate || date;
var timezoneOffset = originalDate.getTimezoneOffset();
switch(token){
// Short
case "z":
case "zz":
case "zzz":
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
// Long
case "zzzz":
default:
return "GMT" + formatTimezone(timezoneOffset, ":");
}
},
// Seconds timestamp
t: function t(date, token, _localize, options) {
var originalDate = options._originalDate || date;
var timestamp = Math.floor(originalDate.getTime() / 1000);
return (0, _indexJsDefault5.default)(timestamp, token.length);
},
// Milliseconds timestamp
T: function T(date, token, _localize, options) {
var originalDate = options._originalDate || date;
var timestamp = originalDate.getTime();
return (0, _indexJsDefault5.default)(timestamp, token.length);
}
};
function formatTimezoneShort(offset, dirtyDelimiter) {
var sign = offset > 0 ? "-" : "+";
var absOffset = Math.abs(offset);
var hours = Math.floor(absOffset / 60);
var minutes = absOffset % 60;
if (minutes === 0) return sign + String(hours);
var delimiter = dirtyDelimiter || "";
return sign + String(hours) + delimiter + (0, _indexJsDefault5.default)(minutes, 2);
}
function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
if (offset % 60 === 0) {
var sign = offset > 0 ? "-" : "+";
return sign + (0, _indexJsDefault5.default)(Math.abs(offset) / 60, 2);
}
return formatTimezone(offset, dirtyDelimiter);
}
function formatTimezone(offset, dirtyDelimiter) {
var delimiter = dirtyDelimiter || "";
var sign = offset > 0 ? "-" : "+";
var absOffset = Math.abs(offset);
var hours = (0, _indexJsDefault5.default)(Math.floor(absOffset / 60), 2);
var minutes = (0, _indexJsDefault5.default)(absOffset % 60, 2);
return sign + hours + delimiter + minutes;
}
exports.default = formatters;
},{"../../../_lib/getUTCDayOfYear/index.js":"g9JRO","../../../_lib/getUTCISOWeek/index.js":"jryE3","../../../_lib/getUTCISOWeekYear/index.js":"eHssd","../../../_lib/getUTCWeek/index.js":"aezdu","../../../_lib/getUTCWeekYear/index.js":"eYkAV","../../addLeadingZeros/index.js":"jQY88","../lightFormatters/index.js":"6L4YZ","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"g9JRO":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>getUTCDayOfYear);
var _indexJs = require("../../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var MILLISECONDS_IN_DAY = 86400000;
function getUTCDayOfYear(dirtyDate) {
(0, _indexJsDefault1.default)(1, arguments);
var date = (0, _indexJsDefault.default)(dirtyDate);
var timestamp = date.getTime();
date.setUTCMonth(0, 1);
date.setUTCHours(0, 0, 0, 0);
var startOfYearTimestamp = date.getTime();
var difference = timestamp - startOfYearTimestamp;
return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
}
},{"../../toDate/index.js":"g6izO","../requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"jryE3":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>getUTCISOWeek);
var _indexJs = require("../../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../startOfUTCISOWeek/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../startOfUTCISOWeekYear/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../requiredArgs/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
var MILLISECONDS_IN_WEEK = 604800000;
function getUTCISOWeek(dirtyDate) {
(0, _indexJsDefault3.default)(1, arguments);
var date = (0, _indexJsDefault.default)(dirtyDate);
var diff = (0, _indexJsDefault1.default)(date).getTime() - (0, _indexJsDefault2.default)(date).getTime();
// Round the number of days to the nearest integer
// because the number of milliseconds in a week is not constant
// (e.g. it's different in the week of the daylight saving time clock shift)
return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
}
},{"../../toDate/index.js":"g6izO","../startOfUTCISOWeek/index.js":"8mZl7","../startOfUTCISOWeekYear/index.js":"emGJU","../requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8mZl7":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>startOfUTCISOWeek);
var _indexJs = require("../../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
function startOfUTCISOWeek(dirtyDate) {
(0, _indexJsDefault1.default)(1, arguments);
var weekStartsOn = 1;
var date = (0, _indexJsDefault.default)(dirtyDate);
var day = date.getUTCDay();
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
date.setUTCDate(date.getUTCDate() - diff);
date.setUTCHours(0, 0, 0, 0);
return date;
}
},{"../../toDate/index.js":"g6izO","../requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"emGJU":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>startOfUTCISOWeekYear);
var _indexJs = require("../getUTCISOWeekYear/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../startOfUTCISOWeek/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../requiredArgs/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
function startOfUTCISOWeekYear(dirtyDate) {
(0, _indexJsDefault2.default)(1, arguments);
var year = (0, _indexJsDefault.default)(dirtyDate);
var fourthOfJanuary = new Date(0);
fourthOfJanuary.setUTCFullYear(year, 0, 4);
fourthOfJanuary.setUTCHours(0, 0, 0, 0);
var date = (0, _indexJsDefault1.default)(fourthOfJanuary);
return date;
}
},{"../getUTCISOWeekYear/index.js":"eHssd","../startOfUTCISOWeek/index.js":"8mZl7","../requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"eHssd":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>getUTCISOWeekYear);
var _indexJs = require("../../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../startOfUTCISOWeek/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
function getUTCISOWeekYear(dirtyDate) {
(0, _indexJsDefault1.default)(1, arguments);
var date = (0, _indexJsDefault.default)(dirtyDate);
var year = date.getUTCFullYear();
var fourthOfJanuaryOfNextYear = new Date(0);
fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
var startOfNextYear = (0, _indexJsDefault2.default)(fourthOfJanuaryOfNextYear);
var fourthOfJanuaryOfThisYear = new Date(0);
fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
var startOfThisYear = (0, _indexJsDefault2.default)(fourthOfJanuaryOfThisYear);
if (date.getTime() >= startOfNextYear.getTime()) return year + 1;
else if (date.getTime() >= startOfThisYear.getTime()) return year;
else return year - 1;
}
},{"../../toDate/index.js":"g6izO","../requiredArgs/index.js":"1toZm","../startOfUTCISOWeek/index.js":"8mZl7","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"aezdu":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>getUTCWeek);
var _indexJs = require("../../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../startOfUTCWeek/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../startOfUTCWeekYear/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../requiredArgs/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
var MILLISECONDS_IN_WEEK = 604800000;
function getUTCWeek(dirtyDate, options) {
(0, _indexJsDefault3.default)(1, arguments);
var date = (0, _indexJsDefault.default)(dirtyDate);
var diff = (0, _indexJsDefault1.default)(date, options).getTime() - (0, _indexJsDefault2.default)(date, options).getTime();
// Round the number of days to the nearest integer
// because the number of milliseconds in a week is not constant
// (e.g. it's different in the week of the daylight saving time clock shift)
return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
}
},{"../../toDate/index.js":"g6izO","../startOfUTCWeek/index.js":"fkwiF","../startOfUTCWeekYear/index.js":"5hpw5","../requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fkwiF":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>startOfUTCWeek);
var _indexJs = require("../../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../toInteger/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../defaultOptions/index.js");
function startOfUTCWeek(dirtyDate, options) {
var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
(0, _indexJsDefault1.default)(1, arguments);
var defaultOptions = (0, _indexJs3.getDefaultOptions)();
var weekStartsOn = (0, _indexJsDefault2.default)((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
// Test if weekStartsOn is between 0 and 6 _and_ is not NaN
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");
var date = (0, _indexJsDefault.default)(dirtyDate);
var day = date.getUTCDay();
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
date.setUTCDate(date.getUTCDate() - diff);
date.setUTCHours(0, 0, 0, 0);
return date;
}
},{"../../toDate/index.js":"g6izO","../requiredArgs/index.js":"1toZm","../toInteger/index.js":"nPgxy","../defaultOptions/index.js":"iBwxJ","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"iBwxJ":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "getDefaultOptions", ()=>getDefaultOptions);
parcelHelpers.export(exports, "setDefaultOptions", ()=>setDefaultOptions);
var defaultOptions = {};
function getDefaultOptions() {
return defaultOptions;
}
function setDefaultOptions(newOptions) {
defaultOptions = newOptions;
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"5hpw5":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>startOfUTCWeekYear);
var _indexJs = require("../getUTCWeekYear/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../startOfUTCWeek/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../toInteger/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
var _indexJs4 = require("../defaultOptions/index.js");
function startOfUTCWeekYear(dirtyDate, options) {
var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
(0, _indexJsDefault1.default)(1, arguments);
var defaultOptions = (0, _indexJs4.getDefaultOptions)();
var firstWeekContainsDate = (0, _indexJsDefault3.default)((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
var year = (0, _indexJsDefault.default)(dirtyDate, options);
var firstWeek = new Date(0);
firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
firstWeek.setUTCHours(0, 0, 0, 0);
var date = (0, _indexJsDefault2.default)(firstWeek, options);
return date;
}
},{"../getUTCWeekYear/index.js":"eYkAV","../requiredArgs/index.js":"1toZm","../startOfUTCWeek/index.js":"fkwiF","../toInteger/index.js":"nPgxy","../defaultOptions/index.js":"iBwxJ","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"eYkAV":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>getUTCWeekYear);
var _indexJs = require("../../toDate/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../requiredArgs/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../startOfUTCWeek/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../toInteger/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
var _indexJs4 = require("../defaultOptions/index.js");
function getUTCWeekYear(dirtyDate, options) {
var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
(0, _indexJsDefault1.default)(1, arguments);
var date = (0, _indexJsDefault.default)(dirtyDate);
var year = date.getUTCFullYear();
var defaultOptions = (0, _indexJs4.getDefaultOptions)();
var firstWeekContainsDate = (0, _indexJsDefault3.default)((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
// Test if weekStartsOn is between 1 and 7 _and_ is not NaN
if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");
var firstWeekOfNextYear = new Date(0);
firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
var startOfNextYear = (0, _indexJsDefault2.default)(firstWeekOfNextYear, options);
var firstWeekOfThisYear = new Date(0);
firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
var startOfThisYear = (0, _indexJsDefault2.default)(firstWeekOfThisYear, options);
if (date.getTime() >= startOfNextYear.getTime()) return year + 1;
else if (date.getTime() >= startOfThisYear.getTime()) return year;
else return year - 1;
}
},{"../../toDate/index.js":"g6izO","../requiredArgs/index.js":"1toZm","../startOfUTCWeek/index.js":"fkwiF","../toInteger/index.js":"nPgxy","../defaultOptions/index.js":"iBwxJ","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"jQY88":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>addLeadingZeros);
function addLeadingZeros(number, targetLength) {
var sign = number < 0 ? "-" : "";
var output = Math.abs(number).toString();
while(output.length < targetLength)output = "0" + output;
return sign + output;
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"6L4YZ":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _indexJs = require("../../addLeadingZeros/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
/*
* | | Unit | | Unit |
* |-----|--------------------------------|-----|--------------------------------|
* | a | AM, PM | A* | |
* | d | Day of month | D | |
* | h | Hour [1-12] | H | Hour [0-23] |
* | m | Minute | M | Month |
* | s | Second | S | Fraction of second |
* | y | Year (abs) | Y | |
*
* Letters marked by * are not implemented but reserved by Unicode standard.
*/ var formatters = {
// Year
y: function y(date, token) {
// From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
// | Year | y | yy | yyy | yyyy | yyyyy |
// |----------|-------|----|-------|-------|-------|
// | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
// | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
// | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
// | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
// | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
var signedYear = date.getUTCFullYear();
// Returns 1 for 1 BC (which is year 0 in JavaScript)
var year = signedYear > 0 ? signedYear : 1 - signedYear;
return (0, _indexJsDefault.default)(token === "yy" ? year % 100 : year, token.length);
},
// Month
M: function M(date, token) {
var month = date.getUTCMonth();
return token === "M" ? String(month + 1) : (0, _indexJsDefault.default)(month + 1, 2);
},
// Day of the month
d: function d(date, token) {
return (0, _indexJsDefault.default)(date.getUTCDate(), token.length);
},
// AM or PM
a: function a(date, token) {
var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? "pm" : "am";
switch(token){
case "a":
case "aa":
return dayPeriodEnumValue.toUpperCase();
case "aaa":
return dayPeriodEnumValue;
case "aaaaa":
return dayPeriodEnumValue[0];
case "aaaa":
default:
return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
}
},
// Hour [1-12]
h: function h(date, token) {
return (0, _indexJsDefault.default)(date.getUTCHours() % 12 || 12, token.length);
},
// Hour [0-23]
H: function H(date, token) {
return (0, _indexJsDefault.default)(date.getUTCHours(), token.length);
},
// Minute
m: function m(date, token) {
return (0, _indexJsDefault.default)(date.getUTCMinutes(), token.length);
},
// Second
s: function s(date, token) {
return (0, _indexJsDefault.default)(date.getUTCSeconds(), token.length);
},
// Fraction of second
S: function S(date, token) {
var numberOfDigits = token.length;
var milliseconds = date.getUTCMilliseconds();
var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
return (0, _indexJsDefault.default)(fractionalSeconds, token.length);
}
};
exports.default = formatters;
},{"../../addLeadingZeros/index.js":"jQY88","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"ifl2k":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
switch(pattern){
case "P":
return formatLong.date({
width: "short"
});
case "PP":
return formatLong.date({
width: "medium"
});
case "PPP":
return formatLong.date({
width: "long"
});
case "PPPP":
default:
return formatLong.date({
width: "full"
});
}
};
var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
switch(pattern){
case "p":
return formatLong.time({
width: "short"
});
case "pp":
return formatLong.time({
width: "medium"
});
case "ppp":
return formatLong.time({
width: "long"
});
case "pppp":
default:
return formatLong.time({
width: "full"
});
}
};
var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
var matchResult = pattern.match(/(P+)(p+)?/) || [];
var datePattern = matchResult[1];
var timePattern = matchResult[2];
if (!timePattern) return dateLongFormatter(pattern, formatLong);
var dateTimeFormat;
switch(datePattern){
case "P":
dateTimeFormat = formatLong.dateTime({
width: "short"
});
break;
case "PP":
dateTimeFormat = formatLong.dateTime({
width: "medium"
});
break;
case "PPP":
dateTimeFormat = formatLong.dateTime({
width: "long"
});
break;
case "PPPP":
default:
dateTimeFormat = formatLong.dateTime({
width: "full"
});
break;
}
return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong)).replace("{{time}}", timeLongFormatter(timePattern, formatLong));
};
var longFormatters = {
p: timeLongFormatter,
P: dateTimeLongFormatter
};
exports.default = longFormatters;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"jL4If":[function(require,module,exports) {
/**
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
* They usually appear for dates that denote time before the timezones were introduced
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
* and GMT+01:00:00 after that date)
*
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
* which would lead to incorrect calculations.
*
* This function returns the timezone offset in milliseconds that takes seconds in account.
*/ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>getTimezoneOffsetInMilliseconds);
function getTimezoneOffsetInMilliseconds(date) {
var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
utcDate.setUTCFullYear(date.getFullYear());
return date.getTime() - utcDate.getTime();
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"VXKfn":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "isProtectedDayOfYearToken", ()=>isProtectedDayOfYearToken);
parcelHelpers.export(exports, "isProtectedWeekYearToken", ()=>isProtectedWeekYearToken);
parcelHelpers.export(exports, "throwProtectedError", ()=>throwProtectedError);
var protectedDayOfYearTokens = [
"D",
"DD"
];
var protectedWeekYearTokens = [
"YY",
"YYYY"
];
function isProtectedDayOfYearToken(token) {
return protectedDayOfYearTokens.indexOf(token) !== -1;
}
function isProtectedWeekYearToken(token) {
return protectedWeekYearTokens.indexOf(token) !== -1;
}
function throwProtectedError(token, format, input) {
if (token === "YYYY") throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
else if (token === "YY") throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
else if (token === "D") throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
else if (token === "DD") throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"1TdkP":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _indexJs = require("../../locale/en-US/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
exports.default = (0, _indexJsDefault.default);
},{"../../locale/en-US/index.js":"21gPD","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"21gPD":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _indexJs = require("./_lib/formatDistance/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("./_lib/formatLong/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("./_lib/formatRelative/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("./_lib/localize/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs3);
var _indexJs4 = require("./_lib/match/index.js");
var _indexJsDefault4 = parcelHelpers.interopDefault(_indexJs4);
/**
* @type {Locale}
* @category Locales
* @summary English locale (United States).
* @language English
* @iso-639-2 eng
* @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
* @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
*/ var locale = {
code: "en-US",
formatDistance: (0, _indexJsDefault.default),
formatLong: (0, _indexJsDefault1.default),
formatRelative: (0, _indexJsDefault2.default),
localize: (0, _indexJsDefault3.default),
match: (0, _indexJsDefault4.default),
options: {
weekStartsOn: 0 /* Sunday */ ,
firstWeekContainsDate: 1
}
};
exports.default = locale;
},{"./_lib/formatDistance/index.js":"8spY9","./_lib/formatLong/index.js":"ebaN4","./_lib/formatRelative/index.js":"8mfLL","./_lib/localize/index.js":"iyt9Z","./_lib/match/index.js":"lnGsR","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8spY9":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var formatDistanceLocale = {
lessThanXSeconds: {
one: "less than a second",
other: "less than {{count}} seconds"
},
xSeconds: {
one: "1 second",
other: "{{count}} seconds"
},
halfAMinute: "half a minute",
lessThanXMinutes: {
one: "less than a minute",
other: "less than {{count}} minutes"
},
xMinutes: {
one: "1 minute",
other: "{{count}} minutes"
},
aboutXHours: {
one: "about 1 hour",
other: "about {{count}} hours"
},
xHours: {
one: "1 hour",
other: "{{count}} hours"
},
xDays: {
one: "1 day",
other: "{{count}} days"
},
aboutXWeeks: {
one: "about 1 week",
other: "about {{count}} weeks"
},
xWeeks: {
one: "1 week",
other: "{{count}} weeks"
},
aboutXMonths: {
one: "about 1 month",
other: "about {{count}} months"
},
xMonths: {
one: "1 month",
other: "{{count}} months"
},
aboutXYears: {
one: "about 1 year",
other: "about {{count}} years"
},
xYears: {
one: "1 year",
other: "{{count}} years"
},
overXYears: {
one: "over 1 year",
other: "over {{count}} years"
},
almostXYears: {
one: "almost 1 year",
other: "almost {{count}} years"
}
};
var formatDistance = function formatDistance(token, count, options) {
var result;
var tokenValue = formatDistanceLocale[token];
if (typeof tokenValue === "string") result = tokenValue;
else if (count === 1) result = tokenValue.one;
else result = tokenValue.other.replace("{{count}}", count.toString());
if (options !== null && options !== void 0 && options.addSuffix) {
if (options.comparison && options.comparison > 0) return "in " + result;
else return result + " ago";
}
return result;
};
exports.default = formatDistance;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"ebaN4":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _indexJs = require("../../../_lib/buildFormatLongFn/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var dateFormats = {
full: "EEEE, MMMM do, y",
long: "MMMM do, y",
medium: "MMM d, y",
short: "MM/dd/yyyy"
};
var timeFormats = {
full: "h:mm:ss a zzzz",
long: "h:mm:ss a z",
medium: "h:mm:ss a",
short: "h:mm a"
};
var dateTimeFormats = {
full: "{{date}} 'at' {{time}}",
long: "{{date}} 'at' {{time}}",
medium: "{{date}}, {{time}}",
short: "{{date}}, {{time}}"
};
var formatLong = {
date: (0, _indexJsDefault.default)({
formats: dateFormats,
defaultWidth: "full"
}),
time: (0, _indexJsDefault.default)({
formats: timeFormats,
defaultWidth: "full"
}),
dateTime: (0, _indexJsDefault.default)({
formats: dateTimeFormats,
defaultWidth: "full"
})
};
exports.default = formatLong;
},{"../../../_lib/buildFormatLongFn/index.js":"cKRp8","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"cKRp8":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>buildFormatLongFn);
function buildFormatLongFn(args) {
return function() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// TODO: Remove String()
var width = options.width ? String(options.width) : args.defaultWidth;
var format = args.formats[width] || args.formats[args.defaultWidth];
return format;
};
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8mfLL":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var formatRelativeLocale = {
lastWeek: "'last' eeee 'at' p",
yesterday: "'yesterday at' p",
today: "'today at' p",
tomorrow: "'tomorrow at' p",
nextWeek: "eeee 'at' p",
other: "P"
};
var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
return formatRelativeLocale[token];
};
exports.default = formatRelative;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"iyt9Z":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _indexJs = require("../../../_lib/buildLocalizeFn/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var eraValues = {
narrow: [
"B",
"A"
],
abbreviated: [
"BC",
"AD"
],
wide: [
"Before Christ",
"Anno Domini"
]
};
var quarterValues = {
narrow: [
"1",
"2",
"3",
"4"
],
abbreviated: [
"Q1",
"Q2",
"Q3",
"Q4"
],
wide: [
"1st quarter",
"2nd quarter",
"3rd quarter",
"4th quarter"
]
};
// Note: in English, the names of days of the week and months are capitalized.
// If you are making a new locale based on this one, check if the same is true for the language you're working on.
// Generally, formatted dates should look like they are in the middle of a sentence,
// e.g. in Spanish language the weekdays and months should be in the lowercase.
var monthValues = {
narrow: [
"J",
"F",
"M",
"A",
"M",
"J",
"J",
"A",
"S",
"O",
"N",
"D"
],
abbreviated: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
wide: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
};
var dayValues = {
narrow: [
"S",
"M",
"T",
"W",
"T",
"F",
"S"
],
short: [
"Su",
"Mo",
"Tu",
"We",
"Th",
"Fr",
"Sa"
],
abbreviated: [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
],
wide: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
]
};
var dayPeriodValues = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night"
}
};
var formattingDayPeriodValues = {
narrow: {
am: "a",
pm: "p",
midnight: "mi",
noon: "n",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
abbreviated: {
am: "AM",
pm: "PM",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
},
wide: {
am: "a.m.",
pm: "p.m.",
midnight: "midnight",
noon: "noon",
morning: "in the morning",
afternoon: "in the afternoon",
evening: "in the evening",
night: "at night"
}
};
var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
var number = Number(dirtyNumber);
// If ordinal numbers depend on context, for example,
// if they are different for different grammatical genders,
// use `options.unit`.
//
// `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
// 'day', 'hour', 'minute', 'second'.
var rem100 = number % 100;
if (rem100 > 20 || rem100 < 10) switch(rem100 % 10){
case 1:
return number + "st";
case 2:
return number + "nd";
case 3:
return number + "rd";
}
return number + "th";
};
var localize = {
ordinalNumber: ordinalNumber,
era: (0, _indexJsDefault.default)({
values: eraValues,
defaultWidth: "wide"
}),
quarter: (0, _indexJsDefault.default)({
values: quarterValues,
defaultWidth: "wide",
argumentCallback: function argumentCallback(quarter) {
return quarter - 1;
}
}),
month: (0, _indexJsDefault.default)({
values: monthValues,
defaultWidth: "wide"
}),
day: (0, _indexJsDefault.default)({
values: dayValues,
defaultWidth: "wide"
}),
dayPeriod: (0, _indexJsDefault.default)({
values: dayPeriodValues,
defaultWidth: "wide",
formattingValues: formattingDayPeriodValues,
defaultFormattingWidth: "wide"
})
};
exports.default = localize;
},{"../../../_lib/buildLocalizeFn/index.js":"gMVqJ","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"gMVqJ":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>buildLocalizeFn);
function buildLocalizeFn(args) {
return function(dirtyIndex, options) {
var context = options !== null && options !== void 0 && options.context ? String(options.context) : "standalone";
var valuesArray;
if (context === "formatting" && args.formattingValues) {
var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
} else {
var _defaultWidth = args.defaultWidth;
var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
valuesArray = args.values[_width] || args.values[_defaultWidth];
}
var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
// @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
return valuesArray[index];
};
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"lnGsR":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _indexJs = require("../../../_lib/buildMatchFn/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
var _indexJs1 = require("../../../_lib/buildMatchPatternFn/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs1);
var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
var parseOrdinalNumberPattern = /\d+/i;
var matchEraPatterns = {
narrow: /^(b|a)/i,
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
wide: /^(before christ|before common era|anno domini|common era)/i
};
var parseEraPatterns = {
any: [
/^b/i,
/^(a|c)/i
]
};
var matchQuarterPatterns = {
narrow: /^[1234]/i,
abbreviated: /^q[1234]/i,
wide: /^[1234](th|st|nd|rd)? quarter/i
};
var parseQuarterPatterns = {
any: [
/1/i,
/2/i,
/3/i,
/4/i
]
};
var matchMonthPatterns = {
narrow: /^[jfmasond]/i,
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
};
var parseMonthPatterns = {
narrow: [
/^j/i,
/^f/i,
/^m/i,
/^a/i,
/^m/i,
/^j/i,
/^j/i,
/^a/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
],
any: [
/^ja/i,
/^f/i,
/^mar/i,
/^ap/i,
/^may/i,
/^jun/i,
/^jul/i,
/^au/i,
/^s/i,
/^o/i,
/^n/i,
/^d/i
]
};
var matchDayPatterns = {
narrow: /^[smtwf]/i,
short: /^(su|mo|tu|we|th|fr|sa)/i,
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
};
var parseDayPatterns = {
narrow: [
/^s/i,
/^m/i,
/^t/i,
/^w/i,
/^t/i,
/^f/i,
/^s/i
],
any: [
/^su/i,
/^m/i,
/^tu/i,
/^w/i,
/^th/i,
/^f/i,
/^sa/i
]
};
var matchDayPeriodPatterns = {
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
};
var parseDayPeriodPatterns = {
any: {
am: /^a/i,
pm: /^p/i,
midnight: /^mi/i,
noon: /^no/i,
morning: /morning/i,
afternoon: /afternoon/i,
evening: /evening/i,
night: /night/i
}
};
var match = {
ordinalNumber: (0, _indexJsDefault1.default)({
matchPattern: matchOrdinalNumberPattern,
parsePattern: parseOrdinalNumberPattern,
valueCallback: function valueCallback(value) {
return parseInt(value, 10);
}
}),
era: (0, _indexJsDefault.default)({
matchPatterns: matchEraPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseEraPatterns,
defaultParseWidth: "any"
}),
quarter: (0, _indexJsDefault.default)({
matchPatterns: matchQuarterPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseQuarterPatterns,
defaultParseWidth: "any",
valueCallback: function valueCallback(index) {
return index + 1;
}
}),
month: (0, _indexJsDefault.default)({
matchPatterns: matchMonthPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseMonthPatterns,
defaultParseWidth: "any"
}),
day: (0, _indexJsDefault.default)({
matchPatterns: matchDayPatterns,
defaultMatchWidth: "wide",
parsePatterns: parseDayPatterns,
defaultParseWidth: "any"
}),
dayPeriod: (0, _indexJsDefault.default)({
matchPatterns: matchDayPeriodPatterns,
defaultMatchWidth: "any",
parsePatterns: parseDayPeriodPatterns,
defaultParseWidth: "any"
})
};
exports.default = match;
},{"../../../_lib/buildMatchFn/index.js":"jemd0","../../../_lib/buildMatchPatternFn/index.js":"gwOGE","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"jemd0":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>buildMatchFn);
function buildMatchFn(args) {
return function(string) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var width = options.width;
var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
var matchResult = string.match(matchPattern);
if (!matchResult) return null;
var matchedString = matchResult[0];
var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function(pattern) {
return pattern.test(matchedString);
}) : findKey(parsePatterns, function(pattern) {
return pattern.test(matchedString);
});
var value;
value = args.valueCallback ? args.valueCallback(key) : key;
value = options.valueCallback ? options.valueCallback(value) : value;
var rest = string.slice(matchedString.length);
return {
value: value,
rest: rest
};
};
}
function findKey(object, predicate) {
for(var key in object){
if (object.hasOwnProperty(key) && predicate(object[key])) return key;
}
return undefined;
}
function findIndex(array, predicate) {
for(var key = 0; key < array.length; key++){
if (predicate(array[key])) return key;
}
return undefined;
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"gwOGE":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>buildMatchPatternFn);
function buildMatchPatternFn(args) {
return function(string) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var matchResult = string.match(args.matchPattern);
if (!matchResult) return null;
var matchedString = matchResult[0];
var parseResult = string.match(args.parsePattern);
if (!parseResult) return null;
var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
value = options.valueCallback ? options.valueCallback(value) : value;
var rest = string.slice(matchedString.length);
return {
value: value,
rest: rest
};
};
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"3Ar5s":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>formatDistance);
var _indexJs = require("../_lib/defaultOptions/index.js");
var _indexJs1 = require("../compareAsc/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs1);
var _indexJs2 = require("../differenceInMonths/index.js");
var _indexJsDefault1 = parcelHelpers.interopDefault(_indexJs2);
var _indexJs3 = require("../differenceInSeconds/index.js");
var _indexJsDefault2 = parcelHelpers.interopDefault(_indexJs3);
var _indexJs4 = require("../_lib/defaultLocale/index.js");
var _indexJsDefault3 = parcelHelpers.interopDefault(_indexJs4);
var _indexJs5 = require("../toDate/index.js");
var _indexJsDefault4 = parcelHelpers.interopDefault(_indexJs5);
var _indexJs6 = require("../_lib/cloneObject/index.js");
var _indexJsDefault5 = parcelHelpers.interopDefault(_indexJs6);
var _indexJs7 = require("../_lib/assign/index.js");
var _indexJsDefault6 = parcelHelpers.interopDefault(_indexJs7);
var _indexJs8 = require("../_lib/getTimezoneOffsetInMilliseconds/index.js");
var _indexJsDefault7 = parcelHelpers.interopDefault(_indexJs8);
var _indexJs9 = require("../_lib/requiredArgs/index.js");
var _indexJsDefault8 = parcelHelpers.interopDefault(_indexJs9);
var MINUTES_IN_DAY = 1440;
var MINUTES_IN_ALMOST_TWO_DAYS = 2520;
var MINUTES_IN_MONTH = 43200;
var MINUTES_IN_TWO_MONTHS = 86400;
function formatDistance(dirtyDate, dirtyBaseDate, options) {
var _ref, _options$locale;
(0, _indexJsDefault8.default)(2, arguments);
var defaultOptions = (0, _indexJs.getDefaultOptions)();
var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : (0, _indexJsDefault3.default);
if (!locale.formatDistance) throw new RangeError("locale must contain formatDistance property");
var comparison = (0, _indexJsDefault.default)(dirtyDate, dirtyBaseDate);
if (isNaN(comparison)) throw new RangeError("Invalid time value");
var localizeOptions = (0, _indexJsDefault6.default)((0, _indexJsDefault5.default)(options), {
addSuffix: Boolean(options === null || options === void 0 ? void 0 : options.addSuffix),
comparison: comparison
});
var dateLeft;
var dateRight;
if (comparison > 0) {
dateLeft = (0, _indexJsDefault4.default)(dirtyBaseDate);
dateRight = (0, _indexJsDefault4.default)(dirtyDate);
} else {
dateLeft = (0, _indexJsDefault4.default)(dirtyDate);
dateRight = (0, _indexJsDefault4.default)(dirtyBaseDate);
}
var seconds = (0, _indexJsDefault2.default)(dateRight, dateLeft);
var offsetInSeconds = ((0, _indexJsDefault7.default)(dateRight) - (0, _indexJsDefault7.default)(dateLeft)) / 1000;
var minutes = Math.round((seconds - offsetInSeconds) / 60);
var months;
// 0 up to 2 mins
if (minutes < 2) {
if (options !== null && options !== void 0 && options.includeSeconds) {
if (seconds < 5) return locale.formatDistance("lessThanXSeconds", 5, localizeOptions);
else if (seconds < 10) return locale.formatDistance("lessThanXSeconds", 10, localizeOptions);
else if (seconds < 20) return locale.formatDistance("lessThanXSeconds", 20, localizeOptions);
else if (seconds < 40) return locale.formatDistance("halfAMinute", 0, localizeOptions);
else if (seconds < 60) return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
else return locale.formatDistance("xMinutes", 1, localizeOptions);
} else {
if (minutes === 0) return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
else return locale.formatDistance("xMinutes", minutes, localizeOptions);
}
} else if (minutes < 45) return locale.formatDistance("xMinutes", minutes, localizeOptions);
else if (minutes < 90) return locale.formatDistance("aboutXHours", 1, localizeOptions);
else if (minutes < MINUTES_IN_DAY) {
var hours = Math.round(minutes / 60);
return locale.formatDistance("aboutXHours", hours, localizeOptions);
// 1 day up to 1.75 days
} else if (minutes < MINUTES_IN_ALMOST_TWO_DAYS) return locale.formatDistance("xDays", 1, localizeOptions);
else if (minutes < MINUTES_IN_MONTH) {
var days = Math.round(minutes / MINUTES_IN_DAY);
return locale.formatDistance("xDays", days, localizeOptions);
// 1 month up to 2 months
} else if (minutes < MINUTES_IN_TWO_MONTHS) {
months = Math.round(minutes / MINUTES_IN_MONTH);
return locale.formatDistance("aboutXMonths", months, localizeOptions);
}
months = (0, _indexJsDefault1.default)(dateRight, dateLeft);
// 2 months up to 12 months
if (months < 12) {
var nearestMonth = Math.round(minutes / MINUTES_IN_MONTH);
return locale.formatDistance("xMonths", nearestMonth, localizeOptions);
// 1 year up to max Date
} else {
var monthsSinceStartOfYear = months % 12;
var years = Math.floor(months / 12);
// N years up to 1 years 3 months
if (monthsSinceStartOfYear < 3) return locale.formatDistance("aboutXYears", years, localizeOptions);
else if (monthsSinceStartOfYear < 9) return locale.formatDistance("overXYears", years, localizeOptions);
else return locale.formatDistance("almostXYears", years + 1, localizeOptions);
}
}
},{"../_lib/defaultOptions/index.js":"iBwxJ","../compareAsc/index.js":"k8jty","../differenceInMonths/index.js":"3M6D4","../differenceInSeconds/index.js":"gZFNs","../_lib/defaultLocale/index.js":"1TdkP","../toDate/index.js":"g6izO","../_lib/cloneObject/index.js":"707CS","../_lib/assign/index.js":"l0CUM","../_lib/getTimezoneOffsetInMilliseconds/index.js":"jL4If","../_lib/requiredArgs/index.js":"1toZm","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"707CS":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>cloneObject);
var _indexJs = require("../assign/index.js");
var _indexJsDefault = parcelHelpers.interopDefault(_indexJs);
function cloneObject(object) {
return (0, _indexJsDefault.default)({}, object);
}
},{"../assign/index.js":"l0CUM","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"l0CUM":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "default", ()=>assign);
function assign(target, object) {
if (target == null) throw new TypeError("assign requires that input parameter not be null or undefined");
for(var property in object)if (Object.prototype.hasOwnProperty.call(object, property)) target[property] = object[property];
return target;
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fXWtG":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "ViPreview", ()=>ViPreview);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _idbKeyval = require("idb-keyval");
var _uaParserJs = require("ua-parser-js");
var _uaParserJsDefault = parcelHelpers.interopDefault(_uaParserJs);
var _wasmGzip = require("wasm-gzip");
var _wasmGzipDefault = parcelHelpers.interopDefault(_wasmGzip);
var _webUtils = require("web-utils");
var _general = require("../../utils/types/general");
var _deadend = require("../../utils/ui/deadend");
var _loading = require("../../utils/ui/loading");
var _edGlobal = require("../ed/logic/ed-global");
var _edRoute = require("../ed/logic/ed-route");
var _edSite = require("../ed/logic/ed-site");
var _build = require("../ed/logic/tree/build");
var _extractNav = require("./render/script/extract-nav");
var _vi = require("./vi");
var _load = require("../ed/logic/comp/load");
const decoder = new TextDecoder();
const ViPreview = (arg)=>{
const p = (0, _webUtils.useGlobal)((0, _edGlobal.EDGlobal), "EDITOR");
if (p.site.id) {
if (!p.mode && !!p.site.responsive) {
if (p.site.responsive !== "mobile-only" && p.site.responsive !== "desktop-only") {
const parsed = (0, _uaParserJsDefault.default)();
p.mode = parsed.device.type === "mobile" ? "mobile" : "desktop";
} else if (p.site.responsive === "mobile-only") p.mode = "mobile";
else if (p.site.responsive === "desktop-only") p.mode = "desktop";
}
if (localStorage.getItem("prasi-editor-mode")) p.mode = localStorage.getItem("prasi-editor-mode");
}
(0, _general.w).navigateOverride = (_href)=>{
if (_href && _href.startsWith("/")) {
if ((0, _general.w).basepath.length > 1) _href = `${(0, _general.w).basepath}${_href}`;
if (location.hostname.split(".").length === 4 || location.hostname === "prasi.app" || location.hostname === "prasi.avolut.com" || location.hostname.includes("ngrok") || location.hostname === "localhost" || location.hostname === "127.0.0.1" || location.hostname === "10.0.2.2" // android localhost
) {
if (location.pathname.startsWith("/vi") && !_href.startsWith("/vi")) {
const patharr = location.pathname.split("/");
_href = `/vi/${patharr[2]}${_href}`;
}
}
}
return _href;
};
viRoute(p);
if (p.status !== "ready" && p.status !== "reload") {
if (p.status === "page-not-found") return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _deadend.DeadEnd), {
back: ()=>{
history.back();
},
children: "Page Not Found"
}, void 0, false, {
fileName: "src/nova/vi/preview.tsx",
lineNumber: 72,
columnNumber: 9
}, undefined);
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _loading.Loading), {
note: p.status + "-page"
}, void 0, false, {
fileName: "src/nova/vi/preview.tsx",
lineNumber: 82,
columnNumber: 12
}, undefined);
}
const mode = p.mode;
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: cx("relative flex flex-1 items-center justify-center"),
children: /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: cx("absolute flex flex-col items-stretch flex-1 bg-white main-content-preview", mode === "mobile" ? css`
@media (min-width: 768px) {
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
width: 375px;
top: 0px;
overflow-x: hidden;
overflow-y: auto;
bottom: 0px;
}
@media (max-width: 767px) {
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
overflow-y: auto;
}
` : "inset-0 overflow-auto", css`
contain: content;
`),
children: [
"asdas",
JSON.stringify(mode),
/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _vi.Vi), {
meta: p.page.meta,
mode: p.mode,
api_url: p.site.config.api_url,
site_id: p.site.id,
page_id: p.page.cur.id,
entry: p.page.entry,
api: p.script.api,
db: p.script.db,
comp_load: async (comp_id)=>{
let comp = p.comp.loaded[comp_id];
if (comp) return comp;
await (0, _load.loadComponent)(p, comp_id);
comp = p.comp.loaded[comp_id];
return (0, _webUtils.deepClone)(comp);
},
layout: p.site.layout.id && p.site.layout.meta ? {
id: p.site.layout.id,
meta: p.site.layout.meta,
entry: p.site.layout.entry
} : undefined,
render_stat: "disabled",
script: {
init_local_effect: p.script.init_local_effect
},
on_preload: async ({ urls })=>{
const load_urls = [];
if (p.preview.url_cache) {
for (const url of urls)if (!p.preview.url_cache.has(url)) {
load_urls.push(url);
p.preview.url_cache.add(url);
}
}
if (load_urls.length > 0) {
const res = await p.sync?.page.cache(p.site.id, load_urls, [
...Object.keys(p.preview.page_cache)
]);
if (res) {
const pages = JSON.parse(decoder.decode((0, _wasmGzip.decompress)(res.gzip)) || "{}");
for (const [id, page] of Object.entries(pages)){
p.preview.page_cache[id] = page;
await (0, _build.treeCacheBuild)(p, id);
}
}
}
}
}, void 0, false, {
fileName: "src/nova/vi/preview.tsx",
lineNumber: 120,
columnNumber: 9
}, undefined)
]
}, void 0, true, {
fileName: "src/nova/vi/preview.tsx",
lineNumber: 89,
columnNumber: 7
}, undefined)
}, void 0, false, {
fileName: "src/nova/vi/preview.tsx",
lineNumber: 88,
columnNumber: 5
}, undefined);
};
const preview = {
first_render: true
};
const viRoute = async (p)=>{
if (p.sync && (p.status === "ready" || p.status === "init")) {
if (p.status === "init") await (0, _wasmGzipDefault.default)();
if (!p.site.domain && !p.site.name) {
p.status = "load-site";
const site = await p.sync.site.load(p.site.id);
if (!site) {
p.status = "site-not-found";
p.render();
return;
}
await (0, _edSite.loadSite)(p, site, "from-route");
if (p.site.layout.id) {
if (!p.page.list[p.site.layout.id]) {
const page_cache = await (0, _edRoute.loadPageMetaCache)(p, p.site.layout.id);
if (page_cache) (0, _edRoute.reloadLayout)(p, p.site.layout.id, "load-route");
else await (0, _edRoute.reloadLayout)(p, p.site.layout.id, "load-route");
}
}
}
if (p.page.cur.id !== params.page_id || !p.page.cur.snapshot || !p.page.list[p.page.cur.id]) {
const page = p.page.list[params.page_id];
if (page && p.page.doc && page.on_update) {
p.page.doc.off("update", page.on_update);
const cur = p.page.list[params.page_id];
p.page.cur = cur.page;
p.page.doc = cur.doc;
}
p.script.init_local_effect = {};
if (!(0, _general.w).isEditor) {
if (preview.first_render) preview.first_render = false;
else {
if (p.page.doc) {
let page = p.page.list[params.page_id];
if (!page) {
p.page.list[params.page_id] = {};
page = p.page.list[params.page_id];
}
if (page && page.on_update) {
page.doc.off("update", page.on_update);
page.doc.destroy();
delete p.page.list[params.page_id];
}
}
let page_cache = p.preview.meta_cache[params.page_id];
let should_render = false;
if (!page_cache) {
const idb_cache = await (0, _idbKeyval.get)(`page-${params.page_id}`, (0, _extractNav.nav).store);
if (idb_cache) {
page_cache = idb_cache;
p.preview.meta_cache[params.page_id] = idb_cache;
should_render = true;
}
}
if (page_cache && page_cache.entry.length > 0) {
p.page.meta = page_cache.meta;
p.page.entry = page_cache.entry;
if (p.page.cur.id !== params.page_id) p.page.cur = {
id: params.page_id
};
p.status = "ready";
if (should_render) p.render();
return;
}
}
}
await (0, _edRoute.reloadPage)(p, params.page_id, "load-route");
}
}
};
},{"react/jsx-dev-runtime":"j0wtd","idb-keyval":"in1MU","ua-parser-js":"2Gc8Q","wasm-gzip":"9TduR","web-utils":"aOKw0","../../utils/types/general":"58I9D","../../utils/ui/deadend":"afvN1","../../utils/ui/loading":"jJynm","../ed/logic/ed-global":"5VTke","../ed/logic/ed-route":"fHUp0","../ed/logic/ed-site":"hPnT5","../ed/logic/tree/build":"53DOC","./render/script/extract-nav":"kVlwd","./vi":"5lNHC","../ed/logic/comp/load":"fQ2tn","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"2Gc8Q":[function(require,module,exports) {
/////////////////////////////////////////////////////////////////////////////////
/* UAParser.js v1.0.38
Copyright © 2012-2021 Faisal Salman <f@faisalman.com>
MIT License */ /*
Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
Supports browser & node.js environment.
Demo : https://faisalman.github.io/ua-parser-js
Source : https://github.com/faisalman/ua-parser-js */ /////////////////////////////////////////////////////////////////////////////////
(function(window1, undefined) {
"use strict";
//////////////
// Constants
/////////////
var LIBVERSION = "1.0.38", EMPTY = "", UNKNOWN = "?", FUNC_TYPE = "function", UNDEF_TYPE = "undefined", OBJ_TYPE = "object", STR_TYPE = "string", MAJOR = "major", MODEL = "model", NAME = "name", TYPE = "type", VENDOR = "vendor", VERSION = "version", ARCHITECTURE = "architecture", CONSOLE = "console", MOBILE = "mobile", TABLET = "tablet", SMARTTV = "smarttv", WEARABLE = "wearable", EMBEDDED = "embedded", UA_MAX_LENGTH = 500;
var AMAZON = "Amazon", APPLE = "Apple", ASUS = "ASUS", BLACKBERRY = "BlackBerry", BROWSER = "Browser", CHROME = "Chrome", EDGE = "Edge", FIREFOX = "Firefox", GOOGLE = "Google", HUAWEI = "Huawei", LG = "LG", MICROSOFT = "Microsoft", MOTOROLA = "Motorola", OPERA = "Opera", SAMSUNG = "Samsung", SHARP = "Sharp", SONY = "Sony", XIAOMI = "Xiaomi", ZEBRA = "Zebra", FACEBOOK = "Facebook", CHROMIUM_OS = "Chromium OS", MAC_OS = "Mac OS";
///////////
// Helper
//////////
var extend = function(regexes, extensions) {
var mergedRegexes = {};
for(var i in regexes)if (extensions[i] && extensions[i].length % 2 === 0) mergedRegexes[i] = extensions[i].concat(regexes[i]);
else mergedRegexes[i] = regexes[i];
return mergedRegexes;
}, enumerize = function(arr) {
var enums = {};
for(var i = 0; i < arr.length; i++)enums[arr[i].toUpperCase()] = arr[i];
return enums;
}, has = function(str1, str2) {
return typeof str1 === STR_TYPE ? lowerize(str2).indexOf(lowerize(str1)) !== -1 : false;
}, lowerize = function(str) {
return str.toLowerCase();
}, majorize = function(version) {
return typeof version === STR_TYPE ? version.replace(/[^\d\.]/g, EMPTY).split(".")[0] : undefined;
}, trim = function(str, len) {
if (typeof str === STR_TYPE) {
str = str.replace(/^\s\s*/, EMPTY);
return typeof len === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH);
}
};
///////////////
// Map helper
//////////////
var rgxMapper = function(ua, arrays) {
var i = 0, j, k, p, q, matches, match;
// loop through all regexes maps
while(i < arrays.length && !matches){
var regex = arrays[i], props = arrays[i + 1]; // odd sequence (1,3,5,..)
j = k = 0;
// try matching uastring with regexes
while(j < regex.length && !matches){
if (!regex[j]) break;
matches = regex[j++].exec(ua);
if (!!matches) for(p = 0; p < props.length; p++){
match = matches[++k];
q = props[p];
// check if given property is actually array
if (typeof q === OBJ_TYPE && q.length > 0) {
if (q.length === 2) {
if (typeof q[1] == FUNC_TYPE) // assign modified match
this[q[0]] = q[1].call(this, match);
else // assign given value, ignore regex match
this[q[0]] = q[1];
} else if (q.length === 3) {
// check whether function or regex
if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) // call function (usually string mapper)
this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
else // sanitize match using given regex
this[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
} else if (q.length === 4) this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined;
} else this[q] = match ? match : undefined;
}
}
i += 2;
}
}, strMapper = function(str, map) {
for(var i in map){
// check if current value is array
if (typeof map[i] === OBJ_TYPE && map[i].length > 0) for(var j = 0; j < map[i].length; j++){
if (has(map[i][j], str)) return i === UNKNOWN ? undefined : i;
}
else if (has(map[i], str)) return i === UNKNOWN ? undefined : i;
}
return str;
};
///////////////
// String map
//////////////
// Safari < 3.0
var oldSafariMap = {
"1.0": "/8",
"1.2": "/1",
"1.3": "/3",
"2.0": "/412",
"2.0.2": "/416",
"2.0.3": "/417",
"2.0.4": "/419",
"?": "/"
}, windowsVersionMap = {
"ME": "4.90",
"NT 3.11": "NT3.51",
"NT 4.0": "NT4.0",
"2000": "NT 5.0",
"XP": [
"NT 5.1",
"NT 5.2"
],
"Vista": "NT 6.0",
"7": "NT 6.1",
"8": "NT 6.2",
"8.1": "NT 6.3",
"10": [
"NT 6.4",
"NT 10.0"
],
"RT": "ARM"
};
//////////////
// Regex map
/////////////
var regexes = {
browser: [
[
/\b(?:crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
],
[
VERSION,
[
NAME,
"Chrome"
]
],
[
/edg(?:e|ios|a)?\/([\w\.]+)/i // Microsoft Edge
],
[
VERSION,
[
NAME,
"Edge"
]
],
[
// Presto based
/(opera mini)\/([-\w\.]+)/i,
/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,
/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i // Opera
],
[
NAME,
VERSION
],
[
/opios[\/ ]+([\w\.]+)/i // Opera mini on iphone >= 8.0
],
[
VERSION,
[
NAME,
OPERA + " Mini"
]
],
[
/\bop(?:rg)?x\/([\w\.]+)/i // Opera GX
],
[
VERSION,
[
NAME,
OPERA + " GX"
]
],
[
/\bopr\/([\w\.]+)/i // Opera Webkit
],
[
VERSION,
[
NAME,
OPERA
]
],
[
// Mixed
/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i // Baidu
],
[
VERSION,
[
NAME,
"Baidu"
]
],
[
/(kindle)\/([\w\.]+)/i,
/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,
// Trident based
/(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i,
/(?:ms|\()(ie) ([\w\.]+)/i,
// Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,
// Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ, aka ShouQ
/(heytap|ovi)browser\/([\d\.]+)/i,
/(weibo)__([\d\.]+)/i // Weibo
],
[
NAME,
VERSION
],
[
/\bddg\/([\w\.]+)/i // DuckDuckGo
],
[
VERSION,
[
NAME,
"DuckDuckGo"
]
],
[
/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i // UCBrowser
],
[
VERSION,
[
NAME,
"UC" + BROWSER
]
],
[
/microm.+\bqbcore\/([\w\.]+)/i,
/\bqbcore\/([\w\.]+).+microm/i,
/micromessenger\/([\w\.]+)/i // WeChat
],
[
VERSION,
[
NAME,
"WeChat"
]
],
[
/konqueror\/([\w\.]+)/i // Konqueror
],
[
VERSION,
[
NAME,
"Konqueror"
]
],
[
/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i // IE11
],
[
VERSION,
[
NAME,
"IE"
]
],
[
/ya(?:search)?browser\/([\w\.]+)/i // Yandex
],
[
VERSION,
[
NAME,
"Yandex"
]
],
[
/slbrowser\/([\w\.]+)/i // Smart Lenovo Browser
],
[
VERSION,
[
NAME,
"Smart Lenovo " + BROWSER
]
],
[
/(avast|avg)\/([\w\.]+)/i // Avast/AVG Secure Browser
],
[
[
NAME,
/(.+)/,
"$1 Secure " + BROWSER
],
VERSION
],
[
/\bfocus\/([\w\.]+)/i // Firefox Focus
],
[
VERSION,
[
NAME,
FIREFOX + " Focus"
]
],
[
/\bopt\/([\w\.]+)/i // Opera Touch
],
[
VERSION,
[
NAME,
OPERA + " Touch"
]
],
[
/coc_coc\w+\/([\w\.]+)/i // Coc Coc Browser
],
[
VERSION,
[
NAME,
"Coc Coc"
]
],
[
/dolfin\/([\w\.]+)/i // Dolphin
],
[
VERSION,
[
NAME,
"Dolphin"
]
],
[
/coast\/([\w\.]+)/i // Opera Coast
],
[
VERSION,
[
NAME,
OPERA + " Coast"
]
],
[
/miuibrowser\/([\w\.]+)/i // MIUI Browser
],
[
VERSION,
[
NAME,
"MIUI " + BROWSER
]
],
[
/fxios\/([-\w\.]+)/i // Firefox for iOS
],
[
VERSION,
[
NAME,
FIREFOX
]
],
[
/\bqihu|(qi?ho?o?|360)browser/i // 360
],
[
[
NAME,
"360 " + BROWSER
]
],
[
/(oculus|sailfish|huawei|vivo)browser\/([\w\.]+)/i
],
[
[
NAME,
/(.+)/,
"$1 " + BROWSER
],
VERSION
],
[
/samsungbrowser\/([\w\.]+)/i // Samsung Internet
],
[
VERSION,
[
NAME,
SAMSUNG + " Internet"
]
],
[
/(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
],
[
[
NAME,
/_/g,
" "
],
VERSION
],
[
/metasr[\/ ]?([\d\.]+)/i // Sogou Explorer
],
[
VERSION,
[
NAME,
"Sogou Explorer"
]
],
[
/(sogou)mo\w+\/([\d\.]+)/i // Sogou Mobile
],
[
[
NAME,
"Sogou Mobile"
],
VERSION
],
[
/(electron)\/([\w\.]+) safari/i,
/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,
/m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i // QQBrowser/2345 Browser
],
[
NAME,
VERSION
],
[
/(lbbrowser)/i,
/\[(linkedin)app\]/i // LinkedIn App for iOS & Android
],
[
NAME
],
[
// WebView
/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i // Facebook App for iOS & Android
],
[
[
NAME,
FACEBOOK
],
VERSION
],
[
/(Klarna)\/([\w\.]+)/i,
/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,
/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,
/safari (line)\/([\w\.]+)/i,
/\b(line)\/([\w\.]+)\/iab/i,
/(alipay)client\/([\w\.]+)/i,
/(twitter)(?:and| f.+e\/([\w\.]+))/i,
/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i // Chromium/Instagram/Snapchat
],
[
NAME,
VERSION
],
[
/\bgsa\/([\w\.]+) .*safari\//i // Google Search Appliance on iOS
],
[
VERSION,
[
NAME,
"GSA"
]
],
[
/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i // TikTok
],
[
VERSION,
[
NAME,
"TikTok"
]
],
[
/headlesschrome(?:\/([\w\.]+)| )/i // Chrome Headless
],
[
VERSION,
[
NAME,
CHROME + " Headless"
]
],
[
/ wv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
],
[
[
NAME,
CHROME + " WebView"
],
VERSION
],
[
/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i // Android Browser
],
[
VERSION,
[
NAME,
"Android " + BROWSER
]
],
[
/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i // Chrome/OmniWeb/Arora/Tizen/Nokia
],
[
NAME,
VERSION
],
[
/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i // Mobile Safari
],
[
VERSION,
[
NAME,
"Mobile Safari"
]
],
[
/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i // Safari & Safari Mobile
],
[
VERSION,
NAME
],
[
/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
],
[
NAME,
[
VERSION,
strMapper,
oldSafariMap
]
],
[
/(webkit|khtml)\/([\w\.]+)/i
],
[
NAME,
VERSION
],
[
// Gecko based
/(navigator|netscape\d?)\/([-\w\.]+)/i // Netscape
],
[
[
NAME,
"Netscape"
],
VERSION
],
[
/mobile vr; rv:([\w\.]+)\).+firefox/i // Firefox Reality
],
[
VERSION,
[
NAME,
FIREFOX + " Reality"
]
],
[
/ekiohf.+(flow)\/([\w\.]+)/i,
/(swiftfox)/i,
/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,
// IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror/Klar
/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
/(firefox)\/([\w\.]+)/i,
/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,
// Other
/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,
// Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir/Obigo/Mosaic/Go/ICE/UP.Browser
/(links) \(([\w\.]+)/i,
/panasonic;(viera)/i // Panasonic Viera
],
[
NAME,
VERSION
],
[
/(cobalt)\/([\w\.]+)/i // Cobalt
],
[
NAME,
[
VERSION,
/master.|lts./,
""
]
]
],
cpu: [
[
/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i // AMD64 (x64)
],
[
[
ARCHITECTURE,
"amd64"
]
],
[
/(ia32(?=;))/i // IA32 (quicktime)
],
[
[
ARCHITECTURE,
lowerize
]
],
[
/((?:i[346]|x)86)[;\)]/i // IA32 (x86)
],
[
[
ARCHITECTURE,
"ia32"
]
],
[
/\b(aarch64|arm(v?8e?l?|_?64))\b/i // ARM64
],
[
[
ARCHITECTURE,
"arm64"
]
],
[
/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i // ARMHF
],
[
[
ARCHITECTURE,
"armhf"
]
],
[
// PocketPC mistakenly identified as PowerPC
/windows (ce|mobile); ppc;/i
],
[
[
ARCHITECTURE,
"arm"
]
],
[
/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i // PowerPC
],
[
[
ARCHITECTURE,
/ower/,
EMPTY,
lowerize
]
],
[
/(sun4\w)[;\)]/i // SPARC
],
[
[
ARCHITECTURE,
"sparc"
]
],
[
/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i
],
[
[
ARCHITECTURE,
lowerize
]
]
],
device: [
[
//////////////////////////
// MOBILES & TABLETS
/////////////////////////
// Samsung
/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i
],
[
MODEL,
[
VENDOR,
SAMSUNG
],
[
TYPE,
TABLET
]
],
[
/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,
/samsung[- ]([-\w]+)/i,
/sec-(sgh\w+)/i
],
[
MODEL,
[
VENDOR,
SAMSUNG
],
[
TYPE,
MOBILE
]
],
[
// Apple
/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i // iPod/iPhone
],
[
MODEL,
[
VENDOR,
APPLE
],
[
TYPE,
MOBILE
]
],
[
/\((ipad);[-\w\),; ]+apple/i,
/applecoremedia\/[\w\.]+ \((ipad)/i,
/\b(ipad)\d\d?,\d\d?[;\]].+ios/i
],
[
MODEL,
[
VENDOR,
APPLE
],
[
TYPE,
TABLET
]
],
[
/(macintosh);/i
],
[
MODEL,
[
VENDOR,
APPLE
]
],
[
// Sharp
/\b(sh-?[altvz]?\d\d[a-ekm]?)/i
],
[
MODEL,
[
VENDOR,
SHARP
],
[
TYPE,
MOBILE
]
],
[
// Huawei
/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
],
[
MODEL,
[
VENDOR,
HUAWEI
],
[
TYPE,
TABLET
]
],
[
/(?:huawei|honor)([-\w ]+)[;\)]/i,
/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i
],
[
MODEL,
[
VENDOR,
HUAWEI
],
[
TYPE,
MOBILE
]
],
[
// Xiaomi
/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,
/\b; (\w+) build\/hm\1/i,
/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,
/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,
/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,
/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i // Xiaomi Mi
],
[
[
MODEL,
/_/g,
" "
],
[
VENDOR,
XIAOMI
],
[
TYPE,
MOBILE
]
],
[
/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,
/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i // Mi Pad tablets
],
[
[
MODEL,
/_/g,
" "
],
[
VENDOR,
XIAOMI
],
[
TYPE,
TABLET
]
],
[
// OPPO
/; (\w+) bui.+ oppo/i,
/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i
],
[
MODEL,
[
VENDOR,
"OPPO"
],
[
TYPE,
MOBILE
]
],
[
/\b(opd2\d{3}a?) bui/i
],
[
MODEL,
[
VENDOR,
"OPPO"
],
[
TYPE,
TABLET
]
],
[
// Vivo
/vivo (\w+)(?: bui|\))/i,
/\b(v[12]\d{3}\w?[at])(?: bui|;)/i
],
[
MODEL,
[
VENDOR,
"Vivo"
],
[
TYPE,
MOBILE
]
],
[
// Realme
/\b(rmx[1-3]\d{3})(?: bui|;|\))/i
],
[
MODEL,
[
VENDOR,
"Realme"
],
[
TYPE,
MOBILE
]
],
[
// Motorola
/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,
/\bmot(?:orola)?[- ](\w*)/i,
/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i
],
[
MODEL,
[
VENDOR,
MOTOROLA
],
[
TYPE,
MOBILE
]
],
[
/\b(mz60\d|xoom[2 ]{0,2}) build\//i
],
[
MODEL,
[
VENDOR,
MOTOROLA
],
[
TYPE,
TABLET
]
],
[
// LG
/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i
],
[
MODEL,
[
VENDOR,
LG
],
[
TYPE,
TABLET
]
],
[
/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,
/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,
/\blg-?([\d\w]+) bui/i
],
[
MODEL,
[
VENDOR,
LG
],
[
TYPE,
MOBILE
]
],
[
// Lenovo
/(ideatab[-\w ]+)/i,
/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i
],
[
MODEL,
[
VENDOR,
"Lenovo"
],
[
TYPE,
TABLET
]
],
[
// Nokia
/(?:maemo|nokia).*(n900|lumia \d+)/i,
/nokia[-_ ]?([-\w\.]*)/i
],
[
[
MODEL,
/_/g,
" "
],
[
VENDOR,
"Nokia"
],
[
TYPE,
MOBILE
]
],
[
// Google
/(pixel c)\b/i // Google Pixel C
],
[
MODEL,
[
VENDOR,
GOOGLE
],
[
TYPE,
TABLET
]
],
[
/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i // Google Pixel
],
[
MODEL,
[
VENDOR,
GOOGLE
],
[
TYPE,
MOBILE
]
],
[
// Sony
/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i
],
[
MODEL,
[
VENDOR,
SONY
],
[
TYPE,
MOBILE
]
],
[
/sony tablet [ps]/i,
/\b(?:sony)?sgp\w+(?: bui|\))/i
],
[
[
MODEL,
"Xperia Tablet"
],
[
VENDOR,
SONY
],
[
TYPE,
TABLET
]
],
[
// OnePlus
/ (kb2005|in20[12]5|be20[12][59])\b/i,
/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i
],
[
MODEL,
[
VENDOR,
"OnePlus"
],
[
TYPE,
MOBILE
]
],
[
// Amazon
/(alexa)webm/i,
/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,
/(kf[a-z]+)( bui|\)).+silk\//i // Kindle Fire HD
],
[
MODEL,
[
VENDOR,
AMAZON
],
[
TYPE,
TABLET
]
],
[
/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i // Fire Phone
],
[
[
MODEL,
/(.+)/g,
"Fire Phone $1"
],
[
VENDOR,
AMAZON
],
[
TYPE,
MOBILE
]
],
[
// BlackBerry
/(playbook);[-\w\),; ]+(rim)/i // BlackBerry PlayBook
],
[
MODEL,
VENDOR,
[
TYPE,
TABLET
]
],
[
/\b((?:bb[a-f]|st[hv])100-\d)/i,
/\(bb10; (\w+)/i // BlackBerry 10
],
[
MODEL,
[
VENDOR,
BLACKBERRY
],
[
TYPE,
MOBILE
]
],
[
// Asus
/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i
],
[
MODEL,
[
VENDOR,
ASUS
],
[
TYPE,
TABLET
]
],
[
/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i
],
[
MODEL,
[
VENDOR,
ASUS
],
[
TYPE,
MOBILE
]
],
[
// HTC
/(nexus 9)/i // HTC Nexus 9
],
[
MODEL,
[
VENDOR,
"HTC"
],
[
TYPE,
TABLET
]
],
[
/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,
// ZTE
/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
],
[
VENDOR,
[
MODEL,
/_/g,
" "
],
[
TYPE,
MOBILE
]
],
[
// Acer
/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i
],
[
MODEL,
[
VENDOR,
"Acer"
],
[
TYPE,
TABLET
]
],
[
// Meizu
/droid.+; (m[1-5] note) bui/i,
/\bmz-([-\w]{2,})/i
],
[
MODEL,
[
VENDOR,
"Meizu"
],
[
TYPE,
MOBILE
]
],
[
// Ulefone
/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i
],
[
MODEL,
[
VENDOR,
"Ulefone"
],
[
TYPE,
MOBILE
]
],
[
// MIXED
/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,
// BlackBerry/BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
/(hp) ([\w ]+\w)/i,
/(asus)-?(\w+)/i,
/(microsoft); (lumia[\w ]+)/i,
/(lenovo)[-_ ]?([-\w]+)/i,
/(jolla)/i,
/(oppo) ?([\w ]+) bui/i // OPPO
],
[
VENDOR,
MODEL,
[
TYPE,
MOBILE
]
],
[
/(kobo)\s(ereader|touch)/i,
/(archos) (gamepad2?)/i,
/(hp).+(touchpad(?!.+tablet)|tablet)/i,
/(kindle)\/([\w\.]+)/i,
/(nook)[\w ]+build\/(\w+)/i,
/(dell) (strea[kpr\d ]*[\dko])/i,
/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,
/(trinity)[- ]*(t\d{3}) bui/i,
/(gigaset)[- ]+(q\w{1,9}) bui/i,
/(vodafone) ([\w ]+)(?:\)| bui)/i // Vodafone
],
[
VENDOR,
MODEL,
[
TYPE,
TABLET
]
],
[
/(surface duo)/i // Surface Duo
],
[
MODEL,
[
VENDOR,
MICROSOFT
],
[
TYPE,
TABLET
]
],
[
/droid [\d\.]+; (fp\du?)(?: b|\))/i // Fairphone
],
[
MODEL,
[
VENDOR,
"Fairphone"
],
[
TYPE,
MOBILE
]
],
[
/(u304aa)/i // AT&T
],
[
MODEL,
[
VENDOR,
"AT&T"
],
[
TYPE,
MOBILE
]
],
[
/\bsie-(\w*)/i // Siemens
],
[
MODEL,
[
VENDOR,
"Siemens"
],
[
TYPE,
MOBILE
]
],
[
/\b(rct\w+) b/i // RCA Tablets
],
[
MODEL,
[
VENDOR,
"RCA"
],
[
TYPE,
TABLET
]
],
[
/\b(venue[\d ]{2,7}) b/i // Dell Venue Tablets
],
[
MODEL,
[
VENDOR,
"Dell"
],
[
TYPE,
TABLET
]
],
[
/\b(q(?:mv|ta)\w+) b/i // Verizon Tablet
],
[
MODEL,
[
VENDOR,
"Verizon"
],
[
TYPE,
TABLET
]
],
[
/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i // Barnes & Noble Tablet
],
[
MODEL,
[
VENDOR,
"Barnes & Noble"
],
[
TYPE,
TABLET
]
],
[
/\b(tm\d{3}\w+) b/i
],
[
MODEL,
[
VENDOR,
"NuVision"
],
[
TYPE,
TABLET
]
],
[
/\b(k88) b/i // ZTE K Series Tablet
],
[
MODEL,
[
VENDOR,
"ZTE"
],
[
TYPE,
TABLET
]
],
[
/\b(nx\d{3}j) b/i // ZTE Nubia
],
[
MODEL,
[
VENDOR,
"ZTE"
],
[
TYPE,
MOBILE
]
],
[
/\b(gen\d{3}) b.+49h/i // Swiss GEN Mobile
],
[
MODEL,
[
VENDOR,
"Swiss"
],
[
TYPE,
MOBILE
]
],
[
/\b(zur\d{3}) b/i // Swiss ZUR Tablet
],
[
MODEL,
[
VENDOR,
"Swiss"
],
[
TYPE,
TABLET
]
],
[
/\b((zeki)?tb.*\b) b/i // Zeki Tablets
],
[
MODEL,
[
VENDOR,
"Zeki"
],
[
TYPE,
TABLET
]
],
[
/\b([yr]\d{2}) b/i,
/\b(dragon[- ]+touch |dt)(\w{5}) b/i // Dragon Touch Tablet
],
[
[
VENDOR,
"Dragon Touch"
],
MODEL,
[
TYPE,
TABLET
]
],
[
/\b(ns-?\w{0,9}) b/i // Insignia Tablets
],
[
MODEL,
[
VENDOR,
"Insignia"
],
[
TYPE,
TABLET
]
],
[
/\b((nxa|next)-?\w{0,9}) b/i // NextBook Tablets
],
[
MODEL,
[
VENDOR,
"NextBook"
],
[
TYPE,
TABLET
]
],
[
/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i // Voice Xtreme Phones
],
[
[
VENDOR,
"Voice"
],
MODEL,
[
TYPE,
MOBILE
]
],
[
/\b(lvtel\-)?(v1[12]) b/i // LvTel Phones
],
[
[
VENDOR,
"LvTel"
],
MODEL,
[
TYPE,
MOBILE
]
],
[
/\b(ph-1) /i // Essential PH-1
],
[
MODEL,
[
VENDOR,
"Essential"
],
[
TYPE,
MOBILE
]
],
[
/\b(v(100md|700na|7011|917g).*\b) b/i // Envizen Tablets
],
[
MODEL,
[
VENDOR,
"Envizen"
],
[
TYPE,
TABLET
]
],
[
/\b(trio[-\w\. ]+) b/i // MachSpeed Tablets
],
[
MODEL,
[
VENDOR,
"MachSpeed"
],
[
TYPE,
TABLET
]
],
[
/\btu_(1491) b/i // Rotor Tablets
],
[
MODEL,
[
VENDOR,
"Rotor"
],
[
TYPE,
TABLET
]
],
[
/(shield[\w ]+) b/i // Nvidia Shield Tablets
],
[
MODEL,
[
VENDOR,
"Nvidia"
],
[
TYPE,
TABLET
]
],
[
/(sprint) (\w+)/i // Sprint Phones
],
[
VENDOR,
MODEL,
[
TYPE,
MOBILE
]
],
[
/(kin\.[onetw]{3})/i // Microsoft Kin
],
[
[
MODEL,
/\./g,
" "
],
[
VENDOR,
MICROSOFT
],
[
TYPE,
MOBILE
]
],
[
/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i // Zebra
],
[
MODEL,
[
VENDOR,
ZEBRA
],
[
TYPE,
TABLET
]
],
[
/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i
],
[
MODEL,
[
VENDOR,
ZEBRA
],
[
TYPE,
MOBILE
]
],
[
///////////////////
// SMARTTVS
///////////////////
/smart-tv.+(samsung)/i // Samsung
],
[
VENDOR,
[
TYPE,
SMARTTV
]
],
[
/hbbtv.+maple;(\d+)/i
],
[
[
MODEL,
/^/,
"SmartTV"
],
[
VENDOR,
SAMSUNG
],
[
TYPE,
SMARTTV
]
],
[
/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
],
[
[
VENDOR,
LG
],
[
TYPE,
SMARTTV
]
],
[
/(apple) ?tv/i // Apple TV
],
[
VENDOR,
[
MODEL,
APPLE + " TV"
],
[
TYPE,
SMARTTV
]
],
[
/crkey/i // Google Chromecast
],
[
[
MODEL,
CHROME + "cast"
],
[
VENDOR,
GOOGLE
],
[
TYPE,
SMARTTV
]
],
[
/droid.+aft(\w+)( bui|\))/i // Fire TV
],
[
MODEL,
[
VENDOR,
AMAZON
],
[
TYPE,
SMARTTV
]
],
[
/\(dtv[\);].+(aquos)/i,
/(aquos-tv[\w ]+)\)/i // Sharp
],
[
MODEL,
[
VENDOR,
SHARP
],
[
TYPE,
SMARTTV
]
],
[
/(bravia[\w ]+)( bui|\))/i // Sony
],
[
MODEL,
[
VENDOR,
SONY
],
[
TYPE,
SMARTTV
]
],
[
/(mitv-\w{5}) bui/i // Xiaomi
],
[
MODEL,
[
VENDOR,
XIAOMI
],
[
TYPE,
SMARTTV
]
],
[
/Hbbtv.*(technisat) (.*);/i // TechniSAT
],
[
VENDOR,
MODEL,
[
TYPE,
SMARTTV
]
],
[
/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,
/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i // HbbTV devices
],
[
[
VENDOR,
trim
],
[
MODEL,
trim
],
[
TYPE,
SMARTTV
]
],
[
/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
],
[
[
TYPE,
SMARTTV
]
],
[
///////////////////
// CONSOLES
///////////////////
/(ouya)/i,
/(nintendo) ([wids3utch]+)/i // Nintendo
],
[
VENDOR,
MODEL,
[
TYPE,
CONSOLE
]
],
[
/droid.+; (shield) bui/i // Nvidia
],
[
MODEL,
[
VENDOR,
"Nvidia"
],
[
TYPE,
CONSOLE
]
],
[
/(playstation [345portablevi]+)/i // Playstation
],
[
MODEL,
[
VENDOR,
SONY
],
[
TYPE,
CONSOLE
]
],
[
/\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
],
[
MODEL,
[
VENDOR,
MICROSOFT
],
[
TYPE,
CONSOLE
]
],
[
///////////////////
// WEARABLES
///////////////////
/((pebble))app/i // Pebble
],
[
VENDOR,
MODEL,
[
TYPE,
WEARABLE
]
],
[
/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i // Apple Watch
],
[
MODEL,
[
VENDOR,
APPLE
],
[
TYPE,
WEARABLE
]
],
[
/droid.+; (glass) \d/i // Google Glass
],
[
MODEL,
[
VENDOR,
GOOGLE
],
[
TYPE,
WEARABLE
]
],
[
/droid.+; (wt63?0{2,3})\)/i
],
[
MODEL,
[
VENDOR,
ZEBRA
],
[
TYPE,
WEARABLE
]
],
[
/(quest( \d| pro)?)/i // Oculus Quest
],
[
MODEL,
[
VENDOR,
FACEBOOK
],
[
TYPE,
WEARABLE
]
],
[
///////////////////
// EMBEDDED
///////////////////
/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i // Tesla
],
[
VENDOR,
[
TYPE,
EMBEDDED
]
],
[
/(aeobc)\b/i // Echo Dot
],
[
MODEL,
[
VENDOR,
AMAZON
],
[
TYPE,
EMBEDDED
]
],
[
////////////////////
// MIXED (GENERIC)
///////////////////
/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i // Android Phones from Unidentified Vendors
],
[
MODEL,
[
TYPE,
MOBILE
]
],
[
/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i // Android Tablets from Unidentified Vendors
],
[
MODEL,
[
TYPE,
TABLET
]
],
[
/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i // Unidentifiable Tablet
],
[
[
TYPE,
TABLET
]
],
[
/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i // Unidentifiable Mobile
],
[
[
TYPE,
MOBILE
]
],
[
/(android[-\w\. ]{0,9});.+buil/i // Generic Android Device
],
[
MODEL,
[
VENDOR,
"Generic"
]
]
],
engine: [
[
/windows.+ edge\/([\w\.]+)/i // EdgeHTML
],
[
VERSION,
[
NAME,
EDGE + "HTML"
]
],
[
/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i // Blink
],
[
VERSION,
[
NAME,
"Blink"
]
],
[
/(presto)\/([\w\.]+)/i,
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,
/ekioh(flow)\/([\w\.]+)/i,
/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,
/(icab)[\/ ]([23]\.[\d\.]+)/i,
/\b(libweb)/i
],
[
NAME,
VERSION
],
[
/rv\:([\w\.]{1,9})\b.+(gecko)/i // Gecko
],
[
VERSION,
NAME
]
],
os: [
[
// Windows
/microsoft (windows) (vista|xp)/i // Windows (iTunes)
],
[
NAME,
VERSION
],
[
/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i // Windows Phone
],
[
NAME,
[
VERSION,
strMapper,
windowsVersionMap
]
],
[
/windows nt 6\.2; (arm)/i,
/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,
/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i
],
[
[
VERSION,
strMapper,
windowsVersionMap
],
[
NAME,
"Windows"
]
],
[
// iOS/macOS
/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,
/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,
/cfnetwork\/.+darwin/i
],
[
[
VERSION,
/_/g,
"."
],
[
NAME,
"iOS"
]
],
[
/(mac os x) ?([\w\. ]*)/i,
/(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
],
[
[
NAME,
MAC_OS
],
[
VERSION,
/_/g,
"."
]
],
[
// Mobile OSes
/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
],
[
VERSION,
NAME
],
[
/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,
/(blackberry)\w*\/([\w\.]*)/i,
/(tizen|kaios)[\/ ]([\w\.]+)/i,
/\((series40);/i // Series 40
],
[
NAME,
VERSION
],
[
/\(bb(10);/i // BlackBerry 10
],
[
VERSION,
[
NAME,
BLACKBERRY
]
],
[
/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i // Symbian
],
[
VERSION,
[
NAME,
"Symbian"
]
],
[
/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i // Firefox OS
],
[
VERSION,
[
NAME,
FIREFOX + " OS"
]
],
[
/web0s;.+rt(tv)/i,
/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i // WebOS
],
[
VERSION,
[
NAME,
"webOS"
]
],
[
/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i // watchOS
],
[
VERSION,
[
NAME,
"watchOS"
]
],
[
// Google Chromecast
/crkey\/([\d\.]+)/i // Google Chromecast
],
[
VERSION,
[
NAME,
CHROME + "cast"
]
],
[
/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS
],
[
[
NAME,
CHROMIUM_OS
],
VERSION
],
[
// Smart TVs
/panasonic;(viera)/i,
/(netrange)mmh/i,
/(nettv)\/(\d+\.[\w\.]+)/i,
// Console
/(nintendo|playstation) ([wids345portablevuch]+)/i,
/(xbox); +xbox ([^\);]+)/i,
// Other
/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,
/(mint)[\/\(\) ]?(\w*)/i,
/(mageia|vectorlinux)[; ]/i,
/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,
// Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware/Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus/Raspbian/Plan9/Minix/RISCOS/Contiki/Deepin/Manjaro/elementary/Sabayon/Linspire
/(hurd|linux) ?([\w\.]*)/i,
/(gnu) ?([\w\.]*)/i,
/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,
/(haiku) (\w+)/i // Haiku
],
[
NAME,
VERSION
],
[
/(sunos) ?([\w\.\d]*)/i // Solaris
],
[
[
NAME,
"Solaris"
],
VERSION
],
[
/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,
/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,
/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,
/(unix) ?([\w\.]*)/i // UNIX
],
[
NAME,
VERSION
]
]
};
/////////////////
// Constructor
////////////////
var UAParser = function(ua, extensions) {
if (typeof ua === OBJ_TYPE) {
extensions = ua;
ua = undefined;
}
if (!(this instanceof UAParser)) return new UAParser(ua, extensions).getResult();
var _navigator = typeof window1 !== UNDEF_TYPE && window1.navigator ? window1.navigator : undefined;
var _ua = ua || (_navigator && _navigator.userAgent ? _navigator.userAgent : EMPTY);
var _uach = _navigator && _navigator.userAgentData ? _navigator.userAgentData : undefined;
var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
var _isSelfNav = _navigator && _navigator.userAgent == _ua;
this.getBrowser = function() {
var _browser = {};
_browser[NAME] = undefined;
_browser[VERSION] = undefined;
rgxMapper.call(_browser, _ua, _rgxmap.browser);
_browser[MAJOR] = majorize(_browser[VERSION]);
// Brave-specific detection
if (_isSelfNav && _navigator && _navigator.brave && typeof _navigator.brave.isBrave == FUNC_TYPE) _browser[NAME] = "Brave";
return _browser;
};
this.getCPU = function() {
var _cpu = {};
_cpu[ARCHITECTURE] = undefined;
rgxMapper.call(_cpu, _ua, _rgxmap.cpu);
return _cpu;
};
this.getDevice = function() {
var _device = {};
_device[VENDOR] = undefined;
_device[MODEL] = undefined;
_device[TYPE] = undefined;
rgxMapper.call(_device, _ua, _rgxmap.device);
if (_isSelfNav && !_device[TYPE] && _uach && _uach.mobile) _device[TYPE] = MOBILE;
// iPadOS-specific detection: identified as Mac, but has some iOS-only properties
if (_isSelfNav && _device[MODEL] == "Macintosh" && _navigator && typeof _navigator.standalone !== UNDEF_TYPE && _navigator.maxTouchPoints && _navigator.maxTouchPoints > 2) {
_device[MODEL] = "iPad";
_device[TYPE] = TABLET;
}
return _device;
};
this.getEngine = function() {
var _engine = {};
_engine[NAME] = undefined;
_engine[VERSION] = undefined;
rgxMapper.call(_engine, _ua, _rgxmap.engine);
return _engine;
};
this.getOS = function() {
var _os = {};
_os[NAME] = undefined;
_os[VERSION] = undefined;
rgxMapper.call(_os, _ua, _rgxmap.os);
if (_isSelfNav && !_os[NAME] && _uach && _uach.platform && _uach.platform != "Unknown") _os[NAME] = _uach.platform.replace(/chrome os/i, CHROMIUM_OS).replace(/macos/i, MAC_OS); // backward compatibility
return _os;
};
this.getResult = function() {
return {
ua: this.getUA(),
browser: this.getBrowser(),
engine: this.getEngine(),
os: this.getOS(),
device: this.getDevice(),
cpu: this.getCPU()
};
};
this.getUA = function() {
return _ua;
};
this.setUA = function(ua) {
_ua = typeof ua === STR_TYPE && ua.length > UA_MAX_LENGTH ? trim(ua, UA_MAX_LENGTH) : ua;
return this;
};
this.setUA(_ua);
return this;
};
UAParser.VERSION = LIBVERSION;
UAParser.BROWSER = enumerize([
NAME,
VERSION,
MAJOR
]);
UAParser.CPU = enumerize([
ARCHITECTURE
]);
UAParser.DEVICE = enumerize([
MODEL,
VENDOR,
TYPE,
CONSOLE,
MOBILE,
SMARTTV,
TABLET,
WEARABLE,
EMBEDDED
]);
UAParser.ENGINE = UAParser.OS = enumerize([
NAME,
VERSION
]);
///////////
// Export
//////////
// check js environment
if (typeof exports !== UNDEF_TYPE) {
// nodejs env
if ("object" !== UNDEF_TYPE && module.exports) exports = module.exports = UAParser;
exports.UAParser = UAParser;
} else {
// requirejs env (optional)
if (typeof define === FUNC_TYPE && define.amd) define(function() {
return UAParser;
});
else if (typeof window1 !== UNDEF_TYPE) // browser env
window1.UAParser = UAParser;
}
// jQuery/Zepto specific (optional)
// Note:
// In AMD env the global scope should be kept clean, but jQuery is an exception.
// jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
// and we should catch that.
var $ = typeof window1 !== UNDEF_TYPE && (window1.jQuery || window1.Zepto);
if ($ && !$.ua) {
var parser = new UAParser();
$.ua = parser.getResult();
$.ua.get = function() {
return parser.getUA();
};
$.ua.set = function(ua) {
parser.setUA(ua);
var result = parser.getResult();
for(var prop in result)$.ua[prop] = result[prop];
};
}
})(typeof window === "object" ? window : this);
},{}],"afvN1":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "DeadEnd", ()=>DeadEnd);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
const w = window;
const DeadEnd = ({ children, back })=>{
if (w.ContentNotFound) return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)(w.ContentNotFound, {}, void 0, false, {
fileName: "src/utils/ui/deadend.tsx",
lineNumber: 10,
columnNumber: 12
}, undefined);
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: "flex items-center justify-center w-full h-full fixed inset-0 flex-col",
children: [
/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
children: children
}, void 0, false, {
fileName: "src/utils/ui/deadend.tsx",
lineNumber: 15,
columnNumber: 7
}, undefined),
/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: "border mt-2 rounded-md p-2 cursor-pointer",
onClick: back ? back : ()=>{
history.back();
},
children: [
" ",
"Go Back"
]
}, void 0, true, {
fileName: "src/utils/ui/deadend.tsx",
lineNumber: 16,
columnNumber: 7
}, undefined)
]
}, void 0, true, {
fileName: "src/utils/ui/deadend.tsx",
lineNumber: 14,
columnNumber: 5
}, undefined);
};
},{"react/jsx-dev-runtime":"j0wtd","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"5lNHC":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "Vi", ()=>Vi);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _react = require("react");
var _webUtils = require("web-utils");
var _load = require("./load/load");
var _global = require("./render/global");
var _render = require("./render/render");
var _root = require("./root");
var _errorBox = require("./utils/error-box");
const w = window;
if (!w.prasi_internal) w.prasi_internal = {
page: {
id: ""
}
};
const Vi = ({ meta, entry, api_url, site_id, api, mode, db, visit, script, preloaded, page_id, render_stat: rs, on_status_changed, on_preload, layout, comp_load })=>{
const vi = (0, _webUtils.useGlobal)((0, _global.ViGlobal), "VI");
vi.mode = mode;
vi.entry = entry;
vi.on_preload = on_preload;
vi.comp.load = comp_load;
if (page_id) w.prasi_internal.page.id = page_id;
w.siteurl = (pathname, forceOriginal)=>{
if (pathname.startsWith("http://") || pathname.startsWith("https://")) return pathname;
try {
if ([
"prasi.avolut.com"
].includes(location.hostname) || location.port === "4550") {
if (vi.site.api_url) {
if (!vi.site_url) vi.site_url = new URL(vi.site.api_url);
}
} else if (!vi.site_url) {
if (forceOriginal && vi.site.api_url) vi.site_url = new URL(vi.site.api_url);
else vi.site_url = new URL(location.href);
vi.site_url.pathname = "";
}
} catch (e) {}
if (vi.site_url) {
const u = vi.site_url;
let path = pathname;
if (!path.startsWith("/")) path = "/" + path;
if (w.prasiContext.siteUrl) path = w.prasiContext.siteUrl(path);
return `${u.protocol}//${u.host}${path}`;
}
return pathname;
};
w.isMobile = mode === "mobile";
w.isDesktop = mode === "desktop";
w.preloaded = preloaded || ((url)=>{});
w.preload = (_urls, opt)=>{
if (vi.on_preload) return new Promise((done)=>{
if (!vi.page.navs[page_id]) vi.page.navs[page_id] = new Set();
const navs = vi.page.navs[page_id];
const urls = typeof _urls === "string" ? [
_urls
] : _urls;
let all_done = true;
for (const url of urls)if (!navs.has(url)) {
navs.add(url);
all_done = false;
}
if (!all_done) {
vi.page.preload.push(done);
vi.on_preload?.({
urls: Array.from(vi.page.navs[page_id]),
opt: {
on_load: (...arg)=>{
opt?.on_load?.(...arg);
for (const done of vi.page.preload)done();
vi.page.preload = [];
vi.render();
}
}
});
} else done();
});
};
vi.layout = layout;
vi.page.cur.id = page_id;
vi.on_status_changes = on_status_changed;
if (rs === "disabled") (0, _render.render_stat).enabled = false;
if (vi.meta !== meta) vi.meta = meta;
if (script) vi.script.init_local_effect = script.init_local_effect;
vi.visit = visit;
if (vi.status === "init") {
vi.site.db = db;
vi.site.api = api;
(0, _load.viLoad)(vi, {
api_url,
site_id
});
}
if (on_preload) (0, _react.useEffect)(()=>{
setTimeout(()=>{
const nav = vi.page.navs[vi.page.cur.id];
if (nav) on_preload({
urls: Array.from(nav),
opt: {
on_load (pages) {}
}
});
}, 500);
}, [
vi.page.cur.id
]);
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _errorBox.ErrorBox), {
children: /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _react.Suspense), {
children: /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _root.ViRoot), {}, void 0, false, {
fileName: "src/nova/vi/vi.tsx",
lineNumber: 189,
columnNumber: 9
}, undefined)
}, void 0, false, {
fileName: "src/nova/vi/vi.tsx",
lineNumber: 188,
columnNumber: 7
}, undefined)
}, void 0, false, {
fileName: "src/nova/vi/vi.tsx",
lineNumber: 187,
columnNumber: 5
}, undefined);
};
},{"react/jsx-dev-runtime":"j0wtd","react":"ftK02","web-utils":"aOKw0","./load/load":"1ReUt","./render/global":"fx5ht","./render/render":"dPkN4","./root":"57NVH","./utils/error-box":"cQ8yv","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"1ReUt":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "viLoad", ()=>viLoad);
const viLoad = (vi, arg)=>{
vi.status = "loading";
if (vi.on_status_changes) vi.on_status_changes(vi.status);
vi.site.id = arg.site_id;
vi.site.api_url = arg.api_url;
vi.status = "ready";
if (vi.on_status_changes) vi.on_status_changes(vi.status);
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"fx5ht":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "ViGlobal", ()=>ViGlobal);
const ViGlobal = {
ts: 0,
status: "init",
meta: {},
entry: [],
tick: 0,
mode: "desktop",
site: {
id: "",
api_url: "",
api: null,
db: null
},
site_url: null,
script: {
init_local_effect: undefined
},
visit: undefined,
on_status_changes: undefined,
layout: undefined,
page: {
cur: {
id: ""
},
navs: {},
preload: []
},
comp: {
load: async ()=>{
return null;
}
},
on_preload: undefined
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"dPkN4":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "render_stat", ()=>render_stat);
parcelHelpers.export(exports, "ViRender", ()=>ViRender);
parcelHelpers.export(exports, "ViChild", ()=>ViChild);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _react = require("react");
var _webUtils = require("web-utils");
var _errorBox = require("../utils/error-box");
var _global = require("./global");
var _parts = require("./parts");
var _script = require("./script");
const MAX_RENDER_IN_SECOND = 70;
const JS_CONFIG = {
debug: !!localStorage.getItem("prasi-js-debug")
};
const render_stat = {
enabled: false,
meta: {}
};
const ViRender = ({ meta, passprop, is_layout, parent_key, depth })=>{
if (render_stat.enabled) {
const rstat_meta = render_stat.meta;
if (!rstat_meta[meta.item.id]) rstat_meta[meta.item.id] = {
last_render: Math.floor(Date.now() / 1000),
count: 1
};
else if (rstat_meta[meta.item.id].last_render === Math.floor(Date.now() / 1000)) rstat_meta[meta.item.id].count++;
else rstat_meta[meta.item.id] = {
last_render: Math.floor(Date.now() / 1000),
count: 1
};
if (rstat_meta[meta.item.id]?.count > MAX_RENDER_IN_SECOND) return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: "bg-orange-100 border border-orange-300 rounded-sm text-xs flex flex-col items-center",
children: [
/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: "text-[10px] font-bold text-red-900 self-stretch px-1",
children: [
"WARNING: Render loop detected in [",
meta.item.name,
"]"
]
}, void 0, true, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 51,
columnNumber: 11
}, undefined),
/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("p", {
className: "border-b border-orange-300 px-1 pb-1 min-w-[100px]",
children: [
"Rendered ",
rstat_meta[meta.item.id]?.count,
" times in less than 1 second."
]
}, void 0, true, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 54,
columnNumber: 11
}, undefined)
]
}, void 0, true, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 50,
columnNumber: 9
}, undefined);
}
if (!meta) return null;
if (meta.item.hidden) return null;
if (JS_CONFIG.debug) {
let spaces = "";
for(let i = 0; i < depth; i++)spaces += ".";
console.log(spaces + meta.item.id, meta.item.name);
}
if (!(is_layout && meta.item.name === "children") && (meta.item.adv?.js || meta.item.component?.id)) return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _errorBox.ErrorBox), {
meta: meta,
children: /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _script.ViScript), {
meta: meta,
depth: depth,
is_layout: is_layout,
passprop: {
...passprop
},
parent_key: parent_key
}, void 0, false, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 78,
columnNumber: 9
}, undefined)
}, void 0, false, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 77,
columnNumber: 7
}, undefined);
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _errorBox.ErrorBox), {
meta: meta,
children: /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)(ViChild, {
meta: meta,
passprop: {
...passprop
},
depth: depth,
is_layout: is_layout,
parent_key: parent_key
}, void 0, false, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 90,
columnNumber: 7
}, undefined)
}, void 0, false, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 89,
columnNumber: 5
}, undefined);
};
const ViChild = ({ meta, passprop, is_layout, parent_key, depth })=>{
const vi = (0, _webUtils.useGlobal)((0, _global.ViGlobal), "VI");
if (is_layout && meta.item.name === "children") {
const childs = [];
for (const item_id of vi.entry){
const meta = vi.meta[item_id];
if (meta.item.adv?.js || meta.item.component?.id) childs.push(/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _errorBox.ErrorBox), {
meta: meta,
children: /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _script.ViScript), {
meta: meta,
is_layout: false,
passprop: {
...passprop
},
parent_key: parent_key,
depth: depth + 1
}, void 0, false, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 119,
columnNumber: 13
}, undefined)
}, void 0, false, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 118,
columnNumber: 11
}, undefined));
else {
const parts = (0, _parts.viParts)(vi, meta, false, passprop, depth);
if (vi.visit) vi.visit(meta, parts);
childs.push(/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
...parts.props
}, void 0, false, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 131,
columnNumber: 21
}, undefined));
}
}
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _jsxDevRuntime.Fragment), {
children: childs.map((e, idx)=>/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _react.Fragment), {
children: e
}, idx, false, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 138,
columnNumber: 11
}, undefined))
}, void 0, false);
}
const parts = (0, _parts.viParts)(vi, meta, is_layout, passprop, depth);
if (vi.visit) vi.visit(meta, parts);
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
...parts.props
}, void 0, false, {
fileName: "src/nova/vi/render/render.tsx",
lineNumber: 147,
columnNumber: 10
}, undefined);
};
},{"react/jsx-dev-runtime":"j0wtd","react":"ftK02","web-utils":"aOKw0","../utils/error-box":"cQ8yv","./global":"fx5ht","./parts":"iQBmW","./script":"1jwSy","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"cQ8yv":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "ErrorBox", ()=>ErrorBox);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _reactUseErrorBoundary = require("react-use-error-boundary");
var _webUtils = require("web-utils");
const ErrorBox = (0, _reactUseErrorBoundary.withErrorBoundary)(({ children, meta, id, silent = true })=>{
const local = (0, _webUtils.useLocal)({
retrying: false,
meta
});
const [error, resetError] = (0, _reactUseErrorBoundary.useErrorBoundary)((error, errorInfo)=>{
if (silent !== true) console.error(error);
});
if (meta && local.meta !== meta) {
local.meta = meta;
setTimeout(resetError);
}
let _meta = meta;
if (error) return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: "bg-red-100 border border-red-300 rounded-sm text-xs flex flex-col items-center",
children: [
/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: "text-[10px] font-bold text-red-900 self-stretch px-1",
children: [
"ERROR ",
_meta?.item.name ? "[" + _meta.item.name + "]:" : ""
]
}, void 0, true, {
fileName: "src/nova/vi/utils/error-box.tsx",
lineNumber: 32,
columnNumber: 11
}, undefined),
/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("p", {
className: "border-b border-red-300 px-1 pb-1 min-w-[100px]",
children: !local.retrying ? /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _jsxDevRuntime.Fragment), {
children: error.message
}, void 0, false) : /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _jsxDevRuntime.Fragment), {
children: "Retrying..."
}, void 0, false)
}, void 0, false, {
fileName: "src/nova/vi/utils/error-box.tsx",
lineNumber: 35,
columnNumber: 11
}, undefined),
/*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: "p-1",
children: /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("button", {
onClick: ()=>{
local.retrying = true;
local.render();
setTimeout(()=>{
local.retrying = false;
local.render();
resetError();
}, 100);
},
className: "bg-white border border-white hover:border-red-400 hover:bg-red-50 rounded px-2",
children: "Try again"
}, void 0, false, {
fileName: "src/nova/vi/utils/error-box.tsx",
lineNumber: 39,
columnNumber: 13
}, undefined)
}, void 0, false, {
fileName: "src/nova/vi/utils/error-box.tsx",
lineNumber: 38,
columnNumber: 11
}, undefined)
]
}, void 0, true, {
fileName: "src/nova/vi/utils/error-box.tsx",
lineNumber: 31,
columnNumber: 9
}, undefined);
return children;
});
},{"react/jsx-dev-runtime":"j0wtd","react-use-error-boundary":"kyNwc","web-utils":"aOKw0","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"kyNwc":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "ErrorBoundaryContext", ()=>ErrorBoundaryContext);
parcelHelpers.export(exports, "withErrorBoundary", ()=>withErrorBoundary);
parcelHelpers.export(exports, "useErrorBoundary", ()=>useErrorBoundary);
var _react = require("react");
var _reactDefault = parcelHelpers.interopDefault(_react);
class ErrorBoundary extends (0, _react.Component) {
displayName = "ReactUseErrorBoundary";
componentDidCatch(...args) {
this.setState({});
this.props.onError(...args);
}
render() {
return this.props.children;
}
}
const noop = ()=>false;
const errorBoundaryContext = (0, _react.createContext)({
componentDidCatch: {
current: undefined
},
error: undefined,
setError: noop
});
function ErrorBoundaryContext({ children }) {
const [error, setError] = (0, _react.useState)();
const componentDidCatch = (0, _react.useRef)();
const ctx = (0, _react.useMemo)(()=>({
componentDidCatch,
error,
setError
}), [
error
]);
return (0, _reactDefault.default).createElement(errorBoundaryContext.Provider, {
value: ctx
}, (0, _reactDefault.default).createElement(ErrorBoundary, {
error: error,
onError: (error, errorInfo)=>{
setError(error);
componentDidCatch.current?.(error, errorInfo);
}
}, children));
}
ErrorBoundaryContext.displayName = "ReactUseErrorBoundaryContext";
function withErrorBoundary(WrappedComponent) {
function WithErrorBoundary(props) {
return (0, _reactDefault.default).createElement(ErrorBoundaryContext, null, (0, _reactDefault.default).createElement(WrappedComponent, {
key: "WrappedComponent",
...props
}));
}
WithErrorBoundary.displayName = `WithErrorBoundary(${WrappedComponent.displayName ?? WrappedComponent.name ?? "Component"})`;
return WithErrorBoundary;
}
function useErrorBoundary(componentDidCatch) {
const ctx = (0, _react.useContext)(errorBoundaryContext);
ctx.componentDidCatch.current = componentDidCatch;
const resetError = (0, _react.useCallback)(()=>{
ctx.setError(undefined);
}, []);
return [
ctx.error,
resetError
];
}
},{"react":"ftK02","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"iQBmW":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "viParts", ()=>viParts);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _gen = require("../../../utils/css/gen");
var _render = require("./render");
const viParts = (vi, meta, is_layout, passprop, depth)=>{
const item = meta.item;
let inherit = undefined;
if (item.component?.style) inherit = {
style: item.component.style,
className: (0, _gen.produceCSS)(item.component.style, {
mode: vi.mode
})
};
const props = {
className: (0, _gen.produceCSS)(item, {
mode: vi.mode
}),
inherit
};
let text_props = {};
const childs = meta.item.childs;
let children = undefined;
if (meta.item.type === "text") {
children = null;
props.dangerouslySetInnerHTML = {
__html: meta.item.html || ""
};
} else children = Array.isArray(childs) && childs?.map((item)=>{
if (!item) return null;
const { id } = item;
let meta = is_layout ? vi.layout?.meta[id] : vi.meta[id];
if (!meta) {
if (item.type === "item" && item.component?.id) console.error(`Warning component ${item.name} - ${item.component.id} failed to load.`);
return null;
}
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _render.ViRender), {
meta: meta,
is_layout: is_layout,
passprop: {
...passprop
},
depth: depth + 1
}, id, false, {
fileName: "src/nova/vi/render/parts.tsx",
lineNumber: 78,
columnNumber: 11
}, undefined);
});
props.children = children;
if (meta.item.adv?.html) {
delete props.children;
props.dangerouslySetInnerHTML = {
__html: meta.item.adv?.html
};
} else if (meta.item.adv?.js && !meta.item.adv.js.includes("children")) {
delete props.children;
delete props.dangerouslySetInnerHTML;
}
return {
props,
text_props
};
};
},{"react/jsx-dev-runtime":"j0wtd","../../../utils/css/gen":"k1tnZ","./render":"dPkN4","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"k1tnZ":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "produceCSS", ()=>produceCSS);
var _advanced = require("./advanced");
var _background = require("./background");
var _border = require("./border");
var _dimension = require("./dimension");
var _editor = require("./editor");
var _font = require("./font");
var _layout = require("./layout");
var _padding = require("./padding");
const produceCSS = (item, arg)=>{
try {
return cx([
item.id ? `s-${item.id}` : "",
css`
display: flex;
position: relative;
user-select: none;
${(0, _layout.cssLayout)(item, arg.mode)}
${(0, _padding.cssPadding)(item, arg.mode)}
${(0, _dimension.cssDimension)(item, arg.mode, arg?.editor)}
${(0, _border.cssBorder)(item, arg.mode)}
${(0, _background.cssBackground)(item, arg.mode)}
${(0, _font.cssFont)(item, arg.mode)}
`,
(arg?.hover || arg?.active) && (0, _editor.cssEditor)({
item,
hover: arg?.hover,
active: arg?.active
}),
(0, _advanced.cssAdv)(item, arg.mode)
]);
} catch (e) {
console.log(e);
}
return cx([]);
};
},{"./advanced":"hO6aW","./background":"j9cgp","./border":"6sldt","./dimension":"kpOBa","./editor":"bvA5G","./font":"aLcCS","./layout":"bs7dT","./padding":"8LNiI","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"hO6aW":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "cssAdv", ()=>cssAdv);
var _responsiveVal = require("../../nova/ed/panel/side/style/tools/responsive-val");
const cssAdv = (cur, mode)=>{
const adv = (0, _responsiveVal.responsiveVal)(cur, "adv", mode, {});
if (typeof adv.css === "string") {
const hasCSS = adv.css.trim();
if (hasCSS) return cx(css`
${adv.css}
`, mode);
}
return "";
};
},{"../../nova/ed/panel/side/style/tools/responsive-val":"2bjzi","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"2bjzi":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "responsiveVal", ()=>responsiveVal);
const responsiveVal = (item, key, mode, defaultVal)=>{
let value = item[key];
if (mode === "desktop" || !mode) {
if (!value && item.mobile && item.mobile[key]) value = item.mobile[key];
} else if (item.mobile && item.mobile[key]) value = item.mobile[key];
if (!value) value = defaultVal;
return value;
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"j9cgp":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "cssBackground", ()=>cssBackground);
var _responsiveVal = require("../../nova/ed/panel/side/style/tools/responsive-val");
const cssBackground = (cur, mode)=>{
const bg = (0, _responsiveVal.responsiveVal)(cur, "bg", mode, {
size: "contain",
pos: "center"
});
let bgurl = `${serverurl}${bg.url}`;
if (bg && bg.url && bg.url.startsWith("http")) bgurl = bg.url;
return cx(`
background-repeat: no-repeat;
`, bg.color && `
background-color: ${bg.color};
`, bg.size && `
background-size: ${bg.size};
`, bg.pos && `
background-position: ${bg.pos};
`);
};
},{"../../nova/ed/panel/side/style/tools/responsive-val":"2bjzi","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"6sldt":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "cssBorder", ()=>cssBorder);
var _lodashGet = require("lodash.get");
var _lodashGetDefault = parcelHelpers.interopDefault(_lodashGet);
var _responsiveVal = require("../../nova/ed/panel/side/style/tools/responsive-val");
const cssBorder = (cur, mode)=>{
const border = (0, _responsiveVal.responsiveVal)(cur, "border", mode, {
style: "solid",
stroke: {},
rounded: {
tr: 0,
tl: 0,
bl: 0,
br: 0
},
color: "transparent"
});
return cx(pick(border, "stroke.l", "border-left-width"), pick(border, "stroke.r", "border-right-width"), pick(border, "stroke.b", "border-bottom-width"), pick(border, "stroke.t", "border-top-width"), pick(border, "color", "border-color", "transparent"), pick(border, "style", "border-style", "dashed"), pick(border, "rounded.tl", "border-top-left-radius"), pick(border, "rounded.tr", "border-top-right-radius"), pick(border, "rounded.bl", "border-bottom-left-radius"), pick(border, "rounded.br", "border-bottom-right-radius"));
};
const pick = (obj, key, attr, notpx)=>{
const val = (0, _lodashGetDefault.default)(obj, key);
if (notpx) {
if (val) return `${attr}: ${val};`;
else return `${attr}: ${notpx};`;
} else if (val) return `${attr}: ${val}px;`;
};
},{"lodash.get":"32uF9","../../nova/ed/panel/side/style/tools/responsive-val":"2bjzi","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"32uF9":[function(require,module,exports) {
/**
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/ /** Used as the `TypeError` message for "Functions" methods. */ var global = arguments[3];
var FUNC_ERROR_TEXT = "Expected a function";
/** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = "__lodash_hash_undefined__";
/** Used as references for various `Number` constants. */ var INFINITY = 1 / 0;
/** `Object#toString` result references. */ var funcTag = "[object Function]", genTag = "[object GeneratorFunction]", symbolTag = "[object Symbol]";
/** Used to match property names within property paths. */ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to match backslashes in property paths. */ var reEscapeChar = /\\(\\)?/g;
/** Used to detect host constructors (Safari). */ var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
/** Detect free variable `self`. */ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
/** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function("return this")();
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/ function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**
* Checks if `value` is a host object in IE < 9.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
*/ function isHostObject(value) {
// Many host objects are `Object` objects that can coerce to strings
// despite having improperly defined `toString` methods.
var result = false;
if (value != null && typeof value.toString != "function") try {
result = !!(value + "");
} catch (e) {}
return result;
}
/** Used for built-in method references. */ var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */ var coreJsData = root["__core-js_shared__"];
/** Used to detect methods masquerading as native. */ var maskSrcKey = function() {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
return uid ? "Symbol(src)_1." + uid : "";
}();
/** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString;
/** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/ var objectToString = objectProto.toString;
/** Used to detect if a method is native. */ var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
/** Built-in value references. */ var Symbol = root.Symbol, splice = arrayProto.splice;
/* Built-in method references that are verified to be native. */ var Map = getNative(root, "Map"), nativeCreate = getNative(Object, "create");
/** Used to convert symbols to primitives and strings. */ var symbolProto = Symbol ? Symbol.prototype : undefined, symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/ function Hash(entries) {
var index = -1, length = entries ? entries.length : 0;
this.clear();
while(++index < length){
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/ function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ function hashDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/ function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {
var result = data[key];
return result === HASH_UNDEFINED ? undefined : result;
}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ function hashHas(key) {
var data = this.__data__;
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
}
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/ function hashSet(key, value) {
var data = this.__data__;
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
return this;
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;
Hash.prototype["delete"] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/ function ListCache(entries) {
var index = -1, length = entries ? entries.length : 0;
this.clear();
while(++index < length){
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/ function listCacheClear() {
this.__data__ = [];
}
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ function listCacheDelete(key) {
var data = this.__data__, index = assocIndexOf(data, key);
if (index < 0) return false;
var lastIndex = data.length - 1;
if (index == lastIndex) data.pop();
else splice.call(data, index, 1);
return true;
}
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/ function listCacheGet(key) {
var data = this.__data__, index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/ function listCacheSet(key, value) {
var data = this.__data__, index = assocIndexOf(data, key);
if (index < 0) data.push([
key,
value
]);
else data[index][1] = value;
return this;
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype["delete"] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/ function MapCache(entries) {
var index = -1, length = entries ? entries.length : 0;
this.clear();
while(++index < length){
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/ function mapCacheClear() {
this.__data__ = {
"hash": new Hash,
"map": new (Map || ListCache),
"string": new Hash
};
}
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ function mapCacheDelete(key) {
return getMapData(this, key)["delete"](key);
}
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/ function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/ function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;
MapCache.prototype["delete"] = mapCacheDelete;
MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapCacheSet;
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/ function assocIndexOf(array, key) {
var length = array.length;
while(length--){
if (eq(array[length][0], key)) return length;
}
return -1;
}
/**
* The base implementation of `_.get` without support for default values.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @returns {*} Returns the resolved value.
*/ function baseGet(object, path) {
path = isKey(path, object) ? [
path
] : castPath(path);
var index = 0, length = path.length;
while(object != null && index < length)object = object[toKey(path[index++])];
return index && index == length ? object : undefined;
}
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/ function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) return false;
var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/ function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == "string") return value;
if (isSymbol(value)) return symbolToString ? symbolToString.call(value) : "";
var result = value + "";
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
}
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/ function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/ function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
}
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/ function getNative(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : undefined;
}
/**
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/ function isKey(value, object) {
if (isArray(value)) return false;
var type = typeof value;
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) return true;
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
}
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/ function isKeyable(value) {
var type = typeof value;
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
}
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/ function isMasked(func) {
return !!maskSrcKey && maskSrcKey in func;
}
/**
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/ var stringToPath = memoize(function(string) {
string = toString(string);
var result = [];
if (reLeadingDot.test(string)) result.push("");
string.replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, "$1") : number || match);
});
return result;
});
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/ function toKey(value) {
if (typeof value == "string" || isSymbol(value)) return value;
var result = value + "";
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
}
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @returns {string} Returns the source code.
*/ function toSource(func) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return func + "";
} catch (e) {}
}
return "";
}
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/ function memoize(func, resolver) {
if (typeof func != "function" || resolver && typeof resolver != "function") throw new TypeError(FUNC_ERROR_TEXT);
var memoized = function() {
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
if (cache.has(key)) return cache.get(key);
var result = func.apply(this, args);
memoized.cache = cache.set(key, result);
return result;
};
memoized.cache = new (memoize.Cache || MapCache);
return memoized;
}
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/ function eq(value, other) {
return value === other || value !== value && other !== other;
}
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/ var isArray = Array.isArray;
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/ function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 8-9 which returns 'object' for typed array and other constructors.
var tag = isObject(value) ? objectToString.call(value) : "";
return tag == funcTag || tag == genTag;
}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/ function isObject(value) {
var type = typeof value;
return !!value && (type == "object" || type == "function");
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/ function isObjectLike(value) {
return !!value && typeof value == "object";
}
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/ function isSymbol(value) {
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {string} Returns the string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/ function toString(value) {
return value == null ? "" : baseToString(value);
}
/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/ function get(object, path, defaultValue) {
var result = object == null ? undefined : baseGet(object, path);
return result === undefined ? defaultValue : result;
}
module.exports = get;
},{}],"kpOBa":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "cssDimension", ()=>cssDimension);
var _responsiveVal = require("../../nova/ed/panel/side/style/tools/responsive-val");
const cssDimension = (cur, mode, editor)=>{
const dim = (0, _responsiveVal.responsiveVal)(cur, "dim", mode, {
h: "fit",
w: "fit"
});
if (dim.w === "full" && dim.h === "full") return `
width:100%;
height:100%;
flex:1;
`;
return cx(dim.w === "fit" && `
& > .txt-box > * {
white-space: nowrap !important;
}
`, dim.w === "full" && `
width: 100%;
`, dim.w && typeof dim.w === "number" && dim.w >= 0 && `
width: ${dim.w}${dim.wUnit || "px"};
overflow-x: clip;
`, dim.h === "full" && `
height: ${editor ? "100%" : "100" + (cur.type === "section" ? mode === "mobile" ? "vh" : "vh" : "%")};
margin-bottom: auto;
`, dim.h && typeof dim.h === "number" && dim.h >= 0 && `
height: ${dim.h}${dim.hUnit || "px"};
overflow-y: clip;
`);
};
},{"../../nova/ed/panel/side/style/tools/responsive-val":"2bjzi","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"bvA5G":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "cssEditor", ()=>cssEditor);
const cssEditor = ({ item, hover, active })=>{
return cx(hover && css`
& {
box-shadow: inset 0 0 0px 3px #bae3fd;
> img {
opacity: 0.6;
}
}
`, active && css`
box-shadow: inset 0 0 0px 2px #009cff !important;
> img {
opacity: 0.6;
}
`);
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"aLcCS":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "glbFont", ()=>glbFont);
parcelHelpers.export(exports, "cssFont", ()=>cssFont);
var _responsiveVal = require("../../nova/ed/panel/side/style/tools/responsive-val");
const glbFont = window;
const cssFont = (cur, mode)=>{
const font = (0, _responsiveVal.responsiveVal)(cur, "font", mode, {});
if (font.family) {
if (!glbFont.loadedFonts) glbFont.loadedFonts = [];
const weight = `:wght@${[
300,
400,
500,
600
].join(";")}`;
const fontName = font.family.replace(/ /g, "+");
if (glbFont.loadedFonts.indexOf(font.family) < 0) {
glbFont.loadedFonts.push(font.family);
const doc = document;
const _href = `https://fonts.googleapis.com/css2?family=${fontName}${weight}&display=swap`;
if (!doc.querySelector(`link[href="${_href}]`)) {
const link = doc.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.crossOrigin = "anonymous";
link.href = _href;
doc.head.appendChild(link);
}
}
}
if (!font.family && glbFont.defaultFont) font.family = glbFont.defaultFont;
const res = cx(font.color && `
color: ${font.color};
`, font.whitespace === "whitespace-normal" && `
word-break: break-word;
`, font.whitespace === "whitespace-nowrap" && `
white-space: nowrap;
`, font.color && `
color: ${font.color};
`, `
text-align: ${font.align ? font.align : "left"};
`, font.size && `
font-size: ${font.size || 15}px;
`, font.height && `
line-height: ${font.height === "auto" ? "normal" : `${font.height}%`};
`, font.family && `
font-family: ${font.family};
`);
return res;
};
},{"../../nova/ed/panel/side/style/tools/responsive-val":"2bjzi","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"bs7dT":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "cssLayout", ()=>cssLayout);
var _responsiveVal = require("../../nova/ed/panel/side/style/tools/responsive-val");
const cssLayout = (cur, mode)=>{
const result = [];
let layout = (0, _responsiveVal.responsiveVal)(cur, "layout", mode, {
dir: "col",
align: "top-left",
gap: 0,
wrap: undefined
});
if (layout) {
if (layout.wrap) result.push(layout.wrap === "flex-wrap" ? "flex-wrap: wrap;" : "flex-wrap: nowrap;");
if (layout.dir.startsWith("col")) {
if (layout.dir === "col") result.push("flex-direction: column;");
else if (layout.dir === "col-reverse") result.push("flex-direction: column-reverse;");
if (layout.gap === "auto") {
if (layout.align === "left") result.push("align-items:start; justify-content: space-between;");
if (layout.align === "center") result.push("align-items:center; justify-content: space-between;");
if (layout.align === "right") result.push("align-items:end; justify-content: space-between;");
} else {
result.push(`gap: ${layout.gap}px;`);
if (layout.align === "top-left") result.push("align-items:start; justify-content: start;");
if (layout.align === "top-center") result.push("align-items:center; justify-content: start;");
if (layout.align === "top-right") result.push("align-items:end; justify-content: start;");
if (layout.align === "left") result.push("align-items:start; justify-content: center;");
if (layout.align === "center") result.push("align-items:center; justify-content: center;");
if (layout.align === "right") result.push("align-items:end; justify-content: center;");
if (layout.align === "bottom-left") result.push("align-items:start; justify-content: end;");
if (layout.align === "bottom-center") result.push("align-items:center; justify-content: end;");
if (layout.align === "bottom-right") result.push("align-items:end; justify-content: end;");
}
} else {
if (layout.dir === "row") result.push("flex-direction: row;");
else if (layout.dir === "row-reverse") result.push("flex-direction: row-reverse;");
if (layout.gap === "auto") {
if (layout.align === "top") result.push("align-items:start; justify-content: space-between;");
if (layout.align === "center") result.push("align-items:center; justify-content: space-between;");
if (layout.align === "bottom") result.push("align-items:end; justify-content: space-between;");
} else {
result.push(`
gap: ${layout.gap}px;
`);
if (layout.align === "top-left") result.push("align-items:start; justify-content: start;");
if (layout.align === "top-center") result.push("align-items:start; justify-content: center;");
if (layout.align === "top-right") result.push("align-items:start; justify-content: end;");
if (layout.align === "left") result.push("align-items:center; justify-content: start;");
if (layout.align === "center") result.push("align-items:center; justify-content: center;");
if (layout.align === "right") result.push("align-items:center; justify-content: end;");
if (layout.align === "bottom-left") result.push("align-items:end; justify-content: start;");
if (layout.align === "bottom-center") result.push("align-items:end; justify-content: center;");
if (layout.align === "bottom-right") result.push("align-items:end; justify-content: end;");
}
}
} else return "flex-direction:column; align-items:start; justify-content: start;";
return result.join("\n ").trim();
};
},{"../../nova/ed/panel/side/style/tools/responsive-val":"2bjzi","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"8LNiI":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "cssPadding", ()=>cssPadding);
var _responsiveVal = require("../../nova/ed/panel/side/style/tools/responsive-val");
const cssPadding = (cur, mode)=>{
const padding = (0, _responsiveVal.responsiveVal)(cur, "padding", mode, {
l: 0,
b: 0,
t: 0,
r: 0
});
return cx(padding.l !== undefined && `
padding-left: ${padding.l}px;
`, padding.r !== undefined && `
padding-right: ${padding.r}px;
`, padding.b !== undefined && `
padding-bottom: ${padding.b}px;
`, padding.t !== undefined && `
padding-top: ${padding.t}px;
`);
};
},{"../../nova/ed/panel/side/style/tools/responsive-val":"2bjzi","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"1jwSy":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "ViScript", ()=>ViScript);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _react = require("react");
var _webUtils = require("web-utils");
var _global = require("./global");
var _render = require("./render");
var _evalProp = require("./script/eval-prop");
var _evalScript = require("./script/eval-script");
const ViScript = ({ meta, passprop, is_layout, parent_key, depth })=>{
const vi = (0, _webUtils.useGlobal)((0, _global.ViGlobal), "VI");
const [_, _set] = (0, _react.useState)({});
meta.render = ()=>{
_set({});
};
let _pass = passprop;
if (meta.item.component?.id) {
if (!_pass) _pass = {};
(0, _evalProp.viEvalProps)(vi, meta, is_layout, _pass, depth, parent_key);
}
if (meta.item.adv?.html) return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _render.ViChild), {
meta: meta,
passprop: _pass,
is_layout: is_layout,
depth: depth
}, void 0, false, {
fileName: "src/nova/vi/render/script.tsx",
lineNumber: 30,
columnNumber: 7
}, undefined);
if (meta.item.adv?.js) {
(0, _evalScript.viEvalScript)(vi, meta, is_layout, _pass, depth, parent_key);
if (meta.script) return meta.script.result;
}
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _render.ViChild), {
meta: meta,
passprop: _pass,
is_layout: is_layout,
depth: depth
}, void 0, false, {
fileName: "src/nova/vi/render/script.tsx",
lineNumber: 46,
columnNumber: 5
}, undefined);
};
},{"react/jsx-dev-runtime":"j0wtd","react":"ftK02","web-utils":"aOKw0","./global":"fx5ht","./render":"dPkN4","./script/eval-prop":"a8GtZ","./script/eval-script":"kh5Uo","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"a8GtZ":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "w", ()=>w);
parcelHelpers.export(exports, "viEvalProps", ()=>viEvalProps);
parcelHelpers.export(exports, "updatePropScope", ()=>updatePropScope);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _cuid2 = require("@paralleldrive/cuid2");
var _edGlobal = require("../../../ed/logic/ed-global");
var _render = require("../render");
var _arg = require("./arg");
var _codeBuild = require("./code-build");
var _evalScript = require("./eval-script");
var _extractNav = require("./extract-nav");
const w = window;
const viEvalProps = (vi, meta, is_layout, passprop, depth, parent_key)=>{
if (meta.item.component?.id) {
let script = meta.item.script;
if (parent_key) {
if (!meta.item.script_keyed) meta.item.script_keyed = {};
if (!meta.item.script_keyed[parent_key]) meta.item.script_keyed[parent_key] = {};
script = meta.item.script_keyed[parent_key];
} else {
if (!meta.item.script) meta.item.script = {};
script = meta.item.script;
}
if (!script) return;
const exports = window.exports;
const arg = {
...exports,
db: vi.site.db,
api: vi.site.api,
...(0, _arg.viScriptArg)(vi),
...passprop,
params
};
script.props = {};
let fails = new Set();
if (!!meta.item.component.props) {
const _props = {};
for (const [name, prop] of Object.entries(meta.item.component.props))try {
if (prop.meta?.type === "content-element") {
let val = {
_jsx: true,
fn: (arg)=>{
const id = prop.content?.id;
if (id) {
const m = is_layout ? vi.layout?.meta[id] : vi.meta[id];
if (!m) return null;
const instances = meta.instances;
if (!arg.meta.item.originalId || !instances) return null;
const instance = instances[meta.item.id];
if (!instance) return null;
const original_id = arg.meta.item.originalId;
if (m.mitem && (prop.jsxCalledBy && (!prop.jsxCalledBy.includes(original_id) || prop.jsxCalledBy.length !== 2) || !prop.jsxCalledBy)) {
const mprop = meta.mitem?.get("component")?.get("props")?.get(name);
if (mprop) {
let mjby = mprop.get("jsxCalledBy");
if (!mjby || typeof mjby !== "object") mprop.set("jsxCalledBy", [
meta.item.id,
original_id
]);
else if (Array.isArray(mjby) && (!mjby.includes(original_id) || mjby.length !== 2 || mjby[0] !== meta.item.id || mjby[1] !== original_id)) mprop.set("jsxCalledBy", [
meta.item.id,
original_id
]);
}
}
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _render.ViRender), {
meta: m,
passprop: arg.passprop,
is_layout: is_layout,
depth: depth + 1
}, void 0, false, {
fileName: "src/nova/vi/render/script/eval-prop.tsx",
lineNumber: 110,
columnNumber: 21
}, undefined);
}
return null;
}
};
arg[name] = val;
if (passprop) passprop[name] = val;
continue;
}
if (prop.value) (0, _extractNav.extractNavigate)(vi, prop.value);
if (!prop.valueBuilt && prop.value && meta.mitem) {
const mprop = meta.mitem?.get("component")?.get("props")?.get(name);
if (mprop) {
updatePropValueBuilt(mprop, prop.value);
return;
}
}
let js = prop.valueBuilt || "";
if (js.startsWith(`const _jsxFileName = "";`)) js = `(() => { ${js.replace(`const _jsxFileName = "";`, `const _jsxFileName = ""; return `)} })()`;
const src = (0, _evalScript.replaceWithObject)(js, (0, _evalScript.replacement)) || "";
const fn = new Function(...Object.keys(arg), `// [${meta.item.name}] ${name}: ${meta.item.id}
return ${src}
`);
script.props[name] = {
value: src,
valueBuilt: src
};
let val = fn(...Object.values(arg));
if (typeof val === "function") val = (...args)=>{
const definer = new Function(...Object.keys(arg), `// [${meta.item.name}] ${name}: ${meta.item.id}
return ${src.trim()}
`);
const fn = definer(...Object.values(arg));
return fn(...args);
};
arg[name] = val;
_props[name] = val;
if (passprop) passprop[name] = val;
} catch (e) {
fails.add(name);
}
if (location.pathname.startsWith("/ed/") && (0, _edGlobal.active).item_id) {
if (meta.item.id === (0, _edGlobal.active).item_id) {
(0, _edGlobal.active).scope = {};
for (const [k, v] of Object.entries(passprop))(0, _edGlobal.active).scope[k] = v;
(0, _edGlobal.active).scope.self_props = _props;
}
}
}
}
};
const conf = {
timeout: null,
set: new WeakSet(),
map: {},
src: {}
};
const updatePropValueBuilt = (mprop, src)=>{
if (!conf.set.has(mprop)) {
conf.set.add(mprop);
const id = (0, _cuid2.createId)();
conf.map[id] = {
mprop
};
conf.src[id] = src;
}
clearTimeout(conf.timeout);
conf.timeout = setTimeout(async ()=>{
const result = await (0, _codeBuild.codeBuild)(conf.src);
let doc = null;
for (const [k, v] of Object.entries(result)){
const mprop = conf.map[k].mprop;
if (!doc && mprop.doc) {
doc = mprop.doc;
break;
}
}
if (doc) {
doc.transact(()=>{
for (const [k, v] of Object.entries(result)){
const mprop = conf.map[k].mprop;
mprop.set("valueBuilt", v);
}
});
conf.set = new WeakSet();
conf.map = {};
conf.src = {};
}
}, 300);
};
const updatePropScope = (vi, meta, scope, parent_key)=>{
const script = parent_key ? meta.item.script_keyed?.[parent_key] : meta.item.script;
if (!script) return;
if (script.props) {
const scopes = {
...scope,
api: vi.site.api,
db: vi.site.db
};
for (const [name, prop] of Object.entries(script.props))if (prop.fn) {
const fn = new Function(...Object.keys(scopes), `// [${meta.item.name}] ${name}: ${meta.item.id}
return ${prop.value || ""}
`);
prop.fn = fn(...Object.values(scopes));
}
}
};
},{"react/jsx-dev-runtime":"j0wtd","@paralleldrive/cuid2":"41M7L","../../../ed/logic/ed-global":"5VTke","../render":"dPkN4","./arg":"e5PfR","./code-build":"kKbAp","./eval-script":"kh5Uo","./extract-nav":"kVlwd","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"kKbAp":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "codeBuild", ()=>codeBuild);
const imported = {
transform: null
};
const codeBuild = async (codes, filePath)=>{
if (!imported.transform) imported.transform = (await require("90b6356c757ec7d2")).transform;
const result = {};
for (const [k, v] of Object.entries(codes)){
result[k] = imported.transform(v, {
transforms: [
"typescript",
"imports",
"jsx"
],
preserveDynamicImport: true,
disableESTransforms: true,
filePath: filePath
}).code;
const removes = [
`"use strict";`
];
for (const r of removes)if (result[k].startsWith(r)) result[k] = result[k].substring(r.length).trim();
}
return result;
};
},{"90b6356c757ec7d2":"5214m","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"5214m":[function(require,module,exports) {
module.exports = require("64ee1123e4889e20")(require("6c1da4547aa3f63").getBundleURL("2E3Jw") + "esm.87f94ee9.js").catch((err)=>{
delete module.bundle.cache[module.id];
throw err;
}).then(()=>module.bundle.root("bBACX"));
},{"64ee1123e4889e20":"bQCon","6c1da4547aa3f63":"f17Mo"}],"kh5Uo":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "viEvalScript", ()=>viEvalScript);
parcelHelpers.export(exports, "replacement", ()=>replacement);
parcelHelpers.export(exports, "replaceWithObject", ()=>replaceWithObject);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _react = require("react");
var _general = require("../../../../utils/types/general");
var _errorBox = require("../../utils/error-box");
var _parts = require("../parts");
var _arg = require("./arg");
var _evalProp = require("./eval-prop");
var _extractNav = require("./extract-nav");
var _local = require("./local");
var _passprop = require("./passprop");
var _itemDev = require("./item-dev");
var _itemProd = require("./item-prod");
const viEvalScript = (vi, meta, is_layout, passprop, depth, parent_key)=>{
const parts = (0, _parts.viParts)(vi, meta, is_layout, passprop, depth);
if (vi.visit) vi.visit(meta, parts);
if (!meta.script) meta.script = {
scope: passprop,
result: null,
Local: (0, _local.createViLocal)(vi, is_layout, meta),
PassProp: (0, _passprop.createViPassProp)(vi, is_layout, meta, passprop, depth)
};
else meta.script.scope = passprop;
const script = meta.script;
const exports = window.exports;
const arg = {
useEffect: (0, _react.useEffect),
children: parts.props.children,
props: parts.props,
Local: script?.Local,
db: vi.site.db,
api: vi.site.api,
PassProp: script?.PassProp,
ErrorBox: (0, _errorBox.ErrorBox),
newElement: ()=>{},
__props: passprop,
_item: meta.mitem ? (0, _itemDev.devItem)(vi.meta, meta.mitem, vi.page.cur.id) : (0, _itemProd.prodItem)(vi.meta, meta.item, vi.page.cur.id),
_meta: vi.meta,
render: (jsx)=>{
let result = jsx;
if (/*#__PURE__*/ (0, _react.isValidElement)(jsx) && jsx.props.children) {
const override_children = (el)=>{
let should_replace = false;
let new_childs = [];
if (/*#__PURE__*/ (0, _react.isValidElement)(el)) {
if (el.type === meta.script?.PassProp) return {
should_replace: true,
el: {
...el,
props: {
...el.props,
internal_key: el.key
}
}
};
if (el.props?.children) {
if (!Array.isArray(el.props.children)) el.props.children = [
el.props.children
];
if (Array.isArray(el.props.children)) for (const child of el.props.children){
if (Array.isArray(child)) {
const sub_child = [];
let sub_replace = false;
for (const c of child){
let nc = override_children(c);
if (nc.should_replace) {
sub_child.push(nc.el);
sub_replace = true;
} else sub_child.push(c);
}
if (sub_replace) {
should_replace = true;
new_childs.push(sub_child);
} else new_childs.push(child);
} else if (typeof child === "object" && child) {
if (child.type === meta.script?.PassProp) {
should_replace = true;
new_childs.push({
...child,
props: {
...child.props,
internal_key: child.props.key
}
});
}
} else new_childs.push(child);
}
}
}
return {
should_replace,
el: {
...el,
props: {
...el.props,
children: new_childs
}
}
};
};
const res = override_children(jsx);
if (res.should_replace) result = res.el;
}
if (script) script.result = /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _react.Suspense), {
children: result
}, void 0, false, {
fileName: "src/nova/vi/render/script/eval-script.tsx",
lineNumber: 150,
columnNumber: 35
}, undefined);
},
params,
...(0, _arg.viScriptArg)(vi),
...exports,
...passprop
};
if (typeof passprop === "object") {
for (const [k, v] of Object.entries(passprop))if (typeof v === "object" && v && v._jsx) {
const jprop = v;
arg[k] = /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)(JsxProp, {
fn: jprop.fn,
passprop: {
...passprop
},
meta: meta
}, void 0, false, {
fileName: "src/nova/vi/render/script/eval-script.tsx",
lineNumber: 166,
columnNumber: 11
}, undefined);
}
}
if (!(0, _general.w).isEditor && meta.item.adv?.js) (0, _extractNav.extractNavigate)(vi, meta.item.adv.js);
const js = meta.item.adv?.jsBuilt || "";
const src = replaceWithObject(js, replacement) || "";
if (js.includes("parent_props")) console.log(meta.item.name, arg);
const final_src = `\
// ${meta.item.name}: ${meta.item.id}
try {
${src}
} catch (e) {
console.error(\`\\
Error in item ${meta.item.name}: ${meta.item.id}
$\{__js}
ERROR: $\{e.message}
\`)
}
`;
try {
const fn = new Function(...Object.keys(arg), "__js", final_src);
fn(...Object.values(arg), meta.item.adv?.js);
} catch (e) {
console.error(`\n
// Syntax Error in ${meta.item.name}: ${meta.item.id}
// arg: ${Object.keys(arg).join(", ")}
${final_src}
${e.message}
`);
}
(0, _evalProp.updatePropScope)(vi, meta, passprop, parent_key);
};
const JsxProp = ({ fn, meta, passprop })=>{
return fn({
passprop,
meta
});
};
const replacement = {
"stroke-width": "strokeWidth",
"fill-rule": "fillRule",
"clip-rule": "clipRule",
"stroke-linejoin": "strokeLinejoin",
"stroke-linecap": "strokeLinecap",
"clip-path": "clipPath",
"stroke-miterlimit": "strokeMiterlimit"
};
const replaceWithObject = (tpl, data)=>{
let res = tpl;
for (const [k, v] of Object.entries(data))res = res.replaceAll(k, v);
return res;
};
},{"react/jsx-dev-runtime":"j0wtd","react":"ftK02","../../../../utils/types/general":"58I9D","../../utils/error-box":"cQ8yv","../parts":"iQBmW","./arg":"e5PfR","./eval-prop":"a8GtZ","./extract-nav":"kVlwd","./local":"ksO07","./passprop":"iUYLm","./item-dev":"gxY98","./item-prod":"97Jz5","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"ksO07":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "local_cached_value", ()=>local_cached_value);
parcelHelpers.export(exports, "createViLocal", ()=>createViLocal);
var _react = require("react");
var _passprop = require("./passprop");
var _webUtils = require("web-utils");
var _evalProp = require("./eval-prop");
const local_cached_value = {};
const createViLocal = (vi, is_layout, meta)=>{
return (arg)=>{
const isEditor = ([
"prasi.avolut.com"
].includes(location.hostname) || location.host === "localhost:4550") && location.pathname.startsWith("/ed/");
let id = meta.item.id;
const { children, parent_key } = arg;
const init_local_effect = vi.script?.init_local_effect;
const metas = is_layout ? vi.layout?.meta : vi.meta;
const curid = vi.page.cur.id + "~" + id;
if (!local_cached_value[curid]) local_cached_value[curid] = {
mounted: true,
value: arg.value
};
else if (!local_cached_value[curid].mounted) {
if (!(0, _evalProp.w).isEditor) {
for (const [k, v] of Object.entries(local_cached_value[curid].value))delete local_cached_value[curid].value[k];
for (const [k, v] of Object.entries((0, _webUtils.deepClone)(arg.value)))local_cached_value[curid].value[k] = v;
}
local_cached_value[curid].mounted = true;
}
const ref = (0, _react.useRef)(local_cached_value[curid].value);
const [_, set] = (0, _react.useState)({});
const local = ref.current;
local.render = ()=>{
const w = window;
if (!w.isEditor && w.prasiContext.render) w.prasiContext.render();
else set({});
};
if (arg.hook) arg.hook(local);
(0, _react.useEffect)(()=>{
if (meta.parent?.instance_id && metas) {
const parent_meta = metas[meta.parent?.instance_id];
if (parent_meta && parent_meta.instances) {
for (const [k, v] of Object.entries(parent_meta.instances[meta.parent.instance_id]))if (v === meta.item.id) {
id = k;
break;
}
}
}
let should_run = !init_local_effect[id];
if (should_run) {
if (typeof init_local_effect === "object") init_local_effect[id] = true;
const fn = async ()=>{
if (arg.effect) await arg.effect(local);
};
fn();
}
return ()=>{
local_cached_value[curid].mounted = false;
};
}, [
...arg.deps || [],
location.pathname
]);
(0, _react.useEffect)(()=>{
if (isEditor) {
if (local_cached_value[id] === null) {
const fn = async ()=>{
if (arg.effect) {
await arg.effect(local);
if (isEditor) local_cached_value[id] = local;
}
};
fn();
}
}
}, [
local_cached_value[id]
]);
const result = (0, _passprop.modifyChild)(children, {
...meta.script?.scope,
[arg.name]: local
});
return result;
};
};
},{"react":"ftK02","./passprop":"iUYLm","web-utils":"aOKw0","./eval-prop":"a8GtZ","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"iUYLm":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "createViPassProp", ()=>createViPassProp);
parcelHelpers.export(exports, "modifyChild", ()=>modifyChild);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _lodashGet = require("lodash.get");
var _lodashGetDefault = parcelHelpers.interopDefault(_lodashGet);
var _react = require("react");
var _render = require("../render");
const createViPassProp = (vi, is_layout, meta, passprop, depth)=>{
return (arg)=>{
const [_, render] = (0, _react.useState)({});
const internal_key = arg.idx || arg.internal_key;
if (!meta.item.script) meta.item.script = {};
let script = meta.item.script;
if (typeof internal_key !== "undefined") {
if (!meta.item.script_keyed) meta.item.script_keyed = {};
if (!meta.item.script_keyed[internal_key]) meta.item.script_keyed[internal_key] = {};
script = meta.item.script_keyed[internal_key];
}
if (!script.passprop) script.passprop = {};
const filtered_args = {};
let is_changed = false;
for (const [k, v] of Object.entries(arg))if (![
"children",
"key"
].includes(k)) {
is_changed = true;
filtered_args[k] = v;
}
let _pass = {
...passprop,
...filtered_args
};
if (typeof internal_key !== "undefined") {
if (typeof script.passprop.internal_key === "undefined") script.passprop = _pass;
else if (internal_key === script.passprop.internal_key) script.passprop = _pass;
_pass = script.passprop;
}
meta.editor_props = _pass;
if (!Array.isArray(arg.children) && /*#__PURE__*/ (0, _react.isValidElement)(arg.children) && typeof arg.children === "object") {
const children = (0, _lodashGetDefault.default)(arg.children, "props.meta.item.component.props.child.content.childs");
if (Array.isArray(children)) {
let is_meta = true;
for (const c of children)if (!(!/*#__PURE__*/ (0, _react.isValidElement)(c) && typeof c === "object")) is_meta = false;
if (is_meta) return children.map((item)=>{
let cmeta = vi.meta[item.id];
if (!cmeta) {
vi.meta[item.id] = {
item
};
cmeta = vi.meta[item.id];
}
if (cmeta) {
if (Object.keys(cmeta.item).length <= 3) {
if (cmeta.mitem) {
const citem = {
...cmeta.item
};
const ref_item = cmeta.mitem.toJSON();
cmeta.item = {
...ref_item,
...citem
};
}
}
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _render.ViRender), {
is_layout: is_layout,
meta: cmeta,
passprop: _pass,
parent_key: arg.internal_key,
depth: depth
}, item.id, false, {
fileName: "src/nova/vi/render/script/passprop.tsx",
lineNumber: 100,
columnNumber: 17
}, undefined);
}
return null;
});
}
}
if (!Array.isArray(arg.children) && !/*#__PURE__*/ (0, _react.isValidElement)(arg.children) && typeof arg.children === "object") {
const child_id = arg.children.id;
if (child_id) {
let meta = vi.meta[child_id];
if (!meta) {
vi.meta[child_id] = {
item: arg.children
};
meta = vi.meta[child_id];
const comp_id = meta.item.component?.id;
if (comp_id) vi.comp.load(comp_id).then((comp)=>{
if (comp) {
for (const [k, v] of Object.entries(comp)){
const item = meta.item;
if (!item[k]) item[k] = v;
}
const props = meta.item.component?.props;
for (const [k, v] of Object.entries(comp.component?.props || {}))if (!props[k]) props[k] = v;
render({});
}
});
}
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _render.ViRender), {
is_layout: is_layout,
meta: meta,
passprop: _pass,
parent_key: arg.internal_key,
depth: depth
}, void 0, false, {
fileName: "src/nova/vi/render/script/passprop.tsx",
lineNumber: 150,
columnNumber: 11
}, undefined);
}
}
const result = modifyChild(arg, _pass, internal_key ? {
parent_key: internal_key
} : undefined);
return result;
};
};
const modifyChild = (arg, passprop, add_props)=>{
let prop = {};
if (Array.isArray(arg)) prop.children = arg;
else prop = arg;
if (Array.isArray(prop.children)) {
if (prop.children.length === 1) return modify(prop.children[0], prop, passprop, add_props);
const childs = [];
for (const child of prop.children)childs.push(modify(child, prop, passprop, add_props));
return childs;
}
return modify(prop.children, prop, passprop, add_props);
};
const modify = (el, arg, passprop, add_props)=>{
if (/*#__PURE__*/ (0, _react.isValidElement)(el)) {
const passarg = {
...arg
};
delete passarg.children;
const result = {
...el,
props: {
...el.props,
...add_props,
passprop: {
...passprop,
...passarg
}
}
};
return result;
} else if (Array.isArray(el)) return modifyChild(el, passprop, add_props);
return el;
};
},{"react/jsx-dev-runtime":"j0wtd","lodash.get":"32uF9","react":"ftK02","../render":"dPkN4","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"gxY98":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "devItem", ()=>devItem);
var _cuid2 = require("@paralleldrive/cuid2");
var _codeBuild = require("./code-build");
const w = window;
const devItem = (metas, mitem, page_id, _added)=>{
const added = _added || {};
const id = mitem.get("id") || "";
if (!w.prasiEditDevItem) w.prasiEditDevItem = {};
let pedit = w.prasiEditDevItem[page_id];
if (!pedit) {
w.prasiEditDevItem[page_id] = {};
pedit = w.prasiEditDevItem[page_id];
}
const initChanges = ()=>{
const id = mitem.get("id") || "";
let changes = pedit[id];
if (!changes) {
pedit[id] = [];
changes = pedit[id];
}
return changes;
};
const item = mitem.toJSON();
const result = {
...item,
edit: {
get props () {
if (item.component?.props) {
const result = {};
for (const [k, v] of Object.entries(item.component.props))if (v.content) {
const content = mitem.get("component")?.get("props")?.get(k)?.get("content");
if (content) {
const id = content.get("id") || "";
if (added[id]) result[k] = {
mode: "jsx",
value: added[id]
};
else result[k] = {
mode: "jsx",
value: devItem(metas, content, page_id, added)
};
} else result[k] = {
mode: "jsx",
value: null
};
} else {
let vbuilt = typeof v.valueBuilt === "string" ? v.valueBuilt.trim() : "";
if (vbuilt.endsWith(";\n")) vbuilt = vbuilt.substring(0, vbuilt.length - 2);
if (vbuilt && vbuilt === v.value.trim()) {
const fn = new Function(`return ${v.value}`);
result[k] = {
mode: "string",
value: fn()
};
} else result[k] = {
mode: "raw",
value: v.value,
valueBuilt: v.valueBuilt
};
}
return result;
}
return undefined;
},
get pending () {
return [];
},
async commit () {
const result = {};
const compile = {};
if (mitem) {
for (const [item_id, changes] of Object.entries(pedit)){
const meta = metas[item_id];
if (!meta) continue;
if (!meta.mitem) continue;
const mitem = meta.mitem;
const item = mitem.toJSON();
if (item && item.component) {
const props = item?.component?.props;
if (!props) {
console.log(item, props);
return;
}
const src = {};
for (const c of changes){
if (c.type === "prop" && props) {
if (props[c.name]) {
if (c.mode === "string") {
props[c.name].value = JSON.stringify(c.value);
props[c.name].valueBuilt = JSON.stringify(c.value);
} else if (c.mode === "raw") {
props[c.name].value = c.value;
if (c.valueBuilt) props[c.name].valueBuilt = c.valueBuilt;
else src[c.name] = c.value;
} else if (c.mode === "jsx") {
if (!props[c.name]) props[c.name] = {
meta: {
type: "content-element"
}
};
if (c.value) props[c.name].content = removeEditFromChilds([
c.value
], compile)[0];
}
}
} else {
if (c.type === "set" && typeof c.value === "object") for (const [k, v] of Object.entries(c.value))item[k] = v;
else if (c.type === "child" && Array.isArray(c.childs)) {
if (item.component?.id) {
if (!item.component.props) item.component.props = {};
item.component.props.child = {
meta: {
type: "content-element"
},
content: {
type: "item",
id: (0, _cuid2.createId)(),
name: "child",
childs: removeEditFromChilds(c.childs.filter((e)=>e), compile)
}
};
} else {
const childs = removeEditFromChilds(c.childs.filter((e)=>e), compile);
item.childs = childs;
}
}
}
}
for (const [k, v] of Object.entries(compile))src[k] = v.value;
let code_result = await (0, _codeBuild.codeBuild)(src);
await new Promise((done)=>{
setTimeout(done);
});
if (props) for (const [k, v] of Object.entries(code_result)){
if (props[k]) props[k].valueBuilt = v;
else if (compile[k]) compile[k].valueBuilt = v;
}
result[item_id] = item;
}
}
mitem.doc?.transact(()=>{
for (const [k, v] of Object.entries(result)){
const m = metas[k];
if (m.mitem) syncronize(m.mitem, v);
}
});
}
},
setValue (name, value) {
const changes = initChanges();
let _value = value;
if (name === "childs") throw new Error("Please modify childs via .child");
changes.push({
type: "set",
name,
value: _value
});
},
setProp (name, value) {
const changes = initChanges();
if (typeof value === "string") changes.push({
type: "prop",
mode: "string",
name,
value
});
else {
if (value.mode === "string") changes.push({
type: "prop",
mode: "string",
name,
value: value.value
});
else if (value.mode === "raw") changes.push({
type: "prop",
mode: "raw",
name,
value: value.value,
valueBuilt: value.valueBuilt
});
else if (value.mode === "jsx") changes.push({
type: "prop",
mode: "jsx",
name,
value: value.value
});
}
},
setChilds (childs) {
const changes = initChanges();
changes.push({
type: "child",
childs
});
},
get childs () {
if (item.component?.id) {
const child = item.component?.props.child;
if (child && child.content) {
const m = mitem.get("component")?.get("props")?.get("child")?.get("content");
if (m) {
const id = m.get("id") || "";
if (added[id]) return [
added[id]
];
return [
devItem(metas, m, page_id, added)
];
}
}
return [];
}
if (item.childs) return item.childs.map((e)=>{
if (e) {
const m = metas[e.id];
if (added[e.id]) return added[e.id];
if (m && m.mitem) return devItem(metas, m.mitem, page_id, added);
}
}).filter((e)=>e);
return [];
},
get parent () {
if (mitem) {
const parent = mitem.parent.toJSON();
let parent_id = null;
if (Array.isArray(parent)) parent_id = (mitem.parent?.parent).get("id");
else {
const parent = mitem.parent?.parent?.parent?.parent;
if (typeof parent === "object" && typeof parent.get === "function") parent_id = parent.get("id");
}
const parent_meta = metas[parent_id]?.mitem;
if (parent_meta) {
const item = added[parent_id] ? added[parent_id] : devItem(metas, parent_meta, page_id, added);
if (Array.isArray(parent)) return {
item,
child_type: "child",
child_idx: parent.findIndex((e)=>e.id === item.id)
};
else return {
item,
child_type: "prop"
};
}
}
return null;
}
}
};
added[id] = result;
return result;
};
const complexifyProps = (props, compileValueBuilt)=>{
const result = {};
for (const [k, v] of Object.entries(props))if (v.mode) {
if (v.mode === "string") result[k] = {
value: JSON.stringify(v.value),
valueBuilt: JSON.stringify(v.value),
meta: {
type: "text"
}
};
else if (v.mode === "jsx" && v.value) result[k] = {
value: "",
valueBuilt: "",
content: removeEditFromChilds([
v.value
], compileValueBuilt)[0],
meta: {
type: "content-element"
}
};
else if (v.mode === "raw") result[k] = {
value: v.value,
valueBuilt: v.valueBuilt,
meta: {
type: "text"
}
};
} else result[k] = v;
return result;
};
const removeEditFromChilds = (childs, compileValueBuilt)=>{
let compile = compileValueBuilt || {};
const result = childs.map((e)=>{
const item = {
...e
};
delete item.edit;
if (!item.id) item.id = (0, _cuid2.createId)();
if (item.component) {
if (!item.component.instances) item.component.instances = {};
if (!item.component.ref_ids) item.component.ref_ids = {};
if (item.component?.props) {
item.component.props = complexifyProps(item.component.props, compile);
for (const [k, v] of Object.entries(item.component.props)){
if (!v.valueBuilt && v.value) compile[item.id + "|||" + k] = v;
if (v.content) v.content = removeEditFromChilds([
v.content
], compile)[0];
}
}
}
if (item.childs) item.childs = removeEditFromChilds(item.childs, compile);
else item.childs = [];
return item;
});
return result;
};
},{"@paralleldrive/cuid2":"41M7L","./code-build":"kKbAp","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"97Jz5":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "prodItem", ()=>prodItem);
const prodItem = (metas, item, page_id)=>{
return {
...item,
edit: {
setChilds (childs) {},
get childs () {
if (item.component?.id) {
const child = item.component?.props.child;
if (child.content) return [
prodItem(metas, child.content, page_id)
];
return [];
}
if (item.childs) return item.childs.map((e)=>{
if (e) {
const m = metas[e.id];
if (m && m.item) return prodItem(metas, m.item, page_id);
}
}).filter((e)=>e);
return [];
},
get props () {
if (item.component?.props) {
const result = {};
for (const [k, v] of Object.entries(item.component.props))if (v.content) {
const content = item.component?.props?.[k]?.content;
if (content) result[k] = {
mode: "jsx",
value: prodItem(metas, content, page_id)
};
else result[k] = {
mode: "jsx",
value: null
};
} else {
let vbuilt = typeof v.valueBuilt === "string" ? v.valueBuilt.trim() : "";
if (vbuilt.endsWith(";\n")) vbuilt = vbuilt.substring(0, vbuilt.length - 2);
if (vbuilt && vbuilt === v.value.trim()) {
const fn = new Function(`return ${v.value}`);
result[k] = {
mode: "string",
value: fn()
};
} else result[k] = {
mode: "raw",
value: v.value,
valueBuilt: v.valueBuilt
};
}
return result;
}
return undefined;
},
async commit () {},
get parent () {
const meta = metas[item.id];
if (meta && meta.parent?.id) {
const parent = metas[meta.parent.id];
return prodItem(metas, parent.item, page_id);
}
return null;
},
pending: [],
setProp (name, value) {},
setValue (name, value) {}
}
};
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"57NVH":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "ViRoot", ()=>ViRoot);
var _jsxDevRuntime = require("react/jsx-dev-runtime");
var _webUtils = require("web-utils");
var _loading = require("../../utils/ui/loading");
var _global = require("./render/global");
var _render = require("./render/render");
var _errorBox = require("./utils/error-box");
var _init = require("./exts/init");
const ViRoot = ({})=>{
const vi = (0, _webUtils.useGlobal)((0, _global.ViGlobal), "VI");
const local = (0, _webUtils.useLocal)({
tick: Date.now()
});
vi.tick = local.tick;
(0, _init.initExts)(vi);
if (vi.status !== "ready") return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: "flex flex-1 flex-col relative",
children: /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _loading.Loading), {
backdrop: false
}, void 0, false, {
fileName: "src/nova/vi/root.tsx",
lineNumber: 19,
columnNumber: 9
}, undefined)
}, void 0, false, {
fileName: "src/nova/vi/root.tsx",
lineNumber: 18,
columnNumber: 7
}, undefined);
const is_layout = !!vi.layout?.entry && vi.layout.entry.length > 0;
let entry = vi.entry;
if (is_layout && vi.layout?.entry) entry = vi.layout?.entry;
return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)("div", {
className: "flex flex-1 flex-col relative",
children: Array.isArray(entry) && entry.map((id)=>{
const meta = is_layout ? vi.layout?.meta[id] : vi.meta[id];
if (meta) return /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _errorBox.ErrorBox), {
children: /*#__PURE__*/ (0, _jsxDevRuntime.jsxDEV)((0, _render.ViRender), {
meta: meta,
is_layout: is_layout,
depth: 0
}, void 0, false, {
fileName: "src/nova/vi/root.tsx",
lineNumber: 38,
columnNumber: 17
}, undefined)
}, meta.item.id, false, {
fileName: "src/nova/vi/root.tsx",
lineNumber: 37,
columnNumber: 15
}, undefined);
return null;
})
}, void 0, false, {
fileName: "src/nova/vi/root.tsx",
lineNumber: 31,
columnNumber: 5
}, undefined);
};
},{"react/jsx-dev-runtime":"j0wtd","web-utils":"aOKw0","../../utils/ui/loading":"jJynm","./render/global":"fx5ht","./render/render":"dPkN4","./utils/error-box":"cQ8yv","./exts/init":"jrEHB","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"jrEHB":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "initExts", ()=>initExts);
var _notif = require("./notif");
var _types = require("./types");
const initExts = async (vi)=>{
let pe = (0, _types.prasi_ext)[vi.site.id];
if (!pe) {
(0, _types.prasi_ext)[vi.site.id] = {
status: "init"
};
pe = (0, _types.prasi_ext)[vi.site.id];
}
if (pe.status === "init") {
pe.status = "loading";
if (window.parent !== window) {
const send = (msg)=>{
window.parent.postMessage({
mobile: true,
...msg
}, "*");
};
window.addEventListener("message", async ({ data: raw })=>{
console.log(raw);
typeof raw === "object" && raw.mobile;
});
send({
type: "ready"
});
}
await (0, _notif.initExtNotif)(vi, pe);
pe.status = "ready";
}
};
},{"./notif":"9yJph","./types":"6RX0z","@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"9yJph":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "initExtNotif", ()=>initExtNotif);
const w = window;
const initExtNotif = async (vi, prasi_ext)=>{
if (window.parent) {
window.addEventListener("message", async ({ data: raw })=>{
if (typeof raw === "object" && raw.mobile) {
const data = raw;
const waitUntil = async (fn)=>{
if (!w.notif?.onTap) {
let ival = null;
let i = 0;
await new Promise(()=>{
ival = setInterval(()=>{
i++;
if (i > 20) clearInterval(ival);
if (fn()) clearInterval(ival);
}, 500);
});
return;
}
};
switch(data.type){
case "notification-token":
prasi_ext.notif = {
token: data.token
};
w.notif = {
async send (data) {
if (vi && vi.site.api) return await vi.site.api._notif("send", {
type: "send",
id: typeof data.user_id === "string" ? data.user_id : data.user_id.toString(),
body: data.body,
title: data.title,
data: data.data
});
},
async register (user_id) {
if (vi && vi.site.api && prasi_ext.notif?.token) return await vi.site.api._notif("register", {
type: "register",
id: typeof user_id === "string" ? user_id : user_id.toString(),
token: prasi_ext.notif.token
});
},
onReceive (notif) {},
onTap (notif) {}
};
break;
case "notification-tap":
if (!w.notif?.onTap) {
waitUntil(()=>{
if (w.notif?.onTap) {
w.notif?.onTap(data.notif);
return true;
}
return false;
});
return;
}
if (w.notif?.onTap) w.notif?.onTap(data.notif);
break;
case "notification-receive":
if (!w.notif?.onReceive) waitUntil(()=>{
if (w.notif?.onReceive) {
w.notif?.onReceive(data.notif);
return true;
}
return false;
});
if (w.notif?.onReceive) w.notif?.onReceive(data.notif);
break;
}
}
});
window.parent.postMessage({
mobile: true,
type: "ready"
}, "*");
}
w.notif = {
async send (data) {
if (vi && vi.site.api) return await vi.site.api._notif("send", {
type: "send",
id: typeof data.user_id === "string" ? data.user_id : data.user_id.toString(),
body: data.body,
title: data.title,
data: data.data
});
}
};
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"6RX0z":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "prasi_ext", ()=>prasi_ext);
const w = window;
if (!w.prasi_ext) w.prasi_ext = {};
const prasi_ext = w.prasi_ext;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"lwmMb"}],"21HNT":[function(require,module,exports) {
module.exports = Promise.resolve(module.bundle.root("85Wzk"));
},{}],"efzlw":[function(require,module,exports) {
module.exports = require("6561ac3ae69bd7f3")(require("599d5a8333850fee").getBundleURL("2E3Jw") + "y-pojo.d28b9ce4.js").catch((err)=>{
delete module.bundle.cache[module.id];
throw err;
}).then(()=>module.bundle.root("4YkP0"));
},{"6561ac3ae69bd7f3":"bQCon","599d5a8333850fee":"f17Mo"}]},[], null, "parcelRequire2d1f")
//# sourceMappingURL=vi.921ac197.js.map