8949 lines
294 KiB
JavaScript
8949 lines
294 KiB
JavaScript
"use strict";
|
|
var _export_sfc = (sfc, props) => {
|
|
const target = sfc.__vccOpts || sfc;
|
|
for (const [key, val] of props) {
|
|
target[key] = val;
|
|
}
|
|
return target;
|
|
};
|
|
function makeMap(str, expectsLowerCase) {
|
|
const map = /* @__PURE__ */ Object.create(null);
|
|
const list = str.split(",");
|
|
for (let i2 = 0; i2 < list.length; i2++) {
|
|
map[list[i2]] = true;
|
|
}
|
|
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
|
|
}
|
|
function normalizeStyle(value) {
|
|
if (isArray(value)) {
|
|
const res = {};
|
|
for (let i2 = 0; i2 < value.length; i2++) {
|
|
const item = value[i2];
|
|
const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
|
if (normalized) {
|
|
for (const key in normalized) {
|
|
res[key] = normalized[key];
|
|
}
|
|
}
|
|
}
|
|
return res;
|
|
} else if (isString(value)) {
|
|
return value;
|
|
} else if (isObject$1(value)) {
|
|
return value;
|
|
}
|
|
}
|
|
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
const propertyDelimiterRE = /:(.+)/;
|
|
function parseStringStyle(cssText) {
|
|
const ret = {};
|
|
cssText.split(listDelimiterRE).forEach((item) => {
|
|
if (item) {
|
|
const tmp = item.split(propertyDelimiterRE);
|
|
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
}
|
|
});
|
|
return ret;
|
|
}
|
|
function normalizeClass(value) {
|
|
let res = "";
|
|
if (isString(value)) {
|
|
res = value;
|
|
} else if (isArray(value)) {
|
|
for (let i2 = 0; i2 < value.length; i2++) {
|
|
const normalized = normalizeClass(value[i2]);
|
|
if (normalized) {
|
|
res += normalized + " ";
|
|
}
|
|
}
|
|
} else if (isObject$1(value)) {
|
|
for (const name in value) {
|
|
if (value[name]) {
|
|
res += name + " ";
|
|
}
|
|
}
|
|
}
|
|
return res.trim();
|
|
}
|
|
const toDisplayString = (val) => {
|
|
return isString(val) ? val : val == null ? "" : isArray(val) || isObject$1(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
|
|
};
|
|
const replacer = (_key, val) => {
|
|
if (val && val.__v_isRef) {
|
|
return replacer(_key, val.value);
|
|
} else if (isMap(val)) {
|
|
return {
|
|
[`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2]) => {
|
|
entries[`${key} =>`] = val2;
|
|
return entries;
|
|
}, {})
|
|
};
|
|
} else if (isSet(val)) {
|
|
return {
|
|
[`Set(${val.size})`]: [...val.values()]
|
|
};
|
|
} else if (isObject$1(val) && !isArray(val) && !isPlainObject$1(val)) {
|
|
return String(val);
|
|
}
|
|
return val;
|
|
};
|
|
const EMPTY_OBJ = Object.freeze({});
|
|
const EMPTY_ARR = Object.freeze([]);
|
|
const NOOP = () => {
|
|
};
|
|
const NO = () => false;
|
|
const onRE = /^on[^a-z]/;
|
|
const isOn = (key) => onRE.test(key);
|
|
const isModelListener = (key) => key.startsWith("onUpdate:");
|
|
const extend = Object.assign;
|
|
const remove = (arr, el) => {
|
|
const i2 = arr.indexOf(el);
|
|
if (i2 > -1) {
|
|
arr.splice(i2, 1);
|
|
}
|
|
};
|
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
const isArray = Array.isArray;
|
|
const isMap = (val) => toTypeString(val) === "[object Map]";
|
|
const isSet = (val) => toTypeString(val) === "[object Set]";
|
|
const isFunction = (val) => typeof val === "function";
|
|
const isString = (val) => typeof val === "string";
|
|
const isSymbol = (val) => typeof val === "symbol";
|
|
const isObject$1 = (val) => val !== null && typeof val === "object";
|
|
const isPromise = (val) => {
|
|
return isObject$1(val) && isFunction(val.then) && isFunction(val.catch);
|
|
};
|
|
const objectToString = Object.prototype.toString;
|
|
const toTypeString = (value) => objectToString.call(value);
|
|
const toRawType = (value) => {
|
|
return toTypeString(value).slice(8, -1);
|
|
};
|
|
const isPlainObject$1 = (val) => toTypeString(val) === "[object Object]";
|
|
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
const isReservedProp = /* @__PURE__ */ makeMap(
|
|
",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
|
|
);
|
|
const isBuiltInDirective = /* @__PURE__ */ makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo");
|
|
const cacheStringFunction = (fn) => {
|
|
const cache = /* @__PURE__ */ Object.create(null);
|
|
return (str) => {
|
|
const hit = cache[str];
|
|
return hit || (cache[str] = fn(str));
|
|
};
|
|
};
|
|
const camelizeRE = /-(\w)/g;
|
|
const camelize = cacheStringFunction((str) => {
|
|
return str.replace(camelizeRE, (_2, c2) => c2 ? c2.toUpperCase() : "");
|
|
});
|
|
const hyphenateRE = /\B([A-Z])/g;
|
|
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
|
|
const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
|
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
const invokeArrayFns$1 = (fns, arg) => {
|
|
for (let i2 = 0; i2 < fns.length; i2++) {
|
|
fns[i2](arg);
|
|
}
|
|
};
|
|
const def = (obj, key, value) => {
|
|
Object.defineProperty(obj, key, {
|
|
configurable: true,
|
|
enumerable: false,
|
|
value
|
|
});
|
|
};
|
|
const toNumber = (val) => {
|
|
const n2 = parseFloat(val);
|
|
return isNaN(n2) ? val : n2;
|
|
};
|
|
const LINEFEED = "\n";
|
|
const SLOT_DEFAULT_NAME = "d";
|
|
const ON_SHOW = "onShow";
|
|
const ON_HIDE = "onHide";
|
|
const ON_LAUNCH = "onLaunch";
|
|
const ON_ERROR = "onError";
|
|
const ON_THEME_CHANGE = "onThemeChange";
|
|
const ON_PAGE_NOT_FOUND = "onPageNotFound";
|
|
const ON_UNHANDLE_REJECTION = "onUnhandledRejection";
|
|
const ON_LOAD = "onLoad";
|
|
const ON_READY = "onReady";
|
|
const ON_UNLOAD = "onUnload";
|
|
const ON_INIT = "onInit";
|
|
const ON_SAVE_EXIT_STATE = "onSaveExitState";
|
|
const ON_RESIZE = "onResize";
|
|
const ON_BACK_PRESS = "onBackPress";
|
|
const ON_PAGE_SCROLL = "onPageScroll";
|
|
const ON_TAB_ITEM_TAP = "onTabItemTap";
|
|
const ON_REACH_BOTTOM = "onReachBottom";
|
|
const ON_PULL_DOWN_REFRESH = "onPullDownRefresh";
|
|
const ON_SHARE_TIMELINE = "onShareTimeline";
|
|
const ON_ADD_TO_FAVORITES = "onAddToFavorites";
|
|
const ON_SHARE_APP_MESSAGE = "onShareAppMessage";
|
|
const ON_NAVIGATION_BAR_BUTTON_TAP = "onNavigationBarButtonTap";
|
|
const ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED = "onNavigationBarSearchInputClicked";
|
|
const ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED = "onNavigationBarSearchInputChanged";
|
|
const ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED = "onNavigationBarSearchInputConfirmed";
|
|
const ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED = "onNavigationBarSearchInputFocusChanged";
|
|
const customizeRE = /:/g;
|
|
function customizeEvent(str) {
|
|
return camelize(str.replace(customizeRE, "-"));
|
|
}
|
|
function hasLeadingSlash(str) {
|
|
return str.indexOf("/") === 0;
|
|
}
|
|
function addLeadingSlash(str) {
|
|
return hasLeadingSlash(str) ? str : "/" + str;
|
|
}
|
|
const invokeArrayFns = (fns, arg) => {
|
|
let ret;
|
|
for (let i2 = 0; i2 < fns.length; i2++) {
|
|
ret = fns[i2](arg);
|
|
}
|
|
return ret;
|
|
};
|
|
function once(fn, ctx = null) {
|
|
let res;
|
|
return (...args) => {
|
|
if (fn) {
|
|
res = fn.apply(ctx, args);
|
|
fn = null;
|
|
}
|
|
return res;
|
|
};
|
|
}
|
|
function getValueByDataPath(obj, path) {
|
|
if (!isString(path)) {
|
|
return;
|
|
}
|
|
path = path.replace(/\[(\d+)\]/g, ".$1");
|
|
const parts = path.split(".");
|
|
let key = parts[0];
|
|
if (!obj) {
|
|
obj = {};
|
|
}
|
|
if (parts.length === 1) {
|
|
return obj[key];
|
|
}
|
|
return getValueByDataPath(obj[key], parts.slice(1).join("."));
|
|
}
|
|
function sortObject(obj) {
|
|
let sortObj = {};
|
|
if (isPlainObject$1(obj)) {
|
|
Object.keys(obj).sort().forEach((key) => {
|
|
const _key = key;
|
|
sortObj[_key] = obj[_key];
|
|
});
|
|
}
|
|
return !Object.keys(sortObj) ? obj : sortObj;
|
|
}
|
|
const encode = encodeURIComponent;
|
|
function stringifyQuery(obj, encodeStr = encode) {
|
|
const res = obj ? Object.keys(obj).map((key) => {
|
|
let val = obj[key];
|
|
if (typeof val === void 0 || val === null) {
|
|
val = "";
|
|
} else if (isPlainObject$1(val)) {
|
|
val = JSON.stringify(val);
|
|
}
|
|
return encodeStr(key) + "=" + encodeStr(val);
|
|
}).filter((x2) => x2.length > 0).join("&") : null;
|
|
return res ? `?${res}` : "";
|
|
}
|
|
const PAGE_HOOKS = [
|
|
ON_INIT,
|
|
ON_LOAD,
|
|
ON_SHOW,
|
|
ON_HIDE,
|
|
ON_UNLOAD,
|
|
ON_BACK_PRESS,
|
|
ON_PAGE_SCROLL,
|
|
ON_TAB_ITEM_TAP,
|
|
ON_REACH_BOTTOM,
|
|
ON_PULL_DOWN_REFRESH,
|
|
ON_SHARE_TIMELINE,
|
|
ON_SHARE_APP_MESSAGE,
|
|
ON_ADD_TO_FAVORITES,
|
|
ON_SAVE_EXIT_STATE,
|
|
ON_NAVIGATION_BAR_BUTTON_TAP,
|
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED,
|
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED,
|
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
|
|
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED
|
|
];
|
|
function isRootHook(name) {
|
|
return PAGE_HOOKS.indexOf(name) > -1;
|
|
}
|
|
const UniLifecycleHooks = [
|
|
ON_SHOW,
|
|
ON_HIDE,
|
|
ON_LAUNCH,
|
|
ON_ERROR,
|
|
ON_THEME_CHANGE,
|
|
ON_PAGE_NOT_FOUND,
|
|
ON_UNHANDLE_REJECTION,
|
|
ON_INIT,
|
|
ON_LOAD,
|
|
ON_READY,
|
|
ON_UNLOAD,
|
|
ON_RESIZE,
|
|
ON_BACK_PRESS,
|
|
ON_PAGE_SCROLL,
|
|
ON_TAB_ITEM_TAP,
|
|
ON_REACH_BOTTOM,
|
|
ON_PULL_DOWN_REFRESH,
|
|
ON_SHARE_TIMELINE,
|
|
ON_ADD_TO_FAVORITES,
|
|
ON_SHARE_APP_MESSAGE,
|
|
ON_SAVE_EXIT_STATE,
|
|
ON_NAVIGATION_BAR_BUTTON_TAP,
|
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED,
|
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED,
|
|
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
|
|
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED
|
|
];
|
|
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = /* @__PURE__ */ (() => {
|
|
return {
|
|
onPageScroll: 1,
|
|
onShareAppMessage: 1 << 1,
|
|
onShareTimeline: 1 << 2
|
|
};
|
|
})();
|
|
let vueApp;
|
|
const createVueAppHooks = [];
|
|
function onCreateVueApp(hook) {
|
|
if (vueApp) {
|
|
return hook(vueApp);
|
|
}
|
|
createVueAppHooks.push(hook);
|
|
}
|
|
function invokeCreateVueAppHook(app) {
|
|
vueApp = app;
|
|
createVueAppHooks.forEach((hook) => hook(app));
|
|
}
|
|
const E$1 = function() {
|
|
};
|
|
E$1.prototype = {
|
|
on: function(name, callback, ctx) {
|
|
var e2 = this.e || (this.e = {});
|
|
(e2[name] || (e2[name] = [])).push({
|
|
fn: callback,
|
|
ctx
|
|
});
|
|
return this;
|
|
},
|
|
once: function(name, callback, ctx) {
|
|
var self2 = this;
|
|
function listener() {
|
|
self2.off(name, listener);
|
|
callback.apply(ctx, arguments);
|
|
}
|
|
listener._ = callback;
|
|
return this.on(name, listener, ctx);
|
|
},
|
|
emit: function(name) {
|
|
var data = [].slice.call(arguments, 1);
|
|
var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
|
|
var i2 = 0;
|
|
var len = evtArr.length;
|
|
for (i2; i2 < len; i2++) {
|
|
evtArr[i2].fn.apply(evtArr[i2].ctx, data);
|
|
}
|
|
return this;
|
|
},
|
|
off: function(name, callback) {
|
|
var e2 = this.e || (this.e = {});
|
|
var evts = e2[name];
|
|
var liveEvents = [];
|
|
if (evts && callback) {
|
|
for (var i2 = 0, len = evts.length; i2 < len; i2++) {
|
|
if (evts[i2].fn !== callback && evts[i2].fn._ !== callback)
|
|
liveEvents.push(evts[i2]);
|
|
}
|
|
}
|
|
liveEvents.length ? e2[name] = liveEvents : delete e2[name];
|
|
return this;
|
|
}
|
|
};
|
|
var E$1$1 = E$1;
|
|
const LOCALE_ZH_HANS = "zh-Hans";
|
|
const LOCALE_ZH_HANT = "zh-Hant";
|
|
const LOCALE_EN = "en";
|
|
const LOCALE_FR = "fr";
|
|
const LOCALE_ES = "es";
|
|
function include(str, parts) {
|
|
return !!parts.find((part) => str.indexOf(part) !== -1);
|
|
}
|
|
function startsWith(str, parts) {
|
|
return parts.find((part) => str.indexOf(part) === 0);
|
|
}
|
|
function normalizeLocale(locale, messages) {
|
|
if (!locale) {
|
|
return;
|
|
}
|
|
locale = locale.trim().replace(/_/g, "-");
|
|
if (messages && messages[locale]) {
|
|
return locale;
|
|
}
|
|
locale = locale.toLowerCase();
|
|
if (locale === "chinese") {
|
|
return LOCALE_ZH_HANS;
|
|
}
|
|
if (locale.indexOf("zh") === 0) {
|
|
if (locale.indexOf("-hans") > -1) {
|
|
return LOCALE_ZH_HANS;
|
|
}
|
|
if (locale.indexOf("-hant") > -1) {
|
|
return LOCALE_ZH_HANT;
|
|
}
|
|
if (include(locale, ["-tw", "-hk", "-mo", "-cht"])) {
|
|
return LOCALE_ZH_HANT;
|
|
}
|
|
return LOCALE_ZH_HANS;
|
|
}
|
|
const lang = startsWith(locale, [LOCALE_EN, LOCALE_FR, LOCALE_ES]);
|
|
if (lang) {
|
|
return lang;
|
|
}
|
|
}
|
|
function getBaseSystemInfo() {
|
|
return wx.getSystemInfoSync();
|
|
}
|
|
function validateProtocolFail(name, msg) {
|
|
console.warn(`${name}: ${msg}`);
|
|
}
|
|
function validateProtocol(name, data, protocol, onFail) {
|
|
if (!onFail) {
|
|
onFail = validateProtocolFail;
|
|
}
|
|
for (const key in protocol) {
|
|
const errMsg = validateProp$1(key, data[key], protocol[key], !hasOwn(data, key));
|
|
if (isString(errMsg)) {
|
|
onFail(name, errMsg);
|
|
}
|
|
}
|
|
}
|
|
function validateProtocols(name, args, protocol, onFail) {
|
|
if (!protocol) {
|
|
return;
|
|
}
|
|
if (!isArray(protocol)) {
|
|
return validateProtocol(name, args[0] || /* @__PURE__ */ Object.create(null), protocol, onFail);
|
|
}
|
|
const len = protocol.length;
|
|
const argsLen = args.length;
|
|
for (let i2 = 0; i2 < len; i2++) {
|
|
const opts = protocol[i2];
|
|
const data = /* @__PURE__ */ Object.create(null);
|
|
if (argsLen > i2) {
|
|
data[opts.name] = args[i2];
|
|
}
|
|
validateProtocol(name, data, { [opts.name]: opts }, onFail);
|
|
}
|
|
}
|
|
function validateProp$1(name, value, prop, isAbsent) {
|
|
if (!isPlainObject$1(prop)) {
|
|
prop = { type: prop };
|
|
}
|
|
const { type, required, validator } = prop;
|
|
if (required && isAbsent) {
|
|
return 'Missing required args: "' + name + '"';
|
|
}
|
|
if (value == null && !required) {
|
|
return;
|
|
}
|
|
if (type != null) {
|
|
let isValid = false;
|
|
const types = isArray(type) ? type : [type];
|
|
const expectedTypes = [];
|
|
for (let i2 = 0; i2 < types.length && !isValid; i2++) {
|
|
const { valid, expectedType } = assertType$1(value, types[i2]);
|
|
expectedTypes.push(expectedType || "");
|
|
isValid = valid;
|
|
}
|
|
if (!isValid) {
|
|
return getInvalidTypeMessage$1(name, value, expectedTypes);
|
|
}
|
|
}
|
|
if (validator) {
|
|
return validator(value);
|
|
}
|
|
}
|
|
const isSimpleType$1 = /* @__PURE__ */ makeMap("String,Number,Boolean,Function,Symbol");
|
|
function assertType$1(value, type) {
|
|
let valid;
|
|
const expectedType = getType$1(type);
|
|
if (isSimpleType$1(expectedType)) {
|
|
const t2 = typeof value;
|
|
valid = t2 === expectedType.toLowerCase();
|
|
if (!valid && t2 === "object") {
|
|
valid = value instanceof type;
|
|
}
|
|
} else if (expectedType === "Object") {
|
|
valid = isObject$1(value);
|
|
} else if (expectedType === "Array") {
|
|
valid = isArray(value);
|
|
} else {
|
|
{
|
|
valid = value instanceof type;
|
|
}
|
|
}
|
|
return {
|
|
valid,
|
|
expectedType
|
|
};
|
|
}
|
|
function getInvalidTypeMessage$1(name, value, expectedTypes) {
|
|
let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`;
|
|
const expectedType = expectedTypes[0];
|
|
const receivedType = toRawType(value);
|
|
const expectedValue = styleValue$1(value, expectedType);
|
|
const receivedValue = styleValue$1(value, receivedType);
|
|
if (expectedTypes.length === 1 && isExplicable$1(expectedType) && !isBoolean$1(expectedType, receivedType)) {
|
|
message += ` with value ${expectedValue}`;
|
|
}
|
|
message += `, got ${receivedType} `;
|
|
if (isExplicable$1(receivedType)) {
|
|
message += `with value ${receivedValue}.`;
|
|
}
|
|
return message;
|
|
}
|
|
function getType$1(ctor) {
|
|
const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
|
|
return match ? match[1] : "";
|
|
}
|
|
function styleValue$1(value, type) {
|
|
if (type === "String") {
|
|
return `"${value}"`;
|
|
} else if (type === "Number") {
|
|
return `${Number(value)}`;
|
|
} else {
|
|
return `${value}`;
|
|
}
|
|
}
|
|
function isExplicable$1(type) {
|
|
const explicitTypes = ["string", "number", "boolean"];
|
|
return explicitTypes.some((elem) => type.toLowerCase() === elem);
|
|
}
|
|
function isBoolean$1(...args) {
|
|
return args.some((elem) => elem.toLowerCase() === "boolean");
|
|
}
|
|
function tryCatch(fn) {
|
|
return function() {
|
|
try {
|
|
return fn.apply(fn, arguments);
|
|
} catch (e2) {
|
|
console.error(e2);
|
|
}
|
|
};
|
|
}
|
|
let invokeCallbackId = 1;
|
|
const invokeCallbacks = {};
|
|
function addInvokeCallback(id, name, callback, keepAlive = false) {
|
|
invokeCallbacks[id] = {
|
|
name,
|
|
keepAlive,
|
|
callback
|
|
};
|
|
return id;
|
|
}
|
|
function invokeCallback(id, res, extras) {
|
|
if (typeof id === "number") {
|
|
const opts = invokeCallbacks[id];
|
|
if (opts) {
|
|
if (!opts.keepAlive) {
|
|
delete invokeCallbacks[id];
|
|
}
|
|
return opts.callback(res, extras);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
const API_SUCCESS = "success";
|
|
const API_FAIL = "fail";
|
|
const API_COMPLETE = "complete";
|
|
function getApiCallbacks(args) {
|
|
const apiCallbacks = {};
|
|
for (const name in args) {
|
|
const fn = args[name];
|
|
if (isFunction(fn)) {
|
|
apiCallbacks[name] = tryCatch(fn);
|
|
delete args[name];
|
|
}
|
|
}
|
|
return apiCallbacks;
|
|
}
|
|
function normalizeErrMsg$1(errMsg, name) {
|
|
if (!errMsg || errMsg.indexOf(":fail") === -1) {
|
|
return name + ":ok";
|
|
}
|
|
return name + errMsg.substring(errMsg.indexOf(":fail"));
|
|
}
|
|
function createAsyncApiCallback(name, args = {}, { beforeAll, beforeSuccess } = {}) {
|
|
if (!isPlainObject$1(args)) {
|
|
args = {};
|
|
}
|
|
const { success, fail, complete } = getApiCallbacks(args);
|
|
const hasSuccess = isFunction(success);
|
|
const hasFail = isFunction(fail);
|
|
const hasComplete = isFunction(complete);
|
|
const callbackId = invokeCallbackId++;
|
|
addInvokeCallback(callbackId, name, (res) => {
|
|
res = res || {};
|
|
res.errMsg = normalizeErrMsg$1(res.errMsg, name);
|
|
isFunction(beforeAll) && beforeAll(res);
|
|
if (res.errMsg === name + ":ok") {
|
|
isFunction(beforeSuccess) && beforeSuccess(res, args);
|
|
hasSuccess && success(res);
|
|
} else {
|
|
hasFail && fail(res);
|
|
}
|
|
hasComplete && complete(res);
|
|
});
|
|
return callbackId;
|
|
}
|
|
const HOOK_SUCCESS = "success";
|
|
const HOOK_FAIL = "fail";
|
|
const HOOK_COMPLETE = "complete";
|
|
const globalInterceptors = {};
|
|
const scopedInterceptors = {};
|
|
function wrapperHook(hook) {
|
|
return function(data) {
|
|
return hook(data) || data;
|
|
};
|
|
}
|
|
function queue$1(hooks, data) {
|
|
let promise = false;
|
|
for (let i2 = 0; i2 < hooks.length; i2++) {
|
|
const hook = hooks[i2];
|
|
if (promise) {
|
|
promise = Promise.resolve(wrapperHook(hook));
|
|
} else {
|
|
const res = hook(data);
|
|
if (isPromise(res)) {
|
|
promise = Promise.resolve(res);
|
|
}
|
|
if (res === false) {
|
|
return {
|
|
then() {
|
|
},
|
|
catch() {
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|
|
return promise || {
|
|
then(callback) {
|
|
return callback(data);
|
|
},
|
|
catch() {
|
|
}
|
|
};
|
|
}
|
|
function wrapperOptions(interceptors2, options = {}) {
|
|
[HOOK_SUCCESS, HOOK_FAIL, HOOK_COMPLETE].forEach((name) => {
|
|
const hooks = interceptors2[name];
|
|
if (!isArray(hooks)) {
|
|
return;
|
|
}
|
|
const oldCallback = options[name];
|
|
options[name] = function callbackInterceptor(res) {
|
|
queue$1(hooks, res).then((res2) => {
|
|
return isFunction(oldCallback) && oldCallback(res2) || res2;
|
|
});
|
|
};
|
|
});
|
|
return options;
|
|
}
|
|
function wrapperReturnValue(method, returnValue) {
|
|
const returnValueHooks = [];
|
|
if (isArray(globalInterceptors.returnValue)) {
|
|
returnValueHooks.push(...globalInterceptors.returnValue);
|
|
}
|
|
const interceptor = scopedInterceptors[method];
|
|
if (interceptor && isArray(interceptor.returnValue)) {
|
|
returnValueHooks.push(...interceptor.returnValue);
|
|
}
|
|
returnValueHooks.forEach((hook) => {
|
|
returnValue = hook(returnValue) || returnValue;
|
|
});
|
|
return returnValue;
|
|
}
|
|
function getApiInterceptorHooks(method) {
|
|
const interceptor = /* @__PURE__ */ Object.create(null);
|
|
Object.keys(globalInterceptors).forEach((hook) => {
|
|
if (hook !== "returnValue") {
|
|
interceptor[hook] = globalInterceptors[hook].slice();
|
|
}
|
|
});
|
|
const scopedInterceptor = scopedInterceptors[method];
|
|
if (scopedInterceptor) {
|
|
Object.keys(scopedInterceptor).forEach((hook) => {
|
|
if (hook !== "returnValue") {
|
|
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
|
|
}
|
|
});
|
|
}
|
|
return interceptor;
|
|
}
|
|
function invokeApi(method, api, options, params) {
|
|
const interceptor = getApiInterceptorHooks(method);
|
|
if (interceptor && Object.keys(interceptor).length) {
|
|
if (isArray(interceptor.invoke)) {
|
|
const res = queue$1(interceptor.invoke, options);
|
|
return res.then((options2) => {
|
|
return api(wrapperOptions(interceptor, options2), ...params);
|
|
});
|
|
} else {
|
|
return api(wrapperOptions(interceptor, options), ...params);
|
|
}
|
|
}
|
|
return api(options, ...params);
|
|
}
|
|
function hasCallback(args) {
|
|
if (isPlainObject$1(args) && [API_SUCCESS, API_FAIL, API_COMPLETE].find((cb) => isFunction(args[cb]))) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function handlePromise(promise) {
|
|
return promise;
|
|
}
|
|
function promisify$1(name, fn) {
|
|
return (args = {}, ...rest) => {
|
|
if (hasCallback(args)) {
|
|
return wrapperReturnValue(name, invokeApi(name, fn, args, rest));
|
|
}
|
|
return wrapperReturnValue(name, handlePromise(new Promise((resolve2, reject) => {
|
|
invokeApi(name, fn, extend(args, { success: resolve2, fail: reject }), rest);
|
|
})));
|
|
};
|
|
}
|
|
function formatApiArgs(args, options) {
|
|
const params = args[0];
|
|
if (!options || !isPlainObject$1(options.formatArgs) && isPlainObject$1(params)) {
|
|
return;
|
|
}
|
|
const formatArgs = options.formatArgs;
|
|
const keys = Object.keys(formatArgs);
|
|
for (let i2 = 0; i2 < keys.length; i2++) {
|
|
const name = keys[i2];
|
|
const formatterOrDefaultValue = formatArgs[name];
|
|
if (isFunction(formatterOrDefaultValue)) {
|
|
const errMsg = formatterOrDefaultValue(args[0][name], params);
|
|
if (isString(errMsg)) {
|
|
return errMsg;
|
|
}
|
|
} else {
|
|
if (!hasOwn(params, name)) {
|
|
params[name] = formatterOrDefaultValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function invokeSuccess(id, name, res) {
|
|
return invokeCallback(id, extend(res || {}, { errMsg: name + ":ok" }));
|
|
}
|
|
function invokeFail(id, name, errMsg, errRes) {
|
|
return invokeCallback(id, extend({ errMsg: name + ":fail" + (errMsg ? " " + errMsg : "") }, errRes));
|
|
}
|
|
function beforeInvokeApi(name, args, protocol, options) {
|
|
{
|
|
validateProtocols(name, args, protocol);
|
|
}
|
|
if (options && options.beforeInvoke) {
|
|
const errMsg2 = options.beforeInvoke(args);
|
|
if (isString(errMsg2)) {
|
|
return errMsg2;
|
|
}
|
|
}
|
|
const errMsg = formatApiArgs(args, options);
|
|
if (errMsg) {
|
|
return errMsg;
|
|
}
|
|
}
|
|
function normalizeErrMsg(errMsg) {
|
|
if (!errMsg || isString(errMsg)) {
|
|
return errMsg;
|
|
}
|
|
if (errMsg.stack) {
|
|
console.error(errMsg.message + LINEFEED + errMsg.stack);
|
|
return errMsg.message;
|
|
}
|
|
return errMsg;
|
|
}
|
|
function wrapperTaskApi(name, fn, protocol, options) {
|
|
return (args) => {
|
|
const id = createAsyncApiCallback(name, args, options);
|
|
const errMsg = beforeInvokeApi(name, [args], protocol, options);
|
|
if (errMsg) {
|
|
return invokeFail(id, name, errMsg);
|
|
}
|
|
return fn(args, {
|
|
resolve: (res) => invokeSuccess(id, name, res),
|
|
reject: (errMsg2, errRes) => invokeFail(id, name, normalizeErrMsg(errMsg2), errRes)
|
|
});
|
|
};
|
|
}
|
|
function wrapperSyncApi(name, fn, protocol, options) {
|
|
return (...args) => {
|
|
const errMsg = beforeInvokeApi(name, args, protocol, options);
|
|
if (errMsg) {
|
|
throw new Error(errMsg);
|
|
}
|
|
return fn.apply(null, args);
|
|
};
|
|
}
|
|
function wrapperAsyncApi(name, fn, protocol, options) {
|
|
return wrapperTaskApi(name, fn, protocol, options);
|
|
}
|
|
function defineSyncApi(name, fn, protocol, options) {
|
|
return wrapperSyncApi(name, fn, protocol, options);
|
|
}
|
|
function defineAsyncApi(name, fn, protocol, options) {
|
|
return promisify$1(name, wrapperAsyncApi(name, fn, protocol, options));
|
|
}
|
|
const API_UPX2PX = "upx2px";
|
|
const Upx2pxProtocol = [
|
|
{
|
|
name: "upx",
|
|
type: [Number, String],
|
|
required: true
|
|
}
|
|
];
|
|
const EPS = 1e-4;
|
|
const BASE_DEVICE_WIDTH = 750;
|
|
let isIOS = false;
|
|
let deviceWidth = 0;
|
|
let deviceDPR = 0;
|
|
function checkDeviceWidth() {
|
|
const { platform, pixelRatio, windowWidth } = getBaseSystemInfo();
|
|
deviceWidth = windowWidth;
|
|
deviceDPR = pixelRatio;
|
|
isIOS = platform === "ios";
|
|
}
|
|
const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
|
|
if (deviceWidth === 0) {
|
|
checkDeviceWidth();
|
|
}
|
|
number = Number(number);
|
|
if (number === 0) {
|
|
return 0;
|
|
}
|
|
let width = newDeviceWidth || deviceWidth;
|
|
let result = number / BASE_DEVICE_WIDTH * width;
|
|
if (result < 0) {
|
|
result = -result;
|
|
}
|
|
result = Math.floor(result + EPS);
|
|
if (result === 0) {
|
|
if (deviceDPR === 1 || !isIOS) {
|
|
result = 1;
|
|
} else {
|
|
result = 0.5;
|
|
}
|
|
}
|
|
return number < 0 ? -result : result;
|
|
}, Upx2pxProtocol);
|
|
const API_ADD_INTERCEPTOR = "addInterceptor";
|
|
const API_REMOVE_INTERCEPTOR = "removeInterceptor";
|
|
const AddInterceptorProtocol = [
|
|
{
|
|
name: "method",
|
|
type: [String, Object],
|
|
required: true
|
|
}
|
|
];
|
|
const RemoveInterceptorProtocol = AddInterceptorProtocol;
|
|
function mergeInterceptorHook(interceptors2, interceptor) {
|
|
Object.keys(interceptor).forEach((hook) => {
|
|
if (isFunction(interceptor[hook])) {
|
|
interceptors2[hook] = mergeHook(interceptors2[hook], interceptor[hook]);
|
|
}
|
|
});
|
|
}
|
|
function removeInterceptorHook(interceptors2, interceptor) {
|
|
if (!interceptors2 || !interceptor) {
|
|
return;
|
|
}
|
|
Object.keys(interceptor).forEach((name) => {
|
|
const hooks = interceptors2[name];
|
|
const hook = interceptor[name];
|
|
if (isArray(hooks) && isFunction(hook)) {
|
|
remove(hooks, hook);
|
|
}
|
|
});
|
|
}
|
|
function mergeHook(parentVal, childVal) {
|
|
const res = childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal;
|
|
return res ? dedupeHooks(res) : res;
|
|
}
|
|
function dedupeHooks(hooks) {
|
|
const res = [];
|
|
for (let i2 = 0; i2 < hooks.length; i2++) {
|
|
if (res.indexOf(hooks[i2]) === -1) {
|
|
res.push(hooks[i2]);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
const addInterceptor = defineSyncApi(API_ADD_INTERCEPTOR, (method, interceptor) => {
|
|
if (isString(method) && isPlainObject$1(interceptor)) {
|
|
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
|
|
} else if (isPlainObject$1(method)) {
|
|
mergeInterceptorHook(globalInterceptors, method);
|
|
}
|
|
}, AddInterceptorProtocol);
|
|
const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interceptor) => {
|
|
if (isString(method)) {
|
|
if (isPlainObject$1(interceptor)) {
|
|
removeInterceptorHook(scopedInterceptors[method], interceptor);
|
|
} else {
|
|
delete scopedInterceptors[method];
|
|
}
|
|
} else if (isPlainObject$1(method)) {
|
|
removeInterceptorHook(globalInterceptors, method);
|
|
}
|
|
}, RemoveInterceptorProtocol);
|
|
const interceptors = {};
|
|
const API_ON = "$on";
|
|
const OnProtocol = [
|
|
{
|
|
name: "event",
|
|
type: String,
|
|
required: true
|
|
},
|
|
{
|
|
name: "callback",
|
|
type: Function,
|
|
required: true
|
|
}
|
|
];
|
|
const API_ONCE = "$once";
|
|
const OnceProtocol = OnProtocol;
|
|
const API_OFF = "$off";
|
|
const OffProtocol = [
|
|
{
|
|
name: "event",
|
|
type: [String, Array]
|
|
},
|
|
{
|
|
name: "callback",
|
|
type: Function
|
|
}
|
|
];
|
|
const API_EMIT = "$emit";
|
|
const EmitProtocol = [
|
|
{
|
|
name: "event",
|
|
type: String,
|
|
required: true
|
|
}
|
|
];
|
|
const emitter = new E$1$1();
|
|
const $on = defineSyncApi(API_ON, (name, callback) => {
|
|
emitter.on(name, callback);
|
|
return () => emitter.off(name, callback);
|
|
}, OnProtocol);
|
|
const $once = defineSyncApi(API_ONCE, (name, callback) => {
|
|
emitter.once(name, callback);
|
|
return () => emitter.off(name, callback);
|
|
}, OnceProtocol);
|
|
const $off = defineSyncApi(API_OFF, (name, callback) => {
|
|
if (!name) {
|
|
emitter.e = {};
|
|
return;
|
|
}
|
|
if (!isArray(name))
|
|
name = [name];
|
|
name.forEach((n2) => emitter.off(n2, callback));
|
|
}, OffProtocol);
|
|
const $emit = defineSyncApi(API_EMIT, (name, ...args) => {
|
|
emitter.emit(name, ...args);
|
|
}, EmitProtocol);
|
|
let cid;
|
|
let cidErrMsg;
|
|
let enabled;
|
|
function normalizePushMessage(message) {
|
|
try {
|
|
return JSON.parse(message);
|
|
} catch (e2) {
|
|
}
|
|
return message;
|
|
}
|
|
function invokePushCallback(args) {
|
|
if (args.type === "enabled") {
|
|
enabled = true;
|
|
} else if (args.type === "clientId") {
|
|
cid = args.cid;
|
|
cidErrMsg = args.errMsg;
|
|
invokeGetPushCidCallbacks(cid, args.errMsg);
|
|
} else if (args.type === "pushMsg") {
|
|
const message = {
|
|
type: "receive",
|
|
data: normalizePushMessage(args.message)
|
|
};
|
|
for (let i2 = 0; i2 < onPushMessageCallbacks.length; i2++) {
|
|
const callback = onPushMessageCallbacks[i2];
|
|
callback(message);
|
|
if (message.stopped) {
|
|
break;
|
|
}
|
|
}
|
|
} else if (args.type === "click") {
|
|
onPushMessageCallbacks.forEach((callback) => {
|
|
callback({
|
|
type: "click",
|
|
data: normalizePushMessage(args.message)
|
|
});
|
|
});
|
|
}
|
|
}
|
|
const getPushCidCallbacks = [];
|
|
function invokeGetPushCidCallbacks(cid2, errMsg) {
|
|
getPushCidCallbacks.forEach((callback) => {
|
|
callback(cid2, errMsg);
|
|
});
|
|
getPushCidCallbacks.length = 0;
|
|
}
|
|
const API_GET_PUSH_CLIENT_ID = "getPushClientId";
|
|
const getPushClientId = defineAsyncApi(API_GET_PUSH_CLIENT_ID, (_2, { resolve: resolve2, reject }) => {
|
|
Promise.resolve().then(() => {
|
|
if (typeof enabled === "undefined") {
|
|
enabled = false;
|
|
cid = "";
|
|
cidErrMsg = "unipush is not enabled";
|
|
}
|
|
getPushCidCallbacks.push((cid2, errMsg) => {
|
|
if (cid2) {
|
|
resolve2({ cid: cid2 });
|
|
} else {
|
|
reject(errMsg);
|
|
}
|
|
});
|
|
if (typeof cid !== "undefined") {
|
|
invokeGetPushCidCallbacks(cid, cidErrMsg);
|
|
}
|
|
});
|
|
});
|
|
const onPushMessageCallbacks = [];
|
|
const onPushMessage = (fn) => {
|
|
if (onPushMessageCallbacks.indexOf(fn) === -1) {
|
|
onPushMessageCallbacks.push(fn);
|
|
}
|
|
};
|
|
const offPushMessage = (fn) => {
|
|
if (!fn) {
|
|
onPushMessageCallbacks.length = 0;
|
|
} else {
|
|
const index2 = onPushMessageCallbacks.indexOf(fn);
|
|
if (index2 > -1) {
|
|
onPushMessageCallbacks.splice(index2, 1);
|
|
}
|
|
}
|
|
};
|
|
const SYNC_API_RE = /^\$|getLocale|setLocale|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getDeviceInfo|getAppBaseInfo|getWindowInfo|getSystemSetting|getAppAuthorizeSetting/;
|
|
const CONTEXT_API_RE = /^create|Manager$/;
|
|
const CONTEXT_API_RE_EXC = ["createBLEConnection"];
|
|
const ASYNC_API = ["createBLEConnection"];
|
|
const CALLBACK_API_RE = /^on|^off/;
|
|
function isContextApi(name) {
|
|
return CONTEXT_API_RE.test(name) && CONTEXT_API_RE_EXC.indexOf(name) === -1;
|
|
}
|
|
function isSyncApi(name) {
|
|
return SYNC_API_RE.test(name) && ASYNC_API.indexOf(name) === -1;
|
|
}
|
|
function isCallbackApi(name) {
|
|
return CALLBACK_API_RE.test(name) && name !== "onPush";
|
|
}
|
|
function shouldPromise(name) {
|
|
if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
if (!Promise.prototype.finally) {
|
|
Promise.prototype.finally = function(onfinally) {
|
|
const promise = this.constructor;
|
|
return this.then((value) => promise.resolve(onfinally && onfinally()).then(() => value), (reason) => promise.resolve(onfinally && onfinally()).then(() => {
|
|
throw reason;
|
|
}));
|
|
};
|
|
}
|
|
function promisify(name, api) {
|
|
if (!shouldPromise(name)) {
|
|
return api;
|
|
}
|
|
if (!isFunction(api)) {
|
|
return api;
|
|
}
|
|
return function promiseApi(options = {}, ...rest) {
|
|
if (isFunction(options.success) || isFunction(options.fail) || isFunction(options.complete)) {
|
|
return wrapperReturnValue(name, invokeApi(name, api, options, rest));
|
|
}
|
|
return wrapperReturnValue(name, handlePromise(new Promise((resolve2, reject) => {
|
|
invokeApi(name, api, extend({}, options, {
|
|
success: resolve2,
|
|
fail: reject
|
|
}), rest);
|
|
})));
|
|
};
|
|
}
|
|
const CALLBACKS = ["success", "fail", "cancel", "complete"];
|
|
function initWrapper(protocols2) {
|
|
function processCallback(methodName, method, returnValue) {
|
|
return function(res) {
|
|
return method(processReturnValue(methodName, res, returnValue));
|
|
};
|
|
}
|
|
function processArgs(methodName, fromArgs, argsOption = {}, returnValue = {}, keepFromArgs = false) {
|
|
if (isPlainObject$1(fromArgs)) {
|
|
const toArgs = keepFromArgs === true ? fromArgs : {};
|
|
if (isFunction(argsOption)) {
|
|
argsOption = argsOption(fromArgs, toArgs) || {};
|
|
}
|
|
for (const key in fromArgs) {
|
|
if (hasOwn(argsOption, key)) {
|
|
let keyOption = argsOption[key];
|
|
if (isFunction(keyOption)) {
|
|
keyOption = keyOption(fromArgs[key], fromArgs, toArgs);
|
|
}
|
|
if (!keyOption) {
|
|
console.warn(`\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F ${methodName} \u6682\u4E0D\u652F\u6301 ${key}`);
|
|
} else if (isString(keyOption)) {
|
|
toArgs[keyOption] = fromArgs[key];
|
|
} else if (isPlainObject$1(keyOption)) {
|
|
toArgs[keyOption.name ? keyOption.name : key] = keyOption.value;
|
|
}
|
|
} else if (CALLBACKS.indexOf(key) !== -1) {
|
|
const callback = fromArgs[key];
|
|
if (isFunction(callback)) {
|
|
toArgs[key] = processCallback(methodName, callback, returnValue);
|
|
}
|
|
} else {
|
|
if (!keepFromArgs && !hasOwn(toArgs, key)) {
|
|
toArgs[key] = fromArgs[key];
|
|
}
|
|
}
|
|
}
|
|
return toArgs;
|
|
} else if (isFunction(fromArgs)) {
|
|
fromArgs = processCallback(methodName, fromArgs, returnValue);
|
|
}
|
|
return fromArgs;
|
|
}
|
|
function processReturnValue(methodName, res, returnValue, keepReturnValue = false) {
|
|
if (isFunction(protocols2.returnValue)) {
|
|
res = protocols2.returnValue(methodName, res);
|
|
}
|
|
return processArgs(methodName, res, returnValue, {}, keepReturnValue);
|
|
}
|
|
return function wrapper3(methodName, method) {
|
|
if (!hasOwn(protocols2, methodName)) {
|
|
return method;
|
|
}
|
|
const protocol = protocols2[methodName];
|
|
if (!protocol) {
|
|
return function() {
|
|
console.error(`\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F \u6682\u4E0D\u652F\u6301${methodName}`);
|
|
};
|
|
}
|
|
return function(arg1, arg2) {
|
|
let options = protocol;
|
|
if (isFunction(protocol)) {
|
|
options = protocol(arg1);
|
|
}
|
|
arg1 = processArgs(methodName, arg1, options.args, options.returnValue);
|
|
const args = [arg1];
|
|
if (typeof arg2 !== "undefined") {
|
|
args.push(arg2);
|
|
}
|
|
const returnValue = wx[options.name || methodName].apply(wx, args);
|
|
if (isSyncApi(methodName)) {
|
|
return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName));
|
|
}
|
|
return returnValue;
|
|
};
|
|
};
|
|
}
|
|
const getLocale = () => {
|
|
const app = getApp({ allowDefault: true });
|
|
if (app && app.$vm) {
|
|
return app.$vm.$locale;
|
|
}
|
|
return normalizeLocale(wx.getSystemInfoSync().language) || LOCALE_EN;
|
|
};
|
|
const setLocale = (locale) => {
|
|
const app = getApp();
|
|
if (!app) {
|
|
return false;
|
|
}
|
|
const oldLocale = app.$vm.$locale;
|
|
if (oldLocale !== locale) {
|
|
app.$vm.$locale = locale;
|
|
onLocaleChangeCallbacks.forEach((fn) => fn({ locale }));
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
const onLocaleChangeCallbacks = [];
|
|
const onLocaleChange = (fn) => {
|
|
if (onLocaleChangeCallbacks.indexOf(fn) === -1) {
|
|
onLocaleChangeCallbacks.push(fn);
|
|
}
|
|
};
|
|
if (typeof global !== "undefined") {
|
|
global.getLocale = getLocale;
|
|
}
|
|
const baseApis = {
|
|
$on,
|
|
$off,
|
|
$once,
|
|
$emit,
|
|
upx2px,
|
|
interceptors,
|
|
addInterceptor,
|
|
removeInterceptor,
|
|
onCreateVueApp,
|
|
invokeCreateVueAppHook,
|
|
getLocale,
|
|
setLocale,
|
|
onLocaleChange,
|
|
getPushClientId,
|
|
onPushMessage,
|
|
offPushMessage,
|
|
invokePushCallback
|
|
};
|
|
function initUni(api, protocols2) {
|
|
const wrapper3 = initWrapper(protocols2);
|
|
const UniProxyHandlers = {
|
|
get(target, key) {
|
|
if (hasOwn(target, key)) {
|
|
return target[key];
|
|
}
|
|
if (hasOwn(api, key)) {
|
|
return promisify(key, api[key]);
|
|
}
|
|
if (hasOwn(baseApis, key)) {
|
|
return promisify(key, baseApis[key]);
|
|
}
|
|
return promisify(key, wrapper3(key, wx[key]));
|
|
}
|
|
};
|
|
return new Proxy({}, UniProxyHandlers);
|
|
}
|
|
function initGetProvider(providers) {
|
|
return function getProvider2({ service, success, fail, complete }) {
|
|
let res;
|
|
if (providers[service]) {
|
|
res = {
|
|
errMsg: "getProvider:ok",
|
|
service,
|
|
provider: providers[service]
|
|
};
|
|
isFunction(success) && success(res);
|
|
} else {
|
|
res = {
|
|
errMsg: "getProvider:fail:\u670D\u52A1[" + service + "]\u4E0D\u5B58\u5728"
|
|
};
|
|
isFunction(fail) && fail(res);
|
|
}
|
|
isFunction(complete) && complete(res);
|
|
};
|
|
}
|
|
const UUID_KEY = "__DC_STAT_UUID";
|
|
let deviceId;
|
|
function useDeviceId(global2 = wx) {
|
|
return function addDeviceId(_2, toRes) {
|
|
deviceId = deviceId || global2.getStorageSync(UUID_KEY);
|
|
if (!deviceId) {
|
|
deviceId = Date.now() + "" + Math.floor(Math.random() * 1e7);
|
|
wx.setStorage({
|
|
key: UUID_KEY,
|
|
data: deviceId
|
|
});
|
|
}
|
|
toRes.deviceId = deviceId;
|
|
};
|
|
}
|
|
function addSafeAreaInsets(fromRes, toRes) {
|
|
if (fromRes.safeArea) {
|
|
const safeArea = fromRes.safeArea;
|
|
toRes.safeAreaInsets = {
|
|
top: safeArea.top,
|
|
left: safeArea.left,
|
|
right: fromRes.windowWidth - safeArea.right,
|
|
bottom: fromRes.screenHeight - safeArea.bottom
|
|
};
|
|
}
|
|
}
|
|
function populateParameters(fromRes, toRes) {
|
|
const { brand = "", model = "", system = "", language = "", theme, version: version2, platform, fontSizeSetting, SDKVersion, pixelRatio, deviceOrientation } = fromRes;
|
|
let osName = "";
|
|
let osVersion = "";
|
|
{
|
|
osName = system.split(" ")[0] || "";
|
|
osVersion = system.split(" ")[1] || "";
|
|
}
|
|
let hostVersion = version2;
|
|
let deviceType = getGetDeviceType(fromRes, model);
|
|
let deviceBrand = getDeviceBrand(brand);
|
|
let _hostName = getHostName(fromRes);
|
|
let _deviceOrientation = deviceOrientation;
|
|
let _devicePixelRatio = pixelRatio;
|
|
let _SDKVersion = SDKVersion;
|
|
const hostLanguage = language.replace(/_/g, "-");
|
|
const parameters = {
|
|
appId: "",
|
|
appName: "",
|
|
appVersion: "1.0.0",
|
|
appVersionCode: "100",
|
|
appLanguage: getAppLanguage(hostLanguage),
|
|
uniCompileVersion: "3.5.3",
|
|
uniRuntimeVersion: "3.5.3",
|
|
uniPlatform: {}.UNI_SUB_PLATFORM || "mp-weixin",
|
|
deviceBrand,
|
|
deviceModel: model,
|
|
deviceType,
|
|
devicePixelRatio: _devicePixelRatio,
|
|
deviceOrientation: _deviceOrientation,
|
|
osName: osName.toLocaleLowerCase(),
|
|
osVersion,
|
|
hostTheme: theme,
|
|
hostVersion,
|
|
hostLanguage,
|
|
hostName: _hostName,
|
|
hostSDKVersion: _SDKVersion,
|
|
hostFontSizeSetting: fontSizeSetting,
|
|
windowTop: 0,
|
|
windowBottom: 0,
|
|
osLanguage: void 0,
|
|
osTheme: void 0,
|
|
ua: void 0,
|
|
hostPackageName: void 0,
|
|
browserName: void 0,
|
|
browserVersion: void 0
|
|
};
|
|
extend(toRes, parameters);
|
|
}
|
|
function getGetDeviceType(fromRes, model) {
|
|
let deviceType = fromRes.deviceType || "phone";
|
|
{
|
|
const deviceTypeMaps = {
|
|
ipad: "pad",
|
|
windows: "pc",
|
|
mac: "pc"
|
|
};
|
|
const deviceTypeMapsKeys = Object.keys(deviceTypeMaps);
|
|
const _model = model.toLocaleLowerCase();
|
|
for (let index2 = 0; index2 < deviceTypeMapsKeys.length; index2++) {
|
|
const _m = deviceTypeMapsKeys[index2];
|
|
if (_model.indexOf(_m) !== -1) {
|
|
deviceType = deviceTypeMaps[_m];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return deviceType;
|
|
}
|
|
function getDeviceBrand(brand) {
|
|
let deviceBrand = brand;
|
|
if (deviceBrand) {
|
|
deviceBrand = deviceBrand.toLocaleLowerCase();
|
|
}
|
|
return deviceBrand;
|
|
}
|
|
function getAppLanguage(defaultLanguage) {
|
|
return getLocale ? getLocale() : defaultLanguage;
|
|
}
|
|
function getHostName(fromRes) {
|
|
const _platform = "WeChat";
|
|
let _hostName = fromRes.hostName || _platform;
|
|
{
|
|
if (fromRes.environment) {
|
|
_hostName = fromRes.environment;
|
|
} else if (fromRes.host && fromRes.host.env) {
|
|
_hostName = fromRes.host.env;
|
|
}
|
|
}
|
|
return _hostName;
|
|
}
|
|
const getSystemInfo = {
|
|
returnValue: (fromRes, toRes) => {
|
|
addSafeAreaInsets(fromRes, toRes);
|
|
useDeviceId()(fromRes, toRes);
|
|
populateParameters(fromRes, toRes);
|
|
}
|
|
};
|
|
const getSystemInfoSync = getSystemInfo;
|
|
const redirectTo = {};
|
|
const previewImage = {
|
|
args(fromArgs, toArgs) {
|
|
let currentIndex = parseInt(fromArgs.current);
|
|
if (isNaN(currentIndex)) {
|
|
return;
|
|
}
|
|
const urls = fromArgs.urls;
|
|
if (!isArray(urls)) {
|
|
return;
|
|
}
|
|
const len = urls.length;
|
|
if (!len) {
|
|
return;
|
|
}
|
|
if (currentIndex < 0) {
|
|
currentIndex = 0;
|
|
} else if (currentIndex >= len) {
|
|
currentIndex = len - 1;
|
|
}
|
|
if (currentIndex > 0) {
|
|
toArgs.current = urls[currentIndex];
|
|
toArgs.urls = urls.filter((item, index2) => index2 < currentIndex ? item !== urls[currentIndex] : true);
|
|
} else {
|
|
toArgs.current = urls[0];
|
|
}
|
|
return {
|
|
indicator: false,
|
|
loop: false
|
|
};
|
|
}
|
|
};
|
|
const showActionSheet = {
|
|
args(fromArgs, toArgs) {
|
|
toArgs.alertText = fromArgs.title;
|
|
}
|
|
};
|
|
const getDeviceInfo = {
|
|
returnValue: (fromRes, toRes) => {
|
|
const { brand, model } = fromRes;
|
|
let deviceType = getGetDeviceType(fromRes, model);
|
|
let deviceBrand = getDeviceBrand(brand);
|
|
useDeviceId()(fromRes, toRes);
|
|
toRes = sortObject(extend(toRes, {
|
|
deviceType,
|
|
deviceBrand,
|
|
deviceModel: model
|
|
}));
|
|
}
|
|
};
|
|
const getAppBaseInfo = {
|
|
returnValue: (fromRes, toRes) => {
|
|
const { version: version2, language, SDKVersion, theme } = fromRes;
|
|
let _hostName = getHostName(fromRes);
|
|
let hostLanguage = language.replace(/_/g, "-");
|
|
toRes = sortObject(extend(toRes, {
|
|
hostVersion: version2,
|
|
hostLanguage,
|
|
hostName: _hostName,
|
|
hostSDKVersion: SDKVersion,
|
|
hostTheme: theme,
|
|
appId: "",
|
|
appName: "",
|
|
appVersion: "1.0.0",
|
|
appVersionCode: "100",
|
|
appLanguage: getAppLanguage(hostLanguage)
|
|
}));
|
|
}
|
|
};
|
|
const getWindowInfo = {
|
|
returnValue: (fromRes, toRes) => {
|
|
addSafeAreaInsets(fromRes, toRes);
|
|
toRes = sortObject(extend(toRes, {
|
|
windowTop: 0,
|
|
windowBottom: 0
|
|
}));
|
|
}
|
|
};
|
|
const getAppAuthorizeSetting = {
|
|
returnValue: function(fromRes, toRes) {
|
|
const { locationReducedAccuracy } = fromRes;
|
|
toRes.locationAccuracy = "unsupported";
|
|
if (locationReducedAccuracy === true) {
|
|
toRes.locationAccuracy = "reduced";
|
|
} else if (locationReducedAccuracy === false) {
|
|
toRes.locationAccuracy = "full";
|
|
}
|
|
}
|
|
};
|
|
const mocks$1 = ["__route__", "__wxExparserNodeId__", "__wxWebviewId__"];
|
|
const getProvider = initGetProvider({
|
|
oauth: ["weixin"],
|
|
share: ["weixin"],
|
|
payment: ["wxpay"],
|
|
push: ["weixin"]
|
|
});
|
|
function initComponentMocks(component) {
|
|
const res = /* @__PURE__ */ Object.create(null);
|
|
mocks$1.forEach((name) => {
|
|
res[name] = component[name];
|
|
});
|
|
return res;
|
|
}
|
|
function createSelectorQuery() {
|
|
const query = wx.createSelectorQuery();
|
|
const oldIn = query.in;
|
|
query.in = function newIn(component) {
|
|
return oldIn.call(this, initComponentMocks(component));
|
|
};
|
|
return query;
|
|
}
|
|
var shims = /* @__PURE__ */ Object.freeze({
|
|
__proto__: null,
|
|
getProvider,
|
|
createSelectorQuery
|
|
});
|
|
var protocols = /* @__PURE__ */ Object.freeze({
|
|
__proto__: null,
|
|
redirectTo,
|
|
previewImage,
|
|
getSystemInfo,
|
|
getSystemInfoSync,
|
|
showActionSheet,
|
|
getDeviceInfo,
|
|
getAppBaseInfo,
|
|
getWindowInfo,
|
|
getAppAuthorizeSetting
|
|
});
|
|
var index = initUni(shims, protocols);
|
|
function warn(msg, ...args) {
|
|
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
}
|
|
let activeEffectScope;
|
|
class EffectScope {
|
|
constructor(detached = false) {
|
|
this.active = true;
|
|
this.effects = [];
|
|
this.cleanups = [];
|
|
if (!detached && activeEffectScope) {
|
|
this.parent = activeEffectScope;
|
|
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
}
|
|
}
|
|
run(fn) {
|
|
if (this.active) {
|
|
const currentEffectScope = activeEffectScope;
|
|
try {
|
|
activeEffectScope = this;
|
|
return fn();
|
|
} finally {
|
|
activeEffectScope = currentEffectScope;
|
|
}
|
|
} else {
|
|
warn(`cannot run an inactive effect scope.`);
|
|
}
|
|
}
|
|
on() {
|
|
activeEffectScope = this;
|
|
}
|
|
off() {
|
|
activeEffectScope = this.parent;
|
|
}
|
|
stop(fromParent) {
|
|
if (this.active) {
|
|
let i2, l2;
|
|
for (i2 = 0, l2 = this.effects.length; i2 < l2; i2++) {
|
|
this.effects[i2].stop();
|
|
}
|
|
for (i2 = 0, l2 = this.cleanups.length; i2 < l2; i2++) {
|
|
this.cleanups[i2]();
|
|
}
|
|
if (this.scopes) {
|
|
for (i2 = 0, l2 = this.scopes.length; i2 < l2; i2++) {
|
|
this.scopes[i2].stop(true);
|
|
}
|
|
}
|
|
if (this.parent && !fromParent) {
|
|
const last = this.parent.scopes.pop();
|
|
if (last && last !== this) {
|
|
this.parent.scopes[this.index] = last;
|
|
last.index = this.index;
|
|
}
|
|
}
|
|
this.active = false;
|
|
}
|
|
}
|
|
}
|
|
function effectScope(detached) {
|
|
return new EffectScope(detached);
|
|
}
|
|
function recordEffectScope(effect, scope = activeEffectScope) {
|
|
if (scope && scope.active) {
|
|
scope.effects.push(effect);
|
|
}
|
|
}
|
|
function getCurrentScope() {
|
|
return activeEffectScope;
|
|
}
|
|
function onScopeDispose(fn) {
|
|
if (activeEffectScope) {
|
|
activeEffectScope.cleanups.push(fn);
|
|
} else {
|
|
warn(`onScopeDispose() is called when there is no active effect scope to be associated with.`);
|
|
}
|
|
}
|
|
const createDep = (effects) => {
|
|
const dep = new Set(effects);
|
|
dep.w = 0;
|
|
dep.n = 0;
|
|
return dep;
|
|
};
|
|
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
|
|
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
|
|
const initDepMarkers = ({ deps }) => {
|
|
if (deps.length) {
|
|
for (let i2 = 0; i2 < deps.length; i2++) {
|
|
deps[i2].w |= trackOpBit;
|
|
}
|
|
}
|
|
};
|
|
const finalizeDepMarkers = (effect) => {
|
|
const { deps } = effect;
|
|
if (deps.length) {
|
|
let ptr = 0;
|
|
for (let i2 = 0; i2 < deps.length; i2++) {
|
|
const dep = deps[i2];
|
|
if (wasTracked(dep) && !newTracked(dep)) {
|
|
dep.delete(effect);
|
|
} else {
|
|
deps[ptr++] = dep;
|
|
}
|
|
dep.w &= ~trackOpBit;
|
|
dep.n &= ~trackOpBit;
|
|
}
|
|
deps.length = ptr;
|
|
}
|
|
};
|
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
let effectTrackDepth = 0;
|
|
let trackOpBit = 1;
|
|
const maxMarkerBits = 30;
|
|
let activeEffect;
|
|
const ITERATE_KEY = Symbol("iterate");
|
|
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate");
|
|
class ReactiveEffect {
|
|
constructor(fn, scheduler = null, scope) {
|
|
this.fn = fn;
|
|
this.scheduler = scheduler;
|
|
this.active = true;
|
|
this.deps = [];
|
|
this.parent = void 0;
|
|
recordEffectScope(this, scope);
|
|
}
|
|
run() {
|
|
if (!this.active) {
|
|
return this.fn();
|
|
}
|
|
let parent = activeEffect;
|
|
let lastShouldTrack = shouldTrack;
|
|
while (parent) {
|
|
if (parent === this) {
|
|
return;
|
|
}
|
|
parent = parent.parent;
|
|
}
|
|
try {
|
|
this.parent = activeEffect;
|
|
activeEffect = this;
|
|
shouldTrack = true;
|
|
trackOpBit = 1 << ++effectTrackDepth;
|
|
if (effectTrackDepth <= maxMarkerBits) {
|
|
initDepMarkers(this);
|
|
} else {
|
|
cleanupEffect(this);
|
|
}
|
|
return this.fn();
|
|
} finally {
|
|
if (effectTrackDepth <= maxMarkerBits) {
|
|
finalizeDepMarkers(this);
|
|
}
|
|
trackOpBit = 1 << --effectTrackDepth;
|
|
activeEffect = this.parent;
|
|
shouldTrack = lastShouldTrack;
|
|
this.parent = void 0;
|
|
if (this.deferStop) {
|
|
this.stop();
|
|
}
|
|
}
|
|
}
|
|
stop() {
|
|
if (activeEffect === this) {
|
|
this.deferStop = true;
|
|
} else if (this.active) {
|
|
cleanupEffect(this);
|
|
if (this.onStop) {
|
|
this.onStop();
|
|
}
|
|
this.active = false;
|
|
}
|
|
}
|
|
}
|
|
function cleanupEffect(effect) {
|
|
const { deps } = effect;
|
|
if (deps.length) {
|
|
for (let i2 = 0; i2 < deps.length; i2++) {
|
|
deps[i2].delete(effect);
|
|
}
|
|
deps.length = 0;
|
|
}
|
|
}
|
|
let shouldTrack = true;
|
|
const trackStack = [];
|
|
function pauseTracking() {
|
|
trackStack.push(shouldTrack);
|
|
shouldTrack = false;
|
|
}
|
|
function resetTracking() {
|
|
const last = trackStack.pop();
|
|
shouldTrack = last === void 0 ? true : last;
|
|
}
|
|
function track(target, type, key) {
|
|
if (shouldTrack && activeEffect) {
|
|
let depsMap = targetMap.get(target);
|
|
if (!depsMap) {
|
|
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
}
|
|
let dep = depsMap.get(key);
|
|
if (!dep) {
|
|
depsMap.set(key, dep = createDep());
|
|
}
|
|
const eventInfo = { effect: activeEffect, target, type, key };
|
|
trackEffects(dep, eventInfo);
|
|
}
|
|
}
|
|
function trackEffects(dep, debuggerEventExtraInfo) {
|
|
let shouldTrack2 = false;
|
|
if (effectTrackDepth <= maxMarkerBits) {
|
|
if (!newTracked(dep)) {
|
|
dep.n |= trackOpBit;
|
|
shouldTrack2 = !wasTracked(dep);
|
|
}
|
|
} else {
|
|
shouldTrack2 = !dep.has(activeEffect);
|
|
}
|
|
if (shouldTrack2) {
|
|
dep.add(activeEffect);
|
|
activeEffect.deps.push(dep);
|
|
if (activeEffect.onTrack) {
|
|
activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
|
|
}
|
|
}
|
|
}
|
|
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
const depsMap = targetMap.get(target);
|
|
if (!depsMap) {
|
|
return;
|
|
}
|
|
let deps = [];
|
|
if (type === "clear") {
|
|
deps = [...depsMap.values()];
|
|
} else if (key === "length" && isArray(target)) {
|
|
depsMap.forEach((dep, key2) => {
|
|
if (key2 === "length" || key2 >= newValue) {
|
|
deps.push(dep);
|
|
}
|
|
});
|
|
} else {
|
|
if (key !== void 0) {
|
|
deps.push(depsMap.get(key));
|
|
}
|
|
switch (type) {
|
|
case "add":
|
|
if (!isArray(target)) {
|
|
deps.push(depsMap.get(ITERATE_KEY));
|
|
if (isMap(target)) {
|
|
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
}
|
|
} else if (isIntegerKey(key)) {
|
|
deps.push(depsMap.get("length"));
|
|
}
|
|
break;
|
|
case "delete":
|
|
if (!isArray(target)) {
|
|
deps.push(depsMap.get(ITERATE_KEY));
|
|
if (isMap(target)) {
|
|
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
}
|
|
}
|
|
break;
|
|
case "set":
|
|
if (isMap(target)) {
|
|
deps.push(depsMap.get(ITERATE_KEY));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
const eventInfo = { target, type, key, newValue, oldValue, oldTarget };
|
|
if (deps.length === 1) {
|
|
if (deps[0]) {
|
|
{
|
|
triggerEffects(deps[0], eventInfo);
|
|
}
|
|
}
|
|
} else {
|
|
const effects = [];
|
|
for (const dep of deps) {
|
|
if (dep) {
|
|
effects.push(...dep);
|
|
}
|
|
}
|
|
{
|
|
triggerEffects(createDep(effects), eventInfo);
|
|
}
|
|
}
|
|
}
|
|
function triggerEffects(dep, debuggerEventExtraInfo) {
|
|
const effects = isArray(dep) ? dep : [...dep];
|
|
for (const effect of effects) {
|
|
if (effect.computed) {
|
|
triggerEffect(effect, debuggerEventExtraInfo);
|
|
}
|
|
}
|
|
for (const effect of effects) {
|
|
if (!effect.computed) {
|
|
triggerEffect(effect, debuggerEventExtraInfo);
|
|
}
|
|
}
|
|
}
|
|
function triggerEffect(effect, debuggerEventExtraInfo) {
|
|
if (effect !== activeEffect || effect.allowRecurse) {
|
|
if (effect.onTrigger) {
|
|
effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
|
|
}
|
|
if (effect.scheduler) {
|
|
effect.scheduler();
|
|
} else {
|
|
effect.run();
|
|
}
|
|
}
|
|
}
|
|
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
const builtInSymbols = new Set(
|
|
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
);
|
|
const get$1 = /* @__PURE__ */ createGetter();
|
|
const shallowGet = /* @__PURE__ */ createGetter(false, true);
|
|
const readonlyGet = /* @__PURE__ */ createGetter(true);
|
|
const shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true);
|
|
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
|
|
function createArrayInstrumentations() {
|
|
const instrumentations = {};
|
|
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
|
instrumentations[key] = function(...args) {
|
|
const arr = toRaw(this);
|
|
for (let i2 = 0, l2 = this.length; i2 < l2; i2++) {
|
|
track(arr, "get", i2 + "");
|
|
}
|
|
const res = arr[key](...args);
|
|
if (res === -1 || res === false) {
|
|
return arr[key](...args.map(toRaw));
|
|
} else {
|
|
return res;
|
|
}
|
|
};
|
|
});
|
|
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
|
instrumentations[key] = function(...args) {
|
|
pauseTracking();
|
|
const res = toRaw(this)[key].apply(this, args);
|
|
resetTracking();
|
|
return res;
|
|
};
|
|
});
|
|
return instrumentations;
|
|
}
|
|
function createGetter(isReadonly2 = false, shallow = false) {
|
|
return function get2(target, key, receiver) {
|
|
if (key === "__v_isReactive") {
|
|
return !isReadonly2;
|
|
} else if (key === "__v_isReadonly") {
|
|
return isReadonly2;
|
|
} else if (key === "__v_isShallow") {
|
|
return shallow;
|
|
} else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
|
|
return target;
|
|
}
|
|
const targetIsArray = isArray(target);
|
|
if (!isReadonly2 && targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
|
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
}
|
|
const res = Reflect.get(target, key, receiver);
|
|
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
return res;
|
|
}
|
|
if (!isReadonly2) {
|
|
track(target, "get", key);
|
|
}
|
|
if (shallow) {
|
|
return res;
|
|
}
|
|
if (isRef(res)) {
|
|
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
}
|
|
if (isObject$1(res)) {
|
|
return isReadonly2 ? readonly(res) : reactive(res);
|
|
}
|
|
return res;
|
|
};
|
|
}
|
|
const set$1$1 = /* @__PURE__ */ createSetter();
|
|
const shallowSet = /* @__PURE__ */ createSetter(true);
|
|
function createSetter(shallow = false) {
|
|
return function set2(target, key, value, receiver) {
|
|
let oldValue = target[key];
|
|
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
|
|
return false;
|
|
}
|
|
if (!shallow && !isReadonly(value)) {
|
|
if (!isShallow(value)) {
|
|
value = toRaw(value);
|
|
oldValue = toRaw(oldValue);
|
|
}
|
|
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
|
oldValue.value = value;
|
|
return true;
|
|
}
|
|
}
|
|
const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
|
const result = Reflect.set(target, key, value, receiver);
|
|
if (target === toRaw(receiver)) {
|
|
if (!hadKey) {
|
|
trigger(target, "add", key, value);
|
|
} else if (hasChanged(value, oldValue)) {
|
|
trigger(target, "set", key, value, oldValue);
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
function deleteProperty(target, key) {
|
|
const hadKey = hasOwn(target, key);
|
|
const oldValue = target[key];
|
|
const result = Reflect.deleteProperty(target, key);
|
|
if (result && hadKey) {
|
|
trigger(target, "delete", key, void 0, oldValue);
|
|
}
|
|
return result;
|
|
}
|
|
function has(target, key) {
|
|
const result = Reflect.has(target, key);
|
|
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
track(target, "has", key);
|
|
}
|
|
return result;
|
|
}
|
|
function ownKeys(target) {
|
|
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
|
|
return Reflect.ownKeys(target);
|
|
}
|
|
const mutableHandlers = {
|
|
get: get$1,
|
|
set: set$1$1,
|
|
deleteProperty,
|
|
has,
|
|
ownKeys
|
|
};
|
|
const readonlyHandlers = {
|
|
get: readonlyGet,
|
|
set(target, key) {
|
|
{
|
|
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
}
|
|
return true;
|
|
},
|
|
deleteProperty(target, key) {
|
|
{
|
|
warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
}
|
|
return true;
|
|
}
|
|
};
|
|
const shallowReactiveHandlers = /* @__PURE__ */ extend({}, mutableHandlers, {
|
|
get: shallowGet,
|
|
set: shallowSet
|
|
});
|
|
const shallowReadonlyHandlers = /* @__PURE__ */ extend({}, readonlyHandlers, {
|
|
get: shallowReadonlyGet
|
|
});
|
|
const toShallow = (value) => value;
|
|
const getProto = (v2) => Reflect.getPrototypeOf(v2);
|
|
function get$1$1(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
target = target["__v_raw"];
|
|
const rawTarget = toRaw(target);
|
|
const rawKey = toRaw(key);
|
|
if (!isReadonly2) {
|
|
if (key !== rawKey) {
|
|
track(rawTarget, "get", key);
|
|
}
|
|
track(rawTarget, "get", rawKey);
|
|
}
|
|
const { has: has2 } = getProto(rawTarget);
|
|
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
if (has2.call(rawTarget, key)) {
|
|
return wrap(target.get(key));
|
|
} else if (has2.call(rawTarget, rawKey)) {
|
|
return wrap(target.get(rawKey));
|
|
} else if (target !== rawTarget) {
|
|
target.get(key);
|
|
}
|
|
}
|
|
function has$1(key, isReadonly2 = false) {
|
|
const target = this["__v_raw"];
|
|
const rawTarget = toRaw(target);
|
|
const rawKey = toRaw(key);
|
|
if (!isReadonly2) {
|
|
if (key !== rawKey) {
|
|
track(rawTarget, "has", key);
|
|
}
|
|
track(rawTarget, "has", rawKey);
|
|
}
|
|
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
}
|
|
function size(target, isReadonly2 = false) {
|
|
target = target["__v_raw"];
|
|
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
return Reflect.get(target, "size", target);
|
|
}
|
|
function add(value) {
|
|
value = toRaw(value);
|
|
const target = toRaw(this);
|
|
const proto2 = getProto(target);
|
|
const hadKey = proto2.has.call(target, value);
|
|
if (!hadKey) {
|
|
target.add(value);
|
|
trigger(target, "add", value, value);
|
|
}
|
|
return this;
|
|
}
|
|
function set$1$1$1(key, value) {
|
|
value = toRaw(value);
|
|
const target = toRaw(this);
|
|
const { has: has2, get: get2 } = getProto(target);
|
|
let hadKey = has2.call(target, key);
|
|
if (!hadKey) {
|
|
key = toRaw(key);
|
|
hadKey = has2.call(target, key);
|
|
} else {
|
|
checkIdentityKeys(target, has2, key);
|
|
}
|
|
const oldValue = get2.call(target, key);
|
|
target.set(key, value);
|
|
if (!hadKey) {
|
|
trigger(target, "add", key, value);
|
|
} else if (hasChanged(value, oldValue)) {
|
|
trigger(target, "set", key, value, oldValue);
|
|
}
|
|
return this;
|
|
}
|
|
function deleteEntry(key) {
|
|
const target = toRaw(this);
|
|
const { has: has2, get: get2 } = getProto(target);
|
|
let hadKey = has2.call(target, key);
|
|
if (!hadKey) {
|
|
key = toRaw(key);
|
|
hadKey = has2.call(target, key);
|
|
} else {
|
|
checkIdentityKeys(target, has2, key);
|
|
}
|
|
const oldValue = get2 ? get2.call(target, key) : void 0;
|
|
const result = target.delete(key);
|
|
if (hadKey) {
|
|
trigger(target, "delete", key, void 0, oldValue);
|
|
}
|
|
return result;
|
|
}
|
|
function clear() {
|
|
const target = toRaw(this);
|
|
const hadItems = target.size !== 0;
|
|
const oldTarget = isMap(target) ? new Map(target) : new Set(target);
|
|
const result = target.clear();
|
|
if (hadItems) {
|
|
trigger(target, "clear", void 0, void 0, oldTarget);
|
|
}
|
|
return result;
|
|
}
|
|
function createForEach(isReadonly2, isShallow2) {
|
|
return function forEach(callback, thisArg) {
|
|
const observed = this;
|
|
const target = observed["__v_raw"];
|
|
const rawTarget = toRaw(target);
|
|
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
return target.forEach((value, key) => {
|
|
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
});
|
|
};
|
|
}
|
|
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
return function(...args) {
|
|
const target = this["__v_raw"];
|
|
const rawTarget = toRaw(target);
|
|
const targetIsMap = isMap(rawTarget);
|
|
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
const isKeyOnly = method === "keys" && targetIsMap;
|
|
const innerIterator = target[method](...args);
|
|
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
!isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
|
return {
|
|
next() {
|
|
const { value, done } = innerIterator.next();
|
|
return done ? { value, done } : {
|
|
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
done
|
|
};
|
|
},
|
|
[Symbol.iterator]() {
|
|
return this;
|
|
}
|
|
};
|
|
};
|
|
}
|
|
function createReadonlyMethod(type) {
|
|
return function(...args) {
|
|
{
|
|
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
|
|
}
|
|
return type === "delete" ? false : this;
|
|
};
|
|
}
|
|
function createInstrumentations() {
|
|
const mutableInstrumentations2 = {
|
|
get(key) {
|
|
return get$1$1(this, key);
|
|
},
|
|
get size() {
|
|
return size(this);
|
|
},
|
|
has: has$1,
|
|
add,
|
|
set: set$1$1$1,
|
|
delete: deleteEntry,
|
|
clear,
|
|
forEach: createForEach(false, false)
|
|
};
|
|
const shallowInstrumentations2 = {
|
|
get(key) {
|
|
return get$1$1(this, key, false, true);
|
|
},
|
|
get size() {
|
|
return size(this);
|
|
},
|
|
has: has$1,
|
|
add,
|
|
set: set$1$1$1,
|
|
delete: deleteEntry,
|
|
clear,
|
|
forEach: createForEach(false, true)
|
|
};
|
|
const readonlyInstrumentations2 = {
|
|
get(key) {
|
|
return get$1$1(this, key, true);
|
|
},
|
|
get size() {
|
|
return size(this, true);
|
|
},
|
|
has(key) {
|
|
return has$1.call(this, key, true);
|
|
},
|
|
add: createReadonlyMethod("add"),
|
|
set: createReadonlyMethod("set"),
|
|
delete: createReadonlyMethod("delete"),
|
|
clear: createReadonlyMethod("clear"),
|
|
forEach: createForEach(true, false)
|
|
};
|
|
const shallowReadonlyInstrumentations2 = {
|
|
get(key) {
|
|
return get$1$1(this, key, true, true);
|
|
},
|
|
get size() {
|
|
return size(this, true);
|
|
},
|
|
has(key) {
|
|
return has$1.call(this, key, true);
|
|
},
|
|
add: createReadonlyMethod("add"),
|
|
set: createReadonlyMethod("set"),
|
|
delete: createReadonlyMethod("delete"),
|
|
clear: createReadonlyMethod("clear"),
|
|
forEach: createForEach(true, true)
|
|
};
|
|
const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
|
|
iteratorMethods.forEach((method) => {
|
|
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
|
|
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
|
|
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
|
|
shallowReadonlyInstrumentations2[method] = createIterableMethod(method, true, true);
|
|
});
|
|
return [
|
|
mutableInstrumentations2,
|
|
readonlyInstrumentations2,
|
|
shallowInstrumentations2,
|
|
shallowReadonlyInstrumentations2
|
|
];
|
|
}
|
|
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* @__PURE__ */ createInstrumentations();
|
|
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
return (target, key, receiver) => {
|
|
if (key === "__v_isReactive") {
|
|
return !isReadonly2;
|
|
} else if (key === "__v_isReadonly") {
|
|
return isReadonly2;
|
|
} else if (key === "__v_raw") {
|
|
return target;
|
|
}
|
|
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
};
|
|
}
|
|
const mutableCollectionHandlers = {
|
|
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
};
|
|
const shallowCollectionHandlers = {
|
|
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
|
};
|
|
const readonlyCollectionHandlers = {
|
|
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
};
|
|
const shallowReadonlyCollectionHandlers = {
|
|
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
};
|
|
function checkIdentityKeys(target, has2, key) {
|
|
const rawKey = toRaw(key);
|
|
if (rawKey !== key && has2.call(target, rawKey)) {
|
|
const type = toRawType(target);
|
|
console.warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
|
|
}
|
|
}
|
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
function targetTypeMap(rawType) {
|
|
switch (rawType) {
|
|
case "Object":
|
|
case "Array":
|
|
return 1;
|
|
case "Map":
|
|
case "Set":
|
|
case "WeakMap":
|
|
case "WeakSet":
|
|
return 2;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
function getTargetType(value) {
|
|
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
}
|
|
function reactive(target) {
|
|
if (isReadonly(target)) {
|
|
return target;
|
|
}
|
|
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
}
|
|
function shallowReactive(target) {
|
|
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
|
|
}
|
|
function readonly(target) {
|
|
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
}
|
|
function shallowReadonly(target) {
|
|
return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
|
}
|
|
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
if (!isObject$1(target)) {
|
|
{
|
|
console.warn(`value cannot be made reactive: ${String(target)}`);
|
|
}
|
|
return target;
|
|
}
|
|
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
return target;
|
|
}
|
|
const existingProxy = proxyMap.get(target);
|
|
if (existingProxy) {
|
|
return existingProxy;
|
|
}
|
|
const targetType = getTargetType(target);
|
|
if (targetType === 0) {
|
|
return target;
|
|
}
|
|
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
proxyMap.set(target, proxy);
|
|
return proxy;
|
|
}
|
|
function isReactive(value) {
|
|
if (isReadonly(value)) {
|
|
return isReactive(value["__v_raw"]);
|
|
}
|
|
return !!(value && value["__v_isReactive"]);
|
|
}
|
|
function isReadonly(value) {
|
|
return !!(value && value["__v_isReadonly"]);
|
|
}
|
|
function isShallow(value) {
|
|
return !!(value && value["__v_isShallow"]);
|
|
}
|
|
function isProxy(value) {
|
|
return isReactive(value) || isReadonly(value);
|
|
}
|
|
function toRaw(observed) {
|
|
const raw = observed && observed["__v_raw"];
|
|
return raw ? toRaw(raw) : observed;
|
|
}
|
|
function markRaw(value) {
|
|
def(value, "__v_skip", true);
|
|
return value;
|
|
}
|
|
const toReactive = (value) => isObject$1(value) ? reactive(value) : value;
|
|
const toReadonly = (value) => isObject$1(value) ? readonly(value) : value;
|
|
function trackRefValue(ref2) {
|
|
if (shouldTrack && activeEffect) {
|
|
ref2 = toRaw(ref2);
|
|
{
|
|
trackEffects(ref2.dep || (ref2.dep = createDep()), {
|
|
target: ref2,
|
|
type: "get",
|
|
key: "value"
|
|
});
|
|
}
|
|
}
|
|
}
|
|
function triggerRefValue(ref2, newVal) {
|
|
ref2 = toRaw(ref2);
|
|
if (ref2.dep) {
|
|
{
|
|
triggerEffects(ref2.dep, {
|
|
target: ref2,
|
|
type: "set",
|
|
key: "value",
|
|
newValue: newVal
|
|
});
|
|
}
|
|
}
|
|
}
|
|
function isRef(r2) {
|
|
return !!(r2 && r2.__v_isRef === true);
|
|
}
|
|
function ref(value) {
|
|
return createRef(value, false);
|
|
}
|
|
function createRef(rawValue, shallow) {
|
|
if (isRef(rawValue)) {
|
|
return rawValue;
|
|
}
|
|
return new RefImpl(rawValue, shallow);
|
|
}
|
|
class RefImpl {
|
|
constructor(value, __v_isShallow) {
|
|
this.__v_isShallow = __v_isShallow;
|
|
this.dep = void 0;
|
|
this.__v_isRef = true;
|
|
this._rawValue = __v_isShallow ? value : toRaw(value);
|
|
this._value = __v_isShallow ? value : toReactive(value);
|
|
}
|
|
get value() {
|
|
trackRefValue(this);
|
|
return this._value;
|
|
}
|
|
set value(newVal) {
|
|
newVal = this.__v_isShallow ? newVal : toRaw(newVal);
|
|
if (hasChanged(newVal, this._rawValue)) {
|
|
this._rawValue = newVal;
|
|
this._value = this.__v_isShallow ? newVal : toReactive(newVal);
|
|
triggerRefValue(this, newVal);
|
|
}
|
|
}
|
|
}
|
|
function unref(ref2) {
|
|
return isRef(ref2) ? ref2.value : ref2;
|
|
}
|
|
const shallowUnwrapHandlers = {
|
|
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
|
set: (target, key, value, receiver) => {
|
|
const oldValue = target[key];
|
|
if (isRef(oldValue) && !isRef(value)) {
|
|
oldValue.value = value;
|
|
return true;
|
|
} else {
|
|
return Reflect.set(target, key, value, receiver);
|
|
}
|
|
}
|
|
};
|
|
function proxyRefs(objectWithRefs) {
|
|
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
}
|
|
function toRefs(object) {
|
|
if (!isProxy(object)) {
|
|
console.warn(`toRefs() expects a reactive object but received a plain one.`);
|
|
}
|
|
const ret = isArray(object) ? new Array(object.length) : {};
|
|
for (const key in object) {
|
|
ret[key] = toRef(object, key);
|
|
}
|
|
return ret;
|
|
}
|
|
class ObjectRefImpl {
|
|
constructor(_object, _key, _defaultValue) {
|
|
this._object = _object;
|
|
this._key = _key;
|
|
this._defaultValue = _defaultValue;
|
|
this.__v_isRef = true;
|
|
}
|
|
get value() {
|
|
const val = this._object[this._key];
|
|
return val === void 0 ? this._defaultValue : val;
|
|
}
|
|
set value(newVal) {
|
|
this._object[this._key] = newVal;
|
|
}
|
|
}
|
|
function toRef(object, key, defaultValue) {
|
|
const val = object[key];
|
|
return isRef(val) ? val : new ObjectRefImpl(object, key, defaultValue);
|
|
}
|
|
class ComputedRefImpl {
|
|
constructor(getter, _setter, isReadonly2, isSSR) {
|
|
this._setter = _setter;
|
|
this.dep = void 0;
|
|
this.__v_isRef = true;
|
|
this._dirty = true;
|
|
this.effect = new ReactiveEffect(getter, () => {
|
|
if (!this._dirty) {
|
|
this._dirty = true;
|
|
triggerRefValue(this);
|
|
}
|
|
});
|
|
this.effect.computed = this;
|
|
this.effect.active = this._cacheable = !isSSR;
|
|
this["__v_isReadonly"] = isReadonly2;
|
|
}
|
|
get value() {
|
|
const self2 = toRaw(this);
|
|
trackRefValue(self2);
|
|
if (self2._dirty || !self2._cacheable) {
|
|
self2._dirty = false;
|
|
self2._value = self2.effect.run();
|
|
}
|
|
return self2._value;
|
|
}
|
|
set value(newValue) {
|
|
this._setter(newValue);
|
|
}
|
|
}
|
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
let getter;
|
|
let setter;
|
|
const onlyGetter = isFunction(getterOrOptions);
|
|
if (onlyGetter) {
|
|
getter = getterOrOptions;
|
|
setter = () => {
|
|
console.warn("Write operation failed: computed value is readonly");
|
|
};
|
|
} else {
|
|
getter = getterOrOptions.get;
|
|
setter = getterOrOptions.set;
|
|
}
|
|
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
|
|
if (debugOptions && !isSSR) {
|
|
cRef.effect.onTrack = debugOptions.onTrack;
|
|
cRef.effect.onTrigger = debugOptions.onTrigger;
|
|
}
|
|
return cRef;
|
|
}
|
|
const stack = [];
|
|
function pushWarningContext(vnode) {
|
|
stack.push(vnode);
|
|
}
|
|
function popWarningContext() {
|
|
stack.pop();
|
|
}
|
|
function warn$1(msg, ...args) {
|
|
pauseTracking();
|
|
const instance = stack.length ? stack[stack.length - 1].component : null;
|
|
const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
|
const trace = getComponentTrace();
|
|
if (appWarnHandler) {
|
|
callWithErrorHandling(appWarnHandler, instance, 11, [
|
|
msg + args.join(""),
|
|
instance && instance.proxy,
|
|
trace.map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`).join("\n"),
|
|
trace
|
|
]);
|
|
} else {
|
|
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
if (trace.length && true) {
|
|
warnArgs.push(`
|
|
`, ...formatTrace(trace));
|
|
}
|
|
console.warn(...warnArgs);
|
|
}
|
|
resetTracking();
|
|
}
|
|
function getComponentTrace() {
|
|
let currentVNode = stack[stack.length - 1];
|
|
if (!currentVNode) {
|
|
return [];
|
|
}
|
|
const normalizedStack = [];
|
|
while (currentVNode) {
|
|
const last = normalizedStack[0];
|
|
if (last && last.vnode === currentVNode) {
|
|
last.recurseCount++;
|
|
} else {
|
|
normalizedStack.push({
|
|
vnode: currentVNode,
|
|
recurseCount: 0
|
|
});
|
|
}
|
|
const parentInstance = currentVNode.component && currentVNode.component.parent;
|
|
currentVNode = parentInstance && parentInstance.vnode;
|
|
}
|
|
return normalizedStack;
|
|
}
|
|
function formatTrace(trace) {
|
|
const logs = [];
|
|
trace.forEach((entry, i2) => {
|
|
logs.push(...i2 === 0 ? [] : [`
|
|
`], ...formatTraceEntry(entry));
|
|
});
|
|
return logs;
|
|
}
|
|
function formatTraceEntry({ vnode, recurseCount }) {
|
|
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
|
const isRoot = vnode.component ? vnode.component.parent == null : false;
|
|
const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
|
|
const close = `>` + postfix;
|
|
return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
|
}
|
|
function formatProps(props) {
|
|
const res = [];
|
|
const keys = Object.keys(props);
|
|
keys.slice(0, 3).forEach((key) => {
|
|
res.push(...formatProp(key, props[key]));
|
|
});
|
|
if (keys.length > 3) {
|
|
res.push(` ...`);
|
|
}
|
|
return res;
|
|
}
|
|
function formatProp(key, value, raw) {
|
|
if (isString(value)) {
|
|
value = JSON.stringify(value);
|
|
return raw ? value : [`${key}=${value}`];
|
|
} else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
|
return raw ? value : [`${key}=${value}`];
|
|
} else if (isRef(value)) {
|
|
value = formatProp(key, toRaw(value.value), true);
|
|
return raw ? value : [`${key}=Ref<`, value, `>`];
|
|
} else if (isFunction(value)) {
|
|
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
} else {
|
|
value = toRaw(value);
|
|
return raw ? value : [`${key}=`, value];
|
|
}
|
|
}
|
|
const ErrorTypeStrings = {
|
|
["sp"]: "serverPrefetch hook",
|
|
["bc"]: "beforeCreate hook",
|
|
["c"]: "created hook",
|
|
["bm"]: "beforeMount hook",
|
|
["m"]: "mounted hook",
|
|
["bu"]: "beforeUpdate hook",
|
|
["u"]: "updated",
|
|
["bum"]: "beforeUnmount hook",
|
|
["um"]: "unmounted hook",
|
|
["a"]: "activated hook",
|
|
["da"]: "deactivated hook",
|
|
["ec"]: "errorCaptured hook",
|
|
["rtc"]: "renderTracked hook",
|
|
["rtg"]: "renderTriggered hook",
|
|
[0]: "setup function",
|
|
[1]: "render function",
|
|
[2]: "watcher getter",
|
|
[3]: "watcher callback",
|
|
[4]: "watcher cleanup function",
|
|
[5]: "native event handler",
|
|
[6]: "component event handler",
|
|
[7]: "vnode hook",
|
|
[8]: "directive hook",
|
|
[9]: "transition hook",
|
|
[10]: "app errorHandler",
|
|
[11]: "app warnHandler",
|
|
[12]: "ref function",
|
|
[13]: "async component loader",
|
|
[14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"
|
|
};
|
|
function callWithErrorHandling(fn, instance, type, args) {
|
|
let res;
|
|
try {
|
|
res = args ? fn(...args) : fn();
|
|
} catch (err) {
|
|
handleError(err, instance, type);
|
|
}
|
|
return res;
|
|
}
|
|
function callWithAsyncErrorHandling(fn, instance, type, args) {
|
|
if (isFunction(fn)) {
|
|
const res = callWithErrorHandling(fn, instance, type, args);
|
|
if (res && isPromise(res)) {
|
|
res.catch((err) => {
|
|
handleError(err, instance, type);
|
|
});
|
|
}
|
|
return res;
|
|
}
|
|
const values = [];
|
|
for (let i2 = 0; i2 < fn.length; i2++) {
|
|
values.push(callWithAsyncErrorHandling(fn[i2], instance, type, args));
|
|
}
|
|
return values;
|
|
}
|
|
function handleError(err, instance, type, throwInDev = true) {
|
|
const contextVNode = instance ? instance.vnode : null;
|
|
if (instance) {
|
|
let cur = instance.parent;
|
|
const exposedInstance = instance.proxy;
|
|
const errorInfo = ErrorTypeStrings[type] || type;
|
|
while (cur) {
|
|
const errorCapturedHooks = cur.ec;
|
|
if (errorCapturedHooks) {
|
|
for (let i2 = 0; i2 < errorCapturedHooks.length; i2++) {
|
|
if (errorCapturedHooks[i2](err, exposedInstance, errorInfo) === false) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
cur = cur.parent;
|
|
}
|
|
const appErrorHandler = instance.appContext.config.errorHandler;
|
|
if (appErrorHandler) {
|
|
callWithErrorHandling(appErrorHandler, null, 10, [err, exposedInstance, errorInfo]);
|
|
return;
|
|
}
|
|
}
|
|
logError(err, type, contextVNode, throwInDev);
|
|
}
|
|
function logError(err, type, contextVNode, throwInDev = true) {
|
|
{
|
|
const info = ErrorTypeStrings[type] || type;
|
|
if (contextVNode) {
|
|
pushWarningContext(contextVNode);
|
|
}
|
|
warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
if (contextVNode) {
|
|
popWarningContext();
|
|
}
|
|
if (throwInDev) {
|
|
console.error(err);
|
|
} else {
|
|
console.error(err);
|
|
}
|
|
}
|
|
}
|
|
let isFlushing = false;
|
|
let isFlushPending = false;
|
|
const queue = [];
|
|
let flushIndex = 0;
|
|
const pendingPreFlushCbs = [];
|
|
let activePreFlushCbs = null;
|
|
let preFlushIndex = 0;
|
|
const pendingPostFlushCbs = [];
|
|
let activePostFlushCbs = null;
|
|
let postFlushIndex = 0;
|
|
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
let currentFlushPromise = null;
|
|
let currentPreFlushParentJob = null;
|
|
const RECURSION_LIMIT = 100;
|
|
function nextTick(fn) {
|
|
const p2 = currentFlushPromise || resolvedPromise;
|
|
return fn ? p2.then(this ? fn.bind(this) : fn) : p2;
|
|
}
|
|
function findInsertionIndex(id) {
|
|
let start = flushIndex + 1;
|
|
let end = queue.length;
|
|
while (start < end) {
|
|
const middle = start + end >>> 1;
|
|
const middleJobId = getId(queue[middle]);
|
|
middleJobId < id ? start = middle + 1 : end = middle;
|
|
}
|
|
return start;
|
|
}
|
|
function queueJob(job) {
|
|
if ((!queue.length || !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) && job !== currentPreFlushParentJob) {
|
|
if (job.id == null) {
|
|
queue.push(job);
|
|
} else {
|
|
queue.splice(findInsertionIndex(job.id), 0, job);
|
|
}
|
|
queueFlush();
|
|
}
|
|
}
|
|
function queueFlush() {
|
|
if (!isFlushing && !isFlushPending) {
|
|
isFlushPending = true;
|
|
currentFlushPromise = resolvedPromise.then(flushJobs);
|
|
}
|
|
}
|
|
function hasQueueJob(job) {
|
|
return queue.indexOf(job) > -1;
|
|
}
|
|
function invalidateJob(job) {
|
|
const i2 = queue.indexOf(job);
|
|
if (i2 > flushIndex) {
|
|
queue.splice(i2, 1);
|
|
}
|
|
}
|
|
function queueCb(cb, activeQueue, pendingQueue, index2) {
|
|
if (!isArray(cb)) {
|
|
if (!activeQueue || !activeQueue.includes(cb, cb.allowRecurse ? index2 + 1 : index2)) {
|
|
pendingQueue.push(cb);
|
|
}
|
|
} else {
|
|
pendingQueue.push(...cb);
|
|
}
|
|
queueFlush();
|
|
}
|
|
function queuePreFlushCb(cb) {
|
|
queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
|
|
}
|
|
function queuePostFlushCb(cb) {
|
|
queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
|
|
}
|
|
function flushPreFlushCbs(seen, parentJob = null) {
|
|
if (pendingPreFlushCbs.length) {
|
|
currentPreFlushParentJob = parentJob;
|
|
activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
|
|
pendingPreFlushCbs.length = 0;
|
|
{
|
|
seen = seen || /* @__PURE__ */ new Map();
|
|
}
|
|
for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
|
|
if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
|
|
continue;
|
|
}
|
|
activePreFlushCbs[preFlushIndex]();
|
|
}
|
|
activePreFlushCbs = null;
|
|
preFlushIndex = 0;
|
|
currentPreFlushParentJob = null;
|
|
flushPreFlushCbs(seen, parentJob);
|
|
}
|
|
}
|
|
function flushPostFlushCbs(seen) {
|
|
flushPreFlushCbs();
|
|
if (pendingPostFlushCbs.length) {
|
|
const deduped = [...new Set(pendingPostFlushCbs)];
|
|
pendingPostFlushCbs.length = 0;
|
|
if (activePostFlushCbs) {
|
|
activePostFlushCbs.push(...deduped);
|
|
return;
|
|
}
|
|
activePostFlushCbs = deduped;
|
|
{
|
|
seen = seen || /* @__PURE__ */ new Map();
|
|
}
|
|
activePostFlushCbs.sort((a2, b2) => getId(a2) - getId(b2));
|
|
for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
|
if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
|
|
continue;
|
|
}
|
|
activePostFlushCbs[postFlushIndex]();
|
|
}
|
|
activePostFlushCbs = null;
|
|
postFlushIndex = 0;
|
|
}
|
|
}
|
|
const getId = (job) => job.id == null ? Infinity : job.id;
|
|
function flushJobs(seen) {
|
|
isFlushPending = false;
|
|
isFlushing = true;
|
|
{
|
|
seen = seen || /* @__PURE__ */ new Map();
|
|
}
|
|
flushPreFlushCbs(seen);
|
|
queue.sort((a2, b2) => getId(a2) - getId(b2));
|
|
const check = (job) => checkRecursiveUpdates(seen, job);
|
|
try {
|
|
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
|
const job = queue[flushIndex];
|
|
if (job && job.active !== false) {
|
|
if (check(job)) {
|
|
continue;
|
|
}
|
|
callWithErrorHandling(job, null, 14);
|
|
}
|
|
}
|
|
} finally {
|
|
flushIndex = 0;
|
|
queue.length = 0;
|
|
flushPostFlushCbs(seen);
|
|
isFlushing = false;
|
|
currentFlushPromise = null;
|
|
if (queue.length || pendingPreFlushCbs.length || pendingPostFlushCbs.length) {
|
|
flushJobs(seen);
|
|
}
|
|
}
|
|
}
|
|
function checkRecursiveUpdates(seen, fn) {
|
|
if (!seen.has(fn)) {
|
|
seen.set(fn, 1);
|
|
} else {
|
|
const count = seen.get(fn);
|
|
if (count > RECURSION_LIMIT) {
|
|
const instance = fn.ownerInstance;
|
|
const componentName = instance && getComponentName(instance.type);
|
|
warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`);
|
|
return true;
|
|
} else {
|
|
seen.set(fn, count + 1);
|
|
}
|
|
}
|
|
}
|
|
function emit(event, ...args) {
|
|
}
|
|
function devtoolsComponentEmit(component, event, params) {
|
|
emit("component:emit", component.appContext.app, component, event, params);
|
|
}
|
|
function emit$1(instance, event, ...rawArgs) {
|
|
if (instance.isUnmounted)
|
|
return;
|
|
const props = instance.vnode.props || EMPTY_OBJ;
|
|
{
|
|
const { emitsOptions, propsOptions: [propsOptions] } = instance;
|
|
if (emitsOptions) {
|
|
if (!(event in emitsOptions) && true) {
|
|
if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
|
|
warn$1(`Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`);
|
|
}
|
|
} else {
|
|
const validator = emitsOptions[event];
|
|
if (isFunction(validator)) {
|
|
const isValid = validator(...rawArgs);
|
|
if (!isValid) {
|
|
warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let args = rawArgs;
|
|
const isModelListener2 = event.startsWith("update:");
|
|
const modelArg = isModelListener2 && event.slice(7);
|
|
if (modelArg && modelArg in props) {
|
|
const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
|
|
const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
|
|
if (trim) {
|
|
args = rawArgs.map((a2) => a2.trim());
|
|
}
|
|
if (number) {
|
|
args = rawArgs.map(toNumber);
|
|
}
|
|
}
|
|
{
|
|
devtoolsComponentEmit(instance, event, args);
|
|
}
|
|
{
|
|
const lowerCaseEvent = event.toLowerCase();
|
|
if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
|
|
warn$1(`Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate(event)}" instead of "${event}".`);
|
|
}
|
|
}
|
|
let handlerName;
|
|
let handler = props[handlerName = toHandlerKey(event)] || props[handlerName = toHandlerKey(camelize(event))];
|
|
if (!handler && isModelListener2) {
|
|
handler = props[handlerName = toHandlerKey(hyphenate(event))];
|
|
}
|
|
if (handler) {
|
|
callWithAsyncErrorHandling(handler, instance, 6, args);
|
|
}
|
|
const onceHandler = props[handlerName + `Once`];
|
|
if (onceHandler) {
|
|
if (!instance.emitted) {
|
|
instance.emitted = {};
|
|
} else if (instance.emitted[handlerName]) {
|
|
return;
|
|
}
|
|
instance.emitted[handlerName] = true;
|
|
callWithAsyncErrorHandling(onceHandler, instance, 6, args);
|
|
}
|
|
}
|
|
function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
|
const cache = appContext.emitsCache;
|
|
const cached = cache.get(comp);
|
|
if (cached !== void 0) {
|
|
return cached;
|
|
}
|
|
const raw = comp.emits;
|
|
let normalized = {};
|
|
let hasExtends = false;
|
|
if (!isFunction(comp)) {
|
|
const extendEmits = (raw2) => {
|
|
const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
|
|
if (normalizedFromExtend) {
|
|
hasExtends = true;
|
|
extend(normalized, normalizedFromExtend);
|
|
}
|
|
};
|
|
if (!asMixin && appContext.mixins.length) {
|
|
appContext.mixins.forEach(extendEmits);
|
|
}
|
|
if (comp.extends) {
|
|
extendEmits(comp.extends);
|
|
}
|
|
if (comp.mixins) {
|
|
comp.mixins.forEach(extendEmits);
|
|
}
|
|
}
|
|
if (!raw && !hasExtends) {
|
|
cache.set(comp, null);
|
|
return null;
|
|
}
|
|
if (isArray(raw)) {
|
|
raw.forEach((key) => normalized[key] = null);
|
|
} else {
|
|
extend(normalized, raw);
|
|
}
|
|
cache.set(comp, normalized);
|
|
return normalized;
|
|
}
|
|
function isEmitListener(options, key) {
|
|
if (!options || !isOn(key)) {
|
|
return false;
|
|
}
|
|
key = key.slice(2).replace(/Once$/, "");
|
|
return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
|
|
}
|
|
let currentRenderingInstance = null;
|
|
function setCurrentRenderingInstance(instance) {
|
|
const prev = currentRenderingInstance;
|
|
currentRenderingInstance = instance;
|
|
instance && instance.type.__scopeId || null;
|
|
return prev;
|
|
}
|
|
function provide(key, value) {
|
|
if (!currentInstance) {
|
|
{
|
|
warn$1(`provide() can only be used inside setup().`);
|
|
}
|
|
} else {
|
|
let provides = currentInstance.provides;
|
|
const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
|
if (parentProvides === provides) {
|
|
provides = currentInstance.provides = Object.create(parentProvides);
|
|
}
|
|
provides[key] = value;
|
|
if (currentInstance.type.mpType === "app") {
|
|
currentInstance.appContext.app.provide(key, value);
|
|
}
|
|
}
|
|
}
|
|
function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
|
const instance = currentInstance || currentRenderingInstance;
|
|
if (instance) {
|
|
const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;
|
|
if (provides && key in provides) {
|
|
return provides[key];
|
|
} else if (arguments.length > 1) {
|
|
return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;
|
|
} else {
|
|
warn$1(`injection "${String(key)}" not found.`);
|
|
}
|
|
} else {
|
|
warn$1(`inject() can only be used inside setup() or functional components.`);
|
|
}
|
|
}
|
|
const INITIAL_WATCHER_VALUE = {};
|
|
function watch(source, cb, options) {
|
|
if (!isFunction(cb)) {
|
|
warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`);
|
|
}
|
|
return doWatch(source, cb, options);
|
|
}
|
|
function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
|
|
if (!cb) {
|
|
if (immediate !== void 0) {
|
|
warn$1(`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`);
|
|
}
|
|
if (deep !== void 0) {
|
|
warn$1(`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`);
|
|
}
|
|
}
|
|
const warnInvalidSource = (s2) => {
|
|
warn$1(`Invalid watch source: `, s2, `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`);
|
|
};
|
|
const instance = currentInstance;
|
|
let getter;
|
|
let forceTrigger = false;
|
|
let isMultiSource = false;
|
|
if (isRef(source)) {
|
|
getter = () => source.value;
|
|
forceTrigger = isShallow(source);
|
|
} else if (isReactive(source)) {
|
|
getter = () => source;
|
|
deep = true;
|
|
} else if (isArray(source)) {
|
|
isMultiSource = true;
|
|
forceTrigger = source.some((s2) => isReactive(s2) || isShallow(s2));
|
|
getter = () => source.map((s2) => {
|
|
if (isRef(s2)) {
|
|
return s2.value;
|
|
} else if (isReactive(s2)) {
|
|
return traverse(s2);
|
|
} else if (isFunction(s2)) {
|
|
return callWithErrorHandling(s2, instance, 2);
|
|
} else {
|
|
warnInvalidSource(s2);
|
|
}
|
|
});
|
|
} else if (isFunction(source)) {
|
|
if (cb) {
|
|
getter = () => callWithErrorHandling(source, instance, 2);
|
|
} else {
|
|
getter = () => {
|
|
if (instance && instance.isUnmounted) {
|
|
return;
|
|
}
|
|
if (cleanup) {
|
|
cleanup();
|
|
}
|
|
return callWithAsyncErrorHandling(source, instance, 3, [onCleanup]);
|
|
};
|
|
}
|
|
} else {
|
|
getter = NOOP;
|
|
warnInvalidSource(source);
|
|
}
|
|
if (cb && deep) {
|
|
const baseGetter = getter;
|
|
getter = () => traverse(baseGetter());
|
|
}
|
|
let cleanup;
|
|
let onCleanup = (fn) => {
|
|
cleanup = effect.onStop = () => {
|
|
callWithErrorHandling(fn, instance, 4);
|
|
};
|
|
};
|
|
let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
|
|
const job = () => {
|
|
if (!effect.active) {
|
|
return;
|
|
}
|
|
if (cb) {
|
|
const newValue = effect.run();
|
|
if (deep || forceTrigger || (isMultiSource ? newValue.some((v2, i2) => hasChanged(v2, oldValue[i2])) : hasChanged(newValue, oldValue)) || false) {
|
|
if (cleanup) {
|
|
cleanup();
|
|
}
|
|
callWithAsyncErrorHandling(cb, instance, 3, [
|
|
newValue,
|
|
oldValue === INITIAL_WATCHER_VALUE ? void 0 : oldValue,
|
|
onCleanup
|
|
]);
|
|
oldValue = newValue;
|
|
}
|
|
} else {
|
|
effect.run();
|
|
}
|
|
};
|
|
job.allowRecurse = !!cb;
|
|
let scheduler;
|
|
if (flush === "sync") {
|
|
scheduler = job;
|
|
} else if (flush === "post") {
|
|
scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
|
} else {
|
|
scheduler = () => {
|
|
if (!instance || instance.isMounted) {
|
|
queuePreFlushCb(job);
|
|
} else {
|
|
job();
|
|
}
|
|
};
|
|
}
|
|
const effect = new ReactiveEffect(getter, scheduler);
|
|
{
|
|
effect.onTrack = onTrack;
|
|
effect.onTrigger = onTrigger;
|
|
}
|
|
if (cb) {
|
|
if (immediate) {
|
|
job();
|
|
} else {
|
|
oldValue = effect.run();
|
|
}
|
|
} else if (flush === "post") {
|
|
queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
|
|
} else {
|
|
effect.run();
|
|
}
|
|
return () => {
|
|
effect.stop();
|
|
if (instance && instance.scope) {
|
|
remove(instance.scope.effects, effect);
|
|
}
|
|
};
|
|
}
|
|
function instanceWatch(source, value, options) {
|
|
const publicThis = this.proxy;
|
|
const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
|
|
let cb;
|
|
if (isFunction(value)) {
|
|
cb = value;
|
|
} else {
|
|
cb = value.handler;
|
|
options = value;
|
|
}
|
|
const cur = currentInstance;
|
|
setCurrentInstance(this);
|
|
const res = doWatch(getter, cb.bind(publicThis), options);
|
|
if (cur) {
|
|
setCurrentInstance(cur);
|
|
} else {
|
|
unsetCurrentInstance();
|
|
}
|
|
return res;
|
|
}
|
|
function createPathGetter(ctx, path) {
|
|
const segments = path.split(".");
|
|
return () => {
|
|
let cur = ctx;
|
|
for (let i2 = 0; i2 < segments.length && cur; i2++) {
|
|
cur = cur[segments[i2]];
|
|
}
|
|
return cur;
|
|
};
|
|
}
|
|
function traverse(value, seen) {
|
|
if (!isObject$1(value) || value["__v_skip"]) {
|
|
return value;
|
|
}
|
|
seen = seen || /* @__PURE__ */ new Set();
|
|
if (seen.has(value)) {
|
|
return value;
|
|
}
|
|
seen.add(value);
|
|
if (isRef(value)) {
|
|
traverse(value.value, seen);
|
|
} else if (isArray(value)) {
|
|
for (let i2 = 0; i2 < value.length; i2++) {
|
|
traverse(value[i2], seen);
|
|
}
|
|
} else if (isSet(value) || isMap(value)) {
|
|
value.forEach((v2) => {
|
|
traverse(v2, seen);
|
|
});
|
|
} else if (isPlainObject$1(value)) {
|
|
for (const key in value) {
|
|
traverse(value[key], seen);
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
function defineComponent(options) {
|
|
return isFunction(options) ? { setup: options, name: options.name } : options;
|
|
}
|
|
const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
|
function onActivated(hook, target) {
|
|
registerKeepAliveHook(hook, "a", target);
|
|
}
|
|
function onDeactivated(hook, target) {
|
|
registerKeepAliveHook(hook, "da", target);
|
|
}
|
|
function registerKeepAliveHook(hook, type, target = currentInstance) {
|
|
const wrappedHook = hook.__wdc || (hook.__wdc = () => {
|
|
let current = target;
|
|
while (current) {
|
|
if (current.isDeactivated) {
|
|
return;
|
|
}
|
|
current = current.parent;
|
|
}
|
|
return hook();
|
|
});
|
|
injectHook(type, wrappedHook, target);
|
|
if (target) {
|
|
let current = target.parent;
|
|
while (current && current.parent) {
|
|
if (isKeepAlive(current.parent.vnode)) {
|
|
injectToKeepAliveRoot(wrappedHook, type, target, current);
|
|
}
|
|
current = current.parent;
|
|
}
|
|
}
|
|
}
|
|
function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
|
const injected = injectHook(type, hook, keepAliveRoot, true);
|
|
onUnmounted(() => {
|
|
remove(keepAliveRoot[type], injected);
|
|
}, target);
|
|
}
|
|
function injectHook(type, hook, target = currentInstance, prepend = false) {
|
|
if (target) {
|
|
if (isRootHook(type)) {
|
|
target = target.root;
|
|
}
|
|
const hooks = target[type] || (target[type] = []);
|
|
const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
|
|
if (target.isUnmounted) {
|
|
return;
|
|
}
|
|
pauseTracking();
|
|
setCurrentInstance(target);
|
|
const res = callWithAsyncErrorHandling(hook, target, type, args);
|
|
unsetCurrentInstance();
|
|
resetTracking();
|
|
return res;
|
|
});
|
|
if (prepend) {
|
|
hooks.unshift(wrappedHook);
|
|
} else {
|
|
hooks.push(wrappedHook);
|
|
}
|
|
return wrappedHook;
|
|
} else {
|
|
const apiName = toHandlerKey((ErrorTypeStrings[type] || type.replace(/^on/, "")).replace(/ hook$/, ""));
|
|
warn$1(`${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().`);
|
|
}
|
|
}
|
|
const createHook$1 = (lifecycle) => (hook, target = currentInstance) => (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, hook, target);
|
|
const onBeforeMount = createHook$1("bm");
|
|
const onMounted = createHook$1("m");
|
|
const onBeforeUpdate = createHook$1("bu");
|
|
const onUpdated = createHook$1("u");
|
|
const onBeforeUnmount = createHook$1("bum");
|
|
const onUnmounted = createHook$1("um");
|
|
const onServerPrefetch = createHook$1("sp");
|
|
const onRenderTriggered = createHook$1("rtg");
|
|
const onRenderTracked = createHook$1("rtc");
|
|
function onErrorCaptured(hook, target = currentInstance) {
|
|
injectHook("ec", hook, target);
|
|
}
|
|
function validateDirectiveName(name) {
|
|
if (isBuiltInDirective(name)) {
|
|
warn$1("Do not use built-in directive ids as custom directive id: " + name);
|
|
}
|
|
}
|
|
const COMPONENTS = "components";
|
|
function resolveComponent(name, maybeSelfReference) {
|
|
return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
|
}
|
|
function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
|
const instance = currentRenderingInstance || currentInstance;
|
|
if (instance) {
|
|
const Component2 = instance.type;
|
|
if (type === COMPONENTS) {
|
|
const selfName = getComponentName(Component2, false);
|
|
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
|
|
return Component2;
|
|
}
|
|
}
|
|
const res = resolve(instance[type] || Component2[type], name) || resolve(instance.appContext[type], name);
|
|
if (!res && maybeSelfReference) {
|
|
return Component2;
|
|
}
|
|
if (warnMissing && !res) {
|
|
const extra = type === COMPONENTS ? `
|
|
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
|
|
warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
|
|
}
|
|
return res;
|
|
} else {
|
|
warn$1(`resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`);
|
|
}
|
|
}
|
|
function resolve(registry, name) {
|
|
return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
|
|
}
|
|
const getPublicInstance = (i2) => {
|
|
if (!i2)
|
|
return null;
|
|
if (isStatefulComponent(i2))
|
|
return getExposeProxy(i2) || i2.proxy;
|
|
return getPublicInstance(i2.parent);
|
|
};
|
|
const publicPropertiesMap = /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
|
|
$: (i2) => i2,
|
|
$el: (i2) => i2.__$el || (i2.__$el = {}),
|
|
$data: (i2) => i2.data,
|
|
$props: (i2) => shallowReadonly(i2.props),
|
|
$attrs: (i2) => shallowReadonly(i2.attrs),
|
|
$slots: (i2) => shallowReadonly(i2.slots),
|
|
$refs: (i2) => shallowReadonly(i2.refs),
|
|
$parent: (i2) => getPublicInstance(i2.parent),
|
|
$root: (i2) => getPublicInstance(i2.root),
|
|
$emit: (i2) => i2.emit,
|
|
$options: (i2) => resolveMergedOptions(i2),
|
|
$forceUpdate: (i2) => i2.f || (i2.f = () => queueJob(i2.update)),
|
|
$watch: (i2) => instanceWatch.bind(i2)
|
|
});
|
|
const isReservedPrefix = (key) => key === "_" || key === "$";
|
|
const PublicInstanceProxyHandlers = {
|
|
get({ _: instance }, key) {
|
|
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
|
if (key === "__isVue") {
|
|
return true;
|
|
}
|
|
if (setupState !== EMPTY_OBJ && setupState.__isScriptSetup && hasOwn(setupState, key)) {
|
|
return setupState[key];
|
|
}
|
|
let normalizedProps;
|
|
if (key[0] !== "$") {
|
|
const n2 = accessCache[key];
|
|
if (n2 !== void 0) {
|
|
switch (n2) {
|
|
case 1:
|
|
return setupState[key];
|
|
case 2:
|
|
return data[key];
|
|
case 4:
|
|
return ctx[key];
|
|
case 3:
|
|
return props[key];
|
|
}
|
|
} else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
|
|
accessCache[key] = 1;
|
|
return setupState[key];
|
|
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
|
accessCache[key] = 2;
|
|
return data[key];
|
|
} else if ((normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)) {
|
|
accessCache[key] = 3;
|
|
return props[key];
|
|
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
|
accessCache[key] = 4;
|
|
return ctx[key];
|
|
} else if (shouldCacheAccess) {
|
|
accessCache[key] = 0;
|
|
}
|
|
}
|
|
const publicGetter = publicPropertiesMap[key];
|
|
let cssModule, globalProperties;
|
|
if (publicGetter) {
|
|
if (key === "$attrs") {
|
|
track(instance, "get", key);
|
|
}
|
|
return publicGetter(instance);
|
|
} else if ((cssModule = type.__cssModules) && (cssModule = cssModule[key])) {
|
|
return cssModule;
|
|
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
|
accessCache[key] = 4;
|
|
return ctx[key];
|
|
} else if (globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) {
|
|
{
|
|
return globalProperties[key];
|
|
}
|
|
} else if (currentRenderingInstance && (!isString(key) || key.indexOf("__v") !== 0)) {
|
|
if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
|
|
warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`);
|
|
} else if (instance === currentRenderingInstance) {
|
|
warn$1(`Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`);
|
|
}
|
|
}
|
|
},
|
|
set({ _: instance }, key, value) {
|
|
const { data, setupState, ctx } = instance;
|
|
if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
|
|
setupState[key] = value;
|
|
return true;
|
|
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
|
data[key] = value;
|
|
return true;
|
|
} else if (hasOwn(instance.props, key)) {
|
|
warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
|
|
return false;
|
|
}
|
|
if (key[0] === "$" && key.slice(1) in instance) {
|
|
warn$1(`Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`, instance);
|
|
return false;
|
|
} else {
|
|
if (key in instance.appContext.config.globalProperties) {
|
|
Object.defineProperty(ctx, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
value
|
|
});
|
|
} else {
|
|
ctx[key] = value;
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
|
|
let normalizedProps;
|
|
return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || setupState !== EMPTY_OBJ && hasOwn(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
|
|
},
|
|
defineProperty(target, key, descriptor) {
|
|
if (descriptor.get != null) {
|
|
target._.accessCache[key] = 0;
|
|
} else if (hasOwn(descriptor, "value")) {
|
|
this.set(target, key, descriptor.value, null);
|
|
}
|
|
return Reflect.defineProperty(target, key, descriptor);
|
|
}
|
|
};
|
|
{
|
|
PublicInstanceProxyHandlers.ownKeys = (target) => {
|
|
warn$1(`Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`);
|
|
return Reflect.ownKeys(target);
|
|
};
|
|
}
|
|
function createDevRenderContext(instance) {
|
|
const target = {};
|
|
Object.defineProperty(target, `_`, {
|
|
configurable: true,
|
|
enumerable: false,
|
|
get: () => instance
|
|
});
|
|
Object.keys(publicPropertiesMap).forEach((key) => {
|
|
Object.defineProperty(target, key, {
|
|
configurable: true,
|
|
enumerable: false,
|
|
get: () => publicPropertiesMap[key](instance),
|
|
set: NOOP
|
|
});
|
|
});
|
|
return target;
|
|
}
|
|
function exposePropsOnRenderContext(instance) {
|
|
const { ctx, propsOptions: [propsOptions] } = instance;
|
|
if (propsOptions) {
|
|
Object.keys(propsOptions).forEach((key) => {
|
|
Object.defineProperty(ctx, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => instance.props[key],
|
|
set: NOOP
|
|
});
|
|
});
|
|
}
|
|
}
|
|
function exposeSetupStateOnRenderContext(instance) {
|
|
const { ctx, setupState } = instance;
|
|
Object.keys(toRaw(setupState)).forEach((key) => {
|
|
if (!setupState.__isScriptSetup) {
|
|
if (isReservedPrefix(key[0])) {
|
|
warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" which are reserved prefixes for Vue internals.`);
|
|
return;
|
|
}
|
|
Object.defineProperty(ctx, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => setupState[key],
|
|
set: NOOP
|
|
});
|
|
}
|
|
});
|
|
}
|
|
function createDuplicateChecker() {
|
|
const cache = /* @__PURE__ */ Object.create(null);
|
|
return (type, key) => {
|
|
if (cache[key]) {
|
|
warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
|
|
} else {
|
|
cache[key] = type;
|
|
}
|
|
};
|
|
}
|
|
let shouldCacheAccess = true;
|
|
function applyOptions$1(instance) {
|
|
const options = resolveMergedOptions(instance);
|
|
const publicThis = instance.proxy;
|
|
const ctx = instance.ctx;
|
|
shouldCacheAccess = false;
|
|
if (options.beforeCreate) {
|
|
callHook$1(options.beforeCreate, instance, "bc");
|
|
}
|
|
const {
|
|
data: dataOptions,
|
|
computed: computedOptions,
|
|
methods,
|
|
watch: watchOptions,
|
|
provide: provideOptions,
|
|
inject: injectOptions,
|
|
created,
|
|
beforeMount,
|
|
mounted,
|
|
beforeUpdate,
|
|
updated,
|
|
activated,
|
|
deactivated,
|
|
beforeDestroy,
|
|
beforeUnmount,
|
|
destroyed,
|
|
unmounted,
|
|
render,
|
|
renderTracked,
|
|
renderTriggered,
|
|
errorCaptured,
|
|
serverPrefetch,
|
|
expose,
|
|
inheritAttrs,
|
|
components,
|
|
directives,
|
|
filters
|
|
} = options;
|
|
const checkDuplicateProperties = createDuplicateChecker();
|
|
{
|
|
const [propsOptions] = instance.propsOptions;
|
|
if (propsOptions) {
|
|
for (const key in propsOptions) {
|
|
checkDuplicateProperties("Props", key);
|
|
}
|
|
}
|
|
}
|
|
if (injectOptions) {
|
|
resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
|
|
}
|
|
if (methods) {
|
|
for (const key in methods) {
|
|
const methodHandler = methods[key];
|
|
if (isFunction(methodHandler)) {
|
|
{
|
|
Object.defineProperty(ctx, key, {
|
|
value: methodHandler.bind(publicThis),
|
|
configurable: true,
|
|
enumerable: true,
|
|
writable: true
|
|
});
|
|
}
|
|
{
|
|
checkDuplicateProperties("Methods", key);
|
|
}
|
|
} else {
|
|
warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`);
|
|
}
|
|
}
|
|
}
|
|
if (dataOptions) {
|
|
if (!isFunction(dataOptions)) {
|
|
warn$1(`The data option must be a function. Plain object usage is no longer supported.`);
|
|
}
|
|
const data = dataOptions.call(publicThis, publicThis);
|
|
if (isPromise(data)) {
|
|
warn$1(`data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`);
|
|
}
|
|
if (!isObject$1(data)) {
|
|
warn$1(`data() should return an object.`);
|
|
} else {
|
|
instance.data = reactive(data);
|
|
{
|
|
for (const key in data) {
|
|
checkDuplicateProperties("Data", key);
|
|
if (!isReservedPrefix(key[0])) {
|
|
Object.defineProperty(ctx, key, {
|
|
configurable: true,
|
|
enumerable: true,
|
|
get: () => data[key],
|
|
set: NOOP
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
shouldCacheAccess = true;
|
|
if (computedOptions) {
|
|
for (const key in computedOptions) {
|
|
const opt = computedOptions[key];
|
|
const get2 = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
|
|
if (get2 === NOOP) {
|
|
warn$1(`Computed property "${key}" has no getter.`);
|
|
}
|
|
const set2 = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
|
|
warn$1(`Write operation failed: computed property "${key}" is readonly.`);
|
|
};
|
|
const c2 = computed$1({
|
|
get: get2,
|
|
set: set2
|
|
});
|
|
Object.defineProperty(ctx, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => c2.value,
|
|
set: (v2) => c2.value = v2
|
|
});
|
|
{
|
|
checkDuplicateProperties("Computed", key);
|
|
}
|
|
}
|
|
}
|
|
if (watchOptions) {
|
|
for (const key in watchOptions) {
|
|
createWatcher(watchOptions[key], ctx, publicThis, key);
|
|
}
|
|
}
|
|
{
|
|
if (provideOptions) {
|
|
const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
|
|
Reflect.ownKeys(provides).forEach((key) => {
|
|
provide(key, provides[key]);
|
|
});
|
|
}
|
|
}
|
|
{
|
|
if (created) {
|
|
callHook$1(created, instance, "c");
|
|
}
|
|
}
|
|
function registerLifecycleHook(register, hook) {
|
|
if (isArray(hook)) {
|
|
hook.forEach((_hook) => register(_hook.bind(publicThis)));
|
|
} else if (hook) {
|
|
register(hook.bind(publicThis));
|
|
}
|
|
}
|
|
registerLifecycleHook(onBeforeMount, beforeMount);
|
|
registerLifecycleHook(onMounted, mounted);
|
|
registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
|
registerLifecycleHook(onUpdated, updated);
|
|
registerLifecycleHook(onActivated, activated);
|
|
registerLifecycleHook(onDeactivated, deactivated);
|
|
registerLifecycleHook(onErrorCaptured, errorCaptured);
|
|
registerLifecycleHook(onRenderTracked, renderTracked);
|
|
registerLifecycleHook(onRenderTriggered, renderTriggered);
|
|
registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
|
registerLifecycleHook(onUnmounted, unmounted);
|
|
registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
|
if (isArray(expose)) {
|
|
if (expose.length) {
|
|
const exposed = instance.exposed || (instance.exposed = {});
|
|
expose.forEach((key) => {
|
|
Object.defineProperty(exposed, key, {
|
|
get: () => publicThis[key],
|
|
set: (val) => publicThis[key] = val
|
|
});
|
|
});
|
|
} else if (!instance.exposed) {
|
|
instance.exposed = {};
|
|
}
|
|
}
|
|
if (render && instance.render === NOOP) {
|
|
instance.render = render;
|
|
}
|
|
if (inheritAttrs != null) {
|
|
instance.inheritAttrs = inheritAttrs;
|
|
}
|
|
if (components)
|
|
instance.components = components;
|
|
if (directives)
|
|
instance.directives = directives;
|
|
if (instance.ctx.$onApplyOptions) {
|
|
instance.ctx.$onApplyOptions(options, instance, publicThis);
|
|
}
|
|
}
|
|
function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
|
|
if (isArray(injectOptions)) {
|
|
injectOptions = normalizeInject(injectOptions);
|
|
}
|
|
for (const key in injectOptions) {
|
|
const opt = injectOptions[key];
|
|
let injected;
|
|
if (isObject$1(opt)) {
|
|
if ("default" in opt) {
|
|
injected = inject(opt.from || key, opt.default, true);
|
|
} else {
|
|
injected = inject(opt.from || key);
|
|
}
|
|
} else {
|
|
injected = inject(opt);
|
|
}
|
|
if (isRef(injected)) {
|
|
if (unwrapRef) {
|
|
Object.defineProperty(ctx, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => injected.value,
|
|
set: (v2) => injected.value = v2
|
|
});
|
|
} else {
|
|
{
|
|
warn$1(`injected property "${key}" is a ref and will be auto-unwrapped and no longer needs \`.value\` in the next minor release. To opt-in to the new behavior now, set \`app.config.unwrapInjectedRef = true\` (this config is temporary and will not be needed in the future.)`);
|
|
}
|
|
ctx[key] = injected;
|
|
}
|
|
} else {
|
|
ctx[key] = injected;
|
|
}
|
|
{
|
|
checkDuplicateProperties("Inject", key);
|
|
}
|
|
}
|
|
}
|
|
function callHook$1(hook, instance, type) {
|
|
callWithAsyncErrorHandling(isArray(hook) ? hook.map((h2) => h2.bind(instance.proxy)) : hook.bind(instance.proxy), instance, type);
|
|
}
|
|
function createWatcher(raw, ctx, publicThis, key) {
|
|
const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
|
|
if (isString(raw)) {
|
|
const handler = ctx[raw];
|
|
if (isFunction(handler)) {
|
|
watch(getter, handler);
|
|
} else {
|
|
warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
|
|
}
|
|
} else if (isFunction(raw)) {
|
|
watch(getter, raw.bind(publicThis));
|
|
} else if (isObject$1(raw)) {
|
|
if (isArray(raw)) {
|
|
raw.forEach((r2) => createWatcher(r2, ctx, publicThis, key));
|
|
} else {
|
|
const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
|
|
if (isFunction(handler)) {
|
|
watch(getter, handler, raw);
|
|
} else {
|
|
warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
|
|
}
|
|
}
|
|
} else {
|
|
warn$1(`Invalid watch option: "${key}"`, raw);
|
|
}
|
|
}
|
|
function resolveMergedOptions(instance) {
|
|
const base = instance.type;
|
|
const { mixins, extends: extendsOptions } = base;
|
|
const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
|
|
const cached = cache.get(base);
|
|
let resolved;
|
|
if (cached) {
|
|
resolved = cached;
|
|
} else if (!globalMixins.length && !mixins && !extendsOptions) {
|
|
{
|
|
resolved = base;
|
|
}
|
|
} else {
|
|
resolved = {};
|
|
if (globalMixins.length) {
|
|
globalMixins.forEach((m2) => mergeOptions(resolved, m2, optionMergeStrategies, true));
|
|
}
|
|
mergeOptions(resolved, base, optionMergeStrategies);
|
|
}
|
|
cache.set(base, resolved);
|
|
return resolved;
|
|
}
|
|
function mergeOptions(to, from, strats, asMixin = false) {
|
|
const { mixins, extends: extendsOptions } = from;
|
|
if (extendsOptions) {
|
|
mergeOptions(to, extendsOptions, strats, true);
|
|
}
|
|
if (mixins) {
|
|
mixins.forEach((m2) => mergeOptions(to, m2, strats, true));
|
|
}
|
|
for (const key in from) {
|
|
if (asMixin && key === "expose") {
|
|
warn$1(`"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`);
|
|
} else {
|
|
const strat = internalOptionMergeStrats[key] || strats && strats[key];
|
|
to[key] = strat ? strat(to[key], from[key]) : from[key];
|
|
}
|
|
}
|
|
return to;
|
|
}
|
|
const internalOptionMergeStrats = {
|
|
data: mergeDataFn,
|
|
props: mergeObjectOptions,
|
|
emits: mergeObjectOptions,
|
|
methods: mergeObjectOptions,
|
|
computed: mergeObjectOptions,
|
|
beforeCreate: mergeAsArray$1,
|
|
created: mergeAsArray$1,
|
|
beforeMount: mergeAsArray$1,
|
|
mounted: mergeAsArray$1,
|
|
beforeUpdate: mergeAsArray$1,
|
|
updated: mergeAsArray$1,
|
|
beforeDestroy: mergeAsArray$1,
|
|
beforeUnmount: mergeAsArray$1,
|
|
destroyed: mergeAsArray$1,
|
|
unmounted: mergeAsArray$1,
|
|
activated: mergeAsArray$1,
|
|
deactivated: mergeAsArray$1,
|
|
errorCaptured: mergeAsArray$1,
|
|
serverPrefetch: mergeAsArray$1,
|
|
components: mergeObjectOptions,
|
|
directives: mergeObjectOptions,
|
|
watch: mergeWatchOptions,
|
|
provide: mergeDataFn,
|
|
inject: mergeInject
|
|
};
|
|
function mergeDataFn(to, from) {
|
|
if (!from) {
|
|
return to;
|
|
}
|
|
if (!to) {
|
|
return from;
|
|
}
|
|
return function mergedDataFn() {
|
|
return extend(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
|
|
};
|
|
}
|
|
function mergeInject(to, from) {
|
|
return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
|
}
|
|
function normalizeInject(raw) {
|
|
if (isArray(raw)) {
|
|
const res = {};
|
|
for (let i2 = 0; i2 < raw.length; i2++) {
|
|
res[raw[i2]] = raw[i2];
|
|
}
|
|
return res;
|
|
}
|
|
return raw;
|
|
}
|
|
function mergeAsArray$1(to, from) {
|
|
return to ? [...new Set([].concat(to, from))] : from;
|
|
}
|
|
function mergeObjectOptions(to, from) {
|
|
return to ? extend(extend(/* @__PURE__ */ Object.create(null), to), from) : from;
|
|
}
|
|
function mergeWatchOptions(to, from) {
|
|
if (!to)
|
|
return from;
|
|
if (!from)
|
|
return to;
|
|
const merged = extend(/* @__PURE__ */ Object.create(null), to);
|
|
for (const key in from) {
|
|
merged[key] = mergeAsArray$1(to[key], from[key]);
|
|
}
|
|
return merged;
|
|
}
|
|
function initProps$1(instance, rawProps, isStateful, isSSR = false) {
|
|
const props = {};
|
|
const attrs = {};
|
|
instance.propsDefaults = /* @__PURE__ */ Object.create(null);
|
|
setFullProps(instance, rawProps, props, attrs);
|
|
for (const key in instance.propsOptions[0]) {
|
|
if (!(key in props)) {
|
|
props[key] = void 0;
|
|
}
|
|
}
|
|
{
|
|
validateProps(rawProps || {}, props, instance);
|
|
}
|
|
if (isStateful) {
|
|
instance.props = isSSR ? props : shallowReactive(props);
|
|
} else {
|
|
if (!instance.type.props) {
|
|
instance.props = attrs;
|
|
} else {
|
|
instance.props = props;
|
|
}
|
|
}
|
|
instance.attrs = attrs;
|
|
}
|
|
function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
|
const { props, attrs, vnode: { patchFlag } } = instance;
|
|
const rawCurrentProps = toRaw(props);
|
|
const [options] = instance.propsOptions;
|
|
let hasAttrsChanged = false;
|
|
if (!(instance.type.__hmrId || instance.parent && instance.parent.type.__hmrId) && (optimized || patchFlag > 0) && !(patchFlag & 16)) {
|
|
if (patchFlag & 8) {
|
|
const propsToUpdate = instance.vnode.dynamicProps;
|
|
for (let i2 = 0; i2 < propsToUpdate.length; i2++) {
|
|
let key = propsToUpdate[i2];
|
|
if (isEmitListener(instance.emitsOptions, key)) {
|
|
continue;
|
|
}
|
|
const value = rawProps[key];
|
|
if (options) {
|
|
if (hasOwn(attrs, key)) {
|
|
if (value !== attrs[key]) {
|
|
attrs[key] = value;
|
|
hasAttrsChanged = true;
|
|
}
|
|
} else {
|
|
const camelizedKey = camelize(key);
|
|
props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false);
|
|
}
|
|
} else {
|
|
if (value !== attrs[key]) {
|
|
attrs[key] = value;
|
|
hasAttrsChanged = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (setFullProps(instance, rawProps, props, attrs)) {
|
|
hasAttrsChanged = true;
|
|
}
|
|
let kebabKey;
|
|
for (const key in rawCurrentProps) {
|
|
if (!rawProps || !hasOwn(rawProps, key) && ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
|
|
if (options) {
|
|
if (rawPrevProps && (rawPrevProps[key] !== void 0 || rawPrevProps[kebabKey] !== void 0)) {
|
|
props[key] = resolvePropValue(options, rawCurrentProps, key, void 0, instance, true);
|
|
}
|
|
} else {
|
|
delete props[key];
|
|
}
|
|
}
|
|
}
|
|
if (attrs !== rawCurrentProps) {
|
|
for (const key in attrs) {
|
|
if (!rawProps || !hasOwn(rawProps, key) && true) {
|
|
delete attrs[key];
|
|
hasAttrsChanged = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (hasAttrsChanged) {
|
|
trigger(instance, "set", "$attrs");
|
|
}
|
|
{
|
|
validateProps(rawProps || {}, props, instance);
|
|
}
|
|
}
|
|
function setFullProps(instance, rawProps, props, attrs) {
|
|
const [options, needCastKeys] = instance.propsOptions;
|
|
let hasAttrsChanged = false;
|
|
let rawCastValues;
|
|
if (rawProps) {
|
|
for (let key in rawProps) {
|
|
if (isReservedProp(key)) {
|
|
continue;
|
|
}
|
|
const value = rawProps[key];
|
|
let camelKey;
|
|
if (options && hasOwn(options, camelKey = camelize(key))) {
|
|
if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
|
props[camelKey] = value;
|
|
} else {
|
|
(rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
|
}
|
|
} else if (!isEmitListener(instance.emitsOptions, key)) {
|
|
if (!(key in attrs) || value !== attrs[key]) {
|
|
attrs[key] = value;
|
|
hasAttrsChanged = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (needCastKeys) {
|
|
const rawCurrentProps = toRaw(props);
|
|
const castValues = rawCastValues || EMPTY_OBJ;
|
|
for (let i2 = 0; i2 < needCastKeys.length; i2++) {
|
|
const key = needCastKeys[i2];
|
|
props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
|
|
}
|
|
}
|
|
return hasAttrsChanged;
|
|
}
|
|
function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
|
const opt = options[key];
|
|
if (opt != null) {
|
|
const hasDefault = hasOwn(opt, "default");
|
|
if (hasDefault && value === void 0) {
|
|
const defaultValue = opt.default;
|
|
if (opt.type !== Function && isFunction(defaultValue)) {
|
|
const { propsDefaults } = instance;
|
|
if (key in propsDefaults) {
|
|
value = propsDefaults[key];
|
|
} else {
|
|
setCurrentInstance(instance);
|
|
value = propsDefaults[key] = defaultValue.call(null, props);
|
|
unsetCurrentInstance();
|
|
}
|
|
} else {
|
|
value = defaultValue;
|
|
}
|
|
}
|
|
if (opt[0]) {
|
|
if (isAbsent && !hasDefault) {
|
|
value = false;
|
|
} else if (opt[1] && (value === "" || value === hyphenate(key))) {
|
|
value = true;
|
|
}
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
function normalizePropsOptions(comp, appContext, asMixin = false) {
|
|
const cache = appContext.propsCache;
|
|
const cached = cache.get(comp);
|
|
if (cached) {
|
|
return cached;
|
|
}
|
|
const raw = comp.props;
|
|
const normalized = {};
|
|
const needCastKeys = [];
|
|
let hasExtends = false;
|
|
if (!isFunction(comp)) {
|
|
const extendProps = (raw2) => {
|
|
hasExtends = true;
|
|
const [props, keys] = normalizePropsOptions(raw2, appContext, true);
|
|
extend(normalized, props);
|
|
if (keys)
|
|
needCastKeys.push(...keys);
|
|
};
|
|
if (!asMixin && appContext.mixins.length) {
|
|
appContext.mixins.forEach(extendProps);
|
|
}
|
|
if (comp.extends) {
|
|
extendProps(comp.extends);
|
|
}
|
|
if (comp.mixins) {
|
|
comp.mixins.forEach(extendProps);
|
|
}
|
|
}
|
|
if (!raw && !hasExtends) {
|
|
cache.set(comp, EMPTY_ARR);
|
|
return EMPTY_ARR;
|
|
}
|
|
if (isArray(raw)) {
|
|
for (let i2 = 0; i2 < raw.length; i2++) {
|
|
if (!isString(raw[i2])) {
|
|
warn$1(`props must be strings when using array syntax.`, raw[i2]);
|
|
}
|
|
const normalizedKey = camelize(raw[i2]);
|
|
if (validatePropName(normalizedKey)) {
|
|
normalized[normalizedKey] = EMPTY_OBJ;
|
|
}
|
|
}
|
|
} else if (raw) {
|
|
if (!isObject$1(raw)) {
|
|
warn$1(`invalid props options`, raw);
|
|
}
|
|
for (const key in raw) {
|
|
const normalizedKey = camelize(key);
|
|
if (validatePropName(normalizedKey)) {
|
|
const opt = raw[key];
|
|
const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : opt;
|
|
if (prop) {
|
|
const booleanIndex = getTypeIndex(Boolean, prop.type);
|
|
const stringIndex = getTypeIndex(String, prop.type);
|
|
prop[0] = booleanIndex > -1;
|
|
prop[1] = stringIndex < 0 || booleanIndex < stringIndex;
|
|
if (booleanIndex > -1 || hasOwn(prop, "default")) {
|
|
needCastKeys.push(normalizedKey);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const res = [normalized, needCastKeys];
|
|
cache.set(comp, res);
|
|
return res;
|
|
}
|
|
function validatePropName(key) {
|
|
if (key[0] !== "$") {
|
|
return true;
|
|
} else {
|
|
warn$1(`Invalid prop name: "${key}" is a reserved property.`);
|
|
}
|
|
return false;
|
|
}
|
|
function getType(ctor) {
|
|
const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
|
|
return match ? match[1] : ctor === null ? "null" : "";
|
|
}
|
|
function isSameType(a2, b2) {
|
|
return getType(a2) === getType(b2);
|
|
}
|
|
function getTypeIndex(type, expectedTypes) {
|
|
if (isArray(expectedTypes)) {
|
|
return expectedTypes.findIndex((t2) => isSameType(t2, type));
|
|
} else if (isFunction(expectedTypes)) {
|
|
return isSameType(expectedTypes, type) ? 0 : -1;
|
|
}
|
|
return -1;
|
|
}
|
|
function validateProps(rawProps, props, instance) {
|
|
const resolvedValues = toRaw(props);
|
|
const options = instance.propsOptions[0];
|
|
for (const key in options) {
|
|
let opt = options[key];
|
|
if (opt == null)
|
|
continue;
|
|
validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
|
|
}
|
|
}
|
|
function validateProp(name, value, prop, isAbsent) {
|
|
const { type, required, validator } = prop;
|
|
if (required && isAbsent) {
|
|
warn$1('Missing required prop: "' + name + '"');
|
|
return;
|
|
}
|
|
if (value == null && !prop.required) {
|
|
return;
|
|
}
|
|
if (type != null && type !== true) {
|
|
let isValid = false;
|
|
const types = isArray(type) ? type : [type];
|
|
const expectedTypes = [];
|
|
for (let i2 = 0; i2 < types.length && !isValid; i2++) {
|
|
const { valid, expectedType } = assertType(value, types[i2]);
|
|
expectedTypes.push(expectedType || "");
|
|
isValid = valid;
|
|
}
|
|
if (!isValid) {
|
|
warn$1(getInvalidTypeMessage(name, value, expectedTypes));
|
|
return;
|
|
}
|
|
}
|
|
if (validator && !validator(value)) {
|
|
warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
|
|
}
|
|
}
|
|
const isSimpleType = /* @__PURE__ */ makeMap("String,Number,Boolean,Function,Symbol,BigInt");
|
|
function assertType(value, type) {
|
|
let valid;
|
|
const expectedType = getType(type);
|
|
if (isSimpleType(expectedType)) {
|
|
const t2 = typeof value;
|
|
valid = t2 === expectedType.toLowerCase();
|
|
if (!valid && t2 === "object") {
|
|
valid = value instanceof type;
|
|
}
|
|
} else if (expectedType === "Object") {
|
|
valid = isObject$1(value);
|
|
} else if (expectedType === "Array") {
|
|
valid = isArray(value);
|
|
} else if (expectedType === "null") {
|
|
valid = value === null;
|
|
} else {
|
|
valid = value instanceof type;
|
|
}
|
|
return {
|
|
valid,
|
|
expectedType
|
|
};
|
|
}
|
|
function getInvalidTypeMessage(name, value, expectedTypes) {
|
|
let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
|
|
const expectedType = expectedTypes[0];
|
|
const receivedType = toRawType(value);
|
|
const expectedValue = styleValue(value, expectedType);
|
|
const receivedValue = styleValue(value, receivedType);
|
|
if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
|
|
message += ` with value ${expectedValue}`;
|
|
}
|
|
message += `, got ${receivedType} `;
|
|
if (isExplicable(receivedType)) {
|
|
message += `with value ${receivedValue}.`;
|
|
}
|
|
return message;
|
|
}
|
|
function styleValue(value, type) {
|
|
if (type === "String") {
|
|
return `"${value}"`;
|
|
} else if (type === "Number") {
|
|
return `${Number(value)}`;
|
|
} else {
|
|
return `${value}`;
|
|
}
|
|
}
|
|
function isExplicable(type) {
|
|
const explicitTypes = ["string", "number", "boolean"];
|
|
return explicitTypes.some((elem) => type.toLowerCase() === elem);
|
|
}
|
|
function isBoolean(...args) {
|
|
return args.some((elem) => elem.toLowerCase() === "boolean");
|
|
}
|
|
function createAppContext() {
|
|
return {
|
|
app: null,
|
|
config: {
|
|
isNativeTag: NO,
|
|
performance: false,
|
|
globalProperties: {},
|
|
optionMergeStrategies: {},
|
|
errorHandler: void 0,
|
|
warnHandler: void 0,
|
|
compilerOptions: {}
|
|
},
|
|
mixins: [],
|
|
components: {},
|
|
directives: {},
|
|
provides: /* @__PURE__ */ Object.create(null),
|
|
optionsCache: /* @__PURE__ */ new WeakMap(),
|
|
propsCache: /* @__PURE__ */ new WeakMap(),
|
|
emitsCache: /* @__PURE__ */ new WeakMap()
|
|
};
|
|
}
|
|
let uid = 0;
|
|
function createAppAPI(render, hydrate) {
|
|
return function createApp2(rootComponent, rootProps = null) {
|
|
if (!isFunction(rootComponent)) {
|
|
rootComponent = Object.assign({}, rootComponent);
|
|
}
|
|
if (rootProps != null && !isObject$1(rootProps)) {
|
|
warn$1(`root props passed to app.mount() must be an object.`);
|
|
rootProps = null;
|
|
}
|
|
const context = createAppContext();
|
|
const installedPlugins = /* @__PURE__ */ new Set();
|
|
const app = context.app = {
|
|
_uid: uid++,
|
|
_component: rootComponent,
|
|
_props: rootProps,
|
|
_container: null,
|
|
_context: context,
|
|
_instance: null,
|
|
version,
|
|
get config() {
|
|
return context.config;
|
|
},
|
|
set config(v2) {
|
|
{
|
|
warn$1(`app.config cannot be replaced. Modify individual options instead.`);
|
|
}
|
|
},
|
|
use(plugin2, ...options) {
|
|
if (installedPlugins.has(plugin2)) {
|
|
warn$1(`Plugin has already been applied to target app.`);
|
|
} else if (plugin2 && isFunction(plugin2.install)) {
|
|
installedPlugins.add(plugin2);
|
|
plugin2.install(app, ...options);
|
|
} else if (isFunction(plugin2)) {
|
|
installedPlugins.add(plugin2);
|
|
plugin2(app, ...options);
|
|
} else {
|
|
warn$1(`A plugin must either be a function or an object with an "install" function.`);
|
|
}
|
|
return app;
|
|
},
|
|
mixin(mixin) {
|
|
{
|
|
if (!context.mixins.includes(mixin)) {
|
|
context.mixins.push(mixin);
|
|
} else {
|
|
warn$1("Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : ""));
|
|
}
|
|
}
|
|
return app;
|
|
},
|
|
component(name, component) {
|
|
{
|
|
validateComponentName(name, context.config);
|
|
}
|
|
if (!component) {
|
|
return context.components[name];
|
|
}
|
|
if (context.components[name]) {
|
|
warn$1(`Component "${name}" has already been registered in target app.`);
|
|
}
|
|
context.components[name] = component;
|
|
return app;
|
|
},
|
|
directive(name, directive) {
|
|
{
|
|
validateDirectiveName(name);
|
|
}
|
|
if (!directive) {
|
|
return context.directives[name];
|
|
}
|
|
if (context.directives[name]) {
|
|
warn$1(`Directive "${name}" has already been registered in target app.`);
|
|
}
|
|
context.directives[name] = directive;
|
|
return app;
|
|
},
|
|
mount() {
|
|
},
|
|
unmount() {
|
|
},
|
|
provide(key, value) {
|
|
if (key in context.provides) {
|
|
warn$1(`App already provides property with key "${String(key)}". It will be overwritten with the new value.`);
|
|
}
|
|
context.provides[key] = value;
|
|
return app;
|
|
}
|
|
};
|
|
return app;
|
|
};
|
|
}
|
|
const queuePostRenderEffect = queuePostFlushCb;
|
|
function isVNode(value) {
|
|
return value ? value.__v_isVNode === true : false;
|
|
}
|
|
const InternalObjectKey = `__vInternal`;
|
|
function guardReactiveProps(props) {
|
|
if (!props)
|
|
return null;
|
|
return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
|
|
}
|
|
const emptyAppContext = createAppContext();
|
|
let uid$1 = 0;
|
|
function createComponentInstance(vnode, parent, suspense) {
|
|
const type = vnode.type;
|
|
const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
|
const instance = {
|
|
uid: uid$1++,
|
|
vnode,
|
|
type,
|
|
parent,
|
|
appContext,
|
|
root: null,
|
|
next: null,
|
|
subTree: null,
|
|
effect: null,
|
|
update: null,
|
|
scope: new EffectScope(true),
|
|
render: null,
|
|
proxy: null,
|
|
exposed: null,
|
|
exposeProxy: null,
|
|
withProxy: null,
|
|
provides: parent ? parent.provides : Object.create(appContext.provides),
|
|
accessCache: null,
|
|
renderCache: [],
|
|
components: null,
|
|
directives: null,
|
|
propsOptions: normalizePropsOptions(type, appContext),
|
|
emitsOptions: normalizeEmitsOptions(type, appContext),
|
|
emit: null,
|
|
emitted: null,
|
|
propsDefaults: EMPTY_OBJ,
|
|
inheritAttrs: type.inheritAttrs,
|
|
ctx: EMPTY_OBJ,
|
|
data: EMPTY_OBJ,
|
|
props: EMPTY_OBJ,
|
|
attrs: EMPTY_OBJ,
|
|
slots: EMPTY_OBJ,
|
|
refs: EMPTY_OBJ,
|
|
setupState: EMPTY_OBJ,
|
|
setupContext: null,
|
|
suspense,
|
|
suspenseId: suspense ? suspense.pendingId : 0,
|
|
asyncDep: null,
|
|
asyncResolved: false,
|
|
isMounted: false,
|
|
isUnmounted: false,
|
|
isDeactivated: false,
|
|
bc: null,
|
|
c: null,
|
|
bm: null,
|
|
m: null,
|
|
bu: null,
|
|
u: null,
|
|
um: null,
|
|
bum: null,
|
|
da: null,
|
|
a: null,
|
|
rtg: null,
|
|
rtc: null,
|
|
ec: null,
|
|
sp: null
|
|
};
|
|
{
|
|
instance.ctx = createDevRenderContext(instance);
|
|
}
|
|
instance.root = parent ? parent.root : instance;
|
|
instance.emit = emit$1.bind(null, instance);
|
|
if (vnode.ce) {
|
|
vnode.ce(instance);
|
|
}
|
|
return instance;
|
|
}
|
|
let currentInstance = null;
|
|
const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
|
const setCurrentInstance = (instance) => {
|
|
currentInstance = instance;
|
|
instance.scope.on();
|
|
};
|
|
const unsetCurrentInstance = () => {
|
|
currentInstance && currentInstance.scope.off();
|
|
currentInstance = null;
|
|
};
|
|
const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");
|
|
function validateComponentName(name, config) {
|
|
const appIsNativeTag = config.isNativeTag || NO;
|
|
if (isBuiltInTag(name) || appIsNativeTag(name)) {
|
|
warn$1("Do not use built-in or reserved HTML elements as component id: " + name);
|
|
}
|
|
}
|
|
function isStatefulComponent(instance) {
|
|
return instance.vnode.shapeFlag & 4;
|
|
}
|
|
let isInSSRComponentSetup = false;
|
|
function setupComponent(instance, isSSR = false) {
|
|
isInSSRComponentSetup = isSSR;
|
|
const { props } = instance.vnode;
|
|
const isStateful = isStatefulComponent(instance);
|
|
initProps$1(instance, props, isStateful, isSSR);
|
|
const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
|
|
isInSSRComponentSetup = false;
|
|
return setupResult;
|
|
}
|
|
function setupStatefulComponent(instance, isSSR) {
|
|
const Component2 = instance.type;
|
|
{
|
|
if (Component2.name) {
|
|
validateComponentName(Component2.name, instance.appContext.config);
|
|
}
|
|
if (Component2.components) {
|
|
const names = Object.keys(Component2.components);
|
|
for (let i2 = 0; i2 < names.length; i2++) {
|
|
validateComponentName(names[i2], instance.appContext.config);
|
|
}
|
|
}
|
|
if (Component2.directives) {
|
|
const names = Object.keys(Component2.directives);
|
|
for (let i2 = 0; i2 < names.length; i2++) {
|
|
validateDirectiveName(names[i2]);
|
|
}
|
|
}
|
|
if (Component2.compilerOptions && isRuntimeOnly()) {
|
|
warn$1(`"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`);
|
|
}
|
|
}
|
|
instance.accessCache = /* @__PURE__ */ Object.create(null);
|
|
instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
|
|
{
|
|
exposePropsOnRenderContext(instance);
|
|
}
|
|
const { setup } = Component2;
|
|
if (setup) {
|
|
const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
|
|
setCurrentInstance(instance);
|
|
pauseTracking();
|
|
const setupResult = callWithErrorHandling(setup, instance, 0, [shallowReadonly(instance.props), setupContext]);
|
|
resetTracking();
|
|
unsetCurrentInstance();
|
|
if (isPromise(setupResult)) {
|
|
setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
|
{
|
|
warn$1(`setup() returned a Promise, but the version of Vue you are using does not support it yet.`);
|
|
}
|
|
} else {
|
|
handleSetupResult(instance, setupResult, isSSR);
|
|
}
|
|
} else {
|
|
finishComponentSetup(instance, isSSR);
|
|
}
|
|
}
|
|
function handleSetupResult(instance, setupResult, isSSR) {
|
|
if (isFunction(setupResult)) {
|
|
{
|
|
instance.render = setupResult;
|
|
}
|
|
} else if (isObject$1(setupResult)) {
|
|
if (isVNode(setupResult)) {
|
|
warn$1(`setup() should not return VNodes directly - return a render function instead.`);
|
|
}
|
|
{
|
|
instance.devtoolsRawSetupState = setupResult;
|
|
}
|
|
instance.setupState = proxyRefs(setupResult);
|
|
{
|
|
exposeSetupStateOnRenderContext(instance);
|
|
}
|
|
} else if (setupResult !== void 0) {
|
|
warn$1(`setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`);
|
|
}
|
|
finishComponentSetup(instance, isSSR);
|
|
}
|
|
let compile;
|
|
const isRuntimeOnly = () => !compile;
|
|
function finishComponentSetup(instance, isSSR, skipOptions) {
|
|
const Component2 = instance.type;
|
|
if (!instance.render) {
|
|
instance.render = Component2.render || NOOP;
|
|
}
|
|
{
|
|
setCurrentInstance(instance);
|
|
pauseTracking();
|
|
applyOptions$1(instance);
|
|
resetTracking();
|
|
unsetCurrentInstance();
|
|
}
|
|
if (!Component2.render && instance.render === NOOP && !isSSR) {
|
|
if (Component2.template) {
|
|
warn$1(`Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".`);
|
|
} else {
|
|
warn$1(`Component is missing template or render function.`);
|
|
}
|
|
}
|
|
}
|
|
function createAttrsProxy(instance) {
|
|
return new Proxy(
|
|
instance.attrs,
|
|
{
|
|
get(target, key) {
|
|
track(instance, "get", "$attrs");
|
|
return target[key];
|
|
},
|
|
set() {
|
|
warn$1(`setupContext.attrs is readonly.`);
|
|
return false;
|
|
},
|
|
deleteProperty() {
|
|
warn$1(`setupContext.attrs is readonly.`);
|
|
return false;
|
|
}
|
|
}
|
|
);
|
|
}
|
|
function createSetupContext(instance) {
|
|
const expose = (exposed) => {
|
|
if (instance.exposed) {
|
|
warn$1(`expose() should be called only once per setup().`);
|
|
}
|
|
instance.exposed = exposed || {};
|
|
};
|
|
let attrs;
|
|
{
|
|
return Object.freeze({
|
|
get attrs() {
|
|
return attrs || (attrs = createAttrsProxy(instance));
|
|
},
|
|
get slots() {
|
|
return shallowReadonly(instance.slots);
|
|
},
|
|
get emit() {
|
|
return (event, ...args) => instance.emit(event, ...args);
|
|
},
|
|
expose
|
|
});
|
|
}
|
|
}
|
|
function getExposeProxy(instance) {
|
|
if (instance.exposed) {
|
|
return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
|
get(target, key) {
|
|
if (key in target) {
|
|
return target[key];
|
|
}
|
|
return instance.proxy[key];
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
const classifyRE = /(?:^|[-_])(\w)/g;
|
|
const classify = (str) => str.replace(classifyRE, (c2) => c2.toUpperCase()).replace(/[-_]/g, "");
|
|
function getComponentName(Component2, includeInferred = true) {
|
|
return isFunction(Component2) ? Component2.displayName || Component2.name : Component2.name || includeInferred && Component2.__name;
|
|
}
|
|
function formatComponentName(instance, Component2, isRoot = false) {
|
|
let name = getComponentName(Component2);
|
|
if (!name && Component2.__file) {
|
|
const match = Component2.__file.match(/([^/\\]+)\.\w+$/);
|
|
if (match) {
|
|
name = match[1];
|
|
}
|
|
}
|
|
if (!name && instance && instance.parent) {
|
|
const inferFromRegistry = (registry) => {
|
|
for (const key in registry) {
|
|
if (registry[key] === Component2) {
|
|
return key;
|
|
}
|
|
}
|
|
};
|
|
name = inferFromRegistry(instance.components || instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
|
|
}
|
|
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
}
|
|
const computed$1 = (getterOrOptions, debugOptions) => {
|
|
return computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
|
|
};
|
|
function useSlots() {
|
|
return getContext().slots;
|
|
}
|
|
function getContext() {
|
|
const i2 = getCurrentInstance();
|
|
if (!i2) {
|
|
warn$1(`useContext() called without active instance.`);
|
|
}
|
|
return i2.setupContext || (i2.setupContext = createSetupContext(i2));
|
|
}
|
|
const version = "3.2.37";
|
|
function unwrapper(target) {
|
|
return unref(target);
|
|
}
|
|
const ARRAYTYPE = "[object Array]";
|
|
const OBJECTTYPE = "[object Object]";
|
|
function diff(current, pre) {
|
|
const result = {};
|
|
syncKeys(current, pre);
|
|
_diff(current, pre, "", result);
|
|
return result;
|
|
}
|
|
function syncKeys(current, pre) {
|
|
current = unwrapper(current);
|
|
if (current === pre)
|
|
return;
|
|
const rootCurrentType = toTypeString(current);
|
|
const rootPreType = toTypeString(pre);
|
|
if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) {
|
|
for (let key in pre) {
|
|
const currentValue = current[key];
|
|
if (currentValue === void 0) {
|
|
current[key] = null;
|
|
} else {
|
|
syncKeys(currentValue, pre[key]);
|
|
}
|
|
}
|
|
} else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {
|
|
if (current.length >= pre.length) {
|
|
pre.forEach((item, index2) => {
|
|
syncKeys(current[index2], item);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
function _diff(current, pre, path, result) {
|
|
current = unwrapper(current);
|
|
if (current === pre)
|
|
return;
|
|
const rootCurrentType = toTypeString(current);
|
|
const rootPreType = toTypeString(pre);
|
|
if (rootCurrentType == OBJECTTYPE) {
|
|
if (rootPreType != OBJECTTYPE || Object.keys(current).length < Object.keys(pre).length) {
|
|
setResult(result, path, current);
|
|
} else {
|
|
for (let key in current) {
|
|
const currentValue = unwrapper(current[key]);
|
|
const preValue = pre[key];
|
|
const currentType = toTypeString(currentValue);
|
|
const preType = toTypeString(preValue);
|
|
if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) {
|
|
if (currentValue != preValue) {
|
|
setResult(result, (path == "" ? "" : path + ".") + key, currentValue);
|
|
}
|
|
} else if (currentType == ARRAYTYPE) {
|
|
if (preType != ARRAYTYPE) {
|
|
setResult(result, (path == "" ? "" : path + ".") + key, currentValue);
|
|
} else {
|
|
if (currentValue.length < preValue.length) {
|
|
setResult(result, (path == "" ? "" : path + ".") + key, currentValue);
|
|
} else {
|
|
currentValue.forEach((item, index2) => {
|
|
_diff(item, preValue[index2], (path == "" ? "" : path + ".") + key + "[" + index2 + "]", result);
|
|
});
|
|
}
|
|
}
|
|
} else if (currentType == OBJECTTYPE) {
|
|
if (preType != OBJECTTYPE || Object.keys(currentValue).length < Object.keys(preValue).length) {
|
|
setResult(result, (path == "" ? "" : path + ".") + key, currentValue);
|
|
} else {
|
|
for (let subKey in currentValue) {
|
|
_diff(currentValue[subKey], preValue[subKey], (path == "" ? "" : path + ".") + key + "." + subKey, result);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (rootCurrentType == ARRAYTYPE) {
|
|
if (rootPreType != ARRAYTYPE) {
|
|
setResult(result, path, current);
|
|
} else {
|
|
if (current.length < pre.length) {
|
|
setResult(result, path, current);
|
|
} else {
|
|
current.forEach((item, index2) => {
|
|
_diff(item, pre[index2], path + "[" + index2 + "]", result);
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
setResult(result, path, current);
|
|
}
|
|
}
|
|
function setResult(result, k2, v2) {
|
|
result[k2] = v2;
|
|
}
|
|
function hasComponentEffect(instance) {
|
|
return queue.includes(instance.update);
|
|
}
|
|
function flushCallbacks(instance) {
|
|
const ctx = instance.ctx;
|
|
const callbacks = ctx.__next_tick_callbacks;
|
|
if (callbacks && callbacks.length) {
|
|
if ({}.VUE_APP_DEBUG) {
|
|
const mpInstance = ctx.$scope;
|
|
console.log("[" + +new Date() + "][" + (mpInstance.is || mpInstance.route) + "][" + instance.uid + "]:flushCallbacks[" + callbacks.length + "]");
|
|
}
|
|
const copies = callbacks.slice(0);
|
|
callbacks.length = 0;
|
|
for (let i2 = 0; i2 < copies.length; i2++) {
|
|
copies[i2]();
|
|
}
|
|
}
|
|
}
|
|
function nextTick$1(instance, fn) {
|
|
const ctx = instance.ctx;
|
|
if (!ctx.__next_tick_pending && !hasComponentEffect(instance)) {
|
|
if ({}.VUE_APP_DEBUG) {
|
|
const mpInstance = ctx.$scope;
|
|
console.log("[" + +new Date() + "][" + (mpInstance.is || mpInstance.route) + "][" + instance.uid + "]:nextVueTick");
|
|
}
|
|
return nextTick(fn && fn.bind(instance.proxy));
|
|
}
|
|
if ({}.VUE_APP_DEBUG) {
|
|
const mpInstance = ctx.$scope;
|
|
console.log("[" + +new Date() + "][" + (mpInstance.is || mpInstance.route) + "][" + instance.uid + "]:nextMPTick");
|
|
}
|
|
let _resolve;
|
|
if (!ctx.__next_tick_callbacks) {
|
|
ctx.__next_tick_callbacks = [];
|
|
}
|
|
ctx.__next_tick_callbacks.push(() => {
|
|
if (fn) {
|
|
callWithErrorHandling(fn.bind(instance.proxy), instance, 14);
|
|
} else if (_resolve) {
|
|
_resolve(instance.proxy);
|
|
}
|
|
});
|
|
return new Promise((resolve2) => {
|
|
_resolve = resolve2;
|
|
});
|
|
}
|
|
function clone(src, seen) {
|
|
src = unwrapper(src);
|
|
const type = typeof src;
|
|
if (type === "object" && src !== null) {
|
|
let copy = seen.get(src);
|
|
if (typeof copy !== "undefined") {
|
|
return copy;
|
|
}
|
|
if (isArray(src)) {
|
|
const len = src.length;
|
|
copy = new Array(len);
|
|
seen.set(src, copy);
|
|
for (let i2 = 0; i2 < len; i2++) {
|
|
copy[i2] = clone(src[i2], seen);
|
|
}
|
|
} else {
|
|
copy = {};
|
|
seen.set(src, copy);
|
|
for (const name in src) {
|
|
if (hasOwn(src, name)) {
|
|
copy[name] = clone(src[name], seen);
|
|
}
|
|
}
|
|
}
|
|
return copy;
|
|
}
|
|
if (type !== "symbol") {
|
|
return src;
|
|
}
|
|
}
|
|
function deepCopy(src) {
|
|
return clone(src, typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : /* @__PURE__ */ new Map());
|
|
}
|
|
function getMPInstanceData(instance, keys) {
|
|
const data = instance.data;
|
|
const ret = /* @__PURE__ */ Object.create(null);
|
|
keys.forEach((key) => {
|
|
ret[key] = data[key];
|
|
});
|
|
return ret;
|
|
}
|
|
function patch(instance, data, oldData) {
|
|
if (!data) {
|
|
return;
|
|
}
|
|
data = deepCopy(data);
|
|
const ctx = instance.ctx;
|
|
const mpType = ctx.mpType;
|
|
if (mpType === "page" || mpType === "component") {
|
|
data.r0 = 1;
|
|
const mpInstance = ctx.$scope;
|
|
const keys = Object.keys(data);
|
|
const diffData = diff(data, oldData || getMPInstanceData(mpInstance, keys));
|
|
if (Object.keys(diffData).length) {
|
|
ctx.__next_tick_pending = true;
|
|
mpInstance.setData(diffData, () => {
|
|
ctx.__next_tick_pending = false;
|
|
flushCallbacks(instance);
|
|
});
|
|
flushPreFlushCbs(void 0, instance.update);
|
|
} else {
|
|
flushCallbacks(instance);
|
|
}
|
|
}
|
|
}
|
|
function initAppConfig(appConfig) {
|
|
appConfig.globalProperties.$nextTick = function $nextTick(fn) {
|
|
return nextTick$1(this.$, fn);
|
|
};
|
|
}
|
|
function onApplyOptions(options, instance, publicThis) {
|
|
instance.appContext.config.globalProperties.$applyOptions(options, instance, publicThis);
|
|
const computedOptions = options.computed;
|
|
if (computedOptions) {
|
|
const keys = Object.keys(computedOptions);
|
|
if (keys.length) {
|
|
const ctx = instance.ctx;
|
|
if (!ctx.$computedKeys) {
|
|
ctx.$computedKeys = [];
|
|
}
|
|
ctx.$computedKeys.push(...keys);
|
|
}
|
|
}
|
|
delete instance.ctx.$onApplyOptions;
|
|
}
|
|
function setRef$1(instance, isUnmount = false) {
|
|
const { setupState, $templateRefs, ctx: { $scope, $mpPlatform } } = instance;
|
|
if ($mpPlatform === "mp-alipay") {
|
|
return;
|
|
}
|
|
if (!$templateRefs || !$scope) {
|
|
return;
|
|
}
|
|
if (isUnmount) {
|
|
return $templateRefs.forEach((templateRef) => setTemplateRef(templateRef, null, setupState));
|
|
}
|
|
const check = $mpPlatform === "mp-baidu" || $mpPlatform === "mp-toutiao";
|
|
const doSetByRefs = (refs) => {
|
|
const mpComponents = $scope.selectAllComponents(".r").concat($scope.selectAllComponents(".r-i-f"));
|
|
return refs.filter((templateRef) => {
|
|
const refValue = findComponentPublicInstance(mpComponents, templateRef.i);
|
|
if (check && refValue === null) {
|
|
return true;
|
|
}
|
|
setTemplateRef(templateRef, refValue, setupState);
|
|
return false;
|
|
});
|
|
};
|
|
const doSet = () => {
|
|
const refs = doSetByRefs($templateRefs);
|
|
if (refs.length && instance.proxy && instance.proxy.$scope) {
|
|
instance.proxy.$scope.setData({ r1: 1 }, () => {
|
|
doSetByRefs(refs);
|
|
});
|
|
}
|
|
};
|
|
if ($scope._$setRef) {
|
|
$scope._$setRef(doSet);
|
|
} else {
|
|
nextTick$1(instance, doSet);
|
|
}
|
|
}
|
|
function findComponentPublicInstance(mpComponents, id) {
|
|
const mpInstance = mpComponents.find((com) => com && (com.properties || com.props).uI === id);
|
|
if (mpInstance) {
|
|
const vm = mpInstance.$vm;
|
|
return getExposeProxy(vm.$) || vm;
|
|
}
|
|
return null;
|
|
}
|
|
function setTemplateRef({ r: r2, f: f2 }, refValue, setupState) {
|
|
if (isFunction(r2)) {
|
|
r2(refValue, {});
|
|
} else {
|
|
const _isString = isString(r2);
|
|
const _isRef = isRef(r2);
|
|
if (_isString || _isRef) {
|
|
if (f2) {
|
|
if (!_isRef) {
|
|
return;
|
|
}
|
|
if (!isArray(r2.value)) {
|
|
r2.value = [];
|
|
}
|
|
const existing = r2.value;
|
|
if (existing.indexOf(refValue) === -1) {
|
|
existing.push(refValue);
|
|
if (!refValue) {
|
|
return;
|
|
}
|
|
onBeforeUnmount(() => remove(existing, refValue), refValue.$);
|
|
}
|
|
} else if (_isString) {
|
|
if (hasOwn(setupState, r2)) {
|
|
setupState[r2] = refValue;
|
|
}
|
|
} else if (isRef(r2)) {
|
|
r2.value = refValue;
|
|
} else {
|
|
warnRef(r2);
|
|
}
|
|
} else {
|
|
warnRef(r2);
|
|
}
|
|
}
|
|
}
|
|
function warnRef(ref2) {
|
|
warn$1("Invalid template ref type:", ref2, `(${typeof ref2})`);
|
|
}
|
|
var MPType;
|
|
(function(MPType2) {
|
|
MPType2["APP"] = "app";
|
|
MPType2["PAGE"] = "page";
|
|
MPType2["COMPONENT"] = "component";
|
|
})(MPType || (MPType = {}));
|
|
const queuePostRenderEffect$1 = queuePostFlushCb;
|
|
function mountComponent(initialVNode, options) {
|
|
const instance = initialVNode.component = createComponentInstance(initialVNode, options.parentComponent, null);
|
|
{
|
|
instance.ctx.$onApplyOptions = onApplyOptions;
|
|
instance.ctx.$children = [];
|
|
}
|
|
if (options.mpType === "app") {
|
|
instance.render = NOOP;
|
|
}
|
|
if (options.onBeforeSetup) {
|
|
options.onBeforeSetup(instance, options);
|
|
}
|
|
{
|
|
pushWarningContext(initialVNode);
|
|
}
|
|
setupComponent(instance);
|
|
{
|
|
if (options.parentComponent && instance.proxy) {
|
|
options.parentComponent.ctx.$children.push(getExposeProxy(instance) || instance.proxy);
|
|
}
|
|
}
|
|
setupRenderEffect(instance);
|
|
{
|
|
popWarningContext();
|
|
}
|
|
return instance.proxy;
|
|
}
|
|
const getFunctionalFallthrough = (attrs) => {
|
|
let res;
|
|
for (const key in attrs) {
|
|
if (key === "class" || key === "style" || isOn(key)) {
|
|
(res || (res = {}))[key] = attrs[key];
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
function renderComponentRoot(instance) {
|
|
const { type: Component2, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit: emit2, render, renderCache, data, setupState, ctx, uid: uid2, appContext: { app: { config: { globalProperties: { pruneComponentPropsCache: pruneComponentPropsCache2 } } } }, inheritAttrs } = instance;
|
|
instance.$templateRefs = [];
|
|
instance.$ei = 0;
|
|
pruneComponentPropsCache2(uid2);
|
|
instance.__counter = instance.__counter === 0 ? 1 : 0;
|
|
let result;
|
|
const prev = setCurrentRenderingInstance(instance);
|
|
try {
|
|
if (vnode.shapeFlag & 4) {
|
|
fallthroughAttrs(inheritAttrs, props, propsOptions, attrs);
|
|
const proxyToUse = withProxy || proxy;
|
|
result = render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx);
|
|
} else {
|
|
fallthroughAttrs(inheritAttrs, props, propsOptions, Component2.props ? attrs : getFunctionalFallthrough(attrs));
|
|
const render2 = Component2;
|
|
result = render2.length > 1 ? render2(props, { attrs, slots, emit: emit2 }) : render2(props, null);
|
|
}
|
|
} catch (err) {
|
|
handleError(err, instance, 1);
|
|
result = false;
|
|
}
|
|
setRef$1(instance);
|
|
setCurrentRenderingInstance(prev);
|
|
return result;
|
|
}
|
|
function fallthroughAttrs(inheritAttrs, props, propsOptions, fallthroughAttrs2) {
|
|
if (props && fallthroughAttrs2 && inheritAttrs !== false) {
|
|
const keys = Object.keys(fallthroughAttrs2).filter((key) => key !== "class" && key !== "style");
|
|
if (!keys.length) {
|
|
return;
|
|
}
|
|
if (propsOptions && keys.some(isModelListener)) {
|
|
keys.forEach((key) => {
|
|
if (!isModelListener(key) || !(key.slice(9) in propsOptions)) {
|
|
props[key] = fallthroughAttrs2[key];
|
|
}
|
|
});
|
|
} else {
|
|
keys.forEach((key) => props[key] = fallthroughAttrs2[key]);
|
|
}
|
|
}
|
|
}
|
|
const updateComponentPreRender = (instance) => {
|
|
pauseTracking();
|
|
flushPreFlushCbs(void 0, instance.update);
|
|
resetTracking();
|
|
};
|
|
function componentUpdateScopedSlotsFn() {
|
|
const scopedSlotsData = this.$scopedSlotsData;
|
|
if (!scopedSlotsData || scopedSlotsData.length === 0) {
|
|
return;
|
|
}
|
|
const mpInstance = this.ctx.$scope;
|
|
const oldData = mpInstance.data;
|
|
const diffData = /* @__PURE__ */ Object.create(null);
|
|
scopedSlotsData.forEach(({ path, index: index2, data }) => {
|
|
const oldScopedSlotData = getValueByDataPath(oldData, path);
|
|
const diffPath = isString(index2) ? `${path}.${index2}` : `${path}[${index2}]`;
|
|
if (typeof oldScopedSlotData === "undefined" || typeof oldScopedSlotData[index2] === "undefined") {
|
|
diffData[diffPath] = data;
|
|
} else {
|
|
const diffScopedSlotData = diff(data, oldScopedSlotData[index2]);
|
|
Object.keys(diffScopedSlotData).forEach((name) => {
|
|
diffData[diffPath + "." + name] = diffScopedSlotData[name];
|
|
});
|
|
}
|
|
});
|
|
scopedSlotsData.length = 0;
|
|
if (Object.keys(diffData).length) {
|
|
mpInstance.setData(diffData);
|
|
}
|
|
}
|
|
function toggleRecurse({ effect, update }, allowed) {
|
|
effect.allowRecurse = update.allowRecurse = allowed;
|
|
}
|
|
function setupRenderEffect(instance) {
|
|
const updateScopedSlots = componentUpdateScopedSlotsFn.bind(instance);
|
|
instance.$updateScopedSlots = () => nextTick(() => queueJob(updateScopedSlots));
|
|
const componentUpdateFn = () => {
|
|
if (!instance.isMounted) {
|
|
onBeforeUnmount(() => {
|
|
setRef$1(instance, true);
|
|
}, instance);
|
|
patch(instance, renderComponentRoot(instance));
|
|
} else {
|
|
const { bu, u: u2 } = instance;
|
|
toggleRecurse(instance, false);
|
|
updateComponentPreRender(instance);
|
|
if (bu) {
|
|
invokeArrayFns$1(bu);
|
|
}
|
|
toggleRecurse(instance, true);
|
|
patch(instance, renderComponentRoot(instance));
|
|
if (u2) {
|
|
queuePostRenderEffect$1(u2);
|
|
}
|
|
}
|
|
};
|
|
const effect = instance.effect = new ReactiveEffect(
|
|
componentUpdateFn,
|
|
() => queueJob(instance.update),
|
|
instance.scope
|
|
);
|
|
const update = instance.update = effect.run.bind(effect);
|
|
update.id = instance.uid;
|
|
toggleRecurse(instance, true);
|
|
{
|
|
effect.onTrack = instance.rtc ? (e2) => invokeArrayFns$1(instance.rtc, e2) : void 0;
|
|
effect.onTrigger = instance.rtg ? (e2) => invokeArrayFns$1(instance.rtg, e2) : void 0;
|
|
update.ownerInstance = instance;
|
|
}
|
|
update();
|
|
}
|
|
function unmountComponent(instance) {
|
|
const { bum, scope, update, um } = instance;
|
|
if (bum) {
|
|
invokeArrayFns$1(bum);
|
|
}
|
|
scope.stop();
|
|
if (update) {
|
|
update.active = false;
|
|
}
|
|
if (um) {
|
|
queuePostRenderEffect$1(um);
|
|
}
|
|
queuePostRenderEffect$1(() => {
|
|
instance.isUnmounted = true;
|
|
});
|
|
}
|
|
const oldCreateApp = createAppAPI();
|
|
function createVueApp(rootComponent, rootProps = null) {
|
|
const app = oldCreateApp(rootComponent, rootProps);
|
|
const appContext = app._context;
|
|
initAppConfig(appContext.config);
|
|
const createVNode = (initialVNode) => {
|
|
initialVNode.appContext = appContext;
|
|
initialVNode.shapeFlag = 6;
|
|
return initialVNode;
|
|
};
|
|
const createComponent2 = function createComponent3(initialVNode, options) {
|
|
return mountComponent(createVNode(initialVNode), options);
|
|
};
|
|
const destroyComponent = function destroyComponent2(component) {
|
|
return component && unmountComponent(component.$);
|
|
};
|
|
app.mount = function mount() {
|
|
rootComponent.render = NOOP;
|
|
const instance = mountComponent(createVNode({ type: rootComponent }), {
|
|
mpType: MPType.APP,
|
|
mpInstance: null,
|
|
parentComponent: null,
|
|
slots: [],
|
|
props: null
|
|
});
|
|
app._instance = instance.$;
|
|
instance.$app = app;
|
|
instance.$createComponent = createComponent2;
|
|
instance.$destroyComponent = destroyComponent;
|
|
appContext.$appInstance = instance;
|
|
return instance;
|
|
};
|
|
app.unmount = function unmount() {
|
|
warn$1(`Cannot unmount an app.`);
|
|
};
|
|
return app;
|
|
}
|
|
function injectLifecycleHook(name, hook, publicThis, instance) {
|
|
if (isFunction(hook)) {
|
|
injectHook(name, hook.bind(publicThis), instance);
|
|
}
|
|
}
|
|
function initHooks$1(options, instance, publicThis) {
|
|
const mpType = options.mpType || publicThis.$mpType;
|
|
if (!mpType) {
|
|
return;
|
|
}
|
|
Object.keys(options).forEach((name) => {
|
|
if (name.indexOf("on") === 0) {
|
|
const hooks = options[name];
|
|
if (isArray(hooks)) {
|
|
hooks.forEach((hook) => injectLifecycleHook(name, hook, publicThis, instance));
|
|
} else {
|
|
injectLifecycleHook(name, hooks, publicThis, instance);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function applyOptions$2(options, instance, publicThis) {
|
|
initHooks$1(options, instance, publicThis);
|
|
}
|
|
function set$2(target, key, val) {
|
|
return target[key] = val;
|
|
}
|
|
function createErrorHandler(app) {
|
|
return function errorHandler(err, instance, _info) {
|
|
if (!instance) {
|
|
throw err;
|
|
}
|
|
const appInstance = app._instance;
|
|
if (!appInstance || !appInstance.proxy) {
|
|
throw err;
|
|
}
|
|
{
|
|
appInstance.proxy.$callHook(ON_ERROR, err);
|
|
}
|
|
};
|
|
}
|
|
function mergeAsArray(to, from) {
|
|
return to ? [...new Set([].concat(to, from))] : from;
|
|
}
|
|
function initOptionMergeStrategies(optionMergeStrategies) {
|
|
UniLifecycleHooks.forEach((name) => {
|
|
optionMergeStrategies[name] = mergeAsArray;
|
|
});
|
|
}
|
|
let realAtob;
|
|
const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
|
|
if (typeof atob !== "function") {
|
|
realAtob = function(str) {
|
|
str = String(str).replace(/[\t\n\f\r ]+/g, "");
|
|
if (!b64re.test(str)) {
|
|
throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
|
|
}
|
|
str += "==".slice(2 - (str.length & 3));
|
|
var bitmap;
|
|
var result = "";
|
|
var r1;
|
|
var r2;
|
|
var i2 = 0;
|
|
for (; i2 < str.length; ) {
|
|
bitmap = b64.indexOf(str.charAt(i2++)) << 18 | b64.indexOf(str.charAt(i2++)) << 12 | (r1 = b64.indexOf(str.charAt(i2++))) << 6 | (r2 = b64.indexOf(str.charAt(i2++)));
|
|
result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255, bitmap & 255);
|
|
}
|
|
return result;
|
|
};
|
|
} else {
|
|
realAtob = atob;
|
|
}
|
|
function b64DecodeUnicode(str) {
|
|
return decodeURIComponent(realAtob(str).split("").map(function(c2) {
|
|
return "%" + ("00" + c2.charCodeAt(0).toString(16)).slice(-2);
|
|
}).join(""));
|
|
}
|
|
function getCurrentUserInfo() {
|
|
const token = index.getStorageSync("uni_id_token") || "";
|
|
const tokenArr = token.split(".");
|
|
if (!token || tokenArr.length !== 3) {
|
|
return {
|
|
uid: null,
|
|
role: [],
|
|
permission: [],
|
|
tokenExpired: 0
|
|
};
|
|
}
|
|
let userInfo;
|
|
try {
|
|
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
|
|
} catch (error) {
|
|
throw new Error("\u83B7\u53D6\u5F53\u524D\u7528\u6237\u4FE1\u606F\u51FA\u9519\uFF0C\u8BE6\u7EC6\u9519\u8BEF\u4FE1\u606F\u4E3A\uFF1A" + error.message);
|
|
}
|
|
userInfo.tokenExpired = userInfo.exp * 1e3;
|
|
delete userInfo.exp;
|
|
delete userInfo.iat;
|
|
return userInfo;
|
|
}
|
|
function uniIdMixin(globalProperties) {
|
|
globalProperties.uniIDHasRole = function(roleId) {
|
|
const { role } = getCurrentUserInfo();
|
|
return role.indexOf(roleId) > -1;
|
|
};
|
|
globalProperties.uniIDHasPermission = function(permissionId) {
|
|
const { permission } = getCurrentUserInfo();
|
|
return this.uniIDHasRole("admin") || permission.indexOf(permissionId) > -1;
|
|
};
|
|
globalProperties.uniIDTokenValid = function() {
|
|
const { tokenExpired } = getCurrentUserInfo();
|
|
return tokenExpired > Date.now();
|
|
};
|
|
}
|
|
function initApp(app) {
|
|
const appConfig = app._context.config;
|
|
if (isFunction(app._component.onError)) {
|
|
appConfig.errorHandler = createErrorHandler(app);
|
|
}
|
|
initOptionMergeStrategies(appConfig.optionMergeStrategies);
|
|
const globalProperties = appConfig.globalProperties;
|
|
{
|
|
uniIdMixin(globalProperties);
|
|
}
|
|
{
|
|
globalProperties.$set = set$2;
|
|
globalProperties.$applyOptions = applyOptions$2;
|
|
}
|
|
{
|
|
index.invokeCreateVueAppHook(app);
|
|
}
|
|
}
|
|
const propsCaches = /* @__PURE__ */ Object.create(null);
|
|
function renderProps(props) {
|
|
const { uid: uid2, __counter } = getCurrentInstance();
|
|
const propsId = (propsCaches[uid2] || (propsCaches[uid2] = [])).push(guardReactiveProps(props)) - 1;
|
|
return uid2 + "," + propsId + "," + __counter;
|
|
}
|
|
function pruneComponentPropsCache(uid2) {
|
|
delete propsCaches[uid2];
|
|
}
|
|
function findComponentPropsData(up) {
|
|
if (!up) {
|
|
return;
|
|
}
|
|
const [uid2, propsId] = up.split(",");
|
|
if (!propsCaches[uid2]) {
|
|
return;
|
|
}
|
|
return propsCaches[uid2][parseInt(propsId)];
|
|
}
|
|
var plugin = {
|
|
install(app) {
|
|
initApp(app);
|
|
app.config.globalProperties.pruneComponentPropsCache = pruneComponentPropsCache;
|
|
const oldMount = app.mount;
|
|
app.mount = function mount(rootContainer) {
|
|
const instance = oldMount.call(app, rootContainer);
|
|
const createApp2 = getCreateApp();
|
|
if (createApp2) {
|
|
createApp2(instance);
|
|
} else {
|
|
if (typeof createMiniProgramApp !== "undefined") {
|
|
createMiniProgramApp(instance);
|
|
}
|
|
}
|
|
return instance;
|
|
};
|
|
}
|
|
};
|
|
function getCreateApp() {
|
|
const method = {}.UNI_MP_PLUGIN ? "createPluginApp" : {}.UNI_SUBPACKAGE ? "createSubpackageApp" : "createApp";
|
|
if (typeof global !== "undefined") {
|
|
return global[method];
|
|
} else if (typeof my !== "undefined") {
|
|
return my[method];
|
|
}
|
|
}
|
|
function vOn(value, key) {
|
|
const instance = getCurrentInstance();
|
|
const ctx = instance.ctx;
|
|
const extraKey = typeof key !== "undefined" && (ctx.$mpPlatform === "mp-weixin" || ctx.$mpPlatform === "mp-qq") && (isString(key) || typeof key === "number") ? "_" + key : "";
|
|
const name = "e" + instance.$ei++ + extraKey;
|
|
const mpInstance = ctx.$scope;
|
|
if (!value) {
|
|
delete mpInstance[name];
|
|
return name;
|
|
}
|
|
const existingInvoker = mpInstance[name];
|
|
if (existingInvoker) {
|
|
existingInvoker.value = value;
|
|
} else {
|
|
mpInstance[name] = createInvoker(value, instance);
|
|
}
|
|
return name;
|
|
}
|
|
function createInvoker(initialValue, instance) {
|
|
const invoker = (e2) => {
|
|
patchMPEvent(e2);
|
|
let args = [e2];
|
|
if (e2.detail && e2.detail.__args__) {
|
|
args = e2.detail.__args__;
|
|
}
|
|
const eventValue = invoker.value;
|
|
const invoke = () => callWithAsyncErrorHandling(patchStopImmediatePropagation(e2, eventValue), instance, 5, args);
|
|
const eventTarget = e2.target;
|
|
const eventSync = eventTarget ? eventTarget.dataset ? eventTarget.dataset.eventsync === "true" : false : false;
|
|
if (bubbles.includes(e2.type) && !eventSync) {
|
|
setTimeout(invoke);
|
|
} else {
|
|
const res = invoke();
|
|
if (e2.type === "input" && (isArray(res) || isPromise(res))) {
|
|
return;
|
|
}
|
|
return res;
|
|
}
|
|
};
|
|
invoker.value = initialValue;
|
|
return invoker;
|
|
}
|
|
const bubbles = [
|
|
"tap",
|
|
"longpress",
|
|
"longtap",
|
|
"transitionend",
|
|
"animationstart",
|
|
"animationiteration",
|
|
"animationend",
|
|
"touchforcechange"
|
|
];
|
|
function patchMPEvent(event) {
|
|
if (event.type && event.target) {
|
|
event.preventDefault = NOOP;
|
|
event.stopPropagation = NOOP;
|
|
event.stopImmediatePropagation = NOOP;
|
|
if (!hasOwn(event, "detail")) {
|
|
event.detail = {};
|
|
}
|
|
if (hasOwn(event, "markerId")) {
|
|
event.detail = typeof event.detail === "object" ? event.detail : {};
|
|
event.detail.markerId = event.markerId;
|
|
}
|
|
if (isPlainObject$1(event.detail) && hasOwn(event.detail, "checked") && !hasOwn(event.detail, "value")) {
|
|
event.detail.value = event.detail.checked;
|
|
}
|
|
if (isPlainObject$1(event.detail)) {
|
|
event.target = extend({}, event.target, event.detail);
|
|
}
|
|
}
|
|
}
|
|
function patchStopImmediatePropagation(e2, value) {
|
|
if (isArray(value)) {
|
|
const originalStop = e2.stopImmediatePropagation;
|
|
e2.stopImmediatePropagation = () => {
|
|
originalStop && originalStop.call(e2);
|
|
e2._stopped = true;
|
|
};
|
|
return value.map((fn) => (e3) => !e3._stopped && fn(e3));
|
|
} else {
|
|
return value;
|
|
}
|
|
}
|
|
function vFor(source, renderItem) {
|
|
let ret;
|
|
if (isArray(source) || isString(source)) {
|
|
ret = new Array(source.length);
|
|
for (let i2 = 0, l2 = source.length; i2 < l2; i2++) {
|
|
ret[i2] = renderItem(source[i2], i2, i2);
|
|
}
|
|
} else if (typeof source === "number") {
|
|
if (!Number.isInteger(source)) {
|
|
warn$1(`The v-for range expect an integer value but got ${source}.`);
|
|
return [];
|
|
}
|
|
ret = new Array(source);
|
|
for (let i2 = 0; i2 < source; i2++) {
|
|
ret[i2] = renderItem(i2 + 1, i2, i2);
|
|
}
|
|
} else if (isObject$1(source)) {
|
|
if (source[Symbol.iterator]) {
|
|
ret = Array.from(source, (item, i2) => renderItem(item, i2, i2));
|
|
} else {
|
|
const keys = Object.keys(source);
|
|
ret = new Array(keys.length);
|
|
for (let i2 = 0, l2 = keys.length; i2 < l2; i2++) {
|
|
const key = keys[i2];
|
|
ret[i2] = renderItem(source[key], key, i2);
|
|
}
|
|
}
|
|
} else {
|
|
ret = [];
|
|
}
|
|
return ret;
|
|
}
|
|
function renderSlot(name, props = {}, key) {
|
|
const instance = getCurrentInstance();
|
|
const { parent, isMounted, ctx: { $scope } } = instance;
|
|
const vueIds = ($scope.properties || $scope.props).uI;
|
|
if (!vueIds) {
|
|
return;
|
|
}
|
|
if (!parent && !isMounted) {
|
|
onMounted(() => {
|
|
renderSlot(name, props, key);
|
|
}, instance);
|
|
return;
|
|
}
|
|
const invoker = findScopedSlotInvoker(vueIds, instance);
|
|
if (invoker) {
|
|
invoker(name, props, key);
|
|
}
|
|
}
|
|
function findScopedSlotInvoker(vueId, instance) {
|
|
let parent = instance.parent;
|
|
while (parent) {
|
|
const invokers = parent.$ssi;
|
|
if (invokers && invokers[vueId]) {
|
|
return invokers[vueId];
|
|
}
|
|
parent = parent.parent;
|
|
}
|
|
}
|
|
function stringifyStyle(value) {
|
|
if (isString(value)) {
|
|
return value;
|
|
}
|
|
return stringify(normalizeStyle(value));
|
|
}
|
|
function stringify(styles) {
|
|
let ret = "";
|
|
if (!styles || isString(styles)) {
|
|
return ret;
|
|
}
|
|
for (const key in styles) {
|
|
ret += `${key.startsWith(`--`) ? key : hyphenate(key)}:${styles[key]};`;
|
|
}
|
|
return ret;
|
|
}
|
|
const o$1 = (value, key) => vOn(value, key);
|
|
const f$1 = (source, renderItem) => vFor(source, renderItem);
|
|
const r$1 = (name, props, key) => renderSlot(name, props, key);
|
|
const s$1 = (value) => stringifyStyle(value);
|
|
const e$1 = (target, ...sources) => extend(target, ...sources);
|
|
const n$1 = (value) => normalizeClass(value);
|
|
const t$1 = (val) => toDisplayString(val);
|
|
const p$1 = (props) => renderProps(props);
|
|
function createApp$1(rootComponent, rootProps = null) {
|
|
rootComponent && (rootComponent.mpType = "app");
|
|
return createVueApp(rootComponent, rootProps).use(plugin);
|
|
}
|
|
const createSSRApp = createApp$1;
|
|
const eventChannels = {};
|
|
const eventChannelStack = [];
|
|
function getEventChannel(id) {
|
|
if (id) {
|
|
const eventChannel = eventChannels[id];
|
|
delete eventChannels[id];
|
|
return eventChannel;
|
|
}
|
|
return eventChannelStack.shift();
|
|
}
|
|
const MP_METHODS = [
|
|
"createSelectorQuery",
|
|
"createIntersectionObserver",
|
|
"selectAllComponents",
|
|
"selectComponent"
|
|
];
|
|
function createEmitFn(oldEmit, ctx) {
|
|
return function emit2(event, ...args) {
|
|
const scope = ctx.$scope;
|
|
if (scope && event) {
|
|
const detail = { __args__: args };
|
|
{
|
|
scope.triggerEvent(event, detail);
|
|
}
|
|
}
|
|
return oldEmit.apply(this, [event, ...args]);
|
|
};
|
|
}
|
|
function initBaseInstance(instance, options) {
|
|
const ctx = instance.ctx;
|
|
ctx.mpType = options.mpType;
|
|
ctx.$mpType = options.mpType;
|
|
ctx.$mpPlatform = "mp-weixin";
|
|
ctx.$scope = options.mpInstance;
|
|
ctx.$mp = {};
|
|
{
|
|
ctx._self = {};
|
|
}
|
|
instance.slots = {};
|
|
if (isArray(options.slots) && options.slots.length) {
|
|
options.slots.forEach((name) => {
|
|
instance.slots[name] = true;
|
|
});
|
|
if (instance.slots[SLOT_DEFAULT_NAME]) {
|
|
instance.slots.default = true;
|
|
}
|
|
}
|
|
ctx.getOpenerEventChannel = function() {
|
|
{
|
|
return options.mpInstance.getOpenerEventChannel();
|
|
}
|
|
};
|
|
ctx.$hasHook = hasHook;
|
|
ctx.$callHook = callHook;
|
|
instance.emit = createEmitFn(instance.emit, ctx);
|
|
}
|
|
function initComponentInstance(instance, options) {
|
|
initBaseInstance(instance, options);
|
|
const ctx = instance.ctx;
|
|
MP_METHODS.forEach((method) => {
|
|
ctx[method] = function(...args) {
|
|
const mpInstance = ctx.$scope;
|
|
if (mpInstance && mpInstance[method]) {
|
|
return mpInstance[method].apply(mpInstance, args);
|
|
}
|
|
};
|
|
});
|
|
}
|
|
function initMocks(instance, mpInstance, mocks2) {
|
|
const ctx = instance.ctx;
|
|
mocks2.forEach((mock) => {
|
|
if (hasOwn(mpInstance, mock)) {
|
|
instance[mock] = ctx[mock] = mpInstance[mock];
|
|
}
|
|
});
|
|
}
|
|
function hasHook(name) {
|
|
const hooks = this.$[name];
|
|
if (hooks && hooks.length) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function callHook(name, args) {
|
|
if (name === "mounted") {
|
|
callHook.call(this, "bm");
|
|
this.$.isMounted = true;
|
|
name = "m";
|
|
} else if (name === "onLoad" && args && args.__id__) {
|
|
this.__eventChannel__ = getEventChannel(args.__id__);
|
|
delete args.__id__;
|
|
}
|
|
const hooks = this.$[name];
|
|
return hooks && invokeArrayFns(hooks, args);
|
|
}
|
|
const PAGE_INIT_HOOKS = [
|
|
ON_LOAD,
|
|
ON_SHOW,
|
|
ON_HIDE,
|
|
ON_UNLOAD,
|
|
ON_RESIZE,
|
|
ON_TAB_ITEM_TAP,
|
|
ON_REACH_BOTTOM,
|
|
ON_PULL_DOWN_REFRESH,
|
|
ON_ADD_TO_FAVORITES
|
|
];
|
|
function findHooks(vueOptions, hooks = /* @__PURE__ */ new Set()) {
|
|
if (vueOptions) {
|
|
Object.keys(vueOptions).forEach((name) => {
|
|
if (name.indexOf("on") === 0 && isFunction(vueOptions[name])) {
|
|
hooks.add(name);
|
|
}
|
|
});
|
|
{
|
|
const { extends: extendsOptions, mixins } = vueOptions;
|
|
if (mixins) {
|
|
mixins.forEach((mixin) => findHooks(mixin, hooks));
|
|
}
|
|
if (extendsOptions) {
|
|
findHooks(extendsOptions, hooks);
|
|
}
|
|
}
|
|
}
|
|
return hooks;
|
|
}
|
|
function initHook(mpOptions, hook, excludes) {
|
|
if (excludes.indexOf(hook) === -1 && !hasOwn(mpOptions, hook)) {
|
|
mpOptions[hook] = function(args) {
|
|
return this.$vm && this.$vm.$callHook(hook, args);
|
|
};
|
|
}
|
|
}
|
|
const EXCLUDE_HOOKS = [ON_READY];
|
|
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
|
|
hooks.forEach((hook) => initHook(mpOptions, hook, excludes));
|
|
}
|
|
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
|
|
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes));
|
|
}
|
|
function initRuntimeHooks(mpOptions, runtimeHooks) {
|
|
if (!runtimeHooks) {
|
|
return;
|
|
}
|
|
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
|
|
hooks.forEach((hook) => {
|
|
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
|
|
initHook(mpOptions, hook, []);
|
|
}
|
|
});
|
|
}
|
|
const findMixinRuntimeHooks = /* @__PURE__ */ once(() => {
|
|
const runtimeHooks = [];
|
|
const app = getApp({ allowDefault: true });
|
|
if (app && app.$vm && app.$vm.$) {
|
|
const mixins = app.$vm.$.appContext.mixins;
|
|
if (isArray(mixins)) {
|
|
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
|
|
mixins.forEach((mixin) => {
|
|
hooks.forEach((hook) => {
|
|
if (hasOwn(mixin, hook) && !runtimeHooks.includes(hook)) {
|
|
runtimeHooks.push(hook);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
return runtimeHooks;
|
|
});
|
|
function initMixinRuntimeHooks(mpOptions) {
|
|
initHooks(mpOptions, findMixinRuntimeHooks());
|
|
}
|
|
const HOOKS = [
|
|
ON_SHOW,
|
|
ON_HIDE,
|
|
ON_ERROR,
|
|
ON_THEME_CHANGE,
|
|
ON_PAGE_NOT_FOUND,
|
|
ON_UNHANDLE_REJECTION
|
|
];
|
|
function parseApp(instance, parseAppOptions) {
|
|
const internalInstance = instance.$;
|
|
const appOptions = {
|
|
globalData: instance.$options && instance.$options.globalData || {},
|
|
$vm: instance,
|
|
onLaunch(options) {
|
|
this.$vm = instance;
|
|
const ctx = internalInstance.ctx;
|
|
if (this.$vm && ctx.$scope) {
|
|
return;
|
|
}
|
|
initBaseInstance(internalInstance, {
|
|
mpType: "app",
|
|
mpInstance: this,
|
|
slots: []
|
|
});
|
|
ctx.globalData = this.globalData;
|
|
instance.$callHook(ON_LAUNCH, options);
|
|
}
|
|
};
|
|
initLocale(instance);
|
|
const vueOptions = instance.$.type;
|
|
initHooks(appOptions, HOOKS);
|
|
initUnknownHooks(appOptions, vueOptions);
|
|
{
|
|
const methods = vueOptions.methods;
|
|
methods && extend(appOptions, methods);
|
|
}
|
|
if (parseAppOptions) {
|
|
parseAppOptions.parse(appOptions);
|
|
}
|
|
return appOptions;
|
|
}
|
|
function initCreateApp(parseAppOptions) {
|
|
return function createApp2(vm) {
|
|
return App(parseApp(vm, parseAppOptions));
|
|
};
|
|
}
|
|
function initCreateSubpackageApp(parseAppOptions) {
|
|
return function createApp2(vm) {
|
|
const appOptions = parseApp(vm, parseAppOptions);
|
|
const app = getApp({
|
|
allowDefault: true
|
|
});
|
|
vm.$.ctx.$scope = app;
|
|
const globalData = app.globalData;
|
|
if (globalData) {
|
|
Object.keys(appOptions.globalData).forEach((name) => {
|
|
if (!hasOwn(globalData, name)) {
|
|
globalData[name] = appOptions.globalData[name];
|
|
}
|
|
});
|
|
}
|
|
Object.keys(appOptions).forEach((name) => {
|
|
if (!hasOwn(app, name)) {
|
|
app[name] = appOptions[name];
|
|
}
|
|
});
|
|
initAppLifecycle(appOptions, vm);
|
|
if ({}.UNI_SUBPACKAGE) {
|
|
(wx.$subpackages || (wx.$subpackages = {}))[{}.UNI_SUBPACKAGE] = {
|
|
$vm: vm
|
|
};
|
|
}
|
|
};
|
|
}
|
|
function initAppLifecycle(appOptions, vm) {
|
|
if (isFunction(appOptions.onLaunch)) {
|
|
const args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync();
|
|
appOptions.onLaunch(args);
|
|
}
|
|
if (isFunction(appOptions.onShow) && wx.onAppShow) {
|
|
wx.onAppShow((args) => {
|
|
vm.$callHook("onShow", args);
|
|
});
|
|
}
|
|
if (isFunction(appOptions.onHide) && wx.onAppHide) {
|
|
wx.onAppHide((args) => {
|
|
vm.$callHook("onHide", args);
|
|
});
|
|
}
|
|
}
|
|
function initLocale(appVm) {
|
|
const locale = ref(normalizeLocale(wx.getSystemInfoSync().language) || LOCALE_EN);
|
|
Object.defineProperty(appVm, "$locale", {
|
|
get() {
|
|
return locale.value;
|
|
},
|
|
set(v2) {
|
|
locale.value = v2;
|
|
}
|
|
});
|
|
}
|
|
function initVueIds(vueIds, mpInstance) {
|
|
if (!vueIds) {
|
|
return;
|
|
}
|
|
const ids = vueIds.split(",");
|
|
const len = ids.length;
|
|
if (len === 1) {
|
|
mpInstance._$vueId = ids[0];
|
|
} else if (len === 2) {
|
|
mpInstance._$vueId = ids[0];
|
|
mpInstance._$vuePid = ids[1];
|
|
}
|
|
}
|
|
const EXTRAS = ["externalClasses"];
|
|
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
|
|
EXTRAS.forEach((name) => {
|
|
if (hasOwn(vueOptions, name)) {
|
|
miniProgramComponentOptions[name] = vueOptions[name];
|
|
}
|
|
});
|
|
}
|
|
function initWxsCallMethods(methods, wxsCallMethods) {
|
|
if (!isArray(wxsCallMethods)) {
|
|
return;
|
|
}
|
|
wxsCallMethods.forEach((callMethod) => {
|
|
methods[callMethod] = function(args) {
|
|
return this.$vm[callMethod](args);
|
|
};
|
|
});
|
|
}
|
|
function selectAllComponents(mpInstance, selector, $refs) {
|
|
const components = mpInstance.selectAllComponents(selector);
|
|
components.forEach((component) => {
|
|
const ref2 = component.properties.uR;
|
|
$refs[ref2] = component.$vm || component;
|
|
});
|
|
}
|
|
function initRefs(instance, mpInstance) {
|
|
Object.defineProperty(instance, "refs", {
|
|
get() {
|
|
const $refs = {};
|
|
selectAllComponents(mpInstance, ".r", $refs);
|
|
const forComponents = mpInstance.selectAllComponents(".r-i-f");
|
|
forComponents.forEach((component) => {
|
|
const ref2 = component.properties.uR;
|
|
if (!ref2) {
|
|
return;
|
|
}
|
|
if (!$refs[ref2]) {
|
|
$refs[ref2] = [];
|
|
}
|
|
$refs[ref2].push(component.$vm || component);
|
|
});
|
|
return $refs;
|
|
}
|
|
});
|
|
}
|
|
function findVmByVueId(instance, vuePid) {
|
|
const $children = instance.$children;
|
|
for (let i2 = $children.length - 1; i2 >= 0; i2--) {
|
|
const childVm = $children[i2];
|
|
if (childVm.$scope._$vueId === vuePid) {
|
|
return childVm;
|
|
}
|
|
}
|
|
let parentVm;
|
|
for (let i2 = $children.length - 1; i2 >= 0; i2--) {
|
|
parentVm = findVmByVueId($children[i2], vuePid);
|
|
if (parentVm) {
|
|
return parentVm;
|
|
}
|
|
}
|
|
}
|
|
const builtInProps = [
|
|
"eO",
|
|
"uR",
|
|
"uRIF",
|
|
"uI",
|
|
"uT",
|
|
"uP",
|
|
"uS"
|
|
];
|
|
function initDefaultProps(isBehavior = false) {
|
|
const properties = {};
|
|
if (!isBehavior) {
|
|
builtInProps.forEach((name) => {
|
|
properties[name] = {
|
|
type: null,
|
|
value: ""
|
|
};
|
|
});
|
|
properties.uS = {
|
|
type: null,
|
|
value: [],
|
|
observer: function(newVal) {
|
|
const $slots = /* @__PURE__ */ Object.create(null);
|
|
newVal && newVal.forEach((slotName) => {
|
|
$slots[slotName] = true;
|
|
});
|
|
this.setData({
|
|
$slots
|
|
});
|
|
}
|
|
};
|
|
}
|
|
return properties;
|
|
}
|
|
function initVirtualHostProps(options) {
|
|
const properties = {};
|
|
{
|
|
if (options && options.virtualHost) {
|
|
properties.virtualHostStyle = {
|
|
type: null,
|
|
value: ""
|
|
};
|
|
properties.virtualHostClass = {
|
|
type: null,
|
|
value: ""
|
|
};
|
|
}
|
|
}
|
|
return properties;
|
|
}
|
|
function initProps(mpComponentOptions) {
|
|
if (!mpComponentOptions.properties) {
|
|
mpComponentOptions.properties = {};
|
|
}
|
|
extend(mpComponentOptions.properties, initDefaultProps(), initVirtualHostProps(mpComponentOptions.options));
|
|
}
|
|
const PROP_TYPES = [String, Number, Boolean, Object, Array, null];
|
|
function parsePropType(type, defaultValue) {
|
|
if (isArray(type) && type.length === 1) {
|
|
return type[0];
|
|
}
|
|
return type;
|
|
}
|
|
function normalizePropType(type, defaultValue) {
|
|
const res = parsePropType(type);
|
|
return PROP_TYPES.indexOf(res) !== -1 ? res : null;
|
|
}
|
|
function initPageProps({ properties }, rawProps) {
|
|
if (isArray(rawProps)) {
|
|
rawProps.forEach((key) => {
|
|
properties[key] = {
|
|
type: String,
|
|
value: ""
|
|
};
|
|
});
|
|
} else if (isPlainObject$1(rawProps)) {
|
|
Object.keys(rawProps).forEach((key) => {
|
|
const opts = rawProps[key];
|
|
if (isPlainObject$1(opts)) {
|
|
let value = opts.default;
|
|
if (isFunction(value)) {
|
|
value = value();
|
|
}
|
|
const type = opts.type;
|
|
opts.type = normalizePropType(type);
|
|
properties[key] = {
|
|
type: opts.type,
|
|
value
|
|
};
|
|
} else {
|
|
properties[key] = {
|
|
type: normalizePropType(opts)
|
|
};
|
|
}
|
|
});
|
|
}
|
|
}
|
|
function findPropsData(properties, isPage2) {
|
|
return (isPage2 ? findPagePropsData(properties) : findComponentPropsData(properties.uP)) || {};
|
|
}
|
|
function findPagePropsData(properties) {
|
|
const propsData = {};
|
|
if (isPlainObject$1(properties)) {
|
|
Object.keys(properties).forEach((name) => {
|
|
if (builtInProps.indexOf(name) === -1) {
|
|
propsData[name] = properties[name];
|
|
}
|
|
});
|
|
}
|
|
return propsData;
|
|
}
|
|
function initData(_2) {
|
|
return {};
|
|
}
|
|
function initPropsObserver(componentOptions) {
|
|
const observe = function observe2() {
|
|
const up = this.properties.uP;
|
|
if (!up) {
|
|
return;
|
|
}
|
|
if (this.$vm) {
|
|
updateComponentProps(up, this.$vm.$);
|
|
} else if (this.properties.uT === "m") {
|
|
updateMiniProgramComponentProperties(up, this);
|
|
}
|
|
};
|
|
{
|
|
if (!componentOptions.observers) {
|
|
componentOptions.observers = {};
|
|
}
|
|
componentOptions.observers.uP = observe;
|
|
}
|
|
}
|
|
function updateMiniProgramComponentProperties(up, mpInstance) {
|
|
const prevProps = mpInstance.properties;
|
|
const nextProps = findComponentPropsData(up) || {};
|
|
if (hasPropsChanged(prevProps, nextProps, false)) {
|
|
mpInstance.setData(nextProps);
|
|
}
|
|
}
|
|
function updateComponentProps(up, instance) {
|
|
const prevProps = toRaw(instance.props);
|
|
const nextProps = findComponentPropsData(up) || {};
|
|
if (hasPropsChanged(prevProps, nextProps)) {
|
|
updateProps(instance, nextProps, prevProps, false);
|
|
if (hasQueueJob(instance.update)) {
|
|
invalidateJob(instance.update);
|
|
}
|
|
{
|
|
instance.update();
|
|
}
|
|
}
|
|
}
|
|
function hasPropsChanged(prevProps, nextProps, checkLen = true) {
|
|
const nextKeys = Object.keys(nextProps);
|
|
if (checkLen && nextKeys.length !== Object.keys(prevProps).length) {
|
|
return true;
|
|
}
|
|
for (let i2 = 0; i2 < nextKeys.length; i2++) {
|
|
const key = nextKeys[i2];
|
|
if (nextProps[key] !== prevProps[key]) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function initBehaviors(vueOptions) {
|
|
const vueBehaviors = vueOptions.behaviors;
|
|
let vueProps = vueOptions.props;
|
|
if (!vueProps) {
|
|
vueOptions.props = vueProps = [];
|
|
}
|
|
const behaviors = [];
|
|
if (isArray(vueBehaviors)) {
|
|
vueBehaviors.forEach((behavior) => {
|
|
behaviors.push(behavior.replace("uni://", "wx://"));
|
|
if (behavior === "uni://form-field") {
|
|
if (isArray(vueProps)) {
|
|
vueProps.push("name");
|
|
vueProps.push("value");
|
|
} else {
|
|
vueProps.name = {
|
|
type: String,
|
|
default: ""
|
|
};
|
|
vueProps.value = {
|
|
type: [String, Number, Boolean, Array, Object, Date],
|
|
default: ""
|
|
};
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return behaviors;
|
|
}
|
|
function applyOptions(componentOptions, vueOptions) {
|
|
componentOptions.data = initData();
|
|
componentOptions.behaviors = initBehaviors(vueOptions);
|
|
}
|
|
function parseComponent(vueOptions, { parse, mocks: mocks2, isPage: isPage2, initRelation: initRelation2, handleLink: handleLink2, initLifetimes: initLifetimes2 }) {
|
|
vueOptions = vueOptions.default || vueOptions;
|
|
const options = {
|
|
multipleSlots: true,
|
|
addGlobalClass: true,
|
|
pureDataPattern: /^uP$/
|
|
};
|
|
if (vueOptions.options) {
|
|
extend(options, vueOptions.options);
|
|
}
|
|
const mpComponentOptions = {
|
|
options,
|
|
lifetimes: initLifetimes2({ mocks: mocks2, isPage: isPage2, initRelation: initRelation2, vueOptions }),
|
|
pageLifetimes: {
|
|
show() {
|
|
this.$vm && this.$vm.$callHook("onPageShow");
|
|
},
|
|
hide() {
|
|
this.$vm && this.$vm.$callHook("onPageHide");
|
|
},
|
|
resize(size2) {
|
|
this.$vm && this.$vm.$callHook("onPageResize", size2);
|
|
}
|
|
},
|
|
methods: {
|
|
__l: handleLink2
|
|
}
|
|
};
|
|
{
|
|
applyOptions(mpComponentOptions, vueOptions);
|
|
}
|
|
initProps(mpComponentOptions);
|
|
initPropsObserver(mpComponentOptions);
|
|
initExtraOptions(mpComponentOptions, vueOptions);
|
|
initWxsCallMethods(mpComponentOptions.methods, vueOptions.wxsCallMethods);
|
|
if (parse) {
|
|
parse(mpComponentOptions, { handleLink: handleLink2 });
|
|
}
|
|
return mpComponentOptions;
|
|
}
|
|
function initCreateComponent(parseOptions2) {
|
|
return function createComponent2(vueComponentOptions) {
|
|
return Component(parseComponent(vueComponentOptions, parseOptions2));
|
|
};
|
|
}
|
|
let $createComponentFn;
|
|
let $destroyComponentFn;
|
|
function getAppVm() {
|
|
if ({}.UNI_MP_PLUGIN) {
|
|
return wx.$vm;
|
|
}
|
|
if ({}.UNI_SUBPACKAGE) {
|
|
return wx.$subpackages[{}.UNI_SUBPACKAGE].$vm;
|
|
}
|
|
return getApp().$vm;
|
|
}
|
|
function $createComponent(initialVNode, options) {
|
|
if (!$createComponentFn) {
|
|
$createComponentFn = getAppVm().$createComponent;
|
|
}
|
|
const proxy = $createComponentFn(initialVNode, options);
|
|
return getExposeProxy(proxy.$) || proxy;
|
|
}
|
|
function $destroyComponent(instance) {
|
|
if (!$destroyComponentFn) {
|
|
$destroyComponentFn = getApp().$vm.$destroyComponent;
|
|
}
|
|
return $destroyComponentFn(instance);
|
|
}
|
|
function parsePage(vueOptions, parseOptions2) {
|
|
const { parse, mocks: mocks2, isPage: isPage2, initRelation: initRelation2, handleLink: handleLink2, initLifetimes: initLifetimes2 } = parseOptions2;
|
|
const miniProgramPageOptions = parseComponent(vueOptions, {
|
|
mocks: mocks2,
|
|
isPage: isPage2,
|
|
initRelation: initRelation2,
|
|
handleLink: handleLink2,
|
|
initLifetimes: initLifetimes2
|
|
});
|
|
initPageProps(miniProgramPageOptions, (vueOptions.default || vueOptions).props);
|
|
const methods = miniProgramPageOptions.methods;
|
|
methods.onLoad = function(query) {
|
|
this.options = query;
|
|
this.$page = {
|
|
fullPath: addLeadingSlash(this.route + stringifyQuery(query))
|
|
};
|
|
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
|
|
};
|
|
initHooks(methods, PAGE_INIT_HOOKS);
|
|
{
|
|
initUnknownHooks(methods, vueOptions);
|
|
}
|
|
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
|
|
initMixinRuntimeHooks(methods);
|
|
parse && parse(miniProgramPageOptions, { handleLink: handleLink2 });
|
|
return miniProgramPageOptions;
|
|
}
|
|
function initCreatePage(parseOptions2) {
|
|
return function createPage2(vuePageOptions) {
|
|
return Component(parsePage(vuePageOptions, parseOptions2));
|
|
};
|
|
}
|
|
function initCreatePluginApp(parseAppOptions) {
|
|
return function createApp2(vm) {
|
|
initAppLifecycle(parseApp(vm, parseAppOptions), vm);
|
|
if ({}.UNI_MP_PLUGIN) {
|
|
wx.$vm = vm;
|
|
}
|
|
};
|
|
}
|
|
const MPPage = Page;
|
|
const MPComponent = Component;
|
|
function initTriggerEvent(mpInstance) {
|
|
const oldTriggerEvent = mpInstance.triggerEvent;
|
|
mpInstance.triggerEvent = function(event, ...args) {
|
|
return oldTriggerEvent.apply(mpInstance, [customizeEvent(event), ...args]);
|
|
};
|
|
}
|
|
function initMiniProgramHook(name, options, isComponent) {
|
|
const oldHook = options[name];
|
|
if (!oldHook) {
|
|
options[name] = function() {
|
|
initTriggerEvent(this);
|
|
};
|
|
} else {
|
|
options[name] = function(...args) {
|
|
initTriggerEvent(this);
|
|
return oldHook.apply(this, args);
|
|
};
|
|
}
|
|
}
|
|
Page = function(options) {
|
|
initMiniProgramHook(ON_LOAD, options);
|
|
return MPPage(options);
|
|
};
|
|
Component = function(options) {
|
|
initMiniProgramHook("created", options);
|
|
const isVueComponent = options.properties && options.properties.uP;
|
|
if (!isVueComponent) {
|
|
initProps(options);
|
|
initPropsObserver(options);
|
|
}
|
|
return MPComponent(options);
|
|
};
|
|
function initLifetimes({ mocks: mocks2, isPage: isPage2, initRelation: initRelation2, vueOptions }) {
|
|
return {
|
|
attached() {
|
|
let properties = this.properties;
|
|
initVueIds(properties.uI, this);
|
|
const relationOptions = {
|
|
vuePid: this._$vuePid
|
|
};
|
|
initRelation2(this, relationOptions);
|
|
const mpInstance = this;
|
|
const isMiniProgramPage = isPage2(mpInstance);
|
|
let propsData = properties;
|
|
this.$vm = $createComponent({
|
|
type: vueOptions,
|
|
props: findPropsData(propsData, isMiniProgramPage)
|
|
}, {
|
|
mpType: isMiniProgramPage ? "page" : "component",
|
|
mpInstance,
|
|
slots: properties.uS || {},
|
|
parentComponent: relationOptions.parent && relationOptions.parent.$,
|
|
onBeforeSetup(instance, options) {
|
|
initRefs(instance, mpInstance);
|
|
initMocks(instance, mpInstance, mocks2);
|
|
initComponentInstance(instance, options);
|
|
}
|
|
});
|
|
},
|
|
ready() {
|
|
if (this.$vm) {
|
|
{
|
|
this.$vm.$callHook("mounted");
|
|
this.$vm.$callHook(ON_READY);
|
|
}
|
|
}
|
|
},
|
|
detached() {
|
|
if (this.$vm) {
|
|
pruneComponentPropsCache(this.$vm.$.uid);
|
|
$destroyComponent(this.$vm);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
const mocks = ["__route__", "__wxExparserNodeId__", "__wxWebviewId__"];
|
|
function isPage(mpInstance) {
|
|
return !!mpInstance.route;
|
|
}
|
|
function initRelation(mpInstance, detail) {
|
|
mpInstance.triggerEvent("__l", detail);
|
|
}
|
|
function handleLink(event) {
|
|
const detail = event.detail || event.value;
|
|
const vuePid = detail.vuePid;
|
|
let parentVm;
|
|
if (vuePid) {
|
|
parentVm = findVmByVueId(this.$vm, vuePid);
|
|
}
|
|
if (!parentVm) {
|
|
parentVm = this.$vm;
|
|
}
|
|
detail.parent = parentVm;
|
|
}
|
|
var parseOptions = /* @__PURE__ */ Object.freeze({
|
|
__proto__: null,
|
|
mocks,
|
|
isPage,
|
|
initRelation,
|
|
handleLink,
|
|
initLifetimes
|
|
});
|
|
const createApp = initCreateApp();
|
|
const createPage = initCreatePage(parseOptions);
|
|
const createComponent = initCreateComponent(parseOptions);
|
|
const createPluginApp = initCreatePluginApp();
|
|
const createSubpackageApp = initCreateSubpackageApp();
|
|
{
|
|
wx.createApp = global.createApp = createApp;
|
|
wx.createPage = createPage;
|
|
wx.createComponent = createComponent;
|
|
wx.createPluginApp = global.createPluginApp = createPluginApp;
|
|
wx.createSubpackageApp = global.createSubpackageApp = createSubpackageApp;
|
|
}
|
|
var isVue2 = false;
|
|
function set$1(target, key, val) {
|
|
if (Array.isArray(target)) {
|
|
target.length = Math.max(target.length, key);
|
|
target.splice(key, 1, val);
|
|
return val;
|
|
}
|
|
target[key] = val;
|
|
return val;
|
|
}
|
|
function del(target, key) {
|
|
if (Array.isArray(target)) {
|
|
target.splice(key, 1);
|
|
return;
|
|
}
|
|
delete target[key];
|
|
}
|
|
/*!
|
|
* pinia v2.0.36
|
|
* (c) 2023 Eduardo San Martin Morote
|
|
* @license MIT
|
|
*/
|
|
let activePinia;
|
|
const setActivePinia = (pinia) => activePinia = pinia;
|
|
const piniaSymbol = Symbol("pinia");
|
|
function isPlainObject(o2) {
|
|
return o2 && typeof o2 === "object" && Object.prototype.toString.call(o2) === "[object Object]" && typeof o2.toJSON !== "function";
|
|
}
|
|
var MutationType;
|
|
(function(MutationType2) {
|
|
MutationType2["direct"] = "direct";
|
|
MutationType2["patchObject"] = "patch object";
|
|
MutationType2["patchFunction"] = "patch function";
|
|
})(MutationType || (MutationType = {}));
|
|
const IS_CLIENT = typeof window !== "undefined";
|
|
const USE_DEVTOOLS = IS_CLIENT;
|
|
const componentStateTypes = [];
|
|
const getStoreType = (id) => "\u{1F34D} " + id;
|
|
function addStoreToDevtools(app, store) {
|
|
if (!componentStateTypes.includes(getStoreType(store.$id))) {
|
|
componentStateTypes.push(getStoreType(store.$id));
|
|
}
|
|
}
|
|
function patchActionForGrouping(store, actionNames) {
|
|
const actions = actionNames.reduce((storeActions, actionName) => {
|
|
storeActions[actionName] = toRaw(store)[actionName];
|
|
return storeActions;
|
|
}, {});
|
|
for (const actionName in actions) {
|
|
store[actionName] = function() {
|
|
const trackedStore = new Proxy(store, {
|
|
get(...args) {
|
|
return Reflect.get(...args);
|
|
},
|
|
set(...args) {
|
|
return Reflect.set(...args);
|
|
}
|
|
});
|
|
return actions[actionName].apply(trackedStore, arguments);
|
|
};
|
|
}
|
|
}
|
|
function devtoolsPlugin({ app, store, options }) {
|
|
if (store.$id.startsWith("__hot:")) {
|
|
return;
|
|
}
|
|
if (options.state) {
|
|
store._isOptionsAPI = true;
|
|
}
|
|
if (typeof options.state === "function") {
|
|
patchActionForGrouping(
|
|
store,
|
|
Object.keys(options.actions)
|
|
);
|
|
const originalHotUpdate = store._hotUpdate;
|
|
toRaw(store)._hotUpdate = function(newStore) {
|
|
originalHotUpdate.apply(this, arguments);
|
|
patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions));
|
|
};
|
|
}
|
|
addStoreToDevtools(
|
|
app,
|
|
store
|
|
);
|
|
}
|
|
function createPinia() {
|
|
const scope = effectScope(true);
|
|
const state = scope.run(() => ref({}));
|
|
let _p = [];
|
|
let toBeInstalled = [];
|
|
const pinia = markRaw({
|
|
install(app) {
|
|
setActivePinia(pinia);
|
|
{
|
|
pinia._a = app;
|
|
app.provide(piniaSymbol, pinia);
|
|
app.config.globalProperties.$pinia = pinia;
|
|
toBeInstalled.forEach((plugin2) => _p.push(plugin2));
|
|
toBeInstalled = [];
|
|
}
|
|
},
|
|
use(plugin2) {
|
|
if (!this._a && !isVue2) {
|
|
toBeInstalled.push(plugin2);
|
|
} else {
|
|
_p.push(plugin2);
|
|
}
|
|
return this;
|
|
},
|
|
_p,
|
|
_a: null,
|
|
_e: scope,
|
|
_s: /* @__PURE__ */ new Map(),
|
|
state
|
|
});
|
|
if (USE_DEVTOOLS && typeof Proxy !== "undefined") {
|
|
pinia.use(devtoolsPlugin);
|
|
}
|
|
return pinia;
|
|
}
|
|
function patchObject(newState, oldState) {
|
|
for (const key in oldState) {
|
|
const subPatch = oldState[key];
|
|
if (!(key in newState)) {
|
|
continue;
|
|
}
|
|
const targetValue = newState[key];
|
|
if (isPlainObject(targetValue) && isPlainObject(subPatch) && !isRef(subPatch) && !isReactive(subPatch)) {
|
|
newState[key] = patchObject(targetValue, subPatch);
|
|
} else {
|
|
{
|
|
newState[key] = subPatch;
|
|
}
|
|
}
|
|
}
|
|
return newState;
|
|
}
|
|
const noop = () => {
|
|
};
|
|
function addSubscription(subscriptions, callback, detached, onCleanup = noop) {
|
|
subscriptions.push(callback);
|
|
const removeSubscription = () => {
|
|
const idx = subscriptions.indexOf(callback);
|
|
if (idx > -1) {
|
|
subscriptions.splice(idx, 1);
|
|
onCleanup();
|
|
}
|
|
};
|
|
if (!detached && getCurrentScope()) {
|
|
onScopeDispose(removeSubscription);
|
|
}
|
|
return removeSubscription;
|
|
}
|
|
function triggerSubscriptions(subscriptions, ...args) {
|
|
subscriptions.slice().forEach((callback) => {
|
|
callback(...args);
|
|
});
|
|
}
|
|
function mergeReactiveObjects(target, patchToApply) {
|
|
if (target instanceof Map && patchToApply instanceof Map) {
|
|
patchToApply.forEach((value, key) => target.set(key, value));
|
|
}
|
|
if (target instanceof Set && patchToApply instanceof Set) {
|
|
patchToApply.forEach(target.add, target);
|
|
}
|
|
for (const key in patchToApply) {
|
|
if (!patchToApply.hasOwnProperty(key))
|
|
continue;
|
|
const subPatch = patchToApply[key];
|
|
const targetValue = target[key];
|
|
if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key) && !isRef(subPatch) && !isReactive(subPatch)) {
|
|
target[key] = mergeReactiveObjects(targetValue, subPatch);
|
|
} else {
|
|
target[key] = subPatch;
|
|
}
|
|
}
|
|
return target;
|
|
}
|
|
const skipHydrateSymbol = Symbol("pinia:skipHydration");
|
|
function shouldHydrate(obj) {
|
|
return !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol);
|
|
}
|
|
const { assign } = Object;
|
|
function isComputed(o2) {
|
|
return !!(isRef(o2) && o2.effect);
|
|
}
|
|
function createOptionsStore(id, options, pinia, hot) {
|
|
const { state, actions, getters } = options;
|
|
const initialState = pinia.state.value[id];
|
|
let store;
|
|
function setup() {
|
|
if (!initialState && !hot) {
|
|
{
|
|
pinia.state.value[id] = state ? state() : {};
|
|
}
|
|
}
|
|
const localState = hot ? toRefs(ref(state ? state() : {}).value) : toRefs(pinia.state.value[id]);
|
|
return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
|
|
if (name in localState) {
|
|
console.warn(`[\u{1F34D}]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`);
|
|
}
|
|
computedGetters[name] = markRaw(computed$1(() => {
|
|
setActivePinia(pinia);
|
|
const store2 = pinia._s.get(id);
|
|
return getters[name].call(store2, store2);
|
|
}));
|
|
return computedGetters;
|
|
}, {}));
|
|
}
|
|
store = createSetupStore(id, setup, options, pinia, hot, true);
|
|
return store;
|
|
}
|
|
function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
|
|
let scope;
|
|
const optionsForPlugin = assign({ actions: {} }, options);
|
|
if (!pinia._e.active) {
|
|
throw new Error("Pinia destroyed");
|
|
}
|
|
const $subscribeOptions = {
|
|
deep: true
|
|
};
|
|
{
|
|
$subscribeOptions.onTrigger = (event) => {
|
|
if (isListening) {
|
|
debuggerEvents = event;
|
|
} else if (isListening == false && !store._hotUpdating) {
|
|
if (Array.isArray(debuggerEvents)) {
|
|
debuggerEvents.push(event);
|
|
} else {
|
|
console.error("\u{1F34D} debuggerEvents should be an array. This is most likely an internal Pinia bug.");
|
|
}
|
|
}
|
|
};
|
|
}
|
|
let isListening;
|
|
let isSyncListening;
|
|
let subscriptions = markRaw([]);
|
|
let actionSubscriptions = markRaw([]);
|
|
let debuggerEvents;
|
|
const initialState = pinia.state.value[$id];
|
|
if (!isOptionsStore && !initialState && !hot) {
|
|
{
|
|
pinia.state.value[$id] = {};
|
|
}
|
|
}
|
|
const hotState = ref({});
|
|
let activeListener;
|
|
function $patch(partialStateOrMutator) {
|
|
let subscriptionMutation;
|
|
isListening = isSyncListening = false;
|
|
{
|
|
debuggerEvents = [];
|
|
}
|
|
if (typeof partialStateOrMutator === "function") {
|
|
partialStateOrMutator(pinia.state.value[$id]);
|
|
subscriptionMutation = {
|
|
type: MutationType.patchFunction,
|
|
storeId: $id,
|
|
events: debuggerEvents
|
|
};
|
|
} else {
|
|
mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
|
|
subscriptionMutation = {
|
|
type: MutationType.patchObject,
|
|
payload: partialStateOrMutator,
|
|
storeId: $id,
|
|
events: debuggerEvents
|
|
};
|
|
}
|
|
const myListenerId = activeListener = Symbol();
|
|
nextTick().then(() => {
|
|
if (activeListener === myListenerId) {
|
|
isListening = true;
|
|
}
|
|
});
|
|
isSyncListening = true;
|
|
triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
|
|
}
|
|
const $reset = isOptionsStore ? function $reset2() {
|
|
const { state } = options;
|
|
const newState = state ? state() : {};
|
|
this.$patch(($state) => {
|
|
assign($state, newState);
|
|
});
|
|
} : () => {
|
|
throw new Error(`\u{1F34D}: Store "${$id}" is built using the setup syntax and does not implement $reset().`);
|
|
};
|
|
function $dispose() {
|
|
scope.stop();
|
|
subscriptions = [];
|
|
actionSubscriptions = [];
|
|
pinia._s.delete($id);
|
|
}
|
|
function wrapAction(name, action) {
|
|
return function() {
|
|
setActivePinia(pinia);
|
|
const args = Array.from(arguments);
|
|
const afterCallbackList = [];
|
|
const onErrorCallbackList = [];
|
|
function after(callback) {
|
|
afterCallbackList.push(callback);
|
|
}
|
|
function onError(callback) {
|
|
onErrorCallbackList.push(callback);
|
|
}
|
|
triggerSubscriptions(actionSubscriptions, {
|
|
args,
|
|
name,
|
|
store,
|
|
after,
|
|
onError
|
|
});
|
|
let ret;
|
|
try {
|
|
ret = action.apply(this && this.$id === $id ? this : store, args);
|
|
} catch (error) {
|
|
triggerSubscriptions(onErrorCallbackList, error);
|
|
throw error;
|
|
}
|
|
if (ret instanceof Promise) {
|
|
return ret.then((value) => {
|
|
triggerSubscriptions(afterCallbackList, value);
|
|
return value;
|
|
}).catch((error) => {
|
|
triggerSubscriptions(onErrorCallbackList, error);
|
|
return Promise.reject(error);
|
|
});
|
|
}
|
|
triggerSubscriptions(afterCallbackList, ret);
|
|
return ret;
|
|
};
|
|
}
|
|
const _hmrPayload = /* @__PURE__ */ markRaw({
|
|
actions: {},
|
|
getters: {},
|
|
state: [],
|
|
hotState
|
|
});
|
|
const partialStore = {
|
|
_p: pinia,
|
|
$id,
|
|
$onAction: addSubscription.bind(null, actionSubscriptions),
|
|
$patch,
|
|
$reset,
|
|
$subscribe(callback, options2 = {}) {
|
|
const removeSubscription = addSubscription(subscriptions, callback, options2.detached, () => stopWatcher());
|
|
const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => {
|
|
if (options2.flush === "sync" ? isSyncListening : isListening) {
|
|
callback({
|
|
storeId: $id,
|
|
type: MutationType.direct,
|
|
events: debuggerEvents
|
|
}, state);
|
|
}
|
|
}, assign({}, $subscribeOptions, options2)));
|
|
return removeSubscription;
|
|
},
|
|
$dispose
|
|
};
|
|
const store = reactive(
|
|
assign(
|
|
{
|
|
_hmrPayload,
|
|
_customProperties: markRaw(/* @__PURE__ */ new Set())
|
|
},
|
|
partialStore
|
|
)
|
|
);
|
|
pinia._s.set($id, store);
|
|
const setupStore = pinia._e.run(() => {
|
|
scope = effectScope();
|
|
return scope.run(() => setup());
|
|
});
|
|
for (const key in setupStore) {
|
|
const prop = setupStore[key];
|
|
if (isRef(prop) && !isComputed(prop) || isReactive(prop)) {
|
|
if (hot) {
|
|
set$1(hotState.value, key, toRef(setupStore, key));
|
|
} else if (!isOptionsStore) {
|
|
if (initialState && shouldHydrate(prop)) {
|
|
if (isRef(prop)) {
|
|
prop.value = initialState[key];
|
|
} else {
|
|
mergeReactiveObjects(prop, initialState[key]);
|
|
}
|
|
}
|
|
{
|
|
pinia.state.value[$id][key] = prop;
|
|
}
|
|
}
|
|
{
|
|
_hmrPayload.state.push(key);
|
|
}
|
|
} else if (typeof prop === "function") {
|
|
const actionValue = hot ? prop : wrapAction(key, prop);
|
|
{
|
|
setupStore[key] = actionValue;
|
|
}
|
|
{
|
|
_hmrPayload.actions[key] = prop;
|
|
}
|
|
optionsForPlugin.actions[key] = prop;
|
|
} else {
|
|
if (isComputed(prop)) {
|
|
_hmrPayload.getters[key] = isOptionsStore ? options.getters[key] : prop;
|
|
if (IS_CLIENT) {
|
|
const getters = setupStore._getters || (setupStore._getters = markRaw([]));
|
|
getters.push(key);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
assign(store, setupStore);
|
|
assign(toRaw(store), setupStore);
|
|
}
|
|
Object.defineProperty(store, "$state", {
|
|
get: () => hot ? hotState.value : pinia.state.value[$id],
|
|
set: (state) => {
|
|
if (hot) {
|
|
throw new Error("cannot set hotState");
|
|
}
|
|
$patch(($state) => {
|
|
assign($state, state);
|
|
});
|
|
}
|
|
});
|
|
{
|
|
store._hotUpdate = markRaw((newStore) => {
|
|
store._hotUpdating = true;
|
|
newStore._hmrPayload.state.forEach((stateKey) => {
|
|
if (stateKey in store.$state) {
|
|
const newStateTarget = newStore.$state[stateKey];
|
|
const oldStateSource = store.$state[stateKey];
|
|
if (typeof newStateTarget === "object" && isPlainObject(newStateTarget) && isPlainObject(oldStateSource)) {
|
|
patchObject(newStateTarget, oldStateSource);
|
|
} else {
|
|
newStore.$state[stateKey] = oldStateSource;
|
|
}
|
|
}
|
|
set$1(store, stateKey, toRef(newStore.$state, stateKey));
|
|
});
|
|
Object.keys(store.$state).forEach((stateKey) => {
|
|
if (!(stateKey in newStore.$state)) {
|
|
del(store, stateKey);
|
|
}
|
|
});
|
|
isListening = false;
|
|
isSyncListening = false;
|
|
pinia.state.value[$id] = toRef(newStore._hmrPayload, "hotState");
|
|
isSyncListening = true;
|
|
nextTick().then(() => {
|
|
isListening = true;
|
|
});
|
|
for (const actionName in newStore._hmrPayload.actions) {
|
|
const action = newStore[actionName];
|
|
set$1(store, actionName, wrapAction(actionName, action));
|
|
}
|
|
for (const getterName in newStore._hmrPayload.getters) {
|
|
const getter = newStore._hmrPayload.getters[getterName];
|
|
const getterValue = isOptionsStore ? computed$1(() => {
|
|
setActivePinia(pinia);
|
|
return getter.call(store, store);
|
|
}) : getter;
|
|
set$1(store, getterName, getterValue);
|
|
}
|
|
Object.keys(store._hmrPayload.getters).forEach((key) => {
|
|
if (!(key in newStore._hmrPayload.getters)) {
|
|
del(store, key);
|
|
}
|
|
});
|
|
Object.keys(store._hmrPayload.actions).forEach((key) => {
|
|
if (!(key in newStore._hmrPayload.actions)) {
|
|
del(store, key);
|
|
}
|
|
});
|
|
store._hmrPayload = newStore._hmrPayload;
|
|
store._getters = newStore._getters;
|
|
store._hotUpdating = false;
|
|
});
|
|
}
|
|
if (USE_DEVTOOLS) {
|
|
const nonEnumerable = {
|
|
writable: true,
|
|
configurable: true,
|
|
enumerable: false
|
|
};
|
|
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((p2) => {
|
|
Object.defineProperty(store, p2, assign({ value: store[p2] }, nonEnumerable));
|
|
});
|
|
}
|
|
pinia._p.forEach((extender) => {
|
|
if (USE_DEVTOOLS) {
|
|
const extensions = scope.run(() => extender({
|
|
store,
|
|
app: pinia._a,
|
|
pinia,
|
|
options: optionsForPlugin
|
|
}));
|
|
Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key));
|
|
assign(store, extensions);
|
|
} else {
|
|
assign(store, scope.run(() => extender({
|
|
store,
|
|
app: pinia._a,
|
|
pinia,
|
|
options: optionsForPlugin
|
|
})));
|
|
}
|
|
});
|
|
if (store.$state && typeof store.$state === "object" && typeof store.$state.constructor === "function" && !store.$state.constructor.toString().includes("[native code]")) {
|
|
console.warn(`[\u{1F34D}]: The "state" must be a plain object. It cannot be
|
|
state: () => new MyClass()
|
|
Found in store "${store.$id}".`);
|
|
}
|
|
if (initialState && isOptionsStore && options.hydrate) {
|
|
options.hydrate(store.$state, initialState);
|
|
}
|
|
isListening = true;
|
|
isSyncListening = true;
|
|
return store;
|
|
}
|
|
function defineStore(idOrOptions, setup, setupOptions) {
|
|
let id;
|
|
let options;
|
|
const isSetupStore = typeof setup === "function";
|
|
if (typeof idOrOptions === "string") {
|
|
id = idOrOptions;
|
|
options = isSetupStore ? setupOptions : setup;
|
|
} else {
|
|
options = idOrOptions;
|
|
id = idOrOptions.id;
|
|
if (typeof id !== "string") {
|
|
throw new Error(`[\u{1F34D}]: "defineStore()" must be passed a store id as its first argument.`);
|
|
}
|
|
}
|
|
function useStore(pinia, hot) {
|
|
const currentInstance2 = getCurrentInstance();
|
|
pinia = pinia || currentInstance2 && inject(piniaSymbol, null);
|
|
if (pinia)
|
|
setActivePinia(pinia);
|
|
if (!activePinia) {
|
|
throw new Error(`[\u{1F34D}]: "getActivePinia()" was called but there was no active Pinia. Did you forget to install pinia?
|
|
const pinia = createPinia()
|
|
app.use(pinia)
|
|
This will fail in production.`);
|
|
}
|
|
pinia = activePinia;
|
|
if (!pinia._s.has(id)) {
|
|
if (isSetupStore) {
|
|
createSetupStore(id, setup, options, pinia);
|
|
} else {
|
|
createOptionsStore(id, options, pinia);
|
|
}
|
|
{
|
|
useStore._pinia = pinia;
|
|
}
|
|
}
|
|
const store = pinia._s.get(id);
|
|
if (hot) {
|
|
const hotId = "__hot:" + id;
|
|
const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign({}, options), pinia, true);
|
|
hot._hotUpdate(newStore);
|
|
delete pinia.state.value[hotId];
|
|
pinia._s.delete(hotId);
|
|
}
|
|
if (IS_CLIENT && currentInstance2 && currentInstance2.proxy && !hot) {
|
|
const vm = currentInstance2.proxy;
|
|
const cache = "_pStores" in vm ? vm._pStores : vm._pStores = {};
|
|
cache[id] = store;
|
|
}
|
|
return store;
|
|
}
|
|
useStore.$id = id;
|
|
return useStore;
|
|
}
|
|
function storeToRefs(store) {
|
|
{
|
|
store = toRaw(store);
|
|
const refs = {};
|
|
for (const key in store) {
|
|
const value = store[key];
|
|
if (isRef(value) || isReactive(value)) {
|
|
refs[key] = toRef(store, key);
|
|
}
|
|
}
|
|
return refs;
|
|
}
|
|
}
|
|
function isObject(v2) {
|
|
return typeof v2 === "object" && v2 !== null;
|
|
}
|
|
function normalizeOptions(options, factoryOptions) {
|
|
options = isObject(options) ? options : /* @__PURE__ */ Object.create(null);
|
|
return new Proxy(options, {
|
|
get(target, key, receiver) {
|
|
return Reflect.get(target, key, receiver) || Reflect.get(factoryOptions, key, receiver);
|
|
}
|
|
});
|
|
}
|
|
function isObject2(value) {
|
|
return value !== null && typeof value === "object";
|
|
}
|
|
function merge(destination, source) {
|
|
const mergingArrays = Array.isArray(destination) && Array.isArray(source);
|
|
const mergingObjects = isObject2(destination) && isObject2(source);
|
|
if (!mergingArrays && !mergingObjects) {
|
|
throw new Error("Can only merge object with object or array with array");
|
|
}
|
|
const result = mergingArrays ? [] : {};
|
|
const keys = [...Object.keys(destination), ...Object.keys(source)];
|
|
keys.forEach((key) => {
|
|
if (Array.isArray(destination[key]) && Array.isArray(source[key])) {
|
|
result[key] = [
|
|
...Object.values(
|
|
merge(destination[key], source[key])
|
|
)
|
|
];
|
|
} else if (source[key] !== null && typeof source[key] === "object" && typeof destination[key] === "object") {
|
|
result[key] = merge(
|
|
destination[key],
|
|
source[key]
|
|
);
|
|
} else if (destination[key] !== void 0 && source[key] === void 0) {
|
|
result[key] = destination[key];
|
|
} else if (destination[key] === void 0 && source[key] !== void 0) {
|
|
result[key] = source[key];
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
function get(state, path) {
|
|
return path.reduce((obj, p2) => {
|
|
if (p2 === "[]" && Array.isArray(obj))
|
|
return obj;
|
|
return obj == null ? void 0 : obj[p2];
|
|
}, state);
|
|
}
|
|
function set(state, path, val) {
|
|
const modifiedState = path.slice(0, -1).reduce((obj, p2) => {
|
|
if (!/^(__proto__)$/.test(p2))
|
|
return obj[p2] = obj[p2] || {};
|
|
else
|
|
return {};
|
|
}, state);
|
|
if (Array.isArray(modifiedState[path[path.length - 1]]) && Array.isArray(val)) {
|
|
const merged = modifiedState[path[path.length - 1]].map(
|
|
(item, index2) => {
|
|
if (Array.isArray(item) && typeof item !== "object") {
|
|
return [...item, ...val[index2]];
|
|
}
|
|
if (typeof item === "object" && item !== null && Object.keys(item).some((key) => Array.isArray(item[key]))) {
|
|
return merge(item, val[index2]);
|
|
}
|
|
return {
|
|
...item,
|
|
...val[index2]
|
|
};
|
|
}
|
|
);
|
|
modifiedState[path[path.length - 1]] = merged;
|
|
} else if (path[path.length - 1] === void 0 && Array.isArray(modifiedState) && Array.isArray(val)) {
|
|
modifiedState.push(...val);
|
|
} else {
|
|
modifiedState[path[path.length - 1]] = val;
|
|
}
|
|
return state;
|
|
}
|
|
function pick(baseState, paths) {
|
|
return paths.reduce(
|
|
(substate, path) => {
|
|
const pathArray = path.split(".");
|
|
if (!pathArray.includes("[]")) {
|
|
return set(substate, pathArray, get(baseState, pathArray));
|
|
}
|
|
const arrayIndex = pathArray.indexOf("[]");
|
|
const pathArrayBeforeArray = pathArray.slice(0, arrayIndex);
|
|
const pathArrayUntilArray = pathArray.slice(0, arrayIndex + 1);
|
|
const pathArrayAfterArray = pathArray.slice(arrayIndex + 1);
|
|
const referencedArray = get(
|
|
baseState,
|
|
pathArrayUntilArray
|
|
);
|
|
const referencedArraySubstate = [];
|
|
for (const item of referencedArray) {
|
|
if (pathArrayAfterArray.length !== 0 && (Array.isArray(item) || typeof item === "object")) {
|
|
referencedArraySubstate.push(
|
|
pick(item, [pathArrayAfterArray.join(".")])
|
|
);
|
|
} else {
|
|
referencedArraySubstate.push(item);
|
|
}
|
|
}
|
|
return set(substate, pathArrayBeforeArray, referencedArraySubstate);
|
|
},
|
|
Array.isArray(baseState) ? [] : {}
|
|
);
|
|
}
|
|
function hydrateStore(store, storage, serializer, key, debug) {
|
|
try {
|
|
const fromStorage = storage == null ? void 0 : storage.getItem(key);
|
|
if (fromStorage)
|
|
store.$patch(serializer == null ? void 0 : serializer.deserialize(fromStorage));
|
|
} catch (error) {
|
|
if (debug)
|
|
console.error(error);
|
|
}
|
|
}
|
|
function createPersistedState(factoryOptions = {}) {
|
|
return (context) => {
|
|
const {
|
|
options: { persist },
|
|
store
|
|
} = context;
|
|
if (!persist)
|
|
return;
|
|
const persistences = (Array.isArray(persist) ? persist.map((p2) => normalizeOptions(p2, factoryOptions)) : [normalizeOptions(persist, factoryOptions)]).map(
|
|
({
|
|
storage = localStorage,
|
|
beforeRestore = null,
|
|
afterRestore = null,
|
|
serializer = {
|
|
serialize: JSON.stringify,
|
|
deserialize: JSON.parse
|
|
},
|
|
key = store.$id,
|
|
paths = null,
|
|
debug = false
|
|
}) => ({
|
|
storage,
|
|
beforeRestore,
|
|
afterRestore,
|
|
serializer,
|
|
key,
|
|
paths,
|
|
debug
|
|
})
|
|
);
|
|
persistences.forEach((persistence) => {
|
|
const {
|
|
storage,
|
|
serializer,
|
|
key,
|
|
paths,
|
|
beforeRestore,
|
|
afterRestore,
|
|
debug
|
|
} = persistence;
|
|
beforeRestore == null ? void 0 : beforeRestore(context);
|
|
hydrateStore(store, storage, serializer, key, debug);
|
|
afterRestore == null ? void 0 : afterRestore(context);
|
|
store.$subscribe(
|
|
(_mutation, state) => {
|
|
try {
|
|
const toStore = Array.isArray(paths) ? pick(state, paths) : state;
|
|
storage.setItem(key, serializer.serialize(toStore));
|
|
} catch (error) {
|
|
if (debug)
|
|
console.error(error);
|
|
}
|
|
},
|
|
{
|
|
detached: true
|
|
}
|
|
);
|
|
});
|
|
store.$hydrate = ({ runHooks = true } = {}) => {
|
|
persistences.forEach((persistence) => {
|
|
const { beforeRestore, afterRestore, storage, serializer, key, debug } = persistence;
|
|
if (runHooks)
|
|
beforeRestore == null ? void 0 : beforeRestore(context);
|
|
hydrateStore(store, storage, serializer, key, debug);
|
|
if (runHooks)
|
|
afterRestore == null ? void 0 : afterRestore(context);
|
|
});
|
|
};
|
|
};
|
|
}
|
|
const createHook = (lifecycle) => (hook, target = getCurrentInstance()) => {
|
|
!isInSSRComponentSetup && injectHook(lifecycle, hook, target);
|
|
};
|
|
const onShow = /* @__PURE__ */ createHook(ON_SHOW);
|
|
const onHide = /* @__PURE__ */ createHook(ON_HIDE);
|
|
const onLaunch = /* @__PURE__ */ createHook(ON_LAUNCH);
|
|
const onLoad = /* @__PURE__ */ createHook(ON_LOAD);
|
|
function deepClone(obj, cache = /* @__PURE__ */ new Map()) {
|
|
if (obj === null || typeof obj !== "object") {
|
|
return obj;
|
|
}
|
|
if (isDate(obj)) {
|
|
return new Date(obj.getTime());
|
|
}
|
|
if (obj instanceof RegExp) {
|
|
return new RegExp(obj.source, obj.flags);
|
|
}
|
|
if (obj instanceof Error) {
|
|
const errorCopy = new Error(obj.message);
|
|
errorCopy.stack = obj.stack;
|
|
return errorCopy;
|
|
}
|
|
if (cache.has(obj)) {
|
|
return cache.get(obj);
|
|
}
|
|
const copy = Array.isArray(obj) ? [] : {};
|
|
cache.set(obj, copy);
|
|
for (const key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
copy[key] = deepClone(obj[key], cache);
|
|
}
|
|
}
|
|
return copy;
|
|
}
|
|
function deepMerge(target, source) {
|
|
target = deepClone(target);
|
|
if (typeof target !== "object" || typeof source !== "object") {
|
|
throw new Error("Both target and source must be objects.");
|
|
}
|
|
for (const prop in source) {
|
|
if (!source.hasOwnProperty(prop))
|
|
continue;
|
|
target[prop] = source[prop];
|
|
}
|
|
return target;
|
|
}
|
|
const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
|
|
const toastDefaultOptionKey = "__TOAST_OPTION__";
|
|
const defaultOptions$1 = {
|
|
duration: 2e3,
|
|
show: false
|
|
};
|
|
const None$1 = Symbol("None");
|
|
function useToast(selector = "") {
|
|
const toastOptionKey = getToastOptionKey(selector);
|
|
const toastOption = inject(toastOptionKey, ref(None$1));
|
|
if (toastOption.value === None$1) {
|
|
toastOption.value = defaultOptions$1;
|
|
provide(toastOptionKey, toastOption);
|
|
}
|
|
let timer = null;
|
|
const createMethod = (toastOptions) => {
|
|
return (options) => {
|
|
return show(deepMerge(toastOptions, typeof options === "string" ? { msg: options } : options));
|
|
};
|
|
};
|
|
const show = (option) => {
|
|
const options = deepMerge(defaultOptions$1, typeof option === "string" ? { msg: option } : option);
|
|
toastOption.value = deepMerge(options, {
|
|
show: true
|
|
});
|
|
timer && clearTimeout(timer);
|
|
if (toastOption.value.duration && toastOption.value.duration > 0) {
|
|
timer = setTimeout(() => {
|
|
timer && clearTimeout(timer);
|
|
close();
|
|
}, options.duration);
|
|
}
|
|
};
|
|
const loading = createMethod({
|
|
iconName: "loading",
|
|
duration: 0,
|
|
cover: true
|
|
});
|
|
const success = createMethod({
|
|
iconName: "success",
|
|
duration: 1500
|
|
});
|
|
const error = createMethod({ iconName: "error" });
|
|
const warning = createMethod({ iconName: "warning" });
|
|
const info = createMethod({ iconName: "info" });
|
|
const close = () => {
|
|
toastOption.value = { show: false };
|
|
};
|
|
return {
|
|
show,
|
|
loading,
|
|
success,
|
|
error,
|
|
warning,
|
|
info,
|
|
close
|
|
};
|
|
}
|
|
const getToastOptionKey = (selector) => {
|
|
return selector ? `${toastDefaultOptionKey}${selector}` : toastDefaultOptionKey;
|
|
};
|
|
const messageDefaultOptionKey = "__MESSAGE_OPTION__";
|
|
const None = Symbol("None");
|
|
const defaultOptions = {
|
|
title: "",
|
|
showCancelButton: false,
|
|
show: false,
|
|
closeOnClickModal: true,
|
|
msg: "",
|
|
type: "alert",
|
|
inputType: "text",
|
|
inputValue: "",
|
|
showErr: false,
|
|
zIndex: 99,
|
|
lazyRender: true,
|
|
inputError: ""
|
|
};
|
|
function useMessage(selector = "") {
|
|
const messageOptionKey = selector ? messageDefaultOptionKey + selector : messageDefaultOptionKey;
|
|
const messageOption = inject(messageOptionKey, ref(None));
|
|
if (messageOption.value === None) {
|
|
messageOption.value = defaultOptions;
|
|
provide(messageOptionKey, messageOption);
|
|
}
|
|
const createMethod = (type) => {
|
|
return (options) => {
|
|
const messageOptions = deepMerge({ type }, typeof options === "string" ? { title: options } : options);
|
|
if (messageOptions.type === "confirm" || messageOptions.type === "prompt") {
|
|
messageOptions.showCancelButton = true;
|
|
} else {
|
|
messageOptions.showCancelButton = false;
|
|
}
|
|
return show(messageOptions);
|
|
};
|
|
};
|
|
const show = (option) => {
|
|
return new Promise((resolve2, reject) => {
|
|
const options = deepMerge(defaultOptions, typeof option === "string" ? { title: option } : option);
|
|
messageOption.value = deepMerge(options, {
|
|
show: true,
|
|
success: (res) => {
|
|
close();
|
|
resolve2(res);
|
|
},
|
|
fail: (res) => {
|
|
close();
|
|
reject(res);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
const alert = createMethod("alert");
|
|
const confirm = createMethod("confirm");
|
|
const prompt = createMethod("prompt");
|
|
const close = () => {
|
|
if (messageOption.value !== None) {
|
|
messageOption.value.show = false;
|
|
}
|
|
};
|
|
return {
|
|
show,
|
|
alert,
|
|
confirm,
|
|
prompt,
|
|
close
|
|
};
|
|
}
|
|
var zhCN = {
|
|
calendar: {
|
|
placeholder: "\u8BF7\u9009\u62E9",
|
|
title: "\u9009\u62E9\u65E5\u671F",
|
|
day: "\u65E5",
|
|
week: "\u5468",
|
|
month: "\u6708",
|
|
confirm: "\u786E\u5B9A",
|
|
startTime: "\u5F00\u59CB\u65F6\u95F4",
|
|
endTime: "\u7ED3\u675F\u65F6\u95F4",
|
|
to: "\u81F3",
|
|
timeFormat: "YY\u5E74MM\u6708DD\u65E5 HH:mm:ss",
|
|
dateFormat: "YYYY\u5E74MM\u6708DD\u65E5",
|
|
weekFormat: (year, week) => `${year} \u7B2C ${week} \u5468`,
|
|
startWeek: "\u5F00\u59CB\u5468",
|
|
endWeek: "\u7ED3\u675F\u5468",
|
|
startMonth: "\u5F00\u59CB\u6708",
|
|
endMonth: "\u7ED3\u675F\u6708",
|
|
monthFormat: "YYYY\u5E74MM\u6708"
|
|
},
|
|
calendarView: {
|
|
startTime: "\u5F00\u59CB",
|
|
endTime: "\u7ED3\u675F",
|
|
weeks: {
|
|
sun: "\u65E5",
|
|
mon: "\u4E00",
|
|
tue: "\u4E8C",
|
|
wed: "\u4E09",
|
|
thu: "\u56DB",
|
|
fri: "\u4E94",
|
|
sat: "\u516D"
|
|
},
|
|
rangePrompt: (maxRange) => `\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7${maxRange}\u5929`,
|
|
rangePromptWeek: (maxRange) => `\u9009\u62E9\u5468\u6570\u4E0D\u80FD\u8D85\u8FC7${maxRange}\u5468`,
|
|
rangePromptMonth: (maxRange) => `\u9009\u62E9\u6708\u4EFD\u4E0D\u80FD\u8D85\u8FC7${maxRange}\u4E2A\u6708`,
|
|
monthTitle: "YYYY\u5E74M\u6708",
|
|
yearTitle: "YYYY\u5E74",
|
|
month: "M\u6708",
|
|
hour: (value) => `${value}\u65F6`,
|
|
minute: (value) => `${value}\u5206`,
|
|
second: (value) => `${value}\u79D2`
|
|
},
|
|
collapse: {
|
|
expand: "\u5C55\u5F00",
|
|
retract: "\u6536\u8D77"
|
|
},
|
|
colPicker: {
|
|
title: "\u8BF7\u9009\u62E9",
|
|
placeholder: "\u8BF7\u9009\u62E9",
|
|
select: "\u8BF7\u9009\u62E9"
|
|
},
|
|
datetimePicker: {
|
|
start: "\u5F00\u59CB\u65F6\u95F4",
|
|
end: "\u7ED3\u675F\u65F6\u95F4",
|
|
to: "\u81F3",
|
|
placeholder: "\u8BF7\u9009\u62E9",
|
|
confirm: "\u5B8C\u6210",
|
|
cancel: "\u53D6\u6D88"
|
|
},
|
|
loadmore: {
|
|
loading: "\u6B63\u5728\u52AA\u529B\u52A0\u8F7D\u4E2D...",
|
|
finished: "\u5DF2\u52A0\u8F7D\u5B8C\u6BD5",
|
|
error: "\u52A0\u8F7D\u5931\u8D25",
|
|
retry: "\u70B9\u51FB\u91CD\u8BD5"
|
|
},
|
|
messageBox: {
|
|
inputPlaceholder: "\u8BF7\u8F93\u5165",
|
|
confirm: "\u786E\u5B9A",
|
|
cancel: "\u53D6\u6D88",
|
|
inputNoValidate: "\u8F93\u5165\u7684\u6570\u636E\u4E0D\u5408\u6CD5"
|
|
},
|
|
numberKeyboard: {
|
|
confirm: "\u5B8C\u6210"
|
|
},
|
|
pagination: {
|
|
prev: "\u4E0A\u4E00\u9875",
|
|
next: "\u4E0B\u4E00\u9875",
|
|
page: (value) => `\u5F53\u524D\u9875\uFF1A${value}`,
|
|
total: (total) => `\u5F53\u524D\u6570\u636E\uFF1A${total}\u6761`,
|
|
size: (size2) => `\u5206\u9875\u5927\u5C0F\uFF1A${size2}`
|
|
},
|
|
picker: {
|
|
cancel: "\u53D6\u6D88",
|
|
done: "\u5B8C\u6210",
|
|
placeholder: "\u8BF7\u9009\u62E9"
|
|
},
|
|
imgCropper: {
|
|
confirm: "\u5B8C\u6210",
|
|
cancel: "\u53D6\u6D88"
|
|
},
|
|
search: {
|
|
search: "\u641C\u7D22",
|
|
cancel: "\u53D6\u6D88"
|
|
},
|
|
steps: {
|
|
wait: "\u672A\u5F00\u59CB",
|
|
finished: "\u5DF2\u5B8C\u6210",
|
|
process: "\u8FDB\u884C\u4E2D",
|
|
failed: "\u5931\u8D25"
|
|
},
|
|
tabs: {
|
|
all: "\u5168\u90E8"
|
|
},
|
|
upload: {
|
|
error: "\u4E0A\u4F20\u5931\u8D25"
|
|
},
|
|
input: {
|
|
placeholder: "\u8BF7\u8F93\u5165..."
|
|
},
|
|
selectPicker: {
|
|
title: "\u8BF7\u9009\u62E9",
|
|
placeholder: "\u8BF7\u9009\u62E9",
|
|
select: "\u8BF7\u9009\u62E9",
|
|
confirm: "\u786E\u8BA4",
|
|
filterPlaceholder: "\u641C\u7D22"
|
|
},
|
|
tag: {
|
|
placeholder: "\u8BF7\u8F93\u5165",
|
|
add: "\u65B0\u589E\u6807\u7B7E"
|
|
},
|
|
textarea: {
|
|
placeholder: "\u8BF7\u8F93\u5165..."
|
|
},
|
|
tableCol: {
|
|
indexLabel: "\u5E8F\u53F7"
|
|
},
|
|
signature: {
|
|
confirmText: "\u786E\u8BA4",
|
|
clearText: "\u6E05\u7A7A",
|
|
revokeText: "\u64A4\u9500",
|
|
restoreText: "\u6062\u590D"
|
|
}
|
|
};
|
|
ref("zh-CN");
|
|
reactive({
|
|
"zh-CN": zhCN
|
|
});
|
|
var SECONDS_A_MINUTE = 60;
|
|
var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
|
|
var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
|
|
var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
|
|
var MILLISECONDS_A_SECOND = 1e3;
|
|
var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
|
|
var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
|
|
var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
|
|
var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;
|
|
var MS = "millisecond";
|
|
var S$1 = "second";
|
|
var MIN = "minute";
|
|
var H$1 = "hour";
|
|
var D$1 = "day";
|
|
var W$1 = "week";
|
|
var M$1 = "month";
|
|
var Q$1 = "quarter";
|
|
var Y$1 = "year";
|
|
var DATE = "date";
|
|
var FORMAT_DEFAULT = "YYYY-MM-DDTHH:mm:ssZ";
|
|
var INVALID_DATE_STRING = "Invalid Date";
|
|
var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
|
|
var REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
|
|
var en = {
|
|
name: "en",
|
|
weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
|
|
months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
|
|
ordinal: function ordinal(n2) {
|
|
var s2 = ["th", "st", "nd", "rd"];
|
|
var v2 = n2 % 100;
|
|
return "[" + n2 + (s2[(v2 - 20) % 10] || s2[v2] || s2[0]) + "]";
|
|
}
|
|
};
|
|
var padStart = function padStart2(string, length, pad) {
|
|
var s2 = String(string);
|
|
if (!s2 || s2.length >= length)
|
|
return string;
|
|
return "" + Array(length + 1 - s2.length).join(pad) + string;
|
|
};
|
|
var padZoneStr = function padZoneStr2(instance) {
|
|
var negMinutes = -instance.utcOffset();
|
|
var minutes = Math.abs(negMinutes);
|
|
var hourOffset = Math.floor(minutes / 60);
|
|
var minuteOffset = minutes % 60;
|
|
return (negMinutes <= 0 ? "+" : "-") + padStart(hourOffset, 2, "0") + ":" + padStart(minuteOffset, 2, "0");
|
|
};
|
|
var monthDiff = function monthDiff2(a2, b2) {
|
|
if (a2.date() < b2.date())
|
|
return -monthDiff2(b2, a2);
|
|
var wholeMonthDiff = (b2.year() - a2.year()) * 12 + (b2.month() - a2.month());
|
|
var anchor = a2.clone().add(wholeMonthDiff, M$1);
|
|
var c2 = b2 - anchor < 0;
|
|
var anchor2 = a2.clone().add(wholeMonthDiff + (c2 ? -1 : 1), M$1);
|
|
return +(-(wholeMonthDiff + (b2 - anchor) / (c2 ? anchor - anchor2 : anchor2 - anchor)) || 0);
|
|
};
|
|
var absFloor = function absFloor2(n2) {
|
|
return n2 < 0 ? Math.ceil(n2) || 0 : Math.floor(n2);
|
|
};
|
|
var prettyUnit = function prettyUnit2(u2) {
|
|
var special = {
|
|
M: M$1,
|
|
y: Y$1,
|
|
w: W$1,
|
|
d: D$1,
|
|
D: DATE,
|
|
h: H$1,
|
|
m: MIN,
|
|
s: S$1,
|
|
ms: MS,
|
|
Q: Q$1
|
|
};
|
|
return special[u2] || String(u2 || "").toLowerCase().replace(/s$/, "");
|
|
};
|
|
var isUndefined = function isUndefined2(s2) {
|
|
return s2 === void 0;
|
|
};
|
|
var U$1 = {
|
|
s: padStart,
|
|
z: padZoneStr,
|
|
m: monthDiff,
|
|
a: absFloor,
|
|
p: prettyUnit,
|
|
u: isUndefined
|
|
};
|
|
var L$1 = "en";
|
|
var Ls = {};
|
|
Ls[L$1] = en;
|
|
var IS_DAYJS = "$isDayjsObject";
|
|
var isDayjs = function isDayjs2(d2) {
|
|
return d2 instanceof Dayjs || !!(d2 && d2[IS_DAYJS]);
|
|
};
|
|
var parseLocale = function parseLocale2(preset, object, isLocal) {
|
|
var l2;
|
|
if (!preset)
|
|
return L$1;
|
|
if (typeof preset === "string") {
|
|
var presetLower = preset.toLowerCase();
|
|
if (Ls[presetLower]) {
|
|
l2 = presetLower;
|
|
}
|
|
if (object) {
|
|
Ls[presetLower] = object;
|
|
l2 = presetLower;
|
|
}
|
|
var presetSplit = preset.split("-");
|
|
if (!l2 && presetSplit.length > 1) {
|
|
return parseLocale2(presetSplit[0]);
|
|
}
|
|
} else {
|
|
var name = preset.name;
|
|
Ls[name] = preset;
|
|
l2 = name;
|
|
}
|
|
if (!isLocal && l2)
|
|
L$1 = l2;
|
|
return l2 || !isLocal && L$1;
|
|
};
|
|
var dayjs = function dayjs2(date, c2) {
|
|
if (isDayjs(date)) {
|
|
return date.clone();
|
|
}
|
|
var cfg = typeof c2 === "object" ? c2 : {};
|
|
cfg.date = date;
|
|
cfg.args = arguments;
|
|
return new Dayjs(cfg);
|
|
};
|
|
var wrapper = function wrapper2(date, instance) {
|
|
return dayjs(date, {
|
|
locale: instance.$L,
|
|
utc: instance.$u,
|
|
x: instance.$x,
|
|
$offset: instance.$offset
|
|
});
|
|
};
|
|
var Utils = U$1;
|
|
Utils.l = parseLocale;
|
|
Utils.i = isDayjs;
|
|
Utils.w = wrapper;
|
|
var parseDate = function parseDate2(cfg) {
|
|
var date = cfg.date, utc = cfg.utc;
|
|
if (date === null)
|
|
return new Date(NaN);
|
|
if (Utils.u(date))
|
|
return new Date();
|
|
if (date instanceof Date)
|
|
return new Date(date);
|
|
if (typeof date === "string" && !/Z$/i.test(date)) {
|
|
var d2 = date.match(REGEX_PARSE);
|
|
if (d2) {
|
|
var m2 = d2[2] - 1 || 0;
|
|
var ms = (d2[7] || "0").substring(0, 3);
|
|
if (utc) {
|
|
return new Date(Date.UTC(d2[1], m2, d2[3] || 1, d2[4] || 0, d2[5] || 0, d2[6] || 0, ms));
|
|
}
|
|
return new Date(d2[1], m2, d2[3] || 1, d2[4] || 0, d2[5] || 0, d2[6] || 0, ms);
|
|
}
|
|
}
|
|
return new Date(date);
|
|
};
|
|
var Dayjs = /* @__PURE__ */ function() {
|
|
function Dayjs2(cfg) {
|
|
this.$L = parseLocale(cfg.locale, null, true);
|
|
this.parse(cfg);
|
|
this.$x = this.$x || cfg.x || {};
|
|
this[IS_DAYJS] = true;
|
|
}
|
|
var _proto = Dayjs2.prototype;
|
|
_proto.parse = function parse(cfg) {
|
|
this.$d = parseDate(cfg);
|
|
this.init();
|
|
};
|
|
_proto.init = function init() {
|
|
var $d = this.$d;
|
|
this.$y = $d.getFullYear();
|
|
this.$M = $d.getMonth();
|
|
this.$D = $d.getDate();
|
|
this.$W = $d.getDay();
|
|
this.$H = $d.getHours();
|
|
this.$m = $d.getMinutes();
|
|
this.$s = $d.getSeconds();
|
|
this.$ms = $d.getMilliseconds();
|
|
};
|
|
_proto.$utils = function $utils() {
|
|
return Utils;
|
|
};
|
|
_proto.isValid = function isValid() {
|
|
return !(this.$d.toString() === INVALID_DATE_STRING);
|
|
};
|
|
_proto.isSame = function isSame(that, units) {
|
|
var other = dayjs(that);
|
|
return this.startOf(units) <= other && other <= this.endOf(units);
|
|
};
|
|
_proto.isAfter = function isAfter(that, units) {
|
|
return dayjs(that) < this.startOf(units);
|
|
};
|
|
_proto.isBefore = function isBefore(that, units) {
|
|
return this.endOf(units) < dayjs(that);
|
|
};
|
|
_proto.$g = function $g(input, get2, set2) {
|
|
if (Utils.u(input))
|
|
return this[get2];
|
|
return this.set(set2, input);
|
|
};
|
|
_proto.unix = function unix() {
|
|
return Math.floor(this.valueOf() / 1e3);
|
|
};
|
|
_proto.valueOf = function valueOf() {
|
|
return this.$d.getTime();
|
|
};
|
|
_proto.startOf = function startOf(units, _startOf) {
|
|
var _this = this;
|
|
var isStartOf = !Utils.u(_startOf) ? _startOf : true;
|
|
var unit = Utils.p(units);
|
|
var instanceFactory = function instanceFactory2(d2, m2) {
|
|
var ins = Utils.w(_this.$u ? Date.UTC(_this.$y, m2, d2) : new Date(_this.$y, m2, d2), _this);
|
|
return isStartOf ? ins : ins.endOf(D$1);
|
|
};
|
|
var instanceFactorySet = function instanceFactorySet2(method, slice) {
|
|
var argumentStart = [0, 0, 0, 0];
|
|
var argumentEnd = [23, 59, 59, 999];
|
|
return Utils.w(_this.toDate()[method].apply(
|
|
_this.toDate("s"),
|
|
(isStartOf ? argumentStart : argumentEnd).slice(slice)
|
|
), _this);
|
|
};
|
|
var $W = this.$W, $M = this.$M, $D = this.$D;
|
|
var utcPad = "set" + (this.$u ? "UTC" : "");
|
|
switch (unit) {
|
|
case Y$1:
|
|
return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11);
|
|
case M$1:
|
|
return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1);
|
|
case W$1: {
|
|
var weekStart = this.$locale().weekStart || 0;
|
|
var gap = ($W < weekStart ? $W + 7 : $W) - weekStart;
|
|
return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M);
|
|
}
|
|
case D$1:
|
|
case DATE:
|
|
return instanceFactorySet(utcPad + "Hours", 0);
|
|
case H$1:
|
|
return instanceFactorySet(utcPad + "Minutes", 1);
|
|
case MIN:
|
|
return instanceFactorySet(utcPad + "Seconds", 2);
|
|
case S$1:
|
|
return instanceFactorySet(utcPad + "Milliseconds", 3);
|
|
default:
|
|
return this.clone();
|
|
}
|
|
};
|
|
_proto.endOf = function endOf(arg) {
|
|
return this.startOf(arg, false);
|
|
};
|
|
_proto.$set = function $set(units, _int) {
|
|
var _C$D$C$DATE$C$M$C$Y$C;
|
|
var unit = Utils.p(units);
|
|
var utcPad = "set" + (this.$u ? "UTC" : "");
|
|
var name = (_C$D$C$DATE$C$M$C$Y$C = {}, _C$D$C$DATE$C$M$C$Y$C[D$1] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[DATE] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[M$1] = utcPad + "Month", _C$D$C$DATE$C$M$C$Y$C[Y$1] = utcPad + "FullYear", _C$D$C$DATE$C$M$C$Y$C[H$1] = utcPad + "Hours", _C$D$C$DATE$C$M$C$Y$C[MIN] = utcPad + "Minutes", _C$D$C$DATE$C$M$C$Y$C[S$1] = utcPad + "Seconds", _C$D$C$DATE$C$M$C$Y$C[MS] = utcPad + "Milliseconds", _C$D$C$DATE$C$M$C$Y$C)[unit];
|
|
var arg = unit === D$1 ? this.$D + (_int - this.$W) : _int;
|
|
if (unit === M$1 || unit === Y$1) {
|
|
var date = this.clone().set(DATE, 1);
|
|
date.$d[name](arg);
|
|
date.init();
|
|
this.$d = date.set(DATE, Math.min(this.$D, date.daysInMonth())).$d;
|
|
} else if (name)
|
|
this.$d[name](arg);
|
|
this.init();
|
|
return this;
|
|
};
|
|
_proto.set = function set2(string, _int2) {
|
|
return this.clone().$set(string, _int2);
|
|
};
|
|
_proto.get = function get2(unit) {
|
|
return this[Utils.p(unit)]();
|
|
};
|
|
_proto.add = function add2(number, units) {
|
|
var _this2 = this, _C$MIN$C$H$C$S$unit;
|
|
number = Number(number);
|
|
var unit = Utils.p(units);
|
|
var instanceFactorySet = function instanceFactorySet2(n2) {
|
|
var d2 = dayjs(_this2);
|
|
return Utils.w(d2.date(d2.date() + Math.round(n2 * number)), _this2);
|
|
};
|
|
if (unit === M$1) {
|
|
return this.set(M$1, this.$M + number);
|
|
}
|
|
if (unit === Y$1) {
|
|
return this.set(Y$1, this.$y + number);
|
|
}
|
|
if (unit === D$1) {
|
|
return instanceFactorySet(1);
|
|
}
|
|
if (unit === W$1) {
|
|
return instanceFactorySet(7);
|
|
}
|
|
var step = (_C$MIN$C$H$C$S$unit = {}, _C$MIN$C$H$C$S$unit[MIN] = MILLISECONDS_A_MINUTE, _C$MIN$C$H$C$S$unit[H$1] = MILLISECONDS_A_HOUR, _C$MIN$C$H$C$S$unit[S$1] = MILLISECONDS_A_SECOND, _C$MIN$C$H$C$S$unit)[unit] || 1;
|
|
var nextTimeStamp = this.$d.getTime() + number * step;
|
|
return Utils.w(nextTimeStamp, this);
|
|
};
|
|
_proto.subtract = function subtract(number, string) {
|
|
return this.add(number * -1, string);
|
|
};
|
|
_proto.format = function format(formatStr) {
|
|
var _this3 = this;
|
|
var locale = this.$locale();
|
|
if (!this.isValid())
|
|
return locale.invalidDate || INVALID_DATE_STRING;
|
|
var str = formatStr || FORMAT_DEFAULT;
|
|
var zoneStr = Utils.z(this);
|
|
var $H = this.$H, $m = this.$m, $M = this.$M;
|
|
var weekdays = locale.weekdays, months = locale.months, meridiem = locale.meridiem;
|
|
var getShort = function getShort2(arr, index2, full, length) {
|
|
return arr && (arr[index2] || arr(_this3, str)) || full[index2].slice(0, length);
|
|
};
|
|
var get$H = function get$H2(num) {
|
|
return Utils.s($H % 12 || 12, num, "0");
|
|
};
|
|
var meridiemFunc = meridiem || function(hour, minute, isLowercase) {
|
|
var m2 = hour < 12 ? "AM" : "PM";
|
|
return isLowercase ? m2.toLowerCase() : m2;
|
|
};
|
|
var matches = function matches2(match) {
|
|
switch (match) {
|
|
case "YY":
|
|
return String(_this3.$y).slice(-2);
|
|
case "YYYY":
|
|
return Utils.s(_this3.$y, 4, "0");
|
|
case "M":
|
|
return $M + 1;
|
|
case "MM":
|
|
return Utils.s($M + 1, 2, "0");
|
|
case "MMM":
|
|
return getShort(locale.monthsShort, $M, months, 3);
|
|
case "MMMM":
|
|
return getShort(months, $M);
|
|
case "D":
|
|
return _this3.$D;
|
|
case "DD":
|
|
return Utils.s(_this3.$D, 2, "0");
|
|
case "d":
|
|
return String(_this3.$W);
|
|
case "dd":
|
|
return getShort(locale.weekdaysMin, _this3.$W, weekdays, 2);
|
|
case "ddd":
|
|
return getShort(locale.weekdaysShort, _this3.$W, weekdays, 3);
|
|
case "dddd":
|
|
return weekdays[_this3.$W];
|
|
case "H":
|
|
return String($H);
|
|
case "HH":
|
|
return Utils.s($H, 2, "0");
|
|
case "h":
|
|
return get$H(1);
|
|
case "hh":
|
|
return get$H(2);
|
|
case "a":
|
|
return meridiemFunc($H, $m, true);
|
|
case "A":
|
|
return meridiemFunc($H, $m, false);
|
|
case "m":
|
|
return String($m);
|
|
case "mm":
|
|
return Utils.s($m, 2, "0");
|
|
case "s":
|
|
return String(_this3.$s);
|
|
case "ss":
|
|
return Utils.s(_this3.$s, 2, "0");
|
|
case "SSS":
|
|
return Utils.s(_this3.$ms, 3, "0");
|
|
case "Z":
|
|
return zoneStr;
|
|
}
|
|
return null;
|
|
};
|
|
return str.replace(REGEX_FORMAT, function(match, $1) {
|
|
return $1 || matches(match) || zoneStr.replace(":", "");
|
|
});
|
|
};
|
|
_proto.utcOffset = function utcOffset() {
|
|
return -Math.round(this.$d.getTimezoneOffset() / 15) * 15;
|
|
};
|
|
_proto.diff = function diff2(input, units, _float) {
|
|
var _this4 = this;
|
|
var unit = Utils.p(units);
|
|
var that = dayjs(input);
|
|
var zoneDelta = (that.utcOffset() - this.utcOffset()) * MILLISECONDS_A_MINUTE;
|
|
var diff3 = this - that;
|
|
var getMonth = function getMonth2() {
|
|
return Utils.m(_this4, that);
|
|
};
|
|
var result;
|
|
switch (unit) {
|
|
case Y$1:
|
|
result = getMonth() / 12;
|
|
break;
|
|
case M$1:
|
|
result = getMonth();
|
|
break;
|
|
case Q$1:
|
|
result = getMonth() / 3;
|
|
break;
|
|
case W$1:
|
|
result = (diff3 - zoneDelta) / MILLISECONDS_A_WEEK;
|
|
break;
|
|
case D$1:
|
|
result = (diff3 - zoneDelta) / MILLISECONDS_A_DAY;
|
|
break;
|
|
case H$1:
|
|
result = diff3 / MILLISECONDS_A_HOUR;
|
|
break;
|
|
case MIN:
|
|
result = diff3 / MILLISECONDS_A_MINUTE;
|
|
break;
|
|
case S$1:
|
|
result = diff3 / MILLISECONDS_A_SECOND;
|
|
break;
|
|
default:
|
|
result = diff3;
|
|
break;
|
|
}
|
|
return _float ? result : Utils.a(result);
|
|
};
|
|
_proto.daysInMonth = function daysInMonth() {
|
|
return this.endOf(M$1).$D;
|
|
};
|
|
_proto.$locale = function $locale() {
|
|
return Ls[this.$L];
|
|
};
|
|
_proto.locale = function locale(preset, object) {
|
|
if (!preset)
|
|
return this.$L;
|
|
var that = this.clone();
|
|
var nextLocaleName = parseLocale(preset, object, true);
|
|
if (nextLocaleName)
|
|
that.$L = nextLocaleName;
|
|
return that;
|
|
};
|
|
_proto.clone = function clone2() {
|
|
return Utils.w(this.$d, this);
|
|
};
|
|
_proto.toDate = function toDate() {
|
|
return new Date(this.valueOf());
|
|
};
|
|
_proto.toJSON = function toJSON() {
|
|
return this.isValid() ? this.toISOString() : null;
|
|
};
|
|
_proto.toISOString = function toISOString() {
|
|
return this.$d.toISOString();
|
|
};
|
|
_proto.toString = function toString() {
|
|
return this.$d.toUTCString();
|
|
};
|
|
return Dayjs2;
|
|
}();
|
|
var proto = Dayjs.prototype;
|
|
dayjs.prototype = proto;
|
|
[["$ms", MS], ["$s", S$1], ["$m", MIN], ["$H", H$1], ["$W", D$1], ["$M", M$1], ["$y", Y$1], ["$D", DATE]].forEach(function(g2) {
|
|
proto[g2[1]] = function(input) {
|
|
return this.$g(input, g2[0], g2[1]);
|
|
};
|
|
});
|
|
dayjs.extend = function(plugin2, option) {
|
|
if (!plugin2.$i) {
|
|
plugin2(option, Dayjs, dayjs);
|
|
plugin2.$i = true;
|
|
}
|
|
return dayjs;
|
|
};
|
|
dayjs.locale = parseLocale;
|
|
dayjs.isDayjs = isDayjs;
|
|
dayjs.unix = function(timestamp) {
|
|
return dayjs(timestamp * 1e3);
|
|
};
|
|
dayjs.en = Ls[L$1];
|
|
dayjs.Ls = Ls;
|
|
dayjs.p = {};
|
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
var textEncodingShim = { exports: {} };
|
|
(function(module, exports2) {
|
|
(function(root, factory) {
|
|
{
|
|
module.exports = factory();
|
|
}
|
|
})(commonjsGlobal, function() {
|
|
var g2 = typeof commonjsGlobal !== "undefined" ? commonjsGlobal : self;
|
|
if (typeof g2.TextEncoder !== "undefined" && typeof g2.TextDecoder !== "undefined") {
|
|
return { "TextEncoder": g2.TextEncoder, "TextDecoder": g2.TextDecoder };
|
|
}
|
|
var utf8Encodings = [
|
|
"utf8",
|
|
"utf-8",
|
|
"unicode-1-1-utf-8"
|
|
];
|
|
var TextEncoder = function(encoding) {
|
|
if (utf8Encodings.indexOf(encoding) < 0 && typeof encoding !== "undefined" && encoding !== null) {
|
|
throw new RangeError("Invalid encoding type. Only utf-8 is supported");
|
|
} else {
|
|
this.encoding = "utf-8";
|
|
this.encode = function(str) {
|
|
if (typeof str !== "string") {
|
|
throw new TypeError("passed argument must be of type string");
|
|
}
|
|
var binstr = unescape(encodeURIComponent(str)), arr = new Uint8Array(binstr.length);
|
|
binstr.split("").forEach(function(char, i2) {
|
|
arr[i2] = char.charCodeAt(0);
|
|
});
|
|
return arr;
|
|
};
|
|
}
|
|
};
|
|
var TextDecoder = function(encoding, options) {
|
|
if (utf8Encodings.indexOf(encoding) < 0 && typeof encoding !== "undefined" && encoding !== null) {
|
|
throw new RangeError("Invalid encoding type. Only utf-8 is supported");
|
|
}
|
|
this.encoding = "utf-8";
|
|
this.ignoreBOM = false;
|
|
this.fatal = typeof options !== "undefined" && "fatal" in options ? options.fatal : false;
|
|
if (typeof this.fatal !== "boolean") {
|
|
throw new TypeError("fatal flag must be boolean");
|
|
}
|
|
this.decode = function(view, options2) {
|
|
if (typeof view === "undefined") {
|
|
return "";
|
|
}
|
|
var stream = typeof options2 !== "undefined" && "stream" in options2 ? options2.stream : false;
|
|
if (typeof stream !== "boolean") {
|
|
throw new TypeError("stream option must be boolean");
|
|
}
|
|
if (!ArrayBuffer.isView(view)) {
|
|
throw new TypeError("passed argument must be an array buffer view");
|
|
} else {
|
|
var arr = new Uint8Array(view.buffer, view.byteOffset, view.byteLength), charArr = new Array(arr.length);
|
|
arr.forEach(function(charcode, i2) {
|
|
charArr[i2] = String.fromCharCode(charcode);
|
|
});
|
|
return decodeURIComponent(escape(charArr.join("")));
|
|
}
|
|
};
|
|
};
|
|
return { "TextEncoder": TextEncoder, "TextDecoder": TextDecoder };
|
|
});
|
|
})(textEncodingShim);
|
|
var t = function(e2, n2) {
|
|
return t = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t2, e3) {
|
|
t2.__proto__ = e3;
|
|
} || function(t2, e3) {
|
|
for (var n3 in e3)
|
|
Object.prototype.hasOwnProperty.call(e3, n3) && (t2[n3] = e3[n3]);
|
|
}, t(e2, n2);
|
|
};
|
|
function e(e2, n2) {
|
|
if ("function" != typeof n2 && null !== n2)
|
|
throw new TypeError("Class extends value " + String(n2) + " is not a constructor or null");
|
|
function r2() {
|
|
this.constructor = e2;
|
|
}
|
|
t(e2, n2), e2.prototype = null === n2 ? Object.create(n2) : (r2.prototype = n2.prototype, new r2());
|
|
}
|
|
function n(t2, e2, n2, r2) {
|
|
var a2, o2 = arguments.length, i2 = o2 < 3 ? e2 : null === r2 ? r2 = Object.getOwnPropertyDescriptor(e2, n2) : r2;
|
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate)
|
|
i2 = Reflect.decorate(t2, e2, n2, r2);
|
|
else
|
|
for (var u2 = t2.length - 1; u2 >= 0; u2--)
|
|
(a2 = t2[u2]) && (i2 = (o2 < 3 ? a2(i2) : o2 > 3 ? a2(e2, n2, i2) : a2(e2, n2)) || i2);
|
|
return o2 > 3 && i2 && Object.defineProperty(e2, n2, i2), i2;
|
|
}
|
|
function r(t2, e2, n2) {
|
|
if (n2 || 2 === arguments.length)
|
|
for (var r2, a2 = 0, o2 = e2.length; a2 < o2; a2++)
|
|
!r2 && a2 in e2 || (r2 || (r2 = Array.prototype.slice.call(e2, 0, a2)), r2[a2] = e2[a2]);
|
|
return t2.concat(r2 || Array.prototype.slice.call(e2));
|
|
}
|
|
"function" == typeof SuppressedError && SuppressedError;
|
|
var a = { ms: "millisecond", s: "second", m: "minute", h: "hour", d: "day", w: "week", M: "month", q: "quarter", y: "year", lh: "lunarhour", ld: "lunarday", lM: "lunarmonth", ly: "lunaryear", ch: "char8hour", cd: "char8day", cM: "char8month", cy: "char8year" }, o = /* @__PURE__ */ new Set(["lunarhour", "lunarday", "lunarmonth", "lunaryear"]), i = "Invalid Date", u = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, c = /\[([^\]]+)]|cZ|t|T|lYn|lMn|lDn|lHn|lY|lM|lL|lD|lH|cYsn|cYs|cYbn|cYb|cYn|cY|cMsn|cMs|cMbn|cMb|cMn|cM|cDsn|cDs|cDbn|cDb|cDn|cD|cHsn|cHs|cHbn|cHb|cHn|cH|dRr|dR|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, s = [[9], [5, 9, 7], [0, 2, 4], [1], [4, 1, 9], [2, 6, 4], [3, 5], [5, 3, 1], [6, 8, 4], [7], [4, 7, 3], [8, 0]], l = [2018, 12, 7], f = [2022, 3, 12], h = { name: "zh", leap: "\u958F", lunarYearUnit: "\u5E74", lunarHourUnit: "\u6642", bigMonth: "\u5927", smallMonth: "\u5C0F", weekdays: ["\u661F\u671F\u65E5", "\u661F\u671F\u4E00", "\u661F\u671F\u4E8C", "\u661F\u671F\u4E09", "\u661F\u671F\u56DB", "\u661F\u671F\u4E94", "\u661F\u671F\u516D"], weekdaysShort: ["\u9031\u65E5", "\u9031\u4E00", "\u9031\u4E8C", "\u9031\u4E09", "\u9031\u56DB", "\u9031\u4E94", "\u9031\u516D"], weekdaysMin: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"], months: "\u4E00\u6708_\u4E8C\u6708_\u4E09\u6708_\u56DB\u6708_\u4E94\u6708_\u516D\u6708_\u4E03\u6708_\u516B\u6708_\u4E5D\u6708_\u5341\u6708_\u5341\u4E00\u6708_\u5341\u4E8C\u6708".split("_"), monthsShort: "1\u6708_2\u6708_3\u6708_4\u6708_5\u6708_6\u6708_7\u6708_8\u6708_9\u6708_10\u6708_11\u6708_12\u6708".split("_"), lunarMonths: "\u6B63\u6708_\u4E8C\u6708_\u4E09\u6708_\u56DB\u6708_\u4E94\u6708_\u516D\u6708_\u4E03\u6708_\u516B\u6708_\u4E5D\u6708_\u5341\u6708_\u5341\u4E00\u6708_\u5341\u4E8C\u6708".split("_"), lunarMonthsAlias: "\u6B63\u6708_\u4E8C\u6708_\u4E09\u6708_\u56DB\u6708_\u4E94\u6708_\u516D\u6708_\u4E03\u6708_\u516B\u6708_\u4E5D\u6708_\u5341\u6708_\u51AC\u6708_\u814A\u6708".split("_"), lunarDays: "\u521D\u4E00_\u521D\u4E8C_\u521D\u4E09_\u521D\u56DB_\u521D\u4E94_\u521D\u516D_\u521D\u4E03_\u521D\u516B_\u521D\u4E5D_\u521D\u5341_\u5341\u4E00_\u5341\u4E8C_\u5341\u4E09_\u5341\u56DB_\u5341\u4E94_\u5341\u516D_\u5341\u4E03_\u5341\u516B_\u5341\u4E5D_\u4E8C\u5341_\u5EFF\u4E00_\u5EFF\u4E8C_\u5EFF\u4E09_\u5EFF\u56DB_\u5EFF\u4E94_\u5EFF\u516D_\u5EFF\u4E03_\u5EFF\u516B_\u5EFF\u4E5D_\u4E09\u5341".split("_"), numerals: "\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341".split(""), constellationName: "\u767D\u7F8A\u5EA7_\u91D1\u725B\u5EA7_\u96D9\u5B50\u5EA7_\u5DE8\u87F9\u5EA7_\u72EE\u5B50\u5EA7_\u8655\u5973\u5EA7_\u5929\u79E4\u5EA7_\u5929\u874E\u5EA7_\u5C04\u624B\u5EA7_\u6469\u7FAF\u5EA7_\u6C34\u74F6\u5EA7_\u96D9\u9B5A\u5EA7".split("_"), solarTerm: "\u5C0F\u5BD2_\u5927\u5BD2_\u7ACB\u6625_\u96E8\u6C34_\u9A5A\u87C4_\u6625\u5206_\u6E05\u660E_\u7A40\u96E8_\u7ACB\u590F_\u5C0F\u6EFF_\u8292\u7A2E_\u590F\u81F3_\u5C0F\u6691_\u5927\u6691_\u7ACB\u79CB_\u8655\u6691_\u767D\u9732_\u79CB\u5206_\u5BD2\u9732_\u971C\u964D_\u7ACB\u51AC_\u5C0F\u96EA_\u5927\u96EA_\u51AC\u81F3".split("_"), seasonName: "\u6625\u590F\u79CB\u51AC".split(""), stems: ["\u7532", "\u4E59", "\u4E19", "\u4E01", "\u620A", "\u5DF1", "\u5E9A", "\u8F9B", "\u58EC", "\u7678"], branchs: ["\u5B50", "\u4E11", "\u5BC5", "\u536F", "\u8FB0", "\u5DF3", "\u5348", "\u672A", "\u7533", "\u9149", "\u620C", "\u4EA5"], stemBranchSeparator: "", chineseZodiac: ["\u9F20", "\u725B", "\u864E", "\u5154", "\u9F8D", "\u86C7", "\u99AC", "\u7F8A", "\u7334", "\u96DE", "\u72D7", "\u8C6C"], fiveElements: ["\u6728", "\u706B", "\u571F", "\u91D1", "\u6C34"], eightTrigram: "\u5764\u9707\u574E\u514C\u826E\u96E2\u5DFD\u4E7E".split(""), moonPhase: { "\u6714": "\u6714", "\u671B": "\u671B", "\u5F26": "\u5F26", "\u6666": "\u6666" }, directions: ["", "\u5317", "\u897F\u5357", "\u6771", "\u6771\u5357", "\u4E2D", "\u897F\u5317", "\u897F", "\u6771\u5317", "\u5357"], formats: { LT: "HH:mm", LTS: "HH:mm:ss", L: "YYYY/MM/DD", LL: "YYYY\u5E74M\u6708D\u65E5", LLL: "YYYY\u5E74M\u6708D\u65E5Ah\u9EDEmm\u5206", LLLL: "YYYY\u5E74M\u6708D\u65E5ddddAh\u9EDEmm\u5206", l: "YYYY/M/D", ll: "YYYY\u5E74M\u6708D\u65E5", lll: "YYYY\u5E74M\u6708D\u65E5 HH:mm", llll: "YYYY\u5E74M\u6708D\u65E5dddd HH:mm" }, meridiem: function(t2, e2) {
|
|
var n2 = 100 * t2 + e2;
|
|
return n2 < 600 ? "\u51CC\u6668" : n2 < 900 ? "\u65E9\u4E0A" : n2 < 1100 ? "\u4E0A\u5348" : n2 < 1300 ? "\u4E2D\u5348" : n2 < 1800 ? "\u4E0B\u5348" : "\u665A\u4E0A";
|
|
} }, g = { isUTC: false, offset: 0, changeAgeTerm: 2, locales: { zh: h }, lang: "zh" }, p = 1901, v = 2100, y = [1874, 3749, 43818, 1611, 2715, 39590, 1386, 2905, 19370, 1874, 52645, 2853, 2635, 47691, 685, 1387, 17845, 3497, 65170, 3730, 3365, 44333, 2646, 694, 39637, 1748, 3753, 20298, 3730, 50854, 1323, 2647, 47446, 2906, 1748, 30561, 1865, 64275, 2707, 1323, 54555, 2733, 1386, 40357, 2980, 2889, 19787, 2709, 60077, 1334, 2733, 47818, 1458, 3493, 32418, 3402, 66965, 2711, 1366, 50549, 2773, 1746, 34645, 3749, 1610, 26191, 2715, 60122, 1386, 2921, 43954, 2898, 2853, 35627, 2635, 68267, 685, 1389, 54697, 3497, 3474, 36501, 3365, 85581, 2646, 694, 49909, 1749, 3753, 44882, 3730, 3366, 25902, 2647, 68310, 858, 1749, 43881, 1865, 1683, 35483, 1323, 2651, 19118, 1386, 60885, 2980, 2889, 44371, 2709, 1325, 34141, 2741, 76714, 1490, 3493, 56970, 3402, 3221, 35486, 1366, 2741, 19162, 1746, 51045, 1829, 1611, 42583, 3243, 1370, 25966, 2921, 94034, 2898, 2853, 56587, 2635, 1195, 41659, 1453, 2922, 19882, 3474, 61093, 3365, 2645, 47693, 1206, 1461, 30418, 3785, 69522, 3730, 3366, 54550, 2647, 1366, 37733, 1877, 1865, 26443, 1683, 60075, 1323, 2651, 43706, 1386, 2917, 35754, 2890, 69013, 2709, 1325, 50541, 2741, 1450, 34261, 3493, 3402, 28237, 3222, 60622, 1366, 2741, 47826, 1746, 3749, 34602, 1675, 67223, 1195, 1371, 54614, 2922, 1874, 35733, 2885, 2699, 19023, 1195], m = [219, 208, 129, 216, 204, 125, 213, 202, 122, 210, 130, 218, 206, 126, 214, 203, 123, 211, 201, 220, 208, 128, 216, 205, 124, 213, 202, 123, 210, 130, 217, 206, 126, 214, 204, 124, 211, 131, 219, 208, 127, 215, 205, 125, 213, 202, 122, 210, 129, 217, 206, 127, 214, 203, 124, 212, 131, 218, 208, 128, 215, 205, 125, 213, 202, 121, 209, 130, 217, 206, 127, 215, 203, 123, 211, 131, 218, 207, 128, 216, 205, 125, 213, 202, 220, 209, 129, 217, 206, 127, 215, 204, 123, 210, 131, 219, 207, 128, 216, 205, 124, 212, 201, 122, 209, 129, 218, 207, 126, 214, 203, 123, 210, 131, 219, 208, 128, 216, 205, 125, 212, 201, 122, 210, 129, 217, 206, 126, 213, 203, 123, 211, 131, 219, 208, 128, 215, 204, 124, 212, 201, 122, 210, 130, 217, 206, 126, 214, 202, 123, 211, 201, 219, 208, 128, 215, 204, 124, 212, 202, 121, 209, 129, 217, 205, 126, 214, 203, 123, 211, 131, 219, 207, 127, 215, 205, 124, 212, 202, 122, 209, 129, 217, 206, 126, 214, 203, 124, 210, 130, 218, 207, 127, 215, 205, 125, 212, 201, 121, 209], d = [4, 19, 3, 18, 4, 19, 4, 19, 4, 20, 4, 20, 6, 22, 6, 22, 6, 22, 7, 22, 6, 21, 6, 21], b = [117281173183066, 187649985522282, 187654548991914, 99670716471979, 187649984473706, 117281173183062, 187649984469594, 187654280490666, 95203950484138, 99671807007318, 117281240291930, 99671806990934, 187654280489578, 93829556755114, 99670716471894, 93829556689578, 95203950484054, 117263993313878, 93829288253866, 95203950484053, 117263993035350, 93829288252842, 93824993285482, 93829556755029, 93824992236906, 93829556689493, 117263993313882, 93824992232810, 93829288254037, 99601996995158, 117263993051738, 93824925123930, 93829288253781, 99671790213718, 23456180946266, 93824993285461, 95203946289749, 93824993285397, 93824992236821, 23439001077082, 93824992232725, 23439000814938, 93824925123861, 23439000798550, 93824925123845, 23437910279510, 23456180946181, 5845724235094, 23439000814853, 5777004758358, 23439000798469, 1378954052950, 23437910279425, 1378954052949, 93824992236885, 5845724235009, 4564518229, 4296017237, 5777004758273, 23438984021253, 1378954052865, 23437910279429, 1048661, 1378954052864, 85, 4564518144, 21, 4296082688], _ = [0, 1, 2, 3, 0, 4, 2, 3, 0, 4, 2, 3, 5, 6, 7, 8, 9, 10, 7, 8, 11, 10, 12, 8, 11, 0, 1, 13, 14, 0, 1, 13, 14, 0, 4, 13, 14, 0, 4, 13, 14, 0, 4, 15, 16, 17, 6, 18, 19, 20, 6, 18, 19, 11, 0, 21, 19, 14, 0, 22, 23, 14, 0, 22, 23, 14, 0, 24, 23, 14, 0, 24, 25, 14, 26, 27, 28, 29, 30, 27, 28, 16, 20, 31, 32, 19, 33, 34, 35, 36, 14, 34, 37, 23, 14, 34, 38, 23, 14, 34, 38, 23, 14, 34, 38, 28, 14, 39, 40, 28, 29, 41, 42, 28, 16, 43, 44, 32, 36, 45, 46, 35, 36, 47, 46, 38, 23, 47, 46, 38, 23, 47, 46, 38, 28, 47, 46, 38, 28, 47, 48, 40, 28, 49, 50, 42, 28, 51, 52, 44, 35, 53, 52, 44, 54, 53, 55, 46, 54, 56, 55, 46, 38, 56, 55, 46, 38, 57, 55, 48, 38, 57, 58, 48, 42, 57, 58, 59, 42, 57, 60, 61, 44, 62, 63, 52, 44, 64, 63, 55, 46, 64, 65, 55, 46, 66, 67, 55, 46, 38], M = function(t2) {
|
|
return t2 ? (t2 = t2.trim(), a[t2] || (t2 || "").toLowerCase().replace(/s$/, "")) : "";
|
|
}, O = function(t2, e2) {
|
|
if (void 0 === e2 && (e2 = false), void 0 === t2)
|
|
return new Date();
|
|
if (null === t2)
|
|
return new Date(NaN);
|
|
if ("object" == typeof t2 && !(t2 instanceof Date) && void 0 !== t2.toDate) {
|
|
var n2 = t2.toDate();
|
|
if (n2 instanceof Date)
|
|
return n2;
|
|
}
|
|
if (t2 instanceof Date)
|
|
return new Date(t2.valueOf());
|
|
if ("string" == typeof t2 && !/Z$/i.test(t2)) {
|
|
var r2 = t2.match(u);
|
|
if (r2) {
|
|
var a2 = r2[2] - 1 || 0, o2 = (r2[7] || "0").substring(0, 3);
|
|
return e2 ? new Date(Date.UTC(r2[1], a2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, o2)) : new Date(r2[1], a2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, o2);
|
|
}
|
|
}
|
|
return new Date(t2);
|
|
}, S = function(t2, e2, n2) {
|
|
void 0 === e2 && (e2 = false), void 0 === n2 && (n2 = false);
|
|
var r2 = L(t2, "FullYear", e2), a2 = L(t2, "Month", e2), o2 = L(t2, "Hours", e2), i2 = L(t2, "Date", e2), u2 = n2 ? 23 === o2 ? " 00:00" : " ".concat(String(o2).padStart(2, "0"), ":00") : "";
|
|
return O("".concat(r2, "/").concat(a2 + 1, "/").concat(i2 + (23 === o2 ? 1 : 0)).concat(u2), e2);
|
|
}, w = function(t2) {
|
|
var e2 = m[t2 - p];
|
|
return O("".concat(t2, "/").concat(Math.floor(e2 / 100), "/").concat(e2 % 100));
|
|
}, T = function(t2) {
|
|
var e2 = y[t2 - p];
|
|
return [e2 >> 13, 1 === (e2 >> 12 & 1)];
|
|
}, D = function(t2, e2) {
|
|
var n2;
|
|
!function(t3, e3) {
|
|
var n3 = g.locales[null != e3 ? e3 : g.lang];
|
|
if ("string" == typeof t3.year) {
|
|
for (var r3 = "", a3 = 0; a3 < t3.year.length; a3++) {
|
|
var o3 = -1;
|
|
r3 += (o3 = "\u96F6" === t3.year[a3] || "\u3007" === t3.year[a3] ? 0 : n3.numerals.indexOf(t3.year[a3])) >= 0 ? o3 : "";
|
|
}
|
|
t3.year = Number(r3);
|
|
}
|
|
if ("string" == typeof t3.month) {
|
|
var i3 = t3.month;
|
|
i3[0] === n3.leap && (t3.isLeapMonth = true, i3 = t3.month.slice(1));
|
|
var u3 = n3.lunarMonths.indexOf(i3);
|
|
-1 === u3 && (u3 = n3.lunarMonthsAlias.indexOf(i3)), t3.month = t3.isLeapMonth ? u3 + 100 + 1 : u3 + 1;
|
|
}
|
|
"string" == typeof t3.day && (t3.day = n3.lunarDays.indexOf(t3.day) + 1), "string" == typeof t3.hour && (t3.hour = n3.branchs.indexOf(t3.hour));
|
|
}(t2, e2);
|
|
var r2 = new Date(), a2 = t2.year ? Number(t2.year) : r2.getFullYear(), o2 = Number(t2.month), i2 = Number(t2.day), u2 = t2.hour ? Number(t2.hour) : 0, c2 = null !== (n2 = t2.isLeapMonth) && void 0 !== n2 && n2;
|
|
if (o2 > 100 && (o2 -= 100, c2 = true), a2 < p || a2 > v)
|
|
throw new Error("Invalid lunar year: out of range");
|
|
if (o2 < 1)
|
|
throw new Error("Invalid lunar month");
|
|
var s2 = w(a2), l2 = T(a2), f2 = l2[0], h2 = l2[1];
|
|
if (c2 && f2 !== o2)
|
|
throw new Error("Invalid lunar leap month: no this leap month");
|
|
for (var m2 = y[a2 - p], d2 = c2 ? h2 : m2 >> o2 - 1 & 1, b2 = 0, _2 = 0; _2 < o2; _2++) {
|
|
if (b2 += m2 >> _2 & 1 ? 30 : 29, _2 === o2 - 1 && !c2)
|
|
break;
|
|
_2 === f2 - 1 && (b2 += h2 ? 30 : 29);
|
|
}
|
|
b2 -= (d2 ? 30 : 29) - i2 + 1;
|
|
var M2 = new Date(s2.valueOf() + 24 * b2 * 60 * 60 * 1e3), S2 = M2.getFullYear(), D2 = M2.getMonth() + 1, j2 = M2.getDate();
|
|
return O("".concat(S2, "/").concat(D2, "/").concat(j2, " ").concat(2 * u2, ":00"));
|
|
}, j = function(t2, e2, n2, r2) {
|
|
void 0 === r2 && (r2 = false);
|
|
var a2 = n2.getDate(), o2 = L(t2, "Month", r2), i2 = e2 / 2 >> 0, u2 = i2 < o2 || 0 === o2 && 11 === i2 || a2 > L(t2, "Date", r2) && !(a2 - 1 === L(t2, "Date", r2) && L(t2, "Hours", r2) >= 23) ? -1 : 0;
|
|
return ((12 * (L(t2, "FullYear", r2) - l[0]) + L(t2, "Month", r2) - l[1] + 1) % 60 + u2 + 60) % 60;
|
|
};
|
|
var Y = { stem: [10, "stems"], branch: [12, "branchs"], trigram8: [8, "eightTrigram"], element5: [5, "fiveElements"] }, P = function(t2, e2, n2, r2) {
|
|
if ("number" == typeof t2)
|
|
t2 %= Y[e2][0];
|
|
else if ("string" == typeof t2) {
|
|
var a2 = r2.locales[n2][Y[e2][1]].indexOf(t2);
|
|
if (-1 === a2)
|
|
throw new Error("Invalid ".concat(e2, " value"));
|
|
t2 = a2;
|
|
}
|
|
return t2;
|
|
}, L = function(t2, e2, n2) {
|
|
void 0 === n2 && (n2 = false);
|
|
var r2 = e2.slice(0, 1).toUpperCase() + e2.slice(1);
|
|
return n2 ? t2["getUTC".concat(r2)]() : t2["get".concat(r2)]();
|
|
};
|
|
var C = function(t2, e2) {
|
|
var n2;
|
|
t2 = (n2 = [O(t2), O(e2)])[0];
|
|
var r2 = 12 * ((e2 = n2[1]).getFullYear() - t2.getFullYear()) + (e2.getMonth() - t2.getMonth()), a2 = new Date(t2).setMonth(t2.getMonth() + r2), o2 = a2.valueOf() > e2.valueOf(), i2 = new Date(t2).setMonth(t2.getMonth() + r2 + (o2 ? -1 : 1));
|
|
return r2 + (e2.valueOf() - a2.valueOf()) / (o2 ? a2 - i2 : i2 - a2) || 0;
|
|
}, A = function(t2, e2, n2) {
|
|
if (t2 > e2)
|
|
return -A(e2, t2);
|
|
for (var r2 = [t2.lunar, e2.lunar], a2 = r2[0], o2 = r2[1], i2 = [a2.year, o2.year], u2 = i2[0], c2 = i2[1], s2 = [a2.month, o2.month], l2 = s2[0], f2 = s2[1], h2 = u2, g2 = 0; h2 <= c2; ) {
|
|
var p2 = [1, 12], v2 = p2[0], y2 = p2[1];
|
|
h2 === u2 && (v2 = l2), h2 === c2 && (y2 = f2), g2 += U(h2, v2, y2), h2++;
|
|
}
|
|
if (!n2)
|
|
return g2 - 1;
|
|
if (g2 > 0)
|
|
g2 += N(t2, true) + N(e2, false) - 2;
|
|
else {
|
|
var m2 = a2.isBigMonth ? 30 : 29;
|
|
g2 = (e2.valueOf() - t2.valueOf()) / (864e5 * m2);
|
|
}
|
|
return g2;
|
|
}, U = function(t2, e2, n2) {
|
|
var r2 = false;
|
|
(e2 = e2 || 1) > 100 && (e2 -= 100, r2 = true), (n2 = n2 || 12) > 100 && (n2 -= 100, r2 = true);
|
|
var a2 = y[t2 - p] >> 13;
|
|
return e2 <= a2 && a2 <= n2 && (r2 = true), n2 - e2 + 1 + (r2 ? 1 : 0);
|
|
}, N = function(t2, e2) {
|
|
void 0 === e2 && (e2 = false);
|
|
var n2 = t2.lunar.isBigMonth ? 30 : 29, r2 = t2.lunar.day;
|
|
return e2 ? 1 - r2 / n2 : r2 / n2;
|
|
}, H = function(t2, e2) {
|
|
void 0 === e2 && (e2 = false);
|
|
var n2 = t2.lunar.leapMonth, r2 = n2 > 0 ? 13 : 12, a2 = false, o2 = t2.lunar.month;
|
|
o2 > 100 && (o2 -= 100, a2 = true), n2 > 0 && (o2 > n2 || o2 === n2 && a2) && o2++;
|
|
var i2 = N(t2, e2);
|
|
return e2 ? 1 - (o2 - i2) / r2 : (o2 + i2 - 1) / r2;
|
|
};
|
|
var k = function(t2, e2) {
|
|
if (e2.toUTCString() === i)
|
|
return i;
|
|
var n2, r2, a2, o2, u2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", s2 = e2.year, l2 = e2.month, f2 = e2.day, h2 = e2.dayOfWeek, p2 = e2.hour, v2 = e2.minute, y2 = e2.second, m2 = (n2 = -e2.utcOffset(), r2 = Math.abs(n2), a2 = Math.floor(r2 / 60), o2 = r2 % 60, "".concat(n2 <= 0 ? "+" : "-").concat(String(a2).padStart(2, "0"), ":").concat(String(o2).padStart(2, "0"))), d2 = function() {
|
|
return e2.lunar;
|
|
}, b2 = function() {
|
|
return e2.char8;
|
|
}, _2 = g.locales[e2._config.lang], M2 = _2.weekdays, O2 = _2.months, S2 = _2.meridiem, w2 = function(t3, e3, n3, r3) {
|
|
return t3 && t3[e3] || (n3 ? n3[e3].slice(0, r3) : "");
|
|
}, T2 = p2 % 12 || 12, D2 = S2 || function(t3, e3, n3) {
|
|
var r3 = t3 < 12 ? "AM" : "PM";
|
|
return n3 ? r3.toLowerCase() : r3;
|
|
}, j2 = { YY: String(s2).slice(-2), YYYY: String(s2), M: String(l2), MM: String(l2).padStart(2, "0"), MMM: w2(_2.monthsShort, l2 - 1, O2, 3), MMMM: w2(O2, l2 - 1), D: String(f2), DD: String(f2).padStart(2, "0"), d: String(h2), dd: w2(_2.weekdaysMin, h2, M2, 2), ddd: w2(_2.weekdaysShort, h2, M2, 3), dddd: M2[h2], H: String(p2), HH: String(p2).padStart(2, "0"), h: String(T2), hh: String(T2).padStart(2, "0"), a: D2(p2, v2, true), A: D2(p2, v2, false), m: String(v2), mm: String(v2).padStart(2, "0"), s: String(y2), ss: String(y2).padStart(2, "0"), SSS: String(e2.millis).padStart(3, "0"), Z: m2, cZ: function() {
|
|
return _2.chineseZodiac[b2().year.branch.value];
|
|
}, t: e2.solarTerm ? String(e2.solarTerm.value + 1) : "", T: e2.solarTerm ? e2.solarTerm.toString() : "", lY: function() {
|
|
return d2().getYearName();
|
|
}, lM: function() {
|
|
return d2().getMonthName();
|
|
}, lD: function() {
|
|
return d2().getDayName();
|
|
}, lH: function() {
|
|
return d2().getHourName();
|
|
}, lL: function() {
|
|
return d2().isBigMonth ? _2.bigMonth : _2.smallMonth;
|
|
}, lYn: function() {
|
|
return String(d2().year);
|
|
}, lMn: function() {
|
|
return String(d2().month);
|
|
}, lDn: function() {
|
|
return String(d2().day);
|
|
}, lHn: function() {
|
|
return String(d2().hour + 1);
|
|
}, cY: function() {
|
|
return b2().year.toString();
|
|
}, cYs: function() {
|
|
return b2().year.stem.toString();
|
|
}, cYb: function() {
|
|
return b2().year.branch.toString();
|
|
}, cM: function() {
|
|
return b2().month.toString();
|
|
}, cMs: function() {
|
|
return b2().month.stem.toString();
|
|
}, cMb: function() {
|
|
return b2().month.branch.toString();
|
|
}, cD: function() {
|
|
return b2().day.toString();
|
|
}, cDs: function() {
|
|
return b2().day.stem.toString();
|
|
}, cDb: function() {
|
|
return b2().day.branch.toString();
|
|
}, cH: function() {
|
|
return b2().hour.toString();
|
|
}, cHs: function() {
|
|
return b2().hour.stem.toString();
|
|
}, cHb: function() {
|
|
return b2().hour.branch.toString();
|
|
}, cYn: function() {
|
|
return b2().year.value;
|
|
}, cYsn: function() {
|
|
return b2().year.stem.value;
|
|
}, cYbn: function() {
|
|
return b2().year.branch.value;
|
|
}, cMn: function() {
|
|
return b2().month.value;
|
|
}, cMsn: function() {
|
|
return b2().month.stem.value;
|
|
}, cMbn: function() {
|
|
return b2().month.branch.value;
|
|
}, cDn: function() {
|
|
return b2().day.value;
|
|
}, cDsn: function() {
|
|
return b2().day.stem.value;
|
|
}, cDbn: function() {
|
|
return b2().day.branch.value;
|
|
}, cHn: function() {
|
|
return b2().hour.value;
|
|
}, cHsn: function() {
|
|
return b2().hour.stem.value;
|
|
}, cHbn: function() {
|
|
return b2().hour.branch.value;
|
|
}, dR: function() {
|
|
return String(Math.ceil(f2 / 7));
|
|
}, dRr: function() {
|
|
var t3 = e2.lunisolar("".concat(s2, "-").concat(l2 + 1, "-1 ").concat(p2, ":").concat(v2, ":").concat(y2), e2._config), n3 = Math.abs(t3.diff(e2, "day"));
|
|
return String(Math.ceil(n3 / 7));
|
|
} };
|
|
return u2 = u2.replace(c, function(t3, e3) {
|
|
var n3 = j2[t3];
|
|
return e3 || ("function" == typeof n3 ? n3() : void 0 !== n3 ? n3 : m2.replace(":", ""));
|
|
});
|
|
};
|
|
function x(t2, e2) {
|
|
return Math.round((e2.valueOf() - t2.valueOf()) / 864e5);
|
|
}
|
|
var B = function() {
|
|
function t2(t3, e2) {
|
|
var n2;
|
|
this._config = { lang: g.lang, isUTC: false }, e2 && (this._config = Object.assign({}, this._config, e2));
|
|
var r2 = O(t3);
|
|
this._date = r2;
|
|
var a2 = this._config.isUTC, o2 = L(r2, "FullYear", a2), i2 = L(r2, "Month", a2), u2 = L(r2, "Hours", a2), c2 = S(r2, a2), s2 = c2.getDate();
|
|
if (o2 < p || o2 > v)
|
|
throw new Error("Invalid lunar year: out of range");
|
|
if (o2 === p && i2 < 1 || o2 === p && 1 === i2 && s2 < 19)
|
|
this.year = o2 - 1, 1 === i2 || i2 < 1 && s2 >= 20 ? (this.month = 12, this.day = 1 === i2 ? 13 + s2 - 1 : s2 - 20 + 1) : (this.month = 11, this.day = 11 + s2 - 1), this.leapMonth = 8, this.leapMonthIsBig = false;
|
|
else {
|
|
var l2 = x(w(o2), c2);
|
|
l2 < 0 && (l2 = x(w(o2 -= 1), c2)), this.year = o2;
|
|
var f2 = T(o2), h2 = f2[0], m2 = f2[1];
|
|
this.leapMonth = h2, this.leapMonthIsBig = m2, n2 = function(t4, e3, n3) {
|
|
var r3 = y[t4 - p], a3 = n3 || T(t4), o3 = a3[0], i3 = a3[1], u3 = 1;
|
|
e3 += 1;
|
|
for (var c3 = false; e3 > 29; ) {
|
|
if (e3 -= r3 >> u3 - 1 & 1 ? 30 : 29, u3 === o3 && e3 > 0) {
|
|
var s3 = i3 ? 30 : 29;
|
|
if (!(e3 > s3)) {
|
|
c3 = true;
|
|
break;
|
|
}
|
|
e3 -= s3;
|
|
}
|
|
u3++;
|
|
}
|
|
return c3 && (u3 += 100), 0 === e3 && (e3 = 30, u3--), [u3, e3];
|
|
}(o2, l2, [h2, m2]), this.month = n2[0], this.day = n2[1];
|
|
}
|
|
this.hour = (u2 + 1) % 24 >> 1;
|
|
}
|
|
return t2.fromLunar = function(e2, n2) {
|
|
return new t2(D(e2, null == n2 ? void 0 : n2.lang), n2);
|
|
}, Object.defineProperty(t2.prototype, "isLeapMonth", { get: function() {
|
|
return this.month > 100;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "isBigMonth", { get: function() {
|
|
if (1900 === this.year && 11 == this.month)
|
|
return false;
|
|
if (1900 === this.year && 12 == this.month)
|
|
return true;
|
|
var t3 = y[this.year - p];
|
|
return this.isLeapMonth ? 1 == (t3 >> 12 & 1) : 1 == (t3 >> this.month - 1 & 1);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "isLastDayOfMonth", { get: function() {
|
|
return !(!this.isBigMonth || 30 !== this.day) || !this.isBigMonth && 29 === this.day;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "lunarNewYearDay", { get: function() {
|
|
return w(this.year);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "lastDayOfYear", { get: function() {
|
|
var t3 = w(this.year + 1);
|
|
return new Date(t3.valueOf() - 864e5);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "phaseOfTheMoon", { get: function() {
|
|
return function(t3, e2) {
|
|
var n2 = t3.day;
|
|
return 1 === n2 ? e2.moonPhase.\u6714 : [7, 8, 22, 23].includes(n2) ? e2.moonPhase.\u5F26 : 15 === n2 ? e2.moonPhase.\u671B : t3.isLastDayOfMonth ? e2.moonPhase.\u6666 : "";
|
|
}(this, g.locales[this._config.lang]);
|
|
}, enumerable: false, configurable: true }), t2.prototype.toDate = function() {
|
|
return new Date(this._date.valueOf());
|
|
}, t2.prototype.getYearName = function() {
|
|
for (var t3 = "", e2 = this.year, n2 = g.locales[this._config.lang].numerals; e2; ) {
|
|
t3 = n2[e2 % 10] + t3, e2 = Math.floor(e2 / 10);
|
|
}
|
|
return t3;
|
|
}, t2.prototype.getMonthName = function() {
|
|
var t3 = g.locales[this._config.lang].lunarMonths, e2 = g.locales[this._config.lang].leap;
|
|
return (this.isLeapMonth ? e2 : "") + t3[this.month % 100 - 1];
|
|
}, t2.prototype.getDayName = function() {
|
|
return g.locales[this._config.lang].lunarDays[this.day - 1];
|
|
}, t2.prototype.getHourName = function() {
|
|
return g.locales[this._config.lang].branchs[this.hour];
|
|
}, t2.prototype.toString = function() {
|
|
var t3 = g.locales[this._config.lang];
|
|
return "".concat(this.getYearName()).concat(t3.lunarYearUnit).concat(this.getMonthName()).concat(this.getDayName()).concat(this.getHourName()).concat(t3.lunarHourUnit);
|
|
}, t2.prototype.valueOf = function() {
|
|
return this._date.valueOf();
|
|
}, t2.getLunarNewYearDay = function(t3) {
|
|
return w(t3);
|
|
}, t2;
|
|
}(), F = function() {
|
|
function t2(e2, n2) {
|
|
if (this.value = -1, this._config = { lang: g.lang, isUTC: false }, n2 && (this._config = Object.assign({}, this._config, n2)), e2 instanceof t2)
|
|
return e2;
|
|
if ("number" == typeof e2)
|
|
this.value = e2 % 24;
|
|
else if ("string" == typeof e2) {
|
|
var r2 = g.locales[this._config.lang].solarTerm.indexOf(e2);
|
|
if (-1 === r2)
|
|
throw new Error("Invalid term value");
|
|
this.value = r2;
|
|
}
|
|
}
|
|
return Object.defineProperty(t2.prototype, "name", { get: function() {
|
|
return String(g.locales[this._config.lang].solarTerm[this.value]);
|
|
}, enumerable: false, configurable: true }), t2.getNames = function(t3) {
|
|
return t3 = t3 || g.lang, r([], g.locales[t3].solarTerm, true);
|
|
}, t2.getYearTermDayList = function(t3) {
|
|
for (var e2 = [], n2 = b[_[t3 - p]].toString(2).padStart(48, "0"); e2.length < 24; ) {
|
|
var r2 = parseInt(n2.slice(n2.length - 2), 2), a2 = d[e2.length];
|
|
e2.push(r2 + a2), n2 = n2.slice(0, n2.length - 2);
|
|
}
|
|
return e2;
|
|
}, t2.getMonthTerms = function(t3, e2) {
|
|
var n2 = b[_[t3 - p]].toString(2).padStart(48, "0"), r2 = 4 * (e2 - 1), a2 = parseInt(n2.slice(n2.length - r2 - 4, n2.length - r2), 2);
|
|
return [(3 & a2) + d[2 * (e2 - 1)], (a2 >> 2 & 3) + d[2 * (e2 - 1) + 1]];
|
|
}, t2.findDate = function(e2, n2, r2) {
|
|
var a2 = r2 && r2.lang ? r2.lang : g.lang;
|
|
return n2 instanceof t2 && (n2 = n2.value), [e2, ((n2 = "string" == typeof n2 ? g.locales[a2].solarTerm.indexOf(n2) : n2 % 24) >> 1) + 1, t2.getYearTermDayList(e2)[n2]];
|
|
}, t2.findNode = function(e2, n2) {
|
|
var r2, a2 = { lang: g.lang, returnValue: false, nodeFlag: 0, isUTC: false }, o2 = n2 ? Object.assign({}, a2, n2) : a2, i2 = o2.returnValue, u2 = o2.nodeFlag;
|
|
if (u2 > 2)
|
|
throw new Error("Invalid nodeFlag");
|
|
var c2, s2 = { lang: o2.lang || g.lang }, l2 = L(e2, "FullYear", o2.isUTC), f2 = L(e2, "Month", o2.isUTC), h2 = L(e2, "Date", o2.isUTC), p2 = L(e2, "Hours", o2.isUTC), v2 = (2 * f2 + 24) % 24, y2 = t2.getMonthTerms(l2, f2 + 1), m2 = y2[0], d2 = y2[1], b2 = false, _2 = false;
|
|
h2 < m2 && !(h2 === m2 - 1 && p2 >= 23) ? b2 = true : h2 < d2 && !(h2 === d2 - 1 && p2 >= 23) && (_2 = true, 1 === u2 && (b2 = true));
|
|
var M2 = false;
|
|
b2 ? (f2 - 1 < 0 ? (l2--, f2 = 11) : f2--, v2 = (2 * f2 + 24) % 24, m2 = (r2 = t2.getMonthTerms(l2, f2 + 1))[0], d2 = r2[1], u2 > 0 && (M2 = true)) : (1 === u2 || 2 === u2 && !_2) && (M2 = true), c2 = M2 ? d2 : m2, v2 = M2 ? (v2 + 1) % 24 : v2;
|
|
var S2 = O("".concat(l2, "-").concat(f2 + 1, "-").concat(c2));
|
|
return i2 ? [v2, S2] : [new t2(v2, s2), S2];
|
|
}, t2.prototype.valueOf = function() {
|
|
return this.value;
|
|
}, t2.prototype.toString = function() {
|
|
return this.name;
|
|
}, t2;
|
|
}(), I = function() {
|
|
function t2(e2, n2) {
|
|
if (this.value = -1, this._config = { lang: g.lang }, e2 instanceof t2)
|
|
return e2;
|
|
n2 && (this._config = Object.assign({}, this._config, n2)), this.value = P(e2, "element5", this._config.lang, g);
|
|
}
|
|
return t2.getNames = function(t3) {
|
|
return t3 = t3 || g.lang, r([], g.locales[t3].fiveElements, true);
|
|
}, t2.create = function(e2, n2) {
|
|
if (e2 instanceof t2)
|
|
return e2;
|
|
var r2 = (null == n2 ? void 0 : n2.lang) || g.lang;
|
|
e2 = P(e2, "element5", r2, g);
|
|
var a2 = "".concat(e2, ":").concat(r2);
|
|
if (t2.instances.has(a2))
|
|
return t2.instances.get(a2);
|
|
var o2 = new t2(e2, n2);
|
|
return t2.instances.set(a2, o2), o2;
|
|
}, Object.defineProperty(t2.prototype, "name", { get: function() {
|
|
return -1 === this.value ? "" : g.locales[this._config.lang].fiveElements[this.value];
|
|
}, enumerable: false, configurable: true }), t2.prototype.generating = function() {
|
|
var e2 = (this.value + 1) % 5;
|
|
return t2.create(e2, this._config);
|
|
}, t2.prototype.overcoming = function() {
|
|
var e2 = (this.value + 2) % 5;
|
|
return t2.create(e2, this._config);
|
|
}, t2.prototype.weakening = function() {
|
|
var e2 = (this.value + 4) % 5;
|
|
return t2.create(e2, this._config);
|
|
}, t2.prototype.counteracting = function() {
|
|
var e2 = (this.value + 3) % 5;
|
|
return t2.create(e2, this._config);
|
|
}, t2.prototype.toString = function() {
|
|
return -1 === this.value ? "Invalid five-element value" : this.name;
|
|
}, t2.prototype.valueOf = function() {
|
|
return this.value;
|
|
}, t2.instances = /* @__PURE__ */ new Map(), t2;
|
|
}(), E = function() {
|
|
function t2(t3, e2) {
|
|
this.value = -1, this._config = { lang: g.lang }, e2 && (this._config = Object.assign({}, this._config, e2)), this.value = t3 % 8;
|
|
}
|
|
return t2.getNames = function(t3) {
|
|
return t3 = t3 || g.lang, r([], g.locales[t3].eightTrigram, true);
|
|
}, t2.create = function(e2, n2) {
|
|
var r2 = (null == n2 ? void 0 : n2.lang) || g.lang;
|
|
e2 = P(e2, "trigram8", r2, g);
|
|
var a2 = "".concat(e2, ":").concat(r2);
|
|
if (t2.instances.has(a2))
|
|
return t2.instances.get(a2);
|
|
var o2 = new t2(e2, n2);
|
|
return t2.instances.set(a2, o2), o2;
|
|
}, Object.defineProperty(t2.prototype, "name", { get: function() {
|
|
return g.locales[this._config.lang].eightTrigram[this.value];
|
|
}, enumerable: false, configurable: true }), t2.prototype.toString = function() {
|
|
return this.name;
|
|
}, t2.prototype.valueOf = function() {
|
|
return this.value;
|
|
}, t2.instances = /* @__PURE__ */ new Map(), t2;
|
|
}();
|
|
function z(t2, e2) {
|
|
return void 0 === e2 && (e2 = false), function(n2, a2, o2) {
|
|
var i2 = void 0 === o2.value ? o2.get : o2.value;
|
|
o2[void 0 === o2.value ? "get" : "value"] = function() {
|
|
for (var n3 = [], a3 = 0; a3 < arguments.length; a3++)
|
|
n3[a3] = arguments[a3];
|
|
if (n3.length > 0 && e2) {
|
|
var o3 = JSON.stringify(n3);
|
|
t2 += o3;
|
|
}
|
|
if (this.cache.has(t2))
|
|
return this.cache.get(t2);
|
|
var u2 = i2.call.apply(i2, r([this], n3, false));
|
|
return this.cache.set(t2, u2), u2;
|
|
};
|
|
};
|
|
}
|
|
var Z = function() {
|
|
this.cache = /* @__PURE__ */ new Map();
|
|
}, G = function(t2) {
|
|
function a2(e2, n2) {
|
|
var r2 = t2.call(this) || this;
|
|
return r2.value = -1, r2._config = { lang: g.lang }, e2 instanceof a2 ? e2 : (n2 && (r2._config = Object.assign({}, r2._config, n2)), r2.value = P(e2, "branch", r2._config.lang, g), r2);
|
|
}
|
|
return e(a2, t2), a2.getNames = function(t3) {
|
|
return t3 = t3 || g.lang, r([], g.locales[t3].branchs, true);
|
|
}, a2.create = function(t3, e2) {
|
|
if (t3 instanceof a2)
|
|
return t3;
|
|
var n2 = (null == e2 ? void 0 : e2.lang) || g.lang;
|
|
t3 = P(t3, "branch", n2, g);
|
|
var r2 = "".concat(t3, ":").concat(n2);
|
|
if (a2.instances.has(r2))
|
|
return a2.instances.get(r2);
|
|
var o2 = new a2(t3, e2);
|
|
return a2.instances.set(r2, o2), o2;
|
|
}, Object.defineProperty(a2.prototype, "name", { get: function() {
|
|
return g.locales[this._config.lang].branchs[this.value];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "hiddenStems", { get: function() {
|
|
return s[this.value].map(function(t3) {
|
|
return new R(t3);
|
|
});
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "e5", { get: function() {
|
|
var t3 = Math.floor((this.value + 10) / 3) % 4;
|
|
return (this.value + 10) % 3 == 2 ? I.create(2, this._config) : I.create(t3 < 2 ? t3 : t3 + 1, this._config);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "meeting", { get: function() {
|
|
var t3 = this, e2 = [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 0, 1]].find(function(e3) {
|
|
return e3.includes(t3.value);
|
|
}), n2 = null == e2 ? void 0 : e2.filter(function(e3) {
|
|
return e3 !== t3.value;
|
|
});
|
|
return [a2.create(n2[0], this._config), a2.create(n2[1], this._config)];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "meetingE5", { get: function() {
|
|
return I.create((t3 = this.value, [0, 1, 3, 4][Math.floor((t3 - 2 + 12) % 12 / 3)]), this._config);
|
|
var t3;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "triad", { get: function() {
|
|
return [a2.create((this.value + 4) % 12, this._config), a2.create((this.value + 8) % 12, this._config)];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "triadE5", { get: function() {
|
|
return I.create([4, 0, 1, 3][this.value % 4], this._config);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "group6", { get: function() {
|
|
return a2.create((13 - this.value) % 12, this._config);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "group6E5", { get: function() {
|
|
return I.create((t3 = this.value, e2 = [2, 0, 1, 3, 4, 2], (t3 = 0 === t3 ? 12 : t3) < 7 ? e2[t3 - 1] : e2[12 - t3]), this._config);
|
|
var t3, e2;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "punishing", { get: function() {
|
|
return a2.create([3, 10, 5, 0, 4, 8, 6, 1, 2, 9, 7, 11][this.value], this._config);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "punishBy", { get: function() {
|
|
return a2.create([3, 7, 8, 0, 4, 2, 6, 10, 5, 9, 1, 11][this.value], this._config);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "conflict", { get: function() {
|
|
return a2.create((this.value + 6) % 12, this._config);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "destroying", { get: function() {
|
|
return a2.create([9, 4, 11, 6, 1, 8, 3, 10, 5, 0, 7, 2][this.value], this._config);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "harming", { get: function() {
|
|
var t3 = this.value > 7 ? 19 - this.value : 7 - this.value;
|
|
return a2.create(t3, this._config);
|
|
}, enumerable: false, configurable: true }), a2.prototype.toString = function() {
|
|
return this.name;
|
|
}, a2.prototype.valueOf = function() {
|
|
return this.value;
|
|
}, a2.instances = /* @__PURE__ */ new Map(), n([z("branch:hiddenStems")], a2.prototype, "hiddenStems", null), n([z("branch:e5")], a2.prototype, "e5", null), n([z("branch:meeting")], a2.prototype, "meeting", null), n([z("branch:punishing")], a2.prototype, "punishing", null), n([z("branch:punishBy")], a2.prototype, "punishBy", null), n([z("branch:conflict")], a2.prototype, "conflict", null), n([z("branch:destroying")], a2.prototype, "destroying", null), n([z("branch:harming")], a2.prototype, "harming", null), a2;
|
|
}(Z), R = function(t2) {
|
|
function a2(e2, n2) {
|
|
var r2 = t2.call(this) || this;
|
|
return r2.value = -1, r2._config = { lang: g.lang }, e2 instanceof a2 ? e2 : (n2 && (r2._config = Object.assign({}, r2._config, n2)), r2.value = P(e2, "stem", r2._config.lang, g), r2);
|
|
}
|
|
return e(a2, t2), a2.getNames = function(t3) {
|
|
return t3 = t3 || g.lang, r([], g.locales[t3].stems, true);
|
|
}, a2.create = function(t3, e2) {
|
|
if (t3 instanceof a2)
|
|
return t3;
|
|
var n2 = (null == e2 ? void 0 : e2.lang) || g.lang;
|
|
t3 = P(t3, "stem", n2, g);
|
|
var r2 = "".concat(t3, ":").concat(n2);
|
|
if (a2.instances.has(r2))
|
|
return a2.instances.get(r2);
|
|
var o2 = new a2(t3, e2);
|
|
return a2.instances.set(r2, o2), o2;
|
|
}, Object.defineProperty(a2.prototype, "name", { get: function() {
|
|
return g.locales[this._config.lang].stems[this.value];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "branchs", { get: function() {
|
|
var t3 = this;
|
|
return g.locales[this._config.lang].branchs.filter(function(e2, n2) {
|
|
return n2 % 2 == t3.value % 2;
|
|
}).map(function(e2) {
|
|
return G.create(e2, t3._config);
|
|
});
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "e5", { get: function() {
|
|
return I.create(Math.floor(this.value / 2), this._config);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(a2.prototype, "trigram8", { get: function() {
|
|
return E.create([7, 0, 4, 3, 2, 5, 1, 5, 7, 0][this.value], this._config);
|
|
}, enumerable: false, configurable: true }), a2.prototype.toString = function() {
|
|
return this.name;
|
|
}, a2.prototype.valueOf = function() {
|
|
return this.value;
|
|
}, a2.instances = /* @__PURE__ */ new Map(), n([z("stem:branchs")], a2.prototype, "branchs", null), n([z("stem:e5")], a2.prototype, "e5", null), a2;
|
|
}(Z), V = function() {
|
|
function t2(t3, e2, n2) {
|
|
if (this.value = -1, this._config = { lang: g.lang }, n2 && (this._config = Object.assign({}, this._config, n2)), "number" == typeof e2 || "string" == typeof e2 || e2 instanceof G) {
|
|
this.stem = R.create(t3, this._config), this.branch = G.create(e2, this._config);
|
|
var r2 = this.stem.valueOf(), a2 = this.branch.valueOf();
|
|
this.value = function(t4, e3) {
|
|
if ((t4 + e3) % 2 != 0)
|
|
throw new Error("Invalid SB value");
|
|
return t4 % 10 + (6 - (e3 >> 1) + (t4 >> 1)) % 6 * 10;
|
|
}(r2, a2);
|
|
} else {
|
|
if ("number" != typeof t3)
|
|
throw new Error("Invalid SB value");
|
|
this.value = t3 % 60;
|
|
r2 = this.value % 10, a2 = this.value % 12;
|
|
this.stem = R.create(r2, this._config), this.branch = G.create(a2, this._config);
|
|
}
|
|
}
|
|
return t2.getNames = function(t3) {
|
|
t3 = t3 || g.lang;
|
|
var e2 = g.locales[t3];
|
|
return new Array(60).fill("").map(function(t4, n2) {
|
|
var r2, a2 = n2 % 10, o2 = n2 % 12;
|
|
return e2.stems[a2] + (null !== (r2 = null == e2 ? void 0 : e2.stemBranchSeparator) && void 0 !== r2 ? r2 : "") + e2.branchs[o2];
|
|
});
|
|
}, t2.create = function(e2, n2) {
|
|
if (e2 instanceof t2)
|
|
return e2;
|
|
var r2 = (null == n2 ? void 0 : n2.lang) || g.lang, a2 = "".concat(e2, ":").concat(r2);
|
|
if (t2.instances.has(a2))
|
|
return t2.instances.get(a2);
|
|
var o2 = new t2(e2, void 0, n2);
|
|
return t2.instances.set(a2, o2), o2;
|
|
}, Object.defineProperty(t2.prototype, "missing", { get: function() {
|
|
var t3 = 2 * (5 - Math.floor(this.value / 10));
|
|
return [G.create(t3, this._config), G.create(t3 + 1, this._config)];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "name", { get: function() {
|
|
var t3, e2 = g.locales[this._config.lang];
|
|
return "".concat(this.stem).concat(null !== (t3 = null == e2 ? void 0 : e2.stemBranchSeparator) && void 0 !== t3 ? t3 : "").concat(this.branch);
|
|
}, enumerable: false, configurable: true }), t2.prototype.toString = function() {
|
|
return this.name;
|
|
}, t2.prototype.valueOf = function() {
|
|
return this.value;
|
|
}, t2.instances = /* @__PURE__ */ new Map(), t2;
|
|
}(), $ = function() {
|
|
function t2(e2, n2) {
|
|
if (this.value = -1, this._config = { changeAgeTerm: g.changeAgeTerm, isUTC: false, lang: g.lang, offset: 0 }, n2 && (this._config = Object.assign({}, this._config, n2)), e2 instanceof Date) {
|
|
var r2 = this._config.isUTC, a2 = S(e2, r2, true), o2 = t2.computeSBYear(a2, this._config), i2 = t2.computeSBMonth(a2, this._config), u2 = t2.computeSBDay(a2, this._config);
|
|
e2 = [o2, i2, u2, t2.computeSBHour(a2, u2, this._config)];
|
|
}
|
|
if (!Array.isArray(e2))
|
|
throw new Error("Invalid Char8");
|
|
this._list = e2, this.value = t2.computeValue(e2);
|
|
}
|
|
return t2.prototype.getConfig = function() {
|
|
return Object.assign({}, this._config);
|
|
}, Object.defineProperty(t2.prototype, "list", { get: function() {
|
|
return this._list;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "year", { get: function() {
|
|
return this._list[0];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "month", { get: function() {
|
|
return this._list[1];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "day", { get: function() {
|
|
return this._list[2];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "hour", { get: function() {
|
|
return this._list[3];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "me", { get: function() {
|
|
return this._list[2].stem;
|
|
}, enumerable: false, configurable: true }), t2.computeValue = function(t3) {
|
|
for (var e2 = 0, n2 = 0; n2 < 4; n2++)
|
|
e2 += t3[n2].valueOf() * Math.pow(10, 2 * (3 - n2));
|
|
return e2;
|
|
}, t2.computeSBYear = function(t3, e2) {
|
|
var n2 = e2 && void 0 !== e2.changeAgeTerm ? e2.changeAgeTerm : g.changeAgeTerm, r2 = e2 && e2.isUTC, a2 = "number" != typeof t3 ? L(t3, "FullYear", r2) : t3;
|
|
if (null != n2 && "number" != typeof t3) {
|
|
var o2 = (n2 %= 24) < 0;
|
|
n2 = n2 >= 0 ? n2 : 24 + n2;
|
|
var i2 = L(t3, "FullYear", r2);
|
|
o2 && i2--;
|
|
var u2 = i2 + 1, c2 = F.findDate(i2, n2), s2 = F.findDate(u2, n2), l2 = O("".concat(c2[0], "-").concat(c2[1], "-").concat(c2[2] - 1, " 23:00:00")), f2 = O("".concat(s2[0], "-").concat(s2[1], "-").concat(s2[2] - 1, " 23:00:00"));
|
|
t3.valueOf() < l2.valueOf() ? a2-- : t3.valueOf() >= f2.valueOf() && a2++;
|
|
} else if (null === n2 && "number" != typeof t3) {
|
|
var h2 = B.getLunarNewYearDay(a2);
|
|
t3.valueOf() < h2.valueOf() - 36e5 && a2--;
|
|
}
|
|
return new V((a2 - 4) % 10, (a2 - 4) % 12, e2);
|
|
}, t2.computeSBMonth = function(t3, e2) {
|
|
var n2, r2 = e2 && void 0 !== e2.lang ? e2.lang : g.lang, a2 = e2 && void 0 !== e2.changeAgeTerm ? e2.changeAgeTerm : g.changeAgeTerm;
|
|
a2 = a2 || 0;
|
|
var o2 = null !== (n2 = null == e2 ? void 0 : e2.isUTC) && void 0 !== n2 && n2, i2 = { isUTC: o2, lang: r2, returnValue: true, nodeFlag: (a2 + 24) % 2 }, u2 = F.findNode(t3, i2), c2 = u2[0], s2 = u2[1], l2 = j(t3, c2, s2, o2);
|
|
return new V(l2, void 0, { lang: r2 });
|
|
}, t2.computeSBDay = function(t3, e2) {
|
|
var n2 = (null == e2 ? void 0 : e2.isUTC) || false, r2 = (null == e2 ? void 0 : e2.offset) || 0, a2 = n2 ? t3.valueOf() - 60 * r2 * 1e3 : t3.valueOf(), o2 = O("".concat(f[0], "-").concat(f[1], "-").concat(f[2] - 1, " 23:00:00")), i2 = Math.floor((a2 - o2.valueOf()) / 864e5) % 60;
|
|
return i2 < 0 && (i2 += 60), new V(i2, void 0, e2);
|
|
}, t2.computeSBHour = function(e2, n2, r2) {
|
|
var a2 = (null == r2 ? void 0 : r2.isUTC) || false;
|
|
n2 || (n2 = t2.computeSBDay(e2, r2));
|
|
var o2, i2, u2 = L(e2, "Hours", a2), c2 = n2.stem, s2 = (u2 + 1 >> 1) % 12, l2 = (o2 = c2.value, void 0 === (i2 = s2) && (i2 = 0), (o2 % 5 * 2 + i2) % 10);
|
|
return new V(l2, s2, r2);
|
|
}, t2.prototype.toString = function() {
|
|
return "".concat(this.year, " ").concat(this.month, " ").concat(this.day, " ").concat(this.hour);
|
|
}, t2.prototype.valueOf = function() {
|
|
return this.value;
|
|
}, t2;
|
|
}();
|
|
function q(t2, e2, n2) {
|
|
for (var r2 in t2) {
|
|
var a2 = t2[r2], o2 = [];
|
|
if (Array.isArray(a2))
|
|
for (var i2 = 0, u2 = a2; i2 < u2.length; i2++) {
|
|
var c2 = u2[i2];
|
|
o2.push(W(c2, n2));
|
|
}
|
|
else
|
|
o2.push(W(a2, n2));
|
|
e2.has(r2) ? e2.set(r2, (e2.get(r2) || []).concat(o2)) : e2.set(r2, o2);
|
|
}
|
|
return e2;
|
|
}
|
|
function W(t2, e2) {
|
|
var n2 = t2.tag, r2 = { tag: [], name: t2.name };
|
|
return Array.isArray(n2) ? r2.tag = n2.slice() : "string" == typeof n2 && r2.tag.push(n2), Array.isArray(e2) ? r2.tag = r2.tag.concat(e2) : "string" == typeof e2 && r2.tag.push(e2), void 0 !== t2.data && (r2.data = Object.assign({}, t2.data)), r2;
|
|
}
|
|
function J(t2, e2, n2) {
|
|
return void 0 === n2 && (n2 = false), t2.filter(function(t3) {
|
|
if (n2) {
|
|
var r2 = Array.isArray(e2) ? e2 : [e2];
|
|
return !nt(t3.tag, r2);
|
|
}
|
|
return Array.isArray(e2) ? !e2.includes(t3.name) : e2 !== t3.name;
|
|
});
|
|
}
|
|
function K(t2, e2, n2, r2) {
|
|
void 0 === n2 && (n2 = true);
|
|
var a2 = function(e3, r3) {
|
|
if (!t2.has(e3))
|
|
return false;
|
|
var a3 = t2.get(e3);
|
|
if (void 0 === a3)
|
|
return false;
|
|
if (void 0 === r3)
|
|
return t2.delete(e3), false;
|
|
var o3 = J(a3, r3, n2);
|
|
return 0 === o3.length ? t2.delete(e3) : o3.length < a3.length && t2.set(e3, o3), true;
|
|
};
|
|
if (void 0 === r2)
|
|
for (var o2 = 0, i2 = Array.from(t2.keys()); o2 < i2.length; o2++) {
|
|
a2(i2[o2], e2);
|
|
}
|
|
else if (Array.isArray(r2))
|
|
for (var u2 = 0, c2 = r2; u2 < c2.length; u2++) {
|
|
a2(c2[u2], e2);
|
|
}
|
|
else
|
|
a2(r2, e2);
|
|
}
|
|
function Q(t2, e2, n2) {
|
|
void 0 === n2 && (n2 = true), function(t3, e3, n3) {
|
|
void 0 === n3 && (n3 = true);
|
|
for (var r2 = t3.formatList, a2 = t3.formatMap, o2 = [], i2 = 0, u2 = r2; i2 < u2.length; i2++) {
|
|
var c2 = u2[i2];
|
|
X(a2, c2, e3, n3) && o2.push(c2);
|
|
}
|
|
o2.length !== r2.length && (t3.formatList = o2);
|
|
}(t2, e2, n2), tt(t2, e2, n2);
|
|
}
|
|
function X(t2, e2, n2, r2, a2) {
|
|
if (void 0 === r2 && (r2 = true), t2.has(e2)) {
|
|
var o2 = t2.get(e2);
|
|
if (void 0 === o2)
|
|
return false;
|
|
if (K(o2, n2, r2, a2), 0 !== o2.size)
|
|
return true;
|
|
t2.delete(e2);
|
|
}
|
|
return false;
|
|
}
|
|
function tt(t2, e2, n2, r2) {
|
|
void 0 === n2 && (n2 = true);
|
|
for (var a2 = t2.fnList, o2 = [], i2 = 0, u2 = a2; i2 < u2.length; i2++) {
|
|
var c2 = u2[i2], s2 = c2.fn, l2 = c2.markers;
|
|
K(l2, e2, n2, r2), l2.size > 0 && o2.push({ fn: s2, markers: l2 });
|
|
}
|
|
o2.length !== a2.length && (t2.fnList = o2);
|
|
}
|
|
function et(t2, e2, n2) {
|
|
var r2 = t2.formatMap;
|
|
if (!r2.has(e2))
|
|
return null;
|
|
var a2 = r2.get(e2);
|
|
if (void 0 === a2)
|
|
return null;
|
|
if (!a2.has(n2))
|
|
return null;
|
|
var o2 = a2.get(n2);
|
|
return void 0 === o2 ? null : o2;
|
|
}
|
|
function nt(t2, e2) {
|
|
for (var n2 = 0; n2 < e2.length; n2++)
|
|
if (t2.includes(e2[n2]))
|
|
return true;
|
|
return false;
|
|
}
|
|
function rt(t2, e2) {
|
|
for (var n2 in t2) {
|
|
var r2 = t2[n2], a2 = e2[n2];
|
|
if ("tag" === n2) {
|
|
if (Array.isArray(r2)) {
|
|
if (!Array.isArray(a2))
|
|
return false;
|
|
if (!nt(r2, a2))
|
|
return false;
|
|
} else if (Array.isArray(a2) && !a2.includes(r2))
|
|
return false;
|
|
} else if ("object" == typeof r2 && "object" == typeof a2) {
|
|
if (!rt(r2, a2))
|
|
return false;
|
|
} else if (r2 !== a2)
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
var at = function() {
|
|
function t2(t3) {
|
|
this._list = null, this.storeMarkers = [], this.storeMarkersFromGlobal = [], this.lsr = t3, this.init();
|
|
}
|
|
return t2.add = function(e2, n2) {
|
|
return function(t3, e3, n3) {
|
|
for (var r2 = 0, a2 = e3; r2 < a2.length; r2++) {
|
|
var o2 = a2[r2], i2 = o2.format, u2 = o2.markers;
|
|
if ("string" == typeof i2) {
|
|
var c2 = void 0;
|
|
t3.formatMap.has(i2) ? c2 = t3.formatMap.get(i2) : t3.formatList.push(i2), void 0 === c2 && (c2 = /* @__PURE__ */ new Map()), q(u2, c2, n3), t3.formatMap.set(i2, c2);
|
|
} else if ("function" == typeof i2) {
|
|
var s2 = /* @__PURE__ */ new Map();
|
|
q(u2, s2, n3), t3.fnList.push({ fn: i2, markers: s2 });
|
|
}
|
|
}
|
|
}(t2.store, e2, n2), t2;
|
|
}, t2.clean = function() {
|
|
return t2.store.formatList = [], t2.store.formatMap = /* @__PURE__ */ new Map(), t2.store.fnList = [], t2;
|
|
}, t2.cleanFnList = function() {
|
|
return t2.store.fnList = [], t2;
|
|
}, t2.remove = function(e2, n2, r2) {
|
|
return function(t3, e3, n3, r3) {
|
|
if (true === e3)
|
|
tt(t3, r3, false, n3);
|
|
else {
|
|
var a2 = t3.formatList, o2 = t3.formatMap;
|
|
X(o2, e3, r3, false, n3), o2.has(e3) || (t3.formatList = a2.filter(function(t4, n4) {
|
|
return t4 !== e3;
|
|
}));
|
|
}
|
|
}(t2.store, e2, n2, r2), t2;
|
|
}, t2.removeByTag = function(e2) {
|
|
return Q(t2.store, e2, true), t2;
|
|
}, t2.removeByName = function(e2) {
|
|
return Q(t2.store, e2, false), t2;
|
|
}, t2.prototype.init = function() {
|
|
for (var e2, n2 = [], a2 = t2.store, o2 = 0, i2 = a2.formatList; o2 < i2.length; o2++) {
|
|
var u2 = i2[o2], c2 = et(a2, u2, this.lsr.format(u2));
|
|
c2 && n2.push(c2);
|
|
}
|
|
(e2 = this.storeMarkersFromGlobal).splice.apply(e2, r([0, this.storeMarkersFromGlobal.length], n2.flat(), false));
|
|
}, t2.prototype.add = function(t3, e2) {
|
|
if (this._list = null, Array.isArray(t3))
|
|
for (var n2 = 0, r2 = t3; n2 < r2.length; n2++) {
|
|
var a2 = r2[n2];
|
|
this.add(a2, e2);
|
|
}
|
|
else {
|
|
var o2 = W(t3, e2);
|
|
this.storeMarkers.push(o2);
|
|
}
|
|
return this;
|
|
}, t2.prototype.remove = function(t3, e2, n2) {
|
|
return void 0 === e2 && (e2 = false), void 0 === n2 && (n2 = 0), this._list = null, 0 !== n2 && 1 !== n2 || (this.storeMarkersFromGlobal = J(this.storeMarkersFromGlobal, t3, e2)), 0 !== n2 && 2 !== n2 || (this.storeMarkers = J(this.storeMarkers, t3, e2)), this;
|
|
}, t2.prototype.clean = function(t3) {
|
|
return void 0 === t3 && (t3 = 0), this._list = null, 0 !== t3 && 1 !== t3 || (this.storeMarkersFromGlobal = []), 0 !== t3 && 2 !== t3 || (this.storeMarkers = []), this;
|
|
}, t2.prototype.reset = function() {
|
|
return this._list = null, this.clean(0), this.init(), this;
|
|
}, t2.prototype[Symbol.iterator] = function() {
|
|
var t3 = 0, e2 = this.list;
|
|
return { next: function() {
|
|
return t3 < e2.length ? { value: e2[t3++], done: false } : { value: void 0, done: true };
|
|
} };
|
|
}, Object.defineProperty(t2.prototype, "list", { get: function() {
|
|
return null == this._list && (this._list = r(r([], this.storeMarkersFromGlobal, true), this.storeMarkers, true)), this._list;
|
|
}, enumerable: false, configurable: true }), t2.prototype.filter = function(t3) {
|
|
return "function" == typeof t3 ? this.list.filter(t3) : "object" == typeof t3 ? this.list.filter(function(e2) {
|
|
return rt(t3, e2);
|
|
}) : [];
|
|
}, t2.prototype.find = function(t3) {
|
|
return "function" == typeof t3 ? this.list.find(t3) : "object" == typeof t3 ? this.list.find(function(e2) {
|
|
return rt(t3, e2);
|
|
}) : void 0;
|
|
}, t2.prototype.toString = function() {
|
|
return this.list.map(function(t3) {
|
|
return t3.name;
|
|
}).join(",");
|
|
}, t2.store = { formatList: [], formatMap: /* @__PURE__ */ new Map(), fnList: [] }, t2;
|
|
}(), ot = function(t2) {
|
|
function r2(e2, n2) {
|
|
var r3 = t2.call(this) || this;
|
|
r3._config = Object.assign({ extra: {} }, g, n2);
|
|
var a2 = r3._config, o2 = a2.isUTC, i2 = a2.offset, u2 = O(e2, o2);
|
|
0 !== i2 && u2.setMinutes(u2.getMinutes() + i2);
|
|
var c2 = -1 * O(e2).getTimezoneOffset();
|
|
return r3._config.extra.localTimezoneOffset = c2, r3._date = u2, r3._offset = i2, r3;
|
|
}
|
|
return e(r2, t2), Object.defineProperty(r2.prototype, "lunisolar", { get: function() {
|
|
return gt;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "year", { get: function() {
|
|
return L(this._date, "FullYear", this.isUTC());
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "month", { get: function() {
|
|
return L(this._date, "Month", this.isUTC()) + 1;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "day", { get: function() {
|
|
return L(this._date, "Date", this.isUTC());
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "dayOfWeek", { get: function() {
|
|
return L(this._date, "Day", this.isUTC());
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "hour", { get: function() {
|
|
return L(this._date, "Hours", this.isUTC());
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "minute", { get: function() {
|
|
return L(this._date, "Minutes", this.isUTC());
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "second", { get: function() {
|
|
return L(this._date, "Seconds", this.isUTC());
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "millis", { get: function() {
|
|
return L(this._date, "Milliseconds", this.isUTC());
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "lunar", { get: function() {
|
|
return new B(this._date, { lang: this._config.lang, isUTC: this.isUTC() });
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "char8", { get: function() {
|
|
var t3 = { lang: this._config.lang, changeAgeTerm: this._config.changeAgeTerm, isUTC: this.isUTC(), offset: this._offset };
|
|
return new $(this._date, t3);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "markers", { get: function() {
|
|
return new at(this);
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(r2.prototype, "solarTerm", { get: function() {
|
|
var t3 = this.year;
|
|
if (t3 < p || t3 > v)
|
|
throw new Error("".concat(t3, " is not in the allowed time range."));
|
|
var e2 = this.month, n2 = this.day, r3 = F.getMonthTerms(t3, e2), a2 = r3[0], o2 = r3[1], i2 = { lang: this._config.lang };
|
|
return n2 === a2 ? new F(2 * (e2 - 1), i2) : n2 === o2 ? new F(2 * (e2 - 1) + 1, i2) : null;
|
|
}, enumerable: false, configurable: true }), r2.prototype.recentSolarTerm = function(t3) {
|
|
return F.findNode(this._date, { lang: this._config.lang, nodeFlag: t3, returnValue: false });
|
|
}, r2.prototype.getMonthBuilder = function(t3) {
|
|
void 0 === t3 && (t3 = 0);
|
|
var e2 = { lang: this.getConfig("lang") }, n2 = this.recentSolarTerm(t3), r3 = n2[0], a2 = n2[1], o2 = j(this.toDate(), r3.value, a2);
|
|
return [new V(o2, void 0, e2), r3, a2];
|
|
}, r2.prototype.getSeasonIndex = function() {
|
|
var t3 = this.recentSolarTerm(0)[0].value;
|
|
return 2 <= t3 && t3 < 8 ? 0 : 8 <= t3 && t3 < 14 ? 1 : 14 <= t3 && t3 < 20 ? 2 : 3;
|
|
}, r2.prototype.getSeason = function(t3) {
|
|
void 0 === t3 && (t3 = false);
|
|
var e2 = this.getSeasonIndex(), n2 = this.getLocale();
|
|
return t3 && n2.seasonShortName ? n2.seasonShortName[e2] : n2.seasonName[e2];
|
|
}, r2.prototype.getLocale = function(t3) {
|
|
return g.locales[null != t3 ? t3 : this._config.lang];
|
|
}, r2.prototype.L = function(t3) {
|
|
return function(t4, e2) {
|
|
for (var n2 = e2.split("."), r3 = t4, a2 = e2, o2 = function(t5) {
|
|
return ("string" == typeof t5 || "number" == typeof t5 || "function" == typeof t5) && (a2 = t5, true);
|
|
}; n2.length >= 0 && !o2(r3) && 0 !== n2.length; ) {
|
|
var i2 = n2.shift();
|
|
if (void 0 === i2)
|
|
return "";
|
|
if (Array.isArray(r3)) {
|
|
var u2 = Number(i2);
|
|
if (isNaN(u2) || u2 >= r3.length)
|
|
return "";
|
|
r3 = r3[u2], a2 = r3;
|
|
} else {
|
|
if (!r3.hasOwnProperty(i2))
|
|
return n2[n2.length - 1] || i2;
|
|
r3 = r3[i2];
|
|
}
|
|
}
|
|
return a2;
|
|
}(this.getLocale(), t3);
|
|
}, r2.prototype.getConfig = function(t3) {
|
|
return void 0 === t3 ? this._config : (this._config[t3], this._config[t3]);
|
|
}, r2.prototype.toDate = function() {
|
|
return new Date(this.valueOf());
|
|
}, r2.prototype.clone = function() {
|
|
return new r2(this.valueOf(), this._config);
|
|
}, r2.prototype.unix = function() {
|
|
return Math.floor(this.valueOf() / 1e3);
|
|
}, r2.prototype.valueOf = function() {
|
|
return this._date.valueOf() - 60 * this._offset * 1e3;
|
|
}, r2.prototype.local = function() {
|
|
var t3 = Object.assign({}, this._config, { isUTC: false, offset: 0 });
|
|
return new r2(this.toDate(), t3);
|
|
}, r2.prototype.utc = function() {
|
|
return this.utcOffset(-this._offset);
|
|
}, r2.prototype.isUTC = function() {
|
|
return this._config.isUTC;
|
|
}, r2.prototype.utcOffset = function(t3) {
|
|
if (void 0 === t3)
|
|
return this.isUTC() ? this._offset : (e2 = this._date, 15 * -Math.round(e2.getTimezoneOffset() / 15));
|
|
var e2, n2 = Object.assign({}, this._config, { isUTC: true, offset: Math.abs(t3) <= 16 ? 60 * t3 : t3 });
|
|
return new r2(this._date, n2);
|
|
}, r2.prototype.toISOString = function() {
|
|
return this._date.toISOString();
|
|
}, r2.prototype.toUTCString = function() {
|
|
return this._date.toUTCString();
|
|
}, r2.prototype.toString = function() {
|
|
return this._date.toUTCString() + " (".concat(this.lunar, ")") + " utcOffset: ".concat(this.utcOffset());
|
|
}, r2.prototype.format = function(t3) {
|
|
return k(t3, this);
|
|
}, r2.prototype.diff = function(t3, e2, n2) {
|
|
return void 0 === n2 && (n2 = false), e2 = e2 ? M(e2) : "millisecond", o.has(e2) ? function(t4, e3, n3, r3) {
|
|
var o2 = [t4.lunar, e3.lunar], i2 = o2[1], u2 = [o2[0].year, i2.year], c2 = u2[0], s2 = u2[1], l2 = e3.valueOf() - t4.valueOf();
|
|
if ((n3 = M(n3)) === a.ly) {
|
|
var f2 = s2 - c2;
|
|
return r3 ? f2 - 1 + H(t4, true) + H(e3, false) : f2;
|
|
}
|
|
return n3 === a.lM ? A(t4, e3, r3) : (n3 === a.ld ? l2 /= 864e5 : n3 === a.lh && (l2 /= 72e5), r3 ? l2 : Math.ceil(l2));
|
|
}(this, t3 instanceof r2 ? t3 : new r2(t3, this._config), e2, n2) : function(t4, e3, n3, r3) {
|
|
var o2;
|
|
t4 = (o2 = [O(t4), O(e3)])[0];
|
|
var i2 = (e3 = o2[1]).valueOf() - t4.valueOf();
|
|
n3 = n3 ? M(n3) : "millisecond";
|
|
var u2 = i2;
|
|
return a.s === n3 ? u2 = i2 / 1e3 : a.m === n3 ? u2 = i2 / 6e4 : a.h === n3 ? u2 = i2 / 36e5 : a.d === n3 ? u2 = i2 / 864e5 : a.w === n3 ? u2 = i2 / 6048e5 : a.M === n3 ? u2 = C(t4, e3) : a.y === n3 ? u2 = C(t4, e3) / 12 : a.q === n3 && (u2 = C(t4, e3) / 3), r3 ? u2 : parseInt(String(u2));
|
|
}(this._date, t3, e2, n2);
|
|
}, r2.prototype.add = function(t3, e2) {
|
|
var n2 = function(t4, e3, n3) {
|
|
var r3 = (t4 = O(t4)).getFullYear(), o2 = t4.getMonth() + 1, i2 = e3;
|
|
if ((n3 = n3 ? M(n3) : "millisecond") === a.d || n3 === a.ld)
|
|
i2 = 24 * e3 * 60 * 60 * 1e3;
|
|
else if (n3 === a.h)
|
|
i2 = 60 * e3 * 60 * 1e3;
|
|
else if (n3 === a.m)
|
|
i2 = 60 * e3 * 1e3;
|
|
else if (n3 === a.s)
|
|
i2 = 1e3 * e3;
|
|
else {
|
|
if (n3 === a.M)
|
|
return new Date(t4.setMonth(o2 - 1 + e3));
|
|
if (n3 === a.y)
|
|
return new Date(t4.setFullYear(r3 + e3));
|
|
}
|
|
return new Date(t4.valueOf() + i2);
|
|
}(this.toDate(), t3, e2);
|
|
return new r2(n2, this.getConfig());
|
|
}, n([z("lunisolar:lunar")], r2.prototype, "lunar", null), n([z("lunisolar:char8")], r2.prototype, "char8", null), n([z("lunisolar:markers")], r2.prototype, "markers", null), n([z("lunisolar:solarTerm")], r2.prototype, "solarTerm", null), n([z("lunisolar:recentSolarTerm", true)], r2.prototype, "recentSolarTerm", null), n([z("lunisolar:getMonthBuilder", true)], r2.prototype, "getMonthBuilder", null), r2;
|
|
}(Z), it = [5, 7, 11, 13, -1, -2, 17, 19, 23, 1], ut = [4, 6, 0, 7], ct = [1, 1, 8, 8, 8, 3, 3, 3, 4, 4, 4, 9, 9, 9, 2, 2, 2, 7, 7, 7, 6, 6, 6, 1], st = /* @__PURE__ */ new Map(), lt = function(t2) {
|
|
void 0 === t2 && (t2 = "zh");
|
|
var e2 = "direction24List:".concat(t2);
|
|
if (st.has(e2))
|
|
return st.get(e2);
|
|
var n2 = { lang: t2 }, r2 = [G.create(0, n2), R.create(9, n2), G.create(1, n2), E.create(4, n2), G.create(2, n2), R.create(0, n2), G.create(3, n2), R.create(1, n2), G.create(4, n2), E.create(6, n2), G.create(5, n2), R.create(2, n2), G.create(6, n2), R.create(3, n2), G.create(7, n2), E.create(0, n2), G.create(8, n2), R.create(6, n2), G.create(9, n2), R.create(7, n2), G.create(10, n2), E.create(7, n2), G.create(11, n2), R.create(8, n2)];
|
|
return st.set(e2, r2), r2;
|
|
};
|
|
function ft(t2) {
|
|
if ("number" == typeof t2)
|
|
return t2;
|
|
var e2 = t2.constructor.name, n2 = t2.value;
|
|
if ("Stem" === e2)
|
|
t2 = it[n2];
|
|
else if ("Branch" === e2)
|
|
t2 = 2 * n2;
|
|
else {
|
|
if ("Trigram8" !== e2)
|
|
throw new Error("Invalid direction24 value");
|
|
var r2 = ut.indexOf(n2);
|
|
if (-1 === r2)
|
|
throw new Error("Invalid direction24 value");
|
|
t2 = 3 * (2 * r2 + 1);
|
|
}
|
|
return t2;
|
|
}
|
|
var ht = function() {
|
|
function t2(t3, e2) {
|
|
this._config = { lang: g.lang };
|
|
var n2 = ft(t3);
|
|
this.value = n2;
|
|
var r2 = (null == e2 ? void 0 : e2.lang) || g.lang, a2 = lt(r2);
|
|
this._sign = -1 === n2 ? R.create(4, e2) : -1 === n2 ? R.create(5, e2) : a2[n2 % 24];
|
|
}
|
|
return t2.create = function(e2, n2) {
|
|
var r2 = ft(e2), a2 = (null == n2 ? void 0 : n2.lang) || "zh", o2 = "".concat(r2, ":").concat(a2);
|
|
if (t2.instances.has(o2))
|
|
return t2.instances.get(o2);
|
|
var i2 = new t2(r2, n2);
|
|
return t2.instances.set(o2, i2), i2;
|
|
}, t2.createFromAngle = function(e2, n2) {
|
|
var r2 = Math.round(e2 % 360 / 15);
|
|
return t2.create(r2, n2);
|
|
}, t2.getNames = function(t3) {
|
|
return t3 = t3 || g.lang, lt(t3).map(function(t4) {
|
|
return t4.name;
|
|
});
|
|
}, Object.defineProperty(t2.prototype, "sign", { get: function() {
|
|
return this._sign;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "name", { get: function() {
|
|
return this._sign.toString();
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "type", { get: function() {
|
|
return this._sign.constructor.name;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "angle", { get: function() {
|
|
return this.value > 0 ? 15 * this.value : NaN;
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "direction", { get: function() {
|
|
return g.locales[this._config.lang].directions[this.directionIndex];
|
|
}, enumerable: false, configurable: true }), Object.defineProperty(t2.prototype, "directionIndex", { get: function() {
|
|
return this.value < 0 ? 5 : ct[this.value];
|
|
}, enumerable: false, configurable: true }), t2.prototype.toString = function() {
|
|
return this._sign.toString();
|
|
}, t2.prototype.valueOf = function() {
|
|
return this.value;
|
|
}, t2.instances = /* @__PURE__ */ new Map(), t2;
|
|
}();
|
|
function gt(t2, e2) {
|
|
return new ot(t2, e2);
|
|
}
|
|
gt.utc = function(t2, e2) {
|
|
return new ot(t2, Object.assign({}, e2, { isUTC: true }));
|
|
}, gt.Lunar = B, gt.SolarTerm = F, gt.Char8 = $, gt.SB = V, gt.Stem = R, gt.Branch = G, gt.Element5 = I, gt.Lunisolar = ot, gt.Trigram8 = E, gt.Direction24 = ht, gt.fromLunar = function(t2, e2) {
|
|
var n2 = D(t2, null == e2 ? void 0 : e2.lang);
|
|
return new ot(n2, e2);
|
|
}, gt.config = function(t2) {
|
|
return t2 ? (Object.assign(g, t2), gt) : gt;
|
|
}, gt.extend = function(t2, e2) {
|
|
return t2.$once || (t2(e2, ot, gt), t2.$once = true), gt;
|
|
}, gt.locale = function(t2, e2) {
|
|
if (void 0 === e2 && (e2 = false), Array.isArray(t2)) {
|
|
for (var n2 = 0, r2 = t2; n2 < r2.length; n2++) {
|
|
var a2 = r2[n2];
|
|
gt.locale(a2, e2);
|
|
}
|
|
return gt;
|
|
}
|
|
return t2 && t2.name ? (g.locales[t2.name] = Object.assign({}, g.locales[t2.name], h, t2), e2 || (g.lang = t2.name), e2 && "zh" !== g.lang && (g.locales[g.lang] = Object.assign({}, g.locales.zh, g.locales[g.lang])), gt) : gt;
|
|
}, gt.getLocale = function(t2) {
|
|
return g.locales[t2];
|
|
}, gt.defineLocale = function(t2) {
|
|
return t2;
|
|
}, gt.Markers = at, gt._globalConfig = g, Object.defineProperty(gt, "_globalConfig", { writable: false });
|
|
exports._export_sfc = _export_sfc;
|
|
exports.computed$1 = computed$1;
|
|
exports.createPersistedState = createPersistedState;
|
|
exports.createPinia = createPinia;
|
|
exports.createSSRApp = createSSRApp;
|
|
exports.defineComponent = defineComponent;
|
|
exports.defineStore = defineStore;
|
|
exports.e = e$1;
|
|
exports.f = f$1;
|
|
exports.getCurrentInstance = getCurrentInstance;
|
|
exports.gt = gt;
|
|
exports.index = index;
|
|
exports.inject = inject;
|
|
exports.isRef = isRef;
|
|
exports.n = n$1;
|
|
exports.nextTick = nextTick;
|
|
exports.o = o$1;
|
|
exports.onBeforeMount = onBeforeMount;
|
|
exports.onHide = onHide;
|
|
exports.onLaunch = onLaunch;
|
|
exports.onLoad = onLoad;
|
|
exports.onMounted = onMounted;
|
|
exports.onShow = onShow;
|
|
exports.onUnmounted = onUnmounted;
|
|
exports.p = p$1;
|
|
exports.provide = provide;
|
|
exports.r = r$1;
|
|
exports.reactive = reactive;
|
|
exports.ref = ref;
|
|
exports.resolveComponent = resolveComponent;
|
|
exports.s = s$1;
|
|
exports.storeToRefs = storeToRefs;
|
|
exports.t = t$1;
|
|
exports.textEncodingShim = textEncodingShim;
|
|
exports.unref = unref;
|
|
exports.useMessage = useMessage;
|
|
exports.useSlots = useSlots;
|
|
exports.useToast = useToast;
|
|
exports.watch = watch;
|